serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
22,701
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <iostream> #include <fstream> using namespace std; extern int size_space; extern float *Ex, *Hy; void file_init() { fstream outEx, outHy; outEx.open("Ex.txt", ios::out); outEx.close(); outHy.open("Hy.txt", ios::out); outHy.close(); } voi...
22,702
// Vector addition: C = 1/A + 1/B, for arbitrarily long vectors // compile with the following command: // // (for GTX970) // nvcc -arch=compute_52 -code=sm_52,sm_52 -O3 -m64 -o vecAdd vecAdd.cu // // (for GTX1060) // nvcc -arch=compute_61 -code=sm_61,sm_61 -O3 -m64 -o vecAdd vecAdd.cu // Includes #include <stdio.h> #...
22,703
#include "includes.h" __global__ void cubefilling_atomic(const float* image, float *dev_cube_wi, float *dev_cube_w, const dim3 image_size, int scale_xy, int scale_eps, dim3 dimensions_down) { const size_t i = blockIdx.x * blockDim.x + threadIdx.x; const size_t j = blockIdx.y * blockDim.y + threadIdx.y; if (i < image_si...
22,704
/************************************************************** * File: rgb2gray.cu * Description: CUDA implementation of application that transfers * color picture to grayscale. * * Author: jfhansen * Last Modification: 28/07/2020 *************************************************************/ #include <iostrea...
22,705
#include <math.h> #include <stdio.h> #include <stdlib.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 (i...
22,706
//////////////////////////////////////////////////////////////////////////////// // // FILE: max_parallel_reduct.cu // DESCRIPTION: uses parallel reduction to find max element in 1000 num array // AUTHOR: Dan Fabian // DATE: 2/23/2020 #include <iostream> #include <random> #include <chrono> using st...
22,707
#include "includes.h" __device__ __forceinline__ void copy_c(float const *in, float *out, int slicesizein, int slicesizeout, int C) { // *out = *in; for (size_t c(0); c < C; ++c) out[c * slicesizeout] = in[c * slicesizein]; } __device__ __forceinline__ void add_c(float const *in, float *out, int slicesizein, int slices...
22,708
/// /// vecAddKernel00.cu /// For CSU CS575 Spring 2011 /// Instructor: Wim Bohm /// Based on code from the CUDA Programming Guide /// By David Newman /// Created: 2011-02-16 /// Last Modified: 2011-02-16 DVN /// /// This Kernel adds two Vectors A and B in C on GPU /// with coalesced memory access. /// #include <stdio...
22,709
#include <cstdlib> #include <cstring> #include <cstdio> __global__ void vecadd(float *A, float *B, float *C, int N) { int i = blockDim.x * blockIdx.x + threadIdx.x; if (i < N) { //printf("%d %.2f %.2f\n", i, A[i], B[i]); C[i] = A[i] + B[i]; } //printf("blockDim %d %d %d i %d \n", blo...
22,710
#include "includes.h" __global__ void matByConst(unsigned char *img, unsigned char *result, int alpha, int cols, int rows) { int row = blockIdx.y * blockDim.y + threadIdx.y; int col = blockIdx.x * blockDim.x + threadIdx.x; if (row < rows && col < cols) { int idx = row * cols + col; result[idx] = img[idx] * alpha; } }
22,711
#include <stdio.h> __global__ void helloWorld(){ printf("Hello World from (block=%d,thread=%d)\n",blockIdx.x,threadIdx.x); } int main(){ helloWorld<<<3,2>>>(); cudaDeviceSynchronize(); return 0; }
22,712
#include<iostream> using namespace std; #include <time.h> __global__ void Array_Add(float* d_out, float* d_array, float Size) { int id = blockIdx.x * blockDim.x + threadIdx.x; int tid = threadIdx.x; int bid = blockIdx.x; extern __shared__ float sh_array[]; if(id < Size) sh_array[tid] ...
22,713
#include "includes.h" __global__ void OPT_4_SIZES(int *d_adjList, int *d_sizeAdj, int *d_LCMSize, int n_vertices) { int i = threadIdx.x + blockDim.x * blockIdx.x; if(i<n_vertices) { int indexUsed = 0; int iStart = 0, iEnd = 0; int k = 0; if(i > 0) { k = d_sizeAdj[i-1]; } iEnd = d_sizeAdj[i]; __syncthreads(); for(in...
22,714
#include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include <assert.h> #ifdef __NVCC__ #include <cublas_v2.h> #endif #ifndef THREADS_PER_BLOCK #define THREADS_PER_BLOCK 1024 #endif #define THREADS_PER_DIM 32 #define VERBOSE //#define PROF #define CUDA_ERROR_CHECK #define CudaSafeCall( err ) __cudaSafeCall( ...
22,715
#include "depthconv_cuda_kernel.h" #include <cstdio> #define CUDA_KERNEL_LOOP(i, n) \ for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < (n); \ i += blockDim.x * gridDim.x) const int CUDA_NUM_THREADS = 1024; inline int GET_BLOCKS(const in...
22,716
/** * @author NageshAC * @email nagesh.ac.aralaguppe@fau.de * @create date 2021-08-10 11:44:00 * @modify date 2021-08-10 11:44:00 * @desc Contains error diagnosis functions */ #pragma once #include<iostream> #include<cstdlib> #include<cuda_runtime.h> //***********************************************************...
22,717
#include <stdio.h> #include <stdlib.h> #include <curand_kernel.h> #include <math.h> #include <cuda.h> int main (int arg, char* argv[]) { int device; cudaGetDevice(&device); cudaDeviceProp prop; cudaGetDeviceProperties(&prop,device); printf("Multi Processor Count: %d", prop.multiProcessorCount); }
22,718
#include<cuda.h> #include<stdio.h> __global__ void VecAdd(float *A, float *B, float *C) { int i = threadIdx.x; for(int j = 0; j < 1000; j++) C[i] = A[i] + B[i]; } __global__ void VecMul(float *A, float *B, float *C) { int i = threadIdx.x; for(int j = 0; j < 1000; j++) C[i] = A[i] * B[i]; } int main() {...
22,719
#include "includes.h" __global__ void tissueGPU4Kernel(int *d_tisspoints, float *d_dtt000, float *d_qtp000, float *d_xt, float *d_rt, int nnt, int step, float diff) { int i = blockDim.x * blockIdx.x + threadIdx.x; int itp = i/step; int itp1 = i%step; int jtp,ixyz,ix,iy,iz,nnt2=2*nnt,istep; float r = 0.; if(itp < nnt){ ...
22,720
//============================================================== // Copyright � 2019 Intel Corporation // // SPDX-License-Identifier: MIT // ============================================================= #include <cuda.h> #include <stdio.h> #include <assert.h> #include <time.h> static long long timediff(struct timespe...
22,721
/* * Copyright 2016 Henry Lee * * 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...
22,722
#include <iostream> #include <vector> //#include <cuda.h> #include <stdio.h> using namespace std; /////////////////////////////////////////////////////////////////////////////// void print(std::vector<float> &vec) { for (size_t i = 0; i < vec.size(); ++i) { cerr << vec[i] << " "; } cerr << endl; } ////...
22,723
#include <stdio.h> #include <cuda_runtime.h> //will compute local histogram //assuming passed pointers are adjusted for the thread //bitpos is the lsb from which to consider numbits towards msb __device__ void computeLocalHisto(int *localHisto, int *arrElem, int n, int numBits, int bitpos) { int i; int nu...
22,724
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <float.h> #include <cuda.h> typedef struct { float posx; float posy; float range; float temp; } heatsrc_t; typedef struct { unsigned maxiter; // maximum number of iterations unsigned resolution; // spatial resolution ...
22,725
#include <cuda.h> //#include "cuda_runtime.h" #include <cuda_runtime_api.h> #include "device_launch_parameters.h" #include <stdio.h> #include <assert.h> #define N 16 __device__ int index(int col, int row, int ord){ return (row *ord)+col; } __global__ void Transpose(int *c, const int *a){ int col = (blockDim.x *...
22,726
#include <stdio.h> #include <cuda.h> __global__ void MyKernel() { printf("ThreadId(x,y,z)=(%u,%u,%u)blockId(x,y,z)=(%u,%u,%u)\n", threadIdx.x, threadIdx.y, threadIdx.z, blockIdx.x, blockIdx.y, blockIdx.z); return; } int main() { MyKernel<<<2,2>>>(); printf("\n\n****Kernel (2x2...
22,727
#include <stdio.h> #include <stdlib.h> #include <cuda.h> __global__ void hello_kernel (char *odata, int num) { char hello_str[12] = "Hello CUDA!"; int idx = blockIdx.x * blockDim.x + threadIdx.x; if (idx < num) odata[idx] = hello_str[idx]; } int main (void) { char *h_data, *d_data; const int strlen = 12;...
22,728
#include "includes.h" #define N 64 /* * This CPU function already works, and will run to create a solution matrix * against which to verify your work building out the matrixMulGPU kernel. */ __global__ void matrixMulGPU( int * a, int * b, int * c ) { /* * Build out this kernel. */ int val = 0; int row = threadIdx....
22,729
#include "includes.h" __global__ void matmul_partition(const float *a, const float *b, float *c, int n){ const int TILE_WIDTH = 8; __shared__ float na[TILE_WIDTH][TILE_WIDTH]; __shared__ float nb[TILE_WIDTH][TILE_WIDTH]; int bx = blockIdx.x, tx = threadIdx.x; int by = blockIdx.y, ty = threadIdx.y; int row = by * TILE...
22,730
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<time.h> #define DCTSIZE 8 #define CENTERJSAMPLE 128 #define PASS1_BITS 2 #define CONST_BITS 13 #define ONE ((INT32) 1) #define FIX_0_298631336 ((INT32) 2446) /* FIX(0.298631336) */ #define FIX_0_390180644 ((INT32) 3196) /* FIX(0.390180644) */ #defin...
22,731
//#include "cuda_runtime.h" //#include "device_launch_parameters.h" //#include "cuda_helper_funcs.h" //#include "RGB.h" // ///** //* Helper function to calculate the greyscale value based on R, G, and B //*/ //__device__ int greyscale(BYTE red, BYTE green, BYTE blue) //{ // int grey = 0.3 * red + 0.59 * green + 0 * 11 ...
22,732
#include <iostream> using namespace std; __global__ void kernel( int* b, int* t) { *b = gridDim.x; // Blocks in the grid *t = blockDim.x; // Treads per block } int main() { int b; int* d_b; int t; int* d_t; // store in d_b the address of a memory // location on the device cudaMalloc( (void**)&d_b,...
22,733
#include <iostream> #include "cuda.h" using Real = double; //Test wrapper to run a function multiple times template<typename PerfFunc> float kernel_timer_wrapper(const int n_burn, const int n_perf, PerfFunc perf_func){ //Initialize the timer and test cudaEvent_t start, stop; cudaEventCreate(&start); cudaEve...
22,734
//function kernel __device__ float length(float3 r) { return r.x*r.x + r.y*r.y + r.z*r.z; } __device__ float3 mul_float3(float3 r1, float3 r2) { return make_float3(r1.x * r2.x, r1.y * r2.y, r1.z * r2.z); } __device__ float3 add_float3(float3 r1, float3 r2) { return make_float3(r1.x + r2.x, r1.y + r2.y, ...
22,735
#include <cuda_runtime.h> #include <cuda_runtime.h> #include <stdio.h> #include <time.h> #include <stdlib.h> //srand() #include <iostream> //cout #include <string.h> //memset() extern "C" void gpuTestAll(float *MatA, float *MatB, float *MatC, int nx, int ny); // grid 1D block 1D // grid 2D block 2D // grid 2D block ...
22,736
#include <stdio.h> #define DIM 32 // 32 is maximum for now int *create_matrix(int row, int col){ return (int *) malloc(sizeof(int) * row * col); } void print_matrix(int *mat, int row, int col){ for(int i = 0; i < row; i++){ for(int j = 0; j < col; j++){ printf("%d ", mat[i*col + j]); } printf("\n"); } } ...
22,737
// doing 1024 * 1024 element's reducing // 1024 blocks with 1024 threads -> 1 block with 1024 threads -> result #include <iostream> /* * This kernel uses global memory, which can be optimized */ __global__ void global_reduce_kernel(int* g_in, int* g_out) { int global_t_idx = threadIdx.x + blockIdx.x * blockDi...
22,738
//http://stackoverflow.com/questions/36436432/cuda-thrust-zip-iterator-tuple-transform-reduce //STL #include <iostream> #include <stdlib.h> //Thrust #include <thrust/device_vector.h> #include <thrust/transform.h> #include <thrust/tuple.h> #include <thrust/transform_reduce.h> #include <thrust/iterator/zip_iterator.h> ...
22,739
#include <cstdio> #include <cstdlib> #include <vector> __global__ void bucketsort(int *a, int n, int range) { // init identifier int i = blockIdx.x * blockDim.x + threadIdx.x; if (i>=n) return; // init bucket extern __shared__ int bucket[]; __syncthreads(); if (threadIdx.x<range) bucket[threadIdx.x]...
22,740
#include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <iostream> using namespace std; __global__ void gpu_matrix_mult(float *d_a, float *d_b, float *d_c, int m, int n, int k) { int row = blockIdx.y * blockDim.y + threadIdx.y; int col = blockIdx.x * blockDim.x + threadIdx.x; if ((col < k) && (r...
22,741
/* * James Jun 2019/12/22 * Fast approximation of knn using binned minimum parallel search */ #include <cuda_runtime.h> #include <math.h> #define ABS(my_val) ((my_val) < 0) ? -(my_val) : (my_val) #define NC (45) //3pca x 16 channels max #define SINGLE_INF (3.402E+38) // equipvalent to NAN. consider -1 value #defin...
22,742
#include <cuda.h> #include <iostream> #include <sys/time.h> using namespace std; /* example for atomic function usage */ __global__ void atomic(int n, float *a) { //a[0] += 1.0f; // gives wrong result // instead use atomic function atomicAdd(&a[0], 1.0f); } int main() { int n = 1024; float *data = (floa...
22,743
#include <cuda.h> #include <stdio.h> int main(void) { int count; cudaDeviceProp prop; cudaGetDeviceCount(&count); for (int i=0; i < count; i++) { cudaGetDeviceProperties(&prop, i); printf ("Device Profile for Device %d\n\n", i); printf ("General Information - \n"); printf (" Name:\t\t\t %s\n",...
22,744
#include <stdio.h> #define BLOCK_SIZE 128 __global__ void calculateWork(int* work, const unsigned long long int leftMiddle, const unsigned long long int middle, const unsigned long long int n) { int i = blockIdx.x * BLOCK_SIZE + threadIdx.x; int temp = i % n; int force; if (temp < leftMiddle) { ...
22,745
#include "includes.h" __global__ void task1_NoCoalescing(unsigned const* a, unsigned const* b, unsigned* result, size_t size) { auto index = blockIdx.x * blockDim.x + threadIdx.x + 7; if (index > size + 6) { return; } if (index >= size) { index -= 7; } result[index] = a[index] * b[index]; }
22,746
#include "includes.h" __global__ void chol_kernel_cudaUFMG_elimination(float * U, int k) { //This call acts as a single K iteration //Each block does a single i iteration //Need to consider offset, int i = (k+1) + blockIdx.x; //Each thread does some part of j //Stide in units of 'stride' //Thread 0 does 0, 16, 32 //T...
22,747
/****************************************************************************** *cr *cr (C) Copyright 2010 The Board of Trustees of the *cr University of Illinois *cr All Rights Reserved *cr *****************************************************************...
22,748
#include <stdio.h> int main() { cudaDeviceProp props; cudaGetDeviceProperties(&props, 0); printf("%24s: %s\n", "Name", props.name); printf("%24s: %d\n", "Total global memory", props.totalGlobalMem); printf("%24s: %d\n", "Shared memory per block", props.sharedMemPerBlock); printf("%24s: %d\n", ...
22,749
#include<iostream> #include<vector> __global__ void averageCal(float *a, float *b, int n){ int index = blockIdx.x*blockDim.x + threadIdx.x; //for(int i = 0; i < n; i++){ //b[i] += a[i]; //} b[index] += a[index]; __syncthreads(); //for(int i = 0; i < n; i++){ //b[i] /= n; //} b[index] /= n; } int main(){ int N = 1...
22,750
// filename: gaxpy.cu // a simple CUDA kernel to add two vectors extern "C" // ensure function name to be exactly "gaxpy" { __global__ void gaxpy(const int lengthC, const double *a, const double *b, double *c) { int i = threadIdx.x + blockIdx.x * blockDim.x; if (i<lengthC) { c[i] = a[0]*b[i...
22,751
/* * CUDA kernel for geometric mean for calculating response of COSFIRE filter * Sofie Lovdal 18.6.2018 * The input is a flattened 3D array of all responses obtained from the COSFIRE * algorithm. The argument output is a buffer for the final response, input is a 1D * array of dimensions numResponses*rumRows*numCols. */...
22,752
#include "includes.h" __global__ void staticReverse(int *d, int n) { __shared__ int s[64]; int t = threadIdx.x; int tr = n - t - 1; s[t] = d[t]; __syncthreads(); d[t] = s[tr]; }
22,753
__global__ void cuda_op_function(const float *in, const int N, float* out){ for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < N; i += blockDim.x * gridDim.x) { out[i] = (float)(2*i) + 1.0f; if(in[i] == -1.0f){ out[i] = in[i]; } } } void cuda_op_launcher(const ...
22,754
#include <stdio.h> #include <assert.h> #include <cuda.h> int main(int argc, char* argv[]) { char* p = NULL; char* q = NULL; char* r = NULL; int i = 0; cudaError_t iRet; p = (char*) malloc(100); assert(p != NULL); q = (char*) malloc(20); assert(q != NULL); r = (char*) malloc(40)...
22,755
#include "includes.h" __global__ void multi(float *a, float *b, float *c, int width) { int col = threadIdx.x + blockIdx.x * blockDim.x; int row = threadIdx.y + blockIdx.y * blockDim.y; float result = 0; if (col < width && row < width) { for (int k = 0; k < width; k++) { result += a[row * width + k] * b[k * width + co...
22,756
#include "includes.h" __global__ void cunn_SoftMax_updateGradInput_kernel(float *gradInput, float *output, float *gradOutput, int nframe, int dim) { __shared__ float buffer[SOFTMAX_THREADS]; int k = blockIdx.x; float *gradInput_k = gradInput + k*dim; float *output_k = output + k*dim; float *gradOutput_k = gradOutput + ...
22,757
#include "includes.h" __global__ void ConditionCFLKernel1D (double *Rsup, double *Rinf, double *Rmed, int nrad, int nsec, double *Vtheta, double *Vmoy) { int i = threadIdx.x + blockDim.x*blockIdx.x; int j; if (i<nrad){ Vmoy[i] = 0.0; for (j = 0; j < nsec; j++) Vmoy[i] += Vtheta[i*nsec + j]; Vmoy[i] /= (double)nsec; ...
22,758
#include<stdio.h> #include<math.h> #include<stdlib.h> #include<sys/time.h> void usage(int exitStatus, char* programName); int sumArray(int* array, int arraySize); void getSeqPrimes(int* array, int arraySize); __host__ __device__ int isPrime(int value); __global__ void getPrimes(int* d_array, int N){ int threadI...
22,759
#include<iostream> #include<cuda_runtime.h> #include<cmath> using namespace std; /* suma elemenata po blokovima koristenjem aomic funkcije */ __global__ void funkc(int *M, int dim, unsigned int *fsum) { unsigned int rez; extern __shared__ int sum[]; sum[blockIdx.x*gridDim.x + blockIdx.y] = 0; __syncthreads...
22,760
#include <stdio.h> struct model { int states; int emissions; float* transition; float* emission; float* initial; }; #define trans(from,to) (transition[from*states+to]) #define emis(state,obs) (emission[state*states+obs]) #define init(state) (initial[state]) __device__ float par_sum(int state, float *shared, int...
22,761
#include <stdio.h> #include <cuda.h> #include <time.h> #define EXPO 7 __global__ void RecursiveDoublingKernel(int variableSize, int step,int blockRow, int blockColumn,float* deviceY,float* deviceM,int evenOrOddFlag) { //we weill do something like y(i+1)=my(i)+b int bx=blockIdx.x; int by=blockIdx.y; int tx=t...
22,762
/* ********************************************** * CS314 Principles of Programming Languages * * Spring 2020 * ********************************************** */ #include <stdio.h> #include <stdlib.h> __global__ void packGraph_gpu(int * newSrc, int * oldSrc, int * newDst, int * old...
22,763
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> #define CUDA_SAFE_CALL(func) { \ cudaError_t err = (func); \ if (err != cudaSuccess) { \ fprintf(stderr, "error [%d] : %s\n", err, cudaGetErrorString(err)); \ exit(err); \ } \ } // __glob...
22,764
#include <stdio.h> #include <stdlib.h> #define N 256 __global__ void bitreverse(unsigned int *data){ unsigned int *idata = data; unsigned int x = idata[threadIdx.x]; x = ((0xf0f0f0f0 & x) >> 4) | ((0x0f0f0f0f & x) << 4); x = ((0xcccccccc & x) >> 2) | ((0x33333333 & x) << 2); x = ((0xaaaaaaaa & x) >> 1) | ((0x5555...
22,765
/************************************************************************************\ * * * Copyright � 2014 Advanced Micro Devices, Inc. * * Copyright (c) 2015 Mark D. Hill and David A. Wood ...
22,766
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <inttypes.h> #include <math.h> #include <sys/time.h> #include <cuda_runtime.h> const int block_size = 1024; const int n = 4 * (1 << 20); void reduce_cpu(int *v, int n, int *sum) { /* int s = 0.0; for (int i = 0; i < n; i++) s += v...
22,767
#include "includes.h" __global__ void ladKernel(float *a, float *b, float *out, int size) { extern __shared__ float sdata[]; unsigned int tid = threadIdx.x; unsigned int i = blockIdx.x*(blockDim.x * 2) + threadIdx.x; int stride = blockDim.x * 2 * gridDim.x; sdata[tid] = 0; while (i < size) { sdata[tid] += abs(a[i] - b[...
22,768
#include <stdio.h> #include <stdlib.h> #define BLOCK_SIZE 32 #define N 321 __global__ void sumValues(int *arr, int *sum) { int index = BLOCK_SIZE * blockIdx.x + threadIdx.x; __shared__ float temp[BLOCK_SIZE]; if (index < N) { temp[threadIdx.x] = arr[index] * arr[index]; __syncthreads(); // The threa...
22,769
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <cstdlib> #include <float.h> __global__ void relu_kernel(float *output, float *input, int batch, int channel, int height, int width, int total_size) { int N = batch; int C = channel; int H = height; int W = width; int tid...
22,770
#include <cuda.h> #include <stdio.h> #include <stdint.h> // For comparisons //#include "seqScan.c" #define ELTS 64 #define BS 1024 #define N 16384*BS /* ------------------------------------------------------------------------ Unrolled in-place(shared memory) Scan without syncs (32 threads, 64 elts). Needs ...
22,771
#include "includes.h" __global__ void PD_ZC_GPU(float *d_input, float *d_output, int maxTaps, int nTimesamples, int nLoops) { int x_r, y_r, x_w, y_w; int Elements_per_block=PD_NTHREADS*PD_NWINDOWS; //read y_r=(blockIdx.y*blockDim.y + threadIdx.y)*nTimesamples; x_r=(blockIdx.x+1)*Elements_per_block + threadIdx.x; //wr...
22,772
#include <iostream> #include <math.h> // Kernel function to add the elements of two arrays __global__ void add(int n, float *x, float *y) { int index = threadIdx.x; int stride = blockDim.x; // how big is one thread for (int i = index; i < n; i += stride) y[i] = x[i] + y[i]; } int main(void) { int N = 1<...
22,773
#include <cuda_fp16.h> #define p_blockSize 256 extern "C" __global__ void packBuf_half( const int Nscatter, const int Nentries, const int * __restrict__ scatterStarts, const int * __restrict__ scatterIds, const float * __restrict__ q, half * __restrict__ scatterq ) { int tile = p_blockSize * blockIdx.x;...
22,774
#include <stdio.h> #include <iostream> #define N 64 #define M 32 #define BLOCK_DIM 32 __global__ void matrixMultiply(int *d_a, int *d_b, int *d_out, int nRows, int nCols){ // Mapping from 2D block grid to absolute 2D locations on C matrix int idx_x = blockDim.x * blockIdx.x + threadIdx.x; int idx_y = bl...
22,775
#include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <thrust/device_ptr.h> #include <thrust/copy.h> #include <thrust/sequence.h> #include <thrust/sort.h> #include <thrust/find.h> #include <cstdio> #include <iostream> #include <cstring> #include <vector> using namespace std; __global__ void fnSe...
22,776
#include "includes.h" __device__ unsigned int getGid3d3d(){ int blockId = blockIdx.x + blockIdx.y * gridDim.x + gridDim.x * gridDim.y * blockIdx.z; int threadId = blockId * (blockDim.x * blockDim.y * blockDim.z) + (threadIdx.y * blockDim.x) + (threadIdx.z * (blockDim.x * blockDim.y)) + threadIdx.x; return threadId; } _...
22,777
#include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <iostream> #include <algorithm> #define THREADS_PER_BLOCK 1024 #define THREADS_PER_SM 2048 #define BLOCKS_NUM 160 #define TOTAL_THREADS (THREADS_PER_BLOCK*BLOCKS_NUM) #define WARP_SIZE 32 #define REPEAT_TIMES 16 // GPU error check #define gpuErrchk...
22,778
#include "cuda.h" #include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> int main() { cudaDeviceProp Prop; cudaError_t e=cudaGetDeviceProperties (&Prop,0); }
22,779
#include "triangle.cuh" // custom rounding function to support needed pixel rounding Triangle::Triangle(Point *a, Point *b, Point *c) { vertices[0] = a; vertices[1] = b; vertices[2] = c; if(getSignedArea() < 0) { // reverse direction vertices[1] = c; vertices[2] = b; } } double Triangle::getSignedArea() { ...
22,780
#include <iostream> #include <fstream> #include <string> #include <cstdlib> #include <limits> #include <algorithm> using namespace std; const int BLOCK_SIZE = 512; #define idx(i,j,lda) ( (j) + ((i)*(lda)) ) class mySet { private: int size = 4000; bool N[4000]; int cnt = 4000; public: __device__ mySet(){} ...
22,781
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> #include <math.h> __global__ void square(int*a , int *t) { int n = threadIdx.x, m=blockIdx.x, size=blockDim.x, size1=gridDim.x; int i= m*size+n; t[i]=1; //int final=0; for(int j=0;j<(m+1);j++) t[i]*=a[i]; } i...
22,782
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> /* #include <sys/time.h> #include <sys/resource.h> double dwalltime(){ double sec; struct timeval tv; gettimeofday(&tv,NULL); sec = tv.tv_sec + t...
22,783
#include "includes.h" __global__ void EFD_2dBM( int width, int height, int pitch_n, int pitch_npo, float *d_val_n, float *d_val_npo, float alpha, float beta ){ int idx = blockIdx.x; //row int idy = threadIdx.x; //column if ((idx < height) && (idy <width)){ //d_val_npo[i] = Pu * d_val_n[i + 1] + Pm * d_val_n[i] + Pd * ...
22,784
#include <functional> #include "auxiliares.cu" using namespace std; // Punteros a memoria global double *g_datos; double *g_resp; double *g_verosimilitud; double *g_verosimilitudParcial; double *g_sumaProbabilidades; double *g_medias; double *g_pesos; double *g_covarianzas; double *g_L; double *g_logDets; __globa...
22,785
#include "includes.h" __global__ void forwardDifferenceAdjointKernel(const int len, const float* source, float* target) { for (int idx = blockIdx.x * blockDim.x + threadIdx.x + 1; idx < len - 1; idx += blockDim.x * gridDim.x) { target[idx] = -source[idx] + source[idx - 1]; } }
22,786
extern "C" __global__ void feilei(int n, float *hostInputA, float *hostInputB,float *result) { int i = threadIdx.y * blockDim.x + threadIdx.x; if (i<n) { for(int j = 0; j < n; j++){ if(hostInputA[j]==1.70141E38f){ //如果chang_tile[j/4]的值是无效值,则无用值赋为0 result[j] = hostInputA[j]; ...
22,787
#include<stdio.h> __global__ void hello(){ printf("*"); } int main() { cudaError_t error_code; hello<<<-1, 1>>>(); error_code = cudaGetLastError(); printf("%d\n", error_code); if(error_code!=cudaSuccess){ printf("\n"); printf("line:%d in %s\n", __LINE__, __FILE__); prin...
22,788
#include <time.h> #include <iostream> #include <stdio.h> #define RADIUS 3 #define NUM_ELEMENTS 1000 static void handleError(cudaError_t err, const char *file, int line ) { if (err != cudaSuccess) { printf("%s in %s at line %d\n", cudaGetErrorString(err), file, line); exit(EXIT_FAILURE); } } #define cud...
22,789
#include <cuda_runtime.h> #include <stdio.h> #include <unistd.h> #include <signal.h> #include "NeuralNet.cuh" sig_atomic_t volatile g_running = 1; void sig_handler(int signum) { if (signum == SIGINT) g_running = 0; } __global__ void add_input_spikes(NeuralNet *elem) { return; } __global__ void p...
22,790
#include <stdio.h> #include <iostream> #include <cuda.h> #include <cuda_runtime.h> #include <cuda_runtime_api.h> #define checkCudaErrors(val) check( (val), #val, __FILE__, __LINE__) template<typename T> void check(T err, const char* const func, const char* const file, const int line) { if (err != cudaSuccess) { ...
22,791
#include <stdio.h> #define NUMOFRASTERRECORDSPERCORE 3 // 160 // defined by num of raster records ~80k divided by num of GPU cores ~512 // rasters are stored in int(4Byte): rasterDd, int(4Byte): minLat, int(4Byte): minLon, int(4Byte): maxLat, int(4Byte): maxLon, int(4Byte): [empty] #define SIZEOFRASTERRECORD 5 // D...
22,792
#include "grid_cell_kernel.cuh" __device__ bool IsGridIdxValid(int idx, int maxGridNum) { return !(idx == GRID_UNDEF || idx < 0 || idx > maxGridNum - 1); } __device__ int GetGridCell( const float3 & gridVolMin, const int3 & gridRes, const float3 & pos, float cellSize, int3 & gridCell) { float gx = gridVolMin...
22,793
//pass //--gridDim=[4,1,1] --blockDim=[256,1,1] __global__ void sequence_gpu(int *d_ptr, int length) { int elemID = blockIdx.x * blockDim.x + threadIdx.x; if (elemID < length) { unsigned int laneid; //This command gets the lane ID within the current warp asm("mov.u32 %0, %%l...
22,794
#include <stdio.h> #include <stdlib.h> __global__ void gpu_conv1d(float *d_out, float *d_in, float *d_filter, int size_in, int size_filter){ int i = blockDim.x * blockIdx.x + threadIdx.x; float sum = 0.0; int offset = size_filter / 2; if (i < size_in){ for (int j=0; j < size_filter; j++){ if ((i-offset+j) >...
22,795
#include "includes.h" __global__ void __soft(float* y, const float* x, float T, int m) { unsigned int xIndex = blockDim.x * blockIdx.x + threadIdx.x; float x_e, y_e; if(xIndex < m) { x_e = x[xIndex]; y_e = fmaxf(fabsf(x_e) - T, 0.f); y[xIndex] = y_e / (y_e + T) * x_e; } }
22,796
#define COALESCED_NUM 16 #define blockDimX 16 #define blockDimY 1 #define gridDimX (gridDim.x) #define gridDimY (gridDim.y) #define idx (blockIdx.x*blockDimX+threadIdx.x) #define idy (blockIdx.y*blockDimY+threadIdx.y) #define bidy (blockIdx.y) #define bidx (blockIdx.x) #define tidx (threadIdx.x) #define tidy (threadIdx...
22,797
#ifndef _MATRIX_CU_ #define _MATRIX_CU_ #include <cuda_runtime.h> __global__ void cuMatMul(double* a, double* b, double* c, int* n) // __global__ void cuMatMul(double* a, double* bt, double* c, int* n) { int index = blockIdx.x * blockDim.x + threadIdx.x; c[index] = 0; for (int i = 0; i < *n; ++i) { ...
22,798
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <math.h> //Hillis Steele scan in one block; __global__ void prefixOnDevice(int *a, int *b, int n){ int id = threadIdx.x; int *s; for(int j=1; j<n; j<<=1){ if(id >=j) b[id] = a[id-j] + a[id]; else b[id] = a[id]; s = a; a = b; b = s; ...
22,799
#include "includes.h" __global__ void mmul(const float *A, const float *B, float *C, int ds) { // declare cache in shared memory __shared__ float As[block_size][block_size]; __shared__ float Bs[block_size][block_size]; int idx = threadIdx.x+blockDim.x*blockIdx.x; // create thread x index int idy = threadIdx.y+blockDi...
22,800
#include "includes.h" __device__ float maxMetricPoints(const float* g_uquery, const float* g_vpoint, int pointdim, int signallength){ float r_u1; float r_v1; float r_d1,r_dim=0; r_dim=0; for(int d=0; d<pointdim; d++){ r_u1 = *(g_uquery+d*signallength); r_v1 = *(g_vpoint+d*signallength); r_d1 = r_v1 - r_u1; r_d1 = r_d1...