serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
2,401
#include <stdio.h> #include <stdlib.h> #define ERROR(s) printf("%s \n Usage: %s <no. of elements> <random seed>\n", s, argv[0]); exit(-1); #define CUDA_ERROR_EXIT(str) do{\ cudaError err = cudaGetLastError();\ if( err != cudaSuccess){\ ...
2,402
#include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <math.h> __global__ void burst(float *dx, int n, int k, float *dxbar, int maxWinSize) { int tid=threadIdx.y*blockDim.x+threadIdx.x; int me=blockIdx.x*blockDim.x*blockDim.y+tid; int width=n-k+1; int x=me%width; int y=me/width; int pers...
2,403
#include <stdlib.h> #include <stdio.h> #include <math.h> #include <time.h> #include "cuda_runtime.h" #include "device_launch_parameters.h" #include <cuda.h> #include <climits> void printBoard(unsigned char* buffer, int width, int height) { printf("----------------\n"); for (int i = 0; i < height; i++){ for (int j ...
2,404
__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 += stride) { a[i] = 1; } } void hostFunction(int *a, int N) { for (int i = 0; i < N; ++i) { a[i] = 1; } } int main() { int N = 2<<2...
2,405
#include <math.h> #include <fstream> #include <stdio.h> #include <exception> #define MAX_THREADS 1024 #define INF 99999999999.0 #define PI 3.14159265 using namespace std; // 3 points. __global__ void nj_step1(float* mat, float* res,int width) // Calculate the tree-divergence for every object. { size_t idx = b...
2,406
#include <stdio.h> #include <stdlib.h> #define N 22 __global__ void MatAdd(int A[][N], int B[][N], int C[][N]){ int i = threadIdx.x; // create threds for use 1024 threads in a single block in a single dimension int j = threadIdx.y; // create threds for use 1024 threads in a single block in a sin...
2,407
/*#include "GPU_function.cuh" void cudaFTshift(cufftComplex * input, int sizeX, int sizeY) { int blocksInX = (sizeX+8-1)/8; int blocksInY = (sizeY+8-1)/8; dim3 grid(blocksInX, blocksInY); dim3 block(8, 8); cuFFT2Dshift<<<grid,block>>>(input, sizeX, sizeY); }*/
2,408
#include <stdio.h> #include <math.h> #include <stdlib.h> #include <time.h> uint getTimeMicroseconds64() { uint nTime; struct timespec tSpec; clock_gettime(CLOCK_REALTIME, &tSpec); nTime = (uint)tSpec.tv_sec * 1000000 + (uint)tSpec.tv_nsec / 1000; return nTime; } __global__ void lrp_perc(int *in, int *out...
2,409
#include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <iostream> #include <fstream> #include <tuple> #include <random> #include <functional> #include <chrono> #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } inline void gpuAssert(cudaError_t code, const char *file, int ...
2,410
#include "includes.h" __global__ void minus_one(float *matrix, unsigned int *indices, unsigned int row, unsigned int col) { int index = blockIdx.x * blockDim.x + threadIdx.x; if (index < row) matrix[index * col + indices[index]] -= 1; }
2,411
#include "includes.h" __global__ void writeSimilarities(const float* nvccResults, int* activelayers, int writestep, int writenum, float* similarities, int active_slices, int slices) { int tid = blockIdx.x * blockDim.x + threadIdx.x; if (tid < active_slices) { float res = nvccResults[tid]; int slice = activelayers[tid];...
2,412
#include<stdio.h> #include<stdlib.h> #include<time.h> #include<math.h> #include<curand.h> #include<curand_kernel.h> #include<string.h> #include<new> #define FALSE 0 #define TRUE 1 #define STR_EQ 0 #define max(a, b) \ ({__typeof__ (a) _a = (a); \ __typeof__ (b) _b = (b); \ _a > _b ? _a : _b; }) #define min(a, ...
2,413
#include "includes.h" __global__ void setGroupsPointersDead(multipassConfig_t* mbk, unsigned numBuckets) { int index = TID; if(index < numBuckets) { mbk->isNextDeads[index] = 1; } }
2,414
//function kernel __device__ float length(float3 r) { return r.x*r.x + r.y*r.y + r.z*r.z; } __device__ float3 mul_float3(float3 r1, float3 r2) { return make_float3(r1.x * r2.x, r1.y * r2.y, r1.z * r2.z); } __device__ float3 add_float3(float3 r1, float3 r2) { return make_float3(r1.x + r2.x, r1.y + r2.y, ...
2,415
#include <iostream> #include <stdio.h> __global__ void kernel() { printf("Just a test! I am point cloud %d!\n", blockIdx.x); } int main() { kernel<<<9, 1>>>(); cudaDeviceSynchronize(); ///wait for the kernel function to finish the execution, and then continue to execute the following code return 1; }
2,416
#include <stdio.h> //#include <cuda_runtime.h> #include <inttypes.h> //для использования uint8_t #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,417
#if GOOGLE_CUDA #define EIGEN_USE_GPU __global__ void default_function_kernel0(const float* __restrict__ Data, const float* __restrict__ K0, const float* __restrict__ K1, const float* __restrict__ KC, float* __restrict__ Output) { float Output_local[128]; __shared__ float pad_temp_shared[640]; ...
2,418
#include <stdio.h> #include <assert.h> #include <cuda.h> int main(void) { const int N = 1000; double *a_h, *b_h; // pointers to host memory double *a_d, *b_d; // pointers to device memory // allocate arrays on host a_h = new double [N]; b_h = new double [N]; // allocate arrays on device cuda...
2,419
#include <thrust/device_vector.h> #include <thrust/host_vector.h> #include <iostream> #include <ctype.h> #include <vector> #include <string> typedef std::vector<double> double_vec; int main() { double_vec stocks; std::string value; while (true) { std::getline(std::cin, value); if (!isd...
2,420
#include <stdio.h> #include <algorithm> #include <cstdlib> #include <curand.h> #include <curand_kernel.h> // In the following section, define the prob distribution parameters #define N_PARAMS 3 #define PARAM1 50.0f, 3.0f, 0.5f // format: LAMBDA, A, B #define PARAM2 1.5f, 0.8f, 5.0f // parameters saved as constants un...
2,421
#include "includes.h" __global__ void cuConvertRGBToLABKernel(const float4* src, float4* dst, size_t stride, int width, int height, bool isNormalized) { const int x = blockIdx.x*blockDim.x + threadIdx.x; const int y = blockIdx.y*blockDim.y + threadIdx.y; int c = y*stride + x; if (x<width && y<height) { // Read float4 ...
2,422
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <device_functions.h> #include <sstream> #include <fstream> #include <iostream> #include <stdlib.h> #include <math.h> #include <cuda.h> #include "changeDatatype.cuh" using namespace std; __global__ void changeType(float* srcData, float* dstData,...
2,423
//pass //--blockDim=[1,128] --gridDim=[512,6] #include <cuda.h> ////////////////////////////////////////////////////////////////////////////// //// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF //// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO //// THE IMPLIED WARRANTIES OF ...
2,424
#include "includes.h" __global__ void ComputeHistogramKernel( float *globalMemData, int *globalHist ) { //the kernel should be only 1D int globalThreadId = blockDim.x*blockIdx.y*gridDim.x //rows preceeding current row in grid + blockDim.x*blockIdx.x //blocks preceeding current block + threadIdx.x; int localThreadI...
2,425
__global__ void choleskyParalelo(float *db, int num){ int id=threadIdx.x + blockIdx.x*blockDim.x; int x=0; int inicio=0; int k=0, N=num; int id1=id+inicio, ids=id,id2; int N2 = N; int NN=0, KK=0; while(k < N){ id1=id+inicio; //Checamos si es un elemnto de la diagonal if(id1 == inicio){ db[id1] = sqr...
2,426
#include <iostream> #include <cstdlib> #include <cmath> #include <cstdio> #include <fstream> #include <time.h> using namespace std; //swap two int arrays void swapPtrs(int **A, int **B){ int *temp = *A; *A = *B; *B = temp; } //clear a cuda array to -1 __global__ void cudaClear(int* dev_clear, int size){ int i...
2,427
#include <iostream> #include <string> using namespace std; __global__ void convertData(char* text, int length) { for (unsigned int i = 0; i < length; i++) { //ALPHA if (text[i] >= 'A') text[i] = '.'; } } int main() { char input[] = "aabfdh.fdsjkl.+@!ckdsj/khj"; cout ...
2,428
#include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <iostream> #define N 3000 using namespace std; __global__ void add(int *a, int *b, int *c) { int i = blockIdx.x * blockDim.x + threadIdx.x; if(i<N) c[i] = a[i] + b[i]; } int main() { int *a, *b, *c; int *dev_a, *dev_b, *dev_c; int i; a = ...
2,429
#include "includes.h" __global__ void constrain_kernel(int N, float ALPHA, float *X, int INCX) { int i = (blockIdx.x + blockIdx.y*gridDim.x) * blockDim.x + threadIdx.x; if(i < N) X[i*INCX] = fminf(ALPHA, fmaxf(-ALPHA, X[i*INCX])); }
2,430
// // Created by root on 2020/11/19. // #include "stdio.h" #include <cuda_runtime.h> #define DIM 128 __global__ void reduceGmem(int *g_idata, int *g_odata, int n) { int tid = threadIdx.x; int *idata = g_idata + blockIdx.x * blockDim.x; int idx = threadIdx.x + blockIdx.x * blockDim.x; if (idx >= n) ...
2,431
#define TILE_DIM 1024 #include <limits> template<typename T> __device__ void argmaxColumn(const T* matrix, int* result, const int numRows, const int numColumns) { __shared__ T partsVals[TILE_DIM]; __shared__ int partsArgs[TILE_DIM]; int index = threadIdx.x; int rowStride = blockDim.x; int partLength = (nu...
2,432
#include<iostream> #include<vector> const int SHARED_MEM = 64; __global__ void dotProdKernel(int *a, int *b, int *r, int N){ __shared__ int sh[SHARED_MEM*sizeof(int)]; int index = threadIdx.x + blockDim.x*blockIdx.x; int offset = 0; int stride = blockDim.x; while(index+offset < N){ s...
2,433
#include "cuda_runtime.h" #include "device_launch_parameters.h" // Optimized using shared memory and on chip memory // nvcc nbodyGPU5.cu -o GPU5 -lglut -lm -lGLU -lGL //To stop hit "control c" in the window you launched it from. #include <math.h> #include <stdio.h> #include ...
2,434
#include <stdio.h> #include <iostream> #include "cuda_runtime.h" //Kernel code. __global__ void square(float * d_in, float * d_out) { int idx = threadIdx.x; float f = d_in[idx]; d_out[idx] = f * f; } int main() { const int ARRAY_SIZE = 4; const int ARRAY_BYTES = ARRAY_SIZE * sizeof(float); //input array on ...
2,435
// Utilities and system includes #include <stdio.h> #include <stdlib.h> #include <cuda.h> // #include <cupti.h> #include <cuda_profiler_api.h> #define DATA_TYPE 0 // 0-SP, 1-INT, 2-DP #define THREADS 1024 #define TILE_DIM 1024 #define SIZE 60000000 #define INNER_REPS 8192 template <class T> __global__ void simpleKe...
2,436
#include <iostream> #include <chrono> #define M 512 __device__ float polynomial (float x, float* poly, int degree) { float out = 0.; float xtothepowerof = 1.; for (int i=0; i<=degree; ++i) { out += xtothepowerof*poly[i]; xtothepowerof *= x; } return out; } __global__ void polynomial_expansion (floa...
2,437
#include <stdio.h> #include <stdlib.h> #include <string.h> /* memcpy */ #include <math.h> #include <stdint.h> void *cuda_upload_var(void *host_var, int size) { void *cuda_var; cudaMalloc(&cuda_var, 4); cudaMemcpy(cuda_var, host_var, size, cudaMemcpyHostToDevice); return cuda_var; } void cuda_download_var(void *cud...
2,438
// #include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> #include <string> #include <iomanip> #include <time.h> #include <iostream> using namespace std; #define N 1000 #define S 2 #define BLOCK_SIZE 1 __global__ void zeta(float* c) { int tid = threadIdx.x; int idx =...
2,439
#include "includes.h" __global__ void awkward_ByteMaskedArray_getitem_nextcarry_kernel(int64_t* prefixed_mask, int64_t* to_carry, int8_t* mask, int64_t length) { int64_t block_id = blockIdx.x + blockIdx.y * gridDim.x + gridDim.x * gridDim.y * blockIdx.z; int64_t thread_id = block_id * blockDim.x + threadIdx.x; if(thre...
2,440
#include <stdio.h> #include <math.h> #include <time.h> #include <unistd.h> #include <cuda_runtime_api.h> /* To compile: nvcc -o LinearRegressionCuda LinearRegressionCuda.cu */ typedef struct point_t { double x; double y; } point_t; int n_data = 1000; __device__ int d_n_data = 1000; point_t data[] = { {71....
2,441
__global__ void repeatedActivations(float* H, int K, int M, int r, float iterfac) { /* Avoid repeated activations with a maximum filter :param H: An KxM matrix whose repeated activations will be suppressed row-wise :param K, M: Dimensions :param r: Width of repeated activation filter :param iter...
2,442
#include <stdio.h> // 这个是kernel函数,就是GPU函数 __global__ void kernelfunction(int*a,int*b,int*c){ *c=*a+*b; } int main(void){ printf("Cuda_Performance Hello World\n"); int a,b,c; int *d_a,*d_b,*d_c; int size =sizeof(int); // take the address of d_a,and cast into void** // 取d_a的地址(一个二级指针),然后类型转换成void** ...
2,443
// // Created by binhpht on 27.3.2021. // #include <stdio.h> #include "iostream" #include "square.cuh" __global__ void square (float * d_out, float * d_in) { // int idx = threadIdx.x; int idx = blockIdx.x * blockDim.x + threadIdx.x; float f = d_in[idx]; d_out[idx] = f * f; } void call_square (int thread_num, float...
2,444
#include <stdio.h> int get_GPU_Rate() { cudaDeviceProp deviceProp; cudaGetDeviceProperties(&deviceProp,0); return deviceProp.clockRate; } int main() { printf("GPU Rate is %d\n", get_GPU_Rate()); }
2,445
//pass //--gridDim=[11377,1,1] --blockDim=[256,1,1] #include "common.h" __global__ void addScalar(uint *array, int scalar, uint size) { uint tid = blockIdx.x * blockDim.x + threadIdx.x; if (tid < size) { array[tid] += scalar; } }
2,446
/* KAM PUI SO (ANTHONY) CS 510 GPU Homework 1 The Cross-Over Point CUDA really shines when given problems involving lots of data, but for small problems, using CUDA can be slower than a pure CPU solution. Since it can be difficult to get a feel for how large a problem needs to be before using the GPU becomes useful, ...
2,447
/** * MIT License * * Copyright (c) 2017 Karan Vivek Bhargava * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without * limitation the rights to...
2,448
#include <cufft.h> #include <fstream> int main(){ // Initializing variables int n = 1024; cufftHandle plan1d; double2 *h_a, *d_a, *h_b; std::ofstream time_out("time_out.dat"), freq_out("freq_out.dat"); // Allocations / definition h_a = (double2 *)malloc(sizeof(double2)*n); h_b = (dou...
2,449
#include <cuda_runtime.h> #include <stdio.h> __global__ void checkIndex(void) { printf("threadIdx: (%d, %d, %d) \n" "blockIdx: (%d, %d, %d) \n" "blockDim: (%d, %d, %d) \n" "gridDim: (%d, %d, %d) \n", threadIdx.x, threadIdx.y, threadIdx.z, blockIdx.x, blockIdx.y, bl...
2,450
#include "includes.h" __global__ void reduceSmemUnroll(int *g_idata, int *g_odata, unsigned int n) { // static shared memory __shared__ int smem[DIM]; // set thread ID unsigned int tid = threadIdx.x; // global index, 4 blocks of input data processed at a time unsigned int idx = blockIdx.x * blockDim.x * 4 + threadIdx...
2,451
#include "includes.h" __global__ void update_presynaptic_activities_C_kernel (float* d_recent_presynaptic_activities_C, float* d_time_of_last_spike_to_reach_synapse, float timestep, float current_time_in_seconds, float synaptic_neurotransmitter_concentration_alpha_C, float decay_term_tau_C, int* d_plastic_synapse_indic...
2,452
//#include "particle.cuh" // // //// constants //const unsigned int g_window_width = 512; //const unsigned int g_window_height = 512; // //const unsigned int g_mesh_width = 256; //const unsigned int g_mesh_height = 256; // //int vectorCount; //GLuint vbo; //struct cudaGraphicsResource *vbo_cuda; // ////method declarati...
2,453
#include <cstdlib> #include <cassert> #include <iostream> // __global__ indicates it will called from the host and run on the device // __device__ is for device/device and __host__ for host/host __global__ void vectorAdd (float*a, float* b, float* c, int N) { // get the global thread ID int TID = blockIdx.x * ...
2,454
#include <stdio.h> #include <time.h> #define PerThread 1024*4*8//每个线程计算多少个i #define N 64*256*1024*4//积分计算PI总共划分为这么多项相加 #define BlockNum 32 //block的数量 #define ThreadNum 64 //每个block中threads的数量 __global__ void Gpu_calPI(double* Gpu_list) { __shared__ double cache[ThreadNum];//每个block共享一个shared memory. int cache...
2,455
#include "includes.h" __global__ void normalization(int *glcm,float *norm,int Max,int sum){ int ix = threadIdx.x + blockIdx.x * blockDim.x; int iy = threadIdx.y + blockIdx.y * blockDim.y; unsigned int idx = iy * Max + ix; __syncthreads(); if(idx<(Max+1)*(Max+1)){ norm[idx]=float(glcm[idx])/float(sum); } }
2,456
#include <stdio.h> int main(int argc, char const *argv[]) { int dev_count; cudaGetDeviceCount(&dev_count); printf("There are %d cuda Devices\n", dev_count); cudaDeviceProp dev_prop; for (int i = 0; i < dev_count; i++) { cudaGetDeviceProperties(&dev_prop, ...
2,457
#include <iostream> #include "cuda.h" #include "cuda_runtime.h" #include "cuda_runtime_api.h" #include "device_launch_parameters.h" namespace kernel { __global__ void measure_global_bandwidth_kb(int *out, int *device, int size) { int r=0; for(int i=0; i<size; ++i) { r+=device[i]; } *out=r; } } auto measur...
2,458
#include <stdio.h> #include <cuda.h> #define N 1024 #define BLOCK_SIZE 32 __global__ void mm(double *a, double *b, double *c) { /* ----- YOUR CODE HERE ----- */ /* -------------------------- */ } int main () { double *a, *b, *c; double *d_a, *d_b, *d_c; double size = sizeof(double) * N*N...
2,459
// // 【normalize_vector】 // // 概要: ベクトルの正規化関数サンプル // 参考: // CUDA for Engineers: An Introduction to High-Performance Parallel Computing // #include <thrust/device_vector.h> #include <thrust/inner_product.h> #include <thrust/transform.h> #include <thrust/functional.h> #include <cmath> #include <iostream> u...
2,460
#include <iostream> #include <math.h> // Kernel function to generate random numbers __global__ void genran(int *rnd,double m) { double n,a=1103515245, c=12345; n=blockIdx.x*blockDim.x+threadIdx.x; //n=threadIdx.x; for(int i=0;i<threadIdx.x;i++) n=fmod(((n*a)+c),m); __syncthreads(); atomicAdd(&rnd[(u...
2,461
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> typedef unsigned long long ul; typedef unsigned int uint; int banyakdata = 256; int dimensigrid = 2; int dimensiblok = 128; typedef struct { char size; uint* value; }big; ty...
2,462
/* CUDA FFT Library */ /* written by Viktor K. Decyk, UCLA */ #include <stdlib.h> #include <stdio.h> #include "cuda.h" #include <cufft.h> extern int nblock_size; extern int maxgsx; static cudaError_t crc; static cufftResult cfrc; static cufftHandle planrx, planxr, planrxn, planxrn; static cufftHandle plany, planyn; ...
2,463
#include <cuda_runtime.h> #include <stdio.h> __device__ float devData; __global__ void checkGlobalVariable() { // display the original value printf("Device: the value of the global variable is %f\n",devData); // alter the value devData +=2.0f; } int main(void) { // initialize the global variable ...
2,464
#include "includes.h" __global__ void update_synaptic_efficacies_or_weights_kernel (float * d_recent_presynaptic_activities_C, float * d_recent_postsynaptic_activities_D, int* d_postsynaptic_neuron_indices, float* d_synaptic_efficacies_or_weights, float current_time_in_seconds, float * d_time_of_last_spike_to_reach_syn...
2,465
//Pia Wetzel /* Program uses the KNN (with K = 3) classification algorithm to classify the Iris species Setosa, Virginica, and Versicolor. Goal is it to identify an Iris species based on the four parameters Sepal-width, Sepal-length, Petal-width, and Petal-length. */ #include <stdio.h> #include <cuda.h> #includ...
2,466
// Tests that ptxas and fatbinary are correctly during CUDA compilation. // // REQUIRES: clang-driver // REQUIRES: x86-registered-target // REQUIRES: nvptx-registered-target // Regular compiles with -O{0,1,2,3,4,fast}. -O4 and -Ofast map to ptxas O3. // RUN: %clang -### -target x86_64-linux-gnu -O0 -c %s 2>&1 \ // RU...
2,467
#include <stdio.h> #include <stdlib.h> // cuda runtime #include <cuda_runtime.h> __global__ void kernel(int *a) { int idx = blockIdx.x * blockDim.x + threadIdx.x; a[idx] = idx; //var2: a[idx] = blockIdx.x; //var3: a[idx] = threadIdx.x; } int main() { int dimx = 16; int num_bytes= dimx*sizeof(int); int *d_a=0...
2,468
#include <iostream> #include <iomanip> using namespace std; void Error(cudaError_t error) { if (error != cudaSuccess){ cout << "ERROR:" << cudaGetErrorString(error) << endl; exit(0); } } __global__ void sqr_items_vectors(double* a, double* result, int n) { int tid = blockIdx.x * blockDi...
2,469
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> #include <math.h> #define ERR_CHK(call) { gpuAssert((call), __FILE__, __LINE__); } inline void gpuAssert(cudaError_t err, const char* file, int line, bool abort = true) { if (err != cudaSuccess) { fp...
2,470
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> int main(int argc, char **argv) { // memory size 128 MBs int isize = 1<<25; int nbytes = isize * sizeof(float); // allocate the host memory //float *h_a = (float *)malloc(nbytes); float *h_a; cu...
2,471
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <cuda_runtime.h> // prints error if detected and exits void inline check(cudaError_t err, const char* filename, int line) { if (err != cudaSuccess) { printf("%s-l%i: %s\n", filename, line, cudaGetErrorString(err)); exit(EXIT_FAILURE); } } ...
2,472
#include "includes.h" __global__ void kernelInterpolationRow(double *original, double *result, int rows, int cols, int factor){ int x = threadIdx.x + blockIdx.x * blockDim.x; int y = threadIdx.y + blockIdx.y * blockDim.y; int idOriginal,idResult; // Puntos de referencia para interpolacion double a,b; double m; // ...
2,473
#include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <math.h> //----------------------------------------------------------------------------- // GpuConstantsPackage: a struct to hold many constants (including pointers // to allocated memory on the device) that can be // ...
2,474
#include <iostream> #include <cuda.h> #include <curand.h> #include <curand_kernel.h> #define N 4 int n = 20; //it defines the range of the random number using namespace std; __device__ float generate( curandState* globalState, int ind ) // ind varies from 0 to N { //int ind = threadIdx.x; curandState localSt...
2,475
#include <cuda.h> #include <cuda_runtime.h> ///all parallel implementations of this algorithim will require two functions or else delay a function significantly __global__ void sundPartOnePerRow(int bound, bool * findArray) { int idx = blockDim.x * blockIdx.x + threadIdx.x; if(idx < 1) { return; } if (idx >...
2,476
#include "includes.h" __global__ void totalSequentialSharedMem(float *input, float *output, int len) { //@@ Compute reduction for a segment of the input vector int tid = threadIdx.x, i = blockIdx.x * blockDim.x; __shared__ float sdata[BLOCK_SIZE]; sdata[tid] = i + tid < len ? input[i+tid] : 0.0; if(tid == 0) { for(uns...
2,477
#include "GPURandom.cuh" #include "GPURandomState.generated.cu" typedef unsigned int uint; // Random number generators from: http://http.developer.nvidia.com/GPUGems3/gpugems3_ch37.html // S1, S2, S3, and M are all constants, and z is part of the // private per-thread generator state. __device__ uint TausStep(uint*...
2,478
#include "CrossSectionUtilities.hh" #include <cmath> namespace MonteRay { void thinGrid(const totalXSFunct_t& xsFunc, linearGrid_t& linearGrid, double max_error) { // thin grid bool done; do { done = true; unsigned i = 0; for( auto previous_itr = linearGrid.begin(); previous_itr !...
2,479
#define NUM_THREADS 32 #define size_t int extern "C" __global__ void euclidean_kernel(const float * vg_a, size_t pitch_a, size_t n_a, const float * vg_b, size_t pitch_b, size_t n_b, size_t k, float * d, size_t pitch_d) { size_t x = blockIdx.x; size_t y = blockIdx.y; // If an element is to be computed ...
2,480
#include "includes.h" __global__ void add(int* a, int* b, int* c) { // calculate global id int id = blockIdx.x * blockDim.x + threadIdx.x; // perform calculation c[id] = a[id] + b[id]; }
2,481
#include <cuda_runtime.h> #include <stdio.h> __global__ void func(void) { printf("hello world from GPU\n"); } int main(void) { printf("hello world from CPU\n"); func <<<1, 10>>>(); cudaDeviceReset(); return 0; }
2,482
// (c) 2017 John Freeman and Jose Rivas // Sorts and array using the bitonic sorting algorithm. // For more information, go here: http://www.cse.buffalo.edu/faculty/miller/Courses/CSE633/Mullapudi-Spring-2014-CSE633.pdf #include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <time....
2,483
#include <cuda.h> #include <stdio.h> #include <stdlib.h> #define N 1000 void addMatrices(float *h_A, float *h_B, float *h_C); void fillMatrix(float *h_A); void printMatrix(float *A); int main(int argc, char const *argv[]) { float *h_A = (float *) malloc(N * N * sizeof(float)); float *h_B = (float *) malloc(N * N...
2,484
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> #define FALSE 0 #define TRUE 1 #define THREADS_PER_BLOCK 32 struct Parms { float cx; float cy; }; void printGridToFile(float *grid, const int totalRows, const int totalColumns, const char *f...
2,485
#define NX 8 #define BATCH_SIZE 1 #include "cufft.h" #include <math.h> #include <stdio.h> //#include "soundfile-2.2/libsoundfile.h" typedef float2 Complex; void testcuFFT(){ cufftReal *h_signal = (cufftReal *)malloc(sizeof(cufftReal) * BATCH_SIZE); cufftComplex *h_data = (cufftComplex *)malloc(sizeof(cufftComp...
2,486
// // Created by gautam on 18/04/20. // #include "tokenizer.cuh" const char tokenizer::delims1[] = {' ', '\t'}; const char tokenizer::delims2[] = {',', ';', '(', ')'}; const int tokenizer::DELIM1_SIZE = 2; const int tokenizer::DELIM2_SIZE = 4; tokenizer::tokenizer(std::string &s) { this->query = s; utils::to...
2,487
#include <iostream> #define DEFAULT_BLOCK_COUNT 128 #define DEFAULT_TPB_COUNT 128 using namespace std; typedef struct { int x; int y; } GridSize; typedef struct { int x; int y; int z; } BlockSize; GridSize gs = {1, 1}; BlockSize bs = {1, 1, 1}; int blockCnt = DEFAULT_BLOCK_COUNT; int t...
2,488
#include "includes.h" __global__ void cuda_rotate_internal_kernel(float* dst, const float* src, float theta, const int nx, const int ny) { // this is flawed and should not be production int src_size = nx * ny; float xoff = (0.5f * nx) - 0.5f; float yoff = (0.5f * ny) - 0.5f; int j0 = blockIdx.x * blockD...
2,489
#include <stdlib.h> #include <stdio.h> #include <ctype.h> #include <cuda.h> #include <math.h> #define ALPHABET_SIZE 26 #define CHUNK_SIZE 64 #define MAX_THREADS 64 #define ASCII_CONST 97 #define DEBUG 0 __global__ void compute_hist(char *dev_text, unsigned int *dev_hist, unsigned int chunk_size, unsigned int max) { ...
2,490
// Copyright (c) 2020 Saurabh Yadav // // This software is released under the MIT License. // https://opensource.org/licenses/MIT /* This example to analyse practically the performance benefits of using tiled algorithms that use shared memory of the gpu */ #include <stdio.h> #include <unistd.h> #include <stdlib.h> #i...
2,491
#include <iostream> 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); exit(EXIT_FAILURE); } } #define HANDLE_ERROR( err ) (HandleError( err, __FILE__, __LINE__ )) int main(void) { cudaDevic...
2,492
// scan sample #include <thrust/scan.h> #include <iostream> void print_array(int* data, int len){ for(int i=0; i<len; i++){ std::cout << data[i]; } std::cout << std::endl; } int main(void){ const int len = 6; int data[len] = {1,0,2,2,1,3}; int inout[len]; thrust::inclusive_scan(data, data+len, ino...
2,493
// // (C) 2021, E. Wes Bethel // sobel_gpu.cpp // usage: // sobel_gpu [no args, all is hard coded] // #include <iostream> #include <vector> #include <chrono> #include <unistd.h> #include <string.h> #include <math.h> // see https://en.wikipedia.org/wiki/Sobel_operator // easy-to-find and change variables for th...
2,494
// Babak Poursartip // 10/01/2020 // profile/profiling with nvprof /* nvprof modes: 1- summary mode 2- GPU and API trace mode 3- event metrics summary mode 4- event, metrics trace mode - To run nvprof, first create the executable (nvcc file.cu -o file.out). Then, profile using: nvprof ./file.out (This would be the ...
2,495
#include "pre_and_post_processor.cuh" #define MAX_THREADS 1024 #include <iostream> /****************************************************************************** * gpu_reorient: re-orientation and/or re-ordering of the axes * * Arguments: * data: input data * data_o: output data * cord0: current...
2,496
#include <cuda.h> #include <stdio.h> #include <stdlib.h> #define DataSize 1024 __global__ void Add(unsigned int *Da,int high,int width,int half) { int tx = threadIdx.x; int bx = blockIdx.x; int bn = blockDim.x; //int gn = gridDim.x; int id = bx*bn+tx; //for(int i=id;i<(high*width);i+=(bn*gn)) ...
2,497
/* * Ejercicio 2 Práctica 3: CUDA * Desempeño en función de la homogeneidad para acceder a memoria * y de la regularidad del código */ #include <stdio.h> //PP#include <cuda.h> #define STRIDE 8 #define OFFSET 1 #define GROUP_SIZE 8 /* Utilidad para checar errores de CUDA */ void checkCUDAError(co...
2,498
#include <stdio.h> __global__ void helloFromGPU(void) { printf("Hello from GPU.\n"); } int main() { printf("Hello from CPU.\n"); helloFromGPU<<<2, 5>>>(); cudaDeviceReset(); return 0; }
2,499
/* * Example from Udacity Intro to Parallel Programming https://www.udacity.com/course/intro-to-parallel-programming--cs344 * nvcc -ccbin clang-3.8 cube.cu */ #include <stdio.h> __global__ void cube(float * d_out, float * d_in){ int idx = threadIdx.x; float f = d_in[idx]; d_out[idx] = f * f * f; } int main(int arg...
2,500
#include<stdio.h> bool check_gpu(void) { int count; cudaGetDeviceCount(&count); printf("device:%d\n", count); if(count < 1) { return false; } else { return true; } }