serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
2,601
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> #include <cuda_runtime.h> #include <sys/time.h> double cpuSecond(){ struct timeval tp; gettimeofday(&tp,NULL); return ( (double)tp.tv_sec + (double)tp.tv_usec * 1e-6 ); } #define CHECK(call){ \ const cudaError_t error = call; \ if( erro...
2,602
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> int main() { // Fetch device properties and display them to the screen. int nDevices; // All CUDA API calls have a return value that indicate // whether or not an error occurred during the execution // of the function. cudaErro...
2,603
#include <stdio.h> #include <time.h> #define virtualCores 1000 #define intervals 1000000000 #define intervalsPerCore ((intervals)/(virtualCores)) #define intervalBase ((1.0)/(intervals)) __global__ void calculatePi(float* acums) { int coreNum = threadIdx.x; int currentInterval = coreNum * intervalsPerCore; ...
2,604
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> #include <assert.h> //#include "benchmark.h" //Macros #define min(a, b) ( (a)<(b)? (a): (b) ) #define max(a, b) ( (a)>(b)? (a): (b) ) //Constants #define MAX_VECTOR_COUNT 5 //Vector structure typedef struct { float e[3]; }Vec3f; //Global ...
2,605
#include <cuda.h> #include <stdio.h> #include <stdlib.h> typedef struct node { int data; struct node *parent; struct node *left; struct node *right; int sema; } node; __device__ int lock(node* n) { return !atomicExch(&n->sema, 1); } __device__ void unlock(node* n) { atomicExch(&n->sema, 0); } __device...
2,606
#include <thrust/sequence.h> #include <thrust/device_vector.h> #include <thrust/host_vector.h> #include <sys/time.h> #define pi_f 3.14159265358979f // Greek pi in single precision struct sin_functor { __host__ __device__ float operator()(float x) const { return x*sin(x); } }...
2,607
/* cuda implementation of RecPF algorithm based on matlab function version [U,Out] = RecPF(m,n,aTV,aL1,picks,B,TVtype,opts,PsiT,Psi,URange,uOrg) - deklaracja funkcji w Matlabie poniej przykadowe wywoanie funkcji RecPF w matlabie ze skryptu sart_tv [UU,Out_RecPF] = RecPF(nn,nn,aTV,aL1,picks,B,2,opts,PsiT,Psi,range...
2,608
#include <stdio.h> #define DIM 1000 struct cppComplex { float r; float i; cppComplex( float a, float b ) : r(a), i(b) {} float magnitude2( void ) { return r * r + i * i; } cppComplex operator*(const cppComplex& a) { return cppComplex(r*a.r - i*a.i, i*a.r + r*a.i); } cppComplex operator+(const cppComplex...
2,609
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdlib.h> #include <math.h> #define ENOUGH_SMALL 0.00001f __host__ __device__ static float func(int d, float *k, float x) { int i; float ans = 0; for (i = 0; i <= d; i++) ans += k[i] * pow(x, i); return ans; } __host__ __device__ stati...
2,610
// Compile: nvcc -arch=sm_61 -std=c++11 assignment5-p4.cu -o assignment5-p4 #include <cmath> #include <cuda.h> #include <iostream> #include <sys/time.h> const uint64_t N = (1 << 12); const uint64_t BLOCK_SIZE = (1 << 4); const uint64_t TILE_SIZE = (1 << 5); using namespace std; #define gpuErrchk(ans) { gpuAssert((a...
2,611
#include "includes.h" __global__ void gpu_stencil37_hack2_cp_rows(double * dst, double * shared_rows, double *shared_cols,double *shared_slices,int d_xpitch,int d_ypitch,int d_zpitch,int s_xpitch,int s_ypitch, int s_zpitch, int n_rows, int n_cols,int n_slices,int tile_x,int tile_y, int tile_z){ #ifdef CUDA_DARTS_DEBUG...
2,612
#include "includes.h" /*****************************************************************************/ // nvcc -O1 -o bpsw bpsw.cu -lrt -lm // Assertion to check for errors __global__ void kernel_jacobi(long* nArray, long* dArray, long len) { int bx = blockIdx.x; // ID thread int tx = threadIdx.x; int result, t; ...
2,613
// small program to print some Gpu properties // compile with nvcc GetGpuProps.cu -o build/GetGpuProps #include <cstdio> int main() { int count = 0; if (cudaSuccess != cudaGetDeviceCount(&count)) return -1; if (count == 0) return -1; std::printf("\nNumber of Cuda Gpu devices: %d\n\n",count-1); cudaDevicePro...
2,614
#include <stdio.h> #include <time.h> __global__ void gpu_loop() { printf("GPU::This is iteration number %d\n", threadIdx.x); } __host__ void cpu_loop(int n) { for(int i = 0; i < n; i++) printf("CPU::This is iteration number %d\n", i); } int main() { int n, b; cudaEvent_t start, stop; cudaEventCreate(&start...
2,615
#include "includes.h" __global__ void writeSeedList( const int idxLimit, const int* gatewayIndexArray, const int* indexArray, const int* seedWriteIndexArray, const int* cellSizeArray, const int* tIDArray, const int* tIndexArray, const int* qIDArray, const int* qIndexArray, int* target_IDArray, int* target_indexArray, i...
2,616
#include <stdio.h> #include <stdint.h> const int MILLION = 1000000; //define the constant million const int thread_per_block = 1000; #define time_record_begin(start){ \ cudaEventCreate(&start); \ cudaEventRecord(start, 0); \ } #define time_record_end(start, stop, time){ \ cudaEventCreate(&stop); \ cudaEventR...
2,617
#include<stdio.h> #define ARRAY_SIZE 16 __global__ void print_index_and_data(int * data) { int tid = threadIdx.y * blockDim.x + threadIdx.x; int number_of_threads_in_block = blockDim.x * blockDim.y; int block_offeset = blockIdx.x * number_of_threads_in_block; int number_of_threads_in_row = number_o...
2,618
#include<iostream> #include <cuda.h> #include <math.h> #include<stdio.h> #include<stdlib.h> #include <sys/types.h> #include <time.h> using namespace std; __device__ int mymin(int a, int b) { int m = a; if(m > b) m=b; return m; } __device__ int min1(int a,int b,int c) { int m=a; if(m>b) m=b; if(m>c) ...
2,619
/* Project: ECE 408 Final Project * File Name: cuda_test.cu * Calls: None * Called by: None * Associated Header: None * Date created: Sat Nov 7 2015 * Engineers: Conor Gardner * Compiler: nvcc * Target O...
2,620
/** * * This is a cuda version of the array addition program as created from the * tutorial from here: * * https://devblogs.nvidia.com/even-easier-introduction-cuda/ * * Any adjustments made are made from suggestions from Programming Massively * Parallel Processors, 3rd Edition: * * https://www.amazon....
2,621
#include <time.h> #include <cuda.h> #include <stdio.h> #define STOP 0 #define START 1 #define BLOCKSIZE 256 extern "C" void chrono (int kind, float *time); __global__ void kconvol (float *gpu_a, float *gpu_b, int n) { int i, j, l; // TO DO : evaluate the global 1D index l of the current thread, // using block...
2,622
#include <string.h> #include <math.h> #ifndef RESTRICT #define restrict __restrict__ #endif /* RESTRICT */ //ldoc on /** * ## Implementation * * The actually work of computing the fluxes and speeds is done * by local (`static`) helper functions that take as arguments * pointers to all the individual fields. This...
2,623
extern "C" __global__ void saxpy(float* S, float A, float* X, float* Y) { int i = blockIdx.x * blockDim.x + threadIdx.x; S[i] = A * X[i] + Y[i]; }
2,624
#include <cuda.h> #include <stdio.h> #define mega 1048576 __global__ void fdcalc(int n) { long n1 = 0; for (int j=0; j < 100000; j++) { for(int i=2; i < n; ++i) { n1=pow(n1,i); //n1=n1*i; (GF 730) } } } // função principal executada iniciada em CPU int main(int argc, char ...
2,625
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <math.h> #define THREADS_PER_BLOCK 1024 void matrixMultiplyCPU(float *a, float *b, float *c, int width) { float result; for (int row = 0; row < width; row++) { for (int col = 0; col < width; col++) { result = 0; ...
2,626
#include <stdio.h> #include <stdlib.h> #include <cuda.h> /* Time */ #include <sys/time.h> #include <sys/resource.h> static struct timeval tv0; double getMicroSeconds() { double t; gettimeofday(&tv0, (struct timezone*)0); t = ((tv0.tv_usec) + (tv0.tv_sec)*1000000); return (t); } void init_seed() { int seedi=1;...
2,627
#include<stdio.h> #include<stdlib.h> #include<cuda.h> #include<cuda_runtime.h> #define N 10000000 __global__ void vector_add(float *out, float *a, float *b, int n){ for(int i=0;i<n;i++){ out[i]=a[i]+b[i]; } } int main(){ float *a, *b, *out; float *d_a, *d_b, *d_out; a=(float*)malloc(sizeof(float)*N); ...
2,628
#include <stdio.h> // A macro for checking the error codes of cuda runtime calls #define CUDA_ERROR_CHECK(expr) \ { \ cudaError_t err = expr; \ if (err != cudaSuccess) \ { \ printf("CUDA call failed!\n%s\n", cudaGetErrorString(err)); \ ...
2,629
/* * Rayhana ZIARA * produit matrice vecteur */ #include <stdlib.h> #include <stdio.h> /* * DESCRIPTION : kernel concernant le produit matrice vecteur * PARAMETRES : matrice A, vecteur v, vecteur r et taille des vecteurs * RETOUR : / */ __global__ void matVect(float *A, float *v, float *r, int size) { float result...
2,630
/* * 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...
2,631
#include <stdio.h> #include <stdlib.h> #define NUMBER_OF_THREADS 100 #define NUMBER_OF_QUERY_IPS 100 #define NUMBER_OF_DATABASE_IPS 1000000 /** * This macro checks return value of the CUDA runtime call and exits * the application if the call failed. */ #define CUDA_CHECK_RETURN(value) { \ cudaError_t _m...
2,632
#include <cuda_runtime_api.h> #include <device_launch_parameters.h> #include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <cstdio> #include <cstdlib> #define ARR_I_J(arr, i, j) arr[(i) * (K) + (j)] #define ARR_I_J_W(arr, i, j, W) arr[(i) * (L) + (j)] //#define N_DEBUG struct PathNode { in...
2,633
/* * HxUpdaterTM.cpp * * Created on: 11 янв. 2016 г. * Author: aleksandr */ #include "HxUpdaterTM.h" #include "SmartIndex.h" #include <thrust/device_vector.h> #include <thrust/functional.h> // o o o o o // o o o o o // o o o o o // o o o o o // x x x x x __host__ __device__ void HxUpdaterTM::op...
2,634
#include "cuda.h" __device__ __forceinline__ int sqr(int const x) { return (x * x); } // Call with 2D thread-organization. Could be called with 1D arrangement but this is for exercise. __global__ void clearFrame(uchar3 *const frame, int const frame_width, int const frame_height) { int const x = blockIdx.x * block...
2,635
/** * Add 2 arrays of 100 elements on the device. */ #include <iostream> #include <vector> #include <algorithm> __global__ void vecadd( int * v0, int * v1, std::size_t size ) { auto tid = threadIdx.x; v0[ tid ] += v1[ tid ]; } int main() { std::vector< int > v0( 100 ); std::vector< int > v1( 100 ); i...
2,636
//compile with: #include <stdio.h> #define Blocksize 10 __global__ void compute( char*, char*); __device__ __host__ void algorithm(char*, char*); __host__ int main (void) { char* targets; char* targets2; char* result; char* result2; int size = Blocksize * sizeof(char); //speicherreservieren cudaMalloc((void...
2,637
/*! \file arrays.cu \author Andrew Kerr <arkerr@gatech.edu> \brief tests implementation of cudaMallocArray(), among other things \date Feb 12, 2010 */ #include <stdlib.h> #include <stdio.h> ////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////...
2,638
#include <cuda.h> #include <stdio.h> #include <stdlib.h> #include <time.h> #define THREADS_PER_BLOCK 512 //function declarations unsigned int getmax(unsigned int *, unsigned int); __global__ void get_max(unsigned int *num, unsigned int size); int main(int argc, char *argv[]) { unsigned int size = 0; // The size...
2,639
__global__ void test_uchar4(uchar4* const c) { int a[5]; uchar4 val; val.x = 10; a[val.x] = 42; uchar4 val2 = val; a[val2.x] = 42; uchar4 val3; val3 = val; a[val3.x] = 42; uchar4 val4[3]; val4[1] = val; a[val4[1].x] = 42; c[1].y = 9; c[1].w = 3; int val5 = c[1].y; a[val5] = 42; }
2,640
#include <iostream> #include "string.h" #include <cuda.h> #include "cuda_runtime_api.h" //===========================================================================// void describe ( int device ) { cudaDeviceProp device_properties; ::memset( &device_properties, 0, sizeof(device_properties)); std::cou...
2,641
/// basic functions // two sum __device__ void two_sum(float a, float b, float &hi, float &lo){ hi = a + b; // best guess float v = hi - a; lo = (a - (hi - v)) + (b - v); } __device__ void two_sum(float a, float b, float c, float &hi, float &lo){ float s,t,u; two_sum(b,c,s,t); two_sum(a,s,hi,u); lo = u ...
2,642
#include "saxpy.cuh" __global__ void saxpy(const int *A, const int *B, int *C, int N, int a) { int i = blockIdx.x * blockDim.x + threadIdx.x; if (i < N) C[i] = a * A[i] + B[i]; }
2,643
#define max(a, b) ((a > b)?a:b) #define THREADSPERDIM 16 #define FALSE 0 #define TRUE !FALSE // mX has order rows x cols // vectY has length rows __global__ void getRestricted(int countx, int county, int rows, int cols, float * mX, int mXdim, float * vY, int vYdim, float * mQ, int mQ...
2,644
#include <iostream> #include <ctime> #include <chrono> using namespace std; __global__ void initArray(uint32_t * path, double *approx, uint32_t *top_k, int n){ int index = threadIdx.x + blockIdx.x * blockDim.x; if(index < n){ for(int i = 0; i < sizeof(path); i++){ approx[i]++; top_k[i] = path[i]++; } } }...
2,645
// [header] // A very basic raytracer example. // [/header] // [compile] // c++ -o raytracer -O3 -Wall raytracer.cpp // [/compile] // [ignore] // Copyright (C) 2012 www.scratchapixel.com // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License a...
2,646
#include "dot-tree.hh" #include <fstream> namespace utils { DotTree::DotTree(const std::string& label, const std::vector<DotTree>& nodes) : label_(label) { for (const auto& node : nodes) nodes_.push_back(new DotTree(node)); } DotTree::DotTree(const Dot...
2,647
#include "includes.h" using namespace std; //Check for edges valid to be part of augmented path //Update frontier __global__ void kernel(bool* adj_mat, const int N, bool* visited, int* frontier, bool* new_frontier, bool* par_mat, int* cap_mat, int* cap_max_mat) { int row_idx = frontier[blockIdx.x+1]; long offset = ...
2,648
#include <iostream> __global__ void mkernel(void){} int main() { mkernel <<<1,1>>>(); std::cout<<"Hello, World!"<<std::endl; system("pause"); return 0; }
2,649
#include <algorithm> #include <math.h> #include <iostream> #include <stdint.h> #include <stdio.h> #include <time.h> #define USE_GPU 1 /* enum Piece { empty, white_reg, white_reg_moved, white_king, white_king_moved, black_reg, black_reg_moved, black_king, black_king_moved };*/ typedef uint8_t Piece; const Pi...
2,650
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <time.h> cudaError_t addWithCuda(int *c, int *a, unsigned int size, int gridx, int gridy, int dimBlock); int * createArray(int amountToAdd, int arraySize, int * a); __global__ void addKernel(int *c, int *a) { //declares spa...
2,651
#include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <math.h> #include <chrono> void checkCUDAError(const char *msg) { cudaError_t err = cudaGetLastError(); if( cudaSuccess != err) { fprintf(stderr, "CUDA Error: %s: %s.\n", msg, cudaGetErrorString(err) ); exit(EXIT_FAILURE); } } #define BLOCKSIZE...
2,652
#include <cuda_runtime.h> #include <stdio.h> #include <time.h> #include <stdlib.h> #include <sys/time.h> //Tamaño de matrices (cuadradas) #define N 1024 //Kernel __global__ void mul(int * A, int * B, int * C){ int i = blockIdx.x; int j = threadIdx.x; C[i * N + j] = 0; for (int k = 0; k < N; k++){ C[i * N + j] ...
2,653
// // kernel routine //
2,654
class weekday { private: unsigned char __wd; public: weekday() = default; inline explicit constexpr weekday(unsigned __val) noexcept : __wd(static_cast<unsigned char>(__val == 7 ? 0 : __val)) {} inline constexpr unsigned c_encoding() const noexcept { return __wd; } }; constexpr int operat...
2,655
/* #include <cassert> #include <cstdio> #include <cstdlib> #include "grasta_cuda_util.cuh" #include "grasta_reduction.cuh" using namespace std; cudaError_t cudaSimpleReduction(float* data_to_sum, unsigned int num, float &accu){ float *dev_data_to_sum = 0; // array of elements to sum that reside on the device ...
2,656
#include "includes.h" __global__ void initializeAtRandom ( const int dim, const int nwl, const float dlt, const float *x0, const float *stn, float *xx ) { int i = threadIdx.x + blockDim.x * blockIdx.x; int j = threadIdx.y + blockDim.y * blockIdx.y; int t = i + j * dim; if ( i < dim && j < nwl ) { xx[t] = x0[i] + dlt * ...
2,657
/*************************************************************************** ************************************************************************** Spherical Harmonic Transform Kit 2.7 Copyright 1997-2003 Sean Moore, Dennis Healy, Dan Rockmore, Peter Kostelec Copyright 2004...
2,658
#include "includes.h" __global__ void scaleWalkers ( const int n, const float c, const float *a, float *d ) { int i = threadIdx.x + blockDim.x * blockIdx.x; if ( i < n ) { d[i] = c * a[i]; } }
2,659
#include <iostream> #include <string.h> #include <fstream> #include <sstream> #include <stdio.h> #include <vector> #include <time.h> #include <cuda.h> #include <math.h> #include <chrono> #include <ctime> using namespace std; //qsub -I -q coc-ice -l nodes=1:ppn=8:gpus=1,walltime=04:30:00,pmem=2gb //qsub -I -q coc-ice -l...
2,660
//Based on the work of Andrew Krepps #include <stdio.h> #define CONST_SIZE 1024 __constant__ unsigned int constDevA[CONST_SIZE]; __constant__ unsigned int constDevB[CONST_SIZE]; __host__ cudaEvent_t get_time(void) { cudaEvent_t time; cudaEventCreate(&time); cudaEventRecord(time); return time; } // Following fu...
2,661
/* Assignment 2 Block Wise reduction Author: Parth Tiwari Roll: 16IM30025 Date: 26th Feb 2020 */ #include <stdio.h> #include <stdlib.h> #include <math.h> #include <cuda.h> #include <cuda_runtime.h> __global__ void reduce(float* A, float* B, int q) { int num_threads = blockDim.x; int block_num = blockIdx....
2,662
#include <stdio.h> #include <stdlib.h> #include <math.h> __global__ void vector_min(float *a, int n) { // each block should cover blockDim.x * 2 elements int thread_id = blockIdx.x * blockDim.x + threadIdx.x; int s; for(s=1; s<blockDim.x; s*=2) { if (thread_id % 2*s == 0 && thread_id * s + s < n) { if(a[t...
2,663
#include <iostream> // Needed to perform IO operations using namespace std; #define N 100000 __global__ void add(int n, int *a, int *b, int *c) { int index = blockIdx.x * blockDim.x + threadIdx.x; int stride = blockDim.x * gridDim.x; printf("Hello from block %d, thread %d\n", blockIdx.x, threadIdx.x); ...
2,664
#include "includes.h" __global__ void kernel_add_wavelet ( float *g_u2, float wavelets, const int nx, const int ny, const int ngpus) { // global grid idx for (x,y) plane int ipos = (ngpus == 2 ? ny - 10 : ny / 2 - 10); unsigned int ix = blockIdx.x * blockDim.x + threadIdx.x; unsigned int idx = ipos * nx + ix; if(ix ==...
2,665
void setGrid(int n, dim3 &blockDim, dim3 &gridDim) { // set your block dimensions and grid dimensions here gridDim.x = n / blockDim.x/4; gridDim.y = n / blockDim.y/4; if(n % blockDim.x != 0) gridDim.x++; if(n % blockDim.y != 0) gridDim.y++; //blockDim.y = blockDim.y/8; }
2,666
/* CPP_CONTEST=2017 CPP_PROBLEM=I CPP_LANG=CUDA CPP_PROCESSES_PER_NODE=saturno 1 */ /* RECORD Francisco Muñoz García September 20, 2017 in CESGA time 1520 speed-up 9.80 */ #include <stdlib.h> __device__ int count(int ld,int n,char *a,char *b) //Each CUDA thread do this work and is called from kernel so ...
2,667
#include "includes.h" __global__ void analyze(const float *input, float *sum, int numElements) { int i = blockIdx.x * blockDim.x + threadIdx.x; if (i < numElements) { atomicAdd(sum + i, input[i]); } }
2,668
#include <stdio.h> #include <stdlib.h> // Define maximum number of vertices in the graph #define N 317080 #define EDGES 1049886 // Data structure to store graph struct Graph { // An array of pointers to Node to represent adjacency list struct Node* head[N+1]; }; // A data structure to store adjacency list nodes of...
2,669
#include "includes.h" __global__ void SumaColMatrizKernel (int M, int N, float *Md, float *Nd){ // Pvalue es usado para el valor intermedio __shared__ float Nds[DIMBLOCKX]; float Pvalue = 0; int columna = blockIdx.y*(N/gridDim.x)+threadIdx.x; int pasos = M/blockDim.x ; int posIni = columna * M + threadIdx.x * pasos; fo...
2,670
/* 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,float var_5,float var_6,float var_7,float var_8,float var_9,float var_10) { if (comp > (-1.3943E-36f / +0.0f - (var_2 ...
2,671
#include <stdio.h> #include <cuda_runtime.h> //#include <cutil.h> #define TILE_WIDTH 16 #define N 2048 void err_handling(cudaError_t *err, const char *str) { if (*err != cudaSuccess) { printf("%s\n", str); exit(EXIT_FAILURE); } } __global__ void matMul(const float *A, const float *B, float *C, int m, int k, i...
2,672
/** Homework 3 question 1 code * * \file q1.cu * \author Jose Carlos Martinez Garcia-Vaso <carlosgvaso@utexas.edu> * \author Utkarsh Vardan <uvardan@utexas.edu> */ #include <cstdio> // standard I/O #include <string> // strings #include <fstream> // streams #include <vector> // std::vector #include <sstre...
2,673
//pass //--blockDim=32 --gridDim=2 #include <cuda.h> __global__ void test_Prog(int *A, int N) { int tid = threadIdx.x; int bid = blockIdx.x; int idx = blockDim.x * bid + tid; for(int d = N/2; d > 0; d = d / 2) { int tmp = A[idx + d]; for (int i = 0; i < N; ++i) { int tmp2 = A[idx]; ...
2,674
#include "includes.h" #define BLKX 32 #define BLKY 32 cudaStream_t gstream; __global__ void initData(int nbLines, int M, double *h, double *g) { long idX = threadIdx.x + blockIdx.x * blockDim.x; if (idX > nbLines * M) return; h[idX] = 0.0L; g[idX] = 0.0L; if ( idX >= M +1 && idX < 2*M-1 ){ h[idX] = 100.0; g[id...
2,675
#include <memory.h> #include <ctime> #include <random> #include <iomanip> #include <algorithm> #include <iostream> #include <iterator> #include <numeric> #include <sstream> #include <fstream> #include <cassert> #include <climits> #include <cstdlib> #include <cstring> #include <string> #include <cstdio> #include <vector...
2,676
#include "Config.cuh.cu" namespace RayTracing { std::istream& operator>>(std::istream &istream, Config& config) { istream >> config.framesNum; istream >> config.outputTemplate; istream >> config.width >> config.height; istream >> config.horizontalViewDegrees; istream >> config.lookFrom >> conf...
2,677
#include "includes.h" __global__ void forwardPass2(float* layer1, float* syn2, float* out) { int l = blockDim.x*blockIdx.x + threadIdx.x; int Y = 128; int Z = 10; #pragma unroll for (int j=0; j < Y; ++j) out[l] += layer1[j] * syn2[j*Z + l]; out[l] = 1.0/(1.0 + exp(out[l])); }
2,678
#include "includes.h" __global__ void _norm_backward_kernel(float *x, float *mean, float *var, float *mean_diff, float *var_diff, int b, int c, int wxh, float *grad) { int ind = (blockIdx.x + blockIdx.y*gridDim.x) * blockDim.x + threadIdx.x; int j = (ind / wxh) % c; if (ind >= b * c * wxh) return; grad[ind] = grad[in...
2,679
/* * Copyright 2019 Australian National University * * 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 applic...
2,680
//ֵ˲Ϊboxfilter #define TILE_DIM 16 #define BLOCKSIZE 128 __global__ void d_boxfilter_x_global(float *src, float *dst, int width, int height, int r) { int tid = threadIdx.x; int bid = blockIdx.x; int offset = 1; int num = (width + 2 * r + 2 * BLOCKSIZE - 1) / (2 * BLOCKSIZE); //ÿһ߳̿鱻BLOCKSIZE*2ָnumsegment int le...
2,681
#include "includes.h" __global__ void k_dummy_test() { }
2,682
#include <iostream> using namespace std; #define MATRIX_SIZE 4 #define CUDAMALLOC_ERROR(_err) \ do { \ if (_err != cudaSuccess) { \ printf("%s failed in file %s at line #%d\n", cudaGetErrorString(_err),__FILE__,__LINE__); \ exit(EXIT_FAILURE); \ } ...
2,683
#include <cstdio> #include <iostream> int main() { int device_count; cudaGetDeviceCount(&device_count); std::cout<<"Device count: "<<device_count<<std::endl; cudaDeviceProp device_prop; cudaGetDeviceProperties(&device_prop, 0); std::cout<<"Max threads per block: "<<device_prop.maxThreadsPerBlock<<std::endl...
2,684
// #include "linalg.cu" /*! * Compute the initial labels for a gene pair in an expression matrix. Samples * with missing values and samples that are outside the expression thresholds are * labeled as such, all other samples are labeled as cluster 0. The number of * clean samples is returned. * * @param x * @...
2,685
#include <iostream> #include <stdlib.h> #include <time.h> #include <float.h> #include <cuda.h> #include <curand_kernel.h> #define N 500000000 //Numero de valores de entrada #define M 8 //Tamaño del histograma #define REPETICONES 10000 //Repeticon de pruevas para calculo de media,...
2,686
#include "includes.h" __global__ void updateVel(float2 *__restrict__ oldVel, float2 *__restrict__ newVel, unsigned int simWidth) { unsigned int x = blockIdx.x * blockDim.x + threadIdx.x; unsigned int y = blockIdx.y * blockDim.y + threadIdx.y; oldVel[y*simWidth+x] = newVel[y*simWidth+x]; }
2,687
extern "C" { __global__ void A_emult_Bg0(const int n, const double *a, const double *b, double *c) { int i = threadIdx.x + blockIdx.x * blockDim.x; if (i<n) { if (b[i]>0.0) {c[i] += a[i];} else {c[i] += 0.0;} } } }
2,688
#include "includes.h" __global__ void awkward_ByteMaskedArray_getitem_nextcarry_outindex_kernel(int64_t* prefixed_mask, int64_t* to_carry, int64_t* outindex, int8_t* mask, int64_t length) { int64_t block_id = blockIdx.x + blockIdx.y * gridDim.x + gridDim.x * gridDim.y * blockIdx.z; int64_t thread_id = block_id * blockD...
2,689
#include "Vector3fDev.cuh";
2,690
// nvcc EthanPixels.cu -o temp -lm #include <math.h> #include <ctype.h> #include <stdio.h> #include <stdlib.h> // size of vector #define M 4 // Number of frames #define N 10 // Number of pixels per frame #define BLOCK 128 // Size of blocks, best if it is a power of 2. // Globals int *BlockOfFrames_CPU, *BlockOfFra...
2,691
#include "includes.h" using namespace std; __global__ void graphGenerate (float *a, float *b, int n){ int i= blockDim.x * blockIdx.x + threadIdx.x; if (i<n){ a[i]=threadIdx.x*2; b[i]=threadIdx.x; } }
2,692
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> //M and N number of threads (grid and block) void secuential(const int a[] ,const int b[], int c[], const int sqrt_dim); __global__ void multiply( const int a[] ,const int...
2,693
#include <stdlib.h> #include <stdio.h> #include <assert.h> #include <tiffio.h> #include <stdint.h> __global__ void blur(uint8_t *d_out, uint8_t *d_in, int width, int height){ int id = (blockIdx.x*blockDim.x)+threadIdx.x; if(id < width*height){ int x_edge = id % width; int y_edge = (id - x_edge) / width; in...
2,694
#define bottom_data(n,c,h,w) bottom_data[(n)*H*W*C+(c)*H*W+(h)*W+(w)] #define top_data(n,c,h,w) top_data[(n)*OC*OH*OW+(c)*OH*OW+(h)*OW+(w)] #define kernel(n,c,h,w) kernel[(n)*C*FW*FH+(c)*FW*FH+(h)*FW+(w)] __global__ void DPUPooling( int N, int C, int H, int W,float *bottom_data, int N1,int OC, int OH, ...
2,695
#include <iostream> using namespace std; __global__ void doSomething(int* outdata) { *outdata = 69; } int main(int argn, char** args) { int a = 5; cout << a << endl; int* kOut = 0; cudaMalloc((void**) &kOut, sizeof(int)); if (kOut == 0) { cerr << "crap, malloc failed" << endl; return 1; } doS...
2,696
/** CUDAで学ぶアルゴリズムとデータ構造 ステップバイステップでN−クイーン問題を最適化 一般社団法人 共同通信社 情報技術局 鈴木 維一郎(suzuki.iichiro@kyodonews.jp) コンパイルと実行 $ nvcc -O3 CUDA**_N-Queen.cu && ./a.out (-c|-r|-g) -c:cpu -r cpu再帰 -g GPU */ #include <stdio.h> #include <stdlib.h> #include <stdbool....
2,697
// Ryan Jacoby // Compiled on GNU/Linux with nvcc 10.2.89 // Test time with: nvprof --unified-memory-profiling off ./test // Ran on RTX 2080 in 1.5752ms #include<iostream> __global__ void add(int, float *, float *); int main() { int N = 1<<20; float *x, *y; cudaMallocManaged(&x, N*sizeof(float)); cu...
2,698
#include "includes.h" __global__ void selection_sort_gpu(int b, int n, int m, int k, float *dist, int *idx, float *val) { int batch_index = blockIdx.x; dist+=m*n*batch_index; idx+=m*k*batch_index; val+=m*k*batch_index; int index = threadIdx.x; int stride = blockDim.x; float *p_dist; for (int j=index;j<m;j+=stride) { ...
2,699
#include "matrix.cuh" __device__ matrix_list_t* device_matrix_list_constructor(buffer_t* buffer, unsigned int num) { matrix_list_t* list = (matrix_list_t*)buffer_malloc(buffer, sizeof(matrix_list_t)); list->num = num; list->matrix_list = (matrix_t**)buffer_malloc(buffer, sizeof(matrix_t*) * num); return list; } _...
2,700
#include <stdio.h> __global__ void hello() { printf("Hello world! I\'m a thread in block %d\n", blockIdx.x); } int main(int argc, char** argv) { hello<<<16, 1>>>(); // this statement will make the printfs() to flush to stdout cudaDeviceSynchronize(); return 0; }