serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
2,701
#include <stdio.h> #include <malloc.h> #include <stdlib.h> #include <math.h> #include <sys/time.h> #include <cuda.h> double wtime(void) { static struct timeval tv0; double time_; gettimeofday(&tv0,(struct timezone*)0); time_=(double)((tv0.tv_usec + (tv0.tv_sec)*1000000)); re...
2,702
#include <cuda.h> #include <stdio.h> #include <stdlib.h> #include <math.h> #define M 512 #define N 512 #define TILE_DIM 32 __global__ void TiledMatMul(int *A, int *B, int *C) { __shared__ float tiled_A[TILE_DIM][TILE_DIM]; __shared__ float tiled_B[TILE_DIM][TILE_DIM]; int bx = blockIdx.x; int by =...
2,703
#include<stdio.h> #include<stdlib.h> #include<cuda.h> //#define m 5 //#define p 5 //#define n 5 __global__ void devicematrix(int *d_m1, int *d_m2, int *d_op, int m, int p, int n) { int i = blockIdx.x * blockDim.x + threadIdx.x; int j = blockIdx.y * blockDim.y + threadIdx.y; int k; if(i<m && j<n) { int ...
2,704
/****************************************************************************** *cr *cr (C) Copyright 2010 The Board of Trustees of the *cr University of Illinois *cr All Rights Reserved *cr *****************************************************************...
2,705
#include <stdio.h> #define N 32 __global__ void kernel(int* input, int* output){ for(int i=0; i<N; i++) output[i] = 2 * input[i]; } int main(void){ int *h_input, *h_output; int *d_input, *d_output; h_input = (int*)malloc(N*sizeof(int)); h_output = (int*)malloc(N*sizeof(int)); cudaMalloc((void**)&d_input, ...
2,706
#include <stdio.h> #include <time.h> #include <cuda.h> #include <curand_kernel.h> #define CL 2000000LL // kernel __global__ void picuda(double *res, long long W, curandState *states) { long long i = blockIdx.x*blockDim.x + threadIdx.x; if (i < W) { double ans = 0; unsigned int seed = (unsigned int) (clo...
2,707
#include <math.h> #include <stdio.h> #include <cuda_runtime.h> __global__ void kernel_add_sq(float* c, const float* a, const float* b, int N) { int i = threadIdx.x + blockDim.x * blockIdx.x; if (i < N) { c[i] = a[i] * a[i] + b[i] * b[i]; } } inline cudaError_t CHECK(cudaError_t err) { if (err != cudaSucc...
2,708
// What happens : // CPU -> Get Inputs from File -> Remove Character + Pre-processing // -> Make an Instrcution Table ( Row , Column , Value to be added ) -> GPU // GPU -> Use Atomics to Add Values // // time : < 0.1 sec for 980m // // Uses : CUDA : Unified Memory // C++ : Vectors , Map , String F...
2,709
#include <stdio.h> #include <math.h> #include <cuda.h> #include<iostream> using namespace std; __global__ void mul(int *a, int n) { __shared__ int s[4]; int t = threadIdx.x; s[t] = a[2*t]*a[2*t+1]; a[2*t]=s[t]; } int main(void) { const int n = 8; int a[n], d[n],ans; int no,x,y; cout <<"Enter your nu...
2,710
#include "includes.h" __global__ void threshold_one(float *vec, float *vec_thres, int *bin, const int k_bin, const int n) { unsigned int xIndex = blockDim.x * blockIdx.x + threadIdx.x; // xIndex is a value from 1 to k from the vector ind if ( (xIndex < n) & (bin[xIndex]<=k_bin) ) vec_thres[xIndex]=vec[xIndex]; }
2,711
#include<stdio.h> #include<cuda.h> #include<cuda_runtime_api.h> #include<stdlib.h> #define O_Tile_Width 3 #define Mask_width 3 #define width 5 #define Block_width (O_Tile_Width+(Mask_width-1)) #define Mask_radius (Mask_width/2) __global__ void convolution_1D_tiled(float *N,float *M,float *P) { int index_out_x=block...
2,712
// set the current Jx on each cell __global__ void set_current(int ncells, float *Jx, float *Jy, float *Jz) { int tid = threadIdx.x + blockIdx.x * blockDim.x; while (tid < ncells) { Jx[tid] = Jx[tid]/float(2.0); Jy[tid] = Jy[tid]/float(2.0); Jz[tid] = Jz[tid]/float(2.0); tid +...
2,713
#include <iostream> #include <stdio.h> #include <cuda.h> #include <time.h> using namespace std; // ---------------------------------------------------------------------------- #define checkLastError() { \ cudaError_t error = cudaGetLastError(); ...
2,714
#include <iostream> #include <cuda_runtime.h> using std::cout; using std::endl; int main(){ int numDev; cudaGetDeviceCount( &numDev ); for(int i = 0; i<numDev; ++i){ cudaDeviceProp properties; cudaGetDeviceProperties(&properties, i); cout << "Device #: " << i << endl; cout << "Name: " << properties.n...
2,715
/* ============================================================================ Name : mull_forward.cu Author : Christophoros Bekos (mpekchri@auth.gr) Version : Copyright : @ copyright notice Description : CUDA compute reciprocals ================================================================...
2,716
#include <stdint.h> #define uint uint32_t #define IDX(i,j,ld) (((i)*(ld))+(j)) #define IDX3(i,j,k,rows,cols) ((k)*(rows)*(cols)+(i)*(cols)+j) #include<cufft.h> #include<cuda.h> //__global__ void copy_Kernel( real *out, const int *outm, const int *outn, real *in, const int ink, const int inm, const int inn, const int o...
2,717
#include "includes.h" __global__ void tanhActivationBackprop(float* Z, float* dA, float* dZ, int Z_x_dim, int Z_y_dim) { int index = blockIdx.x * blockDim.x + threadIdx.x; if (index < Z_x_dim * Z_y_dim) { float d = Z[index]; dZ[index] = dA[index] * (1 - d * d); } }
2,718
#include <sys/time.h> #include <cstdlib> #include <cstdio> #include <ctime> #define BLOCK_SIZE 16 #ifndef DEVICE_COUNT #define DEVICE_COUNT 1 #endif void print_matrix_2D(double *A, int rows, int cols) { for (int i = 0; i < rows; ++i) { for (int j = 0; j < cols; ++j) ...
2,719
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <cuda.h> #define ThreadNum 256 __global__ void printBase(int **base, int length) { int t_id = threadIdx.x; int b_id = blockIdx.x; if (t_id < length) { printf("block:%d-%d : %d\n", b_id, t_id, base[b_id][t_id]); } } int main(...
2,720
/* Faz a soma dos elementos de dois vetores Exemplifica o uso de diferentes streams (1 e 2) com cudaMallocHost para alocar memoria no host nao paginavel e copia assincrona com cudaMemcpyAsync. Usa tambem o cudaStreamSynchronize para aguardar toda a stream terminar. O algoritmo divide "tam" elementos por "streams_nr...
2,721
#include <assert.h> #include <errno.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> typedef signed char schar; typedef unsigned char uchar; typedef short shrt; typedef unsigned short ushrt; typedef unsigned uint; typedef unsigned long ulong; typedef long long llong; typedef unsigned ...
2,722
#include <thrust/device_vector.h> #include <thrust/copy.h> #include <stdio.h> #include <iostream> #include <time.h> #include <chrono> struct is_even{ __host__ __device__ bool operator () (const int x){ return (x & 1) == 0; } }; int main(int argc, char** argv){ int size = atoi(argv[1]); thrust::device...
2,723
#include <stdio.h> #include <math.h> void printMatrix(const int *A, int rows, int cols) { for(int i = 0; i < rows*cols*4; i++){ printf("%d ", A[i]); printf(" "); if ((i+1)%4 == 0){ printf("|"); } } printf("\n"); }; void readInput_aos(const char *filename, int *...
2,724
#include "includes.h" __global__ void repeat_x_for_clusters(float * x,int size) { int index = blockIdx.x * blockDim.x + threadIdx.x ; int thread_index = threadIdx.x ; int block_index = blockIdx.x ; if (block_index > 0 && index < size) { x[index] = x[thread_index] ; } }
2,725
#include "includes.h" __global__ void convertPitchedFloatToGrayRGBA_kernel(uchar4 *out_image, const float *in_image, int width, int height, int pitch, float lowerLim, float upperLim) { const int x = __mul24(blockIdx.x, blockDim.x) + threadIdx.x; const int y = __mul24(blockIdx.y, blockDim.y) + threadIdx.y; uchar4 temp;...
2,726
#include <stdio.h> #include <stdlib.h> #include <iostream> #include <cuda.h> #include <fstream> #include <string> #include <cstdlib> #include <math.h> #include <algorithm> #include <bitset> #include <iomanip> using namespace std; __global__ void twodimconvol(float *a, float *h, float *c, int kY, int kX, int dY, int ...
2,727
// // Created by igor on 26.03.2021. // #include "ColorF.cuh" __host__ __device__ ColorF operator* (const ColorF &c, float f) { return {c.r * f, c.g * f, c.b * f}; } __host__ __device__ ColorF operator+ (const ColorF &l, const ColorF &r) { return {l.r + r.r, l.g + r.g, ...
2,728
#include <iostream> #include <cuda_runtime.h> using namespace std; int main() { float * pDeviceData = nullptr; int width = 10 * sizeof(float); int height = 10 * sizeof(float); size_t pitch; cudaError err = cudaSuccess; //1 use cudaMallocPitch function err = cudaMallocPitch(&pDeviceData, &pitch, width, heigh...
2,729
#include "fast_heap.h" int main(int argc, const char *argv[]) { HeapElement<HeapElementSpec> &elm = fast_heap->get(100); elm.discard(); }
2,730
#include <iostream> __global__ void simdtest(float* A) { int globalID = blockIdx.x * blockDim.x + threadIdx.x; if ( (threadIdx.x % 32) < 8 ) { A[globalID] = 1; } else { A[globalID] = 0; } } int main() { int THREADS = 256; float* A; cudaMallocManaged(&A, THREADS*sizeof(float)); std::cout <...
2,731
#include <cuda_runtime.h> #include <stdio.h> __global__ void helloworld() { printf("hello world\n"); } int main(int argc, char** argv) { // launch a gpu kernel helloworld<<<3,3>>>(); // block the cpu for the gpu to finish execution cudaDeviceSynchronize(); return 0; }
2,732
//MIT License //Copyright (c) 2020 Sherman Lo #include <cuda.h> #include <curand_kernel.h> //See empiricalNullFilter - this is the main entry //Notes: row major //Note: shared memory is used to store the empirical null mean and std. IF big //enough, also the cache. Size becomes a problem if the kernel radius ...
2,733
#ifndef _Vector3D_ #define _Vector3D_ #include <math.h> #include <limits> class Vector3D { public: float x; float y; float z; __host__ __device__ Vector3D() { } __host__ __device__ Vector3D(float x, float y, float z) { this->x = x; this->y = y; this->z = z; } __host__ __device__ ~Vector3D() { ...
2,734
#include <stdint.h> #include <cuda.h> extern "C" __global__ void idle(unsigned int *p, unsigned int n) { int x = blockIdx.x * blockDim.x + threadIdx.x; int y = blockIdx.y * blockDim.y + threadIdx.y; unsigned int i = 0, j = 0, k = 0; __shared__ int s; s = *p; if (x == 0 && y == 0) { for (i = 0; i < n; i+...
2,735
/** * Autor: Grupo GRID * Fecha: Julio 2016 */ #include <stdio.h> #include <stdlib.h> #include <string.h> #define N 4 #define _BLOCK_SIZE_ 2 __global__ void MultiplocarMatrices(int *A, int *B, int *C, int n) { const uint wA = n; const uint wB = n; const uint bx = blockIdx.x; const uint by = blockId...
2,736
#include "includes.h" __global__ void vectorAddKernel(float* inputA, float* inputB, float* output, int length){ //compute element index int idx = blockIdx.x * blockDim.x + threadIdx.x; //add an vector element if(idx < length) output[idx] = inputA[idx] + inputB[idx]; }
2,737
#include "nodes-list.hh" #include "node.hh" #include <algorithm> #include <cassert> #include <map> namespace rt { namespace { std::vector<Node*> preds_no_not(Node* n) { std::vector<Node*> res; for (auto pred : n->preds) { if (pred->type == N...
2,738
/* * EzUpdater.cpp * * Created on: 25 янв. 2016 г. * Author: aleksandr */ #include "EzUpdater.h" #include "SmartIndex.h" // indx - индекс вдоль правой или левой границы по y от firstY до lastY __host__ __device__ void EzUpdater::operator() (const int indx) { /* correct Ez adjacent to TFSF boundary */ //...
2,739
extern "C" { typedef struct { int e0; char* e1; } struct_Buffer_220119; typedef struct { struct_Buffer_220119 e0; int e1; int e2; int e3; } struct_Img_220118; union variant_220130 { int qs32; float pf32; }; typedef struct { unsigned int e0; union variant_220130 e1; } struct_Bound...
2,740
#include <iostream> #include <fstream> #include <sstream> #include <iomanip> #include <cmath> #include <chrono> constexpr double pi = 3.14159265358979323846; class Node_t { // Turn this into separate vectors, because cache exists public: __device__ Node_t(float coordinate, int neighbour0, int ne...
2,741
#include <stdio.h> #include <assert.h> #include <cuda.h> // zwykła funkcja w C/C++ void incrementArrayOnHost(double *tab, int N) { for (int i=0; i < N; i++) tab[i] += 1.0; } // funkcja (tzw. kernel) działająca na GPU __global__ void incrementArrayOnDevice(double *tab, int N) { int idx = blockIdx.x*blockDim....
2,742
#include <iostream> class cuComplex { private: float r; float i; public: __device__ cuComplex(float a, float b) : r(a), i(b) { } __device__ float norm(void) { return r*r + i*i; } __device__ cuComplex operator*(const cuComplex &a) { return cuComplex(r*a.r - i*a.i, i*a....
2,743
namespace Megakernel { __device__ volatile int doneCounter = 0; __device__ volatile int endCounter = 0; __device__ int maxConcurrentBlocks = 0; __device__ volatile int maxConcurrentBlockEvalDone = 0; }
2,744
#include "includes.h" __global__ void add(double* in, double* out, int offset, int n){ int gid = threadIdx.x + blockIdx.x * blockDim.x; if(gid >= n) return ; out[gid] = in[gid]; if(gid >= offset) out[gid] += in[gid-offset]; }
2,745
#include "includes.h" __global__ void transform(float *points3d_after, float *points3d, float * transformation_matrix) { int x = blockIdx.x * TILE_DIM + threadIdx.x; int y = blockIdx.y * TILE_DIM + threadIdx.y; int w = gridDim.x * TILE_DIM; for (int j = 0; j < TILE_DIM; j+= BLOCK_ROWS) { int iw = x; int ih = y + j; fo...
2,746
#include <cuda.h> extern "C" void initCUDA(int argc, char *argv[]) { } extern "C" void exitCUDA(int argc, char *argv[]) { }
2,747
#include <stdio.h> #include <stdlib.h> __global__ void fill_matrix_device(int *m, int width) { int tx=blockIdx.x; int ty=blockIdx.y; int value=(tx+1)*(ty+1); m[tx*width+ty] = value; } __global__ void matrix_mult_device(int *Ma, int *Mb, int *Mc, int width) { int tx = blockIdx.x; ...
2,748
#include <cuda_runtime.h> #include <stdio.h> #define CHECK(call){ \ const cudaError_t error = call; \ if (error != cudaSuccess){ \ printf("Error: %s:%d, ", __FILE_...
2,749
#include "includes.h" __global__ void squareMatrixMulKernel(int *c, int *a, int *b, int arrayWidth) { float sum = 0; //여기서 threadIdx.x와 y는 행렬의 인덱스와 같다. 예시) 2x2행렬일때 00 01 10 11 for (int i = 0; i < arrayWidth; ++i) { float Aelement = a[threadIdx.y * arrayWidth + i]; float Belement = b[i*arrayWidth + threadIdx.x]; sum +...
2,750
#include<iostream> #include<stdlib.h> __global__ void add(int *a,int *b,int *c) { int index=blockIdx.x*blockDim.x+threadIdx.x; c[index]=a[index]+b[index]; } void random_ints(int *a,int N) { int i; for(i=0;i<N;i++) { a[i]=i; } } #define N 2048 #define THREADS_PER_BLOCK 64 int main(void) { int *a,*b,*c; int *d...
2,751
/* TO DO: Please put your name and date of modification * * Author: Brady Chen 5/1/2015 * Modified By: * <your name> <date> * * This is a C code for the computation of a histogram of data from an input text file. The * text file contains multiple lines of characters. The code generate the ...
2,752
#include <cmath> __global__ void my_copysign(double* v) { int i = threadIdx.x; *v = (i == 0 ? 1 : -1) * (*v); }
2,753
#include<stdio.h> #include<time.h> __global__ void grouptrajectoryKernel(int b, int n, int c, int m,int t, int k, const float * __restrict__ inp, const int * __restrict__ idx, float * __restrict__ out) { for(int i=blockIdx.x;i<b;i+=gridDim.x){ for(int j=threadIdx.x;j<m;j+=blockDim.x){ for(int u=...
2,754
#pragma once #include <vector> #include <string> #include <cassert> #include "Vector3.cuh.cu" namespace RayTracing { class Image { private: int m_width; int m_height; cudaResourceDesc m_cudaTextureResourceDesc; cudaTextureDesc m_cudaTextureDesc; cudaArray *m_buffer_d = nullptr; public: std::...
2,755
/****************************************************************************** *cr *cr (C) Copyright 2010 The Board of Trustees of the *cr University of Illinois *cr All Rights Reserved *cr *****************************************************************...
2,756
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <cuda.h> #include <ctime> #include <time.h> #include <cuda_runtime.h> // Kernel CUDA, cada thread trabaja con un elemento de C __global__ void vecAdd(double *a, double *b, double *c, int n) { // Obtencion del thread id global (en el device) in...
2,757
//pass //--blockDim=64 --gridDim=64 --no-inline #include "cuda.h" __global__ void foo(int x) { if (x == 0) { __syncthreads (); } }
2,758
#include <stdio.h> #define row 4 #define col 5 #define space 4*5*sizeof(int) #define elements 4*5 //this works until col<=Nthreads. In this case every threads moves only 1 data __global__ void transpose (int* A, int*B){ int i=threadIdx.x+(blockIdx.x*blockDim.x); int totlength= blockDim.x*gridDim.x-1; int factor;...
2,759
#include "Tests/Tests.cuh" int main(int argc, char **argv) { //Run tests if (argc == 2 && argv[1][1] == 't' && argv[1][0] == '-') { InitAllTests(); //Tests code here TreeBuildingTests(); FinalReport(); return EXIT_SUCCESS; } return 0; }
2,760
#include "includes.h" __global__ void remapAggregateIdxKernel(int size, int *fineAggregateSort, int *aggregateRemapId) { int idx = blockIdx.x * blockDim.x + threadIdx.x; if(idx < size) { fineAggregateSort[idx] = aggregateRemapId[fineAggregateSort[idx]]; } }
2,761
#include <iostream> #define NUM_ELEM 8 #define NUM_THREADS 10 using namespace std; __global__ void concurrentRW(int *data) { // NUM_THREADS try to read and write at same location //data[blockIdx.x] = data[blockIdx.x] + threadIdx.x; atomicAdd(&data[blockIdx.x], threadIdx.x); } int main(int arg...
2,762
#include <stdio.h> #include <math.h> #include <stdlib.h> __host__ __device__ double3 d3add(double3 a, double3 b) { /* * Arguments: two 3d vectors * Returns: a new vector that is a vector addition of the arguments */ double3 ret; ret.x=a.x+b.x; ret.y=a.y+b.y; ret.z=a.z+b.z; return ret; } __host__ __devic...
2,763
#include <cuComplex.h> #include <stdio.h> #include <malloc.h> #include <stdlib.h> #include <complex.h> #include <math.h> #include <iostream> #include <fstream> #include <cmath> #include <algorithm> #define h_x 0.01 #define h_y 0.005 #define N 100 //размер расчетной плоскости по X #define M 400 //размер расчетной плоско...
2,764
//xfail:ASSERTION_ERROR //--blockDim=1024 --gridDim=1 --no-inline __device__ float multiplyByTwo(float *v, unsigned int tid) { return v[tid] * 2.0f; } __device__ float divideByTwo(float *v, unsigned int tid) { return v[tid] * 0.5f; } typedef float(*funcType)(float*, unsigned int); __global__ void foo(float ...
2,765
/****************************************************************************** *cr *cr (C) Copyright 2010 The Board of Trustees of the *cr University of Illinois *cr All Rights Reserved *cr *****************************************************************...
2,766
#include <stdio.h> #include <stdlib.h> /** * (1) Tempos de execução: * (a) CUDA: 0m1.626s * (b) Sequencial: 0m0.324s * (c) OpenMP: 0m0.314s * (d) OpenMP - GPU: 0m1.688s * (e) CUDA - Global: 0m1.723s * * (2) Nvprof: * (a) CUDA: * (a.1) CUDA memcpy HtoD: 465.46ms * (a.2) sum_cuda: 21.560ms...
2,767
// ### // ### // ### Practical Course: GPU Programming in Computer Vision // ### // ### // ### Technical University Munich, Computer Vision Group // ### Winter Semester 2013/2014, March 3 - April 4 // ### // ### // ### Evgeny Strekalovskiy, Maria Klodt, Jan Stuehmer, Mohamed Souiai // ### // ### // ### Shiv, painkiller...
2,768
#include <stdio.h> #include <time.h> __global__ void add(int *a, int *b, int *c); int main() { clock_t t; int a, b, c; int *d_a, *d_b, *d_c; t = clock(); // allocate space for device copies cudaMalloc(&d_a, sizeof(int)); cudaMalloc(&d_b, sizeof(int)); cudaMalloc(&d_c, sizeof(int)); // setup inputs a = 1; ...
2,769
#include <iostream> #include <chrono> #include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <vector> auto cpuVectorAddition(std::vector<int> A, std::vector<int> B) { auto start = std::chrono::high_resolution_clock::now(); for(int i = 0;i< A.size();i++) { A[i] += B[i]; } aut...
2,770
struct Real3 { double value[3]; }; template<class T1, class T2> struct Pair { T1 first; T2 second; template<class U1, class U2> __device__ Pair& operator=(const Pair<U1, U2>& other) { first = other.first; second = other.second; return *this; } }; template<class T1,...
2,771
#include "includes.h" __global__ void MatrixMul(float *darray_1, float *darray_2 , float *dres_arr, int n){ // cols and rows definition int col = threadIdx.x + blockIdx.x * blockDim.x; int row = threadIdx.y + blockIdx.y * blockDim.y; // Mat mult operation for(int i = 0; i<n; i++){ dres_arr[row*n+col]+= darray_1[row*n+i...
2,772
#include "includes.h" __global__ void increment(char* data, size_t length) { size_t global_index = threadIdx.x + blockIdx.x * blockDim.x; if (global_index < length) data[global_index]++; }
2,773
#include "includes.h" __global__ void bcnn_cuda_grad_bias_kernel(float *grad_bias, float *grad_data, int num_channels, int spatial_size) { int offset = blockIdx.x * blockDim.x + threadIdx.x; int channel = blockIdx.y; int batch_size = blockIdx.z; if (offset < spatial_size) grad_bias[channel] += grad_data[(batch_size * ...
2,774
#include "includes.h" __global__ void compactIndicatorToPixelKernel( const unsigned* candidate_pixel_indicator, const unsigned* prefixsum_indicator, unsigned img_cols, ushort2* compacted_pixels ) { const auto idx = threadIdx.x + blockIdx.x * blockDim.x; if(candidate_pixel_indicator[idx] > 0) { const auto offset = prefi...
2,775
#include <stdio.h> int main() { int nDevices, i; cudaDeviceProp prop; cudaGetDeviceCount(&nDevices); for(i = 0; i<nDevices; i++) { cudaGetDeviceProperties(&prop, i); printf("Name: %s, Major: %d, Minor: %d\n", prop.name, prop.major, prop.minor); printf("Maximum # of Threads Per Block = %d\n", ...
2,776
#include "includes.h" #define KERNEL_RADIUS 31 #define KERNEL_LENGTH (2 * KERNEL_RADIUS + 1) __constant__ float c_Kernel[ KERNEL_LENGTH ]; __global__ void convolutionZ_63_Kernel( float *d_Dst, float *d_Src, int imageW, int imageH, int imageD, int outofbounds, float outofboundsvalue ) { // here it is [x][z], we leave...
2,777
#include "includes.h" __global__ void hello(char *a, int *b) { for (int i=0; i<7; ++i) { a[i] += b[i]; } }
2,778
/*#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <opencv2/core.hpp> #include <opencv2/imgcodecs.hpp> #include <opencv2/highgui.hpp> #include<opencv2\imgproc.hpp> #include <iostream> #define INF 2e10f #define SPHERES_C 1300 #define threads 16 #define rnd(x) (x * rand() / RAN...
2,779
__global__ void sorted_mean_per_slice(unsigned int* lower_bounds, unsigned int* upper_bounds, double* u, // array of particle quantity sorted by slice unsigned int n_slices, ...
2,780
//Input file: space delimited #include <stdio.h> #include <math.h> #include <float.h> #include <cuda.h> #include <cuda_runtime.h> //Size of the GPU memory #define GPU_MEMSIZE_GB 2 //For case in which XSIZE = 1201 and YSIZE = 801 #define GLOBAL_MEM_USE_MB 773 #define MEM_USE_PER_THREAD_B 1280 //MAX_XSIZE_POSSIB...
2,781
#include <stdio.h> #include <stdlib.h> #define N 1024 #define N_THR 512 void fill_ints(int* a, int size){ for(int i =0; i<size; i++) a[i]=i; } __global__ void dotVecs(int *x, int *y, int *r){ __shared__ int s_tmp[N_THR]; int index = threadIdx.x + blockIdx.x * blockDim.x; int temp = x[index] * y[index]; ...
2,782
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <iostream> #include <cuda.h> int *a, *b; // host data int *c, *c2; // results __global__ void vecAdd(int *A, int *B, int *C, int N) { int tid = blockIdx.x * blockDim.x + threadIdx.x; C[tid] = A[tid] + B[tid]; } void vecAdd_h(int *A1, int *B1, in...
2,783
extern "C" int cSetDevice(int device) { return cudaSetDevice(device); }
2,784
#include <stdint.h> class Bmp256 { //自定义图像类 #pragma pack(2) // 设定变量以n = 2字节对齐方式 struct Header { // 头信息 uint16_t bfType = 0x4D42; uint32_t bfSize; uint16_t bfReserved1 = 0; uint16_t bfReserved2 = 0; uint32_t bfOffBits = 54 + 256 * 4; uint32_t biSize = 40; int32_t biWidth; int...
2,785
#include <vector> #include <iostream> #define cudaErrCheck(code) if (code != cudaSuccess) throw CudaException{code, __FILE__, __LINE__} struct CudaException { cudaError_t code; const char * file; int line; const char * what() const noexcept { return cudaGetErrorString(code); } }; __global__ void...
2,786
#include <stdio.h> #include <stdlib.h> #include <inttypes.h> #include <stdint.h> #include <string.h> #include <cuda.h> #include <cuda_runtime.h> #define DATAFILE "./data.bin" #define OUTFILE "./snapshot.bin" #define STORAGE_SIZE 1085440 #define MAX_FILE_SIZE 1048576 #define G_WRITE 991 #define G_READ 992 #define LS_...
2,787
/****************************************************************************** *cr *cr (C) Copyright 2010 The Board of Trustees of the *cr University of Illinois *cr All Rights Reserved *cr *****************************************************************...
2,788
#include "includes.h" /* Copyright (C) 2009-2012 Fraunhofer SCAI, Schloss Birlinghoven, 53754 Sankt Augustin, Germany; all rights reserved unless otherwise stated. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software...
2,789
__global__ void computeDescriptor( float* desc_out, unsigned desc_len, unsigned histsz, const float* x_in, const float* y_in, const unsigned* layer_in, const float* response_in, const float* size_in, const float* ori_in, unsigned total_feat, const int d, const int n, ...
2,790
#include <stdio.h> #include <cuda.h> int main() { int deviceCount; cudaGetDeviceCount(&deviceCount); printf("Numero di device disponibili %d\n\n\n",deviceCount); int device; for (device = 0; device < deviceCount; ++device) { cudaDeviceProp deviceProp; cudaGetDeviceProperties(&deviceProp, device...
2,791
#include <iostream> #include <time.h> #include "cuda_runtime.h" #include "device_launch_parameters.h" #include <cufft.h> #define NX 3335 // Чݸ #define NXWITH0 5000 #define Nfft 128 #define BLOCK_SIZE 32 using std::cout; using std::endl; /** * ܣж cufftComplex Ƿ * 룺idataA Aͷָ * 룺idataB Bͷָ * 룺size Ԫظ * أtrue | false *...
2,792
#include<stdio.h> __global__ void parallel_vector_add(int* d_a, int* d_b, int* d_c, int* d_n) { int i = (blockIdx.x*blockDim.x) + threadIdx.x; // printf("I am thread #%d\n", i); if(i < *d_n) { printf("I am thread #%d. and about to computer c[%d].\n", i, i); d_c[i] = d_a[i]+d_b[i]; } else { printf("I am threa...
2,793
#include <iostream> #include <ctime> #include <cuda_runtime.h> #include <cuda_runtime_api.h> #include <device_launch_parameters.h> #include <cuda.h> using namespace std; void KNearestNeighborsCPU(float3 *dataArray, int *result, int cnt); __global__ void KNearestNeighborsGPU(float3 *dataArray, int *result, int cnt); ...
2,794
/** * Copyright 1993-2012 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 relat...
2,795
#include "includes.h" /** Modifed version of knn-CUDA from https://github.com/vincentfpgarcia/kNN-CUDA * The modifications are * removed texture memory usage * removed split query KNN computation * added feature extraction with bilinear interpolation * * Last modified by Christopher B. Choy <chrischoy@ai...
2,796
#include <stdio.h> __global__ void hellokernel() { printf("Hello World!\n"); } int main(void) { int num_threads = 10; int num_blocks = 10; hellokernel<<<num_blocks,num_threads>>>(); cudaDeviceSynchronize(); return 0; }
2,797
#include <iostream> #include <vector> __global__ void vecmabite( int *out, int *in, std::size_t size ) { auto tid = threadIdx.x; out[ tid ] = in[ 2 * tid ]; } int main() { std::vector< int > out( 50 ); std::vector< int > in( 100 ); int * out_d = nullptr; int * in_d = nullptr; for( std::size_t i = 0...
2,798
// #define DEBUG_MODE 1 #include <stdio.h> #include <algorithm> #include <numeric> #include <cmath> #include <thrust/reduce.h> #include <thrust/device_ptr.h> #include <thrust/device_malloc_allocator.h> __global__ void move_nodes(int n_tot, int m_tot, int *d_col_idx, int *d_weights, int *d_prefix_sums, int *d_degrees...
2,799
#include <stdio.h> #include <sys/time.h> __global__ void square( int * d_in,int n){ int totalSum; if (threadIdx.x == 0) totalSum = 0; __syncthreads(); int localVal = d_in[threadIdx.x]; for(int i=0;i<n;i++) atomicAdd(&totalSum, 1); __syncthreads(); } int main(int argc, char ** argv) { con...
2,800
#include "includes.h" __global__ void stencilShared1(float *src, float *dst, int size) { int idx = blockIdx.x * blockDim.x + threadIdx.x; __shared__ float buffer[1024+21]; for(int i = threadIdx.x; i < 1024+21; i = i + 1024) { buffer[i] = src[idx+i]; } idx += 11; if (idx >= size) return; __syncthreads(); float out = 0;...