serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
2,301
#include "includes.h" /** * Programma che simula il comportamento del gpdt per * la risoluzione di un kernel di una serie di * valori di dimensione variabile utilizzando la * tecnologia cuda. * compilare con: * nvcc -o simil_gpdt_si_cuda simil_gpdt_si_cuda.cu * lanciare con: * ./simil_gpdt_si_cuda [numero vettori] [num...
2,302
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdlib.h> #include <stdio.h> cudaError_t cudaDotProduct(int *c, const int *a, const int *b, unsigned int size); int* allocAndAssignMat(int size); __global__ void dot(int *c, const int *a, const int *b) { int i = threadIdx.x + blockIdx.x * ...
2,303
#include <math.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include "time.h" #define NUM_THREADS 256 int nsamp = 65536, ndms = 1024, detrendLen = 32768; // --------------------------- Detrend and Normalisation kernel ---------------------------- __global__ void detrend_normalise(float *input, int d...
2,304
//#include "cudacpp\DeviceVector.h" template<typename type, int size> __global__ void setKernel(type* c, type val) { auto idx = threadIdx.x * size; #pragma unroll(size) for (auto i = 0; i < size; i++) { c[idx] = val; idx++; } }
2,305
template<typename TF> __global__ void doublify(TF* a, const int itot, const int jtot) { const int i = blockIdx.x*blockDim.x + threadIdx.x; const int j = blockIdx.y*blockDim.y + threadIdx.y; const int k = blockIdx.z; int ijk = i + j*itot + k*itot*jtot; a[ijk] += TF(ijk); } template<typename TF> voi...
2,306
#include "includes.h" __global__ void rowDiv(float* a, float* b, float* c, int M, int N){ int i = blockIdx.x*blockDim.x + threadIdx.x; c[i] = a[i]/b[blockIdx.x]; }
2,307
#ifndef __HELPER__ #define __HELPER__ #include <bits/stdc++.h> using namespace std; #define __HD__ __host__ __device__ #define SQR(x) ((x) * (x)) __inline__ __HD__ int rnd(int x, int n) { return ((x + n - 1) / n) * n; } #define LG_BLOCK_N 64 #define LG_BLOCK_M 64 #define LG_BLOCK_K 8 #define LG_THREAD_N 8 #define...
2,308
#include <cuda.h> #include <cuda_runtime.h> #include <stdio.h> #include <stdlib.h> #include <time.h> #define BLOCK_SIZE 32 #define WA 64 #define HA 64 #define HC 3 #define WC 3 #define PAD 1 #define WB (WA+2*PAD - WC + 1) #define HB (HA+2*PAD - HC + 1) #define CHANNEL_SIZE 3 __device__ void flat_conv(floa...
2,309
__global__ void vectorAddition(const float* a, const float* b, float* result, const float scalar) { int index = blockIdx.x * blockDim.x + threadIdx.x; result[index] = a[index] + b[index] + scalar; }
2,310
#include<cuda.h> #include<stdio.h> #include<math.h> #define TILEWIDTH 32 __global__ void vecMulMatrixKernel(float* A, float* B, float* C, int n){ //each block loads the corresponding row of blocks of A matrix and column of blocks of B matrix, one block at a time and then clculates the product for that part then produc...
2,311
/******************************************************************************* * PROGRAM: canny_edge_detector * FILE: non_maximal_supp.cu * PURPOSE: Apply non maximal suppression. * NAME: Vuong Pham-Duy * Faculty of Computer Science and Technology * Ho Chi Minh University of Technology, Viet Nam * ...
2,312
#include <cuda.h> #include <thrust/device_vector.h> #include <thrust/inner_product.h> #include <iostream> #include <stdio.h> //NOTE: COMPILE WITH -arch=sm_20 #define CUDA_CHECK {cudaThreadSynchronize(); \ cudaError_t err = cudaGetLastError();\ if(err){\ std::cout << "Error: " << cudaGetErrorString(err) << " ...
2,313
#include "includes.h" __device__ int translate_idx(int ii, int d1, int d2, int d3, int scale_factor) { int x, y, z, w; w = ii % d3; ii = ii/d3; z = ii % d2; ii = ii/d2; y = ii % d1; ii = ii/d1; x = ii; w = w/scale_factor; z = z/scale_factor; d2 /= scale_factor; d3 /= scale_factor; return (((x*d1+y)*d2)+z)*d3+w; } __gl...
2,314
#include "includes.h" __global__ void convolutionLayers3DKernel( float *d_Dst, float *d_Src, int imageW, int imageH, int imageD, int kernel_index, int kernel_radius ) { __shared__ float s_Data[LAYERS_BLOCKDIM_X][LAYERS_BLOCKDIM_Y][(LAYERS_RESULT_STEPS + 2 * LAYERS_HALO_STEPS) * LAYERS_BLOCKDIM_Z + 1]; //Offset to the ...
2,315
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <iostream> void mean_filter_h(int **img, int **res, int N, int M, int k) { int count; float temp; for(int n = 0; n < N; n++) { for(int m = 0; m < M; m++) { count = 0; temp = 0.0; for(int i = N - k; i <= N + k; i++) { ...
2,316
//#include <algorithm> //#include <vector> // //#include "caffe/layers/clusters_triplet_loss_layer.hpp" //#include "caffe/util/math_functions.hpp" // //namespace caffe { // // template <typename Dtype> // __global__ void ClustersTripletForward(const int nthreads, const int batch_size, // const int dim, const Dtype mar...
2,317
__device__ float magnitude(const float *r) { return pow((r[0] * r[0]) + (r[1] * r[1]) + (r[2] * r[2]), 0.5); } __device__ float magnitude_withId(const float *r) { const int i = blockIdx.x; return pow((r[3 * i] * r[3 * i]) + (r[3 * i + 1] * r[3 * i + 1]) + (r[3 * i + 2] * r[3 * i + 2]), ...
2,318
// #include <algorithm> // #include <vector> // #include "omp.h" // #include <iostream> // using namespace std; // #include "caffe/layers/set_loss2_layer.hpp" // #include "caffe/util/math_functions.hpp" // #include "caffe/util/io.hpp" // namespace caffe // { // template <typename Dtype> // void SetLoss2Layer<Dtype>...
2,319
#include "includes.h" __device__ void find_index(short *vec, const int vec_length, int *value, int *index) { for (int i = threadIdx.x; i < vec_length; i = i + blockDim.x) { if (vec[i] == *value) { atomicMax(index, i); } } } __global__ void find_index(int *vec, const int vec_length, int *value, int *index){ for (int i =...
2,320
#include <cuda.h> #include <stdio.h> #include <stdlib.h> /* __global__ static inline int mandel(float c_re, float c_im, int count) { float z_re = c_re, z_im = c_im; int i; for (i = 0; i < count; ++i) { if (z_re * z_re + z_im * z_im > 4.f) break; float new_re = z_re * z_re - z_im * z_im; floa...
2,321
#include<stdio.h> #include<cuda_runtime.h> bool init_cuda(){ int count; cudaGetDeviceCount(&count); if(0 == count) { fprintf(stderr, "There is no device \n"); return false; } int i; for(i = 0; i < count; i++) { cudaDeviceProp prop; if(cudaSuccess == cudaGetDeviceProperties(&prop, i)) { if(prop.major ...
2,322
#include <stdio.h> #include <cuda.h> // CPU code to do matrix ADdition void matrixAdd(int *a, int *b, int *c, int N) { int index; for(int col=0; col<N; col++) { for(int row=0; row<N; row++) { index = row * N + col; c[index] = a[index] + b[index]; } } } // GPU code to do matrix addition __global__ void...
2,323
/* ============================================================================ Filename : implementation.cu Author : Martino Milani / Sébastien Gachoud SCIPER : 286204 / 250083 ============================================================================ */ #include <iostream> #include <iomanip> #include ...
2,324
#include <stdio.h> #define TILE_SIZE 32 #define KERNEL_RADIUS 8 #define KERNEL_LENGTH (2 * KERNEL_RADIUS + 1) __constant__ float c_M[KERNEL_LENGTH][KERNEL_LENGTH]; const int Width = 3072; const int Height = 3072; const int nIter = 300; float * h_Kernel,*h_Input,*h_Output; float * d_Input, *d_Output; //this optimiza...
2,325
#include "includes.h" #define DOUBLE #ifdef DOUBLE #define Complex cufftDoubleComplex #define Real double #define Transform CUFFT_Z2Z #define TransformExec cufftExecZ2Z #else #define Complex cufftComplex #define Real float #define Transform CUFFT_C2C #define TransformExec cufftExecC2C #endif #define TILE_DIM 8 /...
2,326
#include "includes.h" __global__ void hyst_kernel(unsigned char *data, unsigned char *out, int rows, int cols) { // Establish our high and low thresholds as floats float lowThresh = 10; float highThresh = 70; // These variables are offset by one to avoid seg. fault errors // As such, this kernel ignores the outside r...
2,327
#include "includes.h" __device__ u_char clamp(float t) { if (t < 0) { return 0; } else if (t > 255){ return 255; } return t; } __global__ void kernel_colorSpaceYUV420PToRGBA(dev_t *src, dev_t *dst, int pitch_src, int pitch_dst, int w, int h) { unsigned int dim_x = blockDim.x * blockIdx.x + threadIdx.x; unsigned in...
2,328
/* #include "dpCudaFFT.hpp" #include "errorCheck.hpp" #define BEGIN cudaEventRecord(begin, 0); #define END cudaEventRecord(end, 0); cudaEventSynchronize(end); cudaEventElapsedTime(&delTime, begin, end); #define cudaErrChk(ans) { gpuAssert((ans), __FILE__, __LINE__); } //code from stackexchange to print cuda return me...
2,329
#include<iostream> #include<fstream> using namespace std; const int N = 4096; const int BLOCKSIZE = 1024; __global__ void add_me(int *a, int *b, int *c) { int i = blockIdx.x * blockDim.x + threadIdx.x; c[i] = a[i] + b[i]; } int main() { ofstream outfile; outfile.open("output.txt"); int a[N] = {0}; ...
2,330
#include <stdio.h> #include <stdlib.h> #define DSIZE 256 #define nTPB 64 #define cudaCheckErrors(msg) \ do { \ cudaError_t __err = cudaGetLastError(); \ if (__err != cudaSuccess) { \ fprintf(stderr, "Fatal error: %s (%s at %s:%d)\n", \ msg, cudaGetErrorString(__err), \ ...
2,331
#include "includes.h" __global__ void matrixMul(int *a, int *b, int *c){ int my_x, my_y; my_x = blockIdx.x*blockDim.x + threadIdx.x; my_y = blockIdx.y*blockDim.y + threadIdx.y; int local_c = 0; for(int i = 0 ; i < size; i++) local_c += a[my_x * size + i] * b[i * size + my_y]; c[my_x * size + my_y ] = local_c; }
2,332
#include <stdio.h> /* * This file is an attempt at producing what the generated target code * should look like for the multiplyMatrixMatrix routine. */ /* Prototype matrix representation. */ struct dag_array_t{ size_t rows; size_t cols; int* matrix; }; /* DAG Primitive. Here, we leverage the NVIDI...
2,333
#include <cstdio> #include <cstring> #include<iostream> using namespace std; class Myclass { public: Myclass(int a=0,int b=0) {_a=a;_b=b;} virtual __host__ __device__ void printValues() { printf("a = %d, b = %d\n", _a, _b); } private: int _a; int _b; }; __global__ void virtualFu...
2,334
#include <iostream> #include <cmath> #include <vector> #include <random> #include <cassert> #define GPU_CHECK(ans) { gpuAssert((ans), __FILE__, __LINE__); } constexpr auto VECTOR_LENGTH = 1024u * 2; constexpr auto EPS = 1e-4f; inline void gpuAssert(cudaError_t code, const char *file, int line, ...
2,335
/* 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,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,float var_12,float var_13,floa...
2,336
/* #include "LennardJones.h" //------------------------Lennard Jones Potential -----------------------------// __host__ __device__ double lennardJonesForce(double dist, double sig, double eps) { double sigsq = sig*sig; double con = 24.0*eps/sigsq; double dist2 = dist * dist; dist2 /= sigsq; double dist4 = dist2...
2,337
#include "includes.h" __global__ void ForwardCrossEntropy(float *output, float *labels, int nColsOutput, float *loss) { int col = blockIdx.x; float temp = -(labels[col] * logf(output[col]) + logf(1 - output[col]) * (1 - labels[col])); atomicAdd(loss, temp); }
2,338
#include "includes.h" __global__ void kHingeLinearRowMajor(float* mat, float* labels, float* target, unsigned int width, unsigned int height, float margin) { int image_id = blockIdx.x * blockDim.x + threadIdx.x; if (image_id < height) { mat += image_id; target += image_id; const int correct_label = (int)labels[image_id...
2,339
#include <iostream> #include <stdio.h> #include <math.h> #include <sys/time.h> #define MATRIX_SIZE 256 #define BLOCK_SIZE 16 using namespace std; __global__ void matMul(float *x, float *y, float *z, int matrixSize){ float zTemp = 0.0f; __shared__ float xblkMat[BLOCK_SIZE*BLOCK_SIZE], yblkMat[BLOCK_SIZE*BLOCK_SI...
2,340
#include "includes.h" __global__ void kernel_push_atomic2(int *g_terminate, int *g_push_reser, int *s_push_reser, int *g_block_num, int width1) { int x = __umul24(blockIdx.x, blockDim.x) + threadIdx.x; int y = __umul24(blockIdx.y, blockDim.y) + threadIdx.y; int thid = __umul24(y, width1) + x; if (s_push_reser[thid] -...
2,341
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <cuda.h> #define BLOCKS 8 #define THREADS 16 #define WIDTH 128 #define HEIGHT 64 __global__ void add(int* a, int* b, int* c) { int idx = threadIdx.x + blockIdx.x * blockDim.x; int idy = threadIdx.y + blockIdx.y * blockDim.y; if (id...
2,342
#include <iostream> #include <chrono> #include <cassert> #include <cmath> #include <cstdlib> #include <vector> #include <algorithm> #define BLOCKSIZE 128 #define LOG_BLOCKSIZE 7 // MUST BE ASSOCIATIVE __device__ inline int f(int a, int b){ return a + b; } /** * In this variant, several optimizations have been a...
2,343
/* 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,float var_3,float var_4,float var_5,int var_6,float var_7,float var_8,float var_9,float var_10,float var_11,float var_12,float var_13,float ...
2,344
#include <stdio.h> const int TILE_DIM = 32; const int BLOCK_ROWS = 8; const int NUM_REPS = 100; __global__ void copy(float *odata, const float *idata) { int x = blockIdx.x * TILE_DIM + threadIdx.x; int y = blockIdx.y * TILE_DIM + threadIdx.y; int width = gridDim.x * TILE_DIM; for (int j = 0; j < TILE_DIM; j += ...
2,345
#include "includes.h" __global__ void copy(float *odata, const float *idata) { int x = blockIdx.x * TILE_DIM + threadIdx.x; int y = blockIdx.y * TILE_DIM + threadIdx.y; int width = gridDim.x * TILE_DIM; for (int j = 0; j < TILE_DIM; j+= BLOCK_ROWS) odata[(y+j)*width + x] = idata[(y+j)*width + x]; }
2,346
#include <iostream> #include <complex> #include <math.h> #include <thrust/complex.h> #include <sys/time.h> using namespace std; __global__ void fft(thrust::complex<double> *g_odata, thrust::complex<double> *g_idata, int n) { extern __shared__ thrust::complex<double> temp[]; // allocated on invocation int thid = thr...
2,347
#include <iostream> #include <math.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]; } int main(void){ int N = 1<<20; // 1M elemenets std::cout << N << std::endl; float *x, *y; cud...
2,348
extern "C" __global__ void mtranReference( float *output, float *input, const int width, const int height) { int x = blockIdx.x*blockDim.x + threadIdx.x; int y = blockIdx.y*blockDim.y + threadIdx.y; output[y*width + x] = input[x*height + y]; }
2,349
#include <iostream> #include <sys/time.h> #include <cuda.h> using namespace std; #define CUDA_CHECK_RETURN(value) {\ cudaError_t _m_cudaStat = value;\ if (_m_cudaStat != cudaSuccess) {\ fprintf(stderr, "Error %s at line %d in file %s\n", cudaGetErrorString(_m_cudaStat), __LINE__, __FILE__);\ ...
2,350
#include <iostream> using namespace std; __global__ void square(float *d_out, float *d_in){ int idx = blockDim.x*blockIdx.x + threadIdx.x; float f = d_in[idx]; d_out[idx] = f*f; } int main(){ const int ARRAY_SIZE = 10000; const int ARRAY_BYTES = ARRAY_SIZE * sizeof(float); float h_in[ARRAY_SI...
2,351
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdlib.h> #include <stdio.h> __global__ void Read_texture_obj_kernel(float *iptr, cudaTextureObject_t tex) { int x = threadIdx.x + blockIdx.x * blockDim.x; int y = threadIdx.y + blockIdx.y * blockDim.y; int offset = x + y * blockDim.x * grid...
2,352
#include <array> // CUDA kernel. Each thread takes care of one element of c template<class T> __global__ void vecAdd(T *a, T *b, T *c, int n) { // Get our global thread ID int id = blockIdx.x*blockDim.x+threadIdx.x; // Make sure we do not go out of bounds if (id < n) c[id] = a[id] + b[id]; } ...
2,353
/***************************************************************************//** * \file projectVelocity.cu * \author Anush Krishnan (anush@bu.edu), * \author Christopher Minar (minarc@oregonstate.edu) * \brief kernels to update the velocity field */ #include "projectVelocity.h" namespace kernels { __global__ v...
2,354
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <time.h> #include <stdio.h> #include <stdlib.h> //#include <atlimage.h> enum color_transform_t { grayscale, sRGB, LAB }; enum transform_t { Gaussian }; #define SIZE 1000 //typedef struct //{ // int r; // int g; // int b; //} rgb_t; // /...
2,355
#include <stdio.h> #include <iostream> #include <cstdlib> #include <limits.h> #include <algorithm> #include <sys/time.h> #include <cuda_runtime.h> using namespace std; #define INF INT_MAX-1 __global__ void FloydWarshall(int k, int i, float *matrix, int n) { int col = blockIdx.x * blockDim.x + threadIdx...
2,356
#include <stdio.h> #include <stdlib.h> #include "cuda_runtime.h" #include "device_launch_parameters.h" __global__ void hello_kernel() { printf("Hello World from Thread %d\n", threadIdx.x); } int main(int argc, char *argv[]) { //set the CUDA device to the default CUDA GPU (device 0) cudaError result = cudaSetDevi...
2,357
#include <iostream> #include <stdlib.h> #include <stdio.h> #include <time.h> #include <unistd.h> #include <cuda.h> #include <cuda_runtime.h> //extern __device__ int testxyz[1000]; //int localtrace[10000]; //__device__ float* tracehandle; __device__ float foo_CC(float a) { return a*0.9; } __device__ int foo_DD(float...
2,358
//xfail:BOOGIE_ERROR //--blockDim=1024 --gridDim=1 --no-inline //error: possible null pointer access #include <stdio.h> #include <assert.h> #include <cuda.h> #define N 2//8 #define tid (blockIdx.x * blockDim.x + threadIdx.x) __device__ float multiplyByTwo(float *v, unsigned int index) { return v[index] * 2.0f;...
2,359
#include<stdio.h> #include<stdlib.h> #include<curand_kernel.h> #include<curand.h> #include<sys/time.h> unsigned int NUM_PARTICLES = 1000000; unsigned int NUM_ITERATIONS = 10; unsigned int BLOCK_SIZE = 192; //unsigned int GRID_SIZE = ((NUM_PARTICLES/BLOCK_SIZE) + 1); unsigned int NUM_STREAMS = 10; typedef struct { f...
2,360
#include "includes.h" __global__ void kernel_1(int columns, int rows, float* mat1, float* matanswer) { int columna = threadIdx.x; //En que columna operamos (no filas) float temp_value = 0; for (int k = 0; k < rows; k++) { temp_value = temp_value + mat1[(k * columns) + columna]; } matanswer[columna] = temp_value; }
2,361
#include <iostream> #include <sys/time.h> #define N 16 __global__ void add(int *a, int *b, int *c) { int i = blockIdx.x; if(i < N) c[i] = a[i] + b[i]; } void add_host(int *a, int *b, int *c) { for(int i = 0; i < N; i++) { c[i] = a[i] + b[i]; } } int main (void) { // variables...
2,362
#include <stdio.h> #define FIRST_CHAR 32 #define LAST_CHAR 128 #define NBR 96 __global__ void histo_kernel(unsigned char *buffer,long size, unsigned int *histo){ __shared__ unsigned int temp[256]; temp[threadIdx.x]=0; int i = threadIdx.x + blockIdx.x *blockDim.x; int offset = blockDim.x *gridDim.x; while(i<size)...
2,363
#include <cuda_runtime.h> #include <cuda.h> #include <stdio.h> #include <stdlib.h> #include <math.h> // needed for the function sqrtf() #define TILE_SIZE 32 // NB // Block SIZE /* * Function to perform rank-k update * half of the threads working */ __device__ void ssyrk_tile(float* rA1, float* rA2) { i...
2,364
#include <cuda.h> #include <stdio.h> #include <time.h> #include <stdlib.h> // kernel __global__ void convolution_1D_Kernel(float* d_m, float* d_mask, float* d_n, size_t length, size_t maskLength) { // indexing variables int i = blockIdx.x * blockDim.x + threadIdx.x; int m_index = i - maskLength / 2; ...
2,365
#include <stdio.h> //compilar: nvcc matrizMultiplicacao.cu -o matrizMultiplicacao //for i in `seq 1 10`; do ./matrizMultiplicacao; done #define N 2048 #define B 32 __global__ void matrix_multi(float *a, float *b, float *c) { int y = blockIdx.x * blockDim.x + threadIdx.x; int x = blockIdx.y * blockDim.y + threadIdx...
2,366
#include<stdio.h> #include<cuda_runtime.h> #include "device_launch_parameters.h" #include <ctime> #include <iostream> using namespace std; #define BLOCK 16 #define WIDTH 1024 float* d_A, * d_B, * d_C; __global__ void d_multiply0(float* A, float* B, float* C) { unsigned int r = blockDim.y * blockIdx.y + threadId...
2,367
#include "includes.h" __global__ void cunn_MSECriterion_updateGradInput_kernel(float *gradInput, float *input, float *target, float norm, int nframe, int dim) { int k = blockIdx.x; float *gradInput_k = gradInput + k*dim; float *input_k = input + k*dim; float *target_k = target + k*dim; int i_start = threadIdx.x; int i...
2,368
__global__ void doublify(float *a) { int idx = threadIdx.x + threadIdx.y*4; a[idx] *= 2; }
2,369
#include <stdio.h> #include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> // problem parameters const double a = 1.; const double b = 1.; const int nx = 1024; //number of node points along y const int ny = 1024; //number of node points along x //convergence parameters double tol = 1e-4; int iter_...
2,370
#include "includes.h" __device__ unsigned int getGid3d3d(){ int blockId = blockIdx.x + blockIdx.y * gridDim.x + gridDim.x * gridDim.y * blockIdx.z; int threadId = blockId * (blockDim.x * blockDim.y * blockDim.z) + (threadIdx.y * blockDim.x) + (threadIdx.z * (blockDim.x * blockDim.y)) + threadIdx.x; return threadId; } _...
2,371
#include "includes.h" __global__ void RBMDropoutMaskKernel( float *maskPtr, float dropout, int thisLayerSize ) { int index = blockDim.x * blockIdx.y * gridDim.x //rows preceeding current row in grid + blockDim.x * blockIdx.x //blocks preceeding current block + threadIdx.x; if (index < thisLayerSize) { maskPtr[inde...
2,372
#include "cuda_runtime.h" #include <stdlib.h> #include <stdio.h> #define NUM_ELEMENTS (1024 * 1024 * 10) #define RUN (100) void globalReduceSum(float *out, const float *in, int numElements); void sharedReduceSum(float *out, const float *in, int numElements); void warpReduceSum(float *out, const float *in, int numElem...
2,373
// CUDA libraries. #include <cuda.h> #include <cuda_runtime.h> //dynamical // Include associated header file. #include "cuda_kernel.cuh" #include <stdio.h> __global__ void dotProductKernel(double* A, double* B, double* result) { // number of elements per thread block const int N = 256; // shared memory...
2,374
//Test 1 #include<cuda.h> #include <bits/stdc++.h> using namespace std; //Sequential //Vector addition kernel void vecAdd(float *h_A, float *h_B, float *h_C, int n){ int i; for (i = 0; i < n; i++) h_C[i] = h_A[i] + h_B[i]; } //Parallel __global__ void vecAddP (float *A, float *B, float *C, int n){ ...
2,375
/* * Team - Suraj Singh and Mahir Jain * Roll Numbers - 16CO146 and 16CO123 respectively. */ #include <stdio.h> #include <cuda.h> #include <time.h> #define r_size 10 #define c_size 28 // Only one black is used. #define BLOCKS 1 // Depends on the GPU used. #define THREADS 1024 // Function for calculating execution...
2,376
#include <cuda_runtime.h> #include <stdio.h> __global__ void checkIndex(void){ printf("threadIdx: (%d, %d, %d) blockIdx: (%d, %d, %d) \ blockDim: (%d, %d, %d) gridDim: (%d, %d, %d)\n", threadIdx.x, threadIdx.y, threadIdx.z, blockIdx.x, blockIdx.y, blockIdx.z, blockDim.x, blockDim.y...
2,377
#include <thrust/device_vector.h> #include <thrust/host_vector.h> #include <iostream> #include <chrono> #include <thrust/extrema.h> #include <thrust/execution_policy.h> #include <thrust/functional.h> int main() { thrust::host_vector<double> host(10, 0); for(int i = 0; i<10;i++){ double s; std...
2,378
#include "includes.h" __global__ void mat_mult_transposed_kernel(int *mat_a, int *mat_b, int *res) { int B_TRANS_ROWS = B_COLS; int B_TRANS_COLS = B_ROWS; // El for each thread, shared per block __shared__ int smem[128]; for (int row_block = 0; row_block * gridDim.x < A_ROWS; row_block++) { int a_row = blockIdx.x + (r...
2,379
#include "includes.h" #define FALSE 0 #define TRUE !FALSE #define NUMTHREADS 16 #define THREADWORK 32 __global__ void gpuPMCCNoTest(const float * vectsa, size_t na, const float * vectsb, size_t nb, size_t dim, const float * numPairs, const float * means, const float * sds, float * correlations) { size_t offset...
2,380
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#miscellaneous-instructions-pmevent extern "C" __global__ void run_atomics( const float *A, const float *B, float *OUT, int numElements) { int id = blockDim.x * blockIdx.x + threadIdx.x; asm("pmevent 1;"); asm("pmevent...
2,381
#ifndef KERNEL_REDUCE #define KERNEL_REDUCE #include <math.h> #include <float.h> #include <cuda.h> __global__ void gpu_Heat(float *h, float *g, float *residuals, int N) { float diff = 0.0; int tidx = blockIdx.x * blockDim.x + threadIdx.x; int tidy = blockIdx.y * blockDim.y + threadIdx.y; if (tidx > 0...
2,382
#include "includes.h" __global__ void ComputeCubesKernel( float *pointsCoordinates, float *vertexData, int quadOffset, float cubeSide, int *activityFlag, int textureWidth, int maxCells ) { int threadId = blockDim.x*blockIdx.y*gridDim.x //rows preceeding current row in grid + blockDim.x*blockIdx.x //blocks preceedi...
2,383
#include <stdio.h> #include <stdlib.h> #include <cmath> using namespace std; void zzz2(int c){ if(c<10){ char a=c+'0'; printf("%c",a); }else{ char a=c-10+'a'; printf("%c",a); } } void zzz1(uchar3 a){ int x=a.x; int y=a.y; int z=a.z; zzz2(x/16); zzz2(x%1...
2,384
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <cstdlib> #include <cstdio> #include <cassert> #include <iostream> #include <cmath> __global__ void fibonacci_kernel(double* a, int n) { unsigned int index = threadIdx.x; if (index < n) a[index] = (pow((1 + sqrt(5.0)) / 2, index...
2,385
extern "C" __global__ __launch_bounds__(256) void sgemm_nn_128x128( const float *param_A, const float *param_B, float *param_C, float param_alpha, float param_beta, int param_lda8, int param_ldb8, int param_ldc, int param_m, int param_n, int param_k) { __shared__ float share[128 * 8 * 4 + 32]; ...
2,386
#include <cuda_runtime_api.h> #include <stdio.h> int main(){ cudaStream_t s; cudaError_t res; res = cudaStreamCreate(&s); printf("res : %d\n", res); res = cudaStreamDestroy(s); printf("res : %d\n", res); return 0; }
2,387
#include "CCubicDomain.cuh" namespace NBody { //ds ctor/dtor //ds default constructor requires environmental parameters: N number of bodies, dT time step, T number of time steps CCubicDomain::CCubicDomain( const unsigned int& p_uNumberOfParticles ): m_arrPositions( 0 ), ...
2,388
#include "includes.h" __global__ void vecAdd_kernel(float *c, const float* a, const float* b) { int idx = blockIdx.x * blockDim.x + threadIdx.x; for (int i = 0; i < 500; i++) c[idx] = a[idx] + b[idx]; }
2,389
#include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <cuda_runtime.h> //device (1) __global__ void suma_2_enteros(int *d1, int *d2, int *sum){ *sum = *d1 + *d2; } //HOST int main(int argc, char **argv){ int DeviceCount = 0; int h_d1, h_d2, h_sum; //HOST int *d_d1, *d_d2, *d_sum; //DEVICE (2) h_d1...
2,390
#include <chrono> #include <iostream> #include <random> #include <cuda.h> using std::cout; using std::endl; __global__ void multiply_me_GPU(int *a, int *b, int *c, int width) { int row = blockIdx.y * gridDim.y + threadIdx.y; int column = blockIdx.x * gridDim.x + threadIdx.x; int sum = 0; for (int i...
2,391
#include <stdio.h> #define CSC(call) { \ cudaError err = call; \ if(err != cudaSuccess) { \ fprintf(stderr, "CUDA error in file '%s' in line %i: %s.\n", \ __FILE__, __LINE__, cudaGetErrorString(err)); \ exit(1); \ } ...
2,392
#include "includes.h" /* * CudaOperations.cu * * Created on: Feb 6, 2019 * Author: alexander */ __global__ void allocHamiltonian(float* devMat, float* devSpins, int index, int size, double* energyTempor) { int i; int j; int wIndex = threadIdx.x + blockIdx.x * blockDim.x; while (wIndex < size * size) { i = wInd...
2,393
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> using namespace std; __global__ void hello(){ printf("hello?\n"); return; } __global__ void mtxAddKernel(int* d_a, int* d_b, int m, int n, int* d_c){ int x = blockIdx.x * blockDim.x + threadIdx.x; int y = blockIdx.y * blockDim.y + thread...
2,394
#include "includes.h" __global__ void Correlation_backward_input1(int item, float *gradInput1, int nInputChannels, int inputHeight, int inputWidth, float *gradOutput, int nOutputChannels, int outputHeight, int outputWidth, float *rInput2, int pad_size, int kernel_size, int max_displacement, int stride1, int stride2) { ...
2,395
#include<stdio.h> #include<iostream> using namespace std; /* a sum reduction on the array of floats 'in'. * The reduction result is written to the * address 'result'. The number of elements to * be reduced is given by 'size' * * The example contains data r...
2,396
//#include "cuda_runtime.h" //#include <cuda.h> //#include <cuda_runtime_api.h> //#include "device_launch_parameters.h" #include<stdio.h> //#include<stdlib.h> //#include<string.h> //#include<math.h> //#include<cutil.h> #include<iostream> #define NUM 2048 /////////////////////////////////////////////////////////////...
2,397
#include <stdio.h> #include <stdlib.h> #include <cuda_runtime.h> #include <time.h> __global__ void vAdd(float* A, int num_elements, int factor_hilos, float* s){ //__local__ float a = 0.0; __shared__ float a; if(threadIdx.x == 0) a = 0.0; __syncthreads(); //Posicion del thread int i = (blockIdx.x * blockDim...
2,398
//System header #include <stdio.h> #include <stdlib.h> #include <time.h> //CUDA header #include "cuda_runtime.h" #include "device_launch_parameters.h" __global__ void CUParaSgemv(const float *a, float *b, float *c,unsigned int size)//valid { unsigned int id = blockIdx.x * blockDim.x + threadIdx.x; //int i = thr...
2,399
#include "includes.h" __global__ void matrix_2d_mul_float_gpu(float *A, float *B, float *C, int num_rows_A, int num_cols_A, int num_cols_B) { // Create shared variables (Available to all threads on the same block) __shared__ float A_tile[N_THREADS][N_THREADS]; __shared__ float B_tile[N_THREADS][N_THREADS]; // Block ind...
2,400
#include <emmintrin.h> #include <sys/time.h> #include <stdio.h> const long N = 1000000; // Change array size (may need a long) /////////////////////////////////////////////////////////////////////////////////////////////////////////// // HELPER CODE TO INITIALIZE, PRINT AND TIME struct timeval start, end; void sta...