serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
23,901
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <cuda_runtime.h> #include <curand.h> #include <curand_kernel.h> __global__ void map1(int m, double *xs, double *weightih, double *hidden, int d, int n_hidden){ // m is the no. of samples and d is the number of features in xs(input data) ...
23,902
#include <iostream> #include <stdio.h> #include <time.h> #define LENGTH 10000 using namespace std; __global__ void vector_add(float *a, float *b, float *c){ int index = threadIdx.x + blockDim.x * blockIdx.x; // 101 c[index] = a[index] + b[index]; } __host__ void vector_add_cpu(float a[], float b[], float *c)...
23,903
// TODO: This code is currently unused. Update the implementation to work with ZNCC-based cost? // To have the residuals conform to what works well with Gauss-Newton, could use an affine brightness mapping (with optimized factor & bias parameters) // instead of the ZNCC computation, which should achieve the...
23,904
#include <cooperative_groups.h> #include <stdio.h> #include "cuda.h" #include "cuda_runtime.h" #include <iostream> #define ARRAYSIZE 10000 #define BLOCKSIZE 256 using namespace cooperative_groups; // Basic reduction code found in the presentation; going to test on a variety of // thread groups __device__ float thr...
23,905
#include <stdio.h> #include <stdlib.h> #include <iostream> #include <cuda.h> using namespace std; #define imin(a,b) (a<b?a:b) #define BAR_INIT 0 #define BAR_ENTER 1 #define BAR_WAIT 2 #define BAR_EXIT 3 #define BAR_FINISH 4 const int N = 128; const int threadsPerBlock = 128; const int blocksPerGrid = 1; /* __global__...
23,906
#include <iostream> __global__ void add(int* a, int* b, int* c, int vector_size) { for (int i = 0; i < vector_size; ++i) { c[i] = a[i] + b[i]; } } __global__ void add_wthreads(int* a, int* b, int* c, int vector_size) { for (int i = threadIdx.x; i < vector_size; i+=blockDim.x) { c[...
23,907
#include <bits/stdc++.h> #define milliseconds 1e3 using namespace std; typedef struct _Node_info{ u_short parent_index; u_int potential_flow; } Node_info; void readInput(const char* filename, u_int total_nodes, u_short* residual_capacity) { ifstream file; file.open(filename); if (!file) { cout << "Er...
23,908
#include "includes.h" __global__ void add( int a, int b, int *c ) { *c = a + b; }
23,909
#include <stdio.h> #include <stdlib.h> // defines ---------------------------------------------------------------- #define THREADS_PER_BLOCK 384 __shared__ unsigned oop; __shared__ unsigned bep; extern "C" __global__ void sift() { if (threadIdx.x == 0) { bep = 10000; } __syncthreads(); unsigned n_p...
23,910
#include <iostream> #include <ostream> #include <sstream> #include <iomanip> #include <stdio.h> #include <string> #include <vector> #include <fstream> #include <time.h> #include <curand.h> #include <curand_kernel.h> #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } inline void gpuAssert(cudaError_t code...
23,911
#include "includes.h" __global__ void add_matrices(float *ad,float *bd,float *cd,int N) { cd[threadIdx.y * N + threadIdx.x] = ad[threadIdx.y * N + threadIdx.x] + bd[threadIdx.y * N + threadIdx.x]; }
23,912
#include <iostream> #include <time.h> #include <stdexcept> #include <vector> #include <cstdlib> #define n 20 __global__ void add(int *x,int *y, int *z){ int id=blockIdx.x; z[id]=x[id]+y[id]; } int main(){ srand(time(0)); int a[n], b[n], c[n]; int *d,*e,*f; for(int i=0;i<n;i++){ ...
23,913
# include <iostream> // # include "book.h" __global__ void kernel ( void ) { } __global__ void add( int a, int b, int *c ) { *c = a + b; } int main(int argc, char const *argv[]) { // kernel<<<1, 1>>>(); // printf( "Hello, World!\n"); // int c; // int *dev_c; // int N = 1; // cudaMalloc( (void**)&dev_c, N * ...
23,914
#include <iostream> using namespace std; // Add function to add elements of two arrays __global__ void add(int n, float *x, float *y){ for (int i = 0; i < n; i++){ y[i] = x[i] + y[i]; } } int main(){ int N = 1<<20; // 1M elements float *x; float *y; // Allocate Unified Memory - Accessible from CPU or GPU ...
23,915
#include <cuda_runtime.h> #include <stdio.h> #include <time.h> #define AxCheckError(err) CheckError(err,__FUNCTION__, __LINE__) #define AxCheckErrorMsg(err, msg) CheckErrorMsg(err, msg, __FUNCTION__, __LINE__) int const N = 1024; int const N_BYTES = N*sizeof(float); void GenerateTestData(int const N, float* const a...
23,916
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <assert.h> #include "cuda_runtime.h" #include "device_launch_parameters.h" #include <cstring> #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__);} inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort = true){ if (co...
23,917
/* | * HEAT - PARALLEL FINITE DIFFERENCE SOLVER | *________________________________________________________________| * * Computes a finite difference solution for Laplace's * equation using a two dimensional periodic ini...
23,918
#include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <thrust/sort.h> #include <thrust/generate.h> #include <chrono> using namespace std::chrono; // ALSO CONTAINS EXPERIMETNS WITH SORT(THRUST stable_sort_by_key vs kernel of insertion sorts) + MANUAL REDUCE //kernel of merge sort didnt work because...
23,919
/* ELEC374 - Machine Problems Andrew McClelland Student #: 10150229 NetID: 14amm5 */ #include "cuda.h" #include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> #include <time.h> #include <iostream> #include <random> #include <ctime> using namespace std; #define BLOCK_WI...
23,920
// Placeholder - Preconditioned Bi Conjugate Stabilized Solver.
23,921
#include "includes.h" __global__ void _badd(int nrows, int ncols, float *y, float *b) { int i = threadIdx.x + blockIdx.x * blockDim.x; int n = nrows * ncols; while (i < n) { y[i] += b[i % nrows]; i += blockDim.x * gridDim.x; } }
23,922
#pragma once #include <algorithm> #include <cmath> #include "Vector3.cuh.cu" #include "Ray.cuh.cu" namespace RayTracing { class aabb { private: Point3 m_min, m_max; public: aabb() {} aabb(const Point3& a, const Point3& b) : m_min(a), m_max(b) {} Point3 min() const {return m_min; } ...
23,923
#include <stdio.h> //#define DEBUGPRINT 0 __global__ void InviscidBC_gpu_kernel1(int *lglel, double *fatface,char *cbc, double *xm1,double *ym1,double *zm1,double *vx,double *vy,double *vz,double *t,double *pr,double *sii,double *siii,double *vdiff,double *vtrans,char *cb,double *u,double *phig,double *csound,double *u...
23,924
#include "includes.h" #define NOMINMAX const unsigned int BLOCK_SIZE = 512; __global__ void fillAndAddKernelV2(float* c, float *a, float* b) { int i = threadIdx.x + blockIdx.x * blockDim.x; a[i] = sin((double)i)*sin((double)i); b[i] = cos((double)i)*cos((double)i); c[i] = a[i] + b[i]; }
23,925
float h_A[]= { 0.714899237705168, 0.6593403492402452, 0.8200921920091004, 0.9453533202697284, 0.5522293587559314, 0.911488355650966, 0.6084328273759245, 0.6081693680408298, 0.9852630400453032, 0.9552435162269735, 0.7714556537320874, 0.893125822994568, 0.860835407553673, 0.6580368874559931, 0.8842885921552708, 0.7190619...
23,926
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> __global__ void add(int *a,int *b,int *c) { int tid = threadIdx.x; c[tid] = a[tid] + b[tid]; } int main(void) { int i,a[10000],b[10000],c[10000],n; printf("Enter value of N:"); scanf("%d",&n); printf("Enter array elements of array...
23,927
#include <cstdio> #include <assert.h> #include "splitCounter_kernel.cu" int main(int argc, char ** argv) { // local variables unsigned int * h_counters = NULL; unsigned int * h_outArr = NULL; const int numRuns = 1; int numTBs = 0, tbSize = 0; if (argc != 3) { fprintf(stderr, "./splitCounter <numTBs> <...
23,928
/** size of A = 640 size of B = 600 gridDim = 60 blockDim = 64 k= 1000000 x = 10 **/ __global__ void MultiplyVectors(const float* A, const float* B, float* C, int x, int k) { int B_start_index = (blockIdx.x*gridDim.y + blockIdx.y)*x; int A_start_index = (threadIdx.x*blockDim.y + threadIdx.y)*x; ...
23,929
//#ifndef __CUDACC__ //define __CUDACC__ //#endif #include "cuda.h" #include "device_launch_parameters.h" //#include "cuda_runtime.h" //#include <device_functions.h> #include <stdlib.h> #include <stdio.h> #define tile 4 __global__ void test(int *a) { int i=0; printf("Start\n"); for(;i<100000;i++); printf("235...
23,930
#include <iostream> #include <stdlib.h> __global__ void staticReverse(int *d, int n) { __shared__ int s[64]; //static shared memory allocation int t = threadIdx.x; int tr = n - threadIdx.x - 1; if(t < n) { s[t] = d[t]; __syncthreads(); //None shall pass d[t] = s[tr]; } } __global__ void dynamicReverse(i...
23,931
#include <stdio.h> __global__ void cuda_hello(){ printf("Hello World from GPU!\n"); } int main() { /*As we have 2 blocks and 5 thread per blocks this program will print the message 2*5=10 times*/ cuda_hello<<<2,5>>>(); return 0; }
23,932
// System includes #include <stdio.h> // CUDA runtime #include <cuda_runtime.h> // CUDA device code highlight #include <device_launch_parameters.h> // CUDA Profiler function #include <cuda_profiler_api.h> #define BLOCK_DIM 16 //////////////////////////////////////////////////////////////////////////////// //! Com...
23,933
#include <stdio.h> #include <stdlib.h> #include <algorithm> #include <iostream> using namespace std; #include <cuda_runtime.h> #include <device_launch_parameters.h> int main(int argc, char* argv[]) { float memsettime; cudaEvent_t start, stop; int num_of_iterations = strtol(argv[1], NULL, 10); double u[4][4] = { ...
23,934
#include <math.h> void u_init(double *u, int N, int N2, double start_T) { int i, j, k; // Initialize interior for (i=0; i<N; i++){ for (j=0; j<N; j++) { for (k=0; k<N; k++){ u[i*N2+j*N+k] = start_T; } } } // Initialize boundaries...
23,935
#include<stdio.h> #include<stdlib.h> #include<cuda.h> #define ThPBlck 16 __global__ void transpose(float* A,float* At,int rows,int cols) { int c = blockIdx.x * blockDim.x + threadIdx.x; int r = blockIdx.y * blockDim.x + threadIdx.y; if(c < cols && r < rows) { At[c*rows+r]=A[c+r*cols]; } } //Matrix transpose ...
23,936
#include "includes.h" __global__ void ker_gkylCartFieldAbs(unsigned s, unsigned nv, double *out) { for (int n = blockIdx.x*blockDim.x + threadIdx.x + s; n < s + nv; n += blockDim.x * gridDim.x) out[n] = fabs(out[n]); }
23,937
/* * This program uses the device CURAND API to calculate what * proportion of pseudo-random ints have low bit set. * It then generates uniform results to calculate how many * are greater than .5. * It then generates normal results to calculate how many * are within one standard deviation of the mean. */ #inclu...
23,938
#include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <time.h> #define TIMER_CREATE(t) \ cudaEvent_t t##_start, t##_end; \ cudaEventCreate(&t##_start); \ cudaEventCreate(&t##_end); #define TIMER_START(t) \ cudaEventRecord(t##_start); ...
23,939
/* Copyright 2020 Ying Da Wang file is part of the Open Porous Media project (OPM). OPM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any late...
23,940
#include<stdio.h> #include<iostream> #include<malloc.h> #include<ctime> #include<cuda_runtime.h> #include<assert.h> using namespace std; __global__ void loop_stride_access(int* latency, long long unsigned* device_array, int access_number, long long unsigned* last_access_value, int array_size){ int threadx =threadIdx...
23,941
#include "includes.h" __global__ void build_actual_output(int *output, int n_rows, int k, const int *idx_labels, const int64_t *indices) { int element = threadIdx.x + blockDim.x * blockIdx.x; if (element >= n_rows * k) return; int ind = (int)indices[element]; output[element] = idx_labels[ind]; }
23,942
#define TILE_DIM 64 #define BLOCK_ROWS 4 extern "C" __global__ void copy(float *odata, const float *idata) { int x = blockIdx.x * TILE_DIM + threadIdx.x; int y = blockIdx.y * TILE_DIM + threadIdx.y; int width = gridDim.x * TILE_DIM; for (int j = 0; j < TILE_DIM; j += BLOCK_ROWS) odata[(y + j) * width + x]...
23,943
#include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include <sys/resource.h> #include <math.h> double dwalltime(){ double sec; struct timeval tv; gettimeofday(&tv,NULL); sec = tv.tv_sec + tv.tv_usec/1000000.0; return sec; } __global__ void vecMult(double *d_vecA,unsigned long n, unsigned long blockS...
23,944
//pass //--gridDim=[1322,1,1] --blockDim=[256,1,1] #include "common.h" __global__ void removeCycles(uint *successors, uint verticesCount) { uint tid = blockIdx.x * blockDim.x + threadIdx.x; if (tid < verticesCount) { uint successor = successors[tid]; uint ...
23,945
/** * * bash版ビットマップのC言語版のGPU/CUDA移植版 * 詳しい説明はこちらをどうぞ https://suzukiiichiro.github.io/search/?keyword=Nクイーン問題 * アーキテクチャの指定(なくても問題なし、あれば高速) -arch=sm_13 or -arch=sm_61 CPUの再帰での実行 $ nvcc -O3 -arch=sm_61 01CUDA_Bitmap.cu && ./a.out -r CPUの非再帰での実行 $ nvcc -O3 -arch=sm_61 01CUDA_Bitmap.cu && ./a.out -c GPUのシングルスレッド $ ...
23,946
#include "stdio.h" #include <cuda.h> #include <cuda_runtime.h> #include <iostream> #define N 100000 // Test result // No Size GPU CPU // 1 10 0.098583 0.000047 // 2 10000 0.106036 0.000428 // 3 100000 0.102938 0.003612 // Defining vector addition function for CPU void cpuAdd(int *h_a, int *h_b...
23,947
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdbool.h> #include <time.h> #include <curand.h> #include <curand_kernel.h> #include <math.h> #define BLOCK_SIZE 768 #define N 9999 // number of bodies #define MASS 0 // row in array for mass #define X_POS 1 // row in array for x position ...
23,948
#include <iostream> #include <stdlib.h> #include <math.h> #include <time.h> #include <stdio.h> #define ROW 15 //filas Matriz 1 #define COL 15 // columna Matriz 2 #define N ROW*COL // Cantidad de elementos en Matriz 3 #define THREADS 5 using namespace std; void createMatrixHost(float**& host, int row, int col, int s...
23,949
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <cuda.h> #include <ctime> #include <iostream> #define THREADS 1024 __global__ void getmaxcu(unsigned int * numbers, unsigned int * result, unsigned int size) { extern __shared__ unsigned int arr[]; int tx = threadIdx.x; arr[tx] = numbers[tx]; ...
23,950
#include "includes.h" __global__ void float2toUchar1(float2 *inputImage, uchar1 *outputImage, int width, int height, int index) { int offsetBlock = blockIdx.x * blockDim.x + blockIdx.y * blockDim.y * width; int offset = offsetBlock + threadIdx.x + threadIdx.y * width; float2 pixelf = inputImage[offset]; float pixelfInd...
23,951
#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 err...
23,952
#include <iostream> #include <cstdlib> #include <math.h> #define epoch 100000000 using namespace std; int rand(); double RandomNumber(double Min, double Max) { return ((double(rand()) / double(RAND_MAX)) * (Max - Min)) + Min; } double sigmoid(double x){ return 1 / (1 + exp(-x)); } double sigmoid_der(double ...
23,953
#include <stdio.h> #include <stdint.h> #define MAXN 1024 #define SeqSize 4 __device__ __host__ int CeilDiv(int a, int b) { return (a-1)/b + 1; } __global__ void myMatrixMul(int N, uint32_t *cuC, uint32_t *cuA, uint32_t *cuTransB){ int tid = blockIdx.x * blockDim.x + threadIdx.x; if (tid >= N*N) return; in...
23,954
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <math.h> #include <sys/types.h> #include <sys/times.h> #include <sys/time.h> #include <time.h> /* Program Parameters */ #define MAXN 8000 /* Max value of N */ int N; /* Matrix size */ int nt; /* Number of Threads */ /* junk */ #define randm() 4|2[...
23,955
#include <stdio.h> #include <iostream> #include <fstream> #include <chrono> #define IMAGE_WIDTH 3840 #define IMAGE_HEIGH 2160 #define IMAGE_CH 3u #define IMAGE_OFF 54u __global__ void kernelYUV2RGB(unsigned char *a, unsigned char *b) { int i = 3*blockIdx.x; int c = b[i+0] - 16; int d = b[i+1] - 128; ...
23,956
#include "includes.h" extern "C" __global__ void recipSummation(double* data, double* recip, int len) { const int y = blockIdx.y * gridDim.x * blockDim.x; const int x = blockIdx.x * blockDim.x; const int i = threadIdx.x + x + y; if (i < len) { const int j = 2 * i; data[j] *= recip[i]; data[j + 1] *= recip[i]; } }
23,957
#include <stdio.h> // // compile: nvcc -o example example.cu // #define N 1000 // // This function multiplies the elements of an array // of ints by 2. // __global__ void add(int *a, int *b) { int i = blockIdx.x; if (i<N) { b[i] = 2*a[i]; } } int main() { // // Create int arrays on the C...
23,958
#include "includes.h" __global__ void kInitIdentityMatrix(float* a, int size, int num_elements) { const int idxX = blockIdx.x * THREADS_PER_BLOCK + threadIdx.x; for (int x = idxX; x < num_elements; x += gridDim.x * THREADS_PER_BLOCK) { if (x % size == x / size) { a[x] = 1; } else { a[x] = 0; } } }
23,959
#include "includes.h" __global__ void cg_init_k( const int x_inner, const int y_inner, const int halo_depth, const double* w, double* kx, double* ky, double rx, double ry) { const int gid = threadIdx.x+blockIdx.x*blockDim.x; if(gid >= x_inner*y_inner) return; const int x = x_inner + 2*halo_depth-1; const int col = gid...
23,960
#include "includes.h" __global__ void get_c_size(int *d_c_size, int *d_full_cl, int size) { int i = blockDim.x * blockIdx.x + threadIdx.x; if (i >= size) { return; } if (d_full_cl[i] != 0) { atomicAdd(d_c_size, 1); } }
23,961
#include <stdio.h> #include <math.h> #include <thrust/scan.h> void rng(int* arr, int n) { int seed = 13516014; // NIM Renjira srand(seed); for(long i = 0; i < n; i++) { arr[i] = (int)rand(); } } __host__ int getMax(int *arr, int n) { int mx = arr[0]; for (int i = 1; i < n; i++) ...
23,962
/* Mary Barker Homework 7 Vector dot product on GPU with more blocks than allowed. to compile: nvcc BarkerHW7.cu */ #include <sys/time.h> #include <stdio.h> #define N 300000 #define MIN(x,y) (x<y)?x:y #define threadsPerBlock 1024 float *A_CPU, *B_CPU, *C_CPU; //CPU pointers float *A_GPU, *B_GPU, *C_GPU; //GPU ...
23,963
//STL #include <iostream> #include <string> #include <vector> using namespace std; string childInput; unsigned i; vector < float > inputVec; string letter, subFp; const string sep( "_" ); //=========================== gpu =========================== __device__ float d_Array[ 30 ]; //static gpu array __global__ void...
23,964
#include <stdio.h> #include <stdlib.h> #include <unistd.h> /* Bounds of the Mandelbrot set */ #define X_MIN -1.78 #define X_MAX 0.78 #define Y_MIN -0.961 #define Y_MAX 0.961 typedef struct { int nb_rows, nb_columns; /* Dimensions */ char * pixels; /* Linearized matrix of pixels */ } Image; static void error_op...
23,965
#include<iostream> #include<stdlib.h> #include<set> #include<map> #include<vector> #include<algorithm> #include<cuda.h> #include <thrust/sort.h> using namespace std; #define pairi pair<int,int> #define ve vector #define vi vector<int> #define f first #define s second #define t third // HYPERPARAMETERS #define PANEL_S...
23,966
#include "stdio.h" #define ROW 3 #define COL 2 __global__ void add(int *a,int *b,int *c) { int x = blockIdx.x; int y = blockIdx.x; int i = COL*y + x; c[i] = a[i] + b[i]; } int main() { int a[ROW][COL],b[ROW][COL],c[ROW][COL]; int *dev_a,*dev_b,*dev_c; cudaMalloc((void**)&dev_a,ROW*COL*sizeof(int)); cudaMalloc...
23,967
#include <iostream> const int N = 1000; __global__ void add(float a[N][N], float b[N][N]); using namespace std; int main() { float(*A)[N]; float(*B)[N]; // Allocate Unified Memory – accessible from CPU or GPU cudaMallocManaged(&A, N * N * sizeof(float)); cudaMallocManaged(&B, N * N * sizeof(float)); for (...
23,968
/****************************************************************************** *cr *cr (C) Copyright 2010 The Board of Trustees of the *cr University of Illinois *cr All Rights Reserved *cr *****************************************************************...
23,969
/* The code generates a 3D image of a stack of images. For each image (matrix) calculate the variance at all points, and then create a topography matrix (relief matrix) with the position (number in the stack) of the image that had the largest variance in a pixel. The same with the color of the image (RGB matrices). */...
23,970
#include <cuda.h> #include <stdio.h> int main(){ cudaDeviceProp Props; cudaGetDeviceProperties(&Props,0); printf("shared mem: %d\n",Props.sharedMemPerBlock); printf("max threads per block : %d\n",Props.maxThreadsPerBlock); printf("max blocks: %d\n",Props.maxGridSize[0]); printf("total Const mem: %d\n",Props.tot...
23,971
#include "includes.h" __global__ void computeGradientCentralDiff(const float* similarities, float* gradient, int* activeMask, int activePatches, int patches, int p) { int i = threadIdx.x + blockIdx.x * blockDim.x; if (i >= activePatches) return; int patch = activeMask[i]; float dx = similarities[patch] - similarities[...
23,972
#include "includes.h" __device__ size_t GIDX(size_t row, size_t col, int H, int W) { return row * W + col; } __global__ void kernel_optflow(float* d_dx1, float* d_dy1, float* d_dx2, float* d_dy2, float* d_dt, float4* uv, float4* uv1, int H, int W) { const size_t row = threadIdx.y + blockDim.y * blockIdx.y; const size_...
23,973
#include <cuda_runtime_api.h> #include <cassert> #include <cstdio> #include <cstdlib> #include <cmath> #include <random> constexpr int BLOCK_SIZE = 1024; //KERNEL implementation 1 __global__ void scan1(int *data_out, int *data_in, int *max, int N) { __shared__ int partial[BLOCK_SIZE * 2]; ...
23,974
#include <iostream> #include <math.h> #include <cstdlib> using namespace std; __global__ void kernel_multiply(int *A, int *B, int *C, int n) { int row = blockDim.y * blockIdx.y + threadIdx.y; int col = blockDim.x * blockIdx.x + threadIdx.x; int sum = 0; if(row<n && col<n) { for(int i=0;i<n;i++) { sum+=A...
23,975
#include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <thrust/sort.h> extern "C" cudaError_t cuda_main() { printf("Generating random numbers\n"); thrust::host_vector<int> h_vec(100); thrust::generate(h_vec.begin(), h_vec.end(), rand); for(int i=0; i<h_vec.size();i++) printf("%d ",h_vec[i]); pr...
23,976
// Matrix addition, GPU version // nvcc matrix_gpu.cu -L /usr/local/cuda/lib -lcudart -arch=sm_20 -o matrix_gpu #include <stdio.h> const int BLOCKSIZE = 32; const int GRIDSIZE = 1; __global__ void multiply(float *a, float *b, float *c, int N) { int row = (blockIdx.x * blockDim.x) + threadIdx.x; int col = (...
23,977
#include "includes.h" __global__ void kernel_tanh_full_device(unsigned int size, int *x, int *out) { unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x; unsigned int stride = blockDim.x * gridDim.x; /* tanh : R -> (-1,1) which is 0 in the integers */ for (unsigned int i = idx; i < size; i += stride) { out[i] = ...
23,978
#include "includes.h" __global__ void DragRealGrad(float2 *ORIGIN , float *DEST , float *VEC) { int idx = threadIdx.x + blockIdx.x*blockDim.x; DEST[idx] = ORIGIN[idx].x/sqV - VEC[idx]; }
23,979
//Tyler Sorensen //tylersorensen3221@hotmail.com //University of Utah /*********************************************************** *Really strange behavior from Cuda program * *This is a simple contrived example I came up with *to test GKLEE's -pure-canonical-schedule flag. I made a simple *kernel that wouldn't r...
23,980
#define A2 (1.0/4.0) #define B2 (1.0/4.0) #define A3 (3.0/8.0) #define B3 (3.0/32.0) #define C3 (9.0/32.0) #define A4 (12.0/13.0) #define B4 (1932.0/2197.0) #define C4 (-7200.0/2197.0) #define D4 (7296.0/2197.0) #define A5 1.0 #define B5 (439.0/216.0) #define C5 (-8.0) #define D5 (3680.0/513.0) #define E5 (-845.0/41...
23,981
//////////////////////////////////////////////////////////////////////////// // // Copyright 1993-2015 NVIDIA Corporation. All rights reserved. // // Please refer to the NVIDIA end user license agreement (EULA) associated // with this source code for terms and conditions that govern your use of // this software. Any u...
23,982
/************************************************************************* > File Name: 00gridblock.cu > Author: dong xu > Mail: gwmxyd@163.com > Created Time: 2016年03月30日 星期三 23时27分51秒 ************************************************************************/ #include <stdio.h> #include <cuda_runtime.h> __globa...
23,983
// // main.cpp // pi_with_cuda // // Created by Mirco Meazzo on 21/10/2019. // Copyright © 2019 Mirco Meazzo. All rights reserved. // #include <iostream> #include <stdlib.h> #include <math.h> #include <typeinfo> #define NLIM 10000000 __global__ void compute_r(int *mem, double *rand_real, double *rand_imag ) { ...
23,984
#include "includes.h" __global__ void propose_kernel(int64_t *out, int64_t *proposal, const int64_t *rowptr, const int64_t *col, int64_t numel) { const int64_t thread_idx = blockIdx.x * blockDim.x + threadIdx.x; if (thread_idx < numel) { if (out[thread_idx] != -1) return; // Only vist blue nodes. bool has_unmatched_n...
23,985
#include <stdio.h> void hello(){ printf("hello world!\n"); } __global__ void say_hello(){ printf("[say_hello] Hello World from GPU! \n"); } __global__ void say_hello_multi(){ int idx = threadIdx.x; if(idx == 5) printf("[say_hello_multi] hello world from gpu [%d]\n",idx); } int main(){ hell...
23,986
__global__ void update_e( int Ny, int Nz, float *Ex, float *Ey, float *Ez, float *Hx, float *Hy, float *Hz, float *CEx, float *CEy, float *CEz ) { int tk = threadIdx.x; int idx = blockIdx.x*blockDim.x + tk; int Nyz = Ny*Nz; //int fidx = idx + idx/(Nz-1) + Nyz + Nz + 1; int fidx = idx + idx/(Nz-1) + idx/( (Nz-1)*(...
23,987
#include "includes.h" __global__ void setValue_kernel(int *vals, int N) { // Taken from //geco.mines.edu/workshop/aug2010/slides/fri/cuda1.pd int myblock = blockIdx.x + blockIdx.y * gridDim.x; /* how big is each block within a grid */ int blocksize = blockDim.x * blockDim.y * blockDim.z; /* get thread within a block */...
23,988
__global__ void MatchSiftPoints(float *sift1, float *sift2, float *corrData, int numPts1, int numPts2) { __shared__ float siftPoint[128]; __shared__ float sums[16*16]; const int tx = threadIdx.x; const int ty = threadIdx.y; const int p1 = blockIdx.x; const int p2 = blockIdx.y*16 + ty; const float *ptr1 = ...
23,989
#include <cuda_runtime.h> #include <stdio.h> #include <assert.h> __global__ void MatrixMultiply(float * mat_a, float * mat_b, float * mat_c, int m, int n, int k) { int ix=threadIdx.x+blockDim.x*blockIdx.x; int iy=threadIdx.y+blockDim.y*blockIdx.y; int idx=iy*n + ix; // printf("ix=%d, iy=%d\n", ix, iy);...
23,990
cudaEvent_t cstart, cstop; void cudatic(){ cudaEventCreate(&cstart); cudaEventCreate(&cstop); cudaEventRecord(cstart, 0); } float cudatoc(){ cudaEventRecord(cstop, 0); cudaEventSynchronize(cstop); float elapsedTime; cudaEventElapsedTime(&elapsedTime, cstart, cstop); /* return elapsed tim...
23,991
/* Author: Chen Zhang, NYU Courant * * This is a sukodu solver using stochastic methods. */ #include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> #include <math.h> #include <cuda.h> #include <curand.h> #include <curand_kernel.h> #define puzzlePb 32 #define NBLOCK 10 #define index(x, y) ...
23,992
/* ============================================================================ Filename : algorithm.c Author : Dominique Roduit SCIPER : 234868 ============================================================================ */ #include <iostream> #include <iomanip> #include <sys/time.h> #include <cuda_runti...
23,993
#include "visualization.cuh" #include <fstream> #include <iostream> #include <string> #include "cuda_runtime.h" #include "device_launch_parameters.h" #include <ctime> #define INFINITY 2<<27 #define BLOCK_SIZE 512 #define GRID_SIZE 8192 //CUDA kernel for expansion of each field in matrix to square with edge = square_di...
23,994
#include <cstdio> #include <vector> using std::vector; // parameter describing the size of matrix A const int rows = 4096; const int cols = 4096; const int BLOCK_SIZE = 32; // naive transpose kernel __global__ void matrixTransposeNaive(float *_a, // pointer to matrix A on the device ...
23,995
#include "includes.h" __global__ void cuda_fill(double* pVec, double val, int n) { int id = blockIdx.x * blockDim.x + threadIdx.x; if (id < n) pVec[n] = val; }
23,996
#include "defines.cuh" #include "function_defines.cuh" __device__ inline Vector3D AmbientGetDirection(Ambient *ab, ShadeRec *sr){ return (Vector3D(0,0,0)); } __device__ inline RGBColor AmbientL(Ambient *ab, ShadeRec *sr){ return (ab->color * ab->ls); } __device__ inline Vector3D DirectionalGetDirection(Directional...
23,997
#include <iostream> #include <numeric> #include <random> #include <vector> // Here you can set the device ID that was assigned to you #define MYDEVICE 1 constexpr int num_elements = 1 << 18; constexpr uint num_blocks = num_elements >> 10; // div by 1024 constexpr uint block_size = num_elements / num_blocks; // const...
23,998
#include "includes.h" __global__ void batch_crop_kernel(float* input, const int nCropRows, const int nCropCols, const int iH, const int iW, const int nPlanes){ const int plane = blockIdx.x; if (plane >= nPlanes) return; input += plane * iH * iW; const int tx = threadIdx.x; const int ty = threadIdx.y; const int tz = th...
23,999
#include <stdio.h> #include <string.h> #define THREADS_PER_BLOCK 64 __global__ void part_a_cuda(int* a, int* b, int len) { int a_index = threadIdx.x + blockIdx.x * THREADS_PER_BLOCK; int b_index = 0; if (a_index < len) { b_index = a[a_index] / 100; atomicAdd(&b[b_index], 1); } } __global__ void pa...
24,000
#include <cuda.h> #include <math.h> #include <stdlib.h> #include <stdio.h> #include <sys/time.h> int main(int argc, char *argv[]) { int a; int b; int *ptx; int *pty; int *pttmp; printf("Pointer Example Program : Print Pointer Address\n"); a = 10; b = 11; ptx = &a; pty = &b; printf("\n[ptx ]:V...