serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
19,501
/* Cuda GPU Based Program that use GPU processor for finding cosine of numbers */ /* --------------------------- header secton ----------------------------*/ #include<stdio.h> #include<cuda.h> #define COS_THREAD_CNT 10 #define N 10 /* --------------------------- target code ------------------------------*/ struct co...
19,502
#include "BitMapper.cuh" // Get the index of a field in the bit array. The field contains the bit corresponding to value. __host__ __device__ unsigned int BitMapper::getIndexInBitArray(unsigned int value) { // 5 = log2(32) return (value >> 5); // 5 Bits, to fit 32 different positions } // Get the position of a bit ...
19,503
#include <stdio.h> #include <iostream> #include <chrono> /* __global__ void VecAdd(float* A, float *B, float *C) { int idx = threadIdx.x; C[idx] = A[idx] + B[idx]; } // Matrix Addtion using 1 block (threadIdx has limitation about 1024) __global__ void MatAdd(float A[N][N], float B[N][N], float C[N][N]) { int idx1 ...
19,504
#include <stdlib.h> #include <stdio.h> #include <vector> #include <math.h> #include <cuda_runtime.h> #define N (1 << 25) #define blocksize 8 void checkCUDAError(const char *msg) { cudaError_t err = cudaGetLastError(); if( cudaSuccess != err) { fprintf(stderr, "Cuda error: %s: %s.\n", msg, cudaGetError...
19,505
#include <cstdlib> #include <iostream> #include <time.h> #define DIM1 3 #define DIM2 3 __global__ void avg(float* in, float* out, int radius) { int tid = threadIdx.x + blockIdx.x * blockDim.x; if(tid < DIM1 * DIM2) { int x = tid / DIM1; int y = tid % DIM2; float count = 0; float...
19,506
#include <cstdlib> #include <string> #include <iostream> __global__ void kernel(int* arr,int n){ int idx=blockDim.x*blockIdx.x+threadIdx.x; if(idx<n){ arr[idx]=5; } return; } __host__ void error(std::string message,bool warning=false){ cudaError_t err=cudaSuccess; err=cudaGetLastError(); if(err!=cudaSuccess...
19,507
#include <stdio.h> const char STR_LENGTH = 52; __device__ const char *STR = "HELLO WORLD! HELLO WORLD! HELLO WORLD! HELLO WORLD! "; __global__ void hello() { printf("%c", STR[blockIdx.x]); } int main(int argc, char** argv) { int device = atoi(argv[1]); cudaSetDevice(device); hello<<<STR_LENGTH, 1>>>(); ...
19,508
//numThreads should be multiple of 32 __global__ void mediumKernel(int *offset, int *col_id, int *medium, int sizeMedium, int *color, int currentColor) { extern __shared__ bool set[]; if( (blockIdx.x*blockDim.x+threadIdx.x)/32 < sizeMedium) { int node = medium[(blockIdx.x*blockDim.x+threadIdx.x)/32]; if(col...
19,509
#include <cuda_runtime.h> #include <device_launch_parameters.h> #include <stdio.h> #include <time.h> #include<sys/time.h> //#difine LINUX_IMP #define CHECK(call) \ { \ const cudaError_t error = call; \ if(error != cudaSuccess) ...
19,510
// Device code extern "C" __global__ void m3shell_memset_kernel(char *ptr, int sz, char val) { // Dummy kernel int idx = blockIdx.x * blockDim.x + threadIdx.x; for (; idx < sz; idx += (gridDim.x * blockDim.x)) { ptr[idx] = val; } }
19,511
#include <stdio.h> #define MIN(x, y) (((x) < (y)) ? (x) : (y)) __global__ void matmult_kernel1(int m, int n, int k, double *A, double *B, double *C){ // set C to zeros for (int i=0;i<m;i++){ for (int p=0;p<n;p++){ C[i*n+p]=0; //C[i][p] } } // do matmult with mkn loop ...
19,512
#include "includes.h" extern "C" __global__ void add(int n, float *a, float *sum) { int i = threadIdx.x + blockDim.x * blockIdx.x; if (i<n) { for (int j = 0; j < n; j++) { sum[i] = sum[i] + a[i*n + j]; } } }
19,513
// Program corresponding to CythonBM.cu that can be run directly from the command lin. For testing purposes. //Attempt to Parallelize function for crossing time. Slower than other methods. //#include <cmath> #include <curand_kernel.h> #include <stdio.h> #include <cuda.h> // Error handling code used in Nvidia example...
19,514
#include <cuda_runtime.h> #include <iostream> using namespace std; __global__ void kernelMatrixMul( float* a, float*b, float*c, int n ) { int ii = blockIdx.x * blockDim.x + threadIdx.x; if( ii >= n*n ) return; int i= ii / n ; int j= ii %n; for(int k=0;k<n;k++) c[ i*n +j] += a[ i*n + k] * b[ k*n +j] ; } ...
19,515
#include "includes.h" using namespace std; __global__ void add(int a, int b, int *c)//kernel函数,在gpu上运行。 { *c = a + b; }
19,516
#include <cmath> #include <iostream> #include <vector> int main() { size_t n = 50000000; std::vector<double> a(n); std::vector<double> b(n); for (size_t i = 0; i < n; i++) { a[i] = sin(i) * sin(i); b[i] = cos(i) * cos(i); } std::vector<double> c(n); for (size_t i = 0; i < n...
19,517
// Jin Pyo Jeon #include <cuda.h> #include <stdlib.h> #include <time.h> #include <stdio.h> #include <math.h> #include <assert.h> // N Stream Non-Stream // 3 * 2^15 0.11 0.11 // 3 * 2^10*700 0.15 0.15 // 3 * 2^20 0.22 0.22 // 3 * 2^24 3.45 3.46 // 3 * 2^25 6.89 6.90 #define N (3 * 1024 * 700) #define...
19,518
#include "includes.h" extern "C" { } __global__ void A_emult_Bg0(const int n, const double *a, const double *b, double *c) { int i = threadIdx.x + blockIdx.x * blockDim.x; if (i<n) { if (b[i]>0.0) {c[i] += a[i];} else {c[i] += 0.0;} } }
19,519
#include <iostream> #include <chrono> #include <ctime> #include <stdio.h> #include <math.h> #include <assert.h> __global__ void helloFromGPU() { printf("Hello from GPU!\n"); } int main() { std::chrono::time_point<std::chrono::system_clock> start, end; start = std::chrono::system_clock::now(); ...
19,520
#include "cuda_runtime.h" #include "device_launch_parameters.h" int BlockDim() { cudaDeviceProp prop; cudaGetDeviceProperties(&prop,0); return prop.maxThreadsPerBlock; } int GridDim() { cudaDeviceProp prop; cudaGetDeviceProperties(&prop,0); return prop.maxGridSize[0]; } int major() { cudaDeviceProp prop; cuda...
19,521
#include <math.h> #include <stdio.h> #define N 200 __global__ void reverse(int *a, int *b) { int idx = blockIdx.x * blockDim.x + threadIdx.x; b[gridDim.x - idx - 1] = a[idx]; } void random_ints(int *p, int n) { int i; for (i = 0; i < n; i++) { p[i] = rand() % 100; } } int main(void) { int *a, *b; ...
19,522
__global__ void expit_kernel(float *d_a, float *d_aout, int size) { const int id = threadIdx.x + blockIdx.x * blockDim.x; if (id >= size) { return; } const float x = d_a[id]; float tmp; if (x < 0) { tmp = expf(x); d_aout[id] = tmp / (1.0 + tmp); } else { d_ao...
19,523
#include "../Headers/Includes.cuh" /////////////// Importing the Setup Paramaters /////////////// void InputSetup( string &NAME, string &OUTPUTMOD, unsigned &IT, float &x_start, float &x_end, float &y_start, float &y_end, float &z_start, float &z_end, unsigned &XDIVI, unsigned &YDIVI, u...
19,524
extern "C" __global__ void backwardExponentiationKernel (int length, float *forwardResults, float *chain, float *backwardResults) { int globalId = blockDim.x * blockIdx.x + threadIdx.x; if(globalId < length) { backwardResults[globalId] = chain[globalId] * forwardResults[globalId]; } }
19,525
#include <stdio.h> #include <stdlib.h> #include <ctime> #include <chrono> #include <curand.h> #include <curand_kernel.h> #include <iostream> using namespace std; __device__ unsigned int reduce_sum(unsigned int in) { extern __shared__ unsigned int sdata[]; // Perform first level of reduction: // - Write to...
19,526
#include <stdint.h> #define IPAD 0x36363636 #define OPAD 0x5c5c5c5c #include "sha1.cuh" __device__ void memxor (void * dest, const void * src,size_t n) { int rest = n%4; n = n/4; const int * s = (int*)src; int *d = (int*)dest; const char * s2 = (char*)src+4*n; char *d2 = (char*)dest+4*n; for (; n > 0; n...
19,527
#include "includes.h" // CUDA runtime // Helper functions and utilities to work with CUDA #define N 256 //#define M 256 //__global__ÉùÃ÷µÄº¯Êý£¬¸æËß±àÒëÆ÷Õâ¶Î´úÂë½»ÓÉCPUµ÷Óã¬ÓÉGPUÖ´ÐÐ __global__ void matrix_mult(float *dev_a, float* dev_b, float* dev_c, int Width) { int Row = blockIdx.y*blockDim.y+threadIdx.y;...
19,528
/* ********************************************** * CS314 Principles of Programming Languages * * Fall 2020 * ********************************************** */ #include <stdio.h> #include <stdlib.h> __global__ void exclusive_prefix_sum_gpu(int * oldSum, int * newSum, int distance...
19,529
#include <stdio.h> #include <time.h> #include <stdlib.h> #include <thrust/generate.h> #include <thrust/random.h> #include <thrust/iterator/counting_iterator.h> #include <thrust/functional.h> #include <thrust/transform_reduce.h> #include <cmath> const double niter = 10000; struct montecarlo : public thrust::una...
19,530
#include<iostream> #include<cuda.h> #include<math.h> #include <time.h> /* 1- nvcc acopladas_B3-2.cu -o acopladas_B3-2 2-./acopladas_B3-2 We are using Dormand-Prince Method based on http://depa.fquim.unam.mx/amyd/archivero/DormandPrince_19856.pdf */ using namespace std; __global__ void suma(int *a,int ...
19,531
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <iostream> #include <time.h> using namespace std; // void simpleMatMul(int* c, int* a, int* b, int rows1, int cols1, int cols2) { for (unsigned int i = 0; i < rows1; i++) { for (unsigned int j = 0; j < co...
19,532
#include "moment-update.hh" #include <cassert> #include <stdexcept> #include "graph.hh" #include "mse-grad.hh" #include "ops-builder.hh" #include "variable.hh" #include "../runtime/node.hh" #include "../memory/alloc.hh" namespace ops { MomentUpdate::MomentUpdate(Variable* var, Op* dt, ...
19,533
#include <cassert> // Intentionally doing a cuda assert to generate xid error 43 extern "C" __global__ void make_assert(int* buf, size_t size, int iterations) { assert(false); }
19,534
#include <stdio.h> const int INPUT_DIM = 100; const int FILTER_DIM= 5; // should be factor of INPUT_DIM const int CONV_OUT_DIM = INPUT_DIM / FILTER_DIM; const int CONV_LAYER_SIZE = 10; const int OUT_NEURON_DIM = CONV_OUT_DIM * CONV_OUT_DIM * CONV_LAYER_SIZE; const int OUT_LAYER_SIZE = 10; extern "C" __global__ void c...
19,535
#include <stdio.h> __global__ void add(int *a, int *b, int *c) { *c = *a + *b; } int main(void) { int a, b, c; // host copies of a, b, c int *gpu_a, *gpu_b, *gpu_c; // device copies of a, b, c int size = sizeof(int); // Allocate space for device copies of a, b, c cudaMalloc((void **) &gpu_a, siz...
19,536
#include<stdio.h> #include<stdlib.h> #include<math.h> #include<sys/time.h> #define NUM 10000000 #define CUDA_ERROR_EXIT(str) do{\ cudaError err = cudaGetLastError();\ if( err != cudaSuccess){\ printf("C...
19,537
#include <stdlib.h> #include <stdio.h> #define FILENAME "./dblp-co-authors.txt" #define NumAuthor 317080 #define DataLen 1049866 #define BlockSize 1024 #define GridSize int(DataLen/BlockSize) + 1 #define MAX 343 #define newGridSize int(NumAuthor/BlockSize) + 1 int dataset[DataLen * 2];// array to store the raw dat...
19,538
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> __global__ void mult1(int *A, int *B, int *C, int n){ //each thread computes the product of elements row-wise int row = threadIdx.x; for(int i=0;i<n;i++){ C[row*n+i] = A[row*n +i] * B[row*n+i]; } } __global__ ...
19,539
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <cuda_runtime.h> #define max(x,y) (x>y?x:y) #define min(x,y) (x>y?y:x) #define THREAD_NUM 256 int BLOCK_NUM=0; void matgen(double* a, int n, int m) { for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { a[i ...
19,540
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> //M and N number of threads (grid and block) __global__ void multiply( const int a[] ,const int b[], int c[] , const int sqrt_dim,const int thread_number) { int index...
19,541
#include <curand.h> #include <curand_kernel.h> extern "C" { __global__ void init( unsigned long long int* seed, curandState * state){ int id = threadIdx.x; curand_init(*seed, id, 0, &state[id]); } __device__ void pi(const float &x, float *pars, float &p){ p = expf(-powf(fabsf(...
19,542
#include "includes.h" static const int NTHREADS = 32; __global__ void cunn_ClassNLLCriterion_updateGradInput_kernel1( float* gradInput, float* weights, float* target, float* total_weight, int size_average, int n_classes) { if (*total_weight <= 0) { return; } float norm = size_average ? (1.0f / *total_weight) : 1...
19,543
// Amarjot Singh Parmar #include <iostream> #include <math.h> #include <stdio.h> #include <unistd.h> __device__ int getIndex(int x, int y, int rows){ // (size * 3) * y + (x * 3) int result = (rows * 3) * y; result = result + (x * 3); return result; } __device__ int getCellNeighbours(int index, int *gen, int rows,...
19,544
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <chrono> using namespace std; static inline void _safe_cuda_call(cudaError err, const char* msg, const char* file_name, const int line_number) { if(err!=cudaSuccess) { fprintf(stderr,"%s\n\nFile: %s\n\nLine Number: %d\n\nReason: %s\n",msg,file_name...
19,545
#include "includes.h" __global__ void kNormLimitColumnwise(float* mat, float* target, float norm, unsigned int width, unsigned int height) { __shared__ float sum_vals[33]; float cur_sum = 0; for (unsigned int i = threadIdx.x; i < height; i += 32) { cur_sum += mat[blockIdx.x * height + i] * mat[blockIdx.x * height + i];...
19,546
/********************************************************************** * DESCRIPTION: * Wave Equation - cu Version * This program implements the concurrent wave equation *********************************************************************/ #include <stdio.h> #include <stdlib.h> #include <math.h> #include ...
19,547
/** * @ Author: Minhua Chen * @ Create Time: 2019-08-24 11:41:39 * @ Modified by: Minhua Chen * @ Modified time: 2019-08-24 12:09:28 * @ Description: */ #include <stdio.h> #include<cuda.h> #include<cuda_runtime.h> #define BLOCK_NUM 32 //块数量 #define THREAD_NUM 256 // 每个块中的线程数 #define R_SIZE BLOCK_NUM * THREAD_...
19,548
/* источник: https://www.packetizer.com/security/sha1/ */ /* * Эта структура будет содержать контекстнуб информацию * для орепации хэширования */ typedef struct SHA1Context { unsigned Message_Digest[5]; /* подписть сообщения (выходная) */ unsigned Length_Low; /* длина сообщения в битах ...
19,549
__global__ void vec_add_kernel(float *c, float *a, float *b, int n) { int i = 0; // Oops! Something is not right here, please fix it! if (i < n) { c[i] = a[i] + b[i]; } }
19,550
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> __global__ void print_details() { printf("blockIdx.x : %d, blockIdx.y : %d, blockIdx.z : %d, blockDim.x : %d, blockDim.y : %d, gridDim.x : %d, gridDim.y :%d \n", blockIdx.x, blockIdx.y, blockIdx.z,blockDim.x, blockDim.y, gridDim.x, ...
19,551
extern "C" __global__ void make_gpu_busy(int* buf, size_t size, int iterations) { size_t idx = threadIdx.x + blockIdx.x * blockDim.x; size_t step = blockDim.x * gridDim.x; for (size_t i = idx; i < size; i += step) { float f = buf[i]; double f2 = buf[i]; for (int j = 0; j < itera...
19,552
/************************************\ | filename: escape.c | | description: sequential version | of code that outputs a .PGM file of | a Mandelbrot fractal. | | notes: the number of pixels, 2400x2400 | was chosen so that it would take a fair | amount of time to compute the image so | that speedup may be observed on i...
19,553
/* Name: Matthew Matze Date: 11/1/2016 Class: csc4310 Location: ~/csc4310/cuda_mult3 General Summary of Program The program is designed to take two matrices via input files and output the result into the resultant file. To Compile: nvcc cudamultv3.cu -o cudamultv3 To Execute: cudamultv3...
19,554
#include "includes.h" __global__ void profileSubphaseComputeCoarseA_kernel() {}
19,555
#include "includes.h" __global__ void relabelKernel(int *components, int previousLabel, int newLabel, const int colsComponents) { uint i = (blockIdx.x * blockDim.x) + threadIdx.x; uint j = (blockIdx.y * blockDim.y) + threadIdx.y; if (components[i * colsComponents + j] == previousLabel) { components[i * colsComponents ...
19,556
__global__ void per_row_kernel(int m,int n,int *A,int *B,int *C) { long long int total_no_of_threads=blockDim.x*blockDim.y*blockDim.z; long long int id=threadIdx.x + blockIdx.x * blockDim.x; for(long long int i=id;i<m;i+=total_no_of_threads) { for(long long int j=0;j<n;j++) C[i*n +...
19,557
#include "fastgemm.cuh" void printMatrix(float* mat, int row, int col) { for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { if (j < 10) printf("%6.1lf ", mat[i*col + j]); else { printf(" ..."); break; } } printf("\n"); if(i > 10) break; }...
19,558
#include <stdio.h> const int N = 256; __global__ void hello(char *a) { printf("Hello from thread %d\n", threadIdx.x); // printf("Hello from thread %d with letter %c\n", threadIdx.x, a[threadIdx.x % 32]); } int main() { char a[N] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ01234"; char *a_d; const int csize = N*sizeof(c...
19,559
#include <iostream> #include <iomanip> #include <stdio.h> #include <stdlib.h> #include <time.h> #include "cuda_fp16.h" // float16 半精度计算 100万2048维向量,占显存4G // 注意:精度降低可能导致计算结果错误 using namespace std; const int D = 2048...
19,560
#include <iostream> #include <fstream> #include <ctime> #include <cuda.h> #include <cuda_runtime.h> //#define WRITE_TO_FILE using namespace std; //Обработчик ошибок static void HandleError(cudaError_t err, const char *file, int line) { if (err != cudaSuccess) { ...
19,561
/* NiuTrans.Tensor - an open-source tensor library * Copyright (C) 2017, Natural Language Processing Lab, Northeastern University. * All rights reserved. * * 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 ...
19,562
#include<bits/stdc++.h> #include<thrust/device_vector.h> #include<thrust/transform.h> #include<thrust/extrema.h> #include<thrust/copy.h> #include<thrust/functional.h> using namespace std; struct process { __host__ __device__ int operator()(const float& x, const float& y) const { return (x-y>=0?x-y:0); } }; int sche...
19,563
//Based on the work of Andrew Krepps // C #include <stdio.h> // C++ #include <chrono> #include <functional> #include <initializer_list> #include <vector> /////////////////////////////////////////////////////////////////////////////// // Constants //////////////////////////////////////////////////////////////////////...
19,564
#include "includes.h" __global__ void LSTMDeltaKernel( float *cellStateErrors, float *outputGateDeltas, float *cellStates, float *outputGateActivations, float *outputGateActivationDerivatives, float *deltas, int cellCount, int cellsPerBlock ) { int memoryBlockId = blockDim.x * blockIdx.y * gridDim.x //rows preceeding ...
19,565
#include<stdio.h> int main(){ printf("Hello World!!!"); return 0; }
19,566
#include "kernel.cuh" namespace kernel { __device__ void WarpReduce( volatile int* shared, const unsigned int tid, const unsigned int tid_global, const unsigned int size) { if (tid_global + 32 < size) { shared[tid] += shared[tid + 32]; } if (tid_global + 16 < size) { shared[tid] += shar...
19,567
/* Odd-even sort * This will need to be called within a loop that runs from 0 to * the ceiling of N/2 - 1, where N is the number of eigenvalues * We assume a linear array of threads and it will be the caller's * responsibility to ensure the thread indices are in bounds * Note to self: There is a GPU Quicksort avai...
19,568
#include <stdio.h> #include <stdexcept> #include <cuda_runtime.h> #include <math.h> #include <device_launch_parameters.h> #include <device_functions.h> #include <cuda.h> #include <cuda_runtime_api.h> void LayerSynchronize() { if (cudaGetLastError() != cudaError::cudaSuccess) { throw std::runtime_error("CUDA metho...
19,569
/** Copyright (c) 2015 <wataro> This software is released under the MIT License. http://opensource.org/licenses/mit-license.php */ #include <cuda.h> void * allocate_cuda_memory(size_t size) { void * p = nullptr; cudaMalloc(&p, size); return p; } void delete_cuda_memory(void * p) { cu...
19,570
#include <cmath> #include <cstdio> #include <cstring> #include <string> #include <algorithm> #include <iostream> #include <cuda.h> #include <cuda_runtime.h> #include <device_launch_parameters.h> #include <device_functions.h> #include <cuda_runtime_api.h> using namespace std; typedef double ld; typedef long long LL; ...
19,571
#include<iostream> #include<fstream> void write_ply(float *triangles, int data_length, char *output_file){ std::fstream plyfile; plyfile.open(output_file, std::fstream::out); printf("Writing\n"); plyfile << "ply\nformat ascii 1.0\n"; plyfile << "element vertex \n"; // need to come back and add amo...
19,572
#include <math.h> #include <cstdio> #include <cstdlib> #include <time.h> // Assertion to check for errors #define CUDA_SAFE_CALL(ans) { gpuAssert((ans), __FILE__, __LINE__); } inline void gpuAssert(cudaError_t code, char *file, int line, bool abort=true) { if (code != cudaSuccess) { fprintf(stderr,"CUDA_SAFE_CALL...
19,573
#include "includes.h" // ERROR CHECKING MACROS ////////////////////////////////////////////////////// __global__ void createQueryPoints(int noPoints, int noDims, int dimRes, int control, int noControls, int year, float* xmins, float* xmaxes, float* regression, float* queryPts) { // Global thread index int idx = bloc...
19,574
// Dan Wolf #include <iostream> #include <string> #include <chrono> // https://stackoverflow.com/questions/14038589/what-is-the-canonical-way-to-check-for-errors-using-the-cuda-runtime-api/14038590#14038590 #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } inline void gpuAssert(cudaError_t code, const ...
19,575
#include <stdio.h> #include <stdlib.h> #include <string.h> /* memcpy */ #include <math.h> #include <stdint.h> void *cuda_upload_var(void *host_var, int size) { void *cuda_var; cudaMalloc(&cuda_var, 4); cudaMemcpy(cuda_var, host_var, size, cudaMemcpyHostToDevice); return cuda_var; } void cuda_download_var(void *cud...
19,576
#include <iostream> #include <algorithm> #include <ctime> using namespace std; #define N 100000 #define RADIUS 3 #define BLOCK_SIZE 16 __global__ void stencil_1d(int *in, int *out){ __shared__ int temp[BLOCK_SIZE + 2 * RADIUS]; int gindex = threadIdx.x + blockIdx.x * blockDim.x; int lind...
19,577
#include <assert.h> #include <cuda.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #define MAX_SAMPLE 10000 #define MAX_FEATURE 100 #define STEP_SIZE 0.005 #define NUM_ITER 10000 #define TILE_WIDTH 32 #define BLOCK_SIZE 1024 /** * Check error when calling CUDA API. ...
19,578
#include <cuda.h> #include <cuda_runtime.h> #include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include <math.h> #include "getopt.h" __global__ void register_bandwidth_test(){ } int main(){ return 0; }
19,579
#include <cuComplex.h> __global__ void gen(int px_per_block[2],int px_per_thread[2],int size[2],float position[2],float *zoom, int *iterations,int *result, int* progress,int action) { //blockDim = size of threads per block //gridDim = size of blocks //int size[2] argument is just to make sure we don't...
19,580
#include <cuda.h> #include <stdio.h> #include <stdlib.h> #include <time.h> #define BLOCK_SIZE 16 // Kernel __global__ void cudaMultiplyArrays(int* dA, int* dB, int* dC, int hA, int wA, int hB, int wB, int hC, int wC) { int y = blockIdx.y * BLOCK_SIZE + threadIdx.y; // row int x...
19,581
#include <cmath> #include <iostream> int main(void) { int devices = 0; cudaGetDeviceCount(&devices); cudaDeviceProp prop; for ( int i = 0; i < devices; ++i ) { cudaGetDeviceProperties(&prop, i); std::cout << "=== Device number " << i << " ===" << std::endl; std::cout << ...
19,582
#include <cuda.h> #include <stdio.h> #include <float.h> #define ARRAY_SIZE 2000000 // 2 MB #define BLOCK_SIZE 256 // with 512 block size the shared memory requirement will overshoot the available limit #define NTIMES 10 #define MIN(x,y) ((x)<(y)?(x):(y)) #define MAX(x,y) ((x)>(y)?(x):(y)) /////////////////////...
19,583
/******************************************************************************* * serveral useful gpu functions will be defined in this file to facilitate * the surface redistance scheme ******************************************************************************/ typedef struct { double sR; double sL; } doub...
19,584
#include <iostream> #define checkCudaErrors(val) check_cuda((val), #val, __FILE__, __LINE__) void check_cuda(cudaError_t result, char const* const func, char const* const file, int const line) { if (result) { std::cerr << "CUDA error = " << static_cast<unsigned int>(result) << " at " << file << ":" << line << "...
19,585
#include <stdio.h> #include <random> #include <sys/time.h> #include <stdlib.h> #define SEED 123 #define MARGIN 1e-6 double cpuSecond() { struct timeval tp; gettimeofday(&tp,NULL); return ((double)tp.tv_sec + (double)tp.tv_usec*1.e-6); } float Uniform(){ std::default_random_engine generator; std::un...
19,586
#include <stdio.h> int main() { int nDevices; cudaGetDeviceCount(&nDevices); printf("N dispositivos: %d\n",nDevices); cudaDeviceProp prop; for (int i = 0; i < nDevices; i++) { cudaGetDeviceProperties(&prop, i); printf("Device Number: %d\n", i); printf(" Device name: %s\n", prop.name); printf(" Size wa...
19,587
// Save the position and momentum of particle 0 #include <stdlib.h> #include <math.h> #include <stdio.h> void save_seq( double time, long nseq, double *r_gpu, double *p_gpu, double *f_gpu, FILE *fseq, FILE *fseq2, FILE *fseq3) { long i; double pp[nseq],rr[nseq],ff[nseq],tpi,r2; tpi=6.2831853071795864770; ...
19,588
#include "includes.h" __global__ void _mat_sum_col(float *m, float *target,int nrow, int ncol){ int tid = blockIdx.x * blockDim.x + threadIdx.x; if(tid < ncol){ float sum = 0; for(int i = 0; i < nrow; i++){ sum += m[i*ncol+tid]; } target[tid] = sum; } }
19,589
#include "includes.h" // filename: gax.cu // a simple CUDA kernel to add two vectors extern "C" // ensure function name to be exactly "gax" { } __global__ void vmultbangupdate(const int lengthA, const double alpha, const double *a, const double *b, double *c) { int i = threadIdx.x + blockIdx.x * blockDim.x; if (i<le...
19,590
/* 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...
19,591
/* * EDDL Library - European Distributed Deep Learning Library. * Version: 1.1 * copyright (c) 2022, Universitat Politècnica de València (UPV), PRHLT Research Centre * Date: March 2022 * Author: PRHLT Research Centre, UPV, (rparedes@prhlt.upv.es), (jon@prhlt.upv.es) * All rights reserved */ #include <string.h> #inclu...
19,592
#define get_global_size() (blockDim.x * gridDim.x) #define get_global_id() (threadIdx.x + blockIdx.x * blockDim.x) #define get_local_id() (threadIdx.x) #define get_local_size() (blockDim.x) __device__ double gpu_mmap_result = 0.0; extern "C" __global__ __launch_bounds__(1024) void gpu_mmap_init(char *buffer, si...
19,593
#include <iostream> int main() { cudaDeviceProp prop; int count = 0; cudaGetDeviceCount(&count); for(int i = 0; i < count; ++i) { cudaGetDeviceProperties(&prop, i); std::cout << "Information for device #" << i << std::endl; std::cout << "Name " << prop.name << std::endl; ...
19,594
#include "includes.h" __global__ void cu_divide(const float numerator, const float* denominator, float* dst, const int n){ int tid = threadIdx.x + blockIdx.x * blockDim.x; int stride = blockDim.x * gridDim.x; while(tid < n){ if(0 == denominator[tid]) dst[tid] = 0.0; else dst[tid] = __fdividef(numerator, denominator[tid...
19,595
/* This is a automatically generated test. Do not modify */ #include <stdio.h> #include <stdlib.h> #include <math.h> __global__ void compute(float comp, float 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,floa...
19,596
#include "includes.h" __global__ void cube(float * d_out, float * d_in) { int id = threadIdx.x; float num = d_in[id]; d_out[id] = num * num; }
19,597
/** * Parametric equalizer back-end GPU code. */ #include <cuda_runtime.h> #include <cufft.h> #include "parametric_eq_cuda.cuh" const float PI = 3.14159265358979; /** * This kernel takes an array of Filters, and creates the appropriate * output transfer function in the frequency domain. This just involves a *...
19,598
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> #include "cuda.h" __global__ void kernelAddMatrices1D(int N, double *A, double *B, double *C) { int threadId = threadIdx.x; int blockId = blockIdx.x; int blockSize = blockDim.x; //32 int id = threadId + blockId*blockSize; C[id] ...
19,599
#include <bits/stdc++.h> using namespace std; int main() { // size of row int row = 5; int colom[] = { 5, 3, 4, 2, 1 }; // Create a vector of vector with size // equal to row. vector<vector<int> > vec(row); for (int i = 0; i < row; i++) { // size of column ...
19,600
#include "includes.h" __global__ void _bcnn_forward_softmax_layer_kernel(int n, int batch, float *input, float *output) { float sum = 0.f; float maxf = -INFINITY; int b = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x; if (b >= batch) { return; } for (int i = 0; i < n; ++i) { int val = input[i + b * ...