serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
22,901
#include <stdlib.h> #include <stdio.h> int main(int argc,char **argv) { printf("Usage ./dump_arrays.out size array_file1 array_file2"); int N =pow(2,atoi(argv[1])); size_t size = N * sizeof(float); int loop; // Allocate input vectors h_A and h_B in host memory float* h_A = (float*)malloc(si...
22,902
/* * Copyright 1993-2010 NVIDIA Corporation. All rights reserved. * * NVIDIA Corporation and its licensors retain all intellectual property and * proprietary rights in and to this software and related documentation. * Any use, reproduction, disclosure, or distribution of this software * and related documentat...
22,903
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <cstdlib> #include <time.h> #include <unistd.h> #define MASK_WIDTH 5 #define TILE_SIZE 4 __constant__ float Mc[1024]; __global__ void Convolution3d(float* input, float* output, int numARows, int numACols, int numAHeight, in...
22,904
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <time.h> #include <stdlib.h> #define ARRAYSIZE 1024 __global__ void minCompare(int *a, bool *check) { int idx = threadIdx.x + blockIdx.x * blockDim.x; int idy = threadIdx.y + blockIdx.y * blockDim.y; if (idx == i...
22,905
#include "includes.h" __global__ void findDiffLabelsAtomicFree(float* devDiff, int diffPitchInFloats, int nPoints, int nClusters, int* devClusters, int* devChanges) { int x = blockDim.x * blockIdx.x + threadIdx.x; if (x < nPoints) { int index = x; float minDistance = 10000000; int minCluster = -1; for(int cluster = 0...
22,906
#include "includes.h" __global__ void stretch_kernel(int acc, int samps, float tsamp, float *d_input, float *d_output, float t_zero, float multiplier, float tsamp_inverse) { int t = blockIdx.x * blockDim.x + threadIdx.x; float p_time = t * ( t_zero + ( multiplier * ( t - 1.0f ) ) ); int stretch_index = __float2int_r...
22,907
#include "includes.h" __global__ void normalized_aligned_dot_products(const double* A, const double divisor, const unsigned int m, const unsigned int n, double* QT) { int a = blockIdx.x * blockDim.x + threadIdx.x; if (a < n) { QT[a] = A[a + m - 1] / divisor; } }
22,908
#include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <curand_kernel.h> extern "C" { __global__ void setup_kernel(curandState *state, int seed, int n, int verbose) { // Usual block/thread indexing... int myblock = blockIdx.x + blockIdx.y * gridDim.x; int blocksize = blockDim.x * blockDim.y *...
22,909
#include "includes.h" __global__ void SigmoidProbPolynomForwardImpl( const float* probs, int batchSize, const float* values, int polynomCount, int outputDim, float* out) { //out: batch_elem0 dim0, dim1, dimk batch_elem1 dim0 dim1 dimk //so threads int polynomId = blockIdx.x; const int dimId = blockIdx.y; int tid = th...
22,910
#include <cuda.h> #include <iostream> void matrixMul(int** A, int** B, int** C, int WIDTH); //loading, transfer, execution(host code) void printArray(int **array, int WIDTH); // print Array elements int main(int argc, char * argv[]){ int WIDTH; int x,y; int **a,**b,**c; if(argc<2){ printf(...
22,911
/* * a simple scan program. compute the partial sums of * the elements of the input array. This version uses * only one block */ __global__ void cudaScan(float* d_out, float* d_in, int n) { // shared array allocated by the launch of the kernel extern __shared__ float temp[]; int threadId = threadIdx.x; if ...
22,912
#include<stdio.h> #include<cuda.h> #include<string.h> #include <stdint.h> #include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <thrust/binary_search.h> int null = INT_MAX; int ninf = INT_MIN; typedef struct Node{ Node* parent; thrust :: host_vector<int> keys; thrust :: host_vector<...
22,913
#include <cuda.h> #include <cuda_runtime.h> #include <iostream> using namespace std; __global__ void arrayadd(int *a,int *c){ int tid=threadIdx.x; if(tid<100) { c[tid]=a[tid]*a[tid]; } } int main() { int size=100; int a[size],c[size]; int *h_a,*h_c; for(int i=0;i<size;i++) { a[i]=i*8; c[i]=0; } ...
22,914
#include <stdio.h> __global__ void kernel_A( float *g_data, int dimx, int dimy ) { int ix = blockIdx.x; int iy = blockIdx.y*blockDim.y + threadIdx.y; int idx = iy*dimx + ix; float value = g_data[idx]; if( ix % 2 ) { value += sqrtf( logf(value) + 1.f ); } else { v...
22,915
/* Good Example of handling main-stack overflow */ #include <iostream> #include <cmath> #include <cuda.h> #include <string> #include <chrono> #define PI 3.1415927 static void HandleError(cudaError_t err, const char *file, int line ) { if (err != cudaSuccess) { printf( "%s in %s at line %d\n", cudaGetErrorS...
22,916
#include <stdio.h> __global__ void shift_forward(int * value) { int index = threadIdx.x; __shared__ int array[64]; array[index] = threadIdx.x; __syncthreads(); // Garantir que todos os valores foram armazenados antes de começar o shift if(index < 63) { int tmp = array[index + 1]; __syncthreads(); // Salvar ...
22,917
//xfail:TIMEOUT //--gridDim=64 --blockDim=128 #include "common.h" template <unsigned int blockSize, bool nIsPow2> __global__ void reduceSinglePass(const float *g_idata, float *g_odata, unsigned int n); template __global__ void reduceSinglePass<128, true>(const float *g_idata, fl...
22,918
#include<stdio.h> #include<stdlib.h> #include<string.h> #include <cuda_runtime_api.h> #define restrict __restrict__ #define PADDINGCLASS -2 #define EXP 2 #define OUTPUT_FILE "ocuda" #define INPUT_FILE "data" void printStats(cudaEvent_t before, cudaEvent_t after, const char *msg); void check_error(cudaError_t err, co...
22,919
#include "includes.h" /* sergeim19 April 27, 2015 Burgers equation - GPU CUDA version */ #define NADVANCE (4000) #define nu (5.0e-2) __global__ void kernel_calc_uu(double *u_dev, double *uu_dev) { int j; j = blockIdx.x * blockDim.x + threadIdx.x; uu_dev[j] = 0.5 * u_dev[j] * u_dev[j]; }
22,920
extern "C" __global__ void hello_world(float *a, float *b) { int tx = threadIdx.x; b[tx] = a[tx]; }
22,921
#include<iostream> struct colours{ int red; int green; int blue; }; __global__ void imageReverse(colours* c_arr, colours* rev_c_arr, int N){ int index = threadIdx.x + blockIdx.x*blockDim.x; rev_c_arr[index].red = 255 - c_arr[index].red; rev_c_arr[index].green = 255 - c_arr[index].green; rev_c_arr[index].blue...
22,922
// Includes #include <stdio.h> // Type of the array in which we search for the maximum. // If you use float, don't forget to type %f in the printf later on.. #define TYPE int #define USE_NAIVE // Variables TYPE* h_A; TYPE* d_A; // Functions void Cleanup(void); void WorstCaseInit(TYPE*, int); __device__ __host__ T...
22,923
// Simplified attempt #define STARTING_MATCHING_COST 100.0f struct pixel { float R; float G; float B; }; __global__ void computeDisparity( const struct pixel * imageR, // Input pixel array of left image // array dim: image[image_width][image_height] const struct pixel *...
22,924
#include "includes.h" __global__ void cudaDmult_kernel(unsigned int size, const double *x1, const double *x2, double *y) { 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) { y[i] = x1[i] * x2[i]; } ...
22,925
#include <iostream> #include <fstream> #include <cmath> #define N 512 #define THREADS 32 #define BLOCKS 16 #define eps 0.005 using namespace std; double *devU,*devU_new,*devF; double *u,*u_new,*f; double h; int numberOfBytes; double f1(int i,int j) { double x=(double)i*h; double y=(double)j*h; return 4.0+2....
22,926
#include "includes.h" __global__ void mult2Matrix(float *M, float *N, float *P) { // Calculate the row index of the P element and M int Row = blockIdx.y * blockDim.y + threadIdx.y; // Calculate the column index of P and N int Col = blockIdx.x * blockDim.x + threadIdx.x; if ((Row < WIDTH) && (Col < WIDTH)) { float Pvalu...
22,927
#include "cuda_runtime.h" #include "device_launch_parameters.h" #define thread_size 128 #include <stdio.h> #include <math.h> double N = 400; const int size = 4000; // CUDA Kernel for Vector Addition __global__ void Vector_Addition(const int *dev_a, const int *dev_b, int *dev_c) { //Get the id of thread within a bl...
22,928
#include <stdio.h> __global__ void helloCuda(void) { printf("hello from GPU\n"); } int main(void) { printf("hello from CPU\n"); helloCuda <<< 1, 10 >>> (); cudaDeviceReset(); return 0; }
22,929
#include "includes.h" __device__ __host__ int maximum( int a, int b, int c){ int k; if( a <= b ) k = b; else k = a; if( k <=c ) return(c); else return(k); } __global__ void upper_left(int *dst, int *input_itemsets, int *reference, int max_rows, int max_cols, int i, int penalty) { int r, c; r = blockIdx.y*blockDim.y+t...
22,930
/*! * Compute the next power of 2 which occurs after a number. * * @param n */ __device__ int nextPower2(int n) { int pow2 = 2; while ( pow2 < n ) { pow2 *= 2; } return pow2; } /*! * Swap two values * * @param a * @param b */ __device__ void swap(float *a, float *b) { flo...
22,931
#include "includes.h" extern "C" { } #define IDX2C(i, j, ld) ((j)*(ld)+(i)) #define SQR(x) ((x)*(x)) // x^2 __global__ void weighting_kernel (double const* matrices, double const* weights, double* results) { int matrix_grid_index = blockIdx.x * blockDim.x * blockDim.y; int block_index = bl...
22,932
#include "includes.h" __global__ void ElementWiseMultiply_CUDA(double *C, double *A, double *B, int rows, int cols) { int j = blockDim.x * blockIdx.x + threadIdx.x; int i = blockDim.y * blockIdx.y + threadIdx.y; int sourceLength = cols * rows; int sourceIndex = i + (j * blockDim.y); int targetIndex = i + (j * blockDim...
22,933
#include <cuda_runtime.h> #include<iostream> using namespace std; #include <device_launch_parameters.h> #define N 5 __global__ void add(int* a, int* b, int* c) { int id = threadIdx.x; if (id < N) { c[id] = b[id] + a[id]; } } int main(void) { int a[N], b[N], c[N]; int *dev_a, *dev_b, *dev_c; cudaMalloc((void*...
22,934
/** * * This is a cuda version of the array addition program as created from the * tutorial from here: * * https://devblogs.nvidia.com/even-easier-introduction-cuda/ * * Any adjustments made are made from suggestions from Programming Massively * Parallel Processors, 3rd Edition: * * https://www.amazon....
22,935
#include "includes.h" __device__ int translate_idx_inv(int ii, int d1, int d2, int d3, int d4, int scale_factor_t, int scale_factor_xy, int off_time, int off_x, int off_y) { /* d1 = channel d2 = time d3, d4 = height, width */ int x, y, t, z, w; w = ii % d4; ii = ii/d4; z = ii % d3; ii = ii/d3; t = ii % d2; ii = ii/d2; ...
22,936
#include <stdio.h> #include <math.h> #include <cuda.h> __host__ void checkCudaState(cudaError_t& cudaState,const char *message){ /* it will print an error message if there is */ if(cudaState != cudaSuccess) printf("%s",message); } __device__ void swap(int *points,uint lowIndex,uint upIndex){ /* it will swap two...
22,937
#include "includes.h" __global__ void cuInsertionSort(float *dist, int dist_pitch, int *ind, int ind_pitch, int width, int height, int k){ // Variables int l, i, j; float *p_dist; int *p_ind; float curr_dist, max_dist; int curr_row, max_row; unsigned int xIndex = blockIdx.x * blockDim.x + threadIdx.x; if (xIndex<...
22,938
// Huang Tianwei 20026141 twhuang@connect.ust.hk #include <iostream> #include <cstdio> #include <cmath> #include <cuda_runtime.h> #include <device_launch_parameters.h> #include <cstdlib> #include <ctime> #include <thrust/scan.h> #include <thrust/device_ptr.h> #include <thrust/sort.h> #include <thrust/device_vector.h> u...
22,939
__global__ void assignTID(int *data) { int tid = blockIdx.x * blockDim.x + threadIdx.x; data[tid] = tid; }
22,940
/** * File : gpu_conv.cu * Author : Xianglan Piao <lanxlpiao@gmail.com> * Date : 2020.06.16 * Last Modified Date: 2020.07.31 * Last Modified By : Xianglan Piao <lanxlpiao@gmail.com> * NOTE: : cuda conv2d */ #include <iostream> #define ifm_size 8 #define wgt_siz...
22,941
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <sys/time.h> #include <sys/types.h> struct timeval startTime, stopTime; int started = 0; void start_timer() { started = 1; gettimeofday(&startTime, NULL); } double stop_timer() { long seconds, useconds; double duration = -1; ...
22,942
#include <iostream> using namespace std; __host__ __device__ void swap(int & a, int &b){ a=a^b; b=a^b; a=b^a; } // Scan, limited to 1 block, upto 1024 threads; __global__ void scan(unsigned int *g_data, unsigned int * g_intermediate, int n, int flag) { // flag =0 inclusive; flag =1 Exclusive ex...
22,943
#include <stdio.h> #include <stdlib.h> #include <time.h> #define SEC_AS_NANO 1000000000.0 struct _matriz { int n; int m; int **cont; }; typedef struct _matriz Matriz; Matriz *criarMatriz(int n, int m) { Matriz *mat = (Matriz*) malloc(sizeof(Matriz)); mat->n = n; mat->m = m; mat->cont = (int**) malloc(n * siz...
22,944
#include <stdio.h> #include <cuda_runtime.h> __global__ void checkIndex() { printf("threadIdx = ( %d, %d, %d)\n", threadIdx.x, threadIdx.y, threadIdx.z); printf("blockDim = ( %d, %d, %d)\n", blockDim.x, blockDim.y, blockDim.z); printf("gridDim = ( %d, %d, %d)\n", gridDim.x, gridDim.y, gridDim.z); } int main() ...
22,945
// filename: vsquare.cu // a simple CUDA kernel to element multiply vector with itself extern "C" // ensure function name to be exactly "vsquare" { __global__ void vsquare(const double *a, double *c) { int i = threadIdx.x + blockIdx.x * blockDim.x; c[i] = a[i] * a[i]; } }
22,946
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <iostream> #include <fstream> #include <chrono> #include <string> using namespace std; #include <stdio.h> #include <assert.h> #include <math.h> #define ll long long int const ll m = 0x5DEECE66Dll; const ll mask = (1ll << 48) - 1; #define advan...
22,947
// cuda-kernel: add 2 numbers __global__ void addnums (double *pi, double c){ *pi += c; } // cuda-kernel: add 2 vectors __global__ void addvecs (double *v1, double *v2){ int idx = threadIdx.x; v1[idx] += v2[idx]; }
22,948
#include "includes.h" __global__ void callOperation(int *a, int *b, int *res, int k, int p, int n) { int idx = blockDim.x * blockIdx.x + threadIdx.x; int idy = blockDim.y * blockIdx.y + threadIdx.y; if (idx >= n || idy >= n) { return; } int tid = idx * n + idy; res[tid] = a[tid] + b[tid]; if (res[tid] > k) { res[ti...
22,949
#include "includes.h" __device__ void compute_conv(int row, int col, double2 *d_c, double *d_a, double2 *d_b, int *o_row_vect, int *o_col_vect, int ma, int na, int mb, int nb, int mc, int nc) { int count_row = o_row_vect[row]; int count_col = o_col_vect[col]; int row_idx; int col_idx; int k_row_idx; int k_col_idx; int...
22,950
extern "C" __global__ void SearchPatternKernel_naive(int *d_nFound, int *d_offsets, int nMaxMatched, const unsigned char *d_pattern, int patternLength, const unsigned char *d_text, int searchLength) { int gid = blockDim.x * blockIdx.x + threadIdx.x; if (gid < searchLe...
22,951
#include <stdio.h> #include <time.h> #include <assert.h> inline cudaError_t checkCuda(cudaError_t result) { if (result != cudaSuccess) { fprintf(stderr, "CUDA Runtime Error: %s\n", cudaGetErrorString(result)); assert(result == cudaSuccess); } return result; } void initWith(float num, float *a, int N) {...
22,952
#include "includes.h" __global__ void backward_avgpool_layer_kernel(int n, int w, int h, int c, float *in_delta, float *out_delta) { int id = (blockIdx.x + blockIdx.y*gridDim.x) * blockDim.x + threadIdx.x; if(id >= n) return; int k = id % c; id /= c; int b = id; int i; int out_index = (k + c*b); for(i = 0; i < w*h; +...
22,953
#include<iostream> #include<cstdlib> #include<cmath> #include<time.h> using namespace std; __global__ void matrixVectorMultiplication(float *a, float *mat, float *c, int n) { int row=threadIdx.x+blockDim.x*blockIdx.x; float sum=0; if(row<n){ for(int j=0;j<n;j++) { sum=sum+mat[row*n+j]*...
22,954
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> __global__ void increase(int *c, int N){ int tid = threadIdx.x + blockIdx.x * blockDim.x; if(tid < N) c[tid] = tid; } __global__ void kernel0( int *a ) { int idx = blockIdx.x*blockDim.x + threadIdx.x; a[idx] = 7; ...
22,955
#include <stdio.h> #include <cuda_runtime.h> #include <sys/time.h> double seconds(){ struct timeval tp; struct timezone tzp; int i = gettimeofday(&tp,&tzp); return ((double)tp.tv_sec+(double)tp.tv_usec*1.e-6); } int recursiveReduce(int *data, int const size){ // terminate check if (size ==...
22,956
#include "includes.h" __global__ void cuArraysCopyToBatchWithOffset_kernel(const float2 *imageIn, const int inNY, float2 *imageOut, const int outNX, const int outNY, const int nImages, const int *offsetX, const int *offsetY) { int idxImage = blockIdx.z; int outx = threadIdx.x + blockDim.x*blockIdx.x; int outy = threadI...
22,957
#include <chrono> #include <cmath> #include <cstdio> #include <cstdlib> #include <cuda_runtime.h> #include <iomanip> #include <iostream> // helper for time measurement typedef std::chrono::duration<double, std::milli> d_ms; const auto &now = std::chrono::high_resolution_clock::now; // Define Error Checking Macro #def...
22,958
// Variable num_cores denotes the number of threads to run the code on. #include <stdio.h> //#include <omp.h> #include <string.h> #include <math.h> //#include "../common/common.h" #include <cuda_runtime.h> /* * compute string value, length should be small than strlen */ __global__ void findHashes(char *d_css, int ...
22,959
__global__ void _InitI(int *res,int val,int rows,int columns){ int x = threadIdx.x + blockIdx.x * blockDim.x; int y = threadIdx.y + blockIdx.y * blockDim.y; if (x < rows && y < columns){ int pos = x*columns + y; res[pos] = val; } } __global__ void _AddI(int *res,int *arr,int arrRows,int arrColumns,int rows,in...
22,960
#include <cuda_runtime.h> #include <stdio.h> __global__ void cudahello(){ int thread = threadIdx.x; int block = blockIdx.x; printf("Hola Mundo! Soy el hilo %d del bloque %d\n", thread, block); } int main(){ cudahello<<<4,4>>>(); cudaDeviceSynchronize(); }
22,961
#include "device_launch_parameters.h" #include <stdio.h> #define arraySize 5 #define threadPerBlock 5 // Kernel Function for Rank sort __global__ void addKernel(int *d_a, int *d_b) { int count = 0; int tid = threadIdx.x; int ttid = blockIdx.x * threadPerBlock + tid; int val = d_a[ttid]; __shared__ int cache[...
22,962
void init_bounds(int size, double *u) { int i; for (i = 0; i < size; i++) { u[i * size + 0] = 0; u[0 * size + i] = 20; u[i * size + (size - 1)] = 20; u[(size - 1) * size + i] = 20; } } void init_interior(int size, double *u, double guess) { int i, j; for (i = 1; i < size - 1; i++) { for (j = 1; j < size...
22,963
/* Fold each FFT chunk separately. * pol0, pol1 are input baseband data * Only works for 4 pol output. * Call with grid dims (nffts, nbins/BINS_PER_BLOCK) * All shared blocks need to fit into shared mem (16kB) */ #define BINS_PER_BLOCK 64 #define NTHREAD_FOLD BINS_PER_BLOCK __global__ void fold_fft_blocks(const f...
22,964
/* ================================================================== Programmer: Yicheng Tu (ytu@cse.usf.edu) The basic SDH algorithm implementation for 3D data To compile: nvcc SDH.c -o SDH in the C4 lab machines ================================================================== */ #include <stdio.h> #include ...
22,965
// // CasAES128_CUDA.c // CasAES128_CUDA // Created by Carter McCardwell on 11/11/14. // #include <stdint.h> #include <stdio.h> #include <time.h> #include <string.h> #include <cuda_runtime.h> struct timing_pair{ long time; long times[4]; char cipher[16]; char hits[10][4][4]; //long memory_usage; //int ctx_d...
22,966
#include "includes.h" __global__ void cudaSNearestNeighborKernel(const float* input, size_t inputSizeX, size_t inputSizeY, float* output, size_t outputSizeX, size_t outputSizeY, size_t nbChannels, size_t batchSize) { const size_t inputOffset = (blockIdx.z*blockDim.z + threadIdx.z) * (nbChannels*inputSizeY*inputSizeX); ...
22,967
#include "includes.h" __global__ void scatter(unsigned int *in,unsigned int *in_pos, unsigned int *out, unsigned int *out_pos, unsigned int n, unsigned int *d_histScan, unsigned int mask, unsigned int current_bits, unsigned int nBins) { extern __shared__ unsigned int min_Idx[]; for(int j = threadIdx.x; j < nBins; ...
22,968
/* struct Trim { Trim(t3<const int> n) : left(n.y*n.z, n.x), right(n.y*n.z, 0), edgeCases((n.x-1)*n.y*n.z), iter_helper(edgeCases.begin(), n.y*n.z, n.x-1) {} thrust::device_vector<int> left; thrust::device_vector<int> right; ...
22,969
// Salt and pepper noise simulation with Cuda C/C++ // Original framework for code taken from imflipG.cu // Modified by Ethan Webster #include <cuda_runtime.h> #include <curand_kernel.h> #include <device_launch_parameters.h> #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> #include <iostr...
22,970
#include "includes.h" __global__ void gpu_matrixmult(int *gpu_a, int *gpu_b, int *gpu_c, int N) { int k, sum = 0; int col = threadIdx.x + blockDim.x * blockIdx.x; int row = threadIdx.y + blockDim.y * blockIdx.y; if(col < N && row < N) { for(k = 0; k < N; k++) sum += gpu_a[row * N + k] * gpu_b[k * N + col]; gpu_c[row ...
22,971
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdbool.h> #include <time.h> //-------- Generation of matrix of random single point precision numbers --------// float * generateMatrix(int n){ float* matrix = (float *)malloc(n*n*sizeof(float)); for(int i=0; i<n*n; i++){ matrix[i] = (float)(...
22,972
/** * One Way Hash with CUDA (Fall 2016): * * Members: * Emanuelle Crespi, Tolga Keskinoglu * * This test implements a simple hash from a space of size 2n --> n * * The following code makes use of the kernel call hash(char *f, char *h, int n) * to perform a parallel hash of elements f --> h with correspondin...
22,973
#include<bits/stdc++.h> using namespace std; #define BLOCK_SIZE 256 __global__ void type1(int n, double lr, double lambda, double * W) { int index = blockIdx.x * blockDim.x + threadIdx.x; int stride = blockDim.x * gridDim.x; for (int i=index;i<n;i+=stride) { W[i] = (1.0 - lr* lambda) * W[i]; } ...
22,974
// Take From // https://stackoverflow.com/questions/35137213/texture-objects-for-doubles #include <vector> #include <cstdio> static __inline__ __device__ double fetch_double(uint2 p){ return __hiloint2double(p.y, p.x); } #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } inline void gpuAssert(cuda...
22,975
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <time.h> #include <stdlib.h> #define ARR_SIZE 102400 #define THREADS 512 #define ARR_BYTE sizeof(int) * ARR_SIZE __global__ void gpuSort(int * d_arr, size_t maxSize); int main(int argv, char ** argc) { int * h_arr; in...
22,976
#include "includes.h" __global__ void ZeroMeanImpl(float* solutions, int rowSize, int matCount) { const int matricesPerBlock = BLOCK_SIZE / rowSize; const int matrixIdx = blockIdx.x * matricesPerBlock + threadIdx.x / rowSize; const int tid = threadIdx.x; const int col = threadIdx.x & (rowSize - 1); const int inBlockO...
22,977
#include "includes.h" __global__ void gradient_array_normalize_channels_kernel(float *x, int size, int batch, int channels, int wh_step, float *delta_gpu) { int i = blockIdx.x * blockDim.x + threadIdx.x; int wh_i = i % wh_step; int b = i / wh_step; if (i < size) { int k; /* float grad = 0; for (k = 0; k < channels; +...
22,978
#include "includes.h" __global__ void accumulatedPartSizesKernel(int size, int *part, int *weights, int *accumulatedSize) { int idx = blockIdx.x * blockDim.x + threadIdx.x; if(idx == size - 1) accumulatedSize[part[idx]] = weights[idx]; if(idx < size - 1) { int thisPart = part[idx]; if(thisPart != part[idx + 1]) accumul...
22,979
#include "includes.h" __global__ void fill_with_average(unsigned char *img, int * nz, int * average, int scale) { int x = blockIdx.x * TILE_DIM + threadIdx.x; int y = blockIdx.y * TILE_DIM + threadIdx.y; int width = gridDim.x * TILE_DIM; //int h = width /2; for (int j = 0; j < TILE_DIM; j+= BLOCK_ROWS) { int iw = x; i...
22,980
#include <iostream> using namespace std; __global__ void kernel( int* b, int* t) { if( !threadIdx.x) { *b = blockDim.x; // num threads per block } t[threadIdx.x] = threadIdx.x; } int main() { int numthreads = 4; int b; int* t; t = new int[numthreads]; int* d_b; // pointer to device memory ...
22,981
#include <cuda_runtime_api.h> #include <iostream> // Define a function that will only be compiled for and called from host __host__ void HostOnly() { std::cout << "This function may only be called from the host" << std::endl; } // Define a function that will only be compiled for and called from device __device__ ...
22,982
/****************************************************************************** *cr *cr (C) Copyright 2010 The Board of Trustees of the *cr University of Illinois *cr All Rights Reserved *cr *****************************************************************...
22,983
#include <stdio.h> #include <cuda.h> #define BLOCK_SIZE 1024 #define CUDA_CHECK(value, label) { \ cudaError_t c = (value); \ if (c != cudaSuccess) { \ fprintf(stderr, \ "Error: '%s' at line %d in %s\n", \ cuda...
22,984
#include "includes.h" __global__ void TgvSolveTpMaskedKernel(float* mask, float*a, float *b, float*c, float2* p, float2* Tp, int width, int height, int stride) { int iy = blockIdx.y * blockDim.y + threadIdx.y; // current row int ix = blockIdx.x * blockDim.x + threadIdx.x; // current column if ((iy >= hei...
22,985
__device__ float dist(float x[3], float y[3]) { float d1=x[0]-y[0]; float d2=x[1]-y[1]; float d3=x[2]-y[2]; return (d1*d1 + d2*d2 + d3*d3); } __device__ float dot(float a[], float b[]) { return (a[0] * b[0] + a[1] * b[1] + a[2] * b[2]); } __device__ void transform(float t[3], float u[3][3], float...
22,986
/* Programa: mst_cuda_semGB.c (Versão 1) Descrição: Implementa o Algoritmo para árvore geradora mínima. Programadora: Jucele Vasconcellos Data: 25/08/2017 Versão 3: sem o atomicAddD em Calcula_num_zerodiff Compilacao: nvcc -arch sm_30 -o mst_cuda_semGB.exe mst_cuda_semGB.cu Execucao: ./st_cuda.exe in/grafo/graf...
22,987
#include "includes.h" __global__ void blendingGray(uchar3 *input, uchar3 *input2, uchar3 *output,int width, int height,float coefficient) { int x = threadIdx.x + blockIdx.x * blockDim.x; int y = threadIdx.y + blockIdx.y * blockDim.y; int tid = y*width + x; int nbPixels = width * height; float prod = coefficient * ...
22,988
#include<stdio.h> #include<stdlib.h> int N = 1<<10; __global__ void add(int *a,int *b,int n){ int index = threadIdx.x; if( index < n) b[index] = a[index]+b[index]; } int main(void){ int *A,*B; int *a,*b; A = (int*)malloc(N*sizeof(int)); B = (int*)malloc(N*sizeof(int)); cudaMalloc(&a, N*sizeof(int)); cu...
22,989
#include <cuda_runtime_api.h> #include <stdio.h> #include "cputime.h" // float *accnew_gpu; // float *velnew_gpu; float *parforce_gpu; float *parpot_gpu; float *parvel_gpu; float *acc_gpu; float *force_gpu; float *pos_gpu; float *vel_gpu; /* extern "C" double cputime() { struct timeval tp; int rtn; rtn=gettimeofda...
22,990
#include <iostream> namespace ckt { void check_cuda_error_always(const char *kernelname, const char *file, int line_no, cudaStream_t stream); void check_cuda_error(const char *kernelname, const char *file, int line_no, cudaStream_t stream ) { #ifdef DEBUG check_cuda_error_always(kernelname, file, line_no, s...
22,991
#include <stdio.h> #include <cuda_runtime.h> #define CHECK(call){ \ const cudaError_t error = call; \ if( error != cudaSuccess ){ \ printf("Error: %s:%d\n", __FILE__, __LINE__); \ printf("code: %d, reason: %s\n", error, cudaGetErrorString(error)); \ exit(1); \ } \ } __global__ void helloFromGPU(void){ pri...
22,992
#include "includes.h" __global__ void update_population_metadata( unsigned int * pop , unsigned int rows , unsigned int cols , unsigned int * free , unsigned int * lost , unsigned int * fixed ) { unsigned int tid = threadIdx.y * blockDim.x + threadIdx.x; __shared__ unsigned int sPop[ MAX_THREADS ]; __shared__ unsigned...
22,993
#include "includes.h" __global__ void rgbUtoLab3F_kernel(int width, int height, float gamma, unsigned int* rgbU, float* devL, float* devA, float* devB) { int x0 = blockDim.x * blockIdx.x + threadIdx.x; int y0 = blockDim.y * blockIdx.y + threadIdx.y; if ((x0 < width) && (y0 < height)) { int index = y0 * width + x0; unsi...
22,994
#include <stdio.h> __global__ void vecAdd1(int *A, int *B,int *C){ int id = blockIdx.x; C[id] = A[id] + B[id]; } __global__ void vecAdd2(int *A, int *B, int *C){ int id = threadIdx.x; C[id] = A[id] + B[id]; } __global__ void vecAdd3(int *A, int *B, int *C){ int id = blockIdx.x*blockDim.x + threadIdx.x; C[id] =...
22,995
#include <cuda.h> #include <cuda_fp16.h> #include <stdio.h> #include <stdint.h> #include <zlib.h> #include <stdlib.h> #include <time.h> #include <math.h> #include <fcntl.h> #include <limits.h> typedef struct __ReadSeqList { char* sequence; unsigned int length; struct __ReadSeqList* next; } ReadSeqList; typedef st...
22,996
#include "cuda_runtime.h" #include <stdio.h> int main(void) { cudaDeviceProp prop; int count; cudaGetDeviceCount(&count); for (int i=0; i<count; i++){ cudaGetDeviceProperties(&prop, i); printf("---General information for device %d---\n", i); printf("Name : %s\n", prop.name); printf("Compute Capability : ...
22,997
#include "includes.h" // Copyright 2019, Dimitra S. Kaitalidou, All rights reserved #define N 256 #define THR_PER_BL 8 #define BL_PER_GR 32 __global__ void kernel1(int* D, int* Q, int k){ // Find index int i = blockIdx.x * blockDim.x + threadIdx.x; int block = (int)(i / (2 * k)); int j; if(i % 2 == 0) j = 2 * bl...
22,998
#include <iostream> #include <cstdlib> #include <random> #include <ctime> #include <fstream> using namespace std; #define MAX_T 10000 #define MIN_T 1000 #define MAX_K 400 #define MIN_K 50 #define N 10 #define NUM_SAMPLES 50 double T1[MAX_K][MAX_T]; int T2[MAX_K][MAX_T]; double pi[MAX_K]; int Y[MAX_T]; int X[MAX_T];...
22,999
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> int * myloadFile(int n,char *s){ int i; int *a=(int *)malloc(sizeof(int)*n); for(i=0;i<n;i++) { a[i]=i; } return a; } void display(int *a,int n){ int i; for(i=0;i<n;i++) { printf("%d %d \n",i,a[i]); ...
23,000
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #define DATASIZE 260 cudaError_t searchKeyword(int *result, char *data, char *keyword); __global__ void searchKeywordKernel(int *result, char *data, char *keyword) { int i = threadIdx.x; // Detec...