serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
23,101
#include "sigmoid-grad.hh" #include "graph.hh" #include "../runtime/node.hh" #include "../memory/alloc.hh" namespace ops { SigmoidGrad::SigmoidGrad(Op* sig_out, Op* dout) : Op("sigmoid_grad", sig_out->shape_get(), {sig_out, dout}) {} void SigmoidGrad::compile() { auto& g = Graph::inst...
23,102
#include <stdio.h> __global__ void AplusB( int *sum, int *a, int *b, int n) { /* * Return the sum of the `a` and `b` arrays */ // Fetch the index int i = blockIdx.x; // Perform the sum sum[i] = a[i] + b[i]; } // --- int main() { /* * Calculate the sum of two vectors using managed memory */ ...
23,103
#include "includes.h" __global__ void saturate(unsigned int *bins, unsigned int num_bins) { //@@If the bin value is more than 127, make it equal to 127 for (int i = 0; i < NUM_BINS / BLOCK_SIZE; ++i) if (bins[threadIdx.x + blockDim.x*i] >= 128) bins[threadIdx.x + blockDim.x*i] = 127; }
23,104
#include <stdio.h> #include <stdlib.h> #include <time.h> /* * This example demonstrates a simple vector sum on the host. sumArraysOnHost * sequentially iterates through vector elements on the host. */ __global__ void showResultOnDevice(float *d_A, float *d_B, float *d_C) { printf("d_A is %g\n", d_A[0]); p...
23,105
#include <cuda_runtime.h> #include <iostream> #include <ctime> #include "device_launch_parameters.h" #include <limits.h> #define PRINT_MATRIX true #define CHECK(value) {\ cudaError_t _m_cudaStat = value;\ if (_m_cudaStat != cudaSuccess) {\ cout<< "Error:" << cudaGetErrorString(_m_cudaStat) \ ...
23,106
#include "includes.h" __global__ void totalWithThreadSyncAndSharedMem(float *input, float *output, int len) { //@@ Compute reduction for a segment of the input vector __shared__ float sdata[BLOCK_SIZE]; int tid = threadIdx.x, i = blockIdx.x * blockDim.x + threadIdx.x; if(tid < len) sdata[tid] = input[i]; else sdata[ti...
23,107
#include <iostream> #include <cuda_runtime.h> using namespace std; __global__ void transp(int *A, int n){ int idx = blockIdx.x * blockDim.x + threadIdx.x; if (idx < n*n){ int j = idx % n; int i = idx / n; int tmp = A[i * n + j]; A[i * n + j] = A[j * n + i]; A[j * n ...
23,108
#include "includes.h" __global__ void matrixMultiplyNaive(float * A, float * B, float * C, int N,int K,int M) { int Row = blockDim.y*blockIdx.y + threadIdx.y; //To generate ids of threads. int Col = blockDim.x*blockIdx.x + threadIdx.x; if(Row<N && Col<M) { float Cvalue = 0.0; int k; for(k=0;k<K;k++) { Cvalue += A[Row...
23,109
#include "includes.h" __global__ void TgvCloneKernel2(float2* dst, float2* src, int width, int height, int stride) { int iy = blockIdx.y * blockDim.y + threadIdx.y; // current row int ix = blockIdx.x * blockDim.x + threadIdx.x; // current column if ((iy < height) && (ix < width)) { int pos = ix + iy * st...
23,110
/* * How to compile (assume cuda is installed at /usr/local/cuda/) * nvcc add.cu * ./a.out * */ #include <stdio.h> #include <stdlib.h> #include <assert.h> #include <cuda_runtime.h> __global__ void add_kernel(int* a, int* b, int*c){ *c = *a + *b; } int main(void) { printf("My First CUDA Application\n"); ...
23,111
#include "includes.h" const int Nthreads = 1024, maxFR = 100000, NrankMax = 3, nmaxiter = 500, NchanMax = 32; ////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////...
23,112
#include<stdio.h> #include<time.h> __global__ void gathertrajctoryKernel(int b,int n,int m,int t,const float * __restrict__ inp,const int * __restrict__ idx, float * __restrict__ out){ for(int i = blockIdx.x;i<b;i+=gridDim.x){ for(int j = threadIdx.x;j<m; j+=blockDim.x){ int tmp = idx[i*m+j]; ...
23,113
#include "includes.h" __global__ void addKernel(int * dev_a, int * dev_b, int * dev_c) { int i = threadIdx.x; dev_c[i] = dev_a[i] + dev_b[i]; }
23,114
#include"DumbRand.test.cuh" #include"DumbRand.cuh" #include<iostream> #include<string> namespace DumbRandTest { namespace { template<typename FunctionType, typename... Args> __device__ __host__ inline static void generateAndPrint(const char *comment, const char *typeHint, DumbRand &generator, FunctionType&& gene...
23,115
#include "device_launch_parameters.h" #include <iostream> #include <stdio.h> #include <cuda_runtime.h> #include <time.h> using namespace std; #define eps 1e-4 __global__ void im2col(float ***img, float **img_flat, int c1, int n, int m, int kw, int kh, int out_n, int out_m){ //each thread process a [c1 * kw * kh] f...
23,116
#include "includes.h" __global__ void _A_mul_Bs_32(int mx, int ns, float *x, float *sval, int *srow, int *scol, float *k) { int s0, s1, sp, sc, sr, x0, xr, k0, k1, kp; float sv, xv; sc = threadIdx.x + blockIdx.x * blockDim.x; while (sc < ns) { // sc: 0-based column for s and k to be processed k0 = mx*sc; // k[k0]: fir...
23,117
extern "C" __global__ void math_acosf(size_t n, float *result, float *x) { int id = blockIdx.x * blockDim.x + threadIdx.x; if (id < n) { result[id] = acosf(x[id]); } } extern "C" __global__ void math_acoshf(size_t n, float *result, float *x) { int id = blockIdx.x * blockDim.x + threadIdx....
23,118
extern "C"{ __global__ void sobel(float *dataIn, float *dataOut, int imgHeight, int imgWidth) { int xIndex = threadIdx.x + blockIdx.x * blockDim.x; int yIndex = threadIdx.y + blockIdx.y * blockDim.y; int index = yIndex * imgWidth + xIndex; int Gx = 0; int Gy = 0; if (xIndex > 0 && xIndex < img...
23,119
#include "includes.h" __global__ void reduce(int * vector,int size,int pot){ int idx = threadIdx.x + blockIdx.x*blockDim.x; int salto = pot/2; while(salto){ if(idx<salto && idx+salto<size){ vector[idx]=vector[idx]+vector[idx+salto]; } __syncthreads(); salto=salto/2; } return; }
23,120
#include<stdio.h> int main(int argc, char** argv) { dim3 Dimblock(1024, 1024, 64); printf("blockDim.x = %d\n",Dimblock.x); printf("blockDim.y = %d\n",Dimblock.y); printf("blockDim.z = %d\n",Dimblock.z); return 0; }
23,121
#define BLOCK_DIM 512 extern "C" void Blend_GPU( unsigned char* aImg1, unsigned char* aImg2, unsigned char* aImg3, int width, int height ); extern "C" void Blend_GPU_kernel_only( unsigned char* aImg1, unsigned char* aImg2, unsigned char* aRS, int size ); __global__ void Blending_Kernel( unsigned char* aR1, unsigned c...
23,122
#include <stdio.h> __global__ void mykernel(void) { while(1) printf("Hello kernel\n"); } int main(void) { mykernel<<<222,222>>>(); while(1) printf("Hello World!\n"); return 0; }
23,123
#include "includes.h" #define INTERVALS 1000000 // Max number of threads per block #define THREADS 512 #define BLOCKS 64 double calculatePiCPU(); // Synchronous error checking call. Enable with nvcc -DDEBUG __global__ void integrateOptimised(int *n, float *g_sum) { int idx = threadIdx.x + blockIdx.x * blockDim.x; ...
23,124
/* * HyUpdaterTM.cpp * * Created on: 11 янв. 2016 г. * Author: aleksandr */ #include "HyUpdaterTM.h" #include "SmartIndex.h" #include <thrust/device_vector.h> #include <thrust/functional.h> // o o o o x // o o o o x // o o o o x // o o o o x // o o o o x __host__ __device__ void HyUpdaterTM::op...
23,125
#include <stdio.h> #include <stdlib.h> struct node{ int dst; struct node* next; }; struct list{ struct node *head; }; struct graph{ int n; struct list* set; }; struct node* new_node(int dst){ struct node* newnode = (struct node*)malloc(sizeof(struct node)); newnode -> dst = dst; newnode -> next = NULL; re...
23,126
__device__ int foobar;
23,127
#include <stdio.h> #include <string.h> #include <stdlib.h> #define BLOCK_DIM 8192 __device__ bool isPrime(int number){ int i; if ( number != 2 && number % 2 == 0) return false; if ( number != 3 && number % 3 == 0) return false; float tmp = sqrt(float(number)); int root = int(tmp); for( i = 5; i <=...
23,128
#include "includes.h" __global__ void bin(unsigned short *d_input, float *d_output, int in_nsamp) { int c = ( ( blockIdx.y * BINDIVINF ) + threadIdx.y ); int out_nsamp = ( in_nsamp ) / 2; int t_out = ( ( blockIdx.x * BINDIVINT ) + threadIdx.x ); int t_in = 2 * t_out; size_t shift_one = ( (size_t)(c*out_nsamp) + (size...
23,129
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <sys/time.h> #include <cuda.h> #include <cuda_runtime_api.h> //https://proofwiki.org/wiki/Product_of_Triangular_Matrices int max_per_row = 0; __global__ void devTrianglesCount(int* col_indx, int* csr_rows, int nnz, int rows, int* out_sum); /** * D...
23,130
//#include "crop_cuda.h" // //#include <stdio.h> //#include <cstdlib> //#include <math.h> //#include <iostream> // //#include "../common/macro.h" // // //namespace va_cv { // //texture<unsigned char> tex_src; //__constant__ int rect[4]; // // //__global__ void kernel_crop_grey(unsigned char *dst ) { // // map from ...
23,131
#include "includes.h" __global__ void dotProductSingle(int* pFeatureList, float* pValuesList, size_t* pSizeOfInstanceList, size_t pSize, size_t pMaxNnz, float* pDevDotProduct) { int instanceId = blockIdx.x; int threadId = threadIdx.x; float __shared__ value[32]; int __shared__ jumpLength; size_t __shared__ size; whil...
23,132
#include <cuda.h> #include <cuda_runtime.h> #include <stdio.h> #include <stdlib.h> #include <time.h> void genVector(float *x, int n) { for (int i = 0; i < n; i++) x[i] = random()/((float) RAND_MAX); } void printVector(const char* title, float *y, double n) { printf("%s\n", title); for (int i = 0; i < n; i...
23,133
#include "includes.h" __global__ void Subtract(float *d_Result, float *d_Data1, float *d_Data2, int width, int height) { const int x = __mul24(blockIdx.x, 16) + threadIdx.x; const int y = __mul24(blockIdx.y, 16) + threadIdx.y; int p = __mul24(y, width) + x; if (x<width && y<height) d_Result[p] = d_Data1[p] - d_Data2[p]...
23,134
#include "includes.h" __global__ void radd(float * resp, const float * res, float alpha) { int idx = threadIdx.x + blockIdx.x*blockDim.x; resp[idx] = (1 - alpha)*resp[idx] + alpha*res[idx]; }
23,135
#include <iostream> #include <cstdlib> // GPU kernel without shared memory usage __global__ void stencilKernel (int arrSize, float *in, float *out, int wArrSize, float *wArr) { int midIndex = blockDim.x * blockIdx.x + threadIdx.x; int radius = wArrSize / 2; float result = 0; for (int i = -1 * rad...
23,136
//Assignment No-B3 #include "iostream" using namespace std; __global__ void sort(int *arr_d, int pivot, int len, int *arrl_d, int *arrh_d) { int id = threadIdx.x; bool flag; int element = arr_d[id+1]; if( element <= pivot ) flag = true; else flag = false; __syncthr...
23,137
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <cmath> #define NUM_ELEMENTS 8388608 #define PI 3.141592654 #define r 1048576 //__global__ void divideAndConquer() //{ // int x; // int y; // // double d = (2 * PI) * (NUM_ELEMENTS - 1); // // if (threadIdx.x == 0 && blockI...
23,138
#include "includes.h" __global__ void mat_mul_gpu(float* vec_one, float* vec_two, float* ret_vec, int vec_one_row, int vec_one_col, int vec_two_col) { // compute global thread coordinates int row = blockIdx.y * blockDim.y + threadIdx.y; int col = blockIdx.x * blockDim.x + threadIdx.x; // linearize coordinates for data...
23,139
#include "includes.h" #ifdef TIME #define COMM 1 #elif NOTIME #define COMM 0 #endif #define MASK_WIDTH 5 #define TILE_WIDTH 32 #define GPU 1 #define COMMENT "skeletization_GPU" #define RGB_COMPONENT_COLOR 255 typedef struct { unsigned char red, green, blue; } PPMPixel; typedef struct { int x, y; PPMPixel *data; } ...
23,140
#include "includes.h" #define BLOCK_SIZE 16 __device__ float f(float x) { return 4.f / (1.f + x * x); } __global__ void transGPU(const float *inMatrix, float *outMatrix, const size_t row, const size_t column) { size_t xIndex = blockIdx.x * blockDim.x + threadIdx.x; size_t yIndex = blockIdx.y * blockDim.y + threadId...
23,141
#include "SerializeDeserialize.cuh" void serializeNeuralNet(NeuralNet* nn, char* fileName){ // Opens the file for writing FILE* file=fopen(fileName, "w"); // Writes the layer data fprintf(file, "%d\n", nn->layers); // Writes the neuron data for(int layer=0; layer<nn->layers; layer++){ fprintf(file, "%d\n", n...
23,142
#include <cuda.h> #include <assert.h> #include <stdio.h> // work-group size * 2 #define N 512 template<typename dataType> __global__ void prescan(dataType *g_odata, dataType *g_idata, int n) { __shared__ dataType temp[N]; int thid = threadIdx.x; int offset = 1; temp[2*thid] = g_idata[2*thid]; temp[2*t...
23,143
#ifdef __cplusplus extern "C" { #endif __global__ void vec_add(float *A, float* B,float* C, int size) { int index = blockIdx.x*blockDim.x + threadIdx.x; if(index<size) C[index] = A[index] + B[index]; } #ifdef __cplusplus } #endif
23,144
// Ex. 6 // ===== // Modify the kernel so that each thread will also include its number. #include <stdio.h> __global__ void helloFromGPU() { printf("Hello World from thread number %d!\n", threadIdx.x); } int main(int argc, char *argv[]) { // Hello from CPU printf("Hello World from CPU!\n"); helloFromGPU<<<1...
23,145
#include <stdint.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> int main( int argc, char *argv[] ) { int ITERATIONS = 1; //int numBytes = 131072; int numBytes = 131072*2; uint64_t *memory_to_access = (uint64_t *)malloc(sizeof(uint64_t)*numBytes ); for(int k=0;k< numBytes ;k++) m...
23,146
#include <cuda.h> #include <cuda_runtime.h> #include <iostream> #include <device_launch_parameters.h> constexpr auto PI = 3.14f; //umplerea a doua matrici cu date __global__ void fill_array2D(float *a, float *b, int N, int M) { int row = blockIdx.x * blockDim.x + threadIdx.x; int col = blockIdx.y * blockDim...
23,147
#include <fstream> #include <iostream> #include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <thrust/sort.h> using namespace std; /* Compares two integers lexicographically from least to greatest. First the input integers are reversed. Next reversed integers are traversed from right to left usi...
23,148
#include "includes.h" __global__ void cunnx_WindowGate2_updateGradInput_kernel( float *gradInput, float *error, float* targetCentroids, const float *centroids,const float *input, const float *inputIndice, const float *outputIndice, const float* output, const float* gradOutput, int inputSize, int outputSize, int inputWi...
23,149
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <limits.h> #define NUM_THREADS 512 #define NUM_BLOCKS 1 #define ZERO_BANK_CONFLICTS 1 #define OUTPUT_FILE_NAME "q3.txt" #define NUM_BANKS 16 #define LOG_NUM_BANKS 4 #ifdef ZERO_BANK_CONFLICTS #define CONFLICT_FREE_OFFSET(n) \ ((n) >> NUM_BANKS + (n) ...
23,150
#include <stdio.h> __global__ void device_global(unsigned int *input_array, int num_elements) { int my_index = blockIdx.x * blockDim.x + threadIdx.x; int index = (my_index*3)%num_elements; input_array[index] = my_index; } int main(void) { // how big our array for interfacing with the GPU will be int num_ele...
23,151
#include "includes.h" __global__ void reduce(double4 *ac, double4 *ac1, double4 *ac2, unsigned int bf_real, unsigned int dimension){ unsigned int i = blockIdx.x * blockDim.x + threadIdx.x; unsigned int k = dimension*bf_real; double4 myacc; extern __shared__ double4 shaccelerations[]; double4 *shacc = (double4*) shacc...
23,152
//data race //--blockDim=512 --gridDim=1 --warp-sync=32 --no-inline #include <cuda.h> #include <stdio.h> #include <assert.h> #define N 4//512 __global__ void shuffle (int* A) { int tid = threadIdx.x; int warp = tid / 2;//32; int* B = A + (warp*2);//32); A[tid] = B[(tid + 1)%2];//32]; }
23,153
#include <cstring> #include <ctime> #include <iostream> using namespace std; #define REPEAT256(S) \ S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S ...
23,154
// Andre Driedger 1805536 // A2 cuda greyscale source code #include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <assert.h> #include <stdint.h> #include <tiffio.h> __global__ void greyscale(float *d_out, float* r, float* g, float* b){ int tid = threadIdx.x; int bid = blockIdx.x; int id = tid*(bid+1); ...
23,155
#include <stdio.h> #include <cuda.h> #define N 1024 __global__ void prefixSum(int *x, int n){ volatile unsigned id = threadIdx.x + threadIdx.y * blockDim.x; if(id < n) { // incase of more blocks for( int i=1 ; i < n ; i*=2 ) { if(id >= i) { if (id > 1000) {++i; id--; --i; ++id;} x[id] += x[id - i]; } ...
23,156
// This program fills two arrays with numbers from 1 to N. One array is allocated in pageable // memory and the other is allocated in pinned memory. The GPU is used to calculate the square root // of each element in the array. A timer is used to measure the total execution time (including // memory copy) of the paged v...
23,157
#include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <thrust/sort.h> #include <iostream> int main(void) { // generate 16M random numbers on the host thrust::host_vector<int> h_vec(1 << 16); thrust::generate(h_vec.begin(), h_vec.end(), rand); // transfer data to the device th...
23,158
#include <cuda.h> #include <cuda_runtime.h> #include <iostream> class Managed { public: void *operator new(size_t len) { void *ptr; cudaMallocManaged(&ptr, len); cudaDeviceSynchronize(); return ptr; } void operator delete(void *ptr) { cudaDeviceSynchronize(); cudaFree(ptr); } }; struc...
23,159
/* 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,float var_2,float 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) { for (int i=0; i < var_1; ++i)...
23,160
/* This is the function you need to implement. Quick reference: - input rows: 0 <= y < ny - input columns: 0 <= x < nx - element at row y and column x is stored in data[x + y*nx] - correlation between rows i and row j has to be stored in result[i + j*ny] - only parts with 0 <= j <= i < ny need to be filled */ #include ...
23,161
#include<stdio.h> #include<stddef.h> #include<search.h> #include<device_functions.h> #define MAX_FILE_SIZE 200 #define MAX_HASH_ENTRIES 200 #define M 10 __global__ void getWordCounts(char *fileArray,int *countArray,int *fileSize,char *wordhashtable, int *nextPtr, int *lock){ unsigned int i = blockIdx.x * blockDim.x ...
23,162
#include <cuda_runtime_api.h> #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> // Add your kernel here __global__ void add(int *a, int *b, int *c) { *c = *a + *b; } // main int main(void) { int a, b, c; int *d_a, *d_b, *d_c; int size = sizeof(int); // Allocate memory in Device cudaM...
23,163
#include <stdio.h> #include <string.h> #include <sys/types.h> #include <sys/time.h> #include <cuda.h> #include <stdlib.h> #define IMAGE_HEIGHT 521 #define IMAGE_WIDTH 428 __global__ void blur(int *d_R, int *d_G, int *d_B, int *d_Rnew, int *d_Gnew, int *d_Bnew) { // Get the X and y coords of the pixel for this thre...
23,164
#include "includes.h" __global__ void kCopyInto(float* images, float* targets, const int imgSize, const int paddingSize, const int numImages) { const int imgIdx = blockIdx.y * gridDim.x + blockIdx.x; if (imgIdx < numImages) { const int targetSize = imgSize + 2 * paddingSize; images += imgIdx * imgSize * imgSize; target...
23,165
/* Finds: Maxwell TLB Soure code based on paper https://arxiv.org/pdf/1509.02308.pdf */ #include <stdio.h> #include <stdint.h> #include "cuda_runtime.h" #define LEN 256 __global__ void global_latency(unsigned int* my_array, int N, int iterations, unsign...
23,166
// ### // ### // ### 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...
23,167
#include <cuda_runtime.h> #include <stdio.h> int main(int argc, char **argv) { //データ要素の合計数を定義 int nElem = 1024; // グリッドとブロックの構造を定義 dim3 block(1024); dim3 grid((nElem + block.x -1) / block.x); printf("grid.x %d block.x %d \n", grid.x, block.x); // ブロックをリセット block.x = 512; grid.x = (nElem + block.x -1) / bloc...
23,168
// reduce_float template <typename T> __device__ void reduce(T *x, T *y, int n, int stride) { extern __shared__ T sdata[]; int blockSize = 128; int tid = threadIdx.x; int idx = blockIdx.x * blockSize + threadIdx.x; int gridSize = blockSize * gridDim.x; T sum = x[idx]; //idx += gridSize; // we reduce ...
23,169
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args // CHECK: #include <hip/hip_runtime.h> #include <iostream> // CHECK: #include <hiprand.h> #include <curand.h> // CHECK: #include <hipcub/hipcub.hpp> #include <cub/cub.cuh> // using namespace hipcub; using namespace cub; // Simple CUDA kernel for computing ti...
23,170
#include <stdio.h> #include <stdlib.h> __global__ void add(int *a, int *b, int *c) { // note that add has no variables in its scope, instead it reads and // modifies variables that live elsewhere. int iElem = blockIdx.x; c[iElem] = a[iElem] + b[iElem]; } void irand(int *arr, int nElems) { int iEl...
23,171
#include <iostream> #define N 4096 #define TPB 512 // Threads per Block __global__ void add(int* a, int* b, int *c, int max){ int index = threadIdx.x + blockIdx.x * blockDim.x; int id = index; while(id < max){ c[id] = a[id] + b[id]; id = id + blockDim.x * gridDim.x; } } // Fills a matrix with 1s void...
23,172
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <time.h> #include <math.h> #include <string.h> #define EPSILON 1E-9 #define BLOCK_SIZE_F 512 //Work with blocks of 512 threads due to double precision - shared memory #define BLOCK_SIZE_VP 1024 //Work with blocks of 512 threads due to double precision ...
23,173
#include "includes.h" extern "C" { } #define TB 256 #define EPS 1e-4 __global__ void bilateral_smooth_kernel( float *affine_model, float *filtered_affine_model, float *guide, int h, int w, int kernel_radius, float sigma1, float sigma2 ) { int id = blockIdx.x * blockDim.x + threadIdx.x; int size = h * w; if (id < si...
23,174
#include "Int3.cuh" Int3::Int3(){ } Int3::Int3(int _x, int _y, int _z){ x = _x; y = _y; z = _z; } void Int3::Add(int _x, int _y, int _z){ x = x + _x; y = y + _y; z = z + _z; } void Int3::Add(Int3 value){ x = x + value.x; y = y + value.y; z = z + value.z; } void Int3::Substract(int _x, int _y, int _z){...
23,175
#include "includes.h" __global__ void one_channel_mul_kernel(float *data_l, float *data_r, float *result) { int blockId = blockIdx.x + blockIdx.y * gridDim.x; int threadId = 2 * (blockId * (blockDim.x * blockDim.y) + (threadIdx.y * blockDim.x) + threadIdx.x); int one_ch_index = 2 * ((threadIdx.y * blockDim.x) + threadI...
23,176
#include <thrust/device_vector.h> #include <thrust/for_each.h> #include <thrust/execution_policy.h> struct print { int *B; int len; print(int *b, int _len) : B(b), len(_len) {} __host__ __device__ void operator() (int x) { thrust::for_each(thrust::device, B, B+len, [=](const int k) { if (k < len) printf("...
23,177
// filename: vsquare.cu // a simple CUDA kernel to element multiply vector with itself extern "C" // ensure function name to be exactly "vsquare" { __global__ void vsquare(const double *a, double *c) { int i = threadIdx.x+blockIdx.x*blockDim.x; double v = a[i]; c[i] = v*v; } }
23,178
// Copyright (c) 2012-2017 VideoStitch SAS // Copyright (c) 2018 stitchEm // Used by the CMake configuration to test nvcc flags int main() { return 0; }
23,179
#include <iostream> #include <cuda.h> #include <stdio.h> using namespace std; __global__ void addition(int *a, int *b, int *c) { *c = *a + *b; } int main() { int a, b, c; int *dev_a, *dev_b, *dev_c; int size = sizeof(int); cudaError_t err; err = cudaMalloc((void**)&dev_a, size); if(err != cudaSucce...
23,180
// // nvcc list_threads.cu // // basic into to cuda kernel // #include <cuda_runtime.h> #include <cstdlib> #include <iostream> using namespace std; __global__ void saveTid(int *tids, int numElements) { int tid = blockDim.x * blockIdx.x + threadIdx.x; if (tid < numElements) { tids[tid*2] = blockIdx.x; ...
23,181
#include <stdio.h> #include <cuda_runtime.h> #define CUDACHECK(ans) { gpuAssert((ans), __FILE__, __LINE__); } inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true) { if (code != cudaSuccess) { fprintf(stderr,"GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line); ...
23,182
#include <stdio.h> inline void GPUassert(cudaError_t code, char * file, int line, bool Abort=true) { if (code != 0) { fprintf(stderr, "GPUassert: %s %s %d\n", cudaGetErrorString(code),file,line); if (Abort) exit(code); } } #define GPUerrchk(ans) { GPUassert((ans), __FILE__, __LINE__); }...
23,183
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <cuda.h> #include <cuda_runtime.h> // simple kernel function that adds two vectors // originally used for demonstration __global__ void vect_add(float *a, float *b, int N) { int idx = threadIdx.x; if (idx<N) a[idx] = a[idx] + b[idx]; } __global...
23,184
#include <stdio.h> #include <stdlib.h> #include <string.h> #define Uw 1.0 #define ERMAX 0.0000005 #define xp(i) (float)i*delta #define yp(j) (float)j*delta #define position(i,j) j*Nx+i void Caller(void); void CavityCompute(void); int GetComputeCondition(void); void ComputeMain(int check); void ApplyIC(float *U, float...
23,185
__global__ void evaluateSymbolRegression(float* resultScore, float* result, float* programArray, float* evaluateBuffer, int* stackCountArray, int* programLength, int *maxProgramLengthFromMain, int *targetFunction, float* targetValueArray){ // allocate buffer for processing const unsigned int maxProgramLength = maxP...
23,186
#include "includes.h" __global__ void MHDComputedUz_CUDA3_kernel(float *FluxD, float *FluxS1, float *FluxS2, float *FluxS3, float *FluxTau, float *FluxBx, float *FluxBy, float *FluxBz, float *FluxPhi, float *dUD, float *dUS1, float *dUS2, float *dUS3, float *dUTau, float *dUBx, float *dUBy, float *dUBz, float *dUPhi, f...
23,187
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include "cuda.h" #include <math.h> #include <stdio.h> //#include <stdlib.h> #include <string.h> #include <time.h> //__shared__ int ipiv[3]; __shared__ int indxc[3],indxr[3]; template<typename Typeval> __device__ void Swap(Typeval &a,Typeval &b) //void...
23,188
#include "includes.h" __global__ void find_all_sums_hub_kernel(int* hub, int nhub, double *node_weight, int *neighbor, int *neighbor_start, double *sum_weight_result){ int x = blockIdx.x * blockDim.x + threadIdx.x; if (x < nhub) { int nid = hub[x]; double sum = 0.0; for (int eid = neighbor_start[nid]; eid < neighbor_st...
23,189
#include <cuda.h> #include <cmath> #include <cstdio> #include <iostream> #include <chrono> //#define SIZE 32 using namespace std; /* //F 5.13 __global__ void Sum1_Kernel(float* X, float *Y) { __shared__ float partialSum[SIZE]; partialSum[threadIdx.x] = X[blockIdx.x*blockDim.x + threadIdx.x]; unsigned int t = threa...
23,190
#include<stdio.h> __global__ void computeFutureGen(int* current,int* future,int n){ int col=threadIdx.x+blockIdx.x*blockDim.x; int row=threadIdx.y+blockIdx.y*blockDim.y; int index=col+row*n; //Computing the number of alive neighbors int neighAlive=0; if(col<n && row<n){ //Co...
23,191
#include <stdexcept> #include "reshape.hh" #include "graph.hh" #include "../runtime/graph.hh" #include "../runtime/node.hh" #include "../memory/alloc.hh" #include "ops-builder.hh" #include <cassert> #include <stdexcept> namespace ops { Reshape::Reshape(Op* arg, const Shape& shape) : Op("reshape", shape, ...
23,192
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> #include <float.h> #include <sys/time.h> // includes, kernels #include "trap_kernel.cu" #define BLOCK_DIM 128 #define LEFT_ENDPOINT 10 #define RIGHT_ENDPOINT 1005 #define NUM_TRAPEZOIDS 100000000 double compute_on_device(float, float, int, ...
23,193
#include "includes.h" __global__ void numMayor(float *d_v, float *d_pos){ float temp = 0,pos=0; for(int i=threadIdx.x; i<blockDim.x;i++){ if(d_v[i] > temp){ temp = d_v[i]; pos = i; } } __syncthreads(); if(pos>d_pos[threadIdx.x]) d_pos[threadIdx.x] = pos; d_v[threadIdx.x] = temp; }
23,194
#include "includes.h" __global__ void dot( int *a, int *b, int *c ) { __shared__ int temp[THREADS_PER_BLOCK]; int index = threadIdx.x + blockIdx.x * blockDim.x; temp[threadIdx.x] = a[index] * b[index]; __syncthreads(); if( 0 == threadIdx.x ) { int sum = 0; for( int i = 0; i < THREADS_PER_BLOCK; i++ ) sum += temp[i]; at...
23,195
#include <stdlib.h> #include <stdio.h> #include <time.h> #include <string.h> #include <math.h> #include <float.h> #include <sys/time.h> // includes, kernels #include "vector_dot_product_kernel.cu" void run_test(unsigned int); void compute_on_device(float *, float *,float *,int); extern "C" float compute_gold( float *...
23,196
#include <stdio.h> //using namespace std; //#typedef n 100 // Kernel Definition __global__ void VecAddKernel(float *d_A, float *d_B, float *d_C, int n){ int i=blockDim.x*blockIdx.x+threadIdx.x; if(i<n) d_C[i]=d_A[i]+d_B[i]; } void vecAdd(float *A, float *B, float *C, int n){ float *d_A, *d_B, *d_C; int size=n...
23,197
#include <stdio.h> #include <time.h> #define ADIABATIC_GAMMA (5.0 / 3.0) typedef double real; __device__ void conserved_to_primitive(const real *cons, real *prim) { const real rho = cons[0]; const real px = cons[1]; const real py = cons[2]; const real energy = cons[3]; const real vx = px / rho; ...
23,198
#include <stdio.h> #include <cuda_runtime.h> #include <asm/unistd.h> #include <fcntl.h> #include <inttypes.h> #include <linux/kernel-page-flags.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string> #include <string.h> #include <sys/ioctl.h> #include <sys/mount.h> #include <sys/mman.h> #include...
23,199
//pass //--blockDim=2048 --gridDim=2 --no-inline __constant__ int A[4096]; __constant__ int B[3] = {0,1,2}; __global__ void kernel() { int x = A[threadIdx.x] + B[0]; }
23,200
// compile with: nvcc -arch sm_60 -o reduction reduction.cu // run: ./reduction #include <stdio.h> #include <stdlib.h> #include "cuda.h" // use this later to define number of threads in thread block #define BSIZE 256 __global__ void partialReduction_v0(int N, float *c_a, float *c_result){ // sha...