serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
23,501
#include "includes.h" __global__ void kernel(float *id, float *od, int w, int h, int depth) { int x = blockIdx.x * blockDim.x + threadIdx.x; int y = blockIdx.y * blockDim.y + threadIdx.y; int z = blockIdx.z * blockDim.z + threadIdx.z; const int dataTotalSize = w * h * depth; const int radius = 2; const int filter_...
23,502
#include <stdio.h> #include <stdlib.h> #include <cuda.h> #define DATA_TYPE 0 // 0-SP, 1-INT, 2-DP #define VECTOR_SIZE 60000000 #define TILE_DIM 1024 #define COMP_ITERATIONS 8192 #define KERNEL_CALLS 1 template <class T> __global__ void simpleKernel2(int size, int compute_iters, int tile_dim) { __shared__ T share...
23,503
#include "includes.h" __global__ void cudaSpow_kernel(unsigned int size, float power, const float *x, float *y) { const unsigned int index = blockIdx.x * blockDim.x + threadIdx.x; const unsigned int stride = blockDim.x * gridDim.x; for (unsigned int i = index; i < size; i += stride) { y[i] = powf(x[i], power); } }
23,504
#include <stdio.h> #include <iostream> #include <cuda_profiler_api.h> //#include <cutil.h> #include <cuda_runtime.h> #define GPUJOULE_DIR "" #define SHARED_MEM_ELEMENTS 1024 int num_blocks; int num_threads_per_block; int num_iterations; int divergence; float* h_A; float* h_B; float* h_C; float* h_res; float* d_A; f...
23,505
#include <cuda_runtime.h> #include <device_launch_parameters.h> #include <stdlib.h> #include <stdio.h> #include <math.h> #include <assert.h> __global__ void vectorAdd(int* a, int* b, int* c, int n){ int tid = (blockIdx.x * blockDim.x) + threadIdx.x; if (tid < n){ c[tid] = a[tid] + b[tid]; } } voi...
23,506
#include "includes.h" __global__ void d_updateTransforms (float* d_currentTransform, float3* d_cameraPosition) { d_cameraPosition->x = d_currentTransform[3]; d_cameraPosition->y = d_currentTransform[7]; d_cameraPosition->z = d_currentTransform[11]; }
23,507
#include<stdio.h> __global__ void kernel(int * a, unsigned long int n) { unsigned long long int i = blockDim.x*blockIdx.x+threadIdx.x; if(i<n) a[i] += a[i]*0.5; } int main() { unsigned long int N = 2509892096; int * A = (int *) malloc(N * sizeof(int)); int * B; cudaMalloc(&B, N * sizeof(int)); cudaMemcpy(B,A...
23,508
/* * pthreaded hw5, written by Adam Tygart abd Ryan Hershberger * Could be further optimized by pipelining read operations and not cyclically creating/destroying child threads */ #include <stdio.h> #include <stdlib.h> #include <string.h> /* * Length of "lines changes with every protein" * Thanks to wikipedia for ...
23,509
#include <cuda_runtime_api.h> #include <stdio.h> int main() { int device_id = 0; // ID of the GPU device to query cudaDeviceProp prop; cudaGetDeviceProperties(&prop, device_id); int reservedShared = prop.reservedSharedMemPerBlock; printf("Reversed Shared Memory per Block: %d bytes\n", reservedShared); r...
23,510
#include <bits/stdc++.h> #include <thrust/device_vector.h> #include <thrust/host_vector.h> #include <thrust/copy.h> #define to_ptr(x) thrust::raw_pointer_cast(&x[0]) #define gpu_copy(x, y) thrust::copy((x).begin(), (x).end(), (y).begin()) using namespace std; const int BLOCK_SIZE = 1024; const int SHARE_SIZE = 1024; ...
23,511
#include "includes.h" __global__ void kDumbSumCols(float* mat, float* vec, unsigned int width, unsigned int height) { const unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x; mat += idx; if (idx < width) { float sum = 0; for (int j = 0; j < height; j++) { sum += *mat; mat += width; } vec[idx] = sum; } }
23,512
// // Created by root on 2020/11/24. // #include "curand_kernel.h" #include "cuda_runtime.h" #include "stdio.h" __global__ void device_api_kernel(curandState *states, float *out, int N) { int tid = threadIdx.x + blockIdx.x * blockDim.x; // init curand state for each thread curand_init(9444, tid, 0, states...
23,513
#include "includes.h" __global__ void InterpolateVectorKernel( int r, int q, int f, int inputSize, float *referenceVector ) { int threadId = blockDim.x*blockIdx.y*gridDim.x //rows preceeding current row in grid + blockDim.x*blockIdx.x //blocks preceeding current block + threadIdx.x; if(threadId < inputSize) { ref...
23,514
/* Problem - Paralelno programiranje Naci najveci poligon od ucitanih tacaka */ #include<cuda_runtime.h> #include<stdio.h> #include<stdlib.h> #include<math.h> #define TPB 16 __global__ void calculate(double *x, double *y, double *z, double *out, int n){ int index=threadIdx.x+blockIdx.x*blockDim.x; __shared__ ...
23,515
// CUDA libraries. #include <cuda.h> #include <cuda_runtime.h> // Include associated header file. #include "../include/cuda_kernel.cuh" /** * Sample CUDA device function which adds an element from array A and array B. * */ __global__ void cuda_kernel(double *A, double *B, double *C, int arraySize){ // Get thre...
23,516
#include "includes.h" __global__ void readLocalMemory(const float *data, float *output, int size, int repeat) { int gid = threadIdx.x + (blockDim.x * blockIdx.x), j = 0; float sum = 0; int tid=threadIdx.x, localSize=blockDim.x, grpid=blockIdx.x, litems=2048/localSize, goffset=localSize*grpid+tid*litems; int s = tid; __...
23,517
#include <stdio.h> __global__ void kernel(void) { printf("Hello from block (%d,%d,%d), thread (%d,%d,%d) of the GPU\n", blockIdx.x, blockIdx.y, blockIdx.z, threadIdx.x, threadIdx.y, threadIdx.z); } int main (void) { dim3 numBlocks(1,2,3); dim3 threadsPerBlock(1,2,3); kernel<<<numBlocks, thr...
23,518
//xfail:BOOGIE_ERROR //--blockDim=128 --gridDim=128 --warp-sync=32 --no-inline //kernel.cu: error: possible read-write race on A //It fail to dim >= 128, because it can't synchronize. #include <stdio.h> #include <cuda.h> #define N dim*dim #define dim 2//128 //64 __global__ void foo(int* A) { A[ blockIdx.x*blockDi...
23,519
/* 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,float var_7,float var_8,float var_9,float var_10,float var_11,float var_12,float var_13,float va...
23,520
/* skeleton code for assignment2 COMP4901D xjia@ust.hk 2015/03 */ #include <iostream> #include <cstdio> #include <cmath> #include <cuda_runtime.h> #include <device_launch_parameters.h> #include <thrust/sort.h> #include <thrust/device_vector.h> using namespace std; const int TILE_WIDTH = 1024; __global__ void merge...
23,521
#include "includes.h" __global__ void square(float * d_out, float * d_in) { const unsigned int lid = threadIdx.x; const unsigned int gid = blockIdx.x*blockDim.x + lid; float f = d_in[gid]; d_out[gid] = f * f; }
23,522
#include <iostream> #include <cmath> #include <vector> #include <time.h> #define checkCudaErrors(val) check_cuda( (val), #val, __FILE__, __LINE__ ) void check_cuda(cudaError_t result, char const *const func, const char *const file, int const line) { if (result) { std::cerr << "CUDA error = " << static_cast<unsig...
23,523
#include <cuda.h> int main() { return 0; }
23,524
#include <iostream> #include <cuda_runtime.h> #include <device_launch_parameters.h> using namespace std; int main(int argc, char **argv) { // Get number of devices on system int deviceCount; cudaGetDeviceCount(&deviceCount); cout << "Number of devices: " << deviceCount << endl; for (int i = 0; ...
23,525
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> __global__ void print_warps_details() { int gbid = blockIdx.y * gridDim.x + blockIdx.x; int gid = gbid * blockDim.x + threadIdx.x; int wid = threadIdx.x / 32; printf("tid : %d, bid : [%d, %d], gid : %d, w...
23,526
#include <cstdio> #define EMPTY 0 #define WHITE 1 #define BLACK 2 #define QUEENW 11 #define QUEENB 22 struct checkers_point{ int board[64]; int how_much_children; checkers_point * children = NULL; checkers_point * next = NULL; checkers_point * prev = NULL; checkers_point * parent = NULL; c...
23,527
/* ============================================================================ Name : GScuda.cu Author : caleb Version : Copyright : Your copyright notice Description : CUDA compute reciprocals ============================================================================ */ #include <iostream...
23,528
/* Matrix normalization. * Compile with "gcc matrixNorm.c" */ #include <stdio.h> #include <stdlib.h> #include <time.h> #include <sys/time.h> #include <math.h> /* Program Parameters */ #define N 9000 /* Matrix size */ /* Matrices */ volatile float A[N][N], B[N][N]; // Flattened array A & B float flattenA[N * N], f...
23,529
// CUDA przykład (c) Andrzej Łukaszewski 2010 // Dodawanie macierzy na GPU: kompilacja: nvcc addmat.cu #include <stdio.h> __global__ void AddMatrixKernel1(float *A, float *B, float *C, int N){ int adres = threadIdx.x + N * blockIdx.x; C[adres] = A[adres] + B[adres]; } void GPUMatrixAdd(float ...
23,530
// // Created by steve on 3/15/2021. // #include <deque> #include <iostream> #include <string> std::string getDimsExceptionString(const std::deque<unsigned long long>& dims) { std::string err = "( "; if(dims.size() != 0) { for(unsigned long long i = 0;i<dims.size()- 1; i++) { e...
23,531
// testing usage of thrust vectors #include <iostream> #include <cmath> #include <cuda.h> #include <cuda_runtime.h> #include <curand_kernel.h> #include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <thrust/transform.h> #include <thrust/transform_reduce.h> #include <thrust/sequence.h> #in...
23,532
/* * This sample implements a separable convolution * of a 2D image with an arbitrary filter. */ #include <stdio.h> #include <stdlib.h> #include <time.h> #define MAX_XY 32 #define ABS(val) ((val)<0.0 ? (-(val)) : (val)) #define accuracy 0.00005 #define TILE_H 32 #define TILE_W 32 #define FILTER_RADIUS 32 #defin...
23,533
#include "includes.h" __global__ void THCudaTensor_kernel_indexFill( float *tensor, long* stride, float *index, long src_nDim, int dim, long idx_size, long tensor_size, long size_dim, float val ) { int thread_idx = blockIdx.x * blockDim.x * blockDim.y + threadIdx.y * blockDim.x + threadIdx.x; long flat_size = tensor_s...
23,534
#include<cuda_runtime.h> #include<stdio.h> #include<stdlib.h> #include<math.h> __global__ void add(float* x,float* y,int* n) { int id=blockIdx.x*blockDim.x+threadIdx.x; if(id<*n) y[id]=sinf(x[id]); } int main() { float a[100],res[100],*da,*db; int *dn; int n; printf("Enter size"); scanf("%d",&n); printf("...
23,535
#include <stdio.h> #define SIZE_TEXT (sizeof(text)-1) #define SIZE_END (sizeof(end)-1) __device__ char text[] = "__ bottles of beer on the wall, __ bottles of beer!\n" "Take one down, and pass it around, ## bottles of beer on the wall!\n\n"; __device__ char end[] = "01 bottle of beer on the wall, 01 bottle of beer.\...
23,536
#include <cuda.h> #include <cuda_runtime_api.h> #include <stdio.h> #include <iostream> #include <string.h> #include <algorithm> #include <stdlib.h> #define N 4 #define BLOCK_SIZE 4 #define GRID_SIZE 1 void cuda_error_check(cudaError_t err , const char *msg ) { if(err != cudaSuccess) { printf("The error ...
23,537
// sort_by_key.cpp : Defines the entry point for the application. // #include <thrust/sort.h> #include <thrust/functional.h> template <typename T> void print_array(const T* array, const int size) { for (int i = 0; i < size; ++i) { std::cout << array[i] << ", "; } std::cout << std::endl; } int main() { // Te...
23,538
#include <cstdio> int getThreadNum() { cudaDeviceProp prop; int count; cudaGetDeviceCount(&count); printf("gpu num %d\n", count); cudaGetDeviceProperties(&prop, 0); printf("max thread num : %d\n", prop.maxThreadsPerBlock); printf("grid dimensions : %d %d %d\n", prop.maxGridSize[0], prop.maxGridSize[1], prop.m...
23,539
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> #include <math.h> /* round() */ typedef struct bmpFileHeader { /* 2 bytes de identificación */ unsigned int size; /* Tamaño del archivo */ unsigned short resv1; /* Reservado */ unsigned short resv2; /* Reser...
23,540
#include "includes.h" __global__ void kernel_update_models(float4* d_positions, float4* d_modelBuffer, int numel) { size_t col = threadIdx.x + blockIdx.x * blockDim.x; if (col >= numel) { return; } d_modelBuffer[col*4+3] = make_float4( d_positions[col].x, d_positions[col].y, d_positions[col].z, 1 ); __syncthreads(); ...
23,541
#include <thrust/device_vector.h> #include <thrust/random.h> #include <iostream> struct fillRng { thrust::uniform_real_distribution<double> distribution; thrust::default_random_engine rng; fillRng(thrust::uniform_real_distribution<double> dist, thrust::default_random_engine engine) { distribution ...
23,542
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> #include <math.h> __device__ int getTid() { int bid = blockIdx.y * gridDim.x + blockIdx.x; int tid = threadIdx.y * blockDim.x + threadIdx.x; int tPB = blockDim.x * blockDim.y ; int fin = bid*tPB+tid; return fin;...
23,543
/* Group info: nphabia Niklesh Phabiani rtnaik Rohit Naik anjain2 Akshay Narendra Jain */ #include <stdlib.h> #include <stdio.h> #include <cuda_runtime.h> #include <time.h> #define __DEBUG #define CUDA_CALL( err ) __cudaSafeCall( err, __FILE__, __LINE__ ) #define CUDA_CHK_ERR() __cudaCheckError(__FILE__,__LINE__...
23,544
/* helloWorld example for CUDA compile with: > nvcc -arch=sm_20 hello_cuda.cu run with: > ./a.out */ #include <stdio.h> #include <stdlib.h> #include <cuda.h> #define N 10 // cuda kernel (runs on GPU) __global__ void sum_kernel(float* A,float* B, float* C, float* sum, int nmax) { // thread id ...
23,545
/************************************************************************************ PEMG-2010 June 21-24, 2010 Source Code : sharedMemoryRestructuringDataTypes.cu Objective : This code demonstrates achievable shared memory bandwidth for different inbuilt data types Descr...
23,546
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <cuda_runtime.h> // CUDA Kernel __global__ void matrixMul( float* C, float* A, float* B, int TM) { float cc; int k; // calcul des coordonnees du thread int i = blockIdx.x; int j = threadIdx.x; cc = 0.; // calcul de c[i][j] ...
23,547
#include "cuda_runtime.h" #include <stdio.h> __global__ void PF_iteration_kernel(int t) { }
23,548
//2 layered neural network with LIF neurons //computing Vm in parallel, Computing Isyn //all-all connectivity between 2 layers //starting point of reading mnist set by 'start' //test: Test the trained mnist network on the images of handwritten #include<stdio.h> #include<math.h> #include<time.h> #include<stdlib.h> #i...
23,549
#include "includes.h" __global__ void sum( float4 *a, float4 *b, int N ) { int idx = threadIdx.x + blockDim.x * blockIdx.x; if( idx < N ) { float4 t1 = a[idx]; float4 t2 = b[idx]; t1.x += t2.x; t1.y += t2.y; t1.z += t2.z; t1.w += t2.w; a[idx] = t1; } }
23,550
#include <cuda_runtime.h> #include <iostream> #include "bfs.cuh" using namespace std; int main() { // test data int V[] = {0, 1, 2, 3, 5, 6, 7, 8, 9}; // the last one is not a vetex int E[] = {1, 3, 1, 2, 4, 5, 7, 4, 6}; int C[] = {0, INF, INF, INF, INF, INF, INF, INF}; cudaBfs(V, E, C, 8, 9, 0); cout << "Sh...
23,551
/* File: matmult-cuda-double.cu * * Purpose: * * Input: * * Output: * * Compile: nvcc -o matmult-cuda-double.o matmult-cuda-double.cu * * Run: ./matmult-cuda-double.o * * Algorithm: * * Note: * * */ #include <stdio.h> #include <cuda_runtime.h> __global__ void VecAdd(double* A, double* B, do...
23,552
#include <iostream> #include <math.h> #include <sys/time.h> // provides resolution of 1 us //Number of threads in one thread block #define THREAD_NUM (256) // cuda kernel to add the 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(...
23,553
#include <stdio.h> #include <assert.h> #include <time.h> #include <cuda.h> #define BLOCK_LOW(id,p,n) ((id)*(n)/(p))l; #define BLOCK_HIGH(id,p,n) (BLOCK_LOW((id)+1,p,n)-1); #define BLOCK_SIZE(id,p,n) (BLOCK_LOW((id)+1,p,n)-BLOCK_LOW(id,p,n)); #define BLOCK_OWNER(index,p,n) (((p)*((index)+1)-1)/(n)); int inputvalues[8] ...
23,554
/* * ===================================================================================== * * Filename: glsltest_cuda.cu * * Description: * * Version: 1.0 * Created: 2016年08月11日 18時15分02秒 * Revision: none * Compiler: gcc * * Author: YOUR NAME (), * Org...
23,555
extern "C" __global__ void deltasBatch(float *inputs, float *outputs, float *weights, float *weightsDeltas, int noInputs, int inputSize){ int gid = blockIdx.x * blockDim.x + threadIdx.x; float sum=0; int offsetDeltas = (inputSize+1)*gid; int offsetInput = noInputs*inputSize*gid; int offsetOutputs = noInputs*gid; ...
23,556
#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 :...
23,557
#include <iostream> #include <math.h> // Kernel function to determine depth of mandelbrot at cr, ci __device__ unsigned int mandelDepth(float cr, float ci, int maxDepth) { float zr = 0.0f; float zi = 0.0f; float zrSqr = 0.0f; float ziSqr = 0.0f; unsigned int i; for (i = 0; i < maxDepth; i++) ...
23,558
#include <stdio.h> #include <cuda.h> #include <time.h> #define m(y,x) mapa[(y * cols) + x] /*Definición de constantes*/ #define currentGPU 0 //El número más alto suele indicar la salida de vídeo #define MAX 50 typedef struct { int y; int x; } Antena; __global__ void gpu_init(int *mapad, int max, int size) { /*I...
23,559
#include "includes.h" __global__ void GaussianEliminationGlobal(const int clusterSize,float *x, const float *diagonal_values , const float *non_diagonal_values ,float *y , const int size) { const int index = blockIdx.x * blockDim.x + threadIdx.x ; const int gi = index * clusterSize; float matrix[180][180]; //size of m...
23,560
#include<cuda.h> #include<stdio.h> #include<stdlib.h> #include<iostream> #define CHECK 0 const unsigned int SINGLE_PRECISION = 1; const unsigned int DOUBLE_PRECISION = 0; float *SMd, *SNd, *SPd; double *DMd, *DNd, *DPd; const unsigned int WIDTH = 1024; //generate matrix template<typename T> T *GenMatrix(const unsig...
23,561
#include "includes.h" __global__ void makeError(float *err, float *output, unsigned int Y, const int N) { const int pos = blockIdx.x * blockDim.x + threadIdx.x; const int size = blockDim.x * gridDim.x; for (int idx = N * pos / size; idx < N * (pos+1) / size; ++idx) { err[idx] = ((Y == idx ? 1.0f : 0.0f) - output[idx])...
23,562
// CUDA code to find the maximum in an array #include<iostream> #include<vector> #include<cstdlib> #include<algorithm> const int SHARED_MEM = 256; __global__ void maxFinder(double *arr, double *m, int N){ auto index = blockDim.x*blockIdx.x+threadIdx.x; __shared__ double cache[SHARED_MEM]; float temp = 0; int strid...
23,563
#include "includes.h" __global__ void kernCalcMu( const size_t numPoints, const size_t pointDim, const double* X, const double* loggamma, const double* GammaK, double* dest ) { // Assumes a 2D grid of 1024x1 1D blocks int b = blockIdx.y * gridDim.x + blockIdx.x; int i = b * blockDim.x + threadIdx.x; if(i >= numPoints) ...
23,564
extern "C" __device__ int classify(float* ins, int iniIns, int* attributes, int* isLeaf, int* numbersOfArcs, int* evalTypes, float* vals, int* nodeIndices, int MAX_NUM_ARCS) { int actual = 0; while(isLeaf[actual] == 0) //is not a leaf { int auxx = actual; int att = attributes[actual]; ...
23,565
#include <iostream> #include <cstdlib> #include <math.h> using namespace std; __global__ void p_vec_dist(int dim, float3 p, float3 *vec, float *res){ int index = blockIdx.x * blockDim.x + threadIdx.x; int stride = blockDim.x * gridDim.x; for (int i = index; i < dim; i += stride){ res[i] = (p.x - ...
23,566
#include <iostream> #include <cuda.h> using namespace std; __global__ void AddIntsCUDA (int *a, int *b) { a[0]+=b[0]; } int main() { int a = 5, b = 9; int *d_a, *d_b ; cudaMalloc(&d_a,sizeof(int)); cudaMalloc(&d_b,sizeof(int)); cudaMemcpy(d_a,&a,sizeof(int),cudaMemcpyHostToDevice); cudaMemcpy(d_b,&b,s...
23,567
/* * Overdamped Brownian particle in symmetric piecewise linear potential * * \dot{x} = -V'(x) + dichotomous noise * */ #include <stdio.h> #include <getopt.h> #include <stdlib.h> #include <math.h> #include <time.h> #include <cuda.h> #include <curand.h> #include <curand_kernel.h> #define PI 3.14159265358979f //...
23,568
#include "includes.h" __global__ void bestFilter(const double *Params, const float *data, const float *mu, const float *lam, const float *nu, float *xbest, float *err, int *ftype){ int tid, tid0, i, bid, NT, Nfilt, ibest = 0; float Th, Cf, Ci, xb, Cbest = 0.0f, epu, cdiff; tid = threadIdx.x; bid = blockIdx.x; N...
23,569
#include "includes.h" __global__ void __word2vecEvalNeg(int nrows, int ncols, int *WA, int *WB, float *A, float *B, float *Retval) {}
23,570
#include "includes.h" __global__ void initKernel(double* data, int count, double val) { int ti = blockDim.x * blockIdx.x + threadIdx.x; if (ti < count) { data[ti] = val; } }
23,571
#include "includes.h" __global__ void matrixAddKernel1(float* ans, float* M, float* N, int size) { int row = blockIdx.y*blockDim.y + threadIdx.y; int col = blockIdx.x*blockDim.x + threadIdx.x; if((row < size) && (col < size)) { ans[row*size + col] = M[row*size + col] + N[row*size + col]; } }
23,572
extern "C" __global__ void JCudaVectorAddKernel(int n, int *a, int *b, int *sum) { int i = blockIdx.x * blockDim.x + threadIdx.x; if (i<n) { sum[i] = a[i] + b[i]; } }
23,573
#include "includes.h" __global__ void kBoundingBoxLogisticGrad( float* mat, int* bbox, int* label, int* seg, float* indices, float* width_offset, float* height_offset, int size, int width, int height, int depth, float scale_width, float scale_height, float* grad) { const int color = blockIdx.z; /* const int numXBlocksP...
23,574
#include "includes.h" __global__ void add(float *a, float *b, float *c) { int tid = blockIdx.x; while(tid < N) { c[tid] = a[tid] + b[tid]; tid += gridDim.x; } }
23,575
#include "Objects.cuh" __device__ BVHNode::BVHNode(int depth) : m_depth(depth) { if (depth > 0) { m_left = new BVHNode(depth-1); m_right = new BVHNode(depth-1); #if __CUDA_ARCH__ >= 200 printf("|||| depth %d left %p right %p\n", m_depth,m_left,m_right); #endif } else { m_left = nullptr; m_rig...
23,576
#include <assert.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #define MAX_POINTS 100000000 #define MAX_MEANS 1000 #define MAX_ITER 100 typedef struct { double *x, *y; int *membership; } points; typedef struct { double *x, *y; int *size; double *x_sum, *y...
23,577
#include "includes.h" /* 152096 - William Matheus Friendly Numbers Programacao Paralela e Distribuida CUDA - 2019/2 - UPF Programa 2 - Kernel */ __global__ void sum(long int* device_num, long int* device_den, long int* device_vet, int size, int x) { int i = blockIdx.x * blockDim.x + threadIdx.x + x; int j; if (i < ...
23,578
#define DENOMINATOR_INDEX(a,g,i,j,k,nang,ng,nx,ny) ((a)+((nang)*(g))+((nang)*(ng)*(i))+((nang)*(ng)*(nx)*(j))+((nang)*(ng)*(nx)*(ny)*(k))) #define denominator(a,g,i,j,k) denominator[DENOMINATOR_INDEX((a),(g),(i),(j),(k),nang,ng,nx,ny)] __global__ void calc_denominator( const unsigned int nx, const unsigned in...
23,579
//双线性插值 __global__ void zoomOutIn(const int n, const float*src, int srcWidth, int srcHeight, \ float *dst, int dstWidth, int dstHeight) { float srcColTidf; float srcRowTidf; float c, r; const float rowScale = srcHeight / (float)(dstHeight); const float colScale = srcWidth / (float)(dstWidth); //int tid = blockI...
23,580
#include "includes.h" /* Start Header ***************************************************************** / /*! \file knn-kernel.cu \author Koh Wen Lin \brief Contains the implementation for kmeans clustering on the gpu. */ /* End Header *******************************************************************/ #define KMEAN_B...
23,581
#include "includes.h" __global__ void VecAdd(const int* A, const int* B, int* C, int N) { // Index holen int i = blockDim.x * blockIdx.x + threadIdx.x; if (i < N) C[i] = A[i] + B[i]; }
23,582
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <cuda_runtime.h> #include <device_launch_parameters.h> #include <time.h> #define N 100 __global__ void mul(int a[][N], int b[][N], int c[][N]){ int row = blockIdx.x*blockDim.x+threadIdx.x; int col = blockIdx.y*blockDim.y+threadIdx.y; if(row < N &&...
23,583
#include "includes.h" #define A 1.2f #define B 0.5f #define MIN_LEARNING_RATE 0.000001f #define MAX_LEARNING_RATE 50.0f // Device functions // Array[height * width] __global__ void fillArray(float *array, float value, int arrayLength) { int i = blockIdx.x * blockDim.x + threadIdx.x; if (i >= arrayLength) return; ...
23,584
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include "driver_types.h" #include <stdio.h> #include <fstream> #define BLOCK_SIZE 16 typedef struct { int width; int height; float* elements; } Matrix; __global__ void mat_mul_kernel(const Matrix a, const Matrix b, Matrix c) { int row =...
23,585
//#define DIMX 1920 //#define DIMY 1080 // //struct CuComplex { // float r; // float i; // // __device__ CuComplex(float a, float b) :r(a), i(b) {} // __device__ float magnitude2(void) { // return r * r + i * i; // } // // __device__ CuComplex operator*(const CuComplex& a) // { // return CuComplex(r*a.r - i * a.i, i*...
23,586
#include "includes.h" __global__ void reg_addArrays_kernel_float4(float4 *array1_d, float4 *array2_d) { const int tid= (blockIdx.y*gridDim.x+blockIdx.x)*blockDim.x+threadIdx.x; if(tid < c_VoxelNumber){ float4 a = array1_d[tid]; float4 b = array1_d[tid]; array1_d[tid] = make_float4(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w); } }
23,587
#include<stdio.h> #include"cuda_runtime.h" #include"device_launch_parameters.h" __global__ void add(int *a,int *b,int *c) { *c=*a+*b; } int main() { int a,b,c; printf("\nValue of A:"); scanf("%d",&a); printf("\nValue of b:"); scanf("%d",&b); int *d_a,*d_b,*d_c; int size=sizeof(int); cudaMalloc((void**)&d_a,s...
23,588
#include <iostream> #include <sstream> #include <stdio.h> using namespace std; #define UP 0 #define DOWN 1 #define BLOCK_SIZE 1024 #define NUM_BLOCKS 128 #define SHARED_MEM 8192 /* Cuda memcheck snippets from HW3 * http://graphics.stanford.edu/~seander/bithacks.html#DetermineIfPowerOf2 */ #define CUDA_SAFE_CALL_N...
23,589
#include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <iostream> #include <algorithm> #define BLOCKS_NUM 160 #define THREADS_NUM 1024 //thread number/block #define TOTAL_THREADS (BLOCKS_NUM * THREADS_NUM) #define REPEAT_TIMES 2048 #define WARP_SIZE 32 #define ARRAY_SIZE (TOTAL_THREADS + REPEAT_TIMES*...
23,590
#include "includes.h" __global__ void invierte(float *a, float *b) { int id = threadIdx.x; //int id = threadIdx.x + blockDim.x * blockIdx.x;// para n-bloques de 1 hilo if (id < N) { b[id] = a[N-id]; } }
23,591
#include "includes.h" __global__ void Vector_Addition ( const int *dev_a , const int *dev_b , int *dev_c) { //Get the id of thread within a block unsigned short tid = blockDim.x*blockIdx.x+threadIdx.x; if ( tid < N ) // check the boundry condition for the threads dev_c [tid] = dev_a[tid] + dev_b[tid] ; }
23,592
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <math.h> #include <stdbool.h> #include <time.h> #define K 3 // K is from K-SAT, currently we are working on 3-SAT #define THREAD_PER_BLOCK_log2 10 // current Var Limit is 32; void preProcessing(){ // removes comment while(getchar() =...
23,593
#include <stdio.h> __global__ void laplace(float * U1, float * U2) { int i = blockIdx.x; int j = threadIdx.x; int side = blockDim.x + 2; U2[(i + 1) * side + j + 1] // i, j = U1[i * side + j + 1] // i-1, j + U1[(i + 1) * side + j] // i, j-1 + U1[(i + 2) * side ...
23,594
#include "includes.h" __global__ void cudaDRectifier_backPropagate_kernel(double* x, double* dx, unsigned int size, double leakSlope, double clipping) { const unsigned int index = blockIdx.x * blockDim.x + threadIdx.x; const unsigned int stride = blockDim.x * gridDim.x; for (unsigned int i = index; i < size; i += stri...
23,595
#include "includes.h" __global__ void translate_2D(float* coords, size_t dim_y, size_t dim_x, float seg_y, float seg_x){ size_t index = blockIdx.x * blockDim.x + threadIdx.x; size_t total = dim_x * dim_y; if(index < total){ coords[index] += seg_y; coords[index + total] += seg_x; __syncthreads(); } }
23,596
#include<iostream> #include<cstring> #include<cstdlib> #define GMM_MAX_COMPONT 3 #define GMM_LEARN_ALPHA 0.005 #define GMM_THRESHOD_SUMW 0.7 #define HEIGHT 1080 #define WIDTH 1920 using namespace std; __global__ void trainGMM_CUDA(unsigned char *_image, unsigned char *mask, float *modelW, float *modelS, unsigned ...
23,597
/* Program : To find the run-time for the matrix multiplication kernel without tiling for various block sizes * Author : Anant Shah * Date : 13-9-2018 * Roll Number : EE16B105 **/ #include<stdio.h> #define ERROR_HANDLER(error_msg,line) error_handler(error_msg,line) #define NUM_THREADS_X 16 #define NUM_THREADS_Y 1...
23,598
#include "FileWriter.cuh" #include "Empire.cuh" void writeFile(char* fileName, float** contents, int width, int height) { FILE* f = fopen(fileName, "w"); fprintf(f, "P3\n%d %d\n255\n\n", width, height); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { if (contents[y][x]>=0) { fprintf(f,...
23,599
#include <curand.h> #include <curand_kernel.h> #define DIM 1600 #define PI 3.14159265 __global__ void Get_Histogram(unsigned char *R_input, unsigned char *G_input, unsigned char *B_input, size_t i_size, unsigned int *hist_r,unsigned int *hist_g,unsigned int *hist_b) { ...
23,600
#include "includes.h" __global__ void to_float(float *out, int *in, int size) { int element = threadIdx.x + blockDim.x * blockIdx.x; if (element >= size) return; out[element] = float(in[element]); }