serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
17,401
#include <math.h> #include <stdio.h> int main(int argc, char **argv){ double x = 15.2; int y = 9; double z = pow(x, y); printf("%2.32f", z); }
17,402
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <cuda.h> #include <cuda_runtime.h> #include "device_launch_parameters.h" #include <device_functions.h> #include <cuda_runtime_api.h> __device__ volatile int vint = 0; //a######################### __global__ void fun ( float * vp_...
17,403
#include "includes.h" __global__ void kernel4( int *a, int dimx, int dimy ) { int ix = blockIdx.x * blockDim.x + threadIdx.x; int iy = blockIdx.y * blockDim.y + threadIdx.y; int idx = iy * dimx + ix; if(ix<dimx && iy < dimy) a[idx] = (threadIdx.y * blockDim.x) + threadIdx.x; }
17,404
#include <stdio.h> int main() { cudaDeviceProp prop; cudaGetDeviceProperties(&prop, 0); printf("sm_%d%d\n", prop.major, prop.minor); }
17,405
#include <stdio.h> #define N 1000 // Nº Columnes #define M 10 // Nº Files #define ELE 4 // Elements anteriors __global__ void moving_average(float *a, float *b) { int index = blockDim.x * blockIdx.x + threadIdx.x; float result; if (index % N >= ELE){ //El primer valor de cada fila a calcular és el Nº ELE for(i...
17,406
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <assert.h> #include <cuda.h> #include <algorithm> #define u32 unsigned int #define u64 unsigned long #define uchar unsigned char #define BLOCK_SIZE 64 #define FULL_MASK 0xffffffff /** !ISSUE * sometimes sorted array is partially change, why? * e.g. ...
17,407
#include <stdio.h> #include <stdlib.h> __global__ void gpuMatMul(float * A, float * B, float *C, int ROW_A, int COL_A, int COL_B) { /******************** TODO *********************/ int j = blockIdx.x * blockDim.x + threadIdx.x; //Block Thread의 Index에 Block Thread Size를 곱해서 Thread의 인덱스를 ...
17,408
#include <iostream> #include <string> #include <stdio.h> #include <cuda.h> #include <fstream> using namespace std; #define TILE_WIDTH 16 __global__ void MatrixMulKernel(float *d_M, float *d_N, float *d_P,int width){ __shared__ float Mds[TILE_WIDTH][TILE_WIDTH]; __shared__ float Nds[TILE_WIDTH][TILE_WIDTH]; int b...
17,409
/* Code adapted from book "CUDA by Example: An Introduction to General-Purpose GPU Programming" This code computes a visualization of the Julia set. Two-dimensional "bitmap" data which can be plotted is computed by the function kernel. The data can be viewed with gnuplot. The Julia set iteration is: z= z**2 + C ...
17,410
#include "includes.h" __global__ void kern_ProbBuffer(float* agreement, float* output, int size, short max) { int idx = CUDASTDOFFSET; float locAgreement = agreement[idx]; float probValue = (float) locAgreement / (float) max; probValue = (probValue < 1.0f) ? probValue: 1.0f; if( idx < size ) { output[idx] = probValue; ...
17,411
// nvcc -arch=compute_20 // #include "stdio.h" #include "inttypes.h" #include "time.h" #include "math.h" // Device code #define TPB (256) // number of threads per block #define MAX_V (200000) typedef struct{ double _sqrt; double _log; } table_t; __global__ void build_table(table_t *d_table) { int thread = blo...
17,412
#include <time.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <cuda_runtime.h> //Arreglo de estructuras struct AoS{ int up; int left; int right; int down; }; //Estructura de arreglos struct SoA{ int* up; int* left; int* right; int* down; }; //Imprime arreglo de estructuras void printAoS(s...
17,413
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <cuda_runtime.h> // Host input vectors. float *h_a; float *h_b; // Host output vector. float *h_c; // Device input vectors. float *d_a; float *d_b; // Device output vector. float *d_c; // Size of arrays. int n = 0; /* CUDA kernel. Each thread takes c...
17,414
#include "includes.h" __global__ void add( int *a, int *b, int *c ) { int tid = threadIdx.x + blockIdx.x * blockDim.x; while (tid < N) { c[tid] = a[tid] + b[tid]; tid += blockDim.x * gridDim.x; } }
17,415
#include <stdio.h> #include <string.h> #include <cuda.h> #define GRID_ROW_SIZE 65535 #define GRID_COL_SIZE 65535 #define GRID_DEP_SIZE 65535 #define BLOCK_ROW_SIZE 1 #define BLOCK_COL_SIZE 10 #define BLOCK_DEP_SIZE 10 void checkCudaError(cudaError_t errorCode) { if (errorCode != cudaSuccess) fprintf(stder...
17,416
#include "vector.cu" struct Entity { Vec3 pos; Vec3 target; }; __device__ Entity entitySpawn(float scope) { Vec3 pos = {1.0f, 1.0f, 1.0f}; Vec3 target = {99.0f, 99.0f, 99.0f}; Entity spawned = {pos, target}; return spawned; } __global__ void entityInitialize(Entity* ents, int num_elems) { int local_index = t...
17,417
#include<stdio.h> #include <stdlib.h> #define record(a) {cudaEventCreate(&a);cudaEventRecord(a,0);} #define calculate(a,b,time) {cudaEventCreate(&b);cudaEventRecord(b,0);cudaEventSynchronize(b);cudaEventElapsedTime(&time, a,b);} //Define a constant variable for 1M const int size_constant = 1000000; const int mult...
17,418
#include <iostream> #include <stdio.h> const int Ax = 320; const int Ay = 320; const int Bx = 640; const int By = 320; const float aVal = 1; const float bVal = 2; const int ITER = 10; const int TILE_WIDTH = 32; //const int BLOCK_ROWS = 8; __global__ void matMul(const float *matA, const float *matB, float *matC)...
17,419
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <stdint.h> #include <time.h> #define PI 3.14159265 //#define GPU_COMPUTING __global__ void conv(float *tab, int N, float *filter, int s, float *output); void box_filter(float *filter, int size); void gaussian_filter(float *filter, int size); void conv...
17,420
__device__ int Kabsch(float x[][3], float y[][3], int n, int mode, float *rms, float t[3], float u[3][3] ) { int i, j, m, m1, l, k; //double e0, rms1; dou...
17,421
#include "includes.h" __global__ void CrashKernel (double *array, int nrad, int nsec, int Crash) { int j = threadIdx.x + blockDim.x*blockIdx.x; int i = threadIdx.y + blockDim.y*blockIdx.y; if (i<nrad && j<nsec){ if (array[i*nsec + j] < 0.0) array[i*nsec + j] = 1.0; else array[i*nsec + j] = 0.0; } }
17,422
#include <cuda.h> #include <stdio.h> #include <time.h> #include <stdlib.h> #define BLOCK_SIZE 1024 // kernel __global__ void sumReductionKernel(float* d_input, float* d_output) { __shared__ float output[2 * BLOCK_SIZE]; int startingIndex = 2 * blockIdx.x * blockDim.x; output[threadIdx.x] = d_inp...
17,423
// // Created by Peter Rigole on 2019-03-13. // #include "Neuron.cuh" Neuron::Neuron(NeuronProperties *neuronProperties, unsigned int max_nb_incoming_excitatory_synapses, unsigned int max_nb_incoming_inhibitory_synapses) : properties(neuronProperties), short...
17,424
#include <stdio.h> __global__ void init_numbers(int *d_numbers, int value, int size) { int index = threadIdx.x + blockIdx.x * blockDim.x; if (index < size) { d_numbers[index] = index & 1; } } __global__ void local_blelloch_sum( int *d_input, int input_size, int *d_output, int inclusive ) { exter...
17,425
#include "includes.h" __global__ void copyKernel(float* from, float* to, int size) { int threadId = blockDim.x*blockIdx.y*gridDim.x + blockDim.x*blockIdx.x + threadIdx.x; if(threadId < size) { to[threadId] = from[threadId]; } }
17,426
#include "includes.h" __global__ void generate_histogram(unsigned int* bins, const float* dIn, const int binNumber, const float lumMin, const float lumMax, const int size) { unsigned int i = blockIdx.x * blockDim.x + threadIdx.x; if (i > size) return; float range = lumMax - lumMin; int bin = ((dIn[i] - lumMin) / ran...
17,427
#include "includes.h" __global__ void Bprop1(const float* in, float* dsyn1, const float* dlayer1, const float alpha) { int i = blockDim.y*blockIdx.y + threadIdx.y; //28*28 int j = threadIdx.x; //256 int k = blockIdx.x; //Data.count atomicAdd(&dsyn1[i*256 + j], dlayer1[k...
17,428
// Test File read.cpp : Defines the entry point for the console application. // #include <stdio.h> #include <iostream> #include <fstream> #include <math.h> #include <ctime> using namespace std; int main (int argc, char *argv[]) { ifstream in_stream; in_stream.open(argv[1]); // in_stream.open("D:/1.txt"); int m1;...
17,429
#include <stdio.h> #include <stdlib.h> /*wave kernel*/ __global__ void sin_dist(float *wa) { /*calculate 2d arrray index from thread and block IDs*/ const int j = threadIdx.y+(blockIdx.y*gridDim.y); const int i = threadIdx.x+(blockIdx.x*gridDim.x); /*calculate mapping to 1d array from 2d indicies*/ const int lID...
17,430
#include <cuda_runtime.h> #include <cstddef> #include <cstdio> #include <iostream> #include <numeric> #include <stdexcept> #include <string> #include <sys/time.h> #include <vector> #define cuda_call(f, ...) \ cuda_assert(f(__VA_ARGS__), __FILE__, __LINE__, #f) #define cuda_launch(kernel, grid_dim, block_dim, ......
17,431
#include <stdio.h> #include <stdlib.h> #include <math.h> __global__ void matrix_add (int *device_A, int *device_B, int *device_C, int *device_n) { int index = threadIdx.x + blockIdx.x * blockDim.x; if (index < *device_n) device_C[index] = device_A[index] + device_B[index]; } int main() { int *host...
17,432
/* Program name: gld_throughput.cu Author name: Dr. Nileshchandra Pikle Email: nilesh.pikle@gmail.com Contact Number: 7276834418 Purpose: Program to demonstrate global memory efficiency Description: A simple vector addition kernel is written which performs strided access to arrays. ...
17,433
#include <stdio.h> #include <iostream> #include <chrono> #include <cuda.h> #include <cuda_runtime.h> #include <math.h> #include <stdlib.h> #include <time.h> using namespace std; struct Particle{ float3 position; float3 velocity; }; __global__ void simulate(Particle x[],int N,int iter){ //printf("Hello Wor...
17,434
/* Two kernels, no shared memory, manual laplacian, 1D malloc */ #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(...
17,435
#include "includes.h" __global__ void add_dVector_kernel(double *a, double *b, double *c, int n) { int id = blockIdx.x*blockDim.x + threadIdx.x; if (id < n) c[id] = a[id] + b[id]; }
17,436
// process BICG_BATCH elements in thread #define BICG_BATCH 8 #define BICG_STEP 32/BICG_BATCH typedef float DATA_TYPE; extern "C" __global__ void bicgKernel1( DATA_TYPE *A, DATA_TYPE *p, DATA_TYPE *q, int m, int n) { int i = blockDim.x*blockIdx.x + threadIdx.x; if (i < n) { q[i] = 0.0; int j; for (j = 0...
17,437
#include <stdio.h> #include <math.h> #include <stdlib.h> #include <curand_kernel.h> __global__ void initialConditions(float* vars, int num_param, int num_cells, int cells_per_thread) { float V = -83.5092; float m = 0.0025 ; float h = 0.6945 ; float j = 0.6924 ; float d = 4.2418e-005 ; float f = 0.9697 ; float f...
17,438
#include <stdio.h> #define CSC(call) do { \ cudaError_t e = call; \ if (e != cudaSuccess) { \ fprintf(stderr, "CUDA Error in %s:%d: %s\n", __FILE__, __LINE__, cudaGetErrorString(e)); \ exit(0); \ } \ } while(0) __global__ void subKernel(double* a, ...
17,439
#include <stdint.h> /* for uint64 definition */ #include <time.h> /* for clock_gettime() */ #include <stdio.h> #include <stdlib.h> #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } #define BILLION 1000000000L inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true) { if (code...
17,440
#include "includes.h" __global__ void mul_ctf(float *image, int nx, int ny, float defocus, float cs, float voltage, float apix, float bfactor, float ampcont) { // Block index int bx = blockIdx.x; // Thread index int tx = threadIdx.x; float x, y; x = float(bx); if (tx >= ny>>1) y = float(tx-ny); else y = float(tx); ...
17,441
#pragma once // includes, C string library #include <stdio.h> #include <stdlib.h> #include <string.h> #include <cmath> #include <cuda_runtime.h> #include "device_launch_parameters.h" //----------------------------------- //kernel function to update the vertex buffer //----------------------------------- __global__ void...
17,442
#include <cstdio> typedef struct { int width; int height; float* elements; } Matrix; #define MATRIX_SIZE 1024 #define BLOCK_SIZE 16 __global__ void MatMulKernel(const Matrix A, const Matrix B, Matrix C) { float cv = 0; int row = blockIdx.y * blockDim.y + threadIdx.y; int col = blockIdx.x * bl...
17,443
/* 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 ...
17,444
#include <iostream> #include <cuda.h> #include <algorithm> #include <cstdlib> using namespace std; __global__ void fun1(float *d_out, float *d_in) { int i = blockIdx.x * blockDim.x + threadIdx.x; float x, x_; if(i > 0) { x =d_in[i]; x_ = d_in[i-1]; d_out[i] = x+ x_; } } int main() { // initia...
17,445
#include <bits/stdc++.h> #include <cuda.h> #define H 5 #define W 5 using namespace std; void llenar(int* v) { for (int i = 0; i < H; ++i) { for (int j = 0; j < W; ++j) { v[i*W+j] = rand() % 10; } } } //complexity O((H**2)*W) void mult(int *A, int *B,int *C) { int sum; for (int i = 0; i < H; ++i...
17,446
/* Runs the CPU and GPU implementations of my Pseudo Random Number Generator Project for CS 179 at Caltech. Author: Kyle Seipp This file will demonstrate 4 algorithms for generating random numbers. Before we start, we will check the tests by writing 0.5 to the whole file. First, we will use the built-in random library...
17,447
#include "includes.h" __global__ void gpuSum(int *prices,int *sumpricesout,int days,int seconds,int N) { int currentday = blockIdx.x*blockDim.x + threadIdx.x; if(currentday<days) { int start = currentday * seconds; int end = start+seconds; int totprice=0; for(int j=start;j<end;++j) totprice+=prices[j]; sumpricesout[c...
17,448
#ifndef SPH_memory_storage_precomp_kernels_cu #define SPH_memory_storage_precomp_kernels_cu #endif
17,449
#include <stdlib.h> #include <stdio.h> #include <time.h> #include <sys/time.h> #include <cuda.h> #define INF 100000000 #define BLOCKSIZE 128 #define BITSFT 7 //log2(BLOCKSIZE) void generate(float *A,float *D,float *Q,int vertices) { int i,j; srand ( time(NULL) ); for(i=0;i<vertices;i++) { for(j...
17,450
#include <iostream> #include <memory> #include <cassert> using namespace std; #include <cuda.h> __global__ void getValue(float *indata) { indata[0] = 0.0f - indata[0]; } int main(int argc, char *argv[]) { int N = 1024; CUstream stream; cuStreamCreate(&stream, 0); float *hostFloats1; cuMem...
17,451
#include <stdio.h> #define SEP_LINE_LENGTH 20 typedef struct gridTopology { dim3 blockSize; dim3 gridSize; } gridTopology; typedef struct pixelCoords { int x, y; } pixelCoords; gridTopology initGridTopology2D(int r, int c); void gridDataReport(gridTopology t, int nRows, int nCols); void printLineOf(char c); _...
17,452
#include "includes.h" __global__ void cudaSAnchorBackPropagateSSD_NegSamples_kernel(const float* inputCls, float* diffOutputsCls, const float* confSamples, const int* keySamples, const int nbSamples, const int nbPositive, const unsigned int nbAnchors, const unsigned int outputsHeight, const unsigned int outputsWidth, c...
17,453
#include <cstdio> #include <cuda.h> #include <cuda_runtime.h> void hello_cpu() { printf("hello world from CPU\n\n"); } __global__ void hello_gpu() { printf("Hello world from GPU\n"); } __global__ void hello_gpu_idx() { if (threadIdx.x == 5) printf("\nHellow world from GPU %d\n",threadIdx.x); } int ma...
17,454
#include "includes.h" __global__ void matrixMultiplyShared(float *A, float *B, float *C, int numARows, int numAColumns, int numBRows, int numBColumns, int numCRows, int numCColumns) { //@@ Insert code to implement matrix multiplication here //@@ You have to use shared memory for this MP __shared__ float ds_A[TILE_WIDTH...
17,455
#include "includes.h" __global__ void ComputeOffsetOfMatrixB(const int32_t* row_sum, int32_t* output, int32_t N) { for (int32_t i = threadIdx.x; i < N; i += blockDim.x) { *(output + blockIdx.x * N + i) = -row_sum[blockIdx.x]; } }
17,456
#include <stdlib.h> #include <stdio.h> #include <math.h> #include <time.h> #include "constants.cuh" #include "main_functions.cuh" #include "mesh.cuh" #include "material.cuh" #include "sparse_struc.cuh" int main(int argc, char **argv) { struct mesh mesh; struct material material; double *ke, *me; //FINITE ELEME...
17,457
#define X 0 #define Y 1 #define Z 2 #define CROSS(dest,v1,v2) \ dest[0]=v1[1]*v2[2]-v1[2]*v2[1]; \ dest[1]=v1[2]*v2[0]-v1[0]*v2[2]; \ dest[2]=v1[0]*v2[1]-v1[1]*v2[0]; #define DOT(v1,v2) (v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2]) #define SUB(dest,v1,v2) \ ...
17,458
#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 :...
17,459
#include <cuda.h> #include <stdio.h> #include <stdlib.h> #define XBLOCK_SIZE 32 #define YBLOCK_SIZE 24 __global__ void mandelKernel(float lowerX, float lowerY, float stepX, float stepY,int width,int count, int *output) { // To avoid error caused by the floating number, use the following pseudo code // // ...
17,460
#include <stdio.h> #include "time.h" #include <stdlib.h> #include <limits.h> const int CONST_VEC = 1024; __constant__ int constArrayA[CONST_VEC]; __constant__ int constArrayB[CONST_VEC]; void CPU_mult(int *result, int *a, int *b, int N) { int sum; for (int row=0; row<N; row++){ for (int col=0; col<N; col++){ ...
17,461
#include "blur_gpu.cuh" __global__ void operatepic(int g, int *img1, int *img2, int *img3, int index) { int t = 32 * 30; int threadId_3D = threadIdx.x + threadIdx.y*blockDim.x + threadIdx.z*blockDim.x*blockDim.y; int blockId_3D = blockIdx.x + blockIdx.y*gridDim.x + blockIdx.z*gridDim.x*gridDim.y; int i = threadId_...
17,462
// // Created by bruno on 2021/7/2. // #include <stdio.h> __global__ void hellofromgpu(void ) { printf("Hello World from GPU\n"); } int main(void ) { printf("hello from cpu\n"); hellofromgpu<<<1,10>>>(); cudaDeviceReset(); return 0; }
17,463
// Padding by CUDA __global__ void cu_pad(const float *A, int kw, int kh, int aw_rem, int ah_rem, float *P){ // A : input data, P : padding data // kw : kernel width, kh : kernel hieght // block = (BLOCK_SIZE,BLOCK_SIZE,1) // grid = (aw/BLOCK_SIZE, ah/BLOCK_SIZE, an) int tx = threadIdx.x + blockI...
17,464
#include "includes.h" __global__ void MD_ED_D(float *S, float *T, int trainSize, int window_size, int dimensions, float *data_out, int task, int gm) { long long int i, j, p; float sumErr = 0, dd = 0; int idx = blockIdx.x * blockDim.x + threadIdx.x; if (gm == 0) { extern __shared__ float T2[]; int t, offset; if (task...
17,465
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <assert.h> #include <cuda.h> #include <cuda_runtime.h> #define EPS 1e-8 #define N 10000000 #define MAX_ERR 1e-6 //#define nb 23814 //no. of n bodies //#define nb 1350 //#define nb 294 //#define nb 5766 //#define p 31 //no of threads in each block #defin...
17,466
#include <sys/timeb.h> #include <cmath> #include <cstdio> #define BLOCK_SIZE 512 __device__ double polynominal(double x){ return 5*pow(x,4) + 4*pow(x,3) + x - 10*pow(x,2); } __global__ void calculate(double* result, double start, double dx, long long int length) { int index = blockIdx.x * blockDim.x + threa...
17,467
// This example demonstrates a block-wise inclusive // parallel prefix sum (scan) algorithm. #include <stdlib.h> #include <stdio.h> #include <vector> #include <iostream> // This kernel computes, per-block, a block-sized scan // of the input. It assumes that the block size evenly // divides the input size __global__...
17,468
/* * ARQUITECTURA DE COMPUTADORES * 2 Grado en Ingenieria Informatica * * PRACTICA 2: "Reduccin Paralela" * >> TODO => Aadir comprobacion de potencia de 2 * * AUTOR: Ivn Ruiz Gzquez */ /////////////////////////////////////////////////////////////////////////// // Includes #include <stdio.h> #include <stdlib.h> #include...
17,469
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <assert.h> #include <cuda.h> #include <cuda_runtime.h> #define MAX_ERR 1e-6 __global__ void vector_add(double *res, double *a, double *b, int n) { int tid = blockIdx.x * blockDim.x + threadIdx.x; if (tid < n) res[tid] = a[tid] + b[tid]; } __gl...
17,470
/* simple.cu */ /****************************************************************************/ /* */ /* (C) 2010 Texas Advanced Computing Center. */ /* ...
17,471
#include<stdio.h> #include<cuda.h> #include<math.h> #define imin(a,b) (a<b?a:b) const int N = 33 * 1024; const int threadsPerBlock =256; const int blocksPerGrid = imin( 32, (N+threadsPerBlock-1) /threadsPerBlock ); __global__ void dot( float *a, float *b, float *c){ __shared__ float cache[threadsPerBlock]; int...
17,472
#include "BigNum.cuh" #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <math.h> #include <unistd.h> #define SIZE ((5)) /* __device__ inline void cuda_printNum(unsigned int *__restrict__ num){ unsigned int i; for(i = 0; i < SIZE; i ++) printf("%x ", num[i]); printf("\n"); }*/ __device__ inline ...
17,473
// from quantity_ext.c __global__ void update( int N, double timestep, double * centroid_values, double * explicit_update, double * semi_implicit_update) { const int k = threadIdx.x+threadIdx.y*blockDim.x+ (blockIdx.x+blockIdx.y*gridDim.x)*blockDim.x*...
17,474
#include "includes.h" #define TILE_WIDTH 32 struct event_pair { cudaEvent_t start; cudaEvent_t end; }; __global__ void GPU_convolution(float *channel, float *mask, float *result, int dimMask, int dimW, int dimH) { int bx = blockIdx.x; int by = blockIdx.y; int tx = threadIdx.x; int ty = threadIdx.y; int x, y; // Id...
17,475
#include <stdio.h> #include <stdlib.h> #define TILE_WIDTH 32 __global__ void mat_mul(float* Md, float* Nd, float* Pd) { __shared__ float Mds[TILE_WIDTH*TILE_WIDTH]; __shared__ float Nds[TILE_WIDTH*TILE_WIDTH]; int bx = blockIdx.x; int by = blockIdx.y; int tx = threadIdx.x; int ty = threadIdx.y; int Row = bx*...
17,476
//#pragma once // //#include "cuda_runtime.h" //#include "device_launch_parameters.h" //#include <cuda.h> //#include <device_functions.h> //#include <cuda_runtime_api.h> // //#include <device_functions.h> // //#include "curand_kernel.h" // //#include <thrust/sort.h> //#include <thrust/execution_policy.h> //#include <th...
17,477
// #include <gtest/gtest.h> // #include <matazure/cuda/lambda_tensor.hpp> // #include <mtensor.hpp> // // #include <nvfunctional> // using namespace matazure; // using namespace testing; // __device__ void print(int i) { printf("%d,", i); } // struct print_op { // MATAZURE_GENERAL void operator()(int i) { printf...
17,478
/* 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,int var_3,int 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 var_...
17,479
#include <cuda_runtime.h> #include <device_launch_parameters.h> #include <stdio.h> #include <time.h> #include<sys/time.h> //don't forget the time double cpuSecond() { //#ifdef LINUX_IMP struct timeval tp; gettimeofday(&tp,NULL); return ((double)tp.tv_sec + (double)tp.tv_usec*1.e-6); //#endif } //generat...
17,480
/* Copyright (c) 2016-2017, 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 ...
17,481
/** * gputime.cu - A struct that measures the GPU algorithm performance via GPU time. * * Based off example here: https://devblogs.nvidia.com/how-implement-performance-metrics-cuda-cc. */ struct GpuTimer { cudaEvent_t start_val, stop_val; GpuTimer() { cudaEventCreate(&start_val); cudaEventCreate(&stop_val...
17,482
#include <stdio.h> #include <stdlib.h> #include <math.h> // CUDA kernel. Each thread takes care of one element of c __global__ void vecAdd(double *a, double *b, double *c, int n) { // Get our global thread ID int id = blockIdx.x*blockDim.x+threadIdx.x; // Make sure we do not go out of bounds if (id < ...
17,483
#include "includes.h" __global__ void polynomial_expansion (float* poly,int degree,int n,float* array) { int idx=blockIdx.x*blockDim.x+threadIdx.x; if(idx<n) { float val=0.0; float exp=1.0; for(int x=0;x<=degree;++x) { val+=exp*poly[x]; exp*=array[idx]; } array[idx]=val; } }
17,484
#include <stdio.h> #include <cuda.h> __global__ void cuda_hello(void) { // print a character buffer from the GPU! printf("Hello, world!\n"); } int main(void) { printf("Calling cuda_hello...\n"); // call the CUDA kernel from the GPU cuda_hello<<<1,1>>>(); // wait for the kernel to finish cudaDeviceSync...
17,485
#include "includes.h" __global__ void update_array_one_gpu(int m, int n, int i, int numberOfThreadsRequired,int count, int oldCount, int *d_array ) { long j=blockIdx.x *blockDim.x + threadIdx.x; if (j> numberOfThreadsRequired) {} else { d_Z1 = d_A1 + 1; if (j < (m - 1) ) { d_Z2 = d_A2 + 1; } } }
17,486
#include "cuda_runtime.h" #include "device_launch_parameters.h" #define _CRT_SECURE_NO_WARNINGS #include <math.h> #include <stdio.h> #include <sys/types.h> #include <iostream> #include <stdint.h> #include <stdlib.h> #include <string.h> #include <iomanip> #include <pthread.h> #include <vector> #include <unistd.h> #inclu...
17,487
#include "includes.h" __global__ void addValue(int *array_val, int *b_array_val) { int cacheIndex = threadIdx.x; int i = blockDim.x/2; while (i > 0) { if (cacheIndex < i) { array_val[blockIdx.x * COLUMNS +cacheIndex] += array_val[blockIdx.x * COLUMNS + cacheIndex +i]; } __syncthreads(); i /=2; } if (cacheIndex == 0) b_...
17,488
// // simpleCUDA // // This simple code sample demonstrates how to perform a simple linear // algebra operation using CUDA, single precision axpy: // y[i] = alpha*x[i] + y[i] for x,y in R^N and a scalar alpha // // Please refer to the following article for detailed explanations: // John Nickolls, Ian Buck, Michael Garl...
17,489
#include <stdio.h> #include <cuda.h> #include <cuda_runtime_api.h> #include <time.h> __global__ void axpy(float a, float *xVec, float *yVec){ //block.Idx.x, threadIdx.x, blockDim.x int subID; for(subID=0; subID < 8; subID++){ int idx = subID +(threadIdx.x*8) + blockIdx.x*(blockDim.x*8); yVec[idx] = a*xVec[idx] ...
17,490
#include "includes.h" __global__ void matmul_v0(float* a,float* b,float* c, int n){ // C(nxn) = A(nxn) * B(nxn); int i = blockIdx.x*blockDim.x + threadIdx.x; int j = blockIdx.y*blockDim.y + threadIdx.y; if(i >= n || j >= n) return; float c_ij = 0; for(int k=0;k<n;k++){ c_ij += a[n*j+k]*b[n*k+i]; // printf("%d %d %d...
17,491
#include<stdio.h> #include <stdlib.h> #define Nrows 3 #define Ncols 5 #define Nmatrix 4 __global__ void fillMatrix (float *devPtr, size_t pitch, int matrix_type) { int tid = blockIdx.x * blockDim.x + threadIdx.x; if (tid < Ncols) { switch (matrix_type) { case 0: { ...
17,492
#include "includes.h" __global__ void group_point_gpu(int b, int n, int c, int m, int nsample, const float *points, const int *idx, float *out) { int index = threadIdx.x; points += n*c*index; idx += m*nsample*index; out += m*nsample*c*index; for (int j=0;j<m;++j) { for (int k=0;k<nsample;++k) { int ii = idx[j*nsample+...
17,493
/* 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,int 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...
17,494
#include <iostream> #include <math.h> // function to add the elements of two arrays __global__ void add(int n, float4 *x, float4 *y) { int index = blockIdx.x * blockDim.x + threadIdx.x; int stride = blockDim.x * gridDim.x; for (int i = index; i < n; i += stride){ //there are no operators for float4 type ...
17,495
#include "kernel.cuh" __global__ void norm (float *d_Input, float *d_Output, int n) { // the column to be computed int col = blockIdx.x * blockDim.x + threadIdx.x; __shared__ int row, mu, sigma; // the same alogrithm as sequential since the computation does not depend on rows if (col < n){ ...
17,496
#include <stdio.h> #include <cuda.h> int main (int argc, char *argv[]) { // Initialize variables if (argc != 2) exit(1); size_t size = atoi(argv[1]); void *host, *host2, *device, *device2; host = malloc(size); if (host == NULL) perror("malloc"); if (cudaSuccess != cudaMallocHost(&host2, size))...
17,497
#include "includes.h" __global__ void Run_Me( int* The_Array , int size) { int ID = blockIdx.x; if(ID < 4) The_Array[ID] = The_Array[ID] * The_Array[ID]; }
17,498
//2d cahn hillard with initial condition as random noise using spectral with periodic boundary conditions #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <time.h> #include <cuda.h> #include <cuda_runtime.h> #include <cufft.h> #include "device_launch_parameters.h" #define sizex 512...
17,499
#include<cuda.h> #include<stdio.h> #include<math.h> __global__ void vecAddKernel(float* A, float* B, float* C, int n){ //identify the index of the data to be read int i= threadIdx.x + blockDim.x * blockIdx.x; //calculate the sum and store if(i<n) C[i] = A[i] + B[i]; } __host__ void vecAdd(float* A,float* B,floa...
17,500
#include <cuda.h> #include <stdio.h> __global__ void gInitializeStorage(float* a) { a[(threadIdx.x + blockIdx.x * blockDim.x) + (threadIdx.y + blockIdx.y * blockDim.y) * (blockDim.x * gridDim.x)] = (float)((threadIdx.y + blockIdx.y * blockDim.y) + (threadIdx.x + blockIdx.x * blockDim.x) * (blockDim.x * gridDi...