serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
17,801
#include "includes.h" extern "C" extern "C" extern "C" extern "C" extern "C" extern "C" extern "C" extern "C" extern "C" extern "C" extern "C" extern "C" extern "C" extern "C" extern "C" extern "C" extern "C" extern "C" extern "C" extern "C" extern "C" extern "C" extern "C" extern "C" extern "C...
17,802
#include <cuda.h> #include <cuda_runtime.h> #include <math.h> __global__ void kmultiply(const float* a, float* b, int n) { int i = threadIdx.x + blockIdx.x*blockDim.x; if (i < n) b[i] *= a[i]; } extern "C" void launch_multiply(const float* a, float* b, int n) { float* dA; float* dB; int ce...
17,803
#include "includes.h" __global__ void SampleConcentrationDev(float* concentration, const uint2* cellStartEnd) { const uint cellid = gridDim.x*gridDim.y*threadIdx.x + blockIdx.y*gridDim.x + blockIdx.x; uint2 cellStEnd = cellStartEnd[cellid]; concentration[cellid] = cellStEnd.y - cellStEnd.x; }
17,804
#ifdef _WIN32 # define NOMINMAX #endif // includes, system #include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> // includes, project // includes, kernels //////////////////////////////////////////////////////////////////////////////// // declaration, forward double* read_array(const char* ...
17,805
#include <cstdlib> #include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <thrust/reduce.h> #include <thrust/tuple.h> #include <thrust/transform.h> #include <thrust/functional.h> #include <thrust/device_ptr.h> //Required constants. #define EPSILON 1E-4 #define MAXITER 7000 //Useful functions fo...
17,806
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <iostream> #include <stdio.h> #define BLOCK_SIZE 16 // submatrix size #define N 1024 // matrix size is N*N cudaError_t addWithCuda(int *c, const int *a, const int *b, unsigned int size); __global__ void addKernel(int...
17,807
// CUDA-C includes #include <cuda.h> #include <cuda_runtime.h> #include <stdio.h> __device__ int find_minLri(int *Lrpr, uint16_t m_u16TotalDisp) { int minLri = INT_MAX; for (int i=0; i<m_u16TotalDisp; i++) { if (minLri > Lrpr[i]) { minLri = Lrpr[i]; } } return minLri; } // e...
17,808
#include <iostream> #include <fstream> #include <sstream> #include <string> #include <vector> #include <map> #include <utility> #include <algorithm> #include <cstdlib> #include <cmath> #include <sys/time.h> #include <cuda.h> #include <cuda_runtime.h> using namespace std; bool verbose=false; int benchmark=1; #define L...
17,809
#include "includes.h" __global__ void gpu_array_scale_r4__(size_t tsize, float *arr, float val) /** arr(:)*=val **/ { size_t _ti = blockIdx.x*blockDim.x + threadIdx.x; size_t _gd = gridDim.x*blockDim.x; for(size_t l=_ti;l<tsize;l+=_gd){arr[l]*=val;} return; }
17,810
/* Matrix normalization. * Compile with "nvcc matrixNormCuda.c -lm" */ #include <stdio.h> #include <stdlib.h> #include <time.h> #include <sys/time.h> #include <math.h> /* Program Parameters */ #define N 8000 /* Matrix size */ int blocks_per_grid = 32; int threads_per_block = 256; /* Matrices */ float A[N*N], B[N*N...
17,811
#include "includes.h" __global__ void compute_sqrt(float * dist, int width, int pitch, int k){ unsigned int xIndex = blockIdx.x * blockDim.x + threadIdx.x; unsigned int yIndex = blockIdx.y * blockDim.y + threadIdx.y; if (xIndex<width && yIndex<k) dist[yIndex*pitch + xIndex] = sqrt(dist[yIndex*pitch + xIndex]); }
17,812
#include<iostream> #include<vector> #include<stdlib.h> #include<time.h> #include<math.h> #include<ctime> #include<algorithm> #include<utility> #include <curand.h> #include <curand_kernel.h> #include<random> #include <thrust/scan.h> #include <thrust/device_vector.h> #include <thrust/host_vector.h> using namespace std; ...
17,813
/* * Copyright 1993-2010 NVIDIA Corporation. All rights reserved. * * Please refer to the NVIDIA end user license agreement (EULA) associated * with this source code for terms and conditions that govern your use of * this software. Any use, reproduction, disclosure, or distribution of * this software and related...
17,814
/* * Last name: Gupta * First name: Vaibhav * Net ID: vvg239 * */ #include <stdlib.h> #include <stdio.h> #include <stdbool.h> #include <string.h> #include <time.h> void seq_gen_primes(int); __global__ void gen_primes(bool*, unsigned int, int); void gpu_gen_primes(unsigned int); int main(int a...
17,815
#include "includes.h" /** * Copyright 1993-2015 NVIDIA Corporation. All rights reserved. * * Please refer to the NVIDIA end user license agreement (EULA) associated * with this source code for terms and conditions that govern your use of * this software. Any use, reproduction, disclosure, or distribution of * this sof...
17,816
#include "includes.h" __global__ void matmul_v1(float* a,float* b,float* c, int n){ // C(nxn) = A(nxn) * B(nxn); __shared__ float A[TILE_SIZE][TILE_SIZE+1]; __shared__ float B[TILE_SIZE][TILE_SIZE+1]; int bx = blockIdx.x; int by = blockIdx.y; int tx = threadIdx.x; int ty = threadIdx.y; int i = bx*TILE_SIZE+tx; int j...
17,817
#include <stdio.h> #include <unistd.h> #include <sys/stat.h> #include <fcntl.h> #include <time.h> #include <sys/time.h> __global__ void hashKernel(char* input, int size, int* indices, int* hashOutput) { int index = blockIdx.x * blockDim.x + threadIdx.x; /* assuming 1D grid and block */ //Each thread hashes the dat...
17,818
/* 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 ...
17,819
/* Implement your CUDA kernel in this file */ /* * Solves the Panfilov model using an explicit numerical scheme. * Based on code orginally provided by Xing Cai, Simula Research Laboratory * and reimplementation by Scott B. Baden, UCSD * * Modified and restructured by Didem Unat, Koc University * * Refe...
17,820
#include "includes.h" __global__ void cudaUpdateMetrics_kernel(float * inputs, int * activity, long long unsigned int * firingRate, long long unsigned int * totalFiringRate, long long int * outputsActivity, long long int * totalOutputsActivity, unsigned int inputsDimX, unsigned int inputsDimY, unsigned int inputsDimZ) ...
17,821
#define N 16 #include<stdio.h> #include<stdlib.h> #include<iostream> using namespace std; __global__ void add(int *a, int *b, int *c){ c[blockIdx.x] = a[blockIdx.x] + b[blockIdx.x]; printf("%d blockIdx=%d\n", c[blockIdx.x], blockIdx.x); } __global__ void build_array(int **a, int **b, int **c){ int i = blockId...
17,822
//xfail:BOOGIE_ERROR //main.cu: error: possible read-write race //however, this didn't happen in the tests // In CUDA providing static and __attribute__((always_inline)) SHOUD NOT // keep a copy of inlined function around. //ps: the values from A[N-1-offset] to A[N-1] always will receive unpredictable values, //because...
17,823
#include <iostream> #include <string> #include <cstdlib> // 2 GB of data #define BYTES 2147483648 #define MAX_STRIDE 4194304 #define MAX_INDEX (BYTES/MAX_STRIDE) static void __global__ Set(const int Seed, const int Stride, char *data) { // Everyone set some data for(int i = threadIdx.x; i < BYTES ; i+= blockDim.x )...
17,824
#include "cuda.h" #include "StereoMatchKernels.cuh" // TODO Subpixel Genauigkeit __global__ void kernelStereoMatchL2R(unsigned char* dev_leftImg, unsigned char* dev_rightImg, float* dev_disparity, int width, int height, int kernelSize, int maxDisp, bool colorInput, bool subPixel) { int idx = threadIdx.x + bloc...
17,825
/****************************************************************** File : lcsBigBlockInitializationForPositions.cu Author : Mingcheng Chen Last Update : January 31st, 2013 *******************************************************************/ #include <stdio.h> #define BLOCK_SIZE 512 __global__ void BigBlockInitial...
17,826
#include "includes.h" __global__ void compute_B_for_depth(float* B, float* rho, float* Ns, int npix, int nchannels, int nimages) { int i = blockIdx.x*blockDim.x + threadIdx.x; int c = blockIdx.y*blockDim.y + threadIdx.y; if (i < npix*nimages) { B[c*npix*nimages + i] -= rho[c*npix + i%npix] * Ns[c*npix*nimages + i]; } }
17,827
#include "includes.h" __global__ void cunn_OneVsAllNLLCriterion_updateOutput_kernel(float *output, float *input, float *target, int nframe, int dim, int sizeaverage, float *positiveWeight) { __shared__ float buffer[NLL_THREADS]; int k = blockIdx.x; float *input_k = input + k*dim; float *output_k = output + k; int targe...
17,828
#include "includes.h" // CUDA kernel to add elements of two arrays __global__ __global__ void init(int n, float *x, float *y) { int index = threadIdx.x + blockIdx.x * blockDim.x; int stride = blockDim.x * gridDim.x; for (int i = index; i < n; i += stride) { x[i] = 1.0f; y[i] = 2.0f; } }
17,829
#include "includes.h" __global__ void UdpateEnergyTerm_movement( float* energy, int energy_dim, int nPatches, float * desc, int desc_dim, int id_desc_move) // whic hindex is the one with movement { int id = blockDim.x*blockIdx.y*gridDim.x + blockDim.x*blockIdx.x + threadIdx.x; int idDim = id % energy_dim; int idPatc...
17,830
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include<iostream> #include <stdio.h> using namespace std; struct d_Motif { int dis; int *loc; }; struct h_Motif { int dis; int loc[40]; }; __global__ void forKernel(int *a,int *b, d_Motif *c) { //printf("a: %d | b: %d \n", a[0], b[0]); //100000...
17,831
#include <stdio.h> #include <time.h> #include<math.h> void load_matrix_2D_from_file(FILE * file, int nb_rows,int nb_cols, double* matrix){ for(int i = 0; i < nb_rows; i++){ for(int j = 0; j < nb_cols; j++){ int index=i*nb_cols + j; if (!fscanf(file...
17,832
#include "includes.h" using namespace std; __global__ void kernel_SUM(unsigned char* voxelData,int pixelDepth) { }
17,833
#include "includes.h" __global__ void reduceSum(int *idata, int *odata, unsigned int ncols) { // Reduce rows to the first element in each row int i; int blockOffset; int rowStartPos; int colsPerThread; int *mypart; // Each block gets a row, each thread will reduce part of a row // Calculate the offset of the row bloc...
17,834
#include <cuda.h> #include <iostream> #include <sys/time.h> using namespace std; /* Simple Cuda program for arbitrary array size * - block, thread variables * - data transfer and kernel run times * - kernel execution parameters: effect on performance */ // (*) you should pass the length of array (n) to this fu...
17,835
#include "includes.h" __global__ void kTransposeBig(float *odata, float *idata, int height, int width) { const unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x; const unsigned int numThreads = blockDim.x * gridDim.x; int r, c; for (unsigned int i = idx; i < width * height; i += numThreads) { r = i % width; c = ...
17,836
 #include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> void helloCPU() { printf("Hello from the CPU.\n"); } __global__ void helloGPU() { printf("Hello from the GPU!\n"); } int main() { helloCPU(); helloGPU<<<1, 1>>>(); cudaDeviceSynchronize(); }
17,837
/* Collatz code for CS 4380 / CS 5351 Copyright (c) 2018, Texas State University. All rights reserved. Redistribution in source or binary form, with or without modification, is *not* permitted. Use in source and binary forms, with or without modification, is only permitted for academic use in CS 4380 or CS 5351 at Te...
17,838
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> __global__ void transpose(int *a, int *t){ int n = threadIdx.x, m = blockIdx.x, size = blockDim.x, size1 = gridDim.x; t[n*size1+m] = a[m*size+n]; } int main(){ int *a,*t,m,n,i,j,*da,*dt; printf("Enter m: "); sc...
17,839
#include "includes.h" using namespace std; #define TILE_WIDTH 2 // main fn __global__ void MatrixMult(int m, int n, int k, float *a, float *b, float *c) { int row = threadIdx.y + blockIdx.y*blockDim.y; int col = threadIdx.x + blockIdx.x*blockDim.x; if((row < m) && (col < k)) { float temp = 0.0; for (int i = 0; i...
17,840
#include "includes.h" __global__ void ApplyPool5(float* input, float* output){ int id = threadIdx.x + blockIdx.x * blockDim.x; for (int i = 0; i < 148; ++i){ //float total = input[i * 2 + id * 2 * 296] + // input[i * 2 + 1 + id * 2 * 296] + input[i * 2 + id * 2 * 296 + 296] + input[i * 2 + 1 + id * 2 * 296 + 296]; //t...
17,841
#include "includes.h" __global__ void ComputeInternalEnergy_kernel(float *Vx, float *Vy, float *Vz, float *Etot, float *Eneint, int size) { // get thread and block index const long tx = threadIdx.x; const long bx = blockIdx.x; const long by = blockIdx.y; int igrid; igrid = tx + bx*CUDA_BLOCK_SIZE + by*CUDA_BLOCK_SIZE*...
17,842
#include <cuda.h> extern "C" { __global__ void computeRHS(const double *f_local_d, double *rhs_d, double dx, int mx, int npx) { /* Computes the RHS for solving for the x-derivative of a function f. f_local is th...
17,843
/* We consider 1024 map, which are initially constructed with (at most)size = 4096 key, value pairs, for which keys are integers and values are float point numbers. Then each of them processes 262,144 operations, which only include 'g': search/getting values (If did not find, return -1.), 'e': check empty, 'z': check...
17,844
#include <stdio.h> #define BLOCK_SIZE 512 __global__ void scan(float *input, float *output, int len) { __shared__ float data[BLOCK_SIZE]; // DEBUG if (threadIdx.x == 0 && blockIdx.x == 0) { printf("Block Number: %d\n", blockIdx.x); for (int i = 0; i < BLOCK_SIZE; ++i) { ...
17,845
#include "includes.h" #define BLOCK_SIZE 1 //Global variable set up const int radius = 3; const int numSamples = 100; const double learningRate = 0.15; const int epochs = 1; const int numNeurons =20; //Set up neurons double inputLayer[2][numNeurons] = { 0 }; //takes input and weights double outputLayer[1][numNeurons] ...
17,846
// Basado en el codigo entregado durante clases practicas #include <iostream> #include <time.h> #include <cuda_runtime.h> /* * Lectura Archivo */ void Read(float** R, float** G, float** B, int *N, int *S, int** posicionesRompecabezas, const char *filename) { printf("Leemos el archivo %s!\n", filename); FI...
17,847
#include <stdio.h> #include <future> #include <thread> #include <chrono> #include <iostream> #define N 1000000 __constant__ int factor = 0; __global__ void vectorAdd(int *a, int *b, int *c) { int i = blockIdx.x*blockDim.x + threadIdx.x; c[i] = factor*(a[i] + b[i]); } __global__ void matrixAdd(int **a,int *...
17,848
#define SIZE 60000000 #define BLOCKDIM 1024 struct Test { Test(unsigned size) { data = new int[size]; this->size = size; } ~Test() { delete[] data; } int *data; unsigned size; }; struct Pool { Pool(unsigned size) { cudaMalloc(&d_test, sizeo...
17,849
/* Program : To find the histogram of N count words in a text file * Author : Anant Shah * Date : 17-9-2018 * Roll Number : EE16B105 **/ #include<stdio.h> #include<stdlib.h> #include<math.h> #include<time.h> #include<ctype.h> #define MAXWORDS 20000 #define MAX_WORD_LEN 20 #define ERROR_HANDLER(error_msg,line) err...
17,850
#include "includes.h" __global__ void addKernel(int *c, const int *a) { int i = threadIdx.x; extern __shared__ int smem[]; smem[i] = a[i]; __syncthreads(); if(i == 0) // 0号线程做平方和 { c[0] = 0; for(int d = 0; d < 5; d++) { c[0] += smem[d] * smem[d]; } } if(i == 1)//1号线程做累加 { c[1] = 0; for(int d = 0; d < 5; d++) { c[1]...
17,851
/* 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...
17,852
#include<cuda_runtime.h> #include<stdio.h> __global__ void something(int* a){ int id = blockDim.x*blockIdx.x + threadIdx.x; a[id] = 0; } int main(){ int * a; cudaStream_t stream; cudaStreamCreate(&stream); cudaMalloc((void**)&a, 2049*sizeof(int)); something<<<3,1024, 0, stream>>>(a); cudaFree(a); return 0; }
17,853
#include "pbkdf2.cuh" #include "hmac_sha512.cuh" __device__ void pbkdf2_sha512(const uint8_t password[], size_t password_len, const uint8_t salt[], uint8_t salt_len, int rounds, uint8_t *output, size_t output_len) { HmacSha512Context ctx{}; uint8_t U[64]; uint8_t T[64]; const au...
17,854
/* Implement your CUDA kernel in this file */
17,855
#include <stdio.h> #define STR_NUM 1024 #define RUN_COUNT 1 __global__ void func(char *buf) { int idx = gridDim.x*blockIdx.x; buf[idx ] = 'A'; buf[idx+1] = 'B'; buf[idx+2] = 'C'; buf[idx+3] = 'D'; buf[idx+4] = 'E'; buf[idx+5] = 'F'; buf[idx+6] = 'G'; buf[idx+7] = 'H'; buf[idx+8] = 'I'; buf[idx+9] = 'J';...
17,856
extern "C" __global__ void computeAVG(// Dots props float* pX, float* pY, float* pZ, //Tree specs // per Block int* dotIndexes, int* stBl0, int* nPtBl0, int* stBl1, int* nPtBl1, float*...
17,857
#include <stdio.h> #include <stdlib.h> #include <math.h> template <class T> class vector3d { public: T x, y, z; vector3d() { x = 0; y = 0; z = 0; } vector3d(T x_, T y_, T z_) { x = x_; y = y_; ...
17,858
#include <curand_kernel.h> #include <assert.h> #include <stdio.h> #include <stdlib.h> #include <iostream> #include <iomanip> #include <cassert> #include <unistd.h> #include <fcntl.h> #include <cstdio> #include <string> #include <fstream> #include <sys/types.h> #include <sys/stat.h> #include <cmath> #include <algorithm>...
17,859
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <iostream> #include <time.h> #include <random> using namespace std; // nvidia http://developer.download.nvidia.com/assets/cuda/files/reduction.pdf // , __global__ void piCalcKernel(int *d_odata, double* a, ...
17,860
#include <stdio.h> #include <cuda_runtime.h> // #include <helper_cuda.h> #define THREADS_PER_BLOCK 3 double f(double x){ return x*x; } __global__ void calculate(double *buffer, double start, double step, int N, double (*f) (double)){ int i = blockIdx.x * blockDim.x + threadIdx.x; if(i < N){ double x = start + i...
17,861
#include <stdio.h> #include <assert.h> #include <sys/time.h> /** * KERNEL cuAdd() - Takes 2 input arrays of same size N and adds them into C. * Locations are found by computing the global index of each thread. * @return */ __global__ void cuAdd(int *a,int *b,int *c, int N) { // 1D global index int offset = b...
17,862
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <cuda.h> #include <curand.h> #include <curand_kernel.h> #define THREADNUM 1024 #define BLOCKNUM 127 __device__ float G_rand(curandState *states, int ind){ curandState local_state = states[ind]; float rand_num = curand_uniform(&local_state); ...
17,863
#include "includes.h" __device__ int inner_product(int p, int q, int *a, int c_a, int *b, int r_b, int c_b){ int i = p; int j = q; int tmp_ra = i * c_a; int result = 0; for(int x = 0; x < r_b; x++){ result += a[tmp_ra] * b[j]; tmp_ra += 1; j += c_b; } return result; } __global__ void matmul(int *a, int c_a, int *b, i...
17,864
#include "includes.h" #define THREADS 256 #define BLOCKS 32 #define NUM THREADS*BLOCKS int seed_var =1239; __device__ void swap(int *xp, int *yp) { int temp = *xp; *xp = *yp; *yp = temp; } __global__ void bitonic_sort_step(int *d_pr, int *d_bt, int j, int k) { int i, ixj; /* Sorting partners: i and ixj */ i = thread...
17,865
#include <stdio.h> #include <cuda_runtime.h> int main(void) { int *dev_a; // Error code to check return values for CUDA calls cudaError_t err = cudaSuccess; err = cudaMalloc((void**)&dev_a, 10000000000000 * sizeof(int)); if (err != cudaSuccess) { fprintf(stderr, "Failed to allocate device vector, e...
17,866
//##########################################################// // Name: Kirtan Mali // // Roll no: 18AG10016 // // Question 4: DotProduct using Reduction Kernel // //##########################################################// #inc...
17,867
/* This file is part of the Marching Cubes GPU based algorithm based on * Paul Bourke's tabulation approach to marching cubes * http://paulbourke.net/geometry/polygonise/ * * * We model cubes with 8 vertices labelled as below * * * * 4--------(4)---------5 * /| /| * ...
17,868
#include <stdio.h> #include <cstdlib> #include <cufftXt.h> #include <cuda.h> #include <iostream> #define RANK 1 #define ERR_CHECK(err_val) { \ cudaError_t err = err_val; \ if (err != cudaSuccess) { \ ...
17,869
#include "includes.h" #define T_PER_BLOCK 16 #define MINF __int_as_float(0xff800000) __global__ void computeIntensityGradientMagnitude_Kernel(float* d_output, const float* d_input, unsigned int width, unsigned int height) { const unsigned int x = blockIdx.x*blockDim.x + threadIdx.x; const unsigned int y = blockI...
17,870
#include <iostream> #include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <thrust/copy.h> #include <thrust/scan.h> #include <thrust/execution_policy.h> #include <thrust/count.h> void computeSum( float* reference, float* idata, const unsigned int len) { reference[0] = 0; double total_sum = 0; ...
17,871
#define shaodi_pi 3.1415926 __host__ void ellipke(const double kf, double& K, double&E){ K = 0; E = 0; const double step = 0.00000025; for (double t = 0; t< 1; t+=step){ K += step / sqrt((1- t*t)*(1-kf*kf*t*t)); E += sqrt( (1-kf*kf*t*t)/(1-t*t) ) * step; } // std::cout<<K<<" "<<E...
17,872
#include <iomanip> #include <getopt.h> #include <stdio.h> #include <string.h> void testPooling( int tdims, int xDims[], int pdims, int poolDims[], int poolPad[], int poolStride[], int verbose, int compare ); void testXcorr( int tdims, int xDims[], int wDims[], int cdims, ...
17,873
#include <iostream> #include <cstdlib> #include <cstdio> using namespace std; __global__ void matrixColour (float *a, float *b, int n){ int j= blockDim.x * blockIdx.x + threadIdx.x; printf("Block = %d ; Thread = %d \n",blockIdx.x+1, threadIdx.x+1); // if(j<n){ // for (int i=0; i<n; i++){ //// printf("Block =...
17,874
/* Grupo: 8 Nome: Abner Eduardo Silveira Santos NUSP: 10692012 Nome: Gyovana Mayara Moriyama NUSP: 10734387 Nome: Henrique Matarazo Camillo NUSP: 10294943 Nome: Vitor Augusto de Oliveira NUSP: 9360815 */ /* Soma dois ...
17,875
// // Created by alan on 2/23/21. // #include "dp_clustering.cuh"
17,876
#include <algorithm> #include <iostream> #include <vector> #include <random> #include <limits> #include <cassert> #include <string> #include <sstream> #define CHECK(call) \ { \ const cudaError_t erro...
17,877
// // Created by Peter Rigole on 2019-05-03. // #ifndef AXONBITS_TESTINTPUTPROCESSOR_H #define AXONBITS_TESTINPUTPROCESSOR_H #include "../../InputProcessor.cuh" #include "../../NeuralNet.cuh" class TestInputProcessor : public InputProcessor { public: TestInputProcessor(NeuralNet* neuralNet_init) : InputProcess...
17,878
/****************************************************************************** * FILE: simple_cuda.cu * DESCRIPTION: * A simple cuda program working with arrays. * AUTHOR: David Nguyen * CONTACT: david@knytes.com * LAST REVISED: 25/03/2020 05:02:30 GMT-7 **************************************************************...
17,879
// test_function.cu #include <math.h> __device__ float mathop(float &x, float &y, float &z) { float res = sin(x) + cos(y) + sqrt(z); return res; }
17,880
#include "includes.h" __global__ void devInverseReindexInt(int N, int *destArray, int *srcArray, int *reindex, int realSize, int nDims) { for (unsigned int n = 0; n < nDims; n++) { int i = blockIdx.x*blockDim.x + threadIdx.x; while (i < N) { int tmp = srcArray[i + n*realSize]; destArray[i + n*realSize] = reindex[tmp];...
17,881
#include <math.h> #define DEG2RAD 0.0174532925 #define RAD2DEG 57.2957795 #define FT_PER_MIN_TO_M_PER_SEC 0.00508 // nvcc -Xcompiler -fPIC -shared propagator_cuda.cu -o propagator_cuda.so __device__ inline size_t idx(size_t i, size_t y, size_t vec_len=3){ /* The numpy vectors are flattened for some reason. Thi...
17,882
/* thrust::device_vector<char> gene_d(MAX_GENE_STR * num_targets); thrust::copy(gene_d.begin(), gene_d.end(), gene.begin()); thrust::device_vector<char> seq_d(MAX_SEQ_LEN * num_targets); thrust::copy(seq_d.begin(), seq_d.end(), seq.begin()); //int MAX_GENE_STR = 30; //thrust::host_vector<char> gene(MAX_GENE_S...
17,883
#include<stdio.h> #include<stdlib.h> #include<math.h> #include<cuda.h> #include<cuda_runtime.h> #define X 300 //X dimession of the data #define Y 2 //Y dimesnion of the data //TODO NEED TO KNOW THE DATA SIZE BEFORE IMPORTING #define K 3 //NUMBER OF CLUSTERS TO DIVIDE THE DATA INTO #define MAX_ITERS 1 //NUMBER OF I...
17,884
#include "includes.h" __global__ void ComputeDistanceKernel( int inputSize, float *distance, float *dimensionWeight, int maxCells, float *difference ) { int threadId = blockDim.x*blockIdx.y*gridDim.x //rows preceeding current row in grid + blockDim.x*blockIdx.x //blocks preceeding current block + threadIdx.x; if(...
17,885
#include "includes.h" __global__ void DivisePolarGridKernel (double *Qbase, double *DensInt, double *Work, int nrad, int nsec) { int i = threadIdx.x + blockDim.x*blockIdx.x; //512 int j = threadIdx.y + blockDim.y*blockIdx.y; //256 if (i<=nsec && j<nrad) Work[i*nrad + j] = Qbase[i*nrad + j]/(DensInt[i*nrad + j] + 1e-20...
17,886
#include <stdio.h> #include <stdlib.h> #include <cuda_runtime.h> #include <math.h> __global__ void cu_sobel(int *orig, int *cpu, int height,int width){ int x = threadIdx.x + blockIdx.x * blockDim.x; int y = threadIdx.y + blockIdx.y * blockDim.y; float dx, dy; if( x > 0 && y > 0 && x < width-1 && y < ...
17,887
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <unistd.h> #include <vector> #include <iostream> //#include <Windows.h> //#include <direct.h> using namespace std; #ifndef __CUDACC__ #define __CUDACC__ #endif __device__ int minIndex(double* data,double* centers,bool...
17,888
// // GADANN - GPU Accelerated Deep Artificial Neural Network // // Copyright (C) 2014 Daniel Pineo (daniel@pineo.net) // // 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 restricti...
17,889
static const __constant__ int DIM = 128; __global__ void Normalize128( float *data, int N ) { float tmp[DIM]; float norm1 = 0; float *start = data + threadIdx.x + blockIdx.x*blockDim.x; #pragma unroll for ( int i = 0; i < DIM; ++i ) { tmp[i] = *start; norm1 += abs(tmp[i]); start += N; } float n...
17,890
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <assert.h> #include <unistd.h> #include <sys/time.h> #include <cuda_runtime.h> /* Problem size. */ #ifndef M_PI #define M_PI 3.14159 #endif void init_array(double *x, double *A, int NX, int NY) { int i, j; for (i = 0; i < NX; i++) { for (j = 0; j...
17,891
/* 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,int 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 ...
17,892
#include <iostream> #include <iomanip> #include <stdio.h> #include <stdlib.h> void checkCudaError(const char* msg) { cudaError_t err = cudaGetLastError(); if (cudaSuccess != err) { fprintf(stderr, "ERROR: %s: %s.\n", msg, cudaGetErrorString(err)); exit(0); } } __global__ void Reverse...
17,893
#include <stdio.h> #include <cstdlib> #include <iostream> #include <cuda_runtime.h> #include <float.h> #include "cuda_2opt.cuh" #include "util.cuh" struct best_struct { float best; int i; int j; }; __global__ void two_opt_kernel(const float* x, const float* y, best_struct* return_best, int n, int* lock)...
17,894
#include "segment.cuh" // helper function for determining if t in [a, b] where order of a, b is unknown __device__ bool isBetween(const double &t, const double &a, const double &b) { return (a <= t && t <= b) || (b <= t && t <= a); } __device__ Segment::Segment() {} Segment::Segment(Point *a, Point *b) : endpoint1...
17,895
#include "includes.h" __global__ void cudaSSqrt_kernel(unsigned int size, float* data) { const unsigned int index = blockIdx.x * blockDim.x + threadIdx.x; const unsigned int stride = blockDim.x * gridDim.x; for (unsigned int i = index; i < size; i += stride) data[i] = sqrt(data[i]); }
17,896
#include <iostream> #include <cmath> using namespace std; __global__ void kernel(double *arr, int n) { int index, offset; index = blockDim.x * blockIdx.x + threadIdx.x; offset = blockDim.x * gridDim.x; for (int i = index; i < n; i += offset) arr[i] = abs(arr[i]); } int main(void) { int n; double *arr; ...
17,897
//============================================================================ // Name : LBM2.cpp // Author : Christos Tsotskas // Version : // Copyright : L-GPL // Description : CUDA Lattice Boltzmann in C++ // (code adapted from the original F90 version by Prof. L.Djenidi) // // Input(2 files): L...
17,898
#define NX 256 #include <stdio.h> #include <stdlib.h> #include <cufft.h> int main(){ /* Define FFT variables */ cufftComplex *in, *out; cufftHandle plan; /* Set the GPU device */ cudaSetDevice(0); /* Allocate memory on GPU for FFT data */ cudaMalloc((void**)&in, NX*sizeof(cufftComplex)); ...
17,899
#include <iostream> #include <stdio.h> #include <cuda.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) { std::cerr << "CUDA error at: " << file << ":" << line <...
17,900
#include <iostream> #include "cuda.h" using namespace std; #define N 64 #define ThreadPerBlock 32 __global__ void squareKernel(int* ptr) { const int i = blockIdx.x * blockDim.x + threadIdx.x; ptr[i] = ptr[i] * ptr[i]; } int main(void) { int *array; cudaMallocManaged(&array, N*sizeof(int)); cout << "[Before...