serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
20,801 | #include <iostream>
#include <math.h>
#include <stdio.h>
__global__ void add(int n, float *x, float *y) {
int index = threadIdx.x;
int stride = blockDim.x;
for (int i = index; i < n; i += stride)
y[i] = x[i] + y[i];
}
void FillWithData(int n, float* x, float* y) {
for (int i = 0; i < n; i++) {
x[i] ... |
20,802 | #include <stdio.h>
int main()
{
/*
* Device ID is required first to query the device.
*/
int deviceId;
cudaGetDevice(&deviceId);
cudaDeviceProp props;
cudaGetDeviceProperties(&props, deviceId);
/*
* `props` now contains several properties about the current device.
*/
int computeCapability... |
20,803 | #include "includes.h"
__global__ void get_average(unsigned char * img, int * nz, int * average, int scale)
{
int x = blockIdx.x * TILE_DIM + threadIdx.x;
int y = blockIdx.y * TILE_DIM + threadIdx.y;
int width = gridDim.x * TILE_DIM;
//int h = width /2;
for (int j = 0; j < TILE_DIM; j+= BLOCK_ROWS)
{
int iw = x;
int ih... |
20,804 | #include <iostream>
#include <iomanip>
#include <time.h>
#include <cuda_runtime_api.h>
#include <fstream>
using namespace std;
using std::ifstream;
#define BLOCK_SIZE 16
// max 40
// 32
// 25
// 20
// 16
// 10
// 8
// 4
// min 2
// Device multiplication function called by Mul()
// Compute C = A * B
// wA is the widt... |
20,805 | #include <cuda.h>
#include <stdio.h>
__global__
void g_scalar_mult(float* a, float* b)
{
a[threadIdx.x] *= *b;
}
float* scalar_mult(const float scaler,
const float* vect,
unsigned int size)
{
float* cuda_vect;
float* cuda_scal;
float* answer;
answer = (float*)malloc(size * sizeof(fl... |
20,806 | #include "includes.h"
__global__ void swan_fast_fill_word( uint *ptr, int len ) {
int idx = threadIdx.x + blockDim.x * blockIdx.x;
if( idx<len) {
ptr[idx] = 0;
}
} |
20,807 | #include "includes.h"
__global__ void sum(int *a, int *b, int *c) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
while (i < N) {
c[i] = a[i] + b[i];
i += gridDim.x * blockDim.x;
}
} |
20,808 | /***************************************************************************//**
* \file L.cu
* \author Christopher Minar (minarc@oregonstate.edu)
* \brief kernels to calculate the diffusion terms
*/
#include "L.h"
namespace kernels
{
/*
* calculates explicit diffusion terms in the middle of the domain
* para... |
20,809 | #include <cuda.h>
#include <cuda_runtime.h>
#define BLOCKSIZE 1024
__device__ float sigmoid(float x) {
return 1.0/(1+expf(-x));
}
__global__ void gelu_fwd_cuda(float* input, float* ret,
int64_t size) {
int64_t idx = threadIdx.x + blockIdx.x*blockDim.x;
if(idx < size) {
... |
20,810 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <curand_kernel.h>
#include <math_constants.h>
extern "C"
{
__global__ void
rtruncnorm_kernel(float *vals, int n,
float *mu, float *sigma,
float *lo, float *hi,
int mu_len, int sigma_len,
... |
20,811 |
#include "device.cuh"
__global__
void fill_array(double *d_A){
for (int i=0; i<1000; i++){
d_A[i] = i;
}
}
__global__
void fill_c_array(thrust::complex<double> *d_A){
for (int i=0; i<1000; i++){
d_A[i] = i;
}
}
thrust::device_vector<thrust::complex<double>> d_vec_A;
void get_cuda_array_ptr(double **array... |
20,812 | #include <stdio.h>
#include <math.h>
#include <malloc.h>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
//#define M 12
double* polyfit(double* x, double* y, int n, int M)
{
int m;
m = n + 1;
double **a = (double **)malloc(sizeof(double*)*m);
for (int i = 0; i < m; i++)
{
a[i] = (double*)malloc(... |
20,813 | #include "includes.h"
__global__ void dev_get_gravity_at_point( float eps2, float *eps, float *xh, float *yh, float *zh, float *xt, float *yt, float *zt, float *ax, float *ay, float *az, int n, float *field_m, float *fxh, float *fyh, float *fzh, float *fxt, float *fyt, float *fzt, int n_field) {
float dx, dy, dz, r2, t... |
20,814 | #include <stdio.h>
#include <stdlib.h>
// Matrices are stored in row-major order:
// M(row, col) = *(M.elements + row * M.width + col)
typedef struct
{
int width;
int height;
float *elements;
} Matrix;
// Thread block size
#define BLOCK_SIZE 16
// Forward declaration of the matrix multiplication kernel
_... |
20,815 | extern "C"
__global__ void add(int n, float *a, float *b, float *sum)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i<n)
{
sum[i] = a[i] + b[i];
}
}
|
20,816 | #define NTHREADS 16
__global__ void scale(float knot_max, int nx, int nsamples,
float * x, int pitch_x)
{
int
col_idx = blockDim.x * blockIdx.x + threadIdx.x;
if(col_idx >= nx) return;
float
min, max,
* col = x + col_idx * pitch_x;
// find the min and the max
min = max = ... |
20,817 | #include <cuda.h>
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
int main() {
int driver_version = 0, runtime_version = 0;
cudaDriverGetVersion(&driver_version);
cudaRuntimeGetVersion(&runtime_version);
printf("Driver Version: %d\n Runtime Version: %d\n", \
driver_version,... |
20,818 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define SIZE 50000
void printArr( int arr[], int n )
{
int i;
for ( i = 0; i < n; ++i )
printf( "%d ", arr[i] );
}
__device__ int d_size;
__global__ void partition (int *arr, int *arr_l, int *arr_h, int n)
{
int z = blockIdx.x*blockDim.x+thr... |
20,819 | #include <stdio.h>
__global__ void onetoten() {
__shared__ unsigned int n;
n = 0;
__syncthreads();
while (n < 10) {
int oldn = atomicInc(&n, 100);
if (oldn % 3 == threadIdx.x) {
printf("%d: %d\n", threadIdx.x, oldn);
}
}
}
__global__ void onetoten4() {
__shared__ unsigned int n;
n = 0;
__syncthread... |
20,820 | //
// Created by songzeceng on 2020/11/26.
//
#include "stdio.h"
#include "cuda_runtime.h"
#define N 64
#define TPB 32
__device__ float scale(int i, int n) {
return ((float ) i) / (n - 1);
}
__device__ float distance(float x1, float x2) {
return sqrt((x2 - x1) * (x2 - x1));
}
__global__ void distanceKernel(... |
20,821 | #include "includes.h"
__global__ void add(int *a, int *b, int *c)
{
//blockIdx is the value of the block index for whichever block is running the code
int tid = blockIdx.x;//handle the data at this index
//blockIdx has 2 dimensions; x and y. We only need one dimension
if(tid < N)
c[tid] = a[tid] + b[tid];
} |
20,822 | #include "includes.h"
__global__ void sobelFilterShared3(unsigned char* g_DataIn, unsigned char * g_DataOut, unsigned int width, unsigned int height){
__shared__ char sharedMem[BLOCK_HEIGHT*BLOCK_WIDTH];
int x = blockIdx.x * TILE_WIDTH + threadIdx.x - FILTER_RADIUS;
int y = blockIdx.y * TILE_HEIGHT + threadIdx.y - FIL... |
20,823 | /*
29/12/2019
hmhuan-1612858
nnkhai-1612909
*/
#include <stdio.h>
#include <stdint.h>
#include <thrust/device_vector.h>
#include <thrust/copy.h>
#include <thrust/sort.h>
#define CHECK(call) \
{ ... |
20,824 | #include <cuda.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <float.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <string>
#include <algorithm>
/***all macros**/
#define E_INIT 5 // in joules
#define E_ELEC 50e-9 ... |
20,825 | #include <cstdlib>
#include <cstdio>
#include <cuda.h>
using namespace std;
/*
__global__ void mykernel(void) {
}
int main(void) {
mykernel<<<1,1>>>();
printf("CPU Hello World!\n");
return 0;
}
*/
#define N 10000000
void vector_add(float *out, float *a, float *b, int n) {
for(int i = 0; i < n; i+... |
20,826 | /***************************************************************************//**
* \file intermediateVelocity.cu
* \author Christopher Minar (minarc@oregonstate.edu)
* \brief kernels to generate the right hand side for the initial velocity solve
*/
#include "intermediateVelocity.h"
/**
* \namespace kernels
* \... |
20,827 | #include "math.h"
#include <iostream>
const int ARRAY_SIZE = 1000;
using namespace std;
__global__ void increment(double *aArray, double val, unsigned int sz) {
unsigned int indx = blockIdx.x * blockDim.x + threadIdx.x;
if (indx < sz)
aArray[indx] += val;
}
int main(int argc, char **argv) {
double *hA;
d... |
20,828 | #include "includes.h"
__global__ void calc(float *d_D, int n, int k){ //kernel (4 cells for every thread)
__shared__ float s_d[4*3*256]; //Shared table within a block
int i = blockIdx.x * blockDim.x + threadIdx.x; //Calculation of i and j
int j = blockIdx.y * blockDim.y + threadIdx.y;
int b_index = 4 * 3 * (threadIdx.... |
20,829 | // ###
// ###
// ### Practical Course: GPU Programming in Computer Vision
// ###
// ###
// ### Technical University Munich, Computer Vision Group
// ### Summer Semester 2015, September 7 - October 6
// ###
// ###
// ### Thomas Moellenhoff, Robert Maier, Caner Hazirbas
// ###
// ###
// ###
// ### THIS FILE IS SUPPOSED T... |
20,830 | #include <cuComplex.h>
#include <cuda.h>
#include <cuda_runtime.h>
__global__ void
remove_cp(cuFloatComplex* in, cuFloatComplex* out, int symlen, int cplen, int n)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < n) {
int sym_idx = i / symlen;
int samp_idx = i % symlen;
if (sam... |
20,831 | __global__ void fillKernel(float* array) {
array[threadIdx.x] = threadIdx.x * 0.5;
}
void fillGpuArray(float* array, int count) {
fillKernel<<<1, count>>>(array);
}
|
20,832 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
__global__ void aKernel()
{
int idx = threadIdx.x;
int r1, r2, res_diff;
__shared__ int arr[512];
arr[idx] = idx;
printf("A: Thread %5d, value %5d\n", idx, arr[idx]);
__syncthreads();
r1 = arr[idx];
i... |
20,833 | #include <stdio.h>
__global__ void dumbkernel(bool *input){
// if( input[threadIdx.x] ){
// printf("we made it to dumbkernel\n");
// }
}
#define SZ 25
int main(){
bool *devDummy;
cudaMalloc( (void**) &devDummy, sizeof(bool) * SZ);
dumbkernel<<<1, 32>>>(devDummy);
} |
20,834 | #include "includes.h"
/************************* CudaMat ******************************************
* Copyright (C) 2008-2009 by Rainer Heintzmann *
* heintzmann@gmail.com *
* ... |
20,835 | #include "AntSimple.cuh"
#include <stdio.h>
namespace SIMPLE
{
__device__
Ant::Ant(int initialLocation, int matrixDim, curandState_t randState) :
visitedIndex(0),
isVisited(new bool[matrixDim]),
position(initialLocation),
goodnessNumerators(new double[matrixDim]),
m_randomState(randState)
{
}
__device... |
20,836 | #include "includes.h"
//function declaration
unsigned int getmax(unsigned int *, unsigned int);
//unsigned int getmaxSeq(unsigned int *, unsigned int);
__global__ void getmaxcu(unsigned int* num, int size, int threadCount)
{
__shared__ int localBiggest[32];
if (threadIdx.x==0) {
for (int i = 0; i < 32; i++) {
localBi... |
20,837 |
#include <cuda_runtime.h>
#include <cuda.h>
#include <curand.h>
#include <cuda_runtime_api.h>
#include <device_functions.h>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/sort.h>
#include<sys/time.h>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iostream>... |
20,838 | #define t_max 1
#define t 1
/*
(T[0][0][0][1][0]=((((T[0][0][0][0][0]*((c[0][0][0][0][1]*T[0][0][0][0][0])+c[0][0][0][0][2]))+c[0][0][0][0][3])+((c[0][0][0][0][4]*T[-1][0][0][0][0])+(c[0][0][0][0][5]*T[1][0][0][0][0])))+(((c[0][0][0][0][6]*T[0][-1][0][0][0])+(c[0][0][0][0][7]*T[0][1][0][0][0]))+((c[0][0][0][0][8]*T[0... |
20,839 | /*
* main.cu
*
* Created on: Nov 14, 2019
* Author: cuda-s01
*/
#include <stdio.h>
#include <time.h>
const int TILE_WIDTH = 2;
const int MATRIX_SIZE = 800;
__global__ void matrixMultiplicationKernel(float* M, float* N, float* P, int Width) {
// Calculate the row index of the P element and M
int ... |
20,840 | extern "C" {
__global__ void fill_u8(unsigned char *y, unsigned char elem, unsigned int len) {
int tid = blockIdx.x * blockDim.x + threadIdx.x;
if (tid < len) {
y[tid] = elem;
}
}
__global__ void fill_u32(unsigned int *y, unsigned int elem, unsigned int len) {
in... |
20,841 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#define N (1024 * 64)
__global__ void add(int* a, int* b, int* c)
{
int tid = threadIdx.x + blockIdx.x * blockDim.x;
while (tid < N)
{
c[tid] = a[tid] + b[tid];
tid += blockDim.x * gridDim.x;
}
}
int main()
{
int... |
20,842 | #include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/generate.h>
#include <thrust/reduce.h>
#include <thrust/functional.h>
#include <thrust/random.h>
int my_rand() {
static thrust::default_random_engine rng;
static thrust::uniform_int_distribution<int> dist(0, 9999);
return dist(rng... |
20,843 | #include <cstdio>
#include <cmath>
#define OCCUPIED(board, field) ((board) & (1L<<(field)))
#define ON_BOARD(field) (0 <= (field) && (field) < 64)
#define EVALUATE(p1, p2) ((builtin_popcount(p1))-(builtin_popcount(p2)))
extern "C" {
const int INF = 128;
const int BOARD_SIZE = 8;
const int WARP_SIZE = 32;
const int M... |
20,844 | //xfail:ASSERTION_ERROR
//--blockDim=1024 --gridDim=1
__global__ void foo(int *H) {
size_t tmp = (size_t)H;
tmp += sizeof(int);
int *G = (int *)tmp;
G -= 1;
G[threadIdx.x] = threadIdx.x;
}
|
20,845 | /*
from http://http.developer.nvidia.com/GPUGems3/gpugems3_ch37.html
*/
/*
* Random nubmers on the GPU
*
*
* float RandUniform(unsigned *seeds, unsigned stride); // float, [0.0 1.0)
* unsigned RandUniformui(unsigned *seeds, unsigned stride); // unsigned, [0, RAND_MAX]
* float RandNormal(unsigned *seeds, unsi... |
20,846 | //-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
#include <stdio.h>
#include <time.h>
#include <cuda.h>
const int MIN_SIZE=1280;
const int MAX_SIZE=10000;
const int STEP_SIZE=256;
//----------------------... |
20,847 | /*
* Uloha pro cviceni 3 - CUDA - B4M39GPU (zima 2020/2021):
*
* Napiste kernel, ktery otoci pole celych cisel:
*
* a) pro pripad kdy je vstupni pole i vystupni pole ulozeno v globalni pameti
* -> kernel reverseArrayI(int *devIn, int *devOut)
* pouzijte pouze jednorozmernou mrizku
*
* b) to same ja... |
20,848 | #include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cuda_runtime.h>
#include <sys/time.h>
#include <time.h>
#define NUM_THREADS 743511 // length of calculation
#define BLOCK_SIZE 256 // number of threads per block used in gpu calc
#define EPS 0.00005 // Epsilon for tolerance of d... |
20,849 | #include <iostream>
int main() {
std::cout << "Hello world\n";
return 0;
} |
20,850 | /*
* This program uses the device CURAND API to calculate what
* proportion of pseudo - random ints have low bit set.
*/
# include <stdio.h>
# include <stdlib.h>
# include <cuda.h>
# include "curand_kernel.h"
# include <vector>
# define CUDA_CALL(x) do { if ((x) != cudaSuccess ) { \
printf (" Error at %s:%d\n", __FILE... |
20,851 | #include "cuda_runtime.h"
#include <iostream>
using namespace std;
__global__ void add(int *d_a,int *d_b,int *d_c){
*d_c = *d_a + *d_b;
}
int main(void){
int a, b, c;
int *d_c, *d_b, *d_a;
int size = sizeof(int);
a = 4;
b = 6;
cudaMalloc((void **)&d_a, size);
cudaMalloc((void **)&d_b, size);
cudaMalloc((vo... |
20,852 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
__global__ void add1(int *a, int *b, int *c){
int idx = blockIdx.x;
c[idx] = a[idx] + b[idx];
}
__global__ void add2(int* a, int* b, int* c){
int idx = threadIdx.x;
c[idx] = a[idx] + b[idx];
}... |
20,853 | /*This program implements the CUDA parallel version of matrix multiplication of two square matrices of equal size.
Shared Memory and thread granularity is used for optimizing performance.*/
#include<stdio.h>
#include<stdlib.h>
#include<sys/time.h>
#define TILE_WIDTH 8 /*Block Dimension of TILE_WIDTH x TILE_WIDTH*/
#d... |
20,854 | #include <stdio.h>
int main(void){
int counter, i;
cudaDeviceProp properties;
cudaGetDeviceCount(&counter);
printf("Device count:%d\n", counter);
for(i=0; i<counter; i++){
cudaGetDeviceProperties(&properties, i);
printf("\n\nDEVICE %d: \n",i);
printf("name: %s\ntotalGlobal... |
20,855 | #include "includes.h"
__global__ void detect_edges(unsigned char *input, unsigned char *output) {
int i = (blockIdx.x * 72) + threadIdx.x;
int x, y; // the pixel of interest
int b, d, f, h; // the pixels adjacent to the x,y used to calculate
int r; // the calculation result
y = i / width;;
x = i - (width * y);
if (x ==... |
20,856 | #include <stdio.h>
__global__ void mandelgpu(int disp_width, int disp_height, int *array, int max_iter) {
double scale_real, scale_imag;
double x, y, u, v, u2, v2;
int row,column, iter;
column = threadIdx.y + blockIdx.y*blockDim.y;
row= threadIdx.x + blockIdx.x*blockDim.x;
scale_real... |
20,857 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cuda.h>
#define SIZE 102400
#define MOD 102399
#define STEP 128
/* ARRAY A INITIALIZER */
void init_a(int * a)
{
int i;
for(i=0; i<SIZE; i++)
{
a[i] = 1;
}
}
/* ARRAY B INITIALIZER */
void init_b(int * b)
{
int i, j;
j=0;... |
20,858 | #include <cuda.h>
#include <cuda_runtime.h>
#include <stdio.h>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/inner_product.h>
#include <thrust/reduce.h>
#include <thrust/iterator/constant_iterator.h>
#include <thrust/sort.h>
#include <iostream>
typedef thrust::device_vector<int> in... |
20,859 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#define n 512
__global__ void bmk_add(int *a, int *b, int *result)
{
int i = threadIdx.x;
result[i] = a[i] + b[i];
}
int main()
{
int num_blocks = 1, num_threads = n;
int *a, *b, *c;
int *dev_a, *dev_b, *dev_c;
int size = n * sizeof(int);
a = (int*)m... |
20,860 |
#include <stdio.h>
int main(void) {
// print out important data about the gpu
int nDevices = 0;
cudaGetDeviceCount(&nDevices);
printf("Number of Devices: %d\n", nDevices);
cudaDeviceProp prop;
int i;
for(i = 0; i < nDevices; i++) {
cudaGetDevi... |
20,861 | //#include <omp.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
__global__ void parallel1(int a, int** binaryTree, int** prefixsums)
{
int b = threadIdx.x;
int sum;
sum = binaryTree[a+1][2*b] + binaryTree[a+1][2*b+1];
binaryTree[a][b] = sum;
}
__global__ void parallel2(int a, int** binaryTr... |
20,862 | #include "matrix.cuh"
void Matrix::to_gpu(void)
{
if (!gpu_enabled)
{
gpu_enabled = true;
float* d_matrix;
if (cudaMalloc((void**)&d_matrix, sizeof(float)*dim1*dim2) != cudaSuccess)
throw "memory allocation failed\n";
cudaMemcpy(d_matrix, matrix, sizeof(float)*dim1*dim2, cudaMemcpyHostToDevice);
delete[... |
20,863 | #include<iostream>
#include<vector>
__global__ void matMultiply(float *A, float *B, float *C, int N){
auto i = blockDim.y * blockIdx.y + threadIdx.y;
auto j = blockDim.x * blockIdx.x + threadIdx.x;
// C[i*N+j] = 0.0;
float temp = 0;
for (int k = 0; k < N; k++){
temp += A[i*N+k]*B[k*N+j];
}
C[i*N+j] = temp;... |
20,864 | #include "includes.h"
__global__ void _kgauss32(int mx, int ns, float *xval, int *xrow, int *xcol, float *sval, int *srow, int *scol, float g, float *k) {
// assume x(mx,nd) and s(nd,ns) are in 1-based csc format
// assume k(mx,ns) has been allocated and zeroed out
int s0, s1, sp, sc, sr, x0, x1, xp, xc, xr, k0, k1, kp... |
20,865 | //pass
//--gridDim=64 --blockDim=256
#include "common.h"
#define MERGE_THREADBLOCK_SIZE 256
__global__ void mergeHistogram64Kernel(
uint *d_Histogram,
uint *d_PartialHistograms,
uint histogramCount
)
{
__shared__ uint data[MERGE_THREADBLOCK_SIZE];
uint sum = 0;
for (uint i = t... |
20,866 | /*
* Copyright 1993-2015 NVIDIA Corporation. All rights reserved.
*
* Please refer to the NVIDIA end user license agreement (EULA) associated
* with this source code for terms and conditions that govern your use of
* this software. Any use, reproduction, disclosure, or distribution of
* this software and related... |
20,867 | //
// Created by heidies on 7/7/18.
//
#include <cuda_runtime.h>
#include <iostream>
#include <sys/time.h>
using namespace std;
__global__ void sumMatrixOnGPU2D(float *A, float *B, float *C, const int nx, const int ny){
int ix = blockIdx.x * blockDim.x + threadIdx.x;
int iy = blockIdx.y * blockDim.y + thread... |
20,868 | #include "includes.h"
/***********************************************************
By Huahua Wang, the University of Minnesota, twin cities
***********************************************************/
__global__ void dual( float* err, float* Y, float* X, float* Z, unsigned int size)
{
const unsigned int idx... |
20,869 | #include "includes.h"
__device__ inline float stableSigmoid(float x) {
if(x >= 0) {
float z = expf(-x);
return 1.0 / (1.0 + z);
} else {
float z = expf(x);
return z / (1.0 + z);
}
}
__global__ void gLSTMOutputBackward(float* outCell, float* outXW, float* outSU, float* outB, const float* cell, const float* xW, const flo... |
20,870 | #include "includes.h"
__global__ void cuda_neural_net(float *Weights_D, int num_per_sweeper, int num_per_layer, int num_per_input, int num_per_output, int num_weights, int num_layers, float response, float *inputs_d, float *outputs_d)
{
extern __shared__ float buffer[];
int start_of_weights = blockIdx.x * num_weights... |
20,871 | #include <iostream>
#include <ctime>
#include <cuda.h>
#include <cuda_runtime.h> // Stops underlining of __global__
#include <device_launch_parameters.h> // Stops underlining of threadIdx etc.
using namespace std;
__global__ void FindClosestGPU(float3* points, int* indices, int count)
{
if(count <= 1) return;
int... |
20,872 | #include "includes.h"
__global__ void kAddMultSign(float* a, float* b, unsigned int numEls, float mult) {
const unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x;
const unsigned int numThreads = blockDim.x * gridDim.x;
for (unsigned int i = idx; i < numEls; i += numThreads) {
a[i] = a[i] + ((b[i] > 0) ? mult : (... |
20,873 | __global__ void _add_32_11(int n, float *x, float *y, float *z) {
int i = threadIdx.x + blockIdx.x * blockDim.x;
while (i < n) {
float xi=x[i];
float yi=y[i];
z[i] = xi+yi;
i += blockDim.x * gridDim.x;
}
}
#ifdef __cplusplus
extern "C" {
#endif
void add_32_11(int n, float *x, float *y, float *z)... |
20,874 | //Alfred Shaker
//10-13-2015
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
// CUDA kernel
__global__ void vectorSum(int *a, int *b, int *c, int n)
{
//get the id of global thread
int id = blockIdx.x*blockDim.x+threadIdx.x;
//checks to make sure we're not out of bounds
if(id < n)
c[id] =... |
20,875 | /*
@Author: 3sne ( Mukur Panchani )
@FileName: q3MatrixMul.cu
@Task: CUDA program computes product of two matrices, using different parallelism techniques.
*/
#include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
__global__ void MatMulRowThreads(int *a, int *b, int *c, int m, int n, ... |
20,876 | #include <stdio.h>
#include <cuda.h>
#include <random>
#include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <iostream>
int main(int argc, char *argv[]) {
int n = atol(argv[1]);
// set up random number from -1 to 1 generator
std::random_device entropy_source;
std::mt19937_64 generator(entrop... |
20,877 |
/* This is a automatically generated test. Do not modify */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
__global__
void compute(float comp, int var_1,int var_2,int var_3,float var_4,float var_5,float var_6,float var_7,float var_8,float var_9,float var_10,float var_11,float var_12,float var_13,float var_... |
20,878 | #include<bits/stdc++.h>
using namespace std;
const int MAX_ARRAY_SIZE = 266;
__global__ void stanSum(int N, int *A, int R){
int i = blockIdx.x, j = threadIdx.x, block_size = blockDim.x;
__shared__ int tmp[MAX_ARRAY_SIZE];
assert(MAX_ARRAY_SIZE >= block_size + 2*R);
int gidx = i*block_size + j;
int lidx = R + j;
... |
20,879 |
#include "NA_MathsLib.cuh"
#include <math.h>//used to generate lookup tables when object is constructed
#include <random>
#include <time.h>
const float NA_MathsLib::PI = 3.14f;//this is a stupid compiler rule in my opinion
NA_MathsLib na_maths; //contructs itself, access with extern NA_MathsLib na_maths;
NA_MathsL... |
20,880 | /*
* simple.cu
* includes setup funtion called from "driver" program
* also includes kernel function 'cu_fillArray()'
*/
#include <stdio.h>
#include <stdlib.h>
//#include <string.h>
#define BLOCK_SIZE 32
// The __global__ directive identifies this function as a kernel
// Note: all kernels must be declared with ... |
20,881 | #include "includes.h"
__global__ void UpdateSecond(float *WHAT , float *WITH , float AMOUNT , float *MULT)
{
int idx = threadIdx.x + blockIdx.x * blockDim.x;
WHAT[idx] *=MULT[idx];
WHAT[idx] +=AMOUNT*WITH[idx];
MULT[idx] = 1.0f;
} |
20,882 | #include<iostream>
//#include<stdio.h>
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
__global__ void evalJulia(int *d_pixel,
int *d_temp){
int x_index = threadIdx.x + blockId... |
20,883 | #include <stdio.h>
__global__
void matAddKernel(float *A, float *B, float *C, int n){
int i = threadIdx.x + blockDim.x * blockIdx.x, j;
if(i < n){
for(j = 0; j < n; j++){
C[i+j*n] = A[i+j*n] + B[i+j*n];
}
}
}
void matAdd(float* A, float* B, float* C, int n){
int size = n*n*sizeof(float);
... |
20,884 | #include<stdio.h>
__global__ void evenNum_gpu()
{
//int tid = threadIdx.x;
int tid = threadIdx.x + blockDim.x*blockIdx.x;
if(tid%2==0)
{
printf("Even number: %d\n", tid);
}
}
int main() {
int numUpperBound = 10;
printf("\nEven numbers less than %d (GPU version):\n", numUpperBound);... |
20,885 | #include <stdio.h>
#define NUM 1024
__shared__ int v[NUM];
__global__ void deadlock() {
if (threadIdx.x % 2 == 0) {
v[threadIdx.x]++;
__syncthreads();
}
else {
v[threadIdx.x]--;
//__syncthreads(); // remove this one to incur a barrier dismatch
}
}
int main() {
deadlock<<<1,NUM>>>();
... |
20,886 | #include "stdio.h"
__global__ void add(int a,int b,int *c)
{
*c=a+b;
}
int main()
{
int a,b,c;
int *dev_c;
a=3;b=4;
cudaMalloc((void**)&dev_c,sizeof(int));
add<<<1,1>>> (a,b,dev_c);
cudaMemcpy(&c, dev_c,sizeof(int),cudaMemcpyDeviceToHost);
printf("%d + %d is %d \n",a,b,c);
cudaFree(dev_c);
return 0;
}
|
20,887 | #include <stdio.h>
#include <cuda_runtime.h>
#include <chrono>
#include <iostream>
class GpuTimer {
public:
cudaEvent_t start;
cudaEvent_t stop;
GpuTimer()
{
cudaEventCreate(&start);
cudaEventCreate(&stop);
}
~GpuTimer()
{
cudaEventDestro... |
20,888 | #pragma once
#include <limits>
#include <curand.h>
#include <curand_kernel.h>
#define INF FLT_MAX
#define EPS 1e-8
#define INT_INF INT_MAX
namespace RayTracing
{
float DegreesToRadians(const float degrees);
__host__ __device__
float Clamp(
const float x,
const float xMin,
const float xMax
);
// unif... |
20,889 | //%%cu
/**************************************************************************
C-DAC Tech Workshop : hyPACK-2013
October 15-18, 2013
Objective : Program to solve a solution of Poisson Eq. (PDE) on GPU
Input : No. of Grid Points in X-Dir, No. of Grid Points in Y-Dir
... |
20,890 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#define NUM_THREADS 512
#define OUTPUT_FILE_NAME "q3.txt"
#define NUM_BLOCKS 1
// int* fileToArray(char file1[], int* n){
// FILE* fptr = fopen(file1, "r");
// FILE* fptr_cpy = fptr;
// char* str = (char*) malloc(sizeof(char)*2... |
20,891 | #include <stdio.h>
#include <time.h>
#define TSK 16
#define WPTM 8
#define WPTN 8
#define TSM (TSK * WPTM)
#define TSN (TSK * WPTN)
#define RTSM (TSM/WPTM)
#define RTSN (TSN/WPTN)
#define LPTA (TSK*TSM)
#define LPTB (TSK*TSN)
// Use 2D register blocking (further increase in work per thread)
//C=A*B
__global__ voi... |
20,892 | #include<stdio.h>
#include<math.h>
#include<stdlib.h>
//#include<cuda.h>
#include<unistd.h>
#include<time.h>
/*
for(i=0;i<N/c;i++)
{
for(j=0;j<cols[i];j++)
{
result[i*c+0]+=scval_flat[cs[i]+(j*c)]*vecX[sccol_flat[cs[i]+(j*2)]];
result[i*c+1]+=scval_flat[cs[i]+(j*c)+1]*vecX[sccol_flat[cs[i]+(j*2)+1]];
}
... |
20,893 | #include <math.h>
#include <stdint.h>
#include <stdio.h>
__device__ uint8_t median_pixel(uint8_t *pixels, int stride_H, int stride_W, int size_H, int size_W) {
int hist[256];
for (int i = 0; i < 256; i++) {
hist[i] = 0;
}
for (int i = 0; i < size_H; i++) {
for (int j = 0; j < size_W... |
20,894 | #include "includes.h"
#define TILE_WIDTH 7
__global__ void MatrixMulKernel(float* Md, float* Nd, float* Pd, int Width)
{
__shared__ float Mds[TILE_WIDTH][TILE_WIDTH];
__shared__ float Nds[TILE_WIDTH][TILE_WIDTH];
int bx = blockIdx.x; int by = blockIdx.y;
int tx = threadIdx.x; int ty = threadIdx.y;
//Identify the ro... |
20,895 | #include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <cufft.h>
#include <math.h>
#define BLOCK_SIZE 1024*1024
#define LOOPS 10
// how many loops of block size to do
cudaEvent_t t_start, t_stop;
cufftHandle plan;
__glo... |
20,896 | #include <iostream>
#include <set>
#include "../include/gpu_set.h"
#include <thrust/device_vector.h>
#define def_dvec(t) thrust::device_vector<t>
#define to_ptr(x) thrust::raw_pointer_cast(&x[0])
using namespace std;
const int SET_SIZE = 100;
__global__ void test(int *output){
gpu_set<int, SET_SIZE> set;
for(... |
20,897 | #include<iostream>
#include<string>
#include<cuda.h>
using namespace std;
int main(){
struct cudaDeviceProp prop;
cudaError_t err;
err = cudaGetDeviceProperties(&prop,0);
if(err!=cudaSuccess){
cout<<"Get failed. Exiting."<<endl;
}
else{
cout<<"Name : "<<string(prop.name)<<endl;
cout<<"Total global memor... |
20,898 | #include <math.h>
#include <iostream>
#include <array>
#include <cmath>
#include <cstdint>
#include "cuda_runtime.h"
#include <stdlib.h>
#include <cuda_runtime_api.h>
#include <cuda.h>
using namespace std;
template<int E, int M, int T, int P, int B = (1 << (E - 1)) - 1>
static inline __device__ uint64_t compress(floa... |
20,899 |
#include <stdio.h>
__global__ void add(char *c, char *sub, int *o,int sub_len) {
int idx=threadIdx.x;
int ctr=0;
for (int i = 0; i < sub_len; ++i)
{
if(c[idx+i]==sub[i])
ctr++;
}
o[idx]=0;
if(idx==0 && ctr==sub_len)
o[idx]=-1;
else if(ctr==sub_len)
o[idx]=1;
}
int main(void) {
cha... |
20,900 | #include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <exception>
#include <iostream>
#include <map>
#include <sstream>
#include <string>
using duration_t = unsigned long long;
constexpr std::size_t SHARED_MEM_CAPACITY = 49152;
constexpr std::size_t ITERATIONS = 10;
#define CE(err) ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.