serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
5,701
#include <cstdio> int main(void) { int count; cudaGetDeviceCount(&count); printf("%d devices found supporting CUDA\n", count); char split[] = "----------------------------------\n"; cudaDeviceProp p; for(int d = 0; d < count; d++){ cudaGetDeviceProperties(&p, d); printf("%s", split); printf(...
5,702
#include <stdio.h> #include <stdlib.h> #include <time.h> __global__ void blur_kernel(float *image,float *filter,float *blurred,int r,int c,float filter_sum) { int row=blockIdx.x*blockDim.x + threadIdx.x; int col=blockIdx.y*blockDim.y + threadIdx.y; int above=row-1; int below=row+1; ...
5,703
#include <stdio.h> #include <sys/time.h> #include <cuda_runtime.h> #include <math.h> extern "C" void initialData(float *ip, int size) { for (int i=0; i < size; i++) { ip[i] = (float)rand()/(float)(RAND_MAX/10.0); } } extern "C" void printHello(void) { printf("HELLO from C\n"); } extern "C" void print_matri...
5,704
#include <stdio.h> #include <math.h> __global__ void checkPositions(double2* rnew,int N, double L){ int tid = threadIdx.x + blockIdx.x*blockDim.x; if (tid < N){ if (fabs(rnew[tid].x) > L/2.0) printf("Thread %d: r.x = %lf\n",tid,rnew[tid].x); if (fabs(rnew[tid].y) > L/2.0) printf("Thread %d: r.y = %lf\n",tid,rnew[...
5,705
#include "includes.h" __global__ void global_reduction_kernel(float *data_out, float *data_in, int stride, int size) { int idx_x = blockIdx.x * blockDim.x + threadIdx.x; if (idx_x + stride < size) { data_out[idx_x] += data_in[idx_x + stride]; } }
5,706
#include "portfolio.cuh" #include <math.h> #include <numeric> #include <algorithm> #include <stdexcept> #include <iostream> #include <iomanip> #include <stdio.h> namespace fin { CUDA_CALLABLE_MEMBER Portfolio::Portfolio() { int size = 20; this->size = size; this->assets = new Asset* [size]; this->weights ...
5,707
/* * Parakeet * * (c) 2009-2012 Eric Hielscher, Alex Rubinsteyn * * GPU Probe * * Utility for detecting main GPU characteristics of the given * computer for use in Parakeet's code optimization. * * Outputs an XML file with the gathered information for use by the Parakeet * runtime. */ #include <cuda_runti...
5,708
#include "includes.h" // ERROR CHECKING MACROS ////////////////////////////////////////////////////// __global__ void roadCrossingsKernel(int rows, int segs, int* adjacency, int* cross) { int idx = blockIdx.x*blockDim.x + threadIdx.x; if (idx < rows) { cross[idx] = 0; for (int ii = 0; ii < segs; ii++) { cross[idx]...
5,709
/* * * Accessing out of bound memory from GPU * Vector addition * */ #include <stdio.h> #include <stdlib.h> #include "cuda_runtime.h" #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true) { if (code != cudaSuccess)...
5,710
#include "includes.h" __global__ void add(int a, int b, int *c) { //Add 2 numbers together and store in location pointed by *c *c = a + b; }
5,711
#include "includes.h" extern "C" // don't forget to compile with "nvcc -ptx cudaKernel.cu -o cudaKernel.ptx // And to move the ptx file in the resources ! __global__ void add(int n, float* a, float* b, float* sum) { int index = blockIdx.x * blockDim.x + threadIdx.x; int stride = blockDim.x * gridDim.x; for (int i = in...
5,712
#include <stdio.h> #include <iostream> #define CUDA_SAFE_CALL(call) \ do { \ cudaError_t err = call; \ if (cudaSuccess != err) { \ fprintf (stderr, "Cuda error in file '%s' in line %i : %s.", \ __FILE__, __LINE__, cudaGetErrorString(err) ); \ exit(EXIT_FAILURE); }} while (0) ty...
5,713
// Josh Morris // Lab 6 // Dr Pettey // 4330 Parallel Processing /* A cuda program to add two 16X32 matrices supplied by the user The host will print the result generated by the kernel */ #include <stdio.h> #include <stdlib.h> const int NUM_ROW = 16; const int NUM_COL = 32; __global__ void addMatrices(int arraySize...
5,714
#include <stdlib.h> #include <stdio.h> #include <string> #include <time.h> #include <fstream> #include <iostream> using namespace std; __global__ void KMP(char* pattern, char* text, int prefixTable[], int result[], int pattern_length, int text_length) { int index = blockIdx.x * blockDim.x + threadIdx.x; int i...
5,715
#include "includes.h" __global__ void bfsCheck( bool *d_graph_mask, bool *d_updating_graph_mask, bool *d_graph_visited, int no_of_nodes, bool *stop ) { *stop = false; int tid = blockIdx.x * blockDim.x + threadIdx.x; if (tid < no_of_nodes){ if (d_updating_graph_mask[tid] == true){ d_graph_mask[tid] = true; d_graph_visi...
5,716
#include <stdio.h> #include <cuda_runtime.h> int main() { cudaDeviceProp* cdp = (cudaDeviceProp*) malloc(sizeof(cudaDeviceProp)); int deviceCount = 0, i; cudaGetDeviceCount(&deviceCount); printf("Number of devices : %d\n", deviceCount); for ( i = 0 ; i < deviceCount ; i++ ) { cudaGetDeviceProperties(cdp, i); ...
5,717
#include "includes.h" __global__ void binarize_weights_mean_kernel(float *weights, int n, int size, float *binary, float *mean_arr_gpu) { int i = blockIdx.x * blockDim.x + threadIdx.x; int f = i / size; if (f >= n) return; float mean = mean_arr_gpu[f]; binary[i] = (weights[i] > 0) ? mean : -mean; }
5,718
#include "includes.h" __global__ void convolution1d_notile_noconstant_kernel(int *In, int *Out){ unsigned int index = blockIdx.x * blockDim.x + threadIdx.x; // Index 1d iterator. int Value = 0; int N_start_point = index - (Mask_size/2); for ( int j = 0; j < Mask_size; j ++) { if (N_start_point + j >= 0 && N_start_poin...
5,719
#include "includes.h" __global__ void InterpolateFromMemBlock(float* input1, float* input2, float* output, float* weightMemBlock, int inputSize) { int threadId = blockDim.x*blockIdx.y*gridDim.x //rows preceeding current row in grid + blockDim.x*blockIdx.x //blocks preceeding current block + threadIdx.x; if(threadId...
5,720
#include <stdio.h> __global__ void make_hello(char *str, int *transform_mtx) { str[threadIdx.x] += transform_mtx[threadIdx.x]; } int main(int argc, char **argv) { printf("Hello from main!\n"); for (int ii = 0; ii < argc; ii++) { printf("argv[%d] = %s\n", ii, argv[ii]); } char str[16] =...
5,721
#include <iostream> #include <stdio.h> #include <time.h> using namespace std; #define BLOCK_SIZE 16 __global__ void tranposition(float *A, float *B, int N) { // Matrix multiplication for NxN matrices C=A*B // Each thread computes a single element of C int row = blockIdx.y*blockDim.y + threadIdx.y; int col = bloc...
5,722
#include <stdio.h> const int N = 7; const int blocksize = 7; /* Adds the an integer from the [b] array to a character in the same position * in the [a] array and stores the result back in [a]. Uses a multithreaded * pattern to add the two (each thread modifies a different index in parallel). * * Requires: |a| = ...
5,723
#include <iostream> using namespace std; static void HandleError(cudaError_t err, const char *file, int line) { if (err != cudaSuccess) { cout << cudaGetErrorString(err) << " in file '" << file << "' at line " << line << endl; exit(EXIT_FAILURE); } } #define HANDLE_ERROR(err) (HandleError(err, __FILE__, _...
5,724
#include <cuda.h> #include <stdio.h> #include <dlfcn.h> #include <stdlib.h> CUresult cuDeviceTotalMem(size_t* bytes, CUdevice dev) { void *handle; handle = dlopen("/usr/lib/x86_64-linux-gnu/libcuda.so.1", RTLD_LAZY); printf("%s\n", "cuDeviceTotalMem is hijacked based on env MYMEM!"); const char* mym...
5,725
/* * Device code */ __global__ void ParallelGaussElim( int const nDim_image, int const nDim_matrix, double* d_A, double* d_b, double* d_x) { // Assign image pixels to blocks and threads int i_image = blockDim.x*blockIdx.x + threadIdx.x; if (i_image > nDim_image*nDim_image) return; //int i_image = blockDim....
5,726
#include "float3math.cuh"
5,727
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <cuda.h> #include <iostream> using namespace std; void initArray(float* vec, int n) { int i; for(i=0; i<n; i++) vec[i] = rand() % 9 + 1; } void initMat(float* mat, int n) { int i, j; for(i=0; i<n; i++) for(j=0; j<n; j+...
5,728
#include <iostream> using namespace std; #include <thrust/reduce.h> #include <thrust/sequence.h> #include <thrust/host_vector.h> #include <thrust/device_vector.h> void task1(void) { const int N = 50000; int sum = 0, sumA = 0, i = 0; thrust::device_vector<int>a(N); thrust::sequence(a.begin(), a.end(),...
5,729
/* * GPU based implementation of the elastic mesh deriviatives computations. */ //#define FLOAT_INFINITY __int_as_float(0x7f800000) #define FLOAT_INFINITY __int_as_float(-1) #define SMALL_VALUE 0.0001 /* Huber Loss Functions */ inline __device__ float huber( const float value, const float ...
5,730
#include "includes.h" /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * ...
5,731
#include "includes.h" __device__ int locate(int val, int *data, int n) { int i_left = 0; int i_right = n-1; int i = (i_left+i_right)/2; while(i_right-i_left>1) { if (data[i] > val) i_right = i; else if (data[i]<val) i_left = i; else break; i=(i_left+i_right)/2; } return i; } __global__ void prescan_arbitrary_unoptimiz...
5,732
#include "includes.h" // GPU Libraries // Macro to handle errors occured in CUDA api __device__ void recursiveReduce(int *g_inData, int *g_outData, int inSize, int outSize) { extern __shared__ int sData[]; // Identification unsigned int tId = threadIdx.x; unsigned int i = blockIdx.x * blockDim.x + threadIdx.x; // I...
5,733
#include <stdio.h> #include <sys/time.h> #include <cuda.h> long long getCurrentTime() { struct timeval te; gettimeofday(&te, NULL); // get current time long long microseconds = te.tv_sec*1000000LL + te.tv_usec; return microseconds; } #define CUDA_ERROR_CHECK #define CudaSafeCall( err ) __cudaSafeCall(...
5,734
#include "includes.h" __global__ void laplacianFilter(unsigned char *srcImage, unsigned char *dstImage, unsigned int width, unsigned int height) { int x = blockIdx.x*blockDim.x + threadIdx.x; int y = blockIdx.y*blockDim.y + threadIdx.y; float ker[3][3] = {{0, -1, 0}, {-1, 4, -1}, {0, -1, 0}}; //float kernel[3][3] = {-...
5,735
#include <stdio.h> #include <cuda_runtime.h> void initialize(int *H, int N) { for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) H[N*i+j] = 0; for (int i = 0; i < N; i++) { H[N*i] = H[N*i+N-1] = H[N*(N-1)+i] = 20; H[i] = i >= ((N*30)/100) && i < ((N*70)/100) ? 100 : 20...
5,736
//****************************************************************************** // // File: ModCubeRoot.cu // // This CUDA C file is the kernel function for the GPU to try and break the cipher // key // //****************************************************************************** // Number of threads per block....
5,737
//transform length #define TLEN 128 #define TILE_DIM 16 #define HEIGHT 8 //1, 2, 4, 8 #define NEG_2PI_BY_TLEN -0.04908738521f //-2*PI/128 #define STRIDE_STAGE_1 0x00000040 //64 #define STRIDE_STAGE_2 0x00000020 //32 #define STRIDE_STAGE_3 0x00000010 //16 #define STRIDE_STAGE_4 0x00000008 //08 #define STRIDE_STAGE_5 0x0...
5,738
#include <cuda.h> #include <stdio.h> __global__ void matAddKernel(float* A, float* B, float* C, int width, int height){ int col = blockDim.x*blockIdx.x + threadIdx.x; int row = blockDim.y*blockIdx.y + threadIdx.y; int i = col + row*width; if(i < width*height){ C[i] = A[i] + B[i]; } } void matAdd(float* A, fl...
5,739
#include <math.h> #include <stdio.h> // Array access macros #define INPUT(i,j) imgBef[(i)*n + j] #define OUTPUT(i,j) imgAfter[(i)*n + j] #define fNi(i,j) fNi[(i)*patchSize + j] #define fNj(i,j) fNj[(i)*patchSize + j] #define fN(i,j) fN[(i)*patchSize + j] #define H(i,j) H[(i)*patchSize + j] #define PATCH(i,j) patch[(i)...
5,740
#include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <cuda_runtime.h> #include <cuda_runtime_api.h> #include <curand.h> #define CUDA_CALL(x) do { if((x)!=cudaSuccess) {\ printf("Error at %s:%d\n", __FILE__,__LINE__);\ return EXIT_FAILURE;}} while(0) #define CURAND_CALL(x) do { if((x)!=CURAND_STATUS_SUC...
5,741
// NAME: Jose Torres #include <stdio.h> #include <iostream> #include <assert.h> __global__ void matrixMulCUDA(float *A, float *B, float *C, int size){ // Code from HW slide __shared__ float smem_c[64][64]; __shared__ float smem_a[64][8]; __shared__ float smem_b[8][64]; int c = blockIdx.x * 64; ...
5,742
//#include "stdafx.h" //#include "voxel.cuh" //#include "cuda_definitions.h" //// From http://www.jcgt.org/published/0006/02/01/ //__device__ bool intersect_aabb_branchless2(const glm::vec3& origin, const glm::vec3& direction, float& tmin) { // constexpr glm::vec3 box_min = { 0, 0, 0 }; // constexpr glm::vec3 box_max =...
5,743
#include "includes.h" __device__ float_t d_randu(int * seed, int index) { int M = INT_MAX; int A = 1103515245; int C = 12345; int num = A * seed[index] + C; seed[index] = num % M; return fabsf(seed[index] / ((float_t) M)); } __device__ void cdfCalc(float_t * CDF, float_t * weights, int Nparticles) { int x; CDF[0] = w...
5,744
#include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <thrust/copy.h> #include <thrust/sort.h> #include <thrust/functional.h> #include <iostream> #include <iterator> int main() { thrust::host_vector<int> host_input{5, 1, 9, 3, 7}; thrust::device_vector<int> device_vec(5); thrust::copy(host_...
5,745
#include "includes.h" __global__ void childKernel(unsigned int parentThreadIndex, float* data) { data[threadIdx.x] = parentThreadIndex + 0.1f * threadIdx.x; }
5,746
extern "C" //must be same as threads!!! //Block_Size = blockDim.x #define Block_Size 64 #define m 0.001/2000 #define PI 3.14159265359f __global__ void ker_rho(float *out, const float *x, const int *ind, const float h) { //int IND = gridDim.z * gridDim.y * blockIdx.x + gridDim.z * blockIdx.y + blockIdx.z in...
5,747
#include "includes.h" #define SEED #define BLOCK_SIZE 32 typedef struct _data { char * values; char * next_values; int width; int height; } data; __global__ void operate(char * source, char * goal, int sizex, int sizey) { __shared__ char local[BLOCK_SIZE + MASK_WIDTH - 1][BLOCK_SIZE + MASK_WIDTH - 1]; int i = blockI...
5,748
#include <stdio.h> #include <stdlib.h> __global__ void add(int a, int b, int *c) { *c = a + b; } int main(int argc, char *argv[]) { int c; int *dev_c; cudaError_t error = cudaMalloc((void **)&dev_c, sizeof(int)); if(error != cudaSuccess) { printf("Memory could not be allocated on device\n"); exit(EX...
5,749
#include "includes.h" #define BLOCKSIZE 4 #define CELLS_PER_THREAD 4 // Stride length __global__ void ShortestPath1(float *Arr1,float *Arr2,int N){ //Arr1 input array,Holds of (u,v) //Arr2 output array int k; int col=blockIdx.x * blockDim.x + threadIdx.x; int row=blockIdx.y * blockDim.y + threadIdx.y; int index=ro...
5,750
#include <stdio.h> __global__ void print_kernel() { // this time print the thread index // for simplicity print only for thread index equals 1 if (threadIdx.x == 1 ){ printf("Hello from block %d, thread %d\n", blockIdx.x, threadIdx.x); } // note use of threadIdx.x and blockIdx.x to get // thread a...
5,751
// cudaDCA.cu // //This file contains the recursive DCA function, and the function that is used to invoke DCA and //interperate the results. //Included Files #include <iostream> //Function Prototypes // Functions found in this file void RecDCA(double Zs[], int n, int i, double AF[], int cut_off,double Xs[]); // Fun...
5,752
#include <stdio.h> #include <time.h> #include <math.h> #include <cuda.h> #include <cuda_runtime.h> #include <cuda_profiler_api.h> #include <cuda_fp16.h> #define EPS 0.0000001f #define SIZE 1024 #define BIG_VALUE 65536 #define BLOCK_SIZE 256 // generate random matrix void getMatrix(float* matrix, unsigned size) { if...
5,753
#include <thrust/device_vector.h> #include <thrust/transform.h> #include <thrust/sequence.h> #include <thrust/copy.h> #include <thrust/fill.h> #include <thrust/replace.h> #include <thrust/functional.h> #include <iostream> #include <vector> template <typename T> std::vector<std::vector<T> > matrix_wise_plus(std::ve...
5,754
#include "includes.h" __global__ void kernel( int *a, int dimx, int dimy ) { int ix = blockIdx.x*blockDim.x + threadIdx.x; int iy = blockIdx.y*blockDim.y + threadIdx.y; int idx = iy*dimx + ix; a[idx] = a[idx]+1; }
5,755
#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 :...
5,756
#include "includes.h" __global__ void totalWithThreadSyncAndSharedMemInterleaved(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(i < len) sdata[tid] = input[i]; els...
5,757
#include <chrono> #include <stdio.h> #include <stdlib.h> #include "cuda_runtime.h" #include "device_launch_parameters.h" using namespace std; using namespace chrono; #define GRIDSIZE 1 #define BLOCKSIZE 1024 #define TOTALSIZE (GRIDSIZE*BLOCKSIZE) void genData(unsigned* ptr, unsigned int size) { while (size--) { *p...
5,758
#include "includes.h" __global__ void vecAdd(int *xd, float *Ag, float *Bg, float *Cg) { // this is a kernel, which state the computations the gpu shall do //int j = threadIdx.x; int j = blockIdx.x*blockDim.x + threadIdx.x; *(Cg+j) = *(Ag+j) + *(Bg+j) + (*xd); }
5,759
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include<iostream> #include "config.cuh" #include<map> #include <sstream> #include <vector> #include <algorithm> #include <cassert> #define maxWordSize 1024 using namespace std; vector < string > v1; /* * Mapping function to be run for each...
5,760
#include "includes.h" __global__ void kArgMaxColumnwise(float* mat, float* target, unsigned int width, unsigned int height) { __shared__ float max_vals[32]; __shared__ unsigned int max_args[32]; float cur_max = -2e38; unsigned int cur_arg = 0; float val = 0; for (unsigned int i = threadIdx.x; i < height; i += 32) { va...
5,761
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <device_functions.h> #include "kernels.cuh" #define SHARED_MEMORY_BANKS 32 #define LOG_MEM_BANKS 5 #define CONFLICT_FREE_OFFSET(n) ((n) >> LOG_MEM_BANKS) __global__ void prescan_arbitrary(int *output, int *input, int n, int powerOfTwo) { exter...
5,762
#include "includes.h" /** * C file for parallel QR factorization program usign CUDA * See header for more infos. * * 2016 Marco Tieghi - marco01.tieghi@student.unife.it * */ #define THREADS_PER_BLOCK 512 //I'll use 512 threads for each block (as required in the assignment) __global__ void xTA (double *y, int k, d...
5,763
#include <iostream> #include <algorithm> using namespace std; class Net { private: int rows, cols; int** inputTensor; int** outputTensor; public: Net(int, int); int relulayer(); void poolingFunction(int, int, bool); void filterConvolve(int); void printArray(); }; Net::Net(int r, int c) { rows = r; cols = ...
5,764
#include "includes.h" __global__ void cuSearchDoublet( const int* nSpM, const float* spMmat, const int* nSpB, const float* spBmat, const int* nSpT, const float* spTmat, const float* deltaRMin, const float* deltaRMax, const float* cotThetaMax, const float* collisionRegionMin, const float* collisionRegionMax, int* nSpMco...
5,765
#include "cuda_runtime.h" #include "cuda.h" #include "device_launch_parameters.h" #include "iostream" #include "stdlib.h" #include <thread> // std::this_thread::sleep_for #include <chrono> // std::chrono::seconds #include "time.h" #include <ctime> #include "fstream" using namespace std; int getPos(...
5,766
/****************************************************************************\ * --- Practical Course: GPU Programming in Computer Vision --- * * time: winter term 2012/13 / March 11-18, 2013 * * project: diffusion * file: diffusion.cu * * \******* PLEASE ENTER YOUR CORRECT STUDENT LOGIN, NAME AND ID BELOW ...
5,767
#include <cuda_runtime.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <fstream> #define BILLION 1E9; const int n=300; __global__ void grayscaleKernel(int *ms, int *aux, int n){ int i = threadIdx.x+blockDim.x*blockIdx.x; int k=0; int grayscale=0; if(i<n){ for(k=0; k<n-3; k+=3){ grays...
5,768
#include "includes.h" /* Addition of two numbers using a kernel method. * Note: Documentation will explain each thing only once. */ /* Header files */ /* This a kernel function, it has the __global__ qualifier in the definition. * addition: Perform the addition of two numbers and return their sum. * +------------+--...
5,769
#include <iostream> #include <sstream> #include <stdexcept> using namespace std; // assuming same padding __global__ void Variation2DKernel(float* var, const float* img, int nx, int ny, int nc, float eps) { int ix = blockIdx.x * blockDim.x + threadIdx.x; int iy = blockIdx.y * blockDim.y + threadIdx.y; if (ix >= n...
5,770
#include <stdio.h> #include <stdlib.h> #include <math.h> #define BLOCK_SIZE 512 #define _check(stmt) \ do { \ cudaError_t err = stmt; \ if (er...
5,771
#include<iostream> #include<cuda_runtime.h> int main(void) { cudaDeviceProp prop; int count; cudaGetDeviceCount(&count); for (int i = 0; i < count; i++) { cudaGetDeviceProperties(&prop, i); } return 0; }
5,772
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <time.h> #define BLOCK_SIZE 16 // CPU Implementation void cpu_matrix_mult(int *h_a, int *h_b, int *h_result, int m, int n, int k) { for (int i = 0; i < m; ++i) { for (int j = 0; j < k; ++j) { int tmp = 0.0; for (int h = 0; ...
5,773
/* Copyright 2016-2017 the devicemem_cuda 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 w...
5,774
#include <stdlib.h> #include <stdio.h> #include <unistd.h> #define TILE_SIZE 14 #define KERNEL_SIZE 5 #define BLOCK_SIZE (TILE_SIZE + (KERNEL_SIZE - 1)) // global variable, outsize any function __constant__ float Mc[KERNEL_SIZE][KERNEL_SIZE]; __global__ void Convolution2D(float* d_M, float* d_N, float* d_P,int M_Wi...
5,775
/* * Université Pierre et Marie Curie * Calcul de transport de neutrons * Version séquentielle */ #include <stdlib.h> #include <stdio.h> #include <math.h> #include <time.h> #include <sys/time.h> #include <cuda.h> #include <curand.h> #include <curand_kernel.h> #define OUTPUT_FILE "/tmp/absorbed.dat" #define NB_B...
5,776
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> cudaError_t MovAvgWithCuda(float *result, const float *input, size_t size, int avgWindowSize); __global__ void MovAvgKernel(float *result, const float *input, int threadCount, int elementsCount, const int avgWindowSize) { int idx...
5,777
#include <stdio.h> __global__ void device_hello(){ //uncomment this line to print only one time (unless you have multiple blocks) if(threadIdx.x==0) printf("Hello world! from the device! thread:%d,%d\n",blockIdx.x,threadIdx.x); return; } int main(void){ // rather than calling fflush setbuf(stdout, ...
5,778
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> #include <cuda_runtime.h> // Setup for measuing time #include <sys/time.h> #include <time.h> int timeval_subtract(struct timeval* result, struct timeval* t2, struct timeval* t1) { unsigned int resol...
5,779
/* =============================================================================== Name : simulatorutils.cu Author : Mridul & Srinidhi Version : Copyright : Copyleft Description : Parallel implementation of Rigid Body Dynamics on GPU using CUDA ==================================================...
5,780
#include <cuda_runtime_api.h> #include <stdint.h> #define OFFSET_BANK(idx) ({ __typeof__ (idx) _idx = idx; ((_idx) + ((_idx) / 32)); }) __global__ void softmax_lr_loss_fwd_kernel( const float *ys, uint32_t dim, uint32_t batch_sz, const uint32_t *labels, const float *targets, const float *weigh...
5,781
#include "slicer.cuh" #include "triangle.cuh" #include <thrust/functional.h> __device__ __forceinline__ void triangleCopy(void* src, void* dest, int id); __device__ __forceinline__ double min3(double a, double b, double c); __device__ __forceinline__ double max3(double a, double b, double c); __device__ __forceinline_...
5,782
/** * gramschmidt.cu: This file is part of the PolyBench/GPU 1.0 test suite. * * * Contact: Scott Grauer-Gray <sgrauerg@gmail.com> * Louis-Noel Pouchet <pouchet@cse.ohio-state.edu> * Web address: http://www.cse.ohio-state.edu/~pouchet/software/polybench/GPU */ #include <unistd.h> #include <stdio.h> #include <ti...
5,783
#include<stdio.h> #include<cstdint> #include<thrust/device_ptr.h> #include<thrust/scan.h> typedef uint32_t u32; __global__ void count_gen(u32 *src, int nsrc, u32 *choice, int nchoices, int *ngen) { __shared__ u32 some[256]; int tid = threadIdx.x + blockIdx.x * blockDim.x; int nthreads = blockDim.x * gridDim.x;...
5,784
// // Created by ameen on 09/05/20. // #include "null.cuh" __device__ bool isNull(int *i){ return *i == INT_MIN; } __device__ bool isNull(char *data){ int i = 0; while (data[i] == 127) ++i; return data[i] == 0; } __device__ bool isNull(float *f){ return isnan(*f); } __device__ int getNullInt(){...
5,785
#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 1024 #define ALING 64 __device__ double distance( double* dx, double* dy, double* dz, const double Ax, const double Ay, const doubl...
5,786
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <sys/time.h> void genRandomString(char *str,int length) { for(int i=0;i<length-1;++i) { str[i] = 'a' + rand()%26; } str[length-1] = '\0'; } void genRandomSubString(char *str,int length,int sub_len) { for(int i=0;i<length-1;++i) { ...
5,787
//pass //--gridDim=[32768,1,1] --blockDim=[512,1,1] __global__ void increment_kernel(int *g_data, int inc_value) { int idx = blockIdx.x * blockDim.x + threadIdx.x; g_data[idx] = g_data[idx] + inc_value; }
5,788
#include <stdio.h> // declaração de uma constante (compartilhada c/ somente leitura c/ todas as threads) __device__ const char *STR = "HELLO WORLD!"; const char STR_LENGTH = 12; // GPU: Função imprime um letra por fluxo de execução. __global__ void hello() { printf("%c", STR[threadIdx.x % STR_LENGTH]); } // CPU: Fu...
5,789
#include "includes.h" __global__ void tovalue_kernal(float* data, const float value, const int totaltc) { const uint idx = threadIdx.x + (blockIdx.x + blockIdx.y*gridDim.x)*MAX_THREADS; if(idx < totaltc){ data[idx] = value; } }
5,790
#include <iostream> #include <unistd.h> #include "cuda.h" int main() { // show memory usage of GPU size_t free_byte ; size_t total_byte ; while (true ) { cudaError_t cuda_status = cudaMemGetInfo( &free_byte, &total_byte ) ; if ( cudaSuccess != cuda_status ){ std::cout ...
5,791
#include<stdio.h> // Example 1: This is the standard C that runs on the host // Run nvcc hello_world.cu in order to compile programs with no device code int main(void) { printf("Hello World!\n"); return 0; }
5,792
#include "includes.h" using namespace std; #define CUDA_THREAD_NUM 1024 // must be a multiply of 2 void dotProductCPU(); __global__ void dotProductCuda(float *a, float *b, float *c) { __shared__ float se[CUDA_THREAD_NUM]; // Calculate a.*b se[threadIdx.x]=a[threadIdx.x+blockIdx.x*CUDA_THREAD_NUM]*b[threadIdx.x+bloc...
5,793
#include <cuda_runtime.h> #include <stdio.h> #include <sys/time.h> double cpuSecond() { struct timeval tp; gettimeofday(&tp,NULL); return ((double)tp.tv_sec + (double)tp.tv_usec*1.e-6); } __global__ void add1D(int* A, int* B, int* C, int nx, int ny) { int ix = threadIdx.x + blockIdx.x * blockDim.x; ...
5,794
#include "Utils.cuh" #include "iostream" #include <curand.h> using namespace std; // Simple cuda error checking macro #define ErrChk(ans) \ { CudaAssert((ans), __FILE__, __LINE__); } inline void CudaAssert(cudaError_t code, const char* file, int line, bool abort = true) { if (code != cudaSuccess) { fprintf(...
5,795
#include "includes.h" __global__ void relu_f32 (float* vector, float* output, int len) { int idx = blockIdx.x * blockDim.x + threadIdx.x; if (idx < len) { output[idx] = vector[idx] > 0.0 ? vector[idx] : 0.0; } }
5,796
// // Created by igor on 28.03.2021. // #include "Matrix4.cuh" __host__ __device__ double *Matrix4::operator[](unsigned long x) { return data[x]; } Matrix4::Matrix4(std::initializer_list<double> list) noexcept : data(){ int i = 0; for(double d: list){ data[0][i]=d; ++i; } } const Mat...
5,797
/* * UpdaterHy1D.cpp * * Created on: 25 янв. 2016 г. * Author: aleksandr */ #include "UpdaterHy1D.h" __device__ void UpdaterHy1D::operator() (const int indx) { Hy[indx] = Chyh[indx]*Hy[indx] + Chye[indx]*(Ez[indx+1] - Ez[indx]); }
5,798
extern "C" { __global__ void expkernel_32(const int lengthA, const float *a, float *b) { int i = threadIdx.x + blockIdx.x * blockDim.x; if (i<lengthA) { b[i] = exp(a[i]); } } }
5,799
#include "cuda.h" #include <cstdio> static float *h_points; static float *d_points; static double *h_pointsd; static double *d_pointsd; static unsigned int *d_groups; static unsigned int d_psize; static float d_pmax; static float d_pmin; static double d_pmaxd; static double d_pmind; __global__ void groupKernel(float...
5,800
#include <stdio.h> #include <assert.h> #include <cuda.h> #include <cuda_runtime.h> #define MAX(a,b) ( a>b ? a : b) __global__ void vector_add(float *a, float *b, float *c, int N) { int gtid = blockIdx.x*blockDim.x + threadIdx.x; if (gtid < N) { c[gtid] = a[gtid] + b[gtid]; } } bool bPinGen...