serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
4,101
#include "includes.h" __global__ void fill_kernel(int N, float ALPHA, float *X, int INCX) { const int index = blockIdx.x*blockDim.x + threadIdx.x; if (index >= N) return; X[index*INCX] = ALPHA; }
4,102
#include "includes.h" __global__ void vectorAdd(const int *a, const int *b, int *c, int N) { int tid = blockDim.x * blockIdx.x + threadIdx.x; while(tid < N) { c[tid] = a[tid] + b[tid]; tid += blockDim.x * gridDim.x; } }
4,103
#include <stdio.h> #include <cuda.h> #include <cuComplex.h> #include <cuda_runtime.h> #include <cuda_runtime_api.h> #define BLOCK_SIZE 16 // Threads per block supported by the GPU __global__ void dtpmv_kernel ( char UPLO, char TRANS, char DIAG,int N,double * A, double *X , double *T) { int elementId = blockIdx.x * B...
4,104
#ifndef _CUDA_KERNEL_OPTIONS_CU_ #define _CUDA_KERNEL_OPTIONS_CU_ #define TPB 128 #define MAX_OBSTACLES 128 typedef enum kernel_opt { NONE = 0, IGNORE_UNLESS_ZERO = 1 << 0, LOCAL_SPACE_BANKING = 1 << 1, SPHERICAL_WRAP_AROUND = 1 << 2 } kernel_options; #endif // _CUDA_KERNEL_OPTIONS_CU_
4,105
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <cuda.h> #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__);\ e...
4,106
#include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include <math.h> #define DIM 3 #define GRID 16 #define VALIDATE 10 // function declarations void validate_grid (const float *c, const float *intervals, const int *grid_c, const int *points_block_c, int D); void validate_search (const f...
4,107
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> #include <assert.h> #include <unistd.h> #include <stdint.h> #define POP 300 #define LEN 30 #define MUT 0.1 #define REC 0.5 #define END 10000 #define SUMTAG 150 #define PRODTAG 3600 int gene[POP][LEN]; int value[POP][LEN]; int seed[POP][LEN]; v...
4,108
/** Author: alexge50 * How to use: input should be given in a file input.txt, in the same directory as the binary. Output is given in output.txt * Input: [Number of steps] * [height - number of rows] [width - number of columns] * board * Output: [time] ms * board at the current stat...
4,109
#include <stdio.h> #include <time.h> #define N 4 __global__ void outputFromGPU() { printf("[%d] : [%d]\n", blockIdx.x, threadIdx.x); } __global__ void multiplicationTableBlock(int *mutex, int *index) { int c = blockIdx.x; while(atomicExch(mutex, 1) != 0); for(int i = 1; i <= 12; i++) { printf("[%d]\t%d x %d ...
4,110
#include <stdio.h> #include <math.h> #include <cuda.h> #define CHUNK_SIZE 1024 #define T unsigned long int //make sure start is less than N/2. a is a pointer to an array of length >= N __global__ void Fibonacci( T *a, int start) { int i = blockDim.x * blockIdx.x + threadIdx.x; int index = i + start; if (i < 2 * st...
4,111
//pass //--blockDim=1024 --gridDim=4 #include <cuda.h> ////////////////////////////////////////////////////////////////////////////// //// Copyright (c) Microsoft Corporation. All rights reserved //// This software contains source code provided by NVIDIA Corporation. //////////////////////////////////////////////////...
4,112
#include "TmpMalloc.cuh" #include <stdio.h> #include <cuda.h> #include <cuda_runtime.h> #include <map> #include <vector> using namespace std; #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort = true) { if (code != cudaS...
4,113
#include "includes.h" ////////////////////////////////////////////////////////////////////////////////////////// __global__ void bestFilter(const double *Params, const bool *iMatch, const int *Wh, const float *cmax, const float *mus, int *id, float *x){ int tid,tind,bid, my_chan, ind, Nspikes, Nfilters, Nthreads, Nc...
4,114
/* Copyright (c) 2017-2018, NVIDIA CORPORATION. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of ...
4,115
__global__ void reduce_kernel(float* d_out, const float *d_in){ extern __shared__ float sdata[]; int myId = threadIdx.x + blockDim.x * blockIdx.x; int tid = threadIdx.x; // load shared memory from global memory sdata[tid] = d_in[myId]; __syncthreads(); // Do reduction in shared memory for(unsigned int s = ...
4,116
#include "includes.h" __global__ void cudaComputeYGradient(int* y_gradient, unsigned char* channel, int image_width, int image_height, int chunk_size_per_thread) { int y_kernel[3][3] = { { 1, 2, 1 }, { 0, 0, 0 }, { -1, -2, -1 } }; int index = blockIdx.x * blockDim.x + threadIdx.x; for (int i = index * chunk_size_per_th...
4,117
#include <stdio.h> int main(int argc, char **argv) { printf("Hallo World from CPU!\n"); }
4,118
#include <iostream> #include <unistd.h> #include <cuda.h> #include <cuda_runtime.h> #define size 21 // Tamanho da matrix // Exibe os pontos na tela __host__ void print(bool grid[][size]){ std::cout << "\n\n\n\n\n"; for(unsigned int i = 1; i < size-1; i++) { for(unsigned int j = 1; j < size-1; j++) std...
4,119
#include "includes.h" __global__ void tile_kernel(const float* in,float* out, int num_planes, int num_rows, int num_cols) { const int gid = threadIdx.x + blockIdx.x * blockDim.x; const int elems_per_plane = num_rows * num_cols; const int plane = gid / num_rows; const int row = gid % num_rows; if (plane >= num_plan...
4,120
// Multiply two matrices A * B = C #include <stdlib.h> #include <stdio.h> #include <math.h> //Thread block size #define BLOCK_SIZE 3 #define WA 3 // Matrix A width #define HA 3 // Matrix A height #define WB 3 // Matrix B width #define HB WA // Matrix B height #define WC WB // Matrix C width #define HC ...
4,121
#include <iostream> #include <vector> #include <fstream> #include <map> #include <string> #include <sstream> #include <iterator> #include <algorithm> #include <cuda_profiler_api.h> #include <cuda_runtime.h> #include <chrono> #define timeNow() std::chrono::high_resolution_clock::now() #define duration(start, stop) std:...
4,122
__global__ void add(int *a, int *b, int *c) { *c = *a + *b; }
4,123
#include <thrust/version.h> #include <iostream> /* Version check for thrust If not found, try nvcc version.cu -o version -I /home/you/libraries/ when libraries is where you store you thrust downloaded files */ int main(void) { int major = THRUST_MAJOR_VERSION; int minor = THRUST_MINOR_VERSION; ...
4,124
#include "includes.h" #define tileSize 32 //function for data initialization void initialization( double *M, double *N, int arow, int acol, int brow, int bcol); //(for Debugging) prints out the input data void printInput( double *M, double *N, int arow, int acol, int brow, int bcol); //(for Debugging) prints out t...
4,125
// Modified from // https://github.com/sshaoshuai/Pointnet2.PyTorch/tree/master/pointnet2/src/interpolate_gpu.cu #include <math.h> #include <stdio.h> #include <stdlib.h> #define THREADS_PER_BLOCK 256 #define DIVUP(m, n) ((m) / (n) + ((m) % (n) > 0)) __global__ void three_nn_kernel(int b, int n, int m, ...
4,126
#include <stdio.h> #include <future> #include <thread> #include <chrono> #include <iostream> __constant__ int factor = 0; __global__ void vectorAdd(int *a, int *b, int *c) { int i = blockIdx.x*blockDim.x + threadIdx.x; c[i] = factor*(a[i] + b[i]); } __global__ void matrixAdd(int **a,int **b, int**c) { i...
4,127
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <cuda.h> #define row 10000 #define col 10000 int matrixA[row][col], matrixB[row][col], matrixC[row][col], matrixD[row][col]; __global__ void add_matrix(int matrixA[row][col], int matrixB[row][col], int matrixC[row][col]) { int i = blockDim.x*blockIdx...
4,128
#include <sys/time.h> #include <stdio.h> #include <cuda_runtime.h> #define NUM_STREAMS 4 //For time log by callback function double timeStampB=0; double timeStampC=0; double timeStampD=0; double timeKernal=0; // time stamp function in seconds double getTimeStamp() { struct timeval tv ; gettimeofday( &tv, NULL ) ; r...
4,129
#include <cuda_runtime.h> void saxpy_c(int n, float a, float* x, float* y) { for (int i = 0; i < n; ++i) y[i] = a * x[i] + y[i]; } __global__ void saxpy(int n, float a, float* x, float* y) { int const i = blockIdx.x * blockDim.x + threadIdx.x; if (i < n) y[i] = a * x[i] + y[i]; } #include <iostream> int main(...
4,130
/* ================================================================== Programmer: Yicheng Tu (ytu@cse.usf.edu) The basic SDH algorithm implementation for 3D data To compile: nvcc SDH.c -o SDH in the rc machines StevenFaulkner U9616-1844 Summer 2018 ==============================================================...
4,131
#include <stdio.h> void init(double *a, int N) { int i; for (i = 0; i < N; ++i) { a[i] = i%3; } } struct position { int x; int y; }; /// convert a 2D position to a 1D index /// assumes bottom left corner of image is 0,0 and index 1 long get1dIndex( int width, int x, int y) { return y * ...
4,132
#include "includes.h" __global__ void relabel2Kernel(int *components, int previousLabel, int newLabel, const int colsComponents, const int idx, const int frameRows) { uint i = (blockIdx.x * blockDim.x) + threadIdx.x; uint j = (blockIdx.y * blockDim.y) + threadIdx.y; i = i * colsComponents + j; i = i + (colsComponents *...
4,133
#include <stdio.h> #include <math.h> __global__ void kernelb(int *A, int *x, int *b, int N){ int tId = threadIdx.x + blockIdx.x * blockDim.x; if(tId< N){ for(int k=0; k < N; k++){ b[tId] += A[(int)(tId*N+k)]*x[k]; } } } int main(int argc, char const *argv[]) { int n = 1e4; int block_size = 25...
4,134
#include <stdio.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; } __global__ void initVectorGpu(float *a, float value, int N)...
4,135
#include <cuda_runtime.h> #include <thrust/extrema.h> #include <thrust/execution_policy.h> #include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <thrust/functional.h> #include "curand.h" #include "curand_kernel.h" #include <cmath> #include <chrono> #include <iostream> #include <iomanip> #include <s...
4,136
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <cuda_runtime.h> #define N 5 __global__ void gpu_global_memory(int *d_a) { d_a[threadIdx.x] = threadIdx.x; } __global__ void gpu_local_memory(int d_in) { int t_local; t_local = d_in * threadIdx.x; printf("Val of local var in cur...
4,137
#include <stdlib.h> #include <stdio.h> #include <sys/time.h> /** * * Function my_gettimeofday() * Used to compute time of execution * **/ double my_gettimeofday(){ struct timeval tmp_time; gettimeofday(&tmp_time, NULL); return tmp_time.tv_sec + (tmp_time.tv_usec * 1.0e-6L); } /** * * Function read_para...
4,138
// copied from gsl __device__ __host__ inline double sample_quantile_from_sorted_data( const double sorted_data[], const int n, const double f){ const double index = f * (n - 1) ; const int lhs = (int)index ; const double delta = index - lhs ; double result; if (n == 0) return 0.0 ; if (lhs == n - 1...
4,139
#include<stdio.h> #include<stdlib.h> #include<sys/time.h> // Simple transformation kernel __global__ void transformKernel(float* output, cudaTextureObject_t coolTexObj, cudaTextureObject_t heatTexObj, int nx, int ny, float log_n) { // Calculate normalized texture coordinates int xid = blockIdx.x * blockDim.x + ...
4,140
#include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <thrust/execution_policy.h> #include <thrust/generate.h> #include <thrust/sort.h> #include <thrust/copy.h> #include <algorithm> #include <cstdlib> #include <iostream> #include <numeric> #include <ctime> struct HashGenerator { int current_; ...
4,141
#include "cuda_runtime.h" #include "device_launch_parameters.h" extern "C" { __global__ void IncrementAll(float* input, float* output, float incrementSize, int itemCount) { int threadId = blockIdx.y*blockDim.x*gridDim.x + blockIdx.x*blockDim.x + threadIdx.x; if (threadId < itemCount) { output[threa...
4,142
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <iostream> #include <stdio.h> using namespace std; #define N 3 //rowsize #define M 4 // columnsize const int blockNUM = 4; const int threadNUM =3; void mxv(const int rowsize,const int columnsize, const float*matrix,const float*v,float*r)...
4,143
#include "includes.h" extern "C" { } #define TB 128 #define DISP_MAX 256 __global__ void remove_white(float *x, float *y, int size) { int id = blockIdx.x * blockDim.x + threadIdx.x; if (id < size) { if (x[id] == 255) { y[id] = 0; } } }
4,144
// Tests that "sm_XX" gets correctly converted to "compute_YY" when we invoke // fatbinary. // // REQUIRES: clang-driver // REQUIRES: x86-registered-target // REQUIRES: nvptx-registered-target // CHECK:fatbinary // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s 2>&1 \ // RUN: | FileCheck -check...
4,145
#include <stdio.h> #include <stdlib.h> #include <stdio.h> #include <cuda.h> #include <assert.h> __global__ void Asum(int *a, int *b, int *c){ *c = *a + *b; }
4,146
#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 // ...
4,147
#include <cuda.h> #include <cuda_runtime.h> #include <cfloat> #include <stdio.h> #include <stdlib.h> #include <cmath> /** * @brief Print the device's properties * */ extern void dispDevice() { cudaDeviceProp props; cudaGetDeviceProperties(&props, 0); printf("GPU: %s\n", props.name); } // test kernel _...
4,148
#include "simd_kernels.hh" #include "simd_ops.hh" #include "../runtime/node.hh" #include <iostream> namespace cpu { namespace { void kernel_sigmoid(rt::Node* node) { (void) node; //simd_sigmoid(node->in1, node->out1, node->len1); } } kernel_f simd_...
4,149
#undef NDEBUG #include <assert.h> int main() { assert(sizeof(cudaError_t) == sizeof(int)); assert(sizeof(cudaStream_t) == sizeof(void*)); assert(sizeof(long) == sizeof(size_t)); return 0; }
4,150
#include "includes.h" // helper for CUDA error handling __global__ void restoreEigenvectors( const double* meanSubtractedImages , const double* reducedEigenvectors , double* restoredEigenvectors , std::size_t imageNum , std::size_t pixelNum , std::size_t componentNum ) { std::size_t row = blockIdx.x; std::size_t col...
4,151
#include<stdio.h> #include<math.h> #define N 8 __global__ void exclusive_scan(int *d_in) { __shared__ int temp_in[N]; int id = threadIdx.x; temp_in[id] = d_in[id]; __syncthreads(); unsigned int s = 1; for(; s <= N-1; s <<= 1) { int i = 2 * s * (threadIdx.x + 1) - 1; if...
4,152
#include <cuda.h> #include <stdio.h> #include <stdint.h> // For comparisons //#include "seqScan.c" /* ------------------------------------------------------------------------ Unrolled in-place(shared memory) Scan without syncs (16 threads, 32 elts) -----------------------------------------------------------...
4,153
#include <cuda_runtime.h> #include <stdio.h> __global__ void checkIndex(void) { printf("threadIdx: (%d, %d, %d) || blockIdx: (%d, %d, %d) || blockDim:(%d, %d, %d) \n" "gridDim: (%d, %d, %d)\n", threadIdx.x, threadIdx.y, threadIdx.z, blockIdx.x, blockIdx.y, blockIdx.z, blockDim.x, blockDim.y, blockDi...
4,154
#include <cuda_runtime.h> #include <stdio.h> #include <device_launch_parameters.h> #include <stdlib.h> #define THREADS_PER_BLOCK 16 void save_to_file(double *AB, const int a_size) { FILE *f = fopen("out.txt", "w+"); fprintf(f, "%d\n", a_size); for(int i = 0; i < a_size*(a_size + 1); i++) { if((i...
4,155
#include <stdio.h> #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true) { if (code != cudaSuccess) { fprintf(stderr,"GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line); if (abort) exit(code); }...
4,156
#include "includes.h" __global__ void THCudaTensor_kernel_indexAdd( float *res, float *src, long* res_stride, float *index, long res_nDim, int dim, long idx_size, long src_size, long size_dim ) { int thread_idx = blockIdx.x * blockDim.x * blockDim.y + threadIdx.y * blockDim.x + threadIdx.x; long flat_size = src_size /...
4,157
#include <cuda_runtime.h> #include <sys/time.h> #include "iostream" #include "iomanip" #include "cmath" #include <stdio.h> using namespace std; #define pi 3.14159265358979323846 #define CHECK(call) \ { \ const cudaError_t error = call; ...
4,158
#include "includes.h" __global__ void _kgauss64map(int nx, int ns, double *x2, double *s2, double *k, double g) { int i, n, xi, si; i = threadIdx.x + blockIdx.x * blockDim.x; n = nx*ns; while (i < n) { xi = (i % nx); si = (i / nx); k[i] = exp(-g * (x2[xi] + s2[si] - 2*k[i])); i += blockDim.x * gridDim.x; } }
4,159
#include <stdio.h> #include <cuda.h> #include <time.h> struct Startup{ int seed = time(nullptr); int threadsPerBlock = 256; int datasetSize = 10000; int range = 100; } startup; struct DataSet{ float* values; int size; }; inline int sizeOfDataSet(DataSet data) { return sizeof(float)*data.si...
4,160
#if __linux__ && defined(__INTEL_COMPILER) #define __sync_fetch_and_add(ptr,addend) _InterlockedExchangeAdd(const_cast<void*>(reinterpret_cast<volatile void*>(ptr)), addend) #endif #include <string> #include <cstring> #include <cctype> #include <cstdlib> #include <cstdio> #include <iostream> #include <fstream> #include...
4,161
#include <algorithm> #include <iostream> using namespace std; __global__ void calcEuropeanOption(int timeSteps, double startPrice, double strikePrice, double riskFree, double delta, double u, ...
4,162
#include <stdio.h> #include <time.h> #include "RSA_kernel.cu" #define BUZZ_SIZE 10002 int p, q, n, t, flag, e[100], d[100], temp[BUZZ_SIZE], j, m[BUZZ_SIZE], en[BUZZ_SIZE], mm[BUZZ_SIZE], res[BUZZ_SIZE], i; char msg[BUZZ_SIZE]; int prime(long int); void generate_input(int); void ce(); long int cd(long int); void enc...
4,163
#include <stdio.h> __global__ void use_local_memory_GPU(float in) { float f; // variable "f" is in local memory and private to each thread f = in; // parameter "in" is in local memory and private to each thread } __global__ void use_global_memory_GPU(float *array) { array[threadIdx.x] = 2.0f * (f...
4,164
#include <iostream> #include "mandel.cuh" #define INTER_LIMIT 255 __device__ int get_inter (thrust::complex<float> c) { int i; thrust::complex<float> z(0.0, 0.0); for (i = 0; i < INTER_LIMIT; ++i) { if (thrust::abs(z) > 2 ) { break; } z = thrust::pow(z, 2) + c; } ...
4,165
/* Voxel sampling GPU implementation * Author Zhaoyu SU * All Rights Reserved. Sep., 2019. */ #include <stdio.h> #include <iostream> #include <float.h> __device__ int get_batch_id(int* accu_list, int batch_size, int id) { for (int b=0; b<batch_size-1; b++) { if (id >= accu_list[b]) { if(id ...
4,166
/* \file TestShortCircuit.cu \author Gregory Diamos <gregory.diamos@gatech.edu> \date Tuesday November 9, 2010 \brief A CUDA assembly test for short-circuiting control flow. */ const unsigned int threads = 512; __device__ bool out[threads]; __global__ void short_circuit() { unsigned int id = threadIdx.x; boo...
4,167
/* nvcc -O2 test_cuda.cu -o test_cuda */ /* benchmark sma: size=1048576 sample=5 equal=0 sma_cpu=8ms sma_gpu=64ms benchmark sma: size=1048576 sample=5 equal=0 sma_cpu=8ms sma_gpu=6ms benchmark sma: size=33554432 sample=5 equal=0 sma_cpu=115ms sma_gpu=49ms benchmark sma: size=1073741824 sample=5 equal=0 sma_cpu=1575ms s...
4,168
// vec_add.cu: Parallel vector add using CUDA #include <stdlib.h> #include <stdio.h> #include <cuda.h> // Kernel function, runs on GPU __global__ void add_vectors(float *a, float *b, float *c) { int i = blockIdx.x; c[i] = a[i] + b[i]; } int main(void) { int count, i; // Find number of GPUs cudaGetD...
4,169
template<typename T> __device__ void abs(const T* data, T* result, const int length) { int bx = blockIdx.x; int tx = threadIdx.x; int index = bx * blockDim.x + tx; if (index < length) { result[index] = (T)abs((float)data[index]); } } extern "C" __global__ void abs_Boolean(const unsigned char* data, uns...
4,170
#include <stdio.h> __global__ void vectorAdd(const float *a, const float *b, float *c, int numElements) { int i = blockDim.x * blockIdx.x + threadIdx.x; if (i < numElements) { c[i] = a[i] + b[i]; } for (const clock_t threshold = clock() + 1e+4; clock() < threshold;); } int main(int argc, char *argv[]) { int n...
4,171
//agent.cpp //#include <iostream> //#include <string> //#include <thrust/version.h> //#include <thrust/host_vector.h> //#include <thrust/device_vector.h> //#include <thrust/device_ptr.h> //#include "agent.cuh"
4,172
#include "includes.h" __global__ void relu_ker(float* src, float* dst, int N){ int i = blockIdx.x*blockDim.x + threadIdx.x; if (i >= N){ return; } dst[i] = fmaxf(0.0, src[i]); }
4,173
#include <cuda.h> #include <stdio.h> #include <malloc.h> __host__ void fill_vector(float* matrix , int size){ float aux = 2.0; for (int i = 0; i < size; ++i) { matrix[i] = (((float)rand())/(float)(RAND_MAX)) * aux; } } __host__ void print(float *V, int len){ for (int i = 0; i < len; i++) { printf("%.2f ...
4,174
#include "includes.h" enum ComputeMode { ADD, SUB, MUL, DIV }; cudaError_t computeWithCuda(int *c, const int *a, const int *b, unsigned int size, ComputeMode mode); __global__ void addKernel(int *c, const int *a, const int *b) { int i = threadIdx.x; c[i] = a[i] + b[i]; }
4,175
#include "includes.h" __global__ void pythagoras(unsigned char* Gx, unsigned char* Gy, unsigned char* G, unsigned char* theta) { int idx = (blockIdx.x * blockDim.x) + threadIdx.x; float af = float(Gx[idx]); float bf = float(Gy[idx]); G[idx] = (unsigned char)sqrtf(af * af + bf * bf); theta[idx] = (unsigned char)atan2f...
4,176
#include "cuda_runtime.h" #include "device_launch_parameters.h" # include <iostream> # include <fstream> # include <cstdlib> # include <cmath> # include <vector> using namespace std; struct number{ //struktura wykorzystywana w wektorze danych - zawiera informacje o wartosci liczby oraz o tym czy jest pierwsza uns...
4,177
#include <stdio.h> #include <stdlib.h> #include <iostream> #include <assert.h> #include <vector> using namespace std; const int INF = 10000000; const int V = 10010; const int MAX_THREAD_DIM2 = 32; void input(char *inFileName, int B); void output(char *outFileName); void block_FW_2GPU(int B); int ceil(int a, int b); v...
4,178
float h_A[]= { 0.5627173728130572, 0.6098007276360664, 0.5349730124526967, 0.6280156549880231, 0.5462467493414154, 0.8887562433166953, 0.5283508322038977, 0.9072439117199396, 0.5799009745766212, 0.7118663511190295, 0.6885295493956709, 0.9372667262192638, 0.942889387720673, 0.5654227062167685, 0.9815591129304171, 0.6402...
4,179
/***************************************************************************//** * \file initialise.cu * \author Christopher Minar (minarc@oregonstate.edu) */ #include "initialise.h" namespace kernels { /* * sets all the initial u values * param u u velocities * param xu x locations of where u is stored * para...
4,180
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <iostream> #include <cuda.h> // const int N=1280; // const int window=3; __global__ void mean_Filter (int *inputImage, int *outputImage , int window, int N) { window=window/2; int col = blockIdx.x * blockDim.x + threadIdx.x; int row = ...
4,181
#include <stdio.h> #include <stdlib.h> #include <sys/time.h> struct timeval t1, t2; #define BLOCK_SIZE 16 // kernel MM routine __global__ void mmkernel(float *a, float *b, float *c, int N, int M, int K) { int i = threadIdx.x; int j = threadIdx.y; float sum = 0.0f; for (int k = 0; k< M; k++) sum += a[i+N*k] ...
4,182
#include <stdio.h> #include <stdlib.h> // forward declearation void addOne(float *out_h, const float *in_h, int numElements); int main(void) { int numElements = 50000; float *in_h, *out_h; in_h = (float *)malloc(sizeof(float) * numElements); out_h = (float *)malloc(sizeof(float) * numElements); ...
4,183
#include "includes.h" __global__ void kernel_test0_write(char* _ptr, char* end_ptr, unsigned int pattern, unsigned int* err, unsigned long* err_addr, unsigned long* err_expect, unsigned long* err_current, unsigned long* err_second_read) { unsigned int i; unsigned int* ptr = (unsigned int*) (_ptr + blockIdx.x*BLOCKSIZE)...
4,184
#ifndef __CUDACC__ #define __CUDACC__ #endif #include "cuda_runtime.h" #include "device_launch_parameters.h" #include <cuda.h> #include <device_functions.h> #include <cuda_runtime_api.h> #include <curand.h> #include <curand_kernel.h> #include <math.h> #include <stdio.h> #include <random> #include <iomanip> #include <i...
4,185
/* Program : To query the device properties of the Tesla K40c GPU * Author : Anant Shah * Roll Number : EE16B105 * Date : 14-8-2018 **/ #include<stdio.h> #include<cuda.h> #include<stdlib.h> #define DEVICE_ID 0 #define ERROR_HANDLER(error_msg) error_handler(error_msg) void error_handler(cudaError_t error_msg){ ...
4,186
#include <stdio.h> #include <iostream> #include <stdlib.h> using namespace std; __global__ void MM(int m, int k, int n, int *A, int *B, int *C) { int Row = blockIdx.y * blockDim.y + threadIdx.y; int Col = blockIdx.x * blockDim.x + threadIdx.x; if((Row < m) && (Col < k)) { int Cvalue = 0; for(int i = 0; i < ...
4,187
#include "includes.h" __global__ void __hashmult2(int nrows, int nfeats, int ncols, int brows1, int brows2, float *A, float *Bdata, int *Bir, int *Bjc, float *C, int transpose) {}
4,188
#include "includes.h" __global__ void normCalc (float *d_A, float *d_B, int n) { int col = blockIdx.x * blockDim.x + threadIdx.x; __shared__ int row, mu, sigma; if (col < n){ mu = (float)0.0; for (row=0; row < n; row++) mu += d_A[col*n+row]; mu /= (float) n; __syncthreads(); sigma = (float)0.0; for (row=0; row < n; r...
4,189
#include "includes.h" __global__ void DrawMaskedColorKernel(float *target, int targetWidth, int targetHeight, int inputX, int inputY, float *textureMask, int textureWidth, int textureHeight, float r, float g, float b) { int id = blockDim.x * blockIdx.y * gridDim.x + blockDim.x * blockIdx.x + threadIdx.x; int targetPix...
4,190
#include <stdio.h> #include <time.h> /* Measure Time Maximum Matrix Size */ const int TILE_DIM = 32; inline cudaError_t checkCuda(cudaError_t result) { if (result != cudaSuccess) { printf("CUDA Runtime Error: %s\n", cudaGetErrorString(result)); exit(1); } return result; } __global__ void transposeMa...
4,191
extern "C" { __global__ void blur(const long *IN, long *OUT, const int n) { int idx = blockIdx.x * blockDim.x + threadIdx.x; int idy = blockIdx.y * blockDim.y + threadIdx.y; long v = 0; if (!(idx==0 || idx==n-1 || idy == 0 || idy==n-1) ) { for(int i=-1; i<2; i++) { for (int j=-1; j<2; j+...
4,192
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h>
4,193
// //This is a code for the kernel basics and also the error handling //Author: Zhaoyuan "Maxwell" Cui #include<cuda_runtime.h> #include<stdio.h> #define CHECK(call)\ {\ const cudaError_t error=call;\ if(error!=cudaSuccess)\ {\ printf("Error: %s:%d, ", __FILE__, __LINE__);\ printf("code:%d, reason...
4,194
#include "includes.h" __global__ void naive_histo(int *d_bins, const int *d_in, const int BIN_COUNT) { int myId = threadIdx.x + blockDim.x * blockIdx.x; int myItem = d_in[myId]; int myBin = myItem % BIN_COUNT; d_bins[myBin]++; }
4,195
//http://www.bu.edu/pasi/files/2011/07/Lab5.pdf //http://fgiesen.wordpress.com/2009/12/13/decoding-morton-codes/ /* Sort Voronoi using Morton Code */ #include <thrust/device_vector.h> #include <thrust/host_vector.h> #include <cmath> #include <thrust/sort.h> const int n = 4; struct Color{ int blue, green, red; int ...
4,196
#include <cstdio> using namespace std; __global__ void matmul_kernel(const float* A, const float* B, float* C, unsigned int n) { extern __shared__ float arr[]; float* sA = &arr[0]; float* sB = &arr[blockDim.x * blockDim.y]; int bx = blockIdx.x; int by = blockIdx.y; int tx = ...
4,197
#include <cuda.h> #include <stdio.h> #include <cuda.h> #include <curand_kernel.h> #include <time.h> #include <thrust/device_vector.h> #include <thrust/host_vector.h> #include <thrust/sort.h> #include <thrust/copy.h> #include <thrust/random.h> #include <thrust/inner_product.h> #include <thrust/binary_search.h> #include...
4,198
#include <stdio.h> #include <cuda.h> #include <time.h> #define EXPO 3 __global__ void RecursiveDoublingKernel(int variableSize, int step,int blockRow, int blockColumn,float* deviceY,float* deviceM,int evenOrOddFlag,float deviceA,float* deviceB,float* deviceC, float *deviceD) { //we weill do something like y(i+...
4,199
#include <cstdio> #define gpuErrchk(ans) \ { gpuAssert((ans), __FILE__, __LINE__); } inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort = true) { if (code != cudaSuccess) { fprintf(stderr, "GPUassert: %d %s...
4,200
// fermi // Avoid mangling of function names extern "C" { __global__ void vectoraddKernel(const int n, float* c, const float* a, const float* b); } __global__ void vectoraddKernel(const int n, float* c, const float* a, const float* b) { const int bi = blockIdx.x; const int wti = threadIdx.y; const in...