serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
20,601
#include "includes.h" __global__ void squareFunc(unsigned int *d_in, unsigned int *d_out) { int idx = threadIdx.x; unsigned int val = d_in[idx]; d_out[idx] = val * val; //printf("%d square value %d \n ", idx, d_out[idx]); }
20,602
#include <stdio.h> #include <cuda.h> #define THREADSPERBLOCK 1024 __global__ void primeiroLaco(long int* d_num, long int* d_den, long int start, long int end, int size) { int num_aux, den_aux, aux, resto; long int factor, ii, sum, done, n; int i = blockIdx.x * blockDim.x + threadIdx.x; if (i < size) { ...
20,603
#include <stdio.h> #include <stdlib.h> #define PI 3.14159265 #define PADDING_SIZE 1 #define FILTER_SIZE 3 #define X 8 #define Y 16 // declaring constant memory for kernel __device__ __constant__ float d_filterKernel[FILTER_SIZE] = { -1, 0, 1}; __global__ void convolutionGlobal( float *image, int height, int width, ...
20,604
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <cstdio> #include <math.h> __global__ void sumSingleBlockSharedMem(int* d) { // declare that we're going to use shared memory in this kernel extern __shared__ int dcopy[]; int tid = threadIdx.x; // copy the memory over from global...
20,605
#include "includes.h" __global__ void ApplySubKeplerianBoundaryKernel(double *VthetaInt, double *Rmed, double OmegaFrame, int nsec, int nrad, double VKepIn, double VKepOut) { int j = threadIdx.x + blockDim.x*blockIdx.x; int i = 0; if (j<nsec) VthetaInt[i*nsec + j] = VKepIn - Rmed[i]*OmegaFrame; i = nrad - 1; if (j<n...
20,606
__global__ void ComputeLamda( float* g_VecV, float* g_VecW, float * g_Lamda,int N) { // shared memory size declared at kernel launch extern __shared__ float sdataVW[]; unsigned int tid = threadIdx.x; unsigned int globalid = blockIdx.x*blockDim.x + threadIdx.x; // For thread ids greater than data space if (...
20,607
#include "matrix.cuh" #define ROW_INDEX 0 #define COL_INDEX 1 #define NUM_INDEXES 2 matrix_t* roll_matrix_list(matrix_list_t* list) { unsigned int i; assert(list != NULL); for(i=0; i<list->num; i++) { assert(list->matrix_list[i] != NULL); } unsigned int vector_size=0; for(i=0; i<list->num; i++) { vector_...
20,608
//hello.cu #include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> int main(void) { printf("Hello CUDA \n"); return 0; }
20,609
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include "math.h" #include <stdio.h> extern "C" __global__ void distGrid(float *in1, float *in2, float *out, int columns1, int columns2 ) { int idx = threadIdx.x + blockIdx.x*blockDim.x; if (idx < columns1) { for (int i = 0; i < columns2; i++) ...
20,610
/** Modifed version of knn-CUDA from https://github.com/vincentfpgarcia/kNN-CUDA * The modifications are * removed texture memory usage * removed split query KNN computation * modified global distance computation * * Last modified by Lin Dong <ldong1@andrew.cmu.edu> 05/12/2019 */ #include <cstdio...
20,611
#include <thrust/reduce.h> #include <thrust/functional.h> #include <thrust/device_ptr.h> float sum_thrust(float* in, unsigned int n) { thrust::plus<float> binary_op; // compute sum on the device thrust::device_ptr<float> begin = thrust::device_pointer_cast(in); return thrust::reduce(begin, begin + n, 0...
20,612
#include "includes.h" __global__ void yMaxDeltaIntegralKernel( const float *intData, const int intDataStrideChannel, float *tmpArray, const int batchSize, const int nInputPlane, const int nWindows, const int h, const int w, const float *xMin, const float *xMax, const float *yMax) { int id = NUM_THREADS * blockIdx.x + ...
20,613
#include <stdio.h> #include <stdlib.h> __global__ void VecAdd(float *A, float *B, float *C) { int i = threadIdx.x; C[i] = A[i] + B[i]; } void printVec(int N, float *vec) { for (int i = 0; i < N; i++) { printf("%.2f ", vec[i]); } printf("\n"); } int main(int argc, char const *argv[]) { int deviceCount, devi...
20,614
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <cuda.h> unsigned int getmaxcu(unsigned int *, unsigned int); int main(int argc, char *argv[]) { unsigned int size = 0; // The size of the array unsigned int i; // loop index unsigned int * numbers; //pointer to the array if(argc !=2...
20,615
#include <iostream> #include <cassert> #include<algorithm> using namespace std; int main() { u_char root[10] = {1,2,5,6,7,10,8,4,3,9}; u_char *a = root; if (*a < *(a+5)) { cout << (int)*a << endl; cout << (int)(*(a+5)) << endl; } // sort(*a, *(a+10)); // cout << root << endl; ...
20,616
#include <iostream> #include <fstream> #include <string> #include <unordered_map> #include <unordered_set> #include <stdlib.h> #include <vector> #include <random> using namespace std; void printNeighbours(unordered_map<long, unordered_set<long>> neighbours) { for (auto& n : neighbours) { cout << n.first <...
20,617
#include <stdio.h> #include <cuda.h> #define MAX_TILE_SIZE 32 #define MAX_MASK_WIDTH 11 /*Declare the constant memory*/ __constant__ float M[MAX_MASK_WIDTH]; /***********************/ /** TODO, write KERNEL */ /***********************/ __global__ void Conv1D(float* N, float* P, int Mask_Width, int Width) { int i =...
20,618
///////////////////////// #include <stdio.h> /* Enables printing output to console */ #define N 64 /* Speficy array length value */ #define TPB 32 /* Threads per block used in kernel */ __device__ float scale(int i, int n){ return ((float)i)/(n-1); } __device__ float distance(float x1, float x2){ return sqrt((x2-...
20,619
#include<cuda_runtime.h> #include<stdio.h> #include<stdlib.h> __global__ void add(int* a,int* b,int* c,int* n) { int id=blockIdx.x*blockDim.x+threadIdx.x; if(id<*n) c[id]=a[id]+b[id]; } int main() { int a[100],b[100],c[100],n,*da,*db,*dc; int *dn; printf("Enter size: "); scanf("%d",&n); printf("Enter eleme...
20,620
/* 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* ...
20,621
#include <stdio.h> #include <stdlib.h> #include <float.h> #include <limits.h> #pragma once #define BLOCK_SIZE 32 #define BLOCK_SIZE_DIM1 1024 // Matrices are stored in row-major order: // M(row, col) = *(M.elements + row * M.width + col) typedef struct { int width; int height; double* elements; } Matrix; //func...
20,622
#include<stdio.h> #define ARRAY_SIZE 128*128 #define NUM_THREADS 128 #define BLOCK_SIZE 128 __global__ void reduce(float* d_out, float* d_in){ int global_id = blockDim.x*blockIdx.x + threadIdx.x; int local_id = threadIdx.x; //extern __shared__ float s_in[]; for(unsigned int s = blockDim.x/2; s ...
20,623
#include<stdio.h> #include<stdlib.h> __global__ void matadd(int *d_a,int *d_b,int *d_c, int n){ int idx=threadIdx.x; if(idx<n) d_c[idx]=d_a[idx]+d_b[idx]; } int main(){ int n; scanf("%d",&n); cudaEvent_t start,stop; float escap_time; cudaEventCreate(&start); cudaEventCreate(&stop); cudaEventRecord(start,0); cu...
20,624
/* Host-side code to perform counting sort * * Author: Naga Kandasamy * Date modified: March 2, 2021 * * Student name(s): Abishek S Kumar * Date modified: 03/08/2021 * * Compile as follows: make clean && make */ #include <stdlib.h> #include <stdio.h> #include <time.h> #include <sys/time.h> #include <strin...
20,625
#include "includes.h" __global__ void testKernel(float *g_idata, float *g_odata) { // shared memory // the size is determined by the host application extern __shared__ float sdata[]; // access thread id const unsigned int tid = threadIdx.x; // access number of threads in this block const unsigned int num_threads = b...
20,626
/******************************************************************************** * TEX Object API * * TODO: * Test the behavior of memory cache of cuArray and 2D pitched memory tex. * Test the behavior of float * I suspect some other unit can be used in analysis. ***********************************************...
20,627
#include<stdio.h> #include<time.h> __global__ void threennKernel(int b, int n, int m, int t, const float * __restrict__ xyz1, const float * __restrict__ xyz2, float * __restrict__ dist, int * __restrict__ idx) { for(int i=blockIdx.x;i<b;i+=gridDim.x){ for(int j=threadIdx.x;j<n;j+=blockDim.x){ f...
20,628
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args #pragma once #include <cuda_runtime.h> /** * Allocate GPU memory for `count` elements of type `T`. */ template<typename T> static T* gpuMalloc(size_t count) { T* ret = nullptr; // CHECK: hipMalloc(&ret, count * sizeof(T)); cudaMalloc(&ret, co...
20,629
#include <stdio.h> #define N (2048) #define THREADS_PER_BLOCK 512 void random_ints(int* a, int num) { int i; for(i = 0; i < num; ++i) { a[i] = rand(); // a[i] = 1; } } __global__ void add(int *a, int *b, int *c) { int index = threadIdx.x + blockIdx.x ...
20,630
#include "includes.h" __global__ void TgvComputeOpticalFlowVectorKernel(const float *u, const float2 *tv2, int width, int height, int stride, float2 *warpUV) { const int ix = threadIdx.x + blockIdx.x * blockDim.x; const int iy = threadIdx.y + blockIdx.y * blockDim.y; const int pos = ix + iy * stride; if (ix >= width ...
20,631
#include "includes.h" __global__ void deInterleave_kernel2(float *d_X_out, float *d_Y_out, char *d_XY_in, int pitch_out, int pitch_in, int width, int height) { unsigned int x = blockIdx.x * blockDim.x + threadIdx.x; unsigned int y = blockIdx.y * blockDim.y + threadIdx.y; if ((x < width) & (y < height)) { // are we in ...
20,632
// Mike Hagenow // ME759 - Final Project // Loads a collision map from a CSV and calls the CUDA kernel // to calculate the Laplacian // Compile: nvcc harmonic_main.cu harmonickernel.cu -Xcompiler -O3 -Xcompiler -Wall -Xptxas -O3 -std c++14 -o harmonicmain // Debug: nvcc -g -G harmonic_main.cu harmonickernel.cu -Xcomp...
20,633
// // 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...
20,634
/****************************** * Tisma Miroslav 2006/0395 * Multiprocesorski sistemi * domaci zadatak 6 - 2. zadatak *******************************/ /** * 2. Sastaviti program koji pronalazi najmanji i najveci element dvodimenzionalne matrice. */ #include "cuda_runtime.h" #include "device_launch_parameters.h"...
20,635
#include "Pixel.cuh" //////////////////////////////////////////////////////// //////////////////////////////////////////////////////// /* Pixel CLASS CASE */ //////////////////////////////////////////////////////// //////////////////////////////////////////////////////// __device__ Pixel::Pixel() : R(NULL), G(NUL...
20,636
#define SOURCE_INDEX(m,g,i,j,k,cmom,ng,nx,ny) ((m)+((cmom)*(g))+((cmom)*(ng)*(i))+((cmom)*(ng)*(nx)*(j))+((cmom)*(ng)*(nx)*(ny)*(k))) #define SCATTERING_MATRIX_INDEX(m,g1,g2,nmom,ng) ((m)+((nmom)*(g1))+((nmom)*(ng)*(g2))) #define SCALAR_FLUX_INDEX(g,i,j,k,ng,nx,ny) ((g)+((ng)*(i))+((ng)*(nx)*(j))+((ng)*(nx)*(ny)*(k)))...
20,637
#include "includes.h" extern "C" { } __global__ void elSq(int N, int M, float *Mat) { int i = blockIdx.x * blockDim.x + threadIdx.x; int j = blockIdx.y * blockDim.y + threadIdx.y; int index = j*N + i; if (i < N && j < M) { Mat[index] = __fmul_rn(Mat[index], Mat[index]); } }
20,638
#include <stdio.h> #include <iostream> #include <cuda.h> #include <cuda_runtime.h> #include <cmath> #define N 1024 #define threads_per_block 512 template<typename T> __global__ void blockwise_dot(T *d_a, T *d_b, T *block_sum) { __shared__ T partial_sum [threads_per_block]; int tid = blockDim.x * blockIdx.x + thread...
20,639
/*#include <stdio.h> #include <math.h> #include <time.h> #include <iostream> #include <fstream> #include <stdlib.h> #include "cuda_runtime.h" #include "device_launch_parameters.h" #include "device_functions.h" #include "book.h" #include "cusparse.h" */ #define BlockDim 1024 template <typename T> __global__ void spmv...
20,640
#include "includes.h" // ERROR CHECKING MACROS ////////////////////////////////////////////////////// __global__ void pathAdjacencyKernel(int noTransitions, int noSegments, float* XY1, float* XY2, float* X4_X3, float* Y4_Y3, float* X2_X1, float* Y2_Y1, int* adjacency) { int blockId = blockIdx.y * gridDim.x + blockId...
20,641
#include "includes.h" // ERROR CHECKING MACROS ////////////////////////////////////////////////////// __global__ void expPVPath(const int noPaths, const float gr, const int nYears, const float meanP, const float timeStep, const float rrr, float current, float reversion, float jumpProb, const float* brownian, const fl...
20,642
#include "cuda_runtime.h" #include <chrono> #include <iostream> #include <sstream> #define arraySize 31 // 35 max #define def_div 10 // 5<=X<=15 //#define W 100 //#define threads_per_block 32 //#define max_blocks 32 using namespace std; __constant__ float coefs[arraySize * 2 + 1]; __global__ void hybrid(float *sh...
20,643
#include <stdio.h> #include <cuda.h> #include <time.h> #include <stdlib.h> #include <math.h> #include <string.h> typedef struct { unsigned char red, green, blue; } PPMPixel; typedef struct { unsigned char gray; } PGMPixel; typedef struct { int x, y; PPMPixel *data; } PPMImage; typedef struct { i...
20,644
#include <stdio.h> #define SIZE 1024 // Функция сложения двух векторов __global__ void addVector(float* left, float* right, float* result) { //Получаем id текущей нити. int idx = threadIdx.x; //Расчитываем результат. for (int i = 0; i < SIZE; i++) { for (int k = 0; k < SIZE; k++) { resul...
20,645
#include <stdio.h> #include <stdint.h> #include <arpa/inet.h> #define BUFFER_LEN 64 #define BUFFER_SIZE_OFFSET 56 //#define THREADS 4096 #define THREADS 64 #define LEFTROTATE(x, c) (((x) << (c)) | ((x) >> (32 - (c)))) size_t pad(const char * message, uint32_t buffer[]) { size_t b...
20,646
#include "includes.h" __device__ float logarithmic_mapping(float k, float q, float val_pixel, float maxLum) { return (log10f(1.0 + q * val_pixel))/(log10f(1.0 + k * maxLum)); } __device__ float rgb2Lum(float B, float G, float R) { return B * 0.0722 + G * 0.7152 + R * 0.2126; } __global__ void log_tonemap_kernel(float* ...
20,647
#include "includes.h" /* #define N 512 #define N 2048 #define THREADS_PER_BLOCK 512 */ const int THREADS_PER_BLOCK = 32; const int N = 2048; __global__ void shared_mult(int *a, int *b, int *c) { __shared__ int mem[THREADS_PER_BLOCK]; int pos = threadIdx.x + blockIdx.x * blockDim.x; mem[threadIdx.x] = a[pos] * b[p...
20,648
// calculate neural weights in real time. // serial in 50 mins, pytorch 5 mins // parallel target, solve in less than 10 ms - real time // compile with // nvcc -arch=sm_60 -o mapping neural.cu -rdc=true -lcudadevrt #include <iostream> #include <stdlib.h> #include <cmath> #include <ctime> #include <cuda.h> #includ...
20,649
#include<stdio.h> #include<cuda_runtime.h> #include<device_launch_parameters.h> __global__ void add(int *a, int *b, int m){ int id=blockIdx.x*blockDim.x+threadIdx.x; // c[id]=a[id]+b[id]; // printf("id: %d m: %d ", id, m); for (int i = 0; i < m; ++i){ b[id*m + i] = powf(a[id*m + i], id+1); // printf("i...
20,650
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <cuda_runtime.h> // Host input vectors. float *uva_a; float *uva_b; // Host output vector. float *uva_c; // Size of arrays. int n = 0; /* CUDA kernel. Each thread takes care of one element of c. */ __global__ void vecAdd(float *a, float *b, float *c, ...
20,651
/** * Instituto de Ciencias Matematicas e de Computacao - USP Sao Carlos * * Programacao Concorrente 2013 * Grupo 05 Turma A * * Andre Luiz Catini Paro, 7152740 * Daniel Hideki Yoshimi, 7239173 * Rodrigo Toledo Amancio Silva, 7152308 * * Projeto Final - Metodo Jacobi-Richardson em CUDA * * Este pr...
20,652
#include "includes.h" __global__ void find_maximum_kernel(float *array, int *mutex, unsigned int n, int blockSize){ unsigned int index = threadIdx.x + blockIdx.x*blockDim.x; unsigned int stride = gridDim.x*blockDim.x; unsigned int offset = 0; extern __shared__ float cache[]; float temp = -1.0; while(index + offset < ...
20,653
__device__ unsigned int countDigits(unsigned int number); __device__ bool isNumberDisarium(unsigned int number); __device__ unsigned int pow(unsigned int x, unsigned int n); __global__ void generateDisariumNumbers(unsigned int *generatedNumbers, bool *result, const unsigned int NUMBERS_COUNT) { unsigned int inde...
20,654
/* The solution. */ #include <sys/time.h> #include <ctype.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> // Number of times to run the test (for better timings accuracy): #define NTESTS 100 // Number of threads in one block (possible range is ...
20,655
#include <iostream> #include <malloc.h> using namespace std; __global__ void add(int* d_a, int* d_b, int* d_c, int* d_limit){ int tid = threadIdx.x + blockIdx.x*blockDim.x; if(tid < 1000){ d_c[tid] = d_a[tid] + d_b[tid]; } } int main(){ int size = 2000; // size of an array int ngpus = 2; /* Device memory poin...
20,656
#include <iostream> #include <math.h> #include <float.h> __global__ void sdt_compute(unsigned char *img, int *sz, float *sdt, int sz_edge, int width, float *d_min, int start, int val) { int tx = threadIdx.x + blockDim.x*blockIdx.x; extern __shared__ int ep[]; for(int i=start, j=0;i< val; i++){ ep[j++] = sz[i...
20,657
#include "includes.h" __global__ void meshgrid_create(float* xx, float* yy, int w, int h, float K02, float K12) { int i = blockIdx.x*blockDim.x + threadIdx.x; int j = blockIdx.y*blockDim.y + threadIdx.y; if (i < h && j < w) { xx[j*h + i] = j - K02; yy[j*h + i] = i - K12; } }
20,658
#include <stdio.h> #include <iostream> #include <cstdlib> #include <ctime> #include <climits> #include <cuda_runtime.h> __device__ void vectorAdd1(int* d_A, int* d_B, int* d_C, int size, int* mapBlk, int blockDim){ int vId = threadIdx.x + mapBlk[blockIdx.x]*blockDim; if(vId < size){ d_C[vId] = d_A[vId] + d_B[vId]...
20,659
#include <ctime> #include <cstdlib> #include <iostream> #include <string> #include <cmath> #include <vector> class Pt { public: float x = 0; float y = 0; int group = 1; }; __global__ void setFalse(bool*& Changed, int dsize); __device__ float dist(const Pt& p1, const Pt& p2); __global__ void Group_find(Pt*& data, ...
20,660
#include <vector> #include <iostream> #include <chrono> using std::cout; using std::chrono::high_resolution_clock; using std::chrono::microseconds; using std::chrono::nanoseconds; using clock64_t = long long int; const size_t maxWait = 10000; const size_t nIter = 10000; __device__ clock_t diff; __global__ void Slee...
20,661
#include "includes.h" __device__ float computeDeterminant (float e00, float e01, float e02, float e10, float e11, float e12, float e20, float e21, float e22) { return e00*e11*e22-e00*e12*e21+e10*e21*e02-e10*e01*e22+e20*e01*e12-e20*e11*e02; } __global__ void hessianKernelO ( float *d_output, float *d_output_theta, float...
20,662
#include <stdio.h> #include <stdlib.h> #include <time.h> #define NUM_STREAM 100 #define NUM_BLOCK 1 #define NUM_THREAD 512 #define NUM_DATA 2000000 #define TYPE_DATA double #define CHECK 0 void stopwatch(int); void pp(int); //a 에서 b 로 l 만큼 __global__ void data_trans(TYPE_DATA* a,TYPE_DATA* b,int l); int main() ...
20,663
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> #include <time.h> //M and N number of threads (grid and block) #define M 1 #define N 1 __global__ void multiply( const char string[] , const char substring[], const int dim_str,const int dim_substr, in...
20,664
#include "includes.h" //Udacity HW 4 //Radix Sorting __global__ void addPrevSum(unsigned int* blkSumsScan, unsigned int* blkScans, unsigned int n) { int i = blockIdx.x * blockDim.x + threadIdx.x + blockDim.x; if (i < n) { blkScans[i] += blkSumsScan[blockIdx.x]; } }
20,665
#include "includes.h" __global__ void debugMark() { //This is only for putting marks into the profile. }
20,666
/*--------------------------------------------------------------------------*\ Copyright (c) 2008-2009, Danny Ruijters. All rights reserved. http://www.dannyruijters.nl/cubicinterpolation/ This file is part of CUDA Cubic B-Spline Interpolation (CI). Redistribution and use in source and binary forms, with or without mo...
20,667
__device__ int createArgbColor(int iter, int maxIter) { int color = (255.0*iter)/maxIter; return(255<<24) | (color<<16) | (color<<8) | color; }
20,668
// cudaTrivial.cu #include <cuda.h> #include <iostream> __global__ void cudaKernel(int* data) { //get thread id int i = blockIdx.x * blockDim.x + threadIdx.x; //assign to data data[i] = i; } int main(int argc, char *argv[]){ //set thread count based on args of blocks and threads //ideally wou...
20,669
#include "includes.h" #define VERTICES 600 __constant__ float2 d_vertices[VERTICES]; __constant__ float d_slopes[VERTICES]; /* * This file contains the implementation of a CUDA Kernel for the * point-in-polygon problem using the crossing number algorithm * * The kernel cn_pnpoly is can be tuned using the following p...
20,670
/* 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 ...
20,671
/******************************************************************************* * PROGRAM: canny_edge_detector * FILE: ui.cu / a small user interface, use WIN32 graphic lib * PURPOSE: This program is a case study on porting algorithm implemented in C to CUDA * The original C code is referenced from canny_edge program ...
20,672
// // global.cu // Kernel of verifing ciphertext and constant-time copy. // // Copyright (c) 2021 Tatsuki Ono // // This software is released under the MIT License. // https://opensource.org/licenses/mit-license.php // #include "device.cuh" #include "global.cuh" namespace atpqc_cuda::verify_cmov_ws::global { __globa...
20,673
/* * Parakeet * * (c) 2009-2011 Eric Hielscher, Alex Rubinsteyn * * */ #include <cuda_runtime_api.h> #include <stdio.h> #include <stdlib.h> #include <string.h> void chkError(cudaError_t rslt, char *msg) { if (rslt) { printf("Error: %s\n", msg); exit(1); } } int main(int argc, char **argv) { cuda...
20,674
#include "includes.h" __device__ int is_source_gpu(int i, int j, int radius, int source_active, int src_x, int src_y) { if (!source_active) return 0; if (sqrt(pow((float)(src_x - i), 2) + pow((float)(src_y - j), 2)) <= radius) return 1; return 0; } __global__ void wireless_src_pulse_kernel(int step, double amp, double ...
20,675
#include "includes.h" __global__ void setToOnes(float *data, int size) { int index = threadIdx.x + blockIdx.x * blockDim.x; // 1D grid of 1D blocks if (index < size) data[index] = 1; }
20,676
//VecAdd.cu // author: Pan Yang // date : 2015-7-2 #include <stdio.h> #include <stdlib.h> #include <time.h> #define SIZE 1024 // Kernel definition __global__ void VecAdd_T(int *a, int *b, int *c, int n) { int i = threadIdx.x; if (i < n) c[i] = a[i] + b[i]; } // Kernel definitio...
20,677
#include "VectorOps.cuh" void __device__ vvaddDev(int i2d, real alpha, real* x, real* y, int totpoints) { if(i2d>=totpoints) return; y[i2d] += alpha * x[i2d]; //if (i2d == printv) printf("vm: %.31f\n~~~~~~~~~~~~~~~~\n", g_dev.vm[i2d]); }
20,678
#include <stdio.h> #include <stdlib.h> // __global__ keyword specifies a device kernel function __global__ void cuda_hello() { printf("Hello World from GPU!\n"); printf("hello form GPU B.x=%d, Thread.x=%d\n", blockIdx.x, threadIdx.x); } int main() { printf("Hello World from CPU!\n"); // Call a device ...
20,679
#include <iostream> #include <thrust/sort.h> #include <set> using namespace std; int main(int argc, char const *argv[]) { /* code */ string a, b; int n, m; cin>>n>>m; // cin>>n>>m; int *array = new int [2*m]; int *array2 = new int [2*m]; cout<<n<<"\t"<<m<<endl; for (int i = 0; i < m; ++i) { /* code ...
20,680
#include "includes.h" // https://gist.github.com/wh5a/4641641 // https://www.evl.uic.edu/sjames/cs525/final.html __global__ void CodeParallele(double td, double h, float matDest) { }
20,681
/* @author Jack Clark Simple program to simulate 2D advection using the finite volume approach, with naive averaging at cell boundaries. Compile with nvcc -O3 advection.cu -o gpu_advection */ #include <fstream> #include <sstream> #include <math.h> #include <assert.h> #include <cuda.h> #define NUM_CELLS_X 40...
20,682
#include "includes.h" __global__ void matmul_traditional(const float *a, const float *b, float *c, int n, int m){ int i = blockDim.x * blockIdx.x + threadIdx.x; int j = blockDim.y * blockIdx.y + threadIdx.y; //printf("%d %d %d %d %d %d\n",blockDim.x,blockDim.y,blockIdx.x,blockIdx.y,threadIdx.x,threadIdx.y); int idx = i...
20,683
#include "includes.h" #define NOMINMAX const unsigned int BLOCK_SIZE = 512; __global__ void addKernelV2(float *c, const float *a, const float *b) { int i = threadIdx.x + blockIdx.x * blockDim.x; c[i] = a[i] + b[i]; }
20,684
extern "C" __global__ void add32(float* A, float *B, int size) { int block = blockIdx.x + blockIdx.y * gridDim.x + gridDim.x * gridDim.y * blockIdx.z; int index = block * (blockDim.x * blockDim.y * blockDim.z) + (threadIdx.z * (blockDim.x * blockDim.y)) + (threadIdx.y * blockDim.x) + threadIdx.x; if(index ...
20,685
#include "includes.h" #define tileSize 32 //function for data initialization void initialization( double *M, double *N, int arow, int acol, int brow, int bcol); //(for Debugging) prints out the input data void printInput( double *M, double *N, int arow, int acol, int brow, int bcol); //(for Debugging) prints out t...
20,686
#include <stdio.h> #define ARRAY_LEN 4096 #define RUN_COUNT 1000 int max_print=20; unsigned long long fnd_count=0; void checker(int round, char* buf) { int i; for(i=0; i<ARRAY_LEN; i++) { switch(buf[i]) { case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H...
20,687
// nvcc fft_cuda_2d.cu -lcublas -lcufft -arch=compute_52 -o fft_cuda_2d //https://www.researchgate.net/figure/Computing-2D-FFT-of-size-NX-NY-using-CUDAs-cuFFT-library-49-FFT-fast-Fourier_fig3_324060154 #include "cuda_runtime.h" #include "device_launch_parameters.h" #include "cuda.h" #include <cufft.h> #include "stdio...
20,688
#include <cuda.h> #include <stdio.h> #include <stdlib.h> #define N 10 void add( int *a, int *b, int *c ) { int tid = 0; // this is CPU zero, so we start at zero while (tid < N) { c[tid] = a[tid] + b[tid]; tid += 1; // we have one CPU, so we increment by one } } __global__ void add_gpu( i...
20,689
#include <stdio.h> __global__ void my_gpu_func(int* buf, int w, int h) { int x = blockIdx.x * blockDim.x + threadIdx.x; int y = blockIdx.y * blockDim.y + threadIdx.y; if (x < w && y < h) { buf[y * w + x] += 1; } } extern "C"{ void my_c_func(int *buf, int *wptr, int *hptr) { int h = *hptr; int w = *wpt...
20,690
__global__ void process_kernel1(const float *input1,const float *input2, float *output, int datasize){ int blockNum = blockIdx.z*(gridDim.x*gridDim.y)+blockIdx.y*(gridDim.x)+blockIdx.x; int threadNum = threadIdx.z*(blockDim.x*blockDim.y)+threadIdx.y*(blockDim.x)+threadIdx.x; int i = blockNum*(blockDim.x* blockDim.y ...
20,691
#include <iostream> #include <fstream> #include <stdio.h> #include <stdlib.h> #include <string> #include <sys/time.h> using namespace std; #include "bfs_kernel.cu" /* * gpu_bfs.cu * * Usage: ./executable <graph_file> <output file> * * Input: Name of the file containing the graph. Expected format * is binary ...
20,692
#include "heatmap_update.cuh" #include "cuda_runtime.h" #include "device_launch_parameters.h" #include <cuda.h> #include <cuda_runtime_api.h> #include <cstdlib> #include <iostream> #include <cmath> #include <omp.h> __global__ void fadeHeat(int *d_heatmap, int size) { int index = blockIdx.x * blockDim.x + thread...
20,693
/****************************************************************************** This function converts HSV values to RGB values, scaled from 0 to maxBrightness The ranges for the input variables are: hue: 0-360 sat: 0-255 lig: 0-255 The ranges for the output variables are: r: 0-maxBrightness g: 0-maxBrightnes...
20,694
#include "includes.h" __global__ void bitonic_sort_step(int *dev_values, int j, int k) { unsigned int i, ixj; /* Sorting partners: i and ixj */ i = threadIdx.x + blockDim.x * blockIdx.x; ixj = i^j; /* The threads with the lowest ids sort the array. */ if ((ixj)>i) { if ((i&k)==0) { /* Sort ascending */ if (dev_values[...
20,695
#include<iostream> #include <cuda.h> __global__ void reduce_kernel(const int* g_idata, int* g_odata, unsigned int n) { extern __shared__ int sdata[]; unsigned int i = blockIdx.x*blockDim.x + threadIdx.x; if(i<n) { sdata[threadIdx.x] = g_idata[i]; } __syncthreads(); for (unsigne...
20,696
__device__ float Pq2Luma(float N) { float pq_m1 = 0.1593017578125; // ( 2610.0 / 4096.0 ) / 4.0; float pq_m2 = 78.84375; // ( 2523.0 / 4096.0 ) * 128.0; float pq_c1 = 0.8359375; // 3424.0 / 4096.0 or pq_c3 - pq_c2 + 1.0; float pq_c2 = 18.8515625; // ( 2413.0 / 4096.0 ) * 32.0; float pq_c3 = 18.6875; // ( 2392...
20,697
extern "C" __global__ void sumReduction(double *v, double *v_r) { extern __shared__ double partial_sum[]; int tid = blockIdx.x * blockDim.x + threadIdx.x; partial_sum[threadIdx.x] = v[tid]; __syncthreads(); for (int s = 1; s < blockDim.x; s *= 2) { int index = 2 * s * threadIdx.x; ...
20,698
#include <cuda_runtime.h> #include <device_launch_parameters.h> #include <stdio.h> #define arraySize 6 #define threadPerBlock 6 /**枚举排序或者秩排序算法 * 对于数组中的每一个元素,通过统计小于其值的数组中其他元素的数量, * 该统计数量就是该元素在最终结果数组中的位置索引。 */ // Define kernel function to sort array with rank. __global__ void rank_sort_kernel(int *device_a, int *dev...
20,699
#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(i...
20,700
#include <stdio.h> #include <stdint.h> #define CHECK(call) \ { \ const cudaError_t error = call; \ if (error != cudaSuccess) ...