serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
22,801
#include "includes.h" __global__ void saxpy_float4s ( float* y, float* x, float a, clock_t * timer_vals) { for (int i=0; i < NUM_ITERS/4; i++) { unsigned int idx = i * COMPUTE_THREADS_PER_CTA * CTA_COUNT + blockIdx.x * COMPUTE_THREADS_PER_CTA + threadIdx.x; float4 * x_as_float4 = (float4 *)x; float4 * y_as_float4 = (f...
22,802
#include "includes.h" __global__ void NmDistanceGradKernel(int b, int n, const float *xyz1, int m, const float *xyz2, const float *grad_dist1, const int *idx1, float *grad_xyz1, float *grad_xyz2) { for (int i = blockIdx.x; i < b; i += gridDim.x) { for (int j = threadIdx.x + blockIdx.y * blockDim.x; j < n; j += blo...
22,803
#include<iostream> #include<algorithm> #include<stdio.h> #include<fstream> #include <stdlib.h> using namespace std; #define REPEAT 1 #define Real double #define STRIDE 1 #define CACHELINE 8 __global__ void VecAdd(Real* A, int* N, Real* d_time); int main(int argc, char* argv[]) { if(argc != 2) { std::cout <...
22,804
#include <iostream> #include <vector> #include <random> #include <cuda_runtime.h> using TheType = float; constexpr auto TheSize = 65536u*128u; constexpr auto TheSizeInBytes = TheSize*sizeof(TheType); constexpr auto TheInnerLoop = 256u; __global__ void add(const float *xs1, const float *xs2, float *ys, int size) { ...
22,805
#include <stdio.h> #define MATRIX_ROWS 5 #define MATRIX_COLUMNS 5 #define SHARED_MEMORY_PADDING 1 __global__ void createMatrixStatic(float* out) { __shared__ float matrix[MATRIX_ROWS][MATRIX_COLUMNS]; int idx = blockIdx.y * blockDim.x + threadIdx.x; int idy = blockIdx.x * blockDim.y + threadIdx.y; if (idx < MATR...
22,806
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <cuda.h> #define N 1024 * 1024 #define CHECK_CUDA_ERR(x) { \ err = x; \ if (err != cudaSuccess) { \ printf("cuda error with %s in line %d\n",cudaGetErrorString(err),__LINE__); \ exit(1); \ } } int main() { cudaError_t e...
22,807
#include "includes.h" __device__ int tex_i(const int * ptData,int y,int x,int step) { return ptData[y*step+x]; } __global__ void nonmaxSuppression(const short2* kpLoc_Device, int count, const int* score_DeviceMat,int cols,int rows,short2* locFinal, float* responseFinal) { const int kpIdx = threadIdx.x + blockIdx.x * b...
22,808
#include <stdio.h> #include <cuda.h> __global__ void calculate_g_image_gpu(float* in, float* out, int w, int h){ int x = blockDim.x * blockIdx.x + threadIdx.x; int j = x % w; int i = x / w; if (1 <= i && i < h && 1 <= j && j < w) { float val = pow((in[(i+1)*w+j]-in[(i-1)*w+j])/2, 2) + pow((in[i...
22,809
#include <stdlib.h> #include "cuda.h" #include <iostream> #define RADIUS 3 //TODO: Change to larger values #define N 1000000 void initializeWeights(float* weights) { weights[0] = 0.05f; weights[1] = 0.10f; weights[2] = 0.20f; weights[3] = 0.30f; weights[4] = 0.20f; weights[5] = 0.10f; weig...
22,810
/// managed mamory analysis - cuda lab cpu->gpu only mamory access #include <stdio.h> #include <stdlib.h> #include <chrono> using namespace std::chrono; __global__ void deviceKernel(int *a, int N) { int idx = threadIdx.x + blockIdx.x * blockDim.x; int stride = blockDim.x * gridDim.x; for (int i = idx; i < N; i ...
22,811
//Mesh Laplacian //Author: Weiyue Wang //Reference: https://github.com/charlesq34/pointnet-autoencoder/blob/master/tf_ops/nn_distance/tf_nndistance_g.cu // https://github.com/PointCloudLibrary/pcl/blob/master/tools/mesh_sampling.cpp #if GOOGLE_CUDA #define EIGEN_USE_GPU #include <stdio.h> #include <assert.h>...
22,812
#include "includes.h" __global__ void x_calculation(float * x ,float * r,float * r_squared ,int size) { int index = blockDim.x * blockIdx.x + threadIdx.x ; if (index < size) { float alpha = r_squared[0] ; x[index] = x[index] + alpha * r[index] ; } }
22,813
/* * makeEigenvalues() * float* eigenvalues: Will be populated by the function * float** eigenvectors: Will be populated by the function * float* blockHessian: A linear array containing the block Hessian * matrices in sorted order. Note that these * have different sizes....
22,814
#include <stdio.h> #include <stdlib.h> const int INF = 1000000000; int V = 20010; void input(char *inFileName); void output(char *outFileName); void block_FW(int B); int ceil(int a, int b); int n, m; // Number of vertices, edges int* host_ptr = NULL; size_t pitch; // for device int* device_ptr = NULL; __global__ vo...
22,815
//********************************************************************** // * // University Of North Carolina Charlotte * // * //Program: Vecotr adder ...
22,816
#include "includes.h" __global__ void kLogisticCorrectNormalized(float* mat, float* targets, float* out, unsigned int height, unsigned int width) { const unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x; if (idx < height) { float correct = 0; float total = 0; float p, t; for (int i = idx; i < width * height; i ...
22,817
#include <stdio.h> #include <cuda.h> #define N 1024 __global__ void dkernel(unsigned *a, unsigned chunksize) { unsigned start = chunksize * threadIdx.x; for (unsigned nn = start; nn < start + chunksize; ++nn) { a[nn]++; } } int main() { unsigned *a, chunksize = 32; cudaMalloc(&a, sizeof(unsigned) * N); dkernel<...
22,818
#include <cstring> #include <fstream> #include <iostream> #ifndef SHA256_H #define SHA256_H #include <string> class SHA256 { protected: const static unsigned int sha256_k[]; static const unsigned int SHA224_256_BLOCK_SIZE = (512/8); public: void init(); void update(const unsigned char *message, unsign...
22,819
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> __global__ void cal(int *a, int *b, int x1) { int i = blockIdx.x; b[i] = x1 * a[i] + b[i]; } int main() { int a[20], b[20]; int n, i; printf("Enter size"); scanf("%d",&n); printf("\nEnter set 1 \n"); for(...
22,820
#include "includes.h" __global__ void devicetodevicecopy(double *dphi, double *dpsix, double *dpsiy, double *mphi, double *mpsix, double *mpsiy, unsigned int nx, unsigned int TileSize) { unsigned int bx = blockIdx.x; unsigned int by = blockIdx.y; unsigned int tx = threadIdx.x; unsigned int ty = threadIdx.y; unsigned ...
22,821
#include<iostream> using namespace std; __global__ void add(int *a,int *b,int *c,int n) { int id=blockIdx.x*blockDim.x+threadIdx.x; if(id<n) { c[id]=b[id]+a[id]; } } int main() { cout<<"Enter the no of elements"<<endl; int n; cin>>n; int a[n],b[n],c[n]; for(int i=0;i<n;i++) { a[i]=b[i]=i+1; } i...
22,822
#include "includes.h" __global__ void Add(float *a, float *b, float *c) { int Id = threadIdx.x + blockDim.x * blockIdx.x; if (Id < N) { a[Id] = threadIdx.x; b[Id] = blockIdx.x; c[Id] = Id; } }
22,823
//pass //--blockDim=10 --gridDim=64 --no-inline #include "cuda.h" __device__ void bar(int* p) { p[threadIdx.x] = 0; } __global__ void foo() { __shared__ int A[10]; int* p = A; bar(p); }
22,824
#include <stdio.h> #define LENGTH 16 #define THREADNUM 4 #define BLOCKNUM 2 static void HandleError(cudaError_t err, const char *file, int line) { if (err != cudaSuccess) { printf("%s in %s at line %d\n", cudaGetErrorString(err), file, line); ...
22,825
#include<stdio.h> #define N 10000 // Kernel definition __global__ void VecAdd(int* A, int* B, int* C) { int i = threadIdx.x; C[i] = A[i] + B[i]; //printf("%i ",C[i]); } int main() { int A[N],B[N],C[N],*d_a,*d_b,*d_c; int i; for(i=0;i<N;i++){ A[i]=1; B[i]=1; } cudaMalloc((void**)&d_a,...
22,826
#include <cstdio> #include <cmath> __global__ void vector_add(double *C, const double *A, const double *B, int N) { // Add the kernel code int idx = blockIdx.x * blockDim.x + threadIdx.x; // Do not try to access past the allocated memory if (idx < N) { C[idx] = A[idx] + B[idx]; } } int ma...
22,827
#include "TerrainModifier.cuh" __global__ void submerge(float** map, int width, int height){ //Gets the thread numbers int threadX = threadIdx.x + blockIdx.x * blockDim.x; int threadY = threadIdx.y + blockIdx.y * blockDim.y; //Gets the stride to increase int strideX = gridDim.x*blockDim.x; int strideY = gridDim...
22,828
//Input------------------------------------------------------------------------------------------------- #define WindowDimension 3 // this is the dimension of the window. #define PatchSigma 0.01 // this is h squared , mentioned in the report #define Sigma 0.05 // this is the sigma...
22,829
#include "includes.h" __global__ void cunnx_WindowGate_updateGradInput_kernel( float *gradInput, float *error, float* targetCentroids, const float *centroids,const float *input, const float *outputIndice, const float* output, const float* gradOutput, int inputSize, int outputSize, int outputWindowSize, float c, float d...
22,830
#include "includes.h" #define max(a, b) a > b ? a : b #define min(a, b) a < b ? a : b struct Edge{ long long int x; }; ///* //*/ __global__ void initialize_active_edges(bool* active_edges, int e){ int bid = blockIdx.x; int id = bid*blockDim.x + threadIdx.x; if(id < e) active_edges[id] = true; return; }
22,831
// Samuel Grenon // CS 443 // Dr. Mock // Problem 4: #include "stdio.h" #define COLUMNS 8 #define ROWS 8 __global__ void add(int * a, int*b) { int cacheIndex = threadIdx.x; int i = blockDim.x/2; while(i > 0){ if(cacheIndex < i){ a[blockIdx.x*COLUMNS+cacheIndex] +=...
22,832
#include "sha512.cuh" #define ROTRIGHT(a, b) (((a) >> (b)) | ((a) << (64 - (b)))) #define CH(x, y, z) (((x) & (y)) ^ (~(x) & (z))) #define MAJ(x, y, z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) #define EP0(x) (ROTRIGHT(x, 28) ^ ROTRIGHT(x, 34) ^ ROTRIGHT(x, 39)) #define EP1(x) (ROTRIGHT(x, 14) ^ ROTRIGHT(x, 18) ^ ROT...
22,833
#include "includes.h" __global__ void kernel_normalize_and_add_to_output(float * dev_vol_in, float * dev_vol_out, float * dev_accumulate_weights, float * dev_accumulate_values) { unsigned int i = __umul24(blockIdx.x, blockDim.x) + threadIdx.x; unsigned int j = __umul24(blockIdx.y, blockDim.y) + threadIdx.y; unsigned in...
22,834
#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_a...
22,835
__global__ void tile(float* out, int2 out_size, float* pattern, int2 pat_size, int2 offset){ const int x = blockIdx.x * blockDim.x + threadIdx.x; const int y = blockIdx.y * blockDim.y + threadIdx.y; if(out_size.x <= x || out_size.y <= y){ return; } const int i = x + out_size.x * y; const int j = ((x +...
22,836
/* * The Game of Life * * a cell is born, if it has exactly three neighbours * a cell dies of loneliness, if it has less than two neighbours * a cell dies of overcrowding, if it has more than three neighbours * a cell survives to the next generation, if it does not die of loneliness * or overcrowding * * In th...
22,837
#include <iostream> #include <cstring> #include <fstream> #include <algorithm> #include <cmath> #include <ctime> #include <cuda.h> #include <cuda_runtime.h> #include <thrust/device_vector.h> #include <thrust/extrema.h> #define EPS 1e-3 //#define WRITE_TO_FILE using namespace std; //Обработчик ошибок static void Handl...
22,838
/* 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,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,float va...
22,839
/* Copyright 2017 the arraydiff authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, so...
22,840
#include <iostream> #include <chrono> using test_t = uint64_t; constexpr std::size_t N = 5000; constexpr std::size_t block_size = 1 << 7; constexpr std::size_t num_threads = 240 * block_size; constexpr std::size_t test_count = 1 << 16; __constant__ test_t const_mem[N]; template <std::size_t test_count> __global__ vo...
22,841
/* * Copyright 1993-2007 NVIDIA Corporation. All rights reserved. * * NOTICE TO USER: * * This source code is subject to NVIDIA ownership rights under U.S. and * international Copyright laws. Users and possessors of this source code * are hereby granted a nonexclusive, royalty-free license to use this code * ...
22,842
#include"cuda_runtime.h" #include"device_launch_parameters.h" #include<stdlib.h> #include<stdio.h> #include<string.h> __global__ void multipleStrings(char* a , char* b,int size) { int i = threadIdx.x * size; int j = 0; for(j=0;j<size;j++) { b[i+j] = a[j]; } } int main() { cudaError_t error; int n; int siz...
22,843
#include <iostream> #include <stdio.h> #define N 100 #define ITERS 5 __global__ void stencil(float* a, float* b) { int x = blockIdx.x; int y = blockIdx.y; int offset = x + y * N; float update = 0.0; if (y > 0) { update += a[(y-1)*N+x]; } if (y < N-1) { update += a[(y+1)*N+x]; } if (x > 0) ...
22,844
#include <cuda.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #define MAXPOINTS 1000000 #define MAXSTEPS 1000000 #define MINPOINTS 20 int row = 480000; int col = 464; float *gmat, *gsum; __global__ void get_average(float *arr, float *sum, int row, int col){ //int i = blockIdx.x *...
22,845
// Code adapted from MATLAB implementation at https://people.ece.cornell.edu/land/courses/ece5760/LABS/s2016/lab3.html #include <stdio.h> #include <stdlib.h> #include <sys/time.h> #define N 512 // grid side length #define RHO 0.5 // related to pitch #define ETA 2e-4 // related to duration of sound #define BOUNDARY_GAIN...
22,846
#include <cuda.h> #include <iostream> __global__ void simpleKernel(int* data, int a) { //this adds a value to a variable stored in global memory data[blockIdx.x*8+threadIdx.x] += blockIdx.x+ a*threadIdx.x; } int main() { const int numElems= 8; int hA[numElems*2], *dA; //allocate memory on the device (GPU); zero...
22,847
// Cuda example add2 by Oleksiy Grechnyev // This one uses classical memory management #include <iostream> #include <cmath> #include <vector> // Kernel: This runs on the GPU (device) ! __global__ void add(int n, float *x, float *y){ int index = blockIdx.x * blockDim.x + threadIdx.x; int stride = blockDim.x * ...
22,848
#include "includes.h" __global__ void predicate(int *d_array, int d_numberOfElements,int *d_predicateArray) { int index = blockIdx.x * blockDim.x + threadIdx.x; if(index <d_numberOfElements) { if(d_array[index]%32== 0) { d_predicateArray[index] =1; } else { d_predicateArray[index] = 0; } } }
22,849
#include <thrust/host_vector.h> #include <thrust/device_vector.h> void define_xs_or_ys(float* xs, float dx, float x0, int gsize); void define_xs_or_ys(float* xs, float dx, float x0, int gsize){ for(int i = 0; i < gsize; i++) xs[i] = x0 + i*dx; } int main(){ int gsize = 10; float dx = 1; flo...
22,850
#include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include <cuda_profiler_api.h> #include <assert.h> #define min(x,y) (y + ((x - y) & ((x - y) >> (sizeof(long) * 8 - 1)))) const int Tile_Width = 1; const int WIDTH = 3; void print_matrix(long *m) { for (int i = 0; i < WIDTH; i++) for (int j = 0; j < WI...
22,851
#include "global_defines.cuh" #include <numeric> void LBM::relaxation(){ /*One-step density relaxation process c.......density relaxation: a single time relaxation with relaxation c parameter omega is applied here. This step is only "local", c nothing is propagated through the lattice...
22,852
#include <stdio.h> const int N = 33 * 1024; const int threadsPerBlock = 256; const int blocksPerGrid = ( (N+threadsPerBlock-1) / threadsPerBlock ); static void HandleError( cudaError_t err ) { if (err != cudaSuccess) { printf( "%s \n", cudaGetErrorString( err )); exit( 1 ); } } __global__ void dot( floa...
22,853
#include "includes.h" __global__ void cudaKernel_maxlocPlusZoominOffset(float *offset, const int * padStart, const int * maxlocUpSample, const size_t nImages, float zoomInRatioX, float zoomInRatioY) { int imageIndex = threadIdx.x + blockDim.x *blockIdx.x; //image index if (imageIndex < nImages) { int index=2*imageIndex...
22,854
#include <iostream> #include <string.h> #include <stdio.h> #include <math.h> using namespace std; void calc_on_cpu(float* vec_X, float* vec_Y, float* vec_Z, int nword) { for(int i=0; i<nword; i++){ vec_Z[i] = vec_X[i] + vec_Y[i]; } } __global__ void kernel(float* vec_X, float* vec_Y, float* vec_Z, int nword) { ...
22,855
// Find pixels within histogram range specified by user. // Add to gray color's count value atomically, and filter // out pixels not within histogram range. // by Bruno Costa Rendon #include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <time.h> #define TIMER_CREATE(t) \ cudaEvent_t t##...
22,856
#include "includes.h" __global__ void SomeKernel(int* res, int* data, int col, int row,int y, int step) { unsigned int threadId = blockIdx.x * blockDim.x + threadIdx.x; //Считаем идентификатор текущего потока int currDelta = 0; for (int i=step*threadId; (i<(threadId+1)*step) && (i < col); i++) //Работа со столбцами по ...
22,857
#include "includes.h" __global__ void outerProductSmartBruteForce(float* resultMatrix, float* vec, int vectorLength) { int col = (blockIdx.x * blockDim.x) + threadIdx.x; //column int row = (blockIdx.y * blockDim.y) + threadIdx.y; //row //check bounds if(row >= vectorLength || col >= vectorLength || row > col) return;...
22,858
#include <stdio.h> #include <time.h> #define ROUND 32768*32768 // 32k ^ 2 = 1073741824 __global__ void outputFromGPU() { for(int i = 0; i < ROUND; i++){} // GPU } int main(void) { printf(":: Ex1 ::\n"); clock_t begin, end; float timeGPU, timeCPU; begin = clock(); outputFromGPU<<<1,1>>>(); cudaDeviceSynchron...
22,859
#include "includes.h" __global__ void find_all_sums_hub_kernel(int* hub, int nhub, float *node_weight, int *neighbor, int *neighbor_start, float *neighbor_accum_weight_result, float *sum_weight_result){ int x = blockIdx.x * blockDim.x + threadIdx.x; if (x < nhub) { int nid = hub[x]; float sum = 0.0; for (int eid = neig...
22,860
#include <stdio.h> #include <algorithm> #include <iterator> #include <stdlib.h> #include <math.h> #include <string> #include <vector> #include <map> #include <mutex> using namespace std; #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } typedef struct { int id; double x; double y; } City; typedef st...
22,861
#include<stdio.h> #include<math.h> #define BLOCK_SIZE 1024 __global__ void multithreads_inverse_calculate( double* d_x_in, double* d_x_out, double entry_value, int d_n, int quantity, int entry_price, int leverage, int short_long ) { int tid = blockIdx.x*blockDim.x + threadIdx.x; //int tid = thr...
22,862
/* * Created by Harshavardhan Patil on 9/30/16. * * * Matrix Normalization using CUDA : * - The generated input values are stored by inverting the matrix. i.e All the attributes of a column which needs to be normalized * are stored as elements of a row. So that while normalizing the threads in a block will a...
22,863
#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...
22,864
#include <stdio.h> #include <math.h> __global__ void matmul(float * a, float * b, float * c, int * a_shape, int * b_shape) { if ((blockDim.y * blockIdx.y + threadIdx.y) < a_shape[0] && (blockDim.x * blockIdx.x + threadIdx.x) < b_shape[1]) { int aMin = (blockDim.y * blockIdx.y + threadIdx.y) * a_shape[1]; ...
22,865
#include <algorithm> #include <cstdio> #include <cstring> static void print_matrix(const char *name, const float *matrix, int h, int w) { int eff_h = std::min(h, 8); int eff_w = std::min(w, 8); std::printf("%s = [\n", name); for(int i = 0; i < eff_h; ++i) { for(int j = 0; j < eff_w; ++j) { ...
22,866
/* bfield.c Computes B fields in toroidal coordinates with given coefficients and calculates rms deviation from data Written by Hee Sok Chung at ANL July 10, 2016 */ #include <stdio.h> #include <stdlib.h> #include <math.h> //#include <TTree.h> //#include <TFile.h> #include <iostream> #include <cuda_runtime.h> ...
22,867
/* Test: result = thread ID. * * CUDA equivalent of test_hello_ptx.ml kernel. */ __global__ void test(const float* input, float* result, int N) { int i = blockDim.x * blockIdx.x + threadIdx.x; // if (i < N) result[i] = float(i); }
22,868
#include <iostream> #include <cstdio> #include <ctime> #include <math.h> //CUDA kernel function to add the elements of two arrays __global__ void matvec(float *a, float *x, float *y, int n) { //Set index per block and sum variable int row = blockIdx.x * blockDim.x + threadIdx.x; float sum = 0.0f; //Perform the ma...
22,869
#include <stdio.h> #include <iostream> #include <cuda_profiler_api.h> //#include <cutil.h> #include <cuda_runtime.h> float* h_A; float* h_B; float* h_C; float* h_res; float* d_A; float* d_B; float* d_C; float* d_res; __global__ //void compute(const float* A, const float* B, const float* C, float* D, int n) { void com...
22,870
#include <stdio.h> //#include <stdlib.h> #include <unistd.h> #define BLOCK_SIZE 1024 #define GRID_SIZE 38400 extern "C" { __global__ void mul_matrix(int *A, int *B, int *C, int size){ int i = threadIdx.x + blockDim.x * blockIdx.x; int sum = 0; if(i < size){ __syncthreads(); sum = A[i] + B[i]; C[i] = ...
22,871
#include<stdio.h> #include<stdlib.h> #include<cuda.h> #include <time.h> #define Mask_size 3 //filter size #define Width 1024 // image width #define Height 1024 // image height #define N (Width*Height) //---------------kernel------------------- __global__ void ConvExp (int *I_input, int *Mask1,int *Mask2,int *...
22,872
#include <stdio.h> #include <cuda.h> /**/ #define SAMPLE_INTERVAL 4 /* pick a sample every 4 elements */ /**/ /* Inline device function, to compute a rank of a "key" in an array "arr" of length "len" (including this key) */ static inline __device__ int get_rank_inclusive(int key, int* arr, int len); /* Inli...
22,873
#include "includes.h" __global__ void add(int *a, int *b, int *c) { int i = blockIdx.x; if(i < N) c[i] = a[i] + b[i]; }
22,874
#include <stdio.h> #define N 8 #define THREADS_PER_BLOCK 4 #define BLOCKS (N / THREADS_PER_BLOCK) __global__ void dot_product(int *a, int *b, int *res) { __shared__ int temp[THREADS_PER_BLOCK]; int idx = threadIdx.x + blockIdx.x * blockDim.x; temp[threadIdx.x] = a[idx] * b[idx]; __syncthreads(); if(0 == t...
22,875
#include<cufft.h> #include<stdio.h> int main(){ printf("test for linking cufft library\n"); return 0; }
22,876
#include "cuda.h" __global__ void kernel_saxpy( int n, float a, float * x, float * y, float * z ) { int i = blockIdx.x * blockDim.x + threadIdx.x; if ( i < n ) { z[i] = a * x[i] + y [i]; } } void saxpy( int nblocks, int nthreads, int n, float a, float * x, float * y, float * z ) { kernel_saxpy<<<nblocks, nthre...
22,877
#include "includes.h" __global__ void cudaSclamp_kernel(float* x, unsigned int size, float minVal, float maxVal) { const unsigned int index = blockIdx.x * blockDim.x + threadIdx.x; const unsigned int stride = blockDim.x * gridDim.x; for (unsigned int i = index; i < size; i += stride) { x[i] = (x[i] < minVal) ? minVal ...
22,878
#include "includes.h" __global__ void kernel_Phi4_Phi6(const int N, double *t, double *q, const double lambda, const double g) { int i = blockIdx.x * blockDim.x + threadIdx.x; if (i < N) { t[i] = q[i] * q[i] * q[i] * (lambda + g * q[i] * q[i]); } }
22,879
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <iostream> #define NUM_BLOCKS 800 #define NUM_THREADS 1024 __global__ void localReductionKernel(int* cudaDeltaArray) { __shared__ int sharedDeltaArray[NUM_THREADS]; unsigned int id = threadIdx.x; sharedDeltaArray[id] =...
22,880
#include <stdio.h> #include <iostream> #include <ctime> #include <unistd.h> #include <cmath> #include <sys/time.h> #define N 1000000 #define BLOCK_SIZE 64 //#define TIME_CHECK clock()/float(CLOCKS_PER_SEC) typedef unsigned long long timestamp; //get time in microseconds timestamp get_timestamp() { struct timeva...
22,881
#include "includes.h" /* * 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 soft...
22,882
#include <stdio.h> #include <cuda.h> #include <string.h> #include <stdlib.h> #include <math.h> //use high as x value low as y for clustering typedef struct day{ int month; int date; int year; double high; double low; int cluster; }day; typedef struct center{ double x; double y; }center; __global__ void setC...
22,883
//this is a lite version of a GPU accelerated N-body simulation. Has to be run on an NVIDIA machine with CUDA enabled. //the interaction is just gravitation //the simulation trajectory is to be visualized in VMD #include <cstdio> #include <cstdlib> #include <cmath> #define N 9999 // number of bodies #define MASS 0 /...
22,884
#include <stdio.h> #include <stdlib.h> #include <time.h> #include "cuda_runtime.h" #include "device_launch_parameters.h" __global__ void mem_trs_test(int * input){ int gid = blockIdx.x * blockDim.x + threadIdx.x; printf("tid = %d, gid = %d, value = %d\n", threadIdx.x, gid, input[gid]); } __global__ void mem_trs_...
22,885
/** * Copyright 1993-2012 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 relate...
22,886
#include "includes.h" __device__ float activation_function(float x) { return 1 / (1 + exp(-x)); } __global__ void apply_activation_function(float *input, float *output, const int N) { const int pos = blockIdx.x * blockDim.x + threadIdx.x; const int size = blockDim.x * gridDim.x; for (int idx = N * pos / size; idx < N ...
22,887
extern "C" __global__ void solve_general(double *rateConst, double *state, double *deriv, int *numReact, int *numProd, int *reactId, int *prodId, int numcell, int numrxn, int numspec, int maxreact, int maxprod) ...
22,888
#include "includes.h" __global__ void resampleFeaturesKernel(double* u, double* v, double* d, double* vu, double* vv, double* vd, double* weights, double* randvals, int n_features, double* u_sampled, double* v_sampled, double* d_sampled, double* vu_sampled, double* vv_sampled, double* vd_sampled) { // each block corres...
22,889
#include <stdio.h> #include <cuda.h> #include <assert.h> #define CUDA_WRAP(fct_call) \ while(0) { \ cudaError_t rv = (fct_call); \ assert(rv == cudaSuccess); \ } #define N 10 #define NUM_BLOCKS 2 __global__ void add(int *a, int *b, int *c) { for (int i = blockIdx.x; i < N; i += gridDim.x) { ...
22,890
#include <stdio.h> #include <cuda.h> #define N 500 #define BLOCKSIZE 64 #define ELEPERTHREAD 5 __device__ unsigned wlsize; __device__ unsigned worklist[N * ELEPERTHREAD]; __global__ void k1(unsigned *nelements) { unsigned id = blockIdx.x * blockDim.x + threadIdx.x; unsigned index = atomicAdd(&wlsize, nelements[id...
22,891
#include <stdio.h> #include <math.h> #define N 1024 //Interleave addressing kernel_version __global__ void interleaved_reduce(int *d_in, int *d_out) { //using shared memory __shared__ int sm[N]; int i = threadIdx.x; int id = blockIdx.x * blockDim.x + threadIdx.x; sm[i] = d_in[id]; __syncthreads(); /*int M ...
22,892
#include "includes.h" __global__ void kernMoveMem(const size_t numPoints, const size_t pointDim, const size_t s, double* A) { int b = blockIdx.y * gridDim.x + blockIdx.x; int i = b * blockDim.x + threadIdx.x; // Before // [abc......] [def......] [ghi......] [jkl......] // shared memory // [adgj.....] // After // [a....
22,893
#include "includes.h" __global__ void cpy(float *a, float *b, int n) { unsigned int i = blockIdx.x * blockDim.x + threadIdx.x; if (i < n) a[i] = b[i]; }
22,894
#include "includes.h" __global__ void set_bookmarks(int2* vis_in, int npts, int blocksize, int blockgrid, int* bookmarks) { for (int q=threadIdx.x+blockIdx.x*blockDim.x;q<=npts;q+=gridDim.x*blockDim.x) { int2 this_vis = vis_in[q]; int2 last_vis = vis_in[q-1]; int main_x = this_vis.x/GCF_GRID/blocksize; int main_x_last ...
22,895
#include "includes.h" __global__ void gpu_array_init_r4__(size_t tsize, float *arr, float val) /** arr(:)=val **/ { size_t _ti = blockIdx.x*blockDim.x + threadIdx.x; size_t _gd = gridDim.x*blockDim.x; for(size_t l=_ti;l<tsize;l+=_gd){arr[l]=val;} return; }
22,896
#include <stdio.h> #include <stdint.h> #include <pthread.h> #include <unistd.h> #include <assert.h> #define MAX_STREAMS 3 uint32_t *bufferA[MAX_STREAMS], *bufferB[MAX_STREAMS]; int flags[MAX_STREAMS] = {1,1,1}; int max_iteration = 10; pthread_mutex_t lock; inline cudaError_t checkCuda(cudaError_t result) { if (resu...
22,897
#include "gpu_lib.cuh" __global__ void add(unsigned char* a,unsigned char* b,unsigned char* c,int n) { int i=blockDim.x * blockIdx.x + threadIdx.x; if(i<n) c[i] = a[i]*0.7f + b[i]*0.3f; } extern "C" void func(unsigned char* a,unsigned char *b,unsigned char *c) { unsigned char* dev_c=NULL; unsigned char* dev...
22,898
#include "includes.h" /* Sample input file format: 1.Line : 6 => Number of nodes(int) 2.Line : 7 => Number of edges(int) 3.Line : 1 2 5.0 ---------------- 4.Line : 2 3 1.5 | 5.Line : 1 3 2.1 | 6.Line : 1 4 1.2 |=> Edges 7.Line : 1 5 15.5 | 8.Line : 2 5 3.6 | 9.Line : 3 6 1.2-----------------...
22,899
// TODO: Make more generic __global__ void subset_assignment_kernel(float *d_a, float *d_b, int a_x, int size) { // Get the id and make sure it is within bounds const int b_id = threadIdx.x + blockIdx.x * blockDim.x; if (b_id >= size) { return; } const int a_id = a_x * size + b_id; d_a[...
22,900
#include "includes.h" __global__ void reduction_kernel(float* d_out, float* d_in, unsigned int size) { unsigned int idx_x = blockIdx.x * blockDim.x + threadIdx.x; extern __shared__ float s_data[]; s_data[threadIdx.x] = (idx_x < size) ? d_in[idx_x] : 0.f; __syncthreads(); // do reduction for (unsigned int stride = 1...