serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
101
#define THETA_N 4 #define SQRT_2 1.4142135623730951f #define PI 3.141592653589793f extern "C" { /** * Clears out the Gabor Energies Tensor, setting all of its values to zero. * The Gabor Energies Tensor is the data structure whose [y, x, theta] value contains the average magnitude response to * the different compl...
102
#include "includes.h" __global__ void k0( float* g_dataA, float* g_dataB, int pitch, int width ) { // global thread(data) row index unsigned int i = blockIdx.y * blockDim.y + threadIdx.y; i = i + 1; //because the edge of the data is not processed // global thread(data) column index unsigned int j = blockIdx.x * block...
103
#include "includes.h" /* Copyright 2014-2015 Dake Feng, Peri LLC, dakefeng@gmail.com This file is part of TomograPeri. TomograPeri is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the L...
104
#include "includes.h" // Optimized using shared memory and on chip memory // Compile source: $- nvcc src/TokamakSimulation.cu -o nBody -lglut -lm -lGLU -lGL // Run Executable: $- ./nBody //To stop hit "control c" in the window you launched it from. //Make movies https://gist.github.com/JPEGtheDev/db078e1b066543ce405800...
105
#include <cmath> __global__ void my_copysign(double* v) { int i = threadIdx.x; *v = std::pow(-1, i) * (*v); }
106
#include <iostream> #include "../ginkgo/GOrderList.h" #include <thrust/device_vector.h> #define def_dvec(t) thrust::device_vector<t> using namespace std; __global__ void test(){ int pos = 0, ppos = 0, pnl = 0; // Creating an OrderList struct gpu_ginkgo::OrderList<100, 10> ggol(true, 1024, 10); ggol.ge...
107
/** * Copyright 2020 Sajeeb Roy Chowdhury * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, * copy, modify, merge...
108
#include "includes.h" __global__ void squareMatrixMult(float *d_a, float *d_b, float *d_result, int n) { __shared__ float tile_a[BLOCK_SIZE][BLOCK_SIZE]; __shared__ float tile_b[BLOCK_SIZE][BLOCK_SIZE]; int row = blockIdx.y * BLOCK_SIZE + threadIdx.y; int col = blockIdx.x * BLOCK_SIZE + threadIdx.x; float tmp = 0; int...
109
#include "includes.h" __global__ void rsqrt_kernel_large(float* x, unsigned int len, unsigned int rowsz) { unsigned int idx = threadIdx.x + blockIdx.x * blockDim.x + blockIdx.y * rowsz; if (idx < len) x[idx] = x[idx] > 0 ? rsqrt(x[idx]) : 0; }
110
#include <cuda_runtime.h> //#include <cublas_v2.h> //#include <cublasXt.h> //#include <cudnn.h> //#include <nccl.h> #include <cassert> #include <chrono> #include <iostream> #define CUDA_CHECK(e) (assert(cudaSuccess == (e))) #define CUBLAS_CHECK(e) (assert(CUBLAS_STATUS_SUCCESS == (e))) #define CUDNN_CHECK(e) (assert(...
111
#include "includes.h" __global__ void kEltwiseL2SVMCost(float* ydata, float* ldata, float* pre_grad, float* all_cost, float a, float b, int numCases, int numTasks, int per_thread_case) { const int task_id = blockIdx.x; const int start_tx = threadIdx.x * per_thread_case; const int end_tx = min(start_tx + per_thread_case...
112
/* Kernel that computes the gradient of an image, being the gradient * the difference between the neighbour pixels and the central pixel * of a cluster. */ __global__ void d_Gradient(float *ptrInputImage, float *ptrGradientImage, int Nx, int Ny, int Nz, int Kx, int Ky, int Kz) { int i, j, k, linearIndex; int Kra...
113
/* * A tutorial program for cuda programming. It implement algorithm of tensordot operation. * * by Steven Liu <stevenliucx@gmail.com> * Nov 26, 2017 * */ #include <stdio.h> #include <cuda.h> #include <unistd.h> #include <time.h> #include <stdarg.h> #include <math.h> #include <iostream> #include <vector> ...
114
#include "includes.h" /*********************************************************** By Huahua Wang, the University of Minnesota, twin cities ***********************************************************/ __global__ void matsub( float* X, float* Y, unsigned int size) { const unsigned int idx = blockIdx.x * bloc...
115
/* * Check grid and block dimensions */ #include<stdio.h> __global__ void checkIndex(void) { printf("threadIdx : (%d,%d,%d) blockIdx : (%d,%d,%d)) blockDim : (%d,%d,%d) gridDim : (%d,%d,%d)\n ",threadIdx.x,threadIdx.y,threadIdx.z,blockIdx.x,blockIdx.y,blockIdx.z,blockDim.x,blockDim.y,blockDim.z,gridDim.x,gridDim.y...
116
#include "includes.h" __global__ void kernel_extract_roi(float* input, float* output, char* mean, const int input_w, const int output_w, const int output_h, const int in_plane_r, const int in_plane_g, const int in_plane_b, const int out_plane_r, const int out_plane_g, const int out_plane_b, const int bbox_x, const int ...
117
#include <cuda.h> #include <cuda_runtime.h> #include <iostream> #include <device_launch_parameters.h> #define N 32 //allocate space for vars; this will end up being the number of blocks to iterate over (we want this to be multiples of 32) __global__ void Caps(char *c, int *b) { int tid = blockIdx.x; if (tid < N) {...
118
#include <cuda_runtime.h> #include <sys/time.h> #include <stdio.h> #include <stdlib.h> #include <curand_kernel.h> #include <math.h> #include <unistd.h> __constant__ int d_n_b[128]; __constant__ double d_mu_nu[128]; //Define some hyperparameters for convenience and clarity. #define p_init_bound 0.5 #define tau0_init 0...
119
#include <stdio.h> #include <stdlib.h> #define N 1000 #define T 256 __global__ void vecInc(int *A,int *newA){ int i; for (i = threadIdx.x;i < N;i = i + T){ newA[i] = A[i] + 1; } } int main (int argc, char *argv[]){ int i; int size = N * sizeof ( int); int a[N], new_a[N], *devA, *dev_newA; ...
120
#include <stdio.h> int N; __global__ void matrixMultGPU(float *a, float *b, float *c,int N) { int k, fil, sum = 0; int col = threadIdx.x + blockDim.x * blockIdx.x; //int fil = threadIdx.y + blockDim.y * blockIdx.y; for(fil=0; fil<N; fil++){ for (k = 0; k < N; k++) { sum += a[fil * N + k] * b[k * N + col]; ...
121
#include "hor.cuh" __global__ void horspool(char *text, unsigned long text_size, char *pattern, int pattern_size, unsigned char hbc[], int stride_length, int *match) { int i; unsigned long thread_id = blockDim.x * blockIdx.x + threadIdx.x; unsigned long start_inx = thread_id * stride_length; ...
122
/* * UpdaterEy1D.cpp * * Created on: 01 февр. 2016 г. * Author: aleksandr */ #include "UpdaterEy1D.h" __device__ void UpdaterEy1D::operator() (const int indx) { Ey[indx] = Ceye[indx] * Ey[indx] - Ceyh[indx]*(Hz[indx] - Hz[indx-1]); }
123
#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 error :...
124
#include "cuda_runtime.h" #include "cuda.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> #include <time.h> #include <iostream> #define iceil(num, den) (num + den - 1) / den #define ARRAY_SIZE 20 //must be an even number; this number/2 = number of points //sets random array and constant ...
125
#include "elementwise.cuh" namespace { template<class T> __device__ T multiplies(const T &lhs, const T &rhs) { return lhs * rhs; } template<class T> __device__ T plus(const T &lhs, const T &rhs) { return lhs + rhs; } } namespace kernels { template<class T> __global__ void vector_add_cuda(const T* const a, const T...
126
#include "includes.h" __global__ void kRMSProp(float *history, float *grad, float factor, int len) { const unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x; const unsigned int numThreads = blockDim.x * gridDim.x; for (unsigned int i = idx; i < len; i += numThreads) { history[i] = sqrt(factor * history[i] * hist...
127
//-nvcc -arch=sm_11 -m64 -O3 main.cu -o atomic.bin #include<iostream> #include<cstdlib> #include <cuda_runtime.h> #include <cassert> #include <vector> #define CHECK_ERROR(call) do { \ if( cudaSuccess != call) { ...
128
#include <stdio.h> #include <string> #include <stdlib.h> #include <cstdio> #include <sstream> #include <iostream> #include <cuda.h> #include <cmath> //initialize 2 5 x 5 matrices represented as an array of floats //each of the entry is equal to its position (i.e. A_00 = 0, A_01 = 1, A_44 = 24) #define checkCUDAErr...
129
#include <stdio.h> #include <math.h> #include <time.h> #include <unistd.h> #include <cuda_runtime_api.h> #include <errno.h> #include <unistd.h> /****************************************************************************** * This program takes an initial estimate of m and c and finds the associated * rms error. It...
130
#include <stdio.h> #include <stdlib.h> #include <math.h> // CUDA kernel. Each thread takes care of one element of c __global__ void vecAdd(int *a, int *c, int n) { // Get our global thread ID int id = blockIdx.x*blockDim.x+threadIdx.x; // c[id]=0; // Make sure we do not go out of bounds if (id < n)...
131
/***************************************************************************//** * \file N.cu * \author Christopher Minar (minarc@oregonstate.edu) * \brief kernels to generate the advection term */ #include "N.h" /** * \namespace kernels * \brief Contains all the custom-written CUDA kernels. */ namespace ke...
132
#include "includes.h" __global__ void gpu_get_neighors(int *neighbors, int n , int k) { for (int off1 = 0; off1 < n/gridDim.x+1 ; off1++) { for(int off2 = 0; off2 < n/blockDim.x+1 ;off2++){ int m = blockIdx.x+off1*gridDim.x; int l = threadIdx.x+off2*blockDim.x; int counter_i =0; if(m<n && l<n){ for (int i = m-(k/2); ...
133
#include "global_defines.cuh" #include <cstdio> #include <cstdlib> void temp_compare(FLOATING *a, FLOATING *b){ int x,y,z; int missed=0; int lx=680, ly=73, lz=73; for (z = 0 ; z< lz ; ++z){ for (y = 0 ; y< ly ; ++y){ for (x = 0 ; x< lx; ++x){ if(abs(a[index(z,y,x)]-b[index(z,y,x)])>0.00001) ++misse...
134
#include "includes.h" __global__ void kernel_push2_atomic( int *g_left_weight, int *g_right_weight, int *g_down_weight, int *g_up_weight, int *g_sink_weight, int *g_push_reser, int *g_pull_left, int *g_pull_right, int *g_pull_down, int *g_pull_up, int *g_relabel_mask, int *g_graph_height, int *g_height_write, int graph...
135
//pass //--blockDim=256 --gridDim=1 --no-inline #include <cuda.h> #include <curand_kernel.h> #include <curand_mtgp32.h> #include <stdio.h> //#include <curand.h> #define N 2 //256 __global__ void curand_test(curandStateMtgp32_t *state, float *A) { A[threadIdx.x] = curand(&state[threadIdx.x]); }
136
//pass //--blockDim=32 --gridDim=2 #include "../common.h" __global__ void Pathcalc_Portfolio_KernelGPU(float *d_v, float *d_Lb) { const int tid = blockDim.x * blockIdx.x + threadIdx.x; const int threadN = blockDim.x * gridDim.x; int i,path; float L[NN], L2[L2_SIZE], z[NN]; float *L_b = L; /* Mon...
137
#include "includes.h" __global__ void Add(float * x, size_t idx, size_t N, float W0, float W1) { for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < N; i += blockDim.x * gridDim.x) { //printf("Adding %f and %f\n",x[(idx-1)*N + i], x[(idx-2)*N + i]); //printf("idx = %d, N = %d, i = %d\n", idx, N, i); //printf("%f %f...
138
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <math.h> #include <cuda.h> #define MASK_N 2 #define MASK_X 5 #define MASK_Y 5 #define SCALE 8 unsigned char *host_s = NULL; // source image array unsigned char *host_t = NULL; // target image array FILE *fp_s = NULL; // ...
139
#include <stdio.h> extern "C" { __global__ void GPU_add( int n, int* d_a, int* d_b ) { for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < n; i += blockDim.x * gridDim.x) { d_a[i] += d_b[i]; } } }
140
__constant__ unsigned int pentanomial[5];
141
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <cstdlib> #include <cstdio> #include <cassert> #include <iostream> #define ULI unsigned long int __global__ void fibonacci_kernel(ULI* a, int start) { unsigned int i = blockIdx.x * blockDim.x + threadIdx.x; unsigned int index = i + sta...
142
#include <stdio.h> #include <stdlib.h> #include <cuda_runtime_api.h> #include <iostream> __global__ void kernel(float * d_matrix, size_t pitch, size_t rows, size_t cols) { int count = 1; for (int j = blockIdx.y * blockDim.y + threadIdx.y; j < rows; j += blockDim.y * gridDim.y) { float* row_d_matr...
143
#include <stdio.h> #include <cuda_runtime.h> int main(void){ int deviceCount; cudaGetDeviceCount(&deviceCount); printf("the avalible device count is %d\n", deviceCount); return 0; }
144
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include "string.h" #define DEFAULT_THRESHOLD 4000 #define DEFAULT_FILENAME "bw_stopsign.ppm" #include <sys/time.h> using namespace std; void write_ppm( char*, int, int, int, int*); unsigned int *read_ppm( char *, int *, int *, int *); ...
145
#include "includes.h" __global__ void kernel_hadamard_sum(int N, double *y, double *x, double *w){ unsigned int tid = blockIdx.x*blockDim.x + threadIdx.x; /* make sure to use only N threads */ if (tid<N) { y[tid]+=x[tid]*w[tid]; } }
146
#include <bits/stdc++.h> using namespace std; #define __ ios_base::sync_with_stdio(false);cin.tie(NULL); #define endl '\n' #define KERNEL_SIZE 3 #define BLOCK_SIZE 4 #define gpu_error(ans) { gpu_assert((ans), __LINE__); } __constant__ int d_cachekernel[KERNEL_SIZE]; inline void gpu_assert(cudaError_t code, int line){...
147
/* * Solves the Panfilov model using an explicit numerical scheme. * Based on code orginally provided by Xing Cai, Simula Research Laboratory * and reimplementation by Scott B. Baden, UCSD * * Modified and restructured by Didem Unat, Koc University * */ #include <stdio.h> #include <assert.h> #include <stdlib...
148
#include <cstdio> #include <cstdlib> #include <cmath> #include <sys/time.h> #define cudaErrChk(ans) { cudaAssert((ans), __FILE__, __LINE__); } inline void cudaAssert(cudaError_t code, const char *file, int line, bool abort=true) { if (code != cudaSuccess) { fprintf(stderr,"CUDA assert: %s %s %d\n", cudaGe...
149
#include <stdio.h> #include <stdlib.h> #define LEN_F 3073 #define TILE_WIDTH 32 // 3073/32 = 97. __global__ void sgd(float *x, float* y, float* weights, float *single_dw, /* dw computed by one data point, with size (3073, 10) */ float reg_strength, float learning_rate, int total_examples...
150
// Compile: nvcc -g -G -arch=sm_61 -std=c++11 assignment5-p4.cu -o assignment5-p4 #include <cmath> #include <cuda.h> #include <iostream> #include <sys/time.h> #define N (1 << 12) #define THRESHOLD (0.000001) #define BLOCK_SIZE 32 using std::cerr; using std::cout; using std::endl; __global__ void kernel1(uint64_t* d...
151
#include <iostream> #include <cuda_runtime.h> #include <cuda.h> #define BDIM 32 CUdevice device; CUcontext context; CUmodule module; CUfunction function; #define module_file "kernel.cubin" #define kernel_name "arr_kernel" void initCUDA() { int deviceCount = 0; CUresult err = cuInit(0); if (err == C...
152
#include "includes.h" using namespace std; #define GAUSS_WIDTH 5 #define SOBEL_WIDTH 3 typedef struct images { char *pType; int width; int height; int maxValColor; unsigned char *data; } image; /** Reads the input file formatted as pnm. The actual implementation supports only P5 type pnm images (grayscale). */ __glo...
153
#include "includes.h" __device__ float sigmoid(float x) { return 1 / (1 + expf(-x)); } __global__ void produceState3(const float* arguments, const int argsSize, const float* weights, const int* topology, const int topSize, float* outStates) { const int tid = threadIdx.x; const int dim = argsSize + topSize; extern __sh...
154
#include <iostream> #include <algorithm> #include <string> #include <cstdio> #include <cstdlib> //#include <ctime> #include <thrust/extrema.h> #include <thrust/device_vector.h> //#include "../lib/cuPrintf.cu" using namespace std; typedef double TNum; #define CSC(call) do { \ cudaError_t e = call; \ if...
155
#include <stdio.h> #include <stdlib.h> #include <math.h> // const int n = 1<<20; // const int blockSize = 1024; // const int gridSize = (int)ceil((float)n/blockSize); __global__ void dotProduct(float *a, float *b, float *c, int n) { extern __shared__ float cache[]; int tId = blockIdx.x*blockDim.x+threadIdx.x...
156
// 必要的头文件 #include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <iostream> // 数组元素相加 __global__ void simple_add(const int *A, const int *B, int *C) { C[threadIdx.x] = A[threadIdx.x] + B[threadIdx.x]; } // 主函数 int main(int arg, char* args[]) { // 待操作的数组 const int size = 10;...
157
#include "includes.h" __global__ void laplacian(float *dst, const float *src, const size_t width, const size_t height, const size_t pixelsPerThread) { const size_t col = (blockIdx.x * blockDim.x + threadIdx.x) % width; const size_t crow = (blockIdx.x * blockDim.x + threadIdx.x) / width * pixelsPerThread; if (col >= w...
158
// Exemplo do Hello World em CUDA // Compilar: make // Executar: qsub job (cluster) #include <stdio.h> #include <stdlib.h> // Funcao executada na GPU, tambem eh chamada de kernel __global__ void kernel () { // No caso eh um kernel que vai para GPU e nao faz nada } int main () { // Informamos ao codigo da CPU que...
159
#include <fstream> #include <iostream> #include <assert.h> #include <stdlib.h> #include <random> #define show(x) std::cout << #x ": " << x << std::endl; #define BLOCKSIZE 128 __global__ void pi(float *blockSums, int stepsPerThread, float dx) { __shared__ float threadSums[BLOCKSIZE]; int id = threadIdx.x + block...
160
//example where there is heavy computation done //using very little data, this example GPU outperforms CPU //by 100 of times at least #include <cstdlib> #include <ctime> #include <iostream> #define TSZ 1024 #define BSZ 1024 #define N (BSZ * TSZ) #define M 100000 #define TT float using namespace std; template <type...
161
#include <thrust/device_vector.h> #include <thrust/sequence.h> #include <functional> #include <iostream> #include <random> #include <stdlib.h> #include <sys/time.h> #include <vector> using namespace std; struct saxpy_functor { const double a; saxpy_functor(double _a) : a(_a) {} __host__ __device__ ...
162
//Cu12 cpp cu combo test.cpp namespace Test012_1{ #define threadPerBlock_12_1 2000 __global__ void kernel(int *dst,int *src,int N){ int id = blockIdx.x * threadPerBlock_12_1 * threadIdx.x; int x = src[id]; int y; if(x >=0){ y = 2*x*x*x+3*x*x*+x+1; }else{ y= -x; } } };
163
#include "includes.h" __global__ void compute_absv(const unsigned int nSpheres, const float* velX, const float* velY, const float* velZ, float* d_absv) { unsigned int my_sphere = blockIdx.x * blockDim.x + threadIdx.x; if (my_sphere < nSpheres) { float v[3] = {velX[my_sphere], velY[my_sphere], velZ[my_sphere]}; d_absv[m...
164
//pass //--blockDim=2048 --gridDim=64 __global__ void foo(int *r) { r[threadIdx.x + blockIdx.x * blockDim.x] = warpSize; }
165
#include "includes.h" using namespace std; __global__ void prescan(float *g_odata, float *g_idata, int n) { extern __shared__ float temp[]; // allocated on invocation int thid = threadIdx.x; int offset = 1; temp[2 * thid] = g_idata[2 * thid]; // load input into shared memory temp[2 * thid + 1] = g_idata[2 * thid +...
166
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <time.h> #include <limits.h> #define OPERATOR * #define OPERATOR_NAME "multiplication" #define DTYPE float void random_ints(int* a, int N) { int i; for (i = 0; i < N; ++i) a[i] = rand(); } void random_floats(float* a, int N) { for (in...
167
__global__ void cudaTransientFstatExpWindow ( float *input, unsigned int numAtoms, unsigned int TAtom, unsigned int t0_data, unsigned in...
168
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> #define N 1025 __global__ void CUDAStrCopy(char *A, char C[N]) { int i = threadIdx.x; C[i] = A[i] - 32; // printf("%c\n", C[i]); } int main() { char A[N]; char C[N]; char *pA, *pC; for (i...
169
//#include <cuda_runtime.h> //#include "device_launch_parameters.h" //#include <helper_cuda.h> ////#include "sm_20_atomic_functions.h" // //#include <thrust/host_vector.h> //#include <thrust/device_vector.h> //#include <thrust/count.h> //#include <stdio.h> // //#define REAL float ////#define USE_CONST_MEM //#define HAN...
170
#include <stdio.h> #include <stdlib.h> #include <cuda_runtime.h> #include <unistd.h> #include <sys/wait.h> #include <sys/time.h> #define VSIZE 1024*50000 #define TSIZE 1024 #define BSIZE VSIZE/TSIZE #define ITE 10 __global__ void add(float* a,float* b){ int idx = blockDim.x * blockIdx.x + threadIdx.x; b[idx] +=...
171
#include <cstdio> #include <cassert> #include <cuda_runtime.h> using namespace std; __global__ void matrix_multiplication(const int *d_indices, const int *d_matrix, const int *d_vector, int *d_output, ...
172
#include "includes.h" __global__ void nmfw(double *a, int r, int c, int k, double *w, double *h, double *wcp)//must be block synchronized!!! { int row = blockIdx.y*blockDim.y + threadIdx.y; int col = blockIdx.x*blockDim.x + threadIdx.x; //compute W if (col < k && row < r) { //ah' double sum = 0.0; double temp = 0.0; f...
173
/* Reference: http://docs.nvidia.com/cuda/cuda-c-programming-guide/index. html#ixzz4CtH09yed */ #include <cstdlib> #include <ctime> #include <cstdio> #include <iostream> #include <iomanip> using namespace std; // Generate random floats between 0 and UP_BOUND #define UP_BOUND 100; // Matrices are stored in row...
174
#include "includes.h" __global__ void cuConvert8uC1To32fC1Kernel(const unsigned char *src, size_t src_stride, float* dst, size_t dst_stride, float mul_constant, float add_constant, int width, int height) { const int x = blockIdx.x*blockDim.x + threadIdx.x; const int y = blockIdx.y*blockDim.y + threadIdx.y; int src_c = ...
175
#include "includes.h" extern "C" { } #define TB 128 #define DISP_MAX 256 __global__ void rho(float *x, int size, float lambda) { int id = blockIdx.x * blockDim.x + threadIdx.x; if (id < size) { x[id] = 1 - exp(-x[id] / lambda); } }
176
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <math.h> #include <cuda.h> #define TIME 500 //# of iterations #define BLKSIZE 24 #define DEBUG(s) {printf("peek "); printf(s); printf("\n");} //#define DEBUG(s) typedef unsigned long long bint; __global__ void simulate(float *src, float* des, bint ...
177
/* Copyright 2018 Maxwel Gama Monteiro Junior 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 Unless required by applicable law or ag...
178
// Copyright (c) 2019-2020, NVIDIA CORPORATION. // 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 // // Unless required by applicable law o...
179
/* LICENSE: this code is subject to the license listed at http://www.amolf.nl/~vanmeel/mdgpu/download.html Among other restrictions, this code is released under the GNU Public License (GPL). Authors: A. Arnold (original) Kipton Barros (modifications) ---- Generate pseudo-random numbers using a linear congruential ge...
180
__global__ void gaussian_blur(const unsigned char *inputChannel, unsigned char *outputChannel, const unsigned int width, const unsigned int height, const float *gaussianKernel, const unsigned int filterWidth) { const unsigned int row = threadIdx.y + blockIdx...
181
/* 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,float* var_2,float var_3,float var_4,float var_5,float var_6,float var_7,float var_8,float var_9,float var_10,float var_11,float var_12,float var_13,float...
182
#include<cstdio> #include<memory> #include<vector> #include<functional> #include<iostream> using namespace std; using fp = void(*)(int*); __global__ void test(int *d_data){ printf("hello world\n"); for(int i = 0;i<10;i++) printf("%d:%d\n",i,d_data[i]); } int uniquePtr(){ cout<<"uniquePtr"<<endl; int *d...
183
#include <stdio.h> #include <stdlib.h> #include <cuda_runtime_api.h> #define BASE_TYPE float __global__ void dot_produce(const BASE_TYPE *a, const BASE_TYPE *b, BASE_TYPE *result, const int N) { extern __shared__ BASE_TYPE s[]; int index = blockDim.x * blockIdx.x + threadIdx.x; s[threadIdx.x] = a[index]...
184
// dacrtplane. A GPU ray tracer using a divide and conquor strategy instead of // partitioning the geometry into a hierarchy. // ----------------------------------------------------------------------------- // Copyright (C) 2012, See authors // // This program is open source and distributed under the New BSD License. S...
185
#include <stdio.h> #include <vector> #include <fstream> #include <iostream> #include <sstream> #include <string> #include <cuda.h> using namespace std; #define THREADS 64 __global__ void last_digits(int* mod, int* data, int n) { int thid = blockIdx.x * blockDim.x + threadIdx.x; if(thid < n) { mod[thi...
186
#include "includes.h" __global__ void set_segmented_nnz_num(int *d_rpt, int *d_col, int *d_nnz_num, int *d_group_seg, int *d_offset, size_t seg_size, size_t seg_num, int M, int pad_M, int group_num_col) { int i = blockIdx.x * blockDim.x + threadIdx.x; if (i >= M) { return; } int width = d_rpt[i + 1] - d_rpt[i]; int ...
187
#include <stdio.h> #include <cuda.h> #include <cuda_runtime.h> extern "C" void cudaInit(size_t sizeA); extern "C" void cudaFinalize(); extern "C" void putGPU(void* h_A, size_t sizeA); extern "C" void getGPU(void* h_A, size_t sizeA); void* d_A; void cudaInit(size_t sizeA){ //allocate memory on device cudaMalloc...
188
/* * * compiling: * nvcc -lglut -LGLEW life.cuda.cu -o life -g -G * * -g -G - debug options * * for it's work: * export LD_LIBRARY_PATH=:/usr/local/cuda/lib * export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/libnvvp/ * * cuda-gdb */ #include "cuda_runtime.h" #include "device_launch_parameters.h"...
189
#include "includes.h" __global__ void LinearFunctionKernelDouble(double a1, double a0, double* input, double* output, int size) { int id = blockDim.x * blockIdx.y * gridDim.x + blockDim.x * blockIdx.x + threadIdx.x; if(id < size) { double x = input[id]; output[id] = a1 * x + a0; } }
190
#include <stdio.h> #include <stdlib.h> #include "cuda.h" // to compile: // nvcc -O0 -o transpose transpose.cu -lm // // to run: // ./transpose 1024 // assume going forward 32x32 threads in each thread-block #define BDIM 32 // reference "copy" kernel __global__ void copy(int N, const float * __restrict__ A,...
191
#include "includes.h" __global__ void transposeKernel(float *inData, float *outData) { __shared__ float tile[TILE_DIM][TILE_DIM + 1]; int x = blockIdx.x * TILE_DIM + threadIdx.x; int y = blockIdx.y * TILE_DIM + threadIdx.y; int width = gridDim.x * TILE_DIM; /* Copying data into shared memory - each thread copies 4 el...
192
// #include <ATen/ATen.h> #include <cuda.h> #include <cuda_runtime.h> #include <cstdio> #include <cmath> #include <iostream> namespace { template <typename scalar_t> __device__ __forceinline__ void single_mul( scalar_t x_re, scalar_t x_im, scalar_t y_re, scalar_t y_im, scalar_t* out_re, scala...
193
#include<stdio.h> #include<stdlib.h> #include<ctype.h> #include<math.h> #include<time.h> __device__ float edo_original(float t) { return 9 * (powf(t, 2)) - 4 * t + 5; } __global__ void euler_method_gpu(float t, float *y, float delta_t, float m) { int tId = threadIdx.x + blockIdx.x*blockDim.x; if(tId < (int) m){ ...
194
#include "includes.h" __global__ static void update_inverse_cuda (float *Ainv, float *u, int N, int rowstride, int k) { __shared__ float A_k[NMAX], u_shared[NMAX], Ainv_u[NMAX], Ainv_shared[NMAX]; A_k[threadIdx.x] = Ainv[k*rowstride+threadIdx.x]; u_shared[threadIdx.x] = u[threadIdx.x]; // First, compute k'th element o...
195
#include "conv.cuh" #include <iostream> void HandleError( cudaError_t err, const char *file, int line ) { if (err != cudaSuccess) { printf( "%s in %s at line %d\n", cudaGetErrorString( err ), file, line ); getchar(); exit( EXIT_FAILURE ); } } void CheckError(void) { #ifdef _DEBUG_PRINTS_ ...
196
#include <cuda_runtime.h> #include <stdio.h> //#include <stdbool.h> extern "C" void MeanFilterCUDA(unsigned char* h_in, unsigned char* h_out, int nKernelSize, int rows, int cols); //template <typename T> __global__ void MeanFilterCUDAkernel(T* pInput, T* pOutput, int nKernelSize, int nHeight, int nWidth) __global__ vo...
197
#include <cuda.h> #include <iostream> using namespace std; __global__ void LocalMaximaKernel_CUDA(float* im_vals, unsigned short* out1, int r, int c, int z, double scale_xy, double scale_z, int offset) { int iGID = blockIdx.x * blockDim.x + threadIdx.x + offset; //global index if (iGID >= r * c * z) return; ...
198
#include "includes.h" __global__ void sax_kernel_large(const float a, const float* x, float* result, unsigned int len, unsigned int rowsz) { unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x + blockIdx.y * rowsz; if (idx < len) result[idx] = a * x[idx]; }
199
#include "math.h" extern "C" const size_t SUB_MATRIX_DIM = 32; extern "C" const size_t SUB_VECTOR_LEN = 256; typedef struct { size_t rows; size_t cols; float *elements; } Matrix; __device__ float *sub_block(Matrix m, int block_row, int block_col) { return m.elements + (block_row * SUB_MATRIX_DIM * m.cols) + ...
200
#include "includes.h" __global__ void GPU_increment_number(int* buffer, int initial) { buffer[0] = 1 + initial; }