serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
4,301
#include <cuda.h> #include <stdio.h> #define N 100000 __global__ void kernel_add(int a, int b, int *c){ *c = a + b; } int main(int argc, char **argv){ int* host_a = (int*) malloc(sizeof(int)); int* host_b = (int*) malloc(sizeof(int)); int* host_c = (int*) malloc(sizeof(int)); int* device_c; ...
4,302
#include<stdio.h> #include<cuda.h> #include<stdlib.h> #include<sys/time.h> #include<time.h> //Macro for checking cuda errors following a cuda launch or api call #define CUDA_CHECK_RETURN(value) { \ cudaError_t _m_cudaStat = value; \ if (_m_cudaStat != cudaSuccess) { \ fprintf(stderr, "E...
4,303
#include <stdio.h> #include <stdint.h> #define MAXN 1024 __device__ __host__ int CeilDiv(int a, int b) { return (a-1)/b + 1; } void rand_gen(uint32_t cA, uint32_t cB, int N, uint32_t *A, uint32_t *B) { uint32_t xA = 2, n = N*N; uint32_t xB = 2; uint32_t *_A = A; for (int i = 0; i < N; i++) { for (...
4,304
#include <stdio.h> #include <iostream> // размер грида #define DGX 4 #define DGY 8 // размер блока #define DBX 2 #define DBY 2 #define DBZ 2 // общее количество параллельных процессов: 4*8*2*2*2 = 256 #define N (DBX*DBY*DBZ*DGX*DGY) __global__ void kern( float *a ) { int bs = blockDim.x*blockDim.y*blockDim.z; in...
4,305
/* Task #7 - Gustavo Ciotto Pinton MO644 - Parallel Programming */ #include <stdio.h> #include <stdlib.h> #include <math.h> #include <cuda.h> #define THREAD_PER_BLOCK 32 /* Tesla k40 supports 1024 threads (32 x 32 = 1024 in 2D grids) */ __global__ void addMatrix2d (int *A, int *B, int *C, int rows, int columns) ...
4,306
#include <assert.h> #include <stdio.h> #include <stdlib.h> #include <string.h> //#include <sm_11_atomic_functions.h> #define MAX_NUM_BLOCKS 40 // Synchronization code is based on paper: // Shucai Xiao and Wu-chun Feng. "Inter-Block GPU Communication via Fast Barrier Synchronization". // Proceedings of the 24th IEE...
4,307
#include <stdio.h> #include <string.h> #include <stdlib.h> #include "hist-equ.cuh" #define nbr_bin 256 __device__ unsigned char clip_rgb_gpu(int x) { if(x > 255) return 255; if(x < 0) return 0; return (unsigned char)x; } __global__ void rgb2yuv_conversion_gpu(unsigned char * img_y, unsigned char * img_u, ...
4,308
/* ****************************************************** This program is to reconstruct for 3-D cone beam projection, apply on 3-D shep-Logan head phaton There are three steps to the weighted filtered backprojection algorithm: 1) convert projection to projection_prime (weighted) 2) filtering part 3) backprojection ...
4,309
// Type your code here, or load an example. __global__ void square(int *array, int n) { int tid = blockIdx.x; if (tid < n) array[tid] = array[tid] * array[tid]; }
4,310
//pass //--blockDim=64 --gridDim=1 --no-inline #include "cuda.h" __global__ void foo(int* glob) { int a; int* p; a = 0; p = &a; *p = threadIdx.x; glob[*p] = threadIdx.x; }
4,311
// To compile: nvcc hw06.cu -o hw06 #include <sys/time.h> #include <stdio.h> #define N 100000 #define FORMAT "%f\n" #define TYPE float __global__ void dotProduct(TYPE *a, TYPE *b, TYPE *c){ unsigned long id = (blockIdx.x*blockDim.x)+threadIdx.x; __shared__ TYPE cache[1024]; cache[thr...
4,312
#include <stdio.h> #include <stdlib.h> #include <math.h> #define m 10 #define n 5 // matrix_sum1<<<m, n>>>(d_A, d_B, d_C, m, n); __global__ void matrix_sum1(int A[], int B[], int C[], int fil, int col) { int index = blockDim.x * blockIdx.x + threadIdx.x; if (blockIdx.x < fil && threadIdx.x < col) ...
4,313
// includes, system #include <stdio.h> #include <assert.h> #define ARRAY_SIZE 2000000 #define STRING_SIZE 16 int char_array[ARRAY_SIZE*STRING_SIZE]; int char_counts[26]; char getRandomChar() { int randNum = 0; char randChar = ' '; randNum = 26 * (rand() / (RAND_MAX + 1.0)); // pick number 0 < # < 25 randNum = r...
4,314
#include "includes.h" __global__ void DivideKernel ( float *d_dst, unsigned short *d_denom ) { const int idx = blockIdx.x; d_dst[idx] /= d_denom[idx]; }
4,315
#include <cuda_runtime.h> #include <device_functions.h> #include <device_launch_parameters.h> #include <iostream> __global__ void addVec(int* a, int* b, int* c, int size) { int index = blockDim.x * blockIdx.x + threadIdx.x; c[index] = a[index] + b[index]; } //3.1 a __global__ void MatrixAdditionElement(int* l...
4,316
__device__ inline float2 operator+(float2 a, float2 b) { return make_float2( a.x + b.x, a.y + b.y ); } __device__ __forceinline__ unsigned int get_mesh_id() { return (gridDim.y*gridDim.x*blockIdx.z + gridDim.x*blockIdx.y + blockIdx.x) * (blockDim.z*blockDim.y*blockDim.x) + blockDim.y*blockDim.x*threadIdx.z ...
4,317
/* This is a automatically generated test. Do not modify */ #include <stdio.h> #include <stdlib.h> #include <math.h> __global__ void compute(float comp, float var_1,float var_2,int var_3,float var_4,float var_5,float var_6,float var_7) { if (comp > cosf(+0.0f / (-1.2242E34f * (-1.0814E-37f * sqrtf(+1.0582E-36f + (+1...
4,318
#include <stdlib.h> #include <stdio.h> #include <math.h> #include "sparse_struc.cuh" void matrix_sum(int *mat1, int *mat2, int*sum, int nrow, int ncol) { int mat_index; for (int row_index = 0; row_index < nrow; row_index++) { for (int col_index = 0; col_index < ncol; col_index++) { mat_index = row_index *ncol ...
4,319
#include "includes.h" __global__ void CompareVectorsKernel(float* inputOne, float* inputTwo, float* output) { int id = blockDim.x*blockIdx.y*gridDim.x //rows preceeding current row in grid + blockDim.x*blockIdx.x //blocks preceeding current block + threadIdx.x; if (inputOne[id] != inputTwo[id]) output[0] = 1; }
4,320
#include "includes.h" __global__ void shmem ( int *in, int *out, int N ) { extern __shared__ int buf[]; int idx = blockDim.x * blockIdx.x + threadIdx.x; if( idx < N ) { buf[ idx ] = in[ idx ]; } __syncthreads(); if ( idx < N/2 ) { int tmp = buf[ N - idx - 1]; buf[ N - idx - 1 ] = buf [ idx ]; buf[ idx ] = tmp; } __...
4,321
/* Pointer.to(iGA_nPtBlock0.gpuArray), Pointer.to(iGA_nPtBlock1.gpuArray), Pointer.to(iGA_blockLevel.gpuArray), Pointer.to(iGA_nPtBlPos.gpuArray), Pointer.to(iGA_nPtBlNeg.gpuArray), ...
4,322
/** * Angle Between Two Vectors A and B * * Author: Gulsum Gudukbay * Date: 23 December 2017 * */ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <time.h> #include <math.h> #include <cuda.h> #include <cuda_runtime_api.h> // double precision atomic add function // taken from https://devtalk.n...
4,323
#include "includes.h" __device__ float Dist_between_two_vec(float * v0, float *v1, int size) { float dist = 0; for (int i = 0; i < size; i++) dist += (v0[i] - v1[i])*(v0[i] - v1[i]); return sqrt(dist); } __global__ void Dist_between_two_vec_naive(float * v0, float *v1, int size, float * dst) { float dist = 0; for (int...
4,324
#include <fstream> #include <iostream> #include <stdio.h> #include <string> #include <sstream> #include <stdlib.h> #include <math.h> #include <time.h> #include <ctime> #include <vector> #include <cstdlib> #include <algorithm> #include <cuda_runtime_api.h> #include <cuda.h> using namespace std; //handlerror declarati...
4,325
#include "includes.h" __global__ void _norm_forward_kernel(float *x, float *mean, float *variance, int b, int c, int wxh) { int ind = (blockIdx.x + blockIdx.y*gridDim.x) * blockDim.x + threadIdx.x; int j = (ind / wxh) % c; if (ind >= b * c * wxh) return; x[ind] = (x[ind] - mean[j]) / (sqrt(variance[j] + 0.000001f)); ...
4,326
#include <stdio.h> #define BLOCKS 1 #define THREADS 256 //Create a kernal to perform the wanted task __global__ void kernal() { //Get the tread id and print it printf("Hello world, I'm thread number %d \n", threadIdx.x + blockIdx.x*blockDim.x); } int main() { //Specify the amout of blocks and threads dim3 number...
4,327
#include "includes.h" __global__ void backward_maxpool_layer_kernel(int n, int in_h, int in_w, int in_c, int stride, int size, int pad, float *delta, float *prev_delta, int *indexes) { int h = (in_h + 2 * pad) / stride; int w = (in_w + 2 * pad) / stride; int c = in_c; int area = (size - 1) / stride; int id = (blockIdx...
4,328
extern "C" __global__ void kMul(double* a, double* b, double* dest, int n) { int idx = blockIdx.x * blockDim.x + threadIdx.x; if(idx<n) { dest[idx] = a[idx] * b[idx]; } } extern "C" __global__ void kFillArray(double* a, int m, double* dest, int n) { int idx = blockIdx.x * blockDim.x + threadIdx.x; if(id...
4,329
#include <bits/stdc++.h> #include <cuda.h> using namespace std; #define CEIL(a,b) ((a-1)/b+1) #define N 1024 typedef long long int lli; __global__ void Inclusive_Scan(lli *d_in, lli* d_out) { __shared__ lli sh_array[N]; int id = blockIdx.x * blockDim.x + threadIdx.x; int tid = threadIdx.x; int bid = ...
4,330
#include "includes.h" __global__ void set_dynamic_positions(float *arr, float t) { int threadID = threadIdx.x; int blockID = blockIdx.x; int threads_per_block = blockDim.x; int i = blockID * threads_per_block + threadID; if (threadID == 0 or threadID == 1 or threadID == 2) { arr[i] = arr[i] * t; } }
4,331
#include <dirent.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <malloc.h> #define MAP_COUNT __device__ void mapCount(char*key,char*value,size_t key_size, size_t value_size,int*key_im_size,int*value_im_size,int*map_im_num,int threadID) #define EMIT_IM_COUNT(im_key_size,im_value_size) emitMapCou...
4,332
__global__ void addKernel(const float * a, const float * b, float * res, const int numFloats) { const int index = blockIdx.x * blockDim.x + threadIdx.x; res[index] = a[index] + b[index]; } void addkernel_runSub(const int gs, const int bs, float * p0, float * p1, float * p2, int p3) { addKernel<<<gs, bs>>>(p0, p1,...
4,333
/* College: University of Massachusetts Lowell EECE 7110:High-Performance Comp. on GPUs Semester: Spring 2018 Student : 01639617 Project : Assignment_3 Professor : Dr.Hang Liu Due date: 4/16/2018 Authors : Sai Sri Devesh Kadambari */ #include <stdio.h> #include <stdlib.h> #include <assert.h> #include <time.h> using n...
4,334
// Modified from https://github.com/CVMI-Lab/PAConv/tree/main/scene_seg/lib/pointops/src/knnquery_heap #include <cmath> #include <cstdio> #define THREADS_PER_BLOCK 256 #define DIVUP(m,n) ((m) / (n) + ((m) % (n) > 0)) __device__ void swap_float(float *x, float *y) { float tmp = *x; *x = *y; *y = tmp; } ...
4,335
/* * Zero-Copy example, using vector addition as showcase */ #include <stdio.h> // For the CUDA runtime routines (prefixed with "cuda_") #include <cuda_runtime.h> #define SIZE (1048576) // CUDA kernel, using zerocopy __global__ void vectorAdd(float *A, float *B, float *C, int numElements) { int id = blockDim.x...
4,336
#include <stdio.h> #include <cuda.h> __device__ unsigned dfun(unsigned id) { printf("%d\n", id); if (id > 10 && id < 15) return dfun(id+1); else return 0; } __global__ void dkernel(unsigned n) { dfun(n); } #define BLOCKSIZE 256 int main(int nn, char *str[]) { unsigned N = atoi(str[1]); dkernel<<<1, BLOCKSI...
4,337
// Template for Programming Assignment 2 // Use "module load cuda" to enable compilation with the Nvidia C compiler nvcc // Use "nvcc -O3" to compile code; this can be done even on OSC login node (does not have a GPU) // To execute compiled code, you must either use a batch submission to run on a node with GPU // or ob...
4,338
#include <stdio.h> #include "cuda.h" #define max(x,y) ((x) > (y)? (x) : (y)) #define min(x,y) ((x) < (y)? (x) : (y)) #define ceil(a,b) ((a) % (b) == 0 ? (a) / (b) : ((a) / (b)) + 1) void check_error (const char* message) { cudaError_t error = cudaGetLastError (); if (error != cudaSuccess) { printf ("CUDA error :...
4,339
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <ctime> #include <cmath> #define N (1024) __global__ void kernel(float *dev) { int idx = blockIdx.x * blockDim.x + threadIdx.x; if (N % idx == 0) { dev[idx] = (float) idx; } } int main (int argc, char *argv[]...
4,340
#include "includes.h" cudaEvent_t start, stop; __global__ void cudaComputeYGradient(int* y_gradient, unsigned char* channel, int image_width, int image_height) { int y_kernel[3][3] = { { 1, 2, 1 }, { 0, 0, 0 }, { -1, -2, -1 } }; int index = blockIdx.x * blockDim.x + threadIdx.x; if (index == 0) { return; } y_gradi...
4,341
#define KERNEL_INCLUDE extern __shared__ int local_data[]; __global__ void fillUintArray(uint* bob, uint value, uint length) { uint id = blockIdx.x * blockDim.x + threadIdx.x; if (id < length) bob[id] = value; }
4,342
#include <stdio.h> #include <stdlib.h> #include <cuda_runtime.h> #include <iostream> #include <fstream> const unsigned int BLOCK_SIZE = 1024; __global__ void fastHisto_kernel(unsigned int ** d_out, unsigned int * d_in, unsigned int SIZE){ unsigned int mid = threadIdx.x + blockIdx.x*blo...
4,343
//compile with: nvcc -arch=sm_20 -lcudart #include <stdio.h> #include <string.h> #define Blocksize 10 __global__ void compute(char*, char*); __device__ __host__ void algorithm(char*, char*); __device__ int cudaMemCmp(const char*, const char*, int); __host__ int main (void) { char targets[100]; char* targets2; cha...
4,344
#include "includes.h" __global__ void add(int* in, int offset, int n){ int gid = threadIdx.x + blockIdx.x * blockDim.x; if(gid >= n) return ; extern __shared__ int temp[]; temp[threadIdx.x] = in[gid]; __syncthreads(); //can only control threads in a block. if(threadIdx.x >= offset){ in[threadIdx.x] += temp[threadId...
4,345
#include "includes.h" __global__ void gpu_stencil2D_4pt(double * dst, double * src, int M, int N) { //Declaring the shared memory array for source extern __shared__ double shared_mem[]; double * shSrc = shared_mem; //indexes int i, j; //neighbor's values double north, south, east, west; //SharedMem Collumns Dimens...
4,346
/* We use a term *tile* to identify the rectangular submatrices of the image. Not to be confused with the blocks of threads. */ #include <cuda_runtime.h> #include <stdio.h> #include <thrust/scan.h> #include <thrust/sort.h> #include <thrust/execution_policy.h> #define DSM_MAX_TILES_PER_BLOCK 500 #define DSM_MAX_TIL...
4,347
/*#include <stdio.h> #include <assert.h> #define row 22 #define col 22 __global__ void kernel(float * device_matrix, size_t pitch) { for (int j = blockIdx.y * blockDim.y + threadIdx.y; j < row; j += blockDim.y * gridDim.y) { float* row_device_matrix = (float*)((char*)device_matrix + j*pitch); for (i...
4,348
 #include "cuda_runtime.h" #include "device_launch_parameters.h" #include <iostream> #include <stdio.h> #include <time.h> #include <chrono> //#define SIZE 4194303*1024 //1024*1024 size_t SIZE = 131072 * 1024; #define BLOCKSIZE 1024 __global__ void deviceADD(int* a, int* b, int* c) { int off = threadIdx.x + block...
4,349
#include <stdio.h> const int N = 1 << 29; __global__ void vector_add(float *a, float *b, float *out, long n) { int i = blockDim.x * blockIdx.x + threadIdx.x; out[i] = a[i] + b[i]; } int main(int argc, char **args) { float *a, *b, *out; float *d_a, *d_b, *d_out; a = (float*) malloc(sizeof(float) * N); b = (flo...
4,350
/********************************************************************* * Copyright © 2011-2014, * Marwan Abdellah: <abdellah.marwan@gmail.com> * * This library (cufftShift) is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public * License as published by the F...
4,351
#include <stdio.h> #include <malloc.h> #include <stdlib.h> #include <time.h> #define MATRIX_SIZE 512 // 行列の1辺の数(1024にすると、俺のマシンだろ落ちちゃう。。。) #define BLOCK_SIZE 16 __global__ void matrixMul(int* inMatrixA, int* inMatrixB, int* inMatrixC) { int col_idx = blockIdx.x * blockDim.x + threadIdx.x; int row_idx = blockIdx.y ...
4,352
# include <cuda.h> # include <cuda_runtime.h> extern "C" unsigned char * DFTimageCuda(unsigned char * data, int width, int height); __global__ void processPixelVertical(unsigned char * data_dev, double * PkbReal_dev, double * PkbIm_dev, int width, int height){ int posThread = blockIdx.x*blockDim.x + threadIdx.x; ...
4,353
#include <iostream> #include <cuda_runtime.h> using namespace std; __global__ void sum_kernel(double* A, double* B, double* C, int n){ int idx = blockIdx.x * blockDim.x + threadIdx.x; if (idx < n){ double a = A[idx]; double b = B[idx]; if (idx % 2 == 0) C[idx] = a + b; else C...
4,354
#include "includes.h" __global__ void cudaSMaxBackward_kernel(unsigned int size, float* diffInput, const unsigned int idx, unsigned int* argMax, const float beta, float* result) { const unsigned int index = blockIdx.x * blockDim.x + threadIdx.x; const unsigned int stride = blockDim.x * gridDim.x; if (beta != 0.0f) { f...
4,355
#include "includes.h" __global__ void forward_bias(float *X, float *b, int N, int ch_in, int h_in, int w_in) { int n = blockIdx.x; int ch = blockIdx.y; int h = threadIdx.x; int w = threadIdx.y; X[n * ch_in * h_in * w_in + ch * h_in * w_in + h * w_in + w] += b[ch]; }
4,356
// Mara Isabel Ortiz Naranjo #include <stdio.h> // le agregu el # #include <stdlib.h> #include <cuda_runtime.h> #define N 16 __global__ void kernel( int *a, int *b, int *c ) // Agregu *b { int myID = threadIdx.x + blockDim.x * blockIdx.x; // Solo trabajan N hilos if (myID < N) { c[myID] = a[myID] + b[myID]; ...
4,357
// RK45.cu // //This file contains the function that performs Runge Kutta 45 integration using the DCA algorithm //Included Files #include <iostream> //Function Prototypes // Functions found in Functs.cu void arycpy(double A[],double B[],int n); void arycpy2(double A[],double B[],int n); void arycpy3(double A[],doub...
4,358
#include <stdio.h> #include <iostream> #include <cuda.h> #include <math.h> #include <cuda_runtime.h> #include <ctime> //~ #include <thrust/reduce.h> //~ #include <reduction.h> extern "C" void apply_bc_cuda_(double* p_2); extern "C" void catch_divergence_cuda_(double res2,int ierr,int it); extern "C" void collect_res...
4,359
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <iostream> #include <chrono> using namespace std; float makeCPU(int* inData, int N); float cudaParallel(int* inData, int N); void init(int* inData, int N) { for (int i = 0; i < N; i++) inData[i] = 100 - i + 1; } __glob...
4,360
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <cuda.h> #include <device_functions.h> #include <cuda_runtime_api.h> #include <iostream> #include <assert.h> template <typename T> struct BinaryAssociativeOperator { __host__ __device__ virtual T operator() (const T left, const T right) const ...
4,361
//xfail:REPAIR_ERROR //--blockDim=16 --gridDim=1 --no-inline // #include <cuda.h> __global__ void foo() { __shared__ int A[16]; A[0] = threadIdx.x; }
4,362
#include <stdio.h> #include <cuda_runtime.h> // #include <helper_cuda.h> #define N 1024 #define THREADS_PER_BLOCK 32 __global__ void SingleBlockLoop(){ int i = blockIdx.x * blockDim.x + threadIdx.x; if(i < N) printf("%d\n", i); } int main(void){ cudaError_t err = cudaSuccess; SingleBlockLoop<<<(N + THREADS_PE...
4,363
#include <curand_kernel.h> extern "C" __global__ void uniform_double(int n,double lower,double upper,double *result) { int totalThreads = gridDim.x * blockDim.x; int tid = threadIdx.x; int i = blockIdx.x * blockDim.x + tid; for(; i < n; i += totalThreads) { do...
4,364
#include <cstdio> extern "C" { __global__ void find_maxes(int N, int* table, int* max_table) { int x = (blockIdx.x * blockDim.x) + threadIdx.x; int y = (blockIdx.y * blockDim.y) + threadIdx.y; if (x >= N || y >= N) return; int max_sum = table[0]; for (int i=y; i<N; ++i) { for (int j=x; j<N; ++j) { int tmp ...
4,365
#include <thrust/complex.h> #include <tuple> using F = double; using T = thrust::complex<F>; constexpr F range_x_max = +2; constexpr F range_x_min = -2; constexpr F range_y_max = +2; constexpr F range_y_min = -2; constexpr int block_x = 256; constexpr int block_y = 256; constexpr int thread_x = 32; constexpr int thre...
4,366
#include <stdio.h> # include "cuda_runtime.h" # include "cuda_profiler_api.h" __global__ void add(int n, float *x, float *y, float *z) { int i = blockIdx.x*blockDim.x + threadIdx.x; if (i < n) z[i] = x[i] + y[i]; if (i< n) z[i]++; } int main() { int N = 1<<10; float *x, *y, *z, *d_x, *d_y, *d_z; c...
4,367
#include <stdio.h> #include <cuda_runtime.h> __global__ void hello(void) { printf("Hello World!\n"); } extern "C" int func() { hello <<<1,10>>>(); cudaDeviceReset(); }
4,368
#include <algorithm> #include <chrono> #include <cstdio> #include <fstream> #include <iostream> #include <vector> #include <cuda.h> #include <cuda_runtime.h> #define SIZE 1 using namespace std; int main() { // freopen("swapinout.txt", "w", stdout); long int s[] = { //1, 4, 8, 16, ...
4,369
#include "includes.h" __global__ void normalizeGradient(float* gradient, int* activeMask, int activeSlices, int slices) { int i = threadIdx.x + blockIdx.x * blockDim.x; if (i >= activeSlices) return; int slice = activeMask[i]; float norm = gradient[6 * slices + slice]; if (norm > 0) norm = 1.0f / sqrtf(norm); for (i...
4,370
#include <stdio.h> #include <cuda_runtime.h> #define REP1(x) x #define REP2(x) REP1(x) REP1(x) #define REP4(x) REP2(x) REP2(x) #define REP8(x) REP4(x) REP4(x) #define REP16(x) REP8(x) REP8(x) #define REP32(x) REP16(x) REP16(x) ...
4,371
#include "LBM_GPU.cuh" #include <cmath> ofstream fout_GPU("out_GPU.dat"); ofstream fout_GPU_Ux("out_GPU_Ux.dat"); ofstream fout_GPU_Uy("out_GPU_Uy.dat"); ifstream fin_GPU("in_GPU.txt"); LBM_GPU::LBM_GPU() { // ============================================================================ // // LOAD THE PARAMETERS // =...
4,372
// gpu (device) based matrix/matrix gpu code //------------------------------------------------------------------------- // Included CUDA libraries //------------------------------------------------------------------------- #include <stdio.h> // iceil macro // returns an integer ceil value where integer numerator is f...
4,373
// We assume row_indices, col_indices, and values are of length count struct SparseMatrixCOO { float* values; int* col_indices; int* row_indices; int M; int N; int count; }; // Compared to the sequential SpMV/CSR, the sequential SpMN/COO doesn't waste // time with fully-zero rows void SpMV_COO(const SparseMatri...
4,374
#include "device_launch_parameters.h" #include <iostream> #include <stdio.h> #include <cuda_runtime.h> #include <time.h> using namespace std; #define eps 1e-4 //每个thread负责output的一个pixel __global__ void convolution2d(float *img, float *kernel, float* result, int n, int m, int kw, int kh, int out_n, int out_m, bool padd...
4,375
//---------------------------------------------------------------------- /*!\file gpu_algorithms/basicComplexMath.cu * * \author Felix Laufer * * * CUDA: Collection of basic complex math operations and kernels * */ //---------------------------------------------------------------------- #include <math.h> #...
4,376
#include "includes.h" __device__ __forceinline__ size_t gpu_fieldn_index(unsigned int x, unsigned int y, unsigned int d) { return (NX*(NY*(d-1)+y)+x); } __device__ __forceinline__ size_t gpu_field0_index(unsigned int x, unsigned int y) { return NX*y+x; } __global__ void gpu_bc_charge(double *h0, double *h1, double *h2)...
4,377
#include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <string> #include <iostream> #include <time.h> #include <sys/time.h> int MAX_ITER = 1000; int TEST_TIME = 1; __constant__ double THRESHOLD = 1e-9; double h_THRESHOLD = 1e-9; using namespace std; //Test Convergence for host int isConvergeHost(double *...
4,378
#include "sigmoid-cross-entropy-grad.hh" #include "graph.hh" #include "../runtime/node.hh" #include "../memory/alloc.hh" namespace ops { SigmoidCrossEntropyGrad::SigmoidCrossEntropyGrad(Op* y, Op* logits) : Op("sigmoid_cross_entropy_grad", y->shape_get(), {y, logits}) {} void SigmoidCrossEntropyG...
4,379
#include <math.h> #include <stdlib.h> #include <stdio.h> #include "time.h" #include "string.h" int nchans = 1024, nsamp = 32768; #define ANTS 32 // ======================== CUDA HELPER FUNCTIONS ========================== // Error checking function #define CUDA_ERROR_CHECK #define CudaSafeCall( err ) _cudaSafeCall(...
4,380
#include <stdio.h> #include <assert.h> #include <iostream> void setGrid(int n, dim3 &blockDim, dim3 &gridDim) { // set your block dimensions and grid dimensions here // remember to edit these two parameters each time you change the block size gridDim.x = n / (blockDim.x * 2); gridDim.y = n / (blockDim....
4,381
#include <cuda_runtime.h> #include "device_launch_parameters.h" #include <iostream> // https://stackoverflow.com/a/14038590/4647107 #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true) { if (code != cudaSuccess) { ...
4,382
#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 rng_a, int rng_b, int rng_c) {...
4,383
#include <cuda_runtime.h> //#include <helper_cuda.h> #define cutilSafeCall(err) __cudaSafeCall (err, __FILE__, __LINE__) inline void __cudaSafeCall( cudaError err, const char *file, const int line ) { if( cudaSuccess != err) { //fprintf(stderr, "%s(%i) : cudaSafeCall() Runtime API error %d: %...
4,384
#include "includes.h" __global__ void stats_kernal(const float *data, float * device_soln, const int size, const int num_calcs, const int num_threads, const int offset) { float sum = 0.0f; float sum_sq = 0.0f; int idx = threadIdx.x + blockIdx.x*num_threads + offset; for(int i = 0; i < size; i++){ int index = i*size ...
4,385
//#include "Reduction.h" //#include "RenderScene.h" //#include "ParallelScan.h" // //__global__ void BuildAdjecencyMatrixKernel(cv::cuda::PtrStepSz<float> AM, // PtrSz<ORBKey> TrainKeys, PtrSz<ORBKey> QueryKeys, // PtrSz<float> MatchDist) { // // int x = blockDim.x * blockIdx.x + threadIdx.x; // int y = blockDim.y * ...
4,386
#include "includes.h" __global__ void kOutpTraceMultiplyImages(float *expanded_images, float *expanded_derivs, int num_images, int num_channels, int num_modules_batch, int kernel_size){ int color = blockIdx.y; int module_id = blockIdx.x; expanded_images += num_images * num_modules_batch * kernel_size * color; expanded...
4,387
#include "includes.h" __global__ void pnpoly_cnGPU(char *cs, const float *px, const float *py, const float *vx, const float *vy, int npoint, int nvert) { extern __shared__ int s[]; float *tvx = (float*) s; float *tvy = (float*)&s[nvert]; int i = blockIdx.x*blockDim.x + threadIdx.x; if (i < npoint) { int j, k, c = 0; f...
4,388
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #define L 114 static int AREA = L*L; static int NTOT = L*L - (4*L -4); // #define T 6. // #define T 0.1 // #define T 2.26918531421 #define T_CYCLE_START 1.5 #define T_CYCLE_END 3 #define T_CYCLE_STEP 0.04 #define SINGLETEMP 3.0 int n_temps...
4,389
#include<cuda.h> #include<stdio.h> #include<math.h> #define TILEWIDTH 32 __global__ void vecConvKernel(float* A, float* B, float* C, int n){ //identify the index of the data to be read int tx=threadIdx.x; int bx=blockIdx.x; int index=bx*blockDim.x+tx; __shared__ float Ads[TILEWIDTH]; __shared__ float Bds[2...
4,390
#include <stdio.h> #include <stdlib.h> #include <math.h> __global__ void add(int n, float *x, float *y) { int index = blockIdx.x * blockDim.x + threadIdx.x; int stride = blockDim.x * gridDim.x; for (int i=index; i<n; i += stride) y[i] = y[i] + x[i]; } int main(void) { int n = 1000000; ...
4,391
/* Voxel sampling GPU implementation * Author Zhaoyu SU * All Rights Reserved. Sep., 2019. */ #include <stdio.h> __device__ inline int get_batch_id(int* accu_list, int batch_size, int id) { for (int b=0; b<batch_size-1; b++) { if (id >= accu_list[b]) { if(id < accu_list[b+1]) ...
4,392
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include<stdlib.h> #include<stdio.h> #include<malloc.h> #include<time.h> #define arm 32 __device__ int globalArray[32]; __global__ void add(int *a,int *c) { int tid = threadIdx.x; int temp=a[tid]; int count=0; while(tem...
4,393
/* C stuff */ #include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <unistd.h> #include <string.h> #include <errno.h> // C++ stuff #include <iostream> #include <fstream> #include <string> #include <iomanip> #include <sstream> // Open-CV for the vision stuff //#include <opencv2/opencv.hpp> /* Cuda stuff ...
4,394
#include <stdio.h> #include <assert.h> #define cudaCheckError() { \ cudaError_t e = cudaGetLastError(); \ if (e != cudaSuccess) { \ printf("CUDA Failure %s:%d: '%s'\n", __FILE__, __LINE__, cudaGetErrorString(e)); \ exit(EXIT_FAILURE); \ }...
4,395
#include <stdio.h> #define SIZE 8 __global__ void addVector(int vectorAns[SIZE], int vectorA[SIZE], int vectorB[SIZE]); int main() { int vectorA[SIZE]; int vectorB[SIZE]; int vectorAns[SIZE]; int i; for (i = 0; i < SIZE; i++) { vectorA[i] = i; vectorB[i] = SIZE - i; } i...
4,396
/* CUDA Library for Skeleton 2D Electrostatic GPU PIC Code */ /* written by Viktor K. Decyk, UCLA */ #include <stdlib.h> #include <stdio.h> #include "cuda.h" extern int nblock_size; extern int maxgsx; static cudaError_t crc; /*--------------------------------------------------------------------*/ __device__ void li...
4,397
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <locale.h> #include <stdlib.h> #define N 2000 #define inf 1000000; #define div 200 __global__ void floydCycle(int* b, int i) { int k = blockIdx.x*(N/div)+threadIdx.x; for (int j = 0; j < N; ++j) { int v1 = b[j * N + k]; i...
4,398
#include "includes.h" extern "C" { } __global__ void u8_to_one_hot_f32(const unsigned char* x, unsigned int nclasses, float* y, unsigned int len) { int tid = blockIdx.x * blockDim.x + threadIdx.x; if (tid < len) { y[tid*nclasses+x[tid]] = 1.0f; } }
4,399
#include <stdlib.h> #include <stdio.h> #include <math.h> #define BLOCK_SIZE 3 #define WA 3 #define HA 3 #define WB 3 #define HB WA #define WC WB #define HC HA void randomInit(float * data ,int size) { for(int i = 0; i < size; ++i) data[i] = i; } __global__ void matrixMul(float* C,float* A,float* B,int wA,int wB)...
4,400
#include <cuda.h> #include <curand.h> #include <curand_kernel.h> #include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <stdlib.h> #include <math.h> #include <stdio.h> #define IDX(w, t, n_walkers) ((w) + ((t)*(n_walkers))) /***************************************************************/ __global_...