serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
18,401
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <assert.h> #include <unistd.h> #include <sys/time.h> #include <cuda_runtime.h> #define FLOAT_N 3214212.01 void init_arrays(double* data, int M, int N) { int i, j; for (i = 1; i < (M+1); i++) { for (j = 1; j < (N+1); j++) { data[i*(N+1) + j] = (...
18,402
#include "includes.h" __device__ float softplus_kernel(float x, float threshold = 20) { if (x > threshold) return x; // too large else if (x < -threshold) return expf(x); // too small return logf(expf(x) + 1); } __device__ float tanh_activate_kernel(float x){return (2/(1 + expf(-2*x)) - 1);} __global_...
18,403
#define N 1 #define FLOAT_T float __device__ FLOAT_T work_0(FLOAT_T *data, FLOAT_T *rst, int idx) { FLOAT_T value = 0.0; FLOAT_T v1 = 1, v2 = 1; v1 = data[idx]; for (int i=0; i<N; ++i) { v1 += v2; v2 += v1; v1 += v2; v2 += v1; v1 += v2; v2 += v1; } value = v2; return value; } __device__ FLOAT_T wor...
18,404
#include <stdlib.h> #include <stdio.h> // a kernel that prints the contents of an array __global__ void print_array(int n, int *array) { int thread_id = blockIdx.x * blockDim.x + threadIdx.x; if (thread_id < n) printf("array[%d] = %d\n", thread_id, array[thread_id]); } int main(int argc, char const **...
18,405
#include <stdio.h> /* DATA_SIZE = BLOCK_SIZE * GRID_SIZE Ŋ؂邱(vOł̓m[`FbN) */ #define DATA_SIZE 16 #define BLOCK_SIZE 8 #define GRID_SIZE (DATA_SIZE/BLOCK_SIZE) __global__ void helloFromGPU() { int id = blockDim.x * blockIdx.x + threadIdx.x; printf("I am blockDim.x=%3d, blockIdx.x=%3d, threadIdx.x=%3d. My target is %...
18,406
#include <iostream> #include <math.h> #include <vector> #include <iomanip> #include <sstream> #include <string> #include <fstream> #include <thread> #include <ctime> #include <stdio.h> #define BLOCK_SIZE (128) #define WORK_SIZE_BITS 16 #define SEEDS_PER_CALL ((1ULL << (WORK_SIZE_BITS)) * (BLOCK_SIZE)) #define GPU_ASS...
18,407
/* Matrix addition with a too large block dimension. */ #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <stdint.h> // Grid size #define B 1 // Block size #define T 5120 // Matrix dimension #define C B*T // Macro for checking errors in CUDA API calls #define cudaErrorCheck(call) ...
18,408
#include "includes.h" // // Created by Sowmya Parameshwara on 11/10/16. // /** * * 1) Input is stored by transposing the matrix, so that the attributes of a column are stored in a single row. This * will optimise the algorithm since all threads in a block will access nearby elements, while normalising. * 2) Eac...
18,409
__global__ void sigmoidf(float* X, int size) { const unsigned int x = blockIdx.x * blockDim.x + threadIdx.x; if(x >= size) return; X[x] = 1 / (1 + expf(-X[x])); } __global__ void sigmoid(double* X, int size) { const unsigned int x = blockIdx.x * blockDim.x + threadIdx.x; if(x >= size) return; ...
18,410
__global__ void dual(float* p1, float* p2, const float* u_, const double lambda, const double sigma, const int X, const int Y) { int x = blockIdx.x*blockDim.x + threadIdx.x; int y = blockIdx.y*blockDim.y + threadIdx.y; // center point int c = y*X + x; f...
18,411
#include<iostream> #include<cuda.h> /* Using CUDA warp level primitives all threads in a warp are executed in SIMT fashioni compute bound workloads criteria ------------ performance numerical accuracy and thread-safety 3 topics ------------ floating point operations intrinsic and standar...
18,412
#include <CL/cl.h> #include <iostream> const char * source = "__kernel void thread_printf() {" " int group_id = get_group_id(0); \n" " int local_id = get_local_id(0); \n" " int global_id = get_global_id(0); \n" " printf(\"I am from %d block, %d thread (global thread: %d)\\n\", \n" " group_id, \n" " local_id, \n" " glo...
18,413
/* * 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 documen...
18,414
#include<stdio.h> #include<stdlib.h> #include<cuda.h> #include<sys/time.h> #define SIZE atoi(argv[1]) void safe_call(cudaError_t ret, int line) { if(ret!=cudaSuccess) { printf("Error at line %d : %s\n",line,cudaGetErrorString(ret)); exit(-1); } } void fill_mat(double *arr, int len) { int i; for(i=0;i<len;i+...
18,415
#include <cuda_runtime.h> #include <iostream> #include <stdio.h> #include <device_launch_parameters.h> __global__ void kernelTest() { __shared__ int shrd[50]; //shrd = cudaMalloc((void **) &shrd, 50*sizeof(int)); //int blockX, blockY, blockZ; //int threadX, threadY, threadZ; shrd[0] = blockIdx...
18,416
#include <stdio.h> #include <stdlib.h> #include <cuda_runtime.h> //初始化CUDA int count=0; bool InitCUDA() { printf("Start to detecte devices.........\n");//显示检测到的设备数 cudaGetDeviceCount(&count);//检测计算能力大于等于1.0 的设备数 if(count == 0) { fprintf(stderr, "There is no device.\n"); return false;...
18,417
#include <cuda_runtime.h> #include <stdio.h> __global__ void gpukernel() { printf("%d %d %d %d\n", blockIdx.x, threadIdx.x, blockDim.x, gridDim.x); } int main(int argc, char** argv) { // launch a gpu kernel with 3 blocks and 4 threads in each block. gpukernel<<<3,4>>>(); // block the cpu for the gpu ...
18,418
#include <iostream> #include <stdlib.h> #define WIDTH 448 #define N WIDTH*WIDTH #define totalhilos 64 #define TILE_WIDTH totalhilos using namespace std; __global__ void MatrixMulKernel(float* A, float* B, float* P) { int Row = blockIdx.y*blockDim.y +threadIdx.y; int Col = blockIdx.x*blockDim.x +thread...
18,419
#include <iostream> __global__ void inc_kernel(int32_t *in, int32_t width, int32_t height, int32_t v, int32_t *out) { int gx = threadIdx.x + blockDim.x * blockIdx.x; int gy = threadIdx.y + blockDim.y * blockIdx.y; if (gx < width && gy < height) { out[gy * width + gx] = in[gy * width + gx] + v; ...
18,420
#include <stdio.h> #include <stdlib.h> #include <iostream> #include <cuda.h> #include <sys/time.h> #include <chrono> #define BLOCK_COUNT 256u #define HALF_BLOCK_COUNT 128u #define BANKS 16 #define LOG_2_BANKS 4 // macro used for computing // Bank-Conflict-Free Shared Memory Array Indices #define AVOID_BANK_CONFLICTS(...
18,421
#include "includes.h" __global__ void calcPReLUKernel(const float *input, float *output, const float *weights, int width, int height, int channels) { int x = threadIdx.x + blockIdx.x * blockDim.x; int y = threadIdx.y + blockIdx.y * blockDim.y; if (x >= width || y >= height) { return; } output[y * width + x] = input[y ...
18,422
#include <cmath> __global__ void conditional(double* __restrict__ out, double const* __restrict__ in, double const* __restrict__ sgn) { int i = threadIdx.x; bool is_positive = sgn[i] > 0; out[i] = in[i] * (2 * is_positive - 1); }
18,423
#include <string.h> #include <stdio.h> #include <stdlib.h> #include <cuda_runtime.h> #include <math.h> #define THREAD_COUNT 1024 __global__ void init(float *input, float *map, int w, int h) { unsigned int index = threadIdx.x + blockIdx.x * blockDim.x; if (index < w * h) { int x = index % w; int y ...
18,424
#include <cuda_runtime_api.h> #include <iostream> __global__ void copyKernel(int *src, int *dst, int size) { const int idx = blockIdx.x * blockDim.x + threadIdx.x; if(idx > size) return; dst[idx] = src[idx]; } int main() { int *a_dev; int *b_dev; int *a = new int[1000]; int *b = ne...
18,425
#include <iostream> #include <time.h> #include <string> #include <vector> #include <sstream> #include <cuda_runtime.h> #include <math.h> #include <fstream> // Libreria para leer archivos #include <typeinfo> // for 'typeid' to work #include <tuple> using namespace std; // tuple (elem , posElem) vector<tuple<int , int...
18,426
static const unsigned char Permutations[ 512 ] = { 151,160,137,91,90,15, 131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23, 190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33, 88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166, ...
18,427
////////////////////////////////////////////////////////////////////////// ////This is the code implementation for GPU Premier League Round 1 ////////////////////////////////////////////////////////////////////////// #include <iostream> #include <fstream> #include <vector> #include <chrono> #include <cuda_runtime.h> u...
18,428
__global__ void compute_weight( double * pi, double* b, double c ) { *pi += c; }
18,429
#include <assert.h> #include <cuda.h> #include <stdio.h> #include <stdlib.h> #include <stddef.h> int N = 1024; int THREADS_PER_BLOCK = 512; // Running one thread in each block __global__ void add_blocks(int *a, int *b, int *c) { // blockIdx.x gives each block ID c[blockIdx.x] = a[blockIdx.x] + b[blockIdx...
18,430
extern "C" __global__ void test_fn_ptx (int *a, int *b) { *a = 11; *b = 21; }
18,431
#include "includes.h" __global__ void scan(float* in, float* out, float* post, int len) { __shared__ float scan_array[HALF_BLOCK_SIZE]; unsigned int t = threadIdx.x; unsigned int start = 2 * blockIdx.x * BLOCK_SIZE; int index; if (start + t < len) scan_array[t] = in[start + t]; else scan_array[t] = 0; if (start + BLO...
18,432
/* Two Dimensional (2D) Image Convolution in CUDA by Shared & Constant Memory: An Optimized way After learning the concept of two dimension (2D) Convolution and its implementation in C language; the next step is to learn to optimize it. As Convolution is one of the most Compute Intensive task in Image Processing, it i...
18,433
#include <cuda.h> #include <iostream> using namespace std; int main() { int * input; int * output; int * input_d; int * output_d; input = (int*)malloc(2*sizeof(int)); output = (int*)malloc(2*sizeof(int)); input[0] = 10; input[1] = 20; output[0] = 0; output[1] = 0; cout << "Before the copy ker...
18,434
// Maeva Lecavelier - 50191580 // I choose exercice (b), integral approximation #include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <thrust/sequence.h> #include <thrust/transform.h> #include <stdio.h> #include <time.h> #include <iostream> #define NUM_STEPS 200000 #define STEP 1/NUM_STEPS st...
18,435
#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(...
18,436
#include "includes.h" __global__ void rgb2hsl_gpu_son( unsigned char * d_r, unsigned char * d_g, unsigned char * d_b, float * d_h , float * d_s , unsigned char * d_l , int size) { int x = threadIdx.x + blockDim.x*blockIdx.x; if (x >= size) return; float H,S,L; float var_r = ( (float)d_r[x]/255 );//Convert RGB to [0,...
18,437
#include "externalClass.cuh" void externalClass::squareOnDevice(double *a_h, const int N) { double *a_d = new double[N]; // initialize a_d as an array with N double pointer size_t size = N * sizeof(double); cudaMalloc((void **) &a_d, size); cudaMemcpy(a_d, a_h, size, cudaMemcpyHostToDevice); int block_size = 4; ...
18,438
#include <cuda.h> #include <stdio.h> #include <math.h> #define blockSize 512 #define real float __global__ void redukcja (int N, real* v) { size_t s = threadIdx.x + blockIdx.x * blockDim.x; size_t i; real p = 0; if (s==0){ // *out = 0; for (i=0; i<N; i++) p += v[i]; v[0] = p; } } __global__ void wype...
18,439
#include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include <float.h> #include <math.h> struct timeval startwtime, endwtime; double seq_time; // CPU variable int N = 5000; // number of elements int D = 2; // dimensions int nT = 500; // number of threads per block float sigma = 250.0; float MS_error = 0.0001;...
18,440
#include <stdio.h> #include <sys/mman.h> #include <cuda.h> #define len 21 __global__ void decrypt(unsigned char *code){ int indx = threadIdx.x; code[indx] ^= 12; } extern "C" void _shell(); int main(void){ unsigned char *p = (unsigned char*)_shell; unsigned char *d_shell,*h_shell; h_shell = (unsigne...
18,441
#include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #include <stdio.h> #include <time.h> #include <math.h> #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) #define cuda_check(ret) _cuda_check((ret), __FILE__, __LINE__) inline void _cuda_check(cudaError_t ret, const char *file, int line) {...
18,442
// Include All Libraries #include<bits/stdc++.h> using namespace std; __global__ void add(int n, int *x, int *y,int *val,int *database,int N) { unsigned long long int id = (blockIdx.x*blockDim.y+threadIdx.y)*blockDim.x + threadIdx.x; if(id<n){ atomicAdd(&database[N*x[id]+y[id]-1],val[id]); } } struct ins_...
18,443
#include "includes.h" __global__ void depthwise_input_backward(int B, int N, int M, int F, int C, int r, int K, const int* nnIndex, const int* nnCount, const int* binIndex, const float* input, const float* filter, const float* gradOutput, float* gradInput) { for(int i=blockIdx.x;i<B;i+=gridDim.x) { for(int j=blockIdx.y...
18,444
#include "includes.h" __global__ void EFD( int size, float *d_val_n, float *d_val_npo, float Pu, float Pm, float Pd, float x0, float x ) { int i = threadIdx.x + blockDim.x * blockIdx.x; if (i < size) { d_val_npo[i] = Pu * d_val_n[i + 1] + Pm * d_val_n[i] + Pd * d_val_n[i - 1]; if (i == 0) { d_val_npo[i] = d_val_npo[1]...
18,445
#include <stdio.h> #include <assert.h> #define N 64 inline cudaError_t checkCuda(cudaError_t result) { if (result != cudaSuccess) { fprintf(stderr, "CUDA Runtime Error: %s\n", cudaGetErrorString(result)); assert(result == cudaSuccess); } return result; } __global__ void matrixMulGPU(int *...
18,446
#include <stdio.h> #include <stdlib.h> #include <iostream> #include <fstream> #include <string> #include <vector> #include <sstream> #include <time.h> #include <sys/time.h> using namespace std; double iStart1, iStart2, iStart3a, iStart3b, iStart4a, iStart4b, iStart4c, iStart5; double iElaps1=0, iElaps2=0, iElaps3a=0, ...
18,447
#include <iostream> #include <cassert> typedef void (* execute_task_t)(void *); class CubeTask { double* xi; execute_task_t* cube_on_device; public: __host__ __device__ CubeTask(); __host__ __device__ CubeTask(execute_task_t* cube_fp, double* x) : cube_on_device(cube_fp), xi(x) {} __device__ void execute() ...
18,448
#include "includes.h" extern "C" { #ifndef REAL #define REAL float #endif #ifndef CAST #define CAST(fun) fun ## f #endif #ifndef REAL2o3 #define REAL2o3 (REAL)0.6666666666666667 #endif #ifndef REAL3o2 #define REAL3o2 (REAL)1.5 #endif ...
18,449
#include <stdint.h> #include <stdio.h> #define N 32 #define THREADS_PER_BLOCK 32 __global__ void reverse(float* x) { // Which index of the array should this thread use? size_t index = threadIdx.x + blockIdx.x * THREADS_PER_BLOCK; if (index < (N / 2)) { float temp = x[N-1 - index]; x[N-1 - ...
18,450
// typedef struct { // unsigned long long int lo; // unsigned long long int hi; // } my_uint128; // my_uint128 add_uint128 (my_uint128 a, my_uint128 b) // { // my_uint128 res; // res.lo = a.lo + b.lo; // res.hi = a.hi + b.hi + (res.lo < a.lo); // return res; // } // https://github.com/...
18,451
#include <math.h> #include <stdio.h> __host__ void mat_swap(double **A, double **B) { double *temp = *A; *A = *B; *B = temp; } __global__ void jacobian(double *OLD, double *NEW, double *f, int size, int max_it, \ double h) { /* initializing iteration variables */ // 1 is added to row and co...
18,452
extern "C" { __global__ void gscale_32(const int lengthB, const float *a, float *b) { int i = threadIdx.x + blockIdx.x * blockDim.x; if (i<lengthB) { b[i] = a[0]*b[i]; // REMEMBER ZERO INDEXING IN C LANGUAGE!! } } }
18,453
/** * 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...
18,454
#include <stdio.h> __global__ void kernel(int *A, int x) { A[x + x] = 42; } int main(int argc, char const *argv[]) { kernel<<<1,2>>>(0, 42); cudaDeviceSynchronize(); return 0; }
18,455
// nvcc SeayJohnnyHW1.cu -o SeayJohnnyHW1; ./'SeayJohnnyHW1' #include <sys/time.h> #include <stdio.h> #define N 67043328 __global__ void addition(float *A, float *B, float *C, int n, int maxThreads) { int id = threadIdx.x + blockIdx.x*maxThreads; if(id < n) { C[id] = A[id] + B[id]; } } int mai...
18,456
extern "C" { typedef struct { int e0; char* e1; } struct_Buffer_4844; typedef struct { struct_Buffer_4844 e0; struct_Buffer_4844 e1; int e2; int e3; } struct_image_4847; __device__ inline int threadIdx_x() { return threadIdx.x; } __device__ inline int threadIdx_y() { return threadIdx.y; } __dev...
18,457
// Babak Poursartip // 09/15/2020 // udemy CUDA // sum array #include "common.h" #include <cstdio> #include <time.h> // ================================= __global__ void sum_array_gpu(int *a, int *b, int *c, const int size) { // 1d grid, 1d block thread int gid = blockIdx.x * blockDim.x + threadIdx.x; if (gid...
18,458
#include <stdio.h> #include <math.h> #include <cuda.h> #include <iostream> #include <cuda_runtime.h> #include <cuda_profiler_api.h> __global__ void gpuMatSub(float* A, float* B, float* C, int Nrows, int Ncols) { int tid, tx, ty; tx = threadIdx.x + blockIdx.x * blockDim.x; ty = threadIdx.y + blockIdx.y * blockDim...
18,459
// fermi /* * Copyright 2018 Vrije Universiteit Amsterdam, The Netherlands * * 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 * Unles...
18,460
#include "cstdio" #include <iostream> #include <chrono> constexpr size_t SIZE = 16384 * 3; // 16384 * 3 constexpr size_t BLOCK_COUNT = 4096; //for shared alg 16384 * 3 for simple constexpr size_t BLOCK_SIZE = SIZE / BLOCK_COUNT; constexpr size_t THREAD_PER_BLOCK = 128; /* * GPU Elapsed time 23.9948 * CPU Elapsed t...
18,461
#include "includes.h" __global__ void dwt_per_X_O(float *d_ip, int rows, int cols, int cA_cols, int filt_len, int Halo_steps, float *d_cL, float *d_cH) { extern __shared__ float s_Data[]; //Offset to the left halo edge const int baseX = (blockIdx.x * 2 * X_RESULT_STEPS - Halo_steps) * X_BLOCKDIM_X + threadIdx.x; const...
18,462
#include <stdio.h> #include <ctype.h> // isalnum() #include <string.h> // stricmp() #include <stdlib.h> // exit() #include <sys/time.h> #define N 26 #define BLOCK 32 #define LINE_SIZE 1024 __global__ void countAlphaOnGPU (char *idata, int *sum, int size) { int idx = blockIdx.x * blockDim.x + threadIdx.x; // print...
18,463
#include "includes.h" __global__ void init_segmented_rpt(int *d_nnz_num, int *d_seg_rpt, int total_pad_row_num) { int i = blockIdx.x * blockDim.x + threadIdx.x; if (i > total_pad_row_num) { return; } if (i == 0) { d_seg_rpt[i] = 0; } else { d_seg_rpt[i] = d_nnz_num[i - 1]; } }
18,464
#include "includes.h" __global__ void kernelUpdateWeights(float *nabla_w,float *weights,int tws,float eta,float mini_batch_size) { float rate=eta/mini_batch_size; if ((blockIdx.x*blockDim.x+threadIdx.x)<tws) { weights[blockIdx.x*blockDim.x+threadIdx.x]-=rate*nabla_w[blockIdx.x*blockDim.x+threadIdx.x]; } }
18,465
#include "cuda.h" #include "cuda_runtime.h" #include "device_launch_parameters.h" //#include "cuda_common.cuh" #include <stdio.h> #include <stdlib.h> #include <time.h> __global__ void code_wo_divergence() { int gid = blockIdx.x * blockDim.x + threadIdx.x; float a, b; a=b=0; int warp_id = gid/32; if...
18,466
#include <iostream> #include <stdlib.h> #include <stdio.h> #include <cuda.h> #include <math.h> #include <cuda_profiler_api.h> #define TRIALS 20 __global__ void kernel(int integer) { //Doesn't do anything } //Makes random array of floats void initializeArray(float* arr, int nElements) { srand(time(NULL)); f...
18,467
#include <stdio.h> #include <stdlib.h> #include <stdio.h> #include <math.h> #include <time.h> // Definitions #define NUM_PARTICLES 10000 #define GM (1.0/NUM_PARTICLES) #define PI 3.14159265 #define BLOCK_SIZE 256 // Structs typedef struct { double x, y, z; } vector3; typedef struct { vector3 *p, *v; } particles_t; /...
18,468
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #define N 100 #define num_threads 10 __global__ void addVect(int *a, int *b, int *c) { int i = blockIdx.x * blockDim.x + threadIdx.x; c[i] = a[i] + b[i]; } void add(int *a, int *b, int *c) { int *dev_a; int *dev_b; int *dev_c; ...
18,469
#include <cuda.h> #include <cuda_runtime.h> #include <cuda_runtime_api.h> #include <device_launch_parameters.h> #include <iostream> #include <memory> #include "floyd_warshall.cuh" __global__ void floyd_warshall_buffer(int* in_mat, int* in_mat_t, const int* in_x, const int* in_y) { const int dx = threadIdx.x; const ...
18,470
#include "includes.h" __global__ void generateData(int dimension, int rseed, double* rotation, int number_of_peaks, double* peak_values, double* x_local, double* arr_scales) { }
18,471
#include "includes.h" __global__ void kernel_sub(char* newB, char* first, char* second, int size_biggest, int diff, int * size_newB) { int tmp = 0; int i = threadIdx.x; #if __CUDA_ARCH__>=200 //printf("#threadIdx.x = %d\n", threadIdx.x); #endif if (i == 0) return; //for (int i = size_biggest - 1; i >= 0; i--) { if (i ...
18,472
#include "includes.h" __global__ void rotate_180( float* data,int nx, int nxy, int offset, unsigned int size) { const uint x=threadIdx.x; const uint y=blockIdx.x; __shared__ float shared_lower_data[MAX_THREADS]; __shared__ float shared_upper_data[MAX_THREADS]; shared_lower_data[x] = data[x+y*MAX_THREADS+offset]; sha...
18,473
#include <cuda.h> #include <iostream> #include <stdio.h> #include <time.h> using namespace std; #define MRows 5 #define MCols 5 #define NRows 5 #define NCols 6 #define PRows 5 #define PCols 6 #define H 10 #define W 10 #define TILE_WIDTH 2 __global__ void MultTiled(float *M, float *N, float *P) { __shared__ int ds_...
18,474
#include <cuda_runtime.h> #include <exception> #include <iostream> #include <map> #include <sstream> #include <string> #define CE(err) \ { \ if (err != cudaSuccess) ...
18,475
/** * 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...
18,476
/****************************************************************************** *cr *cr (C) Copyright 2010 The Board of Trustees of the *cr University of Illinois *cr All Rights Reserved *cr *****************************************************************...
18,477
#include <thrust/sort.h> int sort_data(int *keys, int *values, int N) { int i; for(i=0;i<N;i++) { printf("Before sort Key=%d addr=%x\n",keys[i],values[i]); } thrust::sort_by_key(keys, keys + N, values ); for(i=0;i<N;i++) { printf("After sort Key=%d addr=%x\n",keys[i],values[i]); } return 0; }...
18,478
__global__ void inout(short int * out, short int * in, short Res) { const int i = threadIdx.x; out[i] = in[i] * Res/1000000; }
18,479
/*--------------------------------------------------------------------*/ /* CUDA Library for GPU Tutorial */ /* written by Viktor K. Decyk, UCLA */ #include <stdlib.h> #include <stdio.h> #include "cuda.h" int nblock_size = 64; int ngrid_size = 1; int maxgsx = 65535; int mmcc = 0; static int devid; static cudaError_t...
18,480
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <curand.h> #include <random> #include <iostream> #include <math.h> #include <stdio.h> #define ARRAY_SIZE 10000 #define TPB 256 #define BLOCKS (ARRAY_SIZE + TPB - 1)/TPB __global__ void saxpy(float a, float *x, float *y) { int index = bloc...
18,481
#include <stdio.h> #include <stdlib.h> #include <cuda_runtime.h> #include <device_launch_parameters.h> #include <math.h> #include <string.h> #include <sys/time.h> // Radix sort kernel __global__ void radix_sort_kernel(const int* d_number_array, int* d_digit_array, int n, int divisor, int lock){ __shared__ int sha...
18,482
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #define N 100 __global__ void CUDAStrCopy(char *str, int *len) { int i = blockIdx.x; char temp = str[i]; str[i] = str[*len - i - 1]; str[*len - i - 1] = temp; } int main() { char str[N]; p...
18,483
#include "includes.h" #define COUNTERS 66 #define C_SIZE 64 #define C_STOP 65 // == C_SIZE+1 #define N 4224 // == COUNTERS*C_SIZE #define N2 17842176 // == N*N #define CUDA_ERROR_CHECK #define cudaSafeCall(error) __cudaSafeCall(error, __FILE__, __LINE__) #define cudaCheckErrors() __cudaCheckErrors(__FILE__, __LINE__...
18,484
// Babak Poursartip // 09/15/2020 // udemy CUDA // Error: cudaError // We cannot use cudaError to check the launch part of the function. #include "common.h" #include <cstdio> #include <time.h> // ================================= // cuda error check macro #define gpuErrchk(ans) \ { gpuAssert(ans, __FILE__, __LIN...
18,485
#include "includes.h" __device__ float2 JacobiFieldInstance(float2 Top, float2 Left, float2 Bot, float2 Right, float Alpha, float2 Val) { float2 res; res.x = (Top.x + Left.x + Bot.x + Right.x + Alpha * Val.x) / (4 + Alpha); res.y = (Top.y + Left.y + Bot.y + Right.y + Alpha * Val.y) / (4 + Alpha); return res; } __global...
18,486
__global__ void calculate_sumterm_part(double2 * Up, double2 * Vpl, const double2 * A_t, const double* SR, const unsigned char* nonzero_midx1234s, const unsigned int N, const unsigned int M, const double SK_factor, const unsigned int NUM_NONZERO, const unsigned int NUM_MODES) { unsigned int full_thread_idx = thread...
18,487
#include <stdio.h> #include <stdlib.h> __global__ void kernel(int * mem, int did){ int tid = blockIdx.x * blockDim.x + threadIdx.x; int tsz = blockDim.x * gridDim.x; mem[tid] = did * tsz + tid; } int main(){ int deviceCount; int **deviceMem; int *result; int threadPerDevice =3; cudaGetDeviceCount(&dev...
18,488
/* Cuda Program for finding cos(0), cos(1*2*pi/N), ... , cos((N-1)*2*pi/N) */ // nvcc CUDA_example_01.cu -use_fast_math -o CUDA_example_01.out /* --------------------------- header secton ----------------------------*/ #include<stdio.h> #include<cuda.h> #define PRINT_RESULT 1 #define COS_THREAD_CNT 512 #define N 10...
18,489
/* #include <thrust/device_vector.h> #include <thrust/host_vector.h> #include <thrust/system/cuda/experimental/pinned_allocator.h> #include <thrust/copy.h> #include <vector> #include <assert.h> #include "ungapped_extender_gpu.h" #include "group_loader.h" #include "packed_alphabet_code.h" #include "score_matrix.h" #inc...
18,490
#include "cuda.h" // for old version titan x, the same as 1080 // pycuda._driver.device_attribute.MAX_THREADS_PER_BLOCK: 1024 // pycuda._driver.device_attribute.MAX_BLOCK_DIM_X: 1024 // pycuda._driver.device_attribute.MAX_BLOCK_DIM_Y: 1024 // pycuda._driver.device_attribute.MAX_BLOCK_DIM_Z: 64 // pycuda._driver.device...
18,491
float q[215] = {0.0158566571558474, 0.0186216305080987, 0.0212880457241973, 0.0240275926285605, 0.0267181160244818, 0.0294234230943968, 0.0321311169771716, 0.0348228896572595, 0.0375388860648457, 0.0402299379368743, 0.0429401916681916, 0.0456402983336143, 0.0483415638191157, 0.0510483334251337, 0.0537462863636128, 0.0...
18,492
#include "includes.h" #define DOUBLE #ifdef DOUBLE #define Complex cufftDoubleComplex #define Real double #define Transform CUFFT_Z2Z #define TransformExec cufftExecZ2Z #else #define Complex cufftComplex #define Real float #define Transform CUFFT_C2C #define TransformExec cufftExecC2C #endif #define TILE_DIM 8 /...
18,493
#include "cc_labelling.cuh" constexpr int connectivity = 4; __global__ void initialization_step(const int* nn_list, int* residual_list, int* labels, int height, int width) { int x = blockDim.x * blockIdx.x + threadIdx.x; int y = blockDim.y * blockIdx.y + threadIdx.y; if (x >= width || y >= height) ...
18,494
#include "globals.cuh" int width = 0; int height = 0;
18,495
#include "includes.h" __global__ void ComputeErrorPerWinningKernel( float *localError, int *winningCount, float *errorPerWinning, int *activityFlag, int maxCells ) { int threadId = blockDim.x*blockIdx.y*gridDim.x //rows preceeding current row in grid + blockDim.x*blockIdx.x //blocks preceeding current block + thre...
18,496
// GPU kernel __global__ void summation_kernel(int data_size, float * data_out) { unsigned int id = blockIdx.x * blockDim.x + threadIdx.x; if(id < data_size) data_out[id] += ((id % 2 != 0) ? -1:1) / (id + 1.0); // printf("%d>%f\n",id, data_out[id]); } __global__ void reduce(int data_size, float* data_in, float* d...
18,497
#include "stdio.h" #include<iostream> #include <cuda.h> #include <cuda_runtime.h> #define N 1024 #define threadsPerBlock 512 #define cpu_sum(x) (x*(x+1)) __global__ void gpu_dot(float *d_a, float *d_b, float *d_c){ __shared__ float partial_sum[threadsPerBlock]; int tid = threadIdx.x + blockIdx.x * blockDim.x;...
18,498
__global__ void vsort1(int *input0,int *result0){ unsigned int tid = threadIdx.x; unsigned int bid = blockIdx.x; extern __shared__ __attribute__ ((aligned (16))) unsigned char sbase[]; (( int *)sbase)[tid] = ((tid&256)==0) ? min(input0[((bid*512)+tid)],input0[((bid*512)+(tid^256))]) : max(input0[((bid*512)+tid)...
18,499
#include <iostream> #include <stdio.h> #include <math.h> #include <assert.h> #include <cuda_profiler_api.h> #include <stdio.h> #include <cuda.h> #include <time.h> #define MASK_WIDTH 3 //Kx and Ky #define MASK_RADIUS MASK_WIDTH / 2 #define TILE_WIDTH 8 #define W (TILE_WIDTH + MASK_WIDTH - 1) __global__ void Convolut...
18,500
#include "includes.h" __global__ void kernel_setAllPointsToRemove(bool *d_markers, int number_of_points) { int ind=blockIdx.x*blockDim.x+threadIdx.x; if(ind<number_of_points) { d_markers[ind] = false; } }