serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
23,601
#define IA 16807 #define IM 2147483647 #define AM (1.0/IM) #define IQ 127773 #define IR 2836 #define NTAB 32 #define NDIV (1+(IM-1)/NTAB) #define EPS 1.2e-7 #define RNMX (1.0-EPS) double rand(long *idum) { int j; long k; static long iy=0; static long iv[NTAB]; double temp; if (*idum <= 0 || !iy...
23,602
#include <iostream> using namespace std; const int N = 16; const int CORES = 16; __global__ void hello(char* s){ if ((s[blockIdx.x] >= 'a')&&(s[blockIdx.x] <= 'z')) { s[blockIdx.x] -= 32; } } int main(int argc, char const *argv[]) { char cpu_string[N] = "hello world!"; char* gpu_string; cudaMalloc((v...
23,603
#include<stdio.h> #include<math.h> #include<cuda.h> __global__ void matMul(int *d_a,int *d_b,int *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(row<M && col<K){ int sum=d_a[row*N]*d_b[col]; for(int k=1;k<N;k++){ sum+=d_a[row*N+...
23,604
#include "includes.h" __global__ void ExtQtyKernel (double *ExtLabel, double *Dens, double *Label, int nsec, int nrad) { int j = threadIdx.x + blockDim.x*blockIdx.x; int i = threadIdx.y + blockDim.y*blockIdx.y; if (i<nrad && j<nsec) ExtLabel[i*nsec + j] = Dens[i*nsec + j]*Label[i*nsec + j]; }
23,605
#include <cuda_runtime.h> #include <stdio.h> #include <stdlib.h> #include <math.h> #include <sys/time.h> #define blockSize 128 __global__ void reduce0(int *g_idata,int *g_odata){ extern __shared__ int sdata[]; //each thread loads one element from global to shared mem unsigned int tid = threadIdx.x; unsigned int i = b...
23,606
/* The MIT License (MIT) * * Copyright (c) 2013 Johannes Reinhardt <jreinhardt@ist-dein-freund.de> * * 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 restriction, including witho...
23,607
#include "includes.h" __global__ void calcConvolutionForwardPaddedInGPU( float *in, float *padded_in, int batch_size, int in_size_x, int in_size_y, int in_size_z, int padding) { int id = (blockIdx.x + blockIdx.y*gridDim.x) * blockDim.x + threadIdx.x; if( id < batch_size * in_size_x * in_size_y * in_size_z ){ int in_in...
23,608
#include "includes.h" __global__ void prova3() { //auto A = NQfrontier<32>(F_array, 5, Adj_array); //for (auto it : A) //Ouptput[threadIdx.x] = it.start; // printf("threadIdx.x %d \t %d\n", threadIdx.x, it.end); //printf("threadIdx.x %d \t %d\n", threadIdx.x, (*A.begin()).start); }
23,609
#include "includes.h" __device__ static float disp_absolute_residual(float Xd, float Yd, float Zd, float Xm, float Ym, float Zm, float nx, float ny, float nz, float T0, float T1, float T2, float R0, float R1, float R2, float fx, float b) { float r = -Xd * nx + Xm * nx - Yd * ny + Ym * ny - Zd * nz + Zm * nz + nx * T0 +...
23,610
#include <stdio.h> #define cudaErrorCheck(call) \ do { \ cudaError_t cuErr = call; \ if (cudaSuccess != cuErr) { \ prin...
23,611
//This micro-kernel currently does not use shared memory //It could be improved by adding this caching. //This micro-kernel currently uses a selection sort. //This is done for simplicity of testing and should be replaced // before using it for serious testing with a better sort. __device__ void Sort( void* param) { ...
23,612
__device__ inline double sq(double x) { return x*x;} __device__ double optimsquare_eps_2d_descent(double u[4], double xi[4], double epsilon, double w, int steps) { double no, nxi[4], r; r = 1./(1+epsilon/4.); u[0] -= xi[0]-xi[3]; for (int i=1;i<=3;i++) { u[i] -= xi[i]-xi[i-1]; } for (int it=0; it<ste...
23,613
#include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include <time.h> __global__ void additionGPU(float *a, float *b, float *r, int n); void additionCPU(float *a, float *b, float *r, int n); int main(int argc, char* argv[]) { if(argc < 2) { puts("Usage: matmul [N]"); return 0; } int N = atoi(argv[1...
23,614
#include "includes.h" __global__ void reduce_sum_kernel(const float *input, float *d_out, int size) { int tid = threadIdx.x; // Local thread index int myId = blockIdx.x*(blockDim.x*2) + threadIdx.x; // Global thread index extern __shared__ float tempsum[]; //shared memory...
23,615
#define EXPORT_KERNEL(k) extern "C" void* kern_##k = (void*)k // Super simple vector kernel extern "C" __global__ void add_vector(int* a, int* b, int* c) { int i = blockIdx.x * blockDim.x + threadIdx.x; c[i] = a[i] + b[i]; } EXPORT_KERNEL(add_vector);
23,616
#include "includes.h" #define N 24 __global__ void muestraIndice(float *a, float *b, float *c){ int global = blockIdx.x * blockDim.x + threadIdx.x; if(global < N){ a[global] = threadIdx.x; b[global] = blockIdx.x; c[global] = global; } }
23,617
#include "Tools.cuh" #include <math_functions.h> // operator of Vector3D __device__ __host__ inline Vector3D operator+(const Vector3D& param1, const Vector3D& param2){ Vector3D result; result.x = param1.x + param2.x; result.y = param1.y + param2.y; result.z = param1.z + param2.z; return result; } __device__ __h...
23,618
__device__ void imageconvolution(void *param) { float *input = (float *) param; int IW = (int)input[0]; //Image Width int MW = (int)input[1]; //MASK_WIDTH; float* image = input+2; float* mask = image + IW; float* imageout = image + MW + IW; int warp_size=32; int threadId = threadIdx.x % warp_size; float value =0; i...
23,619
#include "includes.h" __global__ void histogram_kernel(float* magnitude, float* phase, float* histograms, int input_width, int input_height, int cell_grid_width, int cell_grid_height, int magnitude_step, int phase_step, int histograms_step, int cell_width, int cell_height, int num_bins) { //TODO: make the buffer sizes ...
23,620
// Jin Pyo Jeon // Times // N Thread/Block seconds // 1 << 24 512 0.60 // 1 << 24 480 0.61 // 1 << 24 272 0.61 // 1 << 22 128 0.15 // 1 << 20 32 0.05 // 1 << 20 64 0.047 // 1 << 20 128 0.048 // 1 << 18 32 0.02 // 1 << 17 32 0.013 #include <cuda.h> #include <stdlib.h> #include <...
23,621
#include<stdio.h> #include<math.h> const int lena = 83; const int lenb = 1543; float a[ lena ], b[ lenb ], x[ lena ], xnew[ lena ], tau[ lenb ]; int De[ lena * lenb ]; int tDe[ lenb * lena ]; inline float sum(float* a, const int lena) { float res = *a; for(int i = 1; i < lena; ++i) { res += a[ i ]; } retu...
23,622
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <iostream> #include <fstream> #include <string> #include <vector> #include <algorithm> #include <time.h> #include <cmath> #include <limits.h> #define MAXHOPS 4 #define MAX_WAITING_TIME 420 #define BLOCK_LENGTH 512 #define EN...
23,623
#ifdef _WIN32 # define NOMINMAX #endif // includes, system #include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> #include <ctime> // includes, project // includes, kernels #include <cuda.h> #include <cuda_runtime.h> #define MAX_TILE_SIZE 1024 /////////////////////////////////////////////////...
23,624
#include <stdio.h> #include <cuda.h> #include <time.h> #define N 128 __global__ void kernel_add(int *d_a,int *d_b,int *d_c){ //int i = threadIdx.x; //int i = blockIdx.x; int i = blockIdx.x * blockDim.x + threadIdx.x; if(i < N) d_c[i] = d_a[i] + d_b[i]; } void addVector(int *h_a,int *h_b,int *h_c){ for(...
23,625
#include <iostream> #include <fstream> #include <bits/stdc++.h> using namespace std; //Graph class for CPU implementation // CPU connected components implementation with DFs //from https://www.geeksforgeeks.org/program-to-count-number-of-connected-components-in-an-undirected-graph/ class Graph { // No. of verti...
23,626
/** * block loading rho calculation. should be much faster * system('nvcc -ptx citydist_rho4.cu') * iA is multiple of CHUNK (16) */ #include <cuda_runtime.h> // #include "cublas_v2.h" #include <math.h> #define ABS(my_val) ((my_val) < 0) ? (-1*(my_val)) : (my_val) #define MIN(A,B) ((A)<(B)) ? (A) : (B) #define MAX(A...
23,627
#include "test_probe.cuh" ProbeConfig make_probe_config(unsigned n_channels, unsigned n_active, unsigned n_groups, double srate_hz) { // don't check that n_total >= n_active for test purposes if (n_groups > n_active) { th...
23,628
// // Created by goforbroke on 26.12.2020. // #include <iostream> #include <cstdlib> #include <cuda_profiler_api.h> __global__ void vector_add(float *out, float *a, float *b, int n) { size_t index = threadIdx.x; size_t stride = blockDim.x; for (int load = index; load < n; load += stride) { // fake additi...
23,629
#include<stdio.h> #include<stdlib.h> #include<time.h> #include<assert.h> #include<unistd.h> #define NUMELEMENT 1E6 void vecADD(float* h_A, float* h_B, float* h_C, int n) { for (int i = 0 ; i < n ; i++) h_C[i] = h_A[i] + h_B[i]; } __global__ void vecADDKernel(float* d_A, float* d_B, float* d_C, int n) { int i = t...
23,630
/*TODO: rewrite timeit.cu to something like this */ #include <string> #include <list> class Event { public: Event (std::string name): name(name) { cudaEventCreate( &(_start) ); cudaEventCreate( &(_stop) ); }; void start() { cudaEventRecord( _start, 0 ); }; void stop...
23,631
#include "includes.h" __device__ double2 subtract(double2 a, double2 b){ return {a.x-b.x, a.y-b.y}; } __global__ void subtract_test(double2 *a, double2 *b, double2 *c){ c[0] = subtract(a[0],b[0]); }
23,632
/* * Copyright (c) 2019 Opticks Team. All Rights Reserved. * * This file is part of Opticks * (see https://bitbucket.org/simoncblyth/opticks). * * 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 ...
23,633
__global__ void select(const double* ran, const double* total, const int* size, double** frac, double** xs, int* selection) { const unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x; double cutoff = total[idx] * ran[idx]; double accum = 0; const double* el_frac = frac[idx]; const...
23,634
#include <stdlib.h> #include <stdio.h> #include <cuda.h> // int pos = threadIdx.x + blockIdx.x * blockDim.x; #define BLOCKS 8 #define THREADS 32 __global__ void kernelVacio( void ) { if (threadIdx.x < 10) { printf("Data: %s Id Thread: %d Id block : %d Num threads block : %d\n", "helloWorld!", threa...
23,635
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdlib.h> #include <stdio.h> #include "cudaHelpers.cuh" void waitForKernel() { CUDA_CHECK_RETURN(cudaGetLastError()); CUDA_CHECK_RETURN(cudaDeviceSynchronize()); } void resetDevice() { CUDA_CHECK_RETURN(cudaDeviceReset()); } void setDevice(...
23,636
#include <cuda_runtime_api.h> #include <stdio.h> __global__ void Foo() { int tid_x = threadIdx.x + blockIdx.x * blockDim.x; int tid_y = threadIdx.y + blockIdx.y * blockDim.y; printf("Hello world, thread:(%d, %d) \n", tid_y, tid_x); } /// same code __global__ void Fuck(int width) { int tid = threadId...
23,637
#include<stdio.h> #include<math.h> #include<cuda.h> #define TWW 32 // Setting TileWidth /*----------Kernel Function------------*/ __global__ void matMul(double *d_a,double *d_b,double *d_c, int M, int N, int K){ int row = blockIdx.y * blockDim.y + threadIdx.y; int col= blockIdx.x * blockDim.x + threadIdx.x; __sh...
23,638
#define DIM 8192 #include<stdio.h> #include<stdlib.h> #include <chrono> //FUNZIONE PER STAMPARE UNA MATRICE void printMatrix(double *M) { int i, j; for (i = 0; i < DIM; i++) { for (j = 0; j < DIM; j++) { printf("%f ", M[i * DIM + j]); } printf("\n"); } } //FUNZIONE CHE RIEMPIE LA MATRICE DI NUMERI double ...
23,639
#include "includes.h" __global__ void calcConvolutionForwardGPU( float *out, float *padded_in, float *filters, int padded_in_size_x, int padded_in_size_y, int padded_in_size_z, int batch_size, int out_size_x, int out_size_y, int out_size_z, int kernel_size, int stride, int filter_size) { int id = (blockIdx.x + blockIdx...
23,640
#include <stdio.h> #define BLOCKDIM 512 #define RSIZE 10 #define JFACTOR 1 __device__ double NonOrtho_dist(double a0, double a1, double a2, double b0, double b1, double b2, double *ucell); //---------------------------------------------------------------------------------------------------------------------...
23,641
//// gol.cu #include <stdlib.h> #include <iostream> #include <stdio.h> #include <assert.h> // Game of Life rules // global memory only typedef bool GolCell; inline GolCell GetNeighbourCell (GolCell *input, int mapCellIdx, int mapWidth, int x_off, int y_off) { return input[mapCellIdx + (mapWidth * y_off) + x_off];...
23,642
#include "includes.h" /// /// Copyright (c) 2018, Intel Corporation /// /// Redistribution and use in source and binary forms, with or without /// modification, are permitted provided that the following conditions /// are met: /// /// * Redistributions of source code must retain the above copyright /// notice, th...
23,643
#include <stdio.h> #include <stdlib.h> #include <time.h> /* 配列の形 node 0:state 1:height 2:out_root_id 3:in_root_id 4:source,sinkにつながっているかのflg edge 0:flow 1:reverse_id 2:in_node_id 3:out_node_id 4:in_link_id 5:out_link_id 6:id */ #define gpuErrchk(ans) { gpuAssert((an...
23,644
#include <iostream> #include <math.h> // Kernel function to color the buffer according to the gradient __global__ void color(float *buffer) { int x = threadIdx.x; int y = blockIdx.x; int nx = blockDim.x; int ny = gridDim.x; float r = (float) x / nx; float g = (float) y / ny; float b = 0.2; ...
23,645
#include "includes.h" __global__ void add(int *a,int *b,int *c) { int tid = threadIdx.x; if(tid < N) { c[tid]=a[tid]+b[tid]; } }
23,646
#include "CudaComputing.cuh" #include "cuda_runtime.h" #include "device_launch_parameters.h" cudaError_t addWithCuda(int *c, const int *a, const int *b, size_t size); __global__ void addKernel(int *c, const int *a, const int *b) { int i = threadIdx.x; c[i] = a[i] + b[i]; } int vvmain(int* c) { const in...
23,647
#include <iostream> #include <cuComplex.h> #include <thrust/transform.h> #include <thrust/sequence.h> #include <thrust/fill.h> #include <thrust/replace.h> #include <thrust/functional.h> #include <thrust/device_vector.h> #include <thrust/system_error.h> #include <math.h> struct zaxpy_functor { const cuDoubleComplex x...
23,648
#include <iostream> using std::cout; using std::endl; void printDeviceInfo(cudaDeviceProp prop, int idx){ cout << "[" << idx << "]\n"; cout << " Name: " << prop.name << endl; cout << " Major: " << prop.major << endl; cout << " Minor: " << prop.major << endl; cout << " Total Global Memory: " << prop.totalGlob...
23,649
#include <stdio.h> //#include <cuda.h> //#include "cuda_runtime_api.h" //#include <stdint.h> //#include <stdlib.h> //This is the working matrix multiplication code - very basic /**** Done: - printing of matrix in a more pleasant manner using printMatrix function - command line arguments - opens matrix files and reads...
23,650
#include "cuda.h" #include "stdio.h" #include "stdlib.h" #define LBLK 8 __device__ int get_index(int N, int C, int H, int W, int a, int b, int c, int d) { return a * C * H * W + b * W * H + c * W + d; } __device__ int RM(int i, int j, int N) { return i * N + j; } __global__ void conv_kernel(float *weight, fl...
23,651
#include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <cuda_runtime.h> #define NUM 100 __constant__ int constant_f; __constant__ int constant_g; __global__ void gpuAtomicAdd(float* d_a){ int threadId = blockDim.x*blockIdx.x + threadIdx.x; extern __shared__ float sh_arr[]; //...
23,652
#include "includes.h" __global__ void add(int *a, int *b, int *c) { int tid = threadIdx.x + blockIdx.x * blockDim.x; while(tid < N) { c[tid] = a[tid] + b[tid]; tid += blockDim.x * gridDim.x; } }
23,653
#include "includes.h" __global__ void __word2vecBwd(int nrows, int ncols, int *WA, int *WB, float *A, float *B, float *C, float lrate) {}
23,654
#include <error.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <cuda_runtime.h> #define DEVICE_NUMBER (0) typedef struct { int nofThreads; int nofBlocks; int32_t nof_repetitions; int data_size; int buffer_length; unsigned int *targ...
23,655
#include <unistd.h> #include <stdio.h> #include "cuda.h" #include <sys/time.h> #define threshold 1e-2 #define n (4096) #define m (3) void init(void); void ref(void); #define TILE_SIZE 4 #define KS_DIV_2 (KERNEL_SIZE >> 1) #define KERNEL_SIZE 3 __constant__ double Mc[KERNEL_SIZE*KERNEL_SIZE]; void compare(int N, double ...
23,656
//gpu_bench.cu #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <sys/time.h> #define CHECK_ERR(x) \ if (x != cudaSuccess) { \ fprintf(stderr,"%s in %s at line %d\n", \ cudaGetErrorString(err),__FILE__,__LINE__);...
23,657
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> #include <unistd.h> #include <sys/time.h> #define WIDTH 1024 #define HEIGHT 768 #define CORE_COUNT 128 static int colors[] = { 0xff0000, // f 0xee3300, // e 0xcc5500, // d 0xaa5500, // c 0xaa3300, // b 0x666600, // a 0x...
23,658
#include "includes.h" __global__ void addKernel(int *c, const int *a, const int *b) { int i = threadIdx.x; c[i] = a[i] + b[i]; for(long i=0;i<1024*500;i++){ c[i] = a[i]*10 + b[i] * 5; } //printf("addKernel::threadIdx: %d, %d, %d\n", threadIdx.x, threadIdx.y, threadIdx.z); }
23,659
#include <stdlib.h> #include <stdio.h> int main(){ int *ptr = 0; cudaError_t error = cudaMalloc((void**)&ptr, UINT_MAX); if(error != cudaSuccess){ printf("CUDA error: %s\n", cudaGetErrorString(error)); exit(-1); } return 0; }
23,660
namespace mynamespace { namespace subnamespace { class Foo { public: int a; Foo() { } ~Foo() { } void somefunc() { } }; } class Bar : public subnamespace::Foo { public: Foo foo; ...
23,661
#include<stdio.h> #include<stdlib.h> #include<cuda.h> __global__ void oddEven(int *d,int I, int n) { int id=threadIdx.x; if(I==0 &&((id*2+1)<n)) { if(d[id*2] > d[id*2+1]) { int temp = d[id*2]; d[id*2] = d[id*2+1]; d[id*2+1] = temp; } } ...
23,662
/* reduce-integer.cu */ #include <stdio.h> #include <stdlib.h> #include <math.h> #include <sys/time.h> #include <cuda_runtime.h> /* * Check kernel performance using the following commands * * nvcc reduce-integer.cu -o bin/reduce-integer * * su * nvprof --metrics inst_per_warp bin/reduce-integer * nvprof --met...
23,663
#include<stdio.h> #include<stdlib.h> __global__ void srt(int* a, int n){ int idx=threadIdx.x; for(int i=0; i<n-1; i++){ if(i%2==idx%2 and idx+1<n) { if(a[idx]>a[idx+1]){ int t=a[idx] ; a[idx]=a[idx+1] ; a[idx+1]=t ; } } } } int main() { int n; scanf("%d",&n); int *a_h; a_h=(int*)malloc(n*sizeo...
23,664
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <cuda.h> #include <cuda_runtime_api.h> #include <stdio.h> #include <time.h> #include <sstream> #include <iostream> #ifndef __CUDACC_RTC__ #define __CUDACC_RTC__ #endif #include <device_functions.h> using namespace std; #define imin(a, b) (a<b...
23,665
/* Matrix addition with to large matrices for the device memory, without utilizng streams. */ #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <stdint.h> // Grid size #define B 100 // Block size #define T 512 // Matrix dimension #define C 51200L // Macro for checking errors in CUDA API calls #de...
23,666
#include "includes.h" __global__ void ComputeLaplacianInPlace(float* d, int n) { // Column to sum auto x = blockIdx.x * blockDim.x + threadIdx.x; if(x < n) { auto dCol = &d[x * n]; for(auto i = 0; i < n; ++i) { if(i != x) { dCol[x] += dCol[i]; dCol[i] = -dCol[i]; } } } }
23,667
#include "includes.h" __global__ void FloatMul(float *A, float *B, float *C) { unsigned int i = blockIdx.x * gridDim.y * gridDim.z * blockDim.x + blockIdx.y * gridDim.z * blockDim.x + blockIdx.z * blockDim.x + threadIdx.x; C[i] = A[i] * B[i]; }
23,668
/*** fir.gpu.cu**/ #include <stdio.h> /** Tool function*/ void random_ints(int* a, int N){ int i; for(i = 0; i < N; ++i) a[i] = (int)(rand() / (RAND_MAX + 1.0) * 10.0); } /** CUDA parameters */ #define BLOCK_SIZE 512 // Define fir coefficients in the texture memory #define COEF_NBR 5 __constant__ int C[]={1, -2...
23,669
#include "includes.h" __global__ void swap_middle_row(float* data, const int num_threads, const int nx, const int ny, const int xodd, const int yodd, const int offset) { const uint x=threadIdx.x; const uint y=blockIdx.x; const uint c = x+y*num_threads+offset; int r = ny/2; int idx1 = r*nx + c; int idx2 = r*nx + c + nx...
23,670
#include <stdio.h> #include <stdlib.h> #include <cuda.h> __global__ void cube(float * d_out, float * d_in){ // Todo: Fill in this function int id = threadIdx.x; float num = d_in[id]; d_out[id] = num*num*num; } int main(int argc, char ** argv) { // NOTE: h is for host and d is for device // This is the general...
23,671
#include <stdlib.h> #include <stdio.h> #define MY_CUDA_CHECK( call) { \ cudaError err = call; \ if( cudaSuccess != err) { \ fprintf(stderr, "Cuda error in file '%s' in li...
23,672
#include <stdio.h> #include "cuda.h" #define max(x,y) ((x) > (y)? (x) : (y)) #define min(x,y) ((x) < (y)? (x) : (y)) #define ceil(a,b) ((a) % (b) == 0 ? (a) / (b) : ((a) / (b)) + 1) void check_error (const char* message) { cudaError_t error = cudaGetLastError (); if (error != cudaSuccess) { printf ("CUDA error :...
23,673
#include <stdio.h> #include <stdlib.h> #include <fstream> #include <chrono> #include <cuda_runtime.h> #include <iostream> #include <vector> #define BlockSize 32 const int INF = 1000000000; void input(char *inFileName); void output(char *outFileName); void block_FW(int B,char*); int ceil(int a, int b); void cal(char*...
23,674
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> #include <cuda.h> #include <cuda_runtime.h> #include <cuda.h> #include <device_launch_parameters.h> #define LIST_SIZE 10000 extern "C" __device__ unsigned long long icmpValue1List[LIST_SIZE]; extern "C" __device__ unsigned long long icmpValu...
23,675
#include "includes.h" __global__ void MatrixMulKernel(float *d_M, float *d_N, float *d_P,int width){ __shared__ float Mds[TILE_WIDTH][TILE_WIDTH]; __shared__ float Nds[TILE_WIDTH][TILE_WIDTH]; int bx = blockIdx.x; int by = blockIdx.y; int tx = threadIdx.x; int ty = threadIdx.y; int row = by * TILE_WIDTH + ty; int col...
23,676
// ####################################################### // // Exercício de multiplicação de matrizes em CUDA // Disciplina: OPRP001 - Programação Paralela // Prof.: Mauricio Pillon // Dupla: Beatriz e Geremias // // ####################################################### #include <cuda.h> #include <stdio.h> #include...
23,677
#include "includes.h" __global__ void LinearValuesKernel(const float min, const float max, float* output, const int size, const int shift) { int id = blockDim.x * blockIdx.y * gridDim.x + blockDim.x * blockIdx.x + threadIdx.x; __shared__ float delta; if (threadIdx.x == 0) delta = (max-min)/fmaxf((size-1), 1); __synct...
23,678
#include<stdio.h> #include<cuda.h> #include<time.h> __global__ void hello() { printf("GPU:: Hello world!!\n"); } int main() { hello<<<1,10>>>(); cudaDeviceSynchronize(); return 0; }
23,679
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> #include <cstring> #include <time.h> __global__ void calculate_unique_3d_idx(int * input, int size) { int tid = (threadIdx.z * blockDim.y * blockDim.x) + (threadIdx.y * blockDim.x) + threadIdx.x; int block_i...
23,680
/*******This is for the test of array-of-struct-of-fixed-array structure******/ // #include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> #define REGIONS 20 #define YEARS 5 __inline __host__ void gpuAssert(cudaError_t code, char *file, int line, bool...
23,681
#include "includes.h" __global__ void updateGradientsKernel(float4 *D, float4 *TD, unsigned int nVertices) { int vidx = 4*(blockIdx.x * blockDim.x) + threadIdx.x; int idx; for (idx=0; idx<4*BLOCK_SIZE_AVGG; idx+=BLOCK_SIZE_AVGG) { D[vidx+idx] = TD[vidx+idx]; } }
23,682
#include<iostream> #include <cuda_runtime.h> #include<cuda.h> #include "device_launch_parameters.h" using namespace std; #define s 96 __global__ void square(int *a, int *b) { int i = threadIdx.x; if(i<s) b[i] = a[i] * a[i] * a[i]; } int main() { int *a,*b, i; a = (int *)malloc(s * sizeof(int)); b = (int...
23,683
#include "includes.h" __global__ void transposeNaive(float *odata, const float *idata,int idata_rows,int idata_cols) { int x = blockIdx.x * TILE_SIZE + threadIdx.x; int y = blockIdx.y * TILE_SIZE + threadIdx.y; //int width = gridDim.x * TILE_SIZE; if(y<idata_rows && x<idata_cols) odata[x*idata_rows+y] = idata[y*idata...
23,684
#include <stdio.h> #include <stdlib.h> void cudaHandleError( cudaError_t err,const char *file,int line ) { if (err != cudaSuccess) { printf( "CUDA Error\n%s in %s at line %d\n", cudaGetErrorString( err ),file, line ); exit( EXIT_FAILURE ); } }
23,685
#include <stdio.h> __global__ void my_pooling(float* const out, float const* const data, size_t const H, size_t const W, size_t const C, size_t const N, size_t const stride) { //channel const size_t d = blockIdx.x; //image number const size_t n = blockIdx.y; // spatial dimensions of the output array const siz...
23,686
/* lenet_old.cu */ template <int InputSize, int InputChannels, int OutputSize, int OutputChannels, int KernelSize> __global__ void convolution_gpu_shared_memory( float* devInput, float* devOutput, float* devWeight, float* devBias) { int ocol = threadIdx.x + blockIdx.x * blockDim.x; ...
23,687
#include <iostream> class queue { private: /* data */ public: queue(/* args */); ~queue(); }; queue::queue(/* args */) { } queue::~queue() { }
23,688
#include "matrix.cuh" #include "vector.cuh" #include <iostream> #include <cstdlib> #include <cmath> #include <chrono> // #include <ratio> #include <functional> using namespace gpu_thrust; class TimeRecord { private: cudaEvent_t start; cudaEvent_t stop; float ms; public: TimeRecord() { cu...
23,689
// #include <stdio.h> // #include <iostream> // #include <fstream> // #include <time.h> // #include <random> // #include "reduction_fcm.cuh" // using namespace std; // __host__ void init_membership(float *i_membership, int i_rows, int i_cols, int i_num_clutsers) { // // cout << i_cols << endl; // // cout << i...
23,690
#define BLOCK_SIZE 16 __global__ void MatMulKernel(float* A, float* B, float* C, int width) { __shared__ float Ads[BLOCK_SIZE][BLOCK_SIZE]; __shared__ float Bds[BLOCK_SIZE][BLOCK_SIZE]; int bx = blockIdx.x; int by = blockIdx.y; int tx = threadIdx.x; int ty = threadIdx.y; int row = by * BLOCK_SIZE + ty; ...
23,691
#include<stdio.h> __global__ void kernel(int* array) { int index = blockIdx.x * blockDim.x + threadIdx.x; array[index] = index; } int main() { int num_element = 1024; int* host_array = (int*)malloc( num_element * sizeof(int) ); int* device_array; cudaMalloc( (void**)&device_array , num_element * sizeof(int) ...
23,692
#include "includes.h" __global__ void gpu_grayscale(int width, int height, float *image, float *image_out) { //////////////// // TO-DO #4.2 ///////////////////////////////////////////// // Implement the GPU version of the grayscale conversion // /////////////////////////////////////////////////////////// }
23,693
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <thrust/generate.h> #include <thrust/sort.h> #include <thrust/copy.h> #include <algorithm> #include <cstdlib> int main2(void) { //@@ generate random data se...
23,694
#include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <cuda_runtime.h> #include <thrust/sort.h> __global__ void getIterationCounts(double x0, double y0, double xD, double yD, int nCols, int nRows, int limitIter, int* iterations) { int x = threadIdx.x + blockIdx.x * blockDim.x; int y = threadIdx.y + block...
23,695
#include "includes.h" __global__ void Crop2DKernel(float *input, float *output, int inputWidth, int inputHeight, int outputWidth, int size, int leftMargin, int topMargin, float fillValue) { int id = blockDim.x * blockIdx.y * gridDim.x + blockDim.x * blockIdx.x + threadIdx.x; if (id < size) { int inputX = id % outputWi...
23,696
#include <stdio.h> #include <stdlib.h> #define DEBUG __global__ void add(const int* x, const int* y, int* z, const int n) { int index = threadIdx.x + blockIdx.x * blockDim.x; if(index < n) z[index] = x[index] + y[index]; } void checkCudaError(const char* filename, const int linenum) { cudaThreadSynchronize...
23,697
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include "device_functions.h" #include <stdio.h> #include <stdlib.h> #include <time.h> #define W 25 #define H 25 __global__ void kernel(int* a, size_t pitch) { int x = threadIdx.x; int y = threadIdx.y; int *row_a = (int*)((char*)a + y * pitch); // ...
23,698
#include "cuda.h" /** * ref_dev B,N,D * query_dev B,M,D * ind_dev B,N,K * out_feat_dev B,N,K,D */ __global__ void gather_nn_kernel( float* out_feat_dev, float* ref_dev, float* query_dev, long* ind_dev, int64_t B, int64_t N, int64_t k, int64_t Dim, int64_t M ) { unsigned int index = ...
23,699
#include "includes.h" __global__ void _bcnn_dropout_layer_kernel(float *input, int size, float *rand, float prob, float scale) { int id = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x; if (id < size) { input[id] = (rand[id] < prob) ? 0 : input[id] * scale; } }
23,700
#include "includes.h" /** * Project TACO: Parallel ACO algorithm for TSP * 15-418 Parallel Algorithms - Final Project * Ivan Wang, Carl Lin */ #define MAX_THREADS 128 __device__ static inline int toIndex(int i, int j) { return i * MAX_CITIES + j; } __global__ void updateTrailsAtomic(float *phero, int *paths, fl...