serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
22,201
//mexPrintf("GPU: %i %i %i \n",threadcount,numcards,deviceind); //mexPrintf("GPU FLAG is: %s\n", usegpu); //mexPrintf("Made it to the function!\n"); //mexPrintf("Dims: %i %i %i %i \n",ns,nd,nt,nb); //mexPrintf("Cartprobsize: %i \n",cartprobsize); //mexPrintf("Size of datapack: %i \n",sizeo...
22,202
#include "alloc.hh" #include "mode.hh" #include <stdexcept> #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } inline void gpuAssert(cudaError_t code, const char *file, int line) { if (code != cudaSuccess) { throw std::runtime_error {"GPUAssert: " + std::string(cudaGetErrorString(code)) + ...
22,203
#include <stdio.h> #define N 2048 #define BLOCK_COLUMNS 32 #define BLOCK_ROWS 32 __global__ void transpose_naive(float *dev_out, const float *dev_in) { int x = blockIdx.x * BLOCK_COLUMNS + threadIdx.x; int y = blockIdx.y * BLOCK_ROWS + threadIdx.y; dev_out[x*N + y] = dev_in[y*N + x]; } int main(){ ...
22,204
#include <stdio.h> #include <stdlib.h> #include <time.h> // CUDA kernel to pause for at least num_cycle cycles __global__ void sleep(int64_t num_cycles) { int64_t cycles = 0; int64_t start = clock64(); while(cycles < num_cycles) { cycles = clock64() - start; } } // Returns number of cycles r...
22,205
#include<stdio.h> #include<stdlib.h> #include<cuda.h> #include<sys/time.h> #include<math.h> #define ERROR 1.0e-9 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...
22,206
 #include "device_launch_parameters.h" #include <cuda.h> #include <cuda_runtime.h> #include <cuda_runtime_api.h> #include<vector> #include<iostream> #include <cassert> using std::vector; using namespace std; #define THREADS 16 // Forward declaration of the kernel __global__ void matrixMul(const int* a, const int* b...
22,207
__global__ void softmax_back_kernel(float *d_a, float *d_error, float *d_out, float s, int size) { // Get the id and make sure it is within bounds const int id = threadIdx.x + blockIdx.x * blockDim.x; if (id >= size) { return; } d_out[id] = d_a[id] * (d_error[id] - s); }
22,208
#include "includes.h" /* * 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 relat...
22,209
/************************************************************************ * Lorson Blair * 03/29/2020 * Assignment3 * ...
22,210
#include<stdio.h> #include<stdlib.h> #include<cuda.h> #include<time.h> //************variables globales*************** int msk=3, dimx=1040, dimy=1388, tam_imag=1388*1040; //*******************kernel******************** __global__ void varianza (int *Gext_d,float *var_d){ int i, dimy_ext, id_p, M_d[9], dimy=1388,t...
22,211
/* This function is used to read the bits from a text file and return the number of bits as well. If no argument is passed, it will try to read from the same directory from the file "input.txt". Bits should be in one line with no spaces, for example: (100011110) To do so in MATLAB, use this command: dlmwrite('output.t...
22,212
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> #define BlockSize 16 void cpuPearson(float *input, int numRow, int numCol, float *output){ int row, col, i; float x, y, sumX, sumY, sumX2, sumY2, sumXY; float avgX, avgY, varX, varY, cov, rho; for (row=0; row<numRow; row++){ outpu...
22,213
#include <stdio.h> extern "C" __global__ void add_n(int *nums, int n, int size) { nums[threadIdx.x] += n; }
22,214
#include "includes.h" __global__ void Matrix_getCol_FloatId_naive(const float * A, int Acount, int Acols, float * out0, int out0count, int out0cols, float col_id) { int id = blockDim.x*blockIdx.y*gridDim.x + blockDim.x*blockIdx.x + threadIdx.x; if (id < out0count) { out0[id] = A[id*Acols + (int)col_id]; } }
22,215
#include <cuda_runtime.h> #include <stdio.h> __global__ void chechIndex() { } int main(int argc, char const *argv[]) { /* code */ return 0; }
22,216
#include "includes.h" __global__ void bitonicSort2(int *inputArray, const unsigned int stage, const unsigned int passOfStage, const unsigned int width) { int4 *theArray = (int4 *)inputArray; size_t i = blockIdx.x * blockDim.x + threadIdx.x; // get_global_id(0); int4 srcLeft, srcRight, mask; int4 imask10 = make_int4(...
22,217
#include <vector> #include <iostream> __global__ void fill(float * a0,std::size_t size){ auto tid = threadIdx.x; if(tid < size){ a0[tid] = 1.0f; } } int main(){ float *a0_d = nullptr; std::size_t const size =10000000; std::vector<float> a0_h(10); cudaMalloc(&a0_d,size*sizeof(float)); dim3 b...
22,218
/* Copyright (c) 1993-2015, 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 ...
22,219
/* * HyUpdater.cpp * * Created on: 25 янв. 2016 г. * Author: aleksandr */ #include "HyUpdater.h" #include "SmartIndex.h" // indx - индекс вдоль правой или левой границы по y от firstY до lastY __host__ __device__ void HyUpdater::operator() (const int indx) { // correct Hy along left edge // mm = firstX ...
22,220
#include <iostream> #include <fstream> #define N_ROWS 27 #define N_COLUMNS 27 #define PRECISION 1.e-4 // ERROR __device__ bool lIsFinished = false; __host__ __device__ void print_matrix(const float *aMatrix) { printf(" --- MATRIX --- \n"); for (unsigned int lRow = 0; lRow < N_ROWS; lRow++) { for (unsigned ...
22,221
#include "includes.h" __global__ void reduction_kernel(float *g_out, float *g_in, unsigned int size) { unsigned int idx_x = blockIdx.x * blockDim.x + threadIdx.x; extern __shared__ float s_data[]; // cumulates input with grid-stride loop and save to share memory float input = 0.f; for (int i = idx_x; i < size; i += b...
22,222
#include "includes.h" __global__ void modcpy(void *destination, void *source, size_t destination_size, size_t source_size){ int idx = blockIdx.x * blockDim.x + threadIdx.x; int pos; int ds = destination_size/sizeof(int4), ss = source_size/sizeof(int4); for(int i = idx; i < ds; i += gridDim.x * blockDim.x){ pos = i % ...
22,223
#include "includes.h" __global__ void _mean_variance_backward_kernel(float *x, float *grad, float *mean, float *var, int b, int c, int wxh, float *mean_diff, float *var_diff) { int i = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x, j, k, ind; if (i >= c) return; mean_diff[i] = 0; var_diff[i] = 0; f...
22,224
/* myapp_m1.cu ---- Brittle */ /* GPU version */ __global__ void kernel(int *a, int *b) { a[threadIdx.x] += b[threadIdx.x]; } extern "C" { void cukernel(int *a, int *b, int size) { kernel <<<1, size>>>(a, b); } }
22,225
#include "includes.h" __global__ void mul(int *a, int *b, int *c) { *c = *a * *b; }
22,226
/* * cudaComputer.cu * * Created on: 06.12.2011 * Author: id23cat */ #include "cudaComputer.cuh" cudaComputer::cudaComputer() { // TODO Auto-generated constructor stub } cudaComputer::~cudaComputer() { // TODO Auto-generated destructor stub }
22,227
#include "saxpy.c" #include <stdio.h> #include <assert.h> #include <stdlib.h> #include <sys/time.h> __global__ void cuda_saxpy(int num_threads, int n, float a, float *d_x, float *d_y) { int i = threadIdx.x; while(i<n){ d_y[i] = a*d_x[i] + d_y[i]; i = i+num_threads; } } extern "C" int cuda_saxpy_laun...
22,228
#include <stdio.h> #include <stdlib.h> #include <math.h> #include "cuda_runtime.h" #include "device_launch_parameters.h" double c_x_min; double c_x_max; double c_y_min; double c_y_max; double pixel_width; double pixel_height; int iteration_max = 200; int image_size; unsigned char *image_buffer_host; unsigned char...
22,229
#include "includes.h" __global__ void signedGPU(int numTests, int* ns, int* ds, int* qs, int* rs) { for (int i = 0; i < numTests; ++i) { int n = ns[i]; int d = ds[i]; qs[i] = n / d; rs[i] = n % d; } }
22,230
#include<iostream> #include<stdio.h> #include<math.h> #include<stdlib.h> #include<time.h> #define N 4 #define t_per_block 2 using namespace std; void random_ints(int *vec, int size){ for(int i=0; i<size; i++) vec[i] = i; } void random_ints_mat(int *mat, int size){ int k=0; for(int i=0; i<size; i++...
22,231
#include <stdio.h> __global__ void hello(){ printf("Hello from block: %u, thread: %u\n", blockIdx.x, threadIdx.x); } int main(){ hello<<<2,2>>>(); cudaDeviceSynchronize(); }
22,232
#include <cuda_runtime_api.h> #include <device_launch_parameters.h> __global__ static void greyRgbFlatArray(unsigned char *arrIn, unsigned char *arrOut, int imgPoints) { int pointIndex = blockIdx.x * blockDim.x + threadIdx.x; if (3 * pointIndex < imgPoints) { unsigned char grey = 0.299f*arrIn[3*poi...
22,233
#include <cuda.h> #include <stdio.h> __global__ void write(int *ret, int a, int b) { ret[threadIdx.x] = a + b + threadIdx.x; } __global__ void append(int *ret, int a, int b) { ret[threadIdx.x] += a + b + threadIdx.x; } int main() { int *ret; cudaMallocManaged(&ret, 1000 * sizeof(int)); cudaMemAdvise(ret, 10...
22,234
/* William Dreese + Steven Gschwind * t-SNE C baseline for mini project * * Proper import path before compilation: * export PATH=${PATH}:/usr/local/cuda-9.1/bin */ #include <stdio.h> #include <stdlib.h> #include <math.h> #include <cuda.h> #include <sys/time.h> #include <time.h> typedef unsigned long long ull; ...
22,235
/* * CS-4370-90: Par. Prog. Many-Core GPUs * Nathan Dunn * Professor Liu * 10/4/19 * Project 1 - Basic Matrix Multiplication */ #include <stdio.h> #include <cuda.h> // -------- EDIT THESE -------------- #define N 8 // size of the matrix #define BLOCK 4 // size of thread block /** * Performs matrix multiplicati...
22,236
//xfail:BOOGIE_ERROR //main.cu: error: possible read-write race //however, this didn't happen in the tests //altough in CUDA providing the inline keyword should still keep a copy of the function around, //this kind of access is considered a error by ESBMC //ps: the values from A[N-1-offset) to A[N-1] always will receiv...
22,237
#include<cuda_runtime.h> #include<stdio.h> // Kernel definition __global__ void MatAdd(float *A, float *B, float *C) { int i = threadIdx.x; int j = threadIdx.y; *C= *A + *B; } int main() { // Kernel invocation with one block of N * N * 1 threads int numBlocks = 1; int i=0,j=0; float A=5,B=10,C; dim...
22,238
#include "includes.h" /* Kintsakis Athanasios AEM 6667 */ #define inf 9999 __global__ void funct2(int n, int k, float* x, int* qx) { int ix= blockIdx.x*blockDim.x + threadIdx.x; int j=ix&(n-1); float temp2=x[ix-j+k]+x[k*n+j]; if(x[ix]>temp2) { x[ix]=temp2; qx[ix]=k; } }
22,239
#include <stdio.h> #include <assert.h> #include <stdlib.h> #include <iostream> #include <numeric> #include <math.h> #include <cuda.h> int block = 1024; int thread = 1024; __device__ int mandel(float cr, float ci); __device__ int mandel(float cr, float ci){ float zr=0, zi=0, zr2=0, zi2=0; int i; for(i=1;i<256;i++...
22,240
#include "includes.h" __global__ void convolutionGPUkernel_1D(int *h_n, int *h_mascara,int *h_r,int n, int mascara){ int mitadMascara= (mascara/2); int i = blockIdx.x * blockDim.x + threadIdx.x; if(i<n){ int p=0;// almacena los valores temporales int k= i - mitadMascara; for (int j =0; j < mascara; j++){ if(k < n && ...
22,241
extern "C" __global__ void velocity_one(float2* psi1, float2* psi2, int resy, int resz, int num, float hbar, float pi, float* vx, float* vy, float* vz) { int i = blockDim.x * blockIdx.x + threadIdx.x; float2 c1 = make_float2(psi1[i].x, -psi1[i].y); float2 c2 = make_float2(psi2[i].x, -psi2[i].y); ...
22,242
//pass //--blockDim=96 --gridDim=96 // N-queen for CUDA // // Copyright(c) 2008 Ping-Che Chen #define THREAD_NUM 96 /* -------------------------------------------------------------------------- * This is a non-recursive version of n-queen backtracking solver for CUDA. * It receives multiple initial conditions fro...
22,243
template<typename T> __device__ void blockReduce(T *in, T *out, int N) { int idx = blockIdx.x * blockDim.x + threadIdx.x; T sum = 0; for (int i = idx; i < N; i += blockDim.x*gridDim.x) sum += in[i]; sum = blockReduceSum(sum); if (threadIdx.x == 0) out[blockIdx.x] = sum; } template<typename T> __inline__ __de...
22,244
/* This is a automatically generated test. Do not modify */ #include <stdio.h> #include <stdlib.h> #include <math.h> __global__ void compute(float comp, int var_1,int var_2,float var_3,float var_4,float var_5,float var_6,int var_7,int var_8,int var_9,float var_10,float var_11,float var_12,float var_13,float var_14,f...
22,245
#include <iostream> #include <fstream> #include <queue> #include <sstream> #include <string> #include <ctime> #include <assert.h> struct vertex { int start; int numAdj; vertex() { numAdj = 0; start = -1; } }; __global__ void parallelBFS(vertex* V, int* E, bool* q, bool* visited, int* cost, int vertices, ...
22,246
__device__ double a[1024]; __global__ void simple_copy(double *b) { size_t i = threadIdx.x + blockDim.x * blockIdx.x; b[i] = a[i]; }
22,247
#include <iostream> #include <cuda.h> #include <cstdlib> class Unified { public: void *operator new(size_t len) { void *ptr; cudaMallocManaged(&ptr, len); return ptr; } void operator delete(void *ptr) { cudaFree(ptr); } void *operator new[] (std::size_t size) { void *ptr; cudaMallocManaged(&ptr,si...
22,248
//#include "concurrent-xfasttrie-binary.cuh" //#include "Catch2/catch.hpp" //#include "cuda/api_wrappers.h" // //#include "concurrent-xfasttrie-common.cuh" // //using key_type = unsigned int; //using mapped_type = int; //using XFastTrie = ConcurrentXFastTrieBinary<key_type, mapped_type, 3>; // //SCENARIO("CONCURRENT-X-...
22,249
#include<stdio.h> #include<stdlib.h> __global__ void print_from_gpu(void) { printf("Hello World! from thread [%d,%d] \ From device\n", threadIdx.x,blockIdx.x); } int main(void) { printf("Hello World from host!\n"); print_from_gpu<<<1,1>>>(); cudaDeviceSynchronize(); return 0; }
22,250
float h_A[]= { 0.989578244384959, 0.8803930979534609, 0.8731452423484092, 0.912829063757735, 0.7368409915964569, 0.8555867624782871, 0.7208439549661202, 0.6729472044903381, 0.6108810500005013, 0.9758945930071181, 0.9272742469740346, 0.640885193983989, 0.7308171301779263, 0.8899022405476111, 0.7926781782885959, 0.909119...
22,251
#include <iostream> #include <fstream> #include <ctime>// include this header #include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <cuda.h> #include <thrust/extrema.h> #include <thrust/sort.h> #include <thrust/device_ptr.h> #include <iomanip> #include <stdio.h> using namespace std; //nvcc -o tes...
22,252
/* This is based on an example developed by Mark Harris for his NVIDIA blog: http://devblogs.nvidia.com/parallelforall/gpu-pro-tip-cuda-7-streams-simplify-concurrency/ -- I have added some timing to it */ #include <stdlib.h> #include <stdio.h> #include <math.h> #include <cuda.h> const int N = 1 << 20; __global_...
22,253
#include "includes.h" __global__ void initAndUpdate( float *D_oldVal, float *D_currVal, int tpoints, int nsteps ) { int j = blockDim.x * blockIdx.x + threadIdx.x; if ( j < tpoints ) { j += 1; /* Calculate initial values based on sine curve */ /* Initialize old values array */ float x = ( float )( j - 1 ) / ( tpoints - ...
22,254
/* This code is show errors in Cuda code: 1. The maximum nubmer of threads in a block is 1024, so if you set dimBlock to be dimBlock(64,64,1), you will see an error: invalid configuration argument. 2.If the configuration is correct, when you run, you see another error: an illegal memory access was encountered. */...
22,255
/* Babak Poursartip 02/27/2021 CUDA topic: stream. - Instead of using malloc or new to allocation memory on the CPU(host), we use cudaHostAlloc(). This will allocate a pinned memory on the host. - To free the memory, we use cudaFreeHost, instead of delete to deallocate. - The disadvantage is that you cannot swap ...
22,256
//Technique 1 //Count array act as a multiple bucket set //frequent-items-using-CUDA #include<iostream> #include<cuda.h> #include<cuda_runtime.h> #include<stdio.h> #include <stdlib.h> #include<time.h> #include<fstream> using namespace std; __global__ void addKernel(int *a,int *count_d,int *nOfItemSet_d) { int i=blo...
22,257
#include <stdio.h> #include <assert.h> #include <stdlib.h> #include <cuda_profiler_api.h> //#define N 1573700//1310720//262144//131072//262144//83886080 //Quantidade de threads por blocos #define BLOCK_SIZE 32//1//1024//95536 #define nThreadsPerBlock 128//420//128//420 ou 416 #define NFinal (nThreadsPerBlock * 5) /...
22,258
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> // Kernel (funcion) que se invoca desde el Host y se ejecuta en un dispositivo __global__ void suma_vectores(int* c, const int* a, const int* b, int size) { int i = blockIdx.x * blockDim.x + threadIdx.x; if (i < size) { ...
22,259
#include <iostream> #include <stdio.h> #include <math.h> #include <cuda.h> #include <cuda_runtime_api.h> using std::cout; using std::endl; using std::string; template<typename T> void print1D(string const& prefix, int count, T const& value, string const& infix, string const& postfix = "") { cout << prefix; int ...
22,260
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> #define MAXPOINTS 1000000 #define MAXSTEPS 1000000 #define MINPOINTS 20 #define PI 3.14159265 #define TILE_LENGTH 20 void check_param(void); //host void init_line(void); //host void printfinal (void); //host int nsteps, /* nu...
22,261
#include "includes.h" static char* program_name; // Usage __global__ void jacobiOptimizedOnDevice(float* x_next, float* A, float* x_now, float* b, int Ni, int Nj) { // Optimization step 1: tiling int idx = blockIdx.x*blockDim.x + threadIdx.x; if (idx < Ni) { float sigma = 0.0; // Optimization step 2: store index in...
22,262
#include <stdio.h> __global__ void kernel( void ) { } int main(void) { kernel <<<1,1>>>(); printf( "Hello, World!\n" ); return 0; }
22,263
#include <iostream> #include <fstream> #include <iomanip> using namespace std; void rowOperation(float** __restrict__ coefMatrix, float* __restrict__ constMatrix, int row1, int row2, int size) { float scalar = coefMatrix[row1][row2] / coefMatrix[row2][row2]; for(int i = 0; i < size; i++) { coefMat...
22,264
#define t_max 1 #define t 1 /* (u[0][0][0][0][0]=((alpha*(ux[1][0][0][0][1]-ux[-1][0][0][0][1]))+((beta*(uy[0][1][0][0][2]-uy[0][-1][0][0][2]))+(gamma*(uz[0][0][1][0][3]-uz[0][0][-1][0][3]))))) */ __global__ void divergence(float * * u_0_0_out, float * u_0_0, float * ux_1_0, float * uy_2_0, float * uz_3_0, floa...
22,265
#include <stdio.h> #include <stdlib.h> #include <iostream> #include <string> #include <fstream> #include <iomanip> using namespace std; bool checkOutput(string filename1, string filename2); float studentKernelExecTime; int main(int argc, char *argv[]) { if(argc != 3) { cout << "Usage: " << argv[0] << " <stude...
22,266
#include <stdio.h> __global__ void helloFromGPU() { printf("Hello World from GPU! thread\n"); } int main(int argc, char ** argv) { printf("Hello World from CPU!\n"); dim3 block(10,1); dim3 grid(1,1); helloFromGPU <<<grid,block>>>(); cudaDeviceReset(); return 0; }
22,267
#include <algorithm> #include <cassert> #include <cmath> #include <iostream> #include <random> #include <limits> #include <vector> #include <chrono> constexpr auto VECTOR_LENGTH = 1024u * 1024u * 16u; constexpr auto EPS = 1e-6f; #define GPU_CHECK(ans) { gpuAssert((ans), __FILE__, __LINE__); } inline void gpuAssert(c...
22,268
/* libcudann Copyright (C) 2011 Luca Donati (lucadonati85@gmail.com) */ /* * CudaActivationFunctions.cu * * Created on: Jan 10, 2011 * Author: donati */ #include "CudaActivationFunctions.cuh" #include <stdlib.h> #include <stdio.h> #define BLOCKSIZE 512 #define clip(x, lo, hi) (((x) < (lo)) ? (lo) : (((x...
22,269
// Jim Samson // 04 April 2019 // Cuda Minimum Finding // Homework Part 2 // #include <stdio.h> #include <limits.h> #define HIGHEST_VALUE 8000000 #define THREADS 8 __global__ void findLowest(int numMin, int *array_val, int *cudaResult ) { int low = threadIdx.x * numMin; int high = low + numMin -1; int m...
22,270
#include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <cuda_runtime.h> using namespace std; __global__ void multi(int * dA, int *dB, int * dC, int rowWidth, int colWidth){ //int id = threadIdx.x + blockIdx.x * blockDim.x; int value = 0; for (int i = 0; i < blockDim.x; i++) value += dA[blockDim.x * bl...
22,271
// Teebone's first CUDA programming #include <stdio.h> // kernel function in GPU __global__ void square_num(float* a, int n) { int id = blockIdx.x*blockDim.x + threadIdx.x; if(id < n) a[id] = a[id]*a[id]; } #define N 10 #define block_size 4 //main routine int main(){ float *a_host, *a_cuda; a...
22,272
#include<stdio.h> #include<stdlib.h> #define SIZE 1024*1024*1024 __global__ void VectorAdd(int *a, int *b, int *c, int n){ //void VectorAdd(int *a, int *b, int *c, int n){ int i=threadIdx.x; if ( i<n-10){ a[i]=b[i]*a[i+1]*a[i+2]; b[i]=a[i+1]+b[i+1]*a[i+4]; c[i]=a[i+1]*a[i]*a[i+1]*b[i]*b[...
22,273
#include "includes.h" __global__ void GPUVectorSum(int * a, int * b, int * c, int VECTOR_QNT) { int n = VECTOR_QNT; int idx = blockIdx.x * blockDim.x + threadIdx.x; for (int i = idx; i < n; i += blockDim.x * gridDim.x) { c[i] = a[i] + b[i]; } }
22,274
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <malloc.h> #include <string.h> #include <math.h> // perform: weights = weights - learning_rate * delta_weights // delta_weights = (1/data_count) * delta_mat * in_mat^T // delta_mat: matrix of delta [row,column] = [n...
22,275
#include <thrust/sort.h> // version 0 // global memory only interleaved version // include comments describing your approach __global__ void histogram_global_kernel(unsigned int *input, unsigned int *bins, unsigned int num_elements, unsigned int num_b...
22,276
/* * HzUpdater.cpp * * Created on: 01 февр. 2016 г. * Author: aleksandr */ #include "HzUpdater.h" #include "SmartIndex.h" // indx - индекс вдоль правой или левой границы по y от firstY до lastY __host__ __device__ void HzUpdater::operator() (const int indx) { // correct Hz along left edge /*mm = firstX ...
22,277
/* * transpose an array */ #include <stdio.h> #include <stdlib.h> void nonCudaTranspose(float* out, float *in, int size); void startClock(char*); void stopClock(char*); void printClock(char*); #define DIM 1024 int main(int argc, char** argv) { float *h_in; float *h_out; h_in = (float*) malloc(DIM*DIM*sizeof...
22,278
#include <iostream> #include <fstream> #include <chrono> #include <math.h> #include <thrust/execution_policy.h> #include <thrust/functional.h> #include <thrust/extrema.h> #include <thrust/count.h> #include <thrust/remove.h> #include <thrust/device_vector.h> using namespace std; static const int BLOCK_SIZE = 256; // ...
22,279
#include <stdio.h> #include <stdlib.h> #include <unistd.h> __global__ void saxpy(unsigned num_rd_streams, unsigned addr1, unsigned addr2, unsigned addr3, unsigned addr4, unsigned addr5, unsigned addr6, unsigned addr7, unsigned addr8, unsigned num_wr_streams, int dummy, float *x) { __shared__ float A[1000]; int id = ...
22,280
#include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <sys/time.h> /* HOMEWORK 1 */ /* Huan Truong <huantruong@mail.missouri.edu> */ /* Based on Becchi M.'s code */ #define NO_EDGE_FND -1 #define LIST_END -1 /* The device number we will use */ /* It's better to be able to specify the device * that we'l...
22,281
// IFF-6/11 Nerijus Dulke L4b #include <stdio.h> #include <iostream> #include <iomanip> #include <fstream> #include <string> #include <thrust/host_vector.h> #include <thrust/device_vector.h> using namespace std; // masyvu skaicius const int N = 4; // automobiliu skaicius masyve const int K = 10; // maksimalus pavadin...
22,282
/* * This sample implements a separable convolution * of a 2D image with an arbitrary filter. */ #include <stdio.h> #include <stdlib.h> #include <time.h> #include "cuda.h" //unsigned int filter_radius; #define filter_radius 16 #define FILTER_LENGTH (2 * filter_radius + 1) #define ABS(val) ((val)<0.0 ? (-(val)) :...
22,283
// this version of the kernel supports PE // this is the pixel dependent field variation from rot to rot expressed in radians __device__ void multiply_2complex( float a_re,float a_im, float b_re,float b_im, float *c_re,float *c_im ) { *c_re = a_re*b_re - a_im*b_im; *c_im = a_re*b_im + a_im*b_re; ...
22,284
/* \(arr_0 :: Array Double[], arr_1 :: Array Double[]) -> let { v_17 :: Int32 = min (dim#0 arr_0) (dim#0 arr_1) } in { vec_alloca_2 :: Array Double[] <- alloc (Array Double[])[v_17] ; call (\(arr_0 :: Array Double[], arr_1 :: Array Double[], v_17 :: Int32, vec_alloca_2 :: Array Double[]) -> ...
22,285
#include "includes.h" __global__ void kernel6( int *a, int dimx, int dimy ) { }
22,286
extern "C" __global__ void fSigmoid( const float* arguments, float* results, const long size ) { const int X = gridDim.x; const int index = gridDim.y * X * threadIdx.x + X * blockIdx.y + blockIdx.x; if(index < size) { results[index] = 1.f / (1.f + expf(-arguments[index])); } } extern "C" __glo...
22,287
#include <stdio.h> #include <assert.h> #include <iostream> #include <math.h> #include <stdlib.h> #include <string.h> #include <sys/time.h> #define SZ 768 #define TOTITER 100000000 #define THRDS 50 #define BLCKS 5 void checkCUDAError(const char* msg); __host__ __device__ float Y_Model(float W1,float W2,float B,float...
22,288
#include "includes.h" __global__ void ThresholdKernel(float min, float max, int mode, float* input, float* output, int size, int count) { int id = blockDim.x * blockIdx.y * gridDim.x + blockDim.x * blockIdx.x + threadIdx.x; __shared__ float delta; if(id < size) { if (threadIdx.x == 0) delta = (max - min)/count; __syn...
22,289
#include "includes.h" __global__ void MatrixMulSh( float *Md , float *Nd , float *Pd , const int WIDTH ) { //Taking shared array to break the MAtrix in Tile widht and fatch them in that array per ele __shared__ float Mds [TILE_WIDTH][TILE_WIDTH]; __shared__ float Nds [TILE_WIDTH][TILE_WIDTH]; // calculate thread id u...
22,290
#include <chrono> #include <stdio.h> #define GRID_DIM 39063 #define BLOCK_DIM 256 using namespace std; __global__ void kernel_new(int *data) { int _tid_ = threadIdx.x + blockIdx.x * blockDim.x; if (_tid_ >= 10000000) return; int idx_0 =_tid_ / 500000; int idx_1 = (_tid_ / 1000) % 500; int idx_...
22,291
/** * 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 relat...
22,292
/** * Demo code of Cuda programming lecture * * This programme is a simple implementation of vector addition in CUDA * * */ #include <sys/time.h> #include <cstdlib> #include <cstdio> // Device code __global__ void VecAdd(int* A, int* B, int* C) { int i = blockDim.x * blockIdx.x + threadIdx.x; C[i] = A[...
22,293
#if GOOGLE_CUDA #define EIGEN_USE_GPU /* #include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor" */ __global__ void AddOneKernel(const float* in, const int N, float* out) { for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < N; i += blockDim.x * gridDim.x) { out[i] = in[i] + 1; } } void...
22,294
/* * AES 128, 192, 256 bits implementation on CUDA. * Part of the crypto-cuda project. * * This file is in the public domain. * */ #include <stdio.h> #include <stdint.h> #include <time.h> #define NUM_THREADS 256 uint8_t s_box[] = { 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, ...
22,295
#include <algorithm> #include <stdio.h> #include "cuda_profiler_api.h" /* Scratch space positions */ const int max_ns = 1024; const int lower_delta_pos = 0; const int mid_delta_pos = lower_delta_pos + max_ns; const int upper_delta_pos = mid_delta_pos + max_ns; const int lower_gamma_pos ...
22,296
/* jacobi.c - Poisson problem in 3d * */ #include <math.h> #include <stdio.h> __device__ void print_matrix2(double*** A, int N){ int i,j,k; for (i=0; i<N; i++){ printf("\n %d -th Layer \n", i); for(j=0; j<N; j++){ for(k=0; k<N; k++){ printf("%lf \t", A[i][j][k]); } printf("\n"); } } } __globa...
22,297
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <fstream> #include <math.h> #include <cuda.h> #include <time.h> // Global Variables #define dim_matrix 8192 #define inf 1000000 #define error 1e-3 #define damping 0.8 #define blockSize 128 __global__ void parMult(double *TM,double *v,double *output){ ...
22,298
#include <stdio.h> // カーネル関数 __global__ void helloFromGPU(){ if(threadIdx.x == 5){ printf("Hello World form GPU! thread %d\n",threadIdx.x); } } int main(int argc, char **argv){ printf("Hello World from CPU!\n"); // カーネル関数の呼び出し helloFromGPU<<<1, 10>>>(); cudaDeviceReset(); return 0; }
22,299
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> cudaError_t addWithCuda(int *c, const int *a, const int *b, unsigned int size); cudaError_t squareWithCuda(int *c, const int *a, unsigned int size); __global__ void addKernel(int *c, const int *a, const int *b) { int i = threadId...
22,300
#include <iostream> #include <fstream> using namespace std; int countOnes(int** A, int row, int col) { int count = 0; for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { if (A[i][j] == 1) count++; } } return count; } int main(int argc, char* argv[]) { if (a...