serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
21,001
#include "includes.h" /* * file name: mm_omp_vs_cuda.cu * * mm_omp_vs_cuda.cu contains the code that realize some common used matrix operations in CUDA, and * an implementation of matrix multiplication speedup via openmp, this is a practice to compare the * of performance of cuda and openmp, as well as a trail of u...
21,002
//this program will assume a 98x98x98 grid with 2 cells of zero padding for the E fields //the padded zeros act as PEC boundaries //The H fields will be 99x99x99 (offset by half cell, inside the PEC boundary) #include <vector> #include <stdio.h> #include <iostream> #include <sstream> #include <string> #include <fstrea...
21,003
__global__ void somme( int taille, float * a, float * b, float *c ){ int index=threadIdx.x+blockDim.x*blockIdx.x; if(index>=taille) return; c[index]=a[index]+b[index]; } __global__ void prod( int taille, float * a, float b, float *c ){ int index=threadIdx.x+blockDim.x*blockIdx.x; ...
21,004
#pragma region License /* The MIT License Copyright (c) 2009 Sky Morey 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, m...
21,005
__device__ void rgb_hsv_single(unsigned char rc, unsigned char gc, unsigned char bc, float *h, float *s, float *v) { // Adapted and simplified from https://github.com/jakebesworth/Simple-Color-Conversions float min, max, delta; float r, g, b; r = (float) rc / 255.0; g = (float) gc / 255.0; b = (float) b...
21,006
#include "includes.h" __global__ void calculateEvalue( const int q_begin, const int matchSize, const double totalDatabaseSize, const double K, const double lambda, const int* queryLengthArray, const int* queryIDArray, const int* scoreArray, double* evalueArray) { const int idx = blockDim.x * blockIdx.x + threadIdx.x; ...
21,007
#include "includes.h" __device__ __forceinline__ float imag(const float2& val) { return val.y; } __global__ void MemsetKernel(const float value, int w, int h, float *image) { int i = threadIdx.y + blockDim.y * blockIdx.y; int j = threadIdx.x + blockDim.x * blockIdx.x; if (i >= h || j >= w) return; const int pos = i *...
21,008
#include <math.h> #include <stdio.h> static const int blockSize = 1024; static const int gridSize = 24; //this number is hardware-dependent; usually #SM*2 is a good number. __device__ float myPower(float* number, int degree) { float result = 1.0; int fraction = 0; if(degree == 0) { return result; } else...
21,009
/* #v1 Ideia: Transformar as matrizes em transpostas para nao precisar fazer ler dois ponteiros, apenas usar o deslocamento Resultado: Aumento de performance. Tempo 1/8 vezes o anterior #8.2 -> 1.1 #v2 Ideia: Transformar matriz em vetor para preparar para CUDA Resultado: Perda de desempenho. Tempo 2.4 vezes o anterior...
21,010
#include <iostream> #include "memory.h" struct aAnimal { virtual void speak()const = 0; virtual aAnimal* clone() const=0; virtual ~aAnimal(){ std::cout << "Animal Destructor\n"; } }; //Yes pure virtual functions can have a definition void aAnimal::speak()const{ std::cout << "I am ";} struct ...
21,011
#include "includes.h" __global__ void kCorrectPreds(float* mat, float* p, float* target, unsigned int len, float cutoff) { 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) { target[i] = mat[i] * ...
21,012
#include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <cuda_runtime.h> __global__ void process_kernel1(float *input1, float *input2, float *output, int datasize){ int blockNum = blockIdx.z * (gridDim.x * gridDim.y) + blockIdx.y * gridDim.x + blockIdx.x; int threadNum = threadIdx.z * (bloc...
21,013
#include "includes.h" __global__ void kernel_1024_one_256(float *A, float *B, float *bnBias, float *bnScale, float *C) { int tile = blockIdx.x, in_channel = threadIdx.x, line = threadIdx.y; int ind = line*256 + in_channel; extern __shared__ float shared_[]; float *weights = shared_ + 1024*4, *output = weights + 256*16...
21,014
#include <iostream> #include <cuda.h> #include <cuda_runtime.h> #include <stdio.h> int WIDTH = 400; int HEIGHT = 300; __device__ double translatex(int x) { return x/100.0 - 2.0; } __device__ double translatey(int y) { return y/100.0 - 1.5; } __global__ void mandel(int* gpu_t) { int tmax = 100; double x = trans...
21,015
/**********************************************************************\ * Author: Jose A. Iglesias-Guitian * * C/C++ code * * Introduction to CUDA * /**********************************************************************/ // Instructions: How to compile this...
21,016
#include <cuda_runtime.h> #include <stdio.h> #include <iostream> using namespace std; /* Mirror operations */ __global__ void mirror(uchar4* inputChannel, uchar4* outputChannel, int numRows, int numCols, bool vertical) { int TotalThread = blockDim.x * gridDim.x; int stripe = numRows*numCols / TotalThread; int col...
21,017
/** * Main CUDA file for running parallel cellular automaton. * @author Logan Apple * @date 5/15/2020 */ #include "gol.cuh" // What if I just passed the grid instead? __host__ __device__ uint8_t count_neighbors(int x, int y, int width, int height, ...
21,018
#include <iostream> #include <string> #include <sstream> #include <fstream> #include <algorithm> #include <chrono> #include <stdio.h> #include <stdlib.h> #include <stdarg.h> #include <cuda.h> #include <unistd.h> //#define _DEBUG_ //#define _TIME_MEASURE_ #ifdef _DEBUG_ #include <string> #include <sstream> ...
21,019
#include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <time.h> #include <curand.h> #include <curand_kernel.h> #define NUM_THREADS 1000 #define NUM_BLOCKS 100 #define HH 1e7 typedef struct { int width; int height; double* elements; } Matrix; extern "C" void fkpaths(double *domain, Matrix ...
21,020
#include "includes.h" __global__ void BaseNeuronGetIntArray(int *arr1, int *arr2, int n_elem, int step1, int step2) { int array_idx = threadIdx.x + blockIdx.x * blockDim.x; if (array_idx<n_elem) { arr2[array_idx*step2] = arr1[array_idx*step1]; } }
21,021
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> #include <cuda.h> #include <cuda_runtime.h> #include <curand_kernel.h> __global__ void conv1d(int *input, int *kernel, int *output, int l, int k) { int tid = blockIdx.x * blockDim.x + threadIdx.x; int r = k / 2; int start = tid - r; int tem...
21,022
//This benchmark measures the maximum read bandwidth of GPU memory //Compile this file using the following command to disable L1 cache: // nvcc -Xptxas -dlcm=cg -Xptxas -dscm=wt l2_bw.cu //This code have been tested on Volta V100 architecture //You can check the mem BW from the NVPROF (dram_read_throughput+dram_wr...
21,023
#include "stdio.h" #include <cuda_runtime.h> static const int N=100000; /* Saxpy: Z = a * X + Y, where - all variables are single precision, - a is a constant - X is a vector - Y is a vector */ __global__ void saxpy (float a, float *x, float *y, float *z, int N) { int i = blockDim.x * blockIdx.x + threadIdx.x...
21,024
#include "includes.h" __global__ void count(int *data,int input, int *result) { int i = blockIdx.x * blockDim.x + threadIdx.x; if(data[i] == input) { int a = 1; atomicAdd(result,a); } }
21,025
/////////////////////////////////////////////////// //////////// Multi-Node Kernels /////////////////// /////////////////////////////////////////////////// __device__ void ComputeParticles_Multi(void* params){ //CUDA Threads int warp_size = 2; int tid = threadIdx.x%warp_size; //Extract all the values. ...
21,026
#include "includes.h" __global__ void set_all_zero_kernel(double *ua_gpu, double *ub_gpu, double *uc_gpu) { ua_gpu[blockIdx.x * blockDim.x + blockIdx.y] = 0; ub_gpu[blockIdx.x * blockDim.x + blockIdx.y] = 0; uc_gpu[blockIdx.x * blockDim.x + blockIdx.y] = 0; // TODO: sync CPU after this -> move to utils.cu file }
21,027
#include "input.hh" #include "graph.hh" #include "../runtime/graph.hh" #include "../runtime/node.hh" #include "../memory/alloc.hh" namespace ops { namespace { std::size_t unique_id() { static std::size_t res = 0; return res++; } } Input::Input(const Sha...
21,028
#include <stdio.h> #include <stdlib.h> #include <cuda.h> #define N 5 __global__ void Add(int *a, int*b, int *c){ int i = blockIdx.x; if(i<N){ c[i] = a[i] + b[i]; } } int main(){ int a[N] = {1,2,3,4,5}, b[N] = {5,6,7,8,9}; int c[N]; int *dev_a, *dev_b, *dev_c; cudaMalloc((void**)&dev_a, N*sizeof(in...
21,029
#include<iostream> #include<math.h> #include<stdint.h> #include<stdlib.h> #define N 16 #define M 16 __global__ void convolve(uint8_t input[N][M], uint8_t *val, int i, int j) { int kernel[25] = { 1, 4, 7, 4, 1, 4,16,26,16, 4, 7,26,41,26, 7, 4,16,26,16, 4, 1, 4, 7, 4, 1 }; int k_pos = 0; int w...
21,030
#include "includes.h" __device__ void softmax_device(float *input, int n, float temp, int stride, float *output) { int i; float sum = 0; float largest = -INFINITY; for(i = 0; i < n; ++i){ int val = input[i*stride]; largest = (val>largest) ? val : largest; } for(i = 0; i < n; ++i){ float e = expf(input[i*stride]/temp - ...
21,031
#include "test.cu"
21,032
#include <curand.h> #include <curand_kernel.h> #include <math.h> #include <iostream> #define ITERATIONS 104000 #define BATCH_SIZE 2097152 #define MAX_REGISTER 5 #define SEED 314159 #define MAX_ZEROES 3 #define MAX_TRANSFERS 7 #define MAX_JUMPS 4 #define MAX_INSTRUCTIONS 150 #define PROGRAM_LINES 10 #define PROGRAM_...
21,033
/* Copyright 2017 the arraydiff authors 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 agreed to in writing, so...
21,034
#include "includes.h" __global__ void addKernel(int* c, const int* a, const int* b, int size) { int i = blockIdx.x * blockDim.x + threadIdx.x; // since we're asking for one more thread than elements in the arrays // we need to handle size to make sure we don't access beyond the end of the array if (i < size) { c[i] = a...
21,035
#include "includes.h" __global__ void windowBartlett2d(float* idata, int length, int height) { int tidx = threadIdx.x + blockIdx.x*blockDim.x; int tidy = threadIdx.y + blockIdx.y*blockDim.y; if (tidx < length && tidy < height) { idata[tidy * length + tidx] = 0; } }
21,036
#include "Constants.cu" __global__ void CUDA_global_selfProd(svm_precision* b_selfProd, svm_precision* b_inputData); __global__ void CUDA_global_test(svm_precision* b_output, svm_precision* b_selfProd, svm_precision* b_inputData, svm_precision* b_class, svm_precision* b_alpha); __global__ void CUDA_global_errorCacheUp...
21,037
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> #define ROW 6 #define N (6*6) //2048*2048 #define THREADS_PER_BLOCK (ROW/2) //1024 #define RADIUS 3 #define BLOCK_SIZE (THREADS_PER_BLOCK-2*RADIUS) // forward declaration __global__ void dila(int *in, int *out); void random_ints(int * mat, in...
21,038
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args #include <iostream> // CHECK: #include <hip/hip_runtime.h> #include <cuda.h> #define TOKEN_PASTE(X, Y) X ## Y #define ARG_LIST_AS_MACRO a, device_x, device_y #define KERNEL_CALL_AS_MACRO axpy<float><<<1, kDataLen>>> #define KERNEL_NAME_MACRO axpy<float> //...
21,039
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <iostream> #include <cuda.h> __global__ void mean_filter_gpu(unsigned char* input_image, int img_height, int img_width,unsigned char* filtered_image, int window_size){ int col = blockIdx.x * blockDim.x + threadIdx.x; int row = blockIdx.y * blockDim....
21,040
#include "includes.h" __global__ void kBoundingBoxSoftMaxGrad( 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 unsigned int len = width * height * depth * size;...
21,041
#include "includes.h" __global__ void arrayTest(int n, long *factor, long *arr, long *result, int *const_arr1, long *const_arr2) { int i = blockIdx.x * blockDim.x + threadIdx.x; if(i == 0) { /* printf("In ArrayTest n=%d factor=%p arr=%p result=%p \n",n,factor,arr,result); printf("In const %d %d %d\n",const_arr1[0],cons...
21,042
#include "includes.h" __global__ void matrixTranspose(double *a, double *c, int cr, int cc){ int x = blockIdx.x * blockDim.x + threadIdx.x; // col int y = blockIdx.y * blockDim.y + threadIdx.y; // row if(x < cc && y < cr){ for(int i = 0; i<cc; i++) { c[y * cc + x+i] = a[x * cc + y + i]; } } }
21,043
/* SorensonPar.cu Parallel Implementation of Algorithm 4.1 as discussed in Sorenson and Parberry's 1994 paper "Two Fast Parallel Prime Number Sieves". Authors: Daniel Anzaldo David Frank Antonio Lanfranchi */ // Visual Studio Dependencies (Can be commented out) #include "cuda_runtime.h" #inclu...
21,044
#include "includes.h" __global__ void CumulatePositionOfNewObjects(float* mask , float* maskNewIds , float* maskOut, int mask_size, int mask_cols, float* centers, int centers_size, int centers_columns){ int idx = blockDim.x*blockIdx.y*gridDim.x + blockDim.x*blockIdx.x + threadIdx.x; int icol = idx % mask_cols; int irow...
21,045
/* * 线性内存通常使用cudaMalloc()分配,并使用cudaFree()释放, * 并且主机内存和设备内存之间的数据传输通常使用cudaMemcpy()完成。 * 在内核的向量加法代码示例中,需要将向量从主机存储器复制到设备存储器: */ #include <stdio.h> // Kernel definition __global__ void VecAdd(float* A, float* B, float* C) { int i = threadIdx.x; C[i] = A[i] + B[i]; C[i] = A[i] + B[i]; } int main...
21,046
#include "includes.h" __global__ void update3(float *rho_out, float *H0_out, const float *yDotS, const float *yDotY) { *rho_out = 1.0f / *yDotS; if (*yDotY > 1e-5) *H0_out = *yDotS / *yDotY; }
21,047
// Steps to be followed while creating a new table // 1. Parse the query - Create TableName // 2. Check if TableName already exists in Database, if not add it to Database. // 3. Create TableName.data and TableName.mdata inside DB // 4. Poppulate TableName.mdata using specifics in the query // Sample Query - "CREATE TAB...
21,048
#include <stdio.h> __global__ void transpose(unsigned char *odata, const unsigned char *idata, int H, int W) { int N = gridDim.y; // batch size int n = blockIdx.y; // batch number int C = gridDim.z; // channel int c = blockIdx.z; // channel number long idx = n * blockDim.x ...
21,049
#include<stdio.h> #include<stdlib.h> #include<sys/time.h> #include<string.h> #include<math.h> #define NUM 10000000 #define CUDA_ERROR_EXIT(str) do{\ cudaError err = cudaGetLastError();\ if( err != cudaSuccess){\ ...
21,050
#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 :...
21,051
#include<iostream> #define N 33*256 #define threadPerBlock 256 #define blockPerGrid 32 __global__ void dot(float *a,float *b,float *c) { __shared__ float cache[threadPerBlock]; int tid = threadIdx.x + blockIdx.x*blockDim.x; int cacheIndex = threadIdx.x; float temp =0; while(tid < N) { temp += a[tid]*b[tid]; t...
21,052
#include<stdio.h> #include<cuda.h> # define s 1000 __global__ void min(int *a,int *c) { int id=threadIdx.x; *c=a[0]; if(a[id]<*c) { *c=a[id]; } } __global__ void max(int *a,int *d) { int id=threadIdx.x; *d=a[0]; if(a[id]>*d) { *d=a[id]; } } int main() { int i,a[s],c,d; int *dev_...
21,053
#include <sys/time.h> #include <stdio.h> #include <stdlib.h> double wtime(void) { double now_time; struct timeval etstart; struct timezone tzp; if (gettimeofday(&etstart, &tzp) == -1) perror("Error: calling gettimeofday() not successful.\n"); now_time = ((double)etstart.tv_sec) ...
21,054
#include <stdio.h> #include <stdlib.h> #include <time.h> #define MAX_DIM 32 #define SCALING_FACTOR 10.0 #define TILE_DIM 32 #define NUM_THREADS 1024 #define MOD_BASE 256 #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true...
21,055
#define MAX_DWELL 256 /** a simple complex type */ struct complex { __host__ __device__ complex(float re, float im = 0) { this->re = re; this->im = im; } /** real and imaginary part */ float re, im; }; // struct complex // operator overloads for complex numbers ...
21,056
extern "C" __global__ void fMatrixExp( const float* arguments, float* results, const int states ) { const int X = gridDim.x; const int col = gridDim.y * X * threadIdx.x + X * blockIdx.y + blockIdx.x; if (col < states) { float sum = 0; for (int j = 0; j < states - 1; j++) { results[col *...
21,057
#include <stdio.h> #include <stdlib.h> #define L (512) #define N (100) int main(){ int mat_A[N][L]; int mat_B[N][L]; int (*d_A)[N]; //pointers to arrays of dimension N int (*d_B)[N]; //pointers to arrays of dimension N //allocate values to matrices for(int i = 0; i < N; i++) {...
21,058
#include <stdint.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <time.h> #include <assert.h> __global__ void sum_arrays_on_device(float *c, float *a, float *b) { uint32_t i = threadIdx.x + blockIdx.x*blockDim.x; c[i] = a[i] + b[i]; } void initialize_data(float *host_data, ...
21,059
/***************************************************************************** Example :cuda-matrix-matrix-multiplication-mgpu.cu Objective : Write CUDA program to compute Matrix-Matrix multiplication to be executed on multiple GPUs.(using global memory) Input : None Output ...
21,060
#include "includes.h" __global__ void vecAddKernel(float *a, float *b, float *c, int n) { //ID del thread int id = blockIdx.x*blockDim.x+threadIdx.x; //No salir del tamaño del vector if (id < n) c[id] = a[id] + b[id]; }
21,061
#include <stdio.h> #include <future> #include <thread> #include <chrono> #include <iostream> #include <iterator> #include <cstring> #define N 1000000 #define SIZE 100 __constant__ int factor = 0; __global__ void vectorAdd(int *a, int *b, int *c) { int i = blockIdx.x*blockDim.x + threadIdx.x; c[i] = factor*(...
21,062
/* Reduction summation algorithm (with sequential addressing) made by: Carrick McClain Sources: http://developer.download.nvidia.com/compute/cuda/1.1-Beta/x86_website/projects/reduction/doc/reduction.pdf some guidance from https://stackoverflow.com */ #include <cuda.h> #include <cuda_runt...
21,063
#include <cuda.h> #include <stdio.h> int main() { int count; cudaDeviceProp prop; cudaGetDeviceCount(&count); printf("Count CUDA device = %i\n", count); for (int i = 0; i < count; i++) { cudaGetDeviceProperties(&prop, i); printf("Device %d\n", i); printf("Compute capability : %d.%d\n", prop...
21,064
//STL #include <iostream> #include <vector> #include <time.h> #include <algorithm> using std::cout; using std::endl; using namespace std; unsigned i; const unsigned N = 2048 * 4, bigN = 1000000; unsigned gpuThr = 512; unsigned gpuBl = N / gpuThr; std::vector < float > inputVec( N ); void hostCalculateDCTPSNR( vector ...
21,065
#include<cuda_runtime.h> #include<thrust/scan.h> #include<thrust/functional.h> #include<iostream> int add_(int a, int b) { return a+b; } __device__ int log_plus(int a, int b) { return a+b; } __device__ int segscan_warp(int* ptr, bool* hd, int idx) { const unsigned int lane = idx & 31; if (...
21,066
#include<stdio.h> #include<stdlib.h> __global__ void arradd(int* md, int* nd, int* pd) { int myid = threadIdx.x; pd[myid] = md[myid] + nd[myid]; } int main() { int size = 200 * sizeof(int); int m[200], n[200], p[200],*md, *nd,*pd; int i=0; for(i=0; i<200; i++ ) { m[i] = i; n[i] = i; p[i] = 0; } cu...
21,067
#include "includes.h" __global__ void reluActivationForward(float* Z, float* A, int Z_x_dim, int Z_y_dim) { int index = blockIdx.x * blockDim.x + threadIdx.x; if (index < Z_x_dim * Z_y_dim) { A[index] = fmaxf(Z[index], 0); } }
21,068
#include "includes.h" __global__ void VectorAdd(int *a, int *b, int *c, int n) { // Get our global thread ID int i = blockIdx.x*blockDim.x+threadIdx.x; //for (i = 0; i < n; ++i) // replaced // Make sure we do not go out of bounds if (i < n) c[i] = a[i] + b[i]; }
21,069
#include <iostream> #include <stdlib.h> #include <cuda.h> #include <cuda_runtime.h> #include <device_launch_parameters.h> #include "parallel.cuh" using std::cout; using std::flush; using std::endl; __global__ void plus100Kernel(int *input, int* output) { int i = blockIdx.x * blockDim.x + threadIdx.x; if (i ...
21,070
#include <thrust/device_vector.h> #include <thrust/sort.h> #include <thrust/inner_product.h> #include <thrust/reduce.h> void count(const thrust::device_vector<int>& d_in, thrust::device_vector<int>& values, thrust::device_vector<int>& counts) { thrust::device_vector<int> d_temp(d_in.begin(), d_in.end()); // copy of i...
21,071
// includes, system #include <stdio.h> #include <assert.h> // Here you can set the device ID that was assigned to you #define MYDEVICE 0 // Simple utility function to check for CUDA runtime errors void checkCUDAError(const char *msg); // Part 3 of 5: implement the kernel __global__ void myFirstKernel(int *d_a) { i...
21,072
/****************************************************************************** *cr *cr (C) Copyright 2010-2013 The Board of Trustees of the *cr University of Illinois *cr All Rights Reserved *cr ***************************************************************...
21,073
#include "includes.h" __global__ void MatrixMulDevice( float *A, float *B, float *C, int *matrixSize) { int chunk = (*matrixSize) / gridDim.x; int sum, i, k; for(i = blockIdx.x * chunk; i < blockIdx.x * chunk + chunk - 1; i++) { sum = 0; for(k = 0; k < *matrixSize; k++) { sum += A[i * *matrixSize + k] * B [k * *matri...
21,074
// 程序功能:查看当前服务器上具有的显卡数目,并且分别获取他们的详细属性。 // 必要的CUDA 包含文件 #include "cuda_runtime.h" #include "device_launch_parameters.h" // 传统 C++ 流输入输出支持 #include <iostream> using namespace std; // 主函数 int main() { // 设备属性的变量 cudaDeviceProp deviceProp; // 设备计数 int deviceCount; // 保存调用函数的输出结果 cudaError_t cudaError; // 获取当前的...
21,075
/* 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 v...
21,076
#include "includes.h" __global__ void kernel(int* D, int* Q, int bits){ // Find index int i = blockIdx.x * blockDim.x + threadIdx.x; // Initialize variables that will be shifted left and right int shifted_right = i; int shifted_left = shifted_right; // Perform bit reversal permutation for(int a = 1; a < bits; a++) {...
21,077
#include <stdlib.h> #include <stdio.h> #include <cuda.h> __global__ void vectorAddKernel(int N, int *c_a, int *c_b, int *c_c){ int threadIndex = threadIdx.x; int blockIndex = blockIdx.x; int threadCount = blockDim.x; int n = threadIndex + threadCount*blockIndex; // check if n is in [0,N) if(n<N) ...
21,078
#include <stdio.h> #include <stdlib.h> #include <math.h> #include "type.cuh" #define UP 0 #define LEFT 1 #define UL 2 #define MAX(I, J) ((I) > (J) ? (I) : (J)) typedef ChromType Pattern; void LcsString(int **b, ChromType *x, int i, int j, ChromType *l, int li); void MatPrint(int **cmat, int m, int n); i...
21,079
// incrementArray.cu #include <stdio.h> #include <assert.h> #include <cuda.h> #include <math.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(stderr,"GPUassert: %s ...
21,080
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <time.h> #define min(a, b) (((a) < (b)) ? (a) : (b)) #define max(a, b) (((a) > (b)) ? (a) : (b)) #define HANDLE_ERROR(err) (HandleError( err, __FILE__, __LINE__ )) #define THREADS_PER_BLOCK 256 static void HandleError(cudaError_t err, const char *fi...
21,081
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> #define THREADS_PER_BLOCK 16 // Threads per block #define SIZE 65 // Array size __global__ void vectorAdd(int *a, int *b, int *c, int n) { // blockIdx.x is block index // threadIdx.x is thread index // blockDi...
21,082
/* * MSU CUDA Course Examples and Exercises. * * Copyright (c) 2011 Dmitry Mikushin * * This software is provided 'as-is', without any express or implied warranty. * In no event will the authors be held liable for any damages arising * from the use of this software. * Permission is granted to anyone to use thi...
21,083
#include "includes.h" // filename: eeTanh.cu // a simple CUDA kernel to square the elements of a matrix extern "C" // ensure function name to be exactly "eeTanh" { } __global__ void swap_matrix_col(int N, int C, float *X, float *V) { int i = blockIdx.x * blockDim.x + threadIdx.x; int index = (...
21,084
/* This is an good trick to see what is going on for debugging purposes. It is terribly BAD to print from GPU kernels in anything you want to be performance oriented though. It is not a performance oriented feature! */ #include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <cuda_runtime.h> __global__ void...
21,085
#include "includes.h" __global__ void colorInvalids_kernel(uchar4 *out_image, const float *in_image, int width, int height) { const int x = __mul24(blockIdx.x, blockDim.x) + threadIdx.x; const int y = __mul24(blockIdx.y, blockDim.y) + threadIdx.y; if (x < width && y < height) { int ind = __mul24(y, width) + x; uchar4 ...
21,086
#include "includes.h" __global__ void matMult(int* a, int* b, int* res,unsigned int rows, unsigned int k, unsigned int cols){ unsigned int r = blockIdx.y * blockDim.y + threadIdx.y; unsigned int c = blockIdx.x * blockDim.x + threadIdx.x; unsigned int sum = 0; if(r< rows && c< cols){ for(int x=0; x<k; x++){ sum += a[...
21,087
#include <iostream> #include <fstream> #include <vector> #include <sstream> #include <cstdio> #include <ctime> #include <curand_mtgp32_kernel.h> #define CUDA_CHECK_RETURN(value) CheckCudaErrorAux(__FILE__,__LINE__, #value, value) #define TILE_WIDTH 32 #define w (TILE_WIDTH + 3 - 1) #define KERNEL_SIZE 3 __global__ v...
21,088
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <iostream> #include <time.h> #include <cstdlib> using namespace std; #define N 2048 #define Iteration 100 const int TILE = 32; const int SIDE = 8; __global__ void matrixTransposeUnrolled(const int *a, int *b) { __shared__ in...
21,089
#include<stdio.h> #include<stdlib.h> #include<cuda.h> #define N 5 __global__ void maximumElement(int *a,int *o) { int of; int id = threadIdx.x; for(of=N/2; of>0;of=of/2) { if(id<of) { if(a[id+of] > a[id]) { a[id] = a[id+of]; } } } if(a[0]<a[N-1]) { a[0]=a[N-1]; } o...
21,090
#include <iostream> #include <cstdlib> #include <iomanip> #include <cstring> #include <cuda_runtime.h> #include <cstdio> //C++ timers #include <chrono> #define BLOCK_SIZE 16 #define N_STREAMS 8 #define CUDA_WARN(XXX) \ do { if (XXX != cudaSuccess) std::cerr << "CUDA Error: " << \ cudaGetErrorString(XXX) ...
21,091
#include <stdio.h> #include <stdlib.h> #include <curand_kernel.h> // CURAND lib header file #define TRIALS_PER_THREAD 1000000 #define BLOCKS 16 #define THREADS 1024 #define PI 3.14159265358979 // known value of pi __global__ void setup_kernel(curandState *states) { int tid = threadIdx.x + blockIdx.x * blockDim.x;...
21,092
#include <iostream> #include <time.h> #include <cuda_runtime.h> /* * Lectura Archivo */ void Read(float** R, float** G, float** B, int *N, int *S, int **ordenamiento, int* P, const char *filename) { FILE *fp; fp = fopen(filename, "r"); fscanf(fp, "%d %d\n", N, S); int imsize = (*N) * (*N); ...
21,093
// // Created by root on 2020/11/12. // #include "cuda_runtime.h" #include "stdio.h" __device__ int *m = NULL, *n = NULL; __device__ volatile int *m_v = NULL, *n_v = NULL; __device__ int A, B, A_v, B_v; __device__ void write() { // m = 10; // n = 20; // // m_v = 10; // n_v = 20; (*m)++; (*n)++;...
21,094
#include <stdio.h> __global__ void kernel( void ){ } int main(void) { int count; cudaGetDeviceCount(&count); printf( "%d\n",count ); return 0; }
21,095
/* * Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. * * 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...
21,096
#include<stdlib.h> #include<iostream> #include<cmath> #include<fstream> #include<chrono> //shared host/device constants int gridWidth,gridHeight,gridDepth,blockWidth,blockHeight,blockDepth,gridWidthBlocks,gridHeightBlocks,gridDepthBlocks,gridArea; __constant__ int gridWidth_d,gridHeight_d,gridDepth_d,blockWidth_d,bl...
21,097
/* Block size X: 32 */ __global__ void fct_ale_c_vertical(const int maxLevels, const int * __restrict__ nLevels, double * __restrict__ del_ttf_advvert, const double * __restrict__ ttf, const double * __restrict__ hnode, const double * __restrict__ fct_LO, const double * __restrict__ hnode_new, const double * __restrict...
21,098
#include <chrono> #include <cstdint> #include <cstdlib> #include <cstring> #include <fstream> #include <iostream> const int BLOCK_SIZE = 32; const int THREADS_PER_BLOCK = 512; void BranchCPU(const ssize_t e, uint32_t* set, const int blockCount, const int k) { set[e * blockCount + k / BLOCK_SIZE] |= (((uint32_t)1)...
21,099
#include <stdio.h> #include <cuda.h> // Notice that this file needs to have a .cu extension for the NVCC compiler // to understand what it is supposed to do. NVCC can compile C and C++, by // emulating a C++ compiler. However, any code that contains GPU kernels // must reside in a CUDA unit with .cu extension. //--...
21,100
//Creating 4 streams, each assigns a local thread index to the array // #include <stdio.h> #include <stdlib.h> #define N 16 #define NCHUNK 2 //__device__ int *data; __global__ void thread_multi(int t1,int *data) { int i=blockDim.x * blockIdx.x + threadIdx.x; int j=threadIdx.x; printf(" %d %d\...