serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
5,601
#include "includes.h" __global__ void doGPUWork(int numData, int *data) { if (threadIdx.x < numData) { data[threadIdx.x] = threadIdx.x; } }
5,602
#include <stdio.h> // CUDA to assign a value to each element of the array of integers A[256] using 256 threads. // Each A[i] is assigned with the value of 2*i, for i = 0 to 255. #define T 256 // As Threads #define ArraySize 1314 // #define n 256 __global__ void vecMultiply(int *A) { int i; int threadID = threadId...
5,603
/************** * HydroCuda model * * HBV hydrological model * using cuda ***************/ #include <math.h> __global__ void hbv_dynamic( float *q , float *etr , float *qin , float *qlz , float *q...
5,604
/*! \file * \brief Custom GPU kernels used in the SAP algorithm * */ #include <stdio.h> #include <stdlib.h> #include <cmath> #include "kernels.cuh" using namespace std; __global__ void readVec(float * d_vector){ /** Reads some number (specified by the number of threads at execution) of entries from an array of f...
5,605
#include <cuda.h> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> #include <math.h> #define TILE_WIDTH 16 // Compute C = A * B __global__ void matrixMultiply(float * A, float * B, float * C, int numARows, int numAColumns, int numBRows, int numBColumns, int numCRows, int numCColumns)...
5,606
#include <stdio.h> #include <stdint.h> #include <cuda.h> #define CHECK(call) \ { \ const cudaError_t error = call; \ if (error != cu...
5,607
/* ================================================================== Programmer: Yicheng Tu (ytu@cse.usf.edu) The basic SDH algorithm implementation for 3D data To compile: nvcc SDH.c -o SDH in the rc machines ================================================================== Steven Faulkner U9616-1844 ...
5,608
/* * Example from "CUDA by Example" * https://developer.download.nvidia.com/books/cuda-by-example/cuda-by-example-sample.pdf */ #include <stdio.h> #define HANDLE_ERROR( err ) (HandleError( err, __FILE__, __LINE__ )) static void HandleError(cudaError_t err, const char *file, int line) { if (err != cudaSuccess)...
5,609
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> #include <cuda.h> #include <time.h> #include <sys/types.h> #include <sys/time.h> #define VERBOSE 1 __global__ void checkMatchOnDevice(char *fileBuffer, char* searchString, int* matchArray, int numBytes,size_t searchSize,int* matchStartArray,...
5,610
#include <iostream> #include <stdio.h> #include <vector> #define MAX_THREADS 256 #define SIZE 131072 #define __START__ cudaEventCreate(&start); cudaEventCreate(&stop); cudaEventRecord(start, 0); #define __STOP__(_V) cudaEventRecord(stop, 0); cudaEventSynchronize(stop); cudaEventElapsedTime(&time, start, stop); _V.pus...
5,611
#include <iostream> #include <cstring> #include <fstream> #include <algorithm> #include <cmath> #include <ctime> #include <cuda.h> #include <cuda_runtime.h> #include <thrust/device_vector.h> #include <thrust/extrema.h> #define EPS 1e-3 //#define WRITE_TO_FILE #define NX 32 #define NY 32 #define PHI_CPU(x,y) sin(M_PI*x)...
5,612
// Simulator a lottery system // // Author: Yili Zou // // For the GPU Programming class, NDSU Spring '14 #include <stdio.h> #include <stdlib.h> #include <time.h> #include <curand_kernel.h> #define FILE_CREATE_ERROR -1 #define Number_Max 9 #define Number_Min 0 #define THREADS_PER_BLOCK 10 // Setting the grid up #...
5,613
// ********************************************************************************************************** // PURPOSE : Index calculation for array to access data from kernel. * // LANGUAGE : CUDA C / CUDA C++ * // ASSUMPTIONS : This code is part of CUDA fundamentals section. * ...
5,614
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <cstdlib> //#include <chrono> #include <time.h> #include <cmath> //#include <random> using namespace std; #define BLOCK_SIZE 16 //mt19937_64 rd; typedef struct { int height, width; float *elements; }Matrix; __global__ v...
5,615
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <cuda.h> #include <math.h> #include <time.h> #include <curand_kernel.h> #include <sys/time.h> #define TRUE 1 unsigned int EMPTY = UINT_MAX; char str[200]; int i, j, k, e, p, na; int nb; // numero de blocos a serem usados no kernel FILE *fp; int line...
5,616
#include <algorithm> #include <cmath> #include <cstdio> #include <fstream> #include <iostream> #include <sstream> #include <string> #include <vector> #include <sys/time.h> #include <chrono> #include <dirent.h> using namespace std::chrono; using namespace std; vector<int> G_timestamps; int getCurrentTime () { return...
5,617
// // Simple and fast atof (ascii to float) function. // // - Executes about 5x faster than standard MSCRT library atof(). // - An attractive alternative if the number of calls is in the millions. // - Assumes input is a proper integer, fraction, or scientific format. // - Matches library atof() to 15 digits (except at...
5,618
#include <assert.h> #include <curand_kernel.h> #include <cuda_runtime.h> #include <fstream> #include <iostream> #include <math.h> #include <sstream> #include <stdio.h> #include <stdlib.h> #include <string.h> // ACO constants #define ANTS 1024 #define ALPHA 2 #define BETA 10 #define RHO 0.5 #define Q 50 #define MAX_ITE...
5,619
#include "includes.h" __global__ void matrixMulCUDA3(float *C, float *B, float *A, int n) { int row = blockIdx.y * blockDim.y + threadIdx.y; int col = blockIdx.x * blockDim.x+ threadIdx.x; float sum = 0.0f; if (row >= n || col >= n) { return; } for (int k = 0; k < n; k++) { sum += A[row * n + k] * B[k * n + col]; }...
5,620
#include <stdio.h> #include <stdlib.h> #include <iostream> #include <fstream> #include <string> #include <algorithm> #include <bits/stdc++.h> #include <string.h> #include <iomanip> using namespace std; /* module purge module load gcc/4.9.0 module load cmake/3.9.1 module load cuda qsub -I -q coc-ice -l nodes=1:ppn=2:gpu...
5,621
/* Single-Precision AX+Y in Cuda ******************************************************************* * Description: * Populate two vectors each of size N. In the first vector, * multiply each element by some constant scalar and then sum * this product with with the elment at same index in other * vector. T...
5,622
#include <iostream> #include <vector> using namespace std; // Create a kernel to estimate pi __global__ void count_samples_in_circles(float* d_randNumsX, float* d_randNumsY, int* d_countInBlocks, int num_blocks, int nsamples) { __shared__ int shared_blocks[500]; int index = blockIdx.x * blockDim.x + threadIdx...
5,623
#include <complex> #include <cstdio> #include <cufft.h> #include <math.h> #include <string.h> using namespace std; __global__ void getPhi(double *d_phi_k, int Nx, int Ny, int Nz_half, double L){ // Change made inside d_phi_k int N = Nx * Ny * Nz_half; int index = blockDim.x * blockIdx.x + threadIdx.x...
5,624
/** * 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 relate...
5,625
#include <cuda.h> inline __global__ void KernelTest(int * a, int * b, int * res, int size) { // Calcul de l'indice du tableau unsigned int x = blockIdx.x*blockDim.x + threadIdx.x; res[x] = a[x] + b[x]; } extern "C" void runKernel(int * a, int * b, int * res, int size) { dim3 dimBlock(64, 1, 1); dim3 dimGr...
5,626
#include <math.h> // function add // m1, m2 are vectors, matrices or tensors of the same size // 1 block, 1 dimensional block size __global__ void add(float* m1, float* m2, float* m3, int n){ for(int index=threadIdx.x;index<n;index+=blockDim.x) m3[index]=m1[index]+m2[index]; } // function minus // m1, m2 ...
5,627
// This is a generated file, do not edit it! #pragma once #include <stdint.h> typedef struct Split { float Entropy; uint8_t SplitType; uint8_t Axis; int32_t Column; float SplitAttribute; uint32_t SplitCategories; } Split;
5,628
#include <cuda_runtime.h> #include <device_launch_parameters.h> #include <algorithm> #include <cassert> #include <cstdio> #include <exception> #include <iostream> #include <sstream> #include <string> #define CE(err) \ { ...
5,629
#include <iostream> #include <cuda.h> #include <time.h> #include <math.h> #define row 100 #define col 100 void handle_error(cudaError_t error) { if (error != cudaSuccess) { std::cout << "Error in cuda. Waiting..."; exit(0); } } int get_rand_in_range() { return rand()%256; } __global__ void convert(float *in...
5,630
#include <stdio.h> __global__ void update(float *ad, float *bd, int ny,int nx) { int x, y; x = blockIdx.x; y = threadIdx.x; if(x > 0 && y > 0 && x < nx-1 && y < ny-1) bd[x*ny+y] = ad[x*ny+y] + (ad[(x+1)*ny+y] + ad[(x-1)*ny+y] - 2 * ad[x*ny+y])/10 + (ad[x*ny+(y+1)] + ad[x*ny+(y-1)] - 2 * ad[x*ny+y...
5,631
#include<iostream> #include<stdio.h> #include<time.h> #include<stdlib.h> using namespace std; //max no. of blocks 65535 __global__ void square(long long *d_in,long long *d_out,long long d_n,long long *d_get_blockDim) { long long idx=1024*blockIdx.x+threadIdx.x; if(idx<d_n) { int temp=d_in[idx]; d_out[idx]=temp*...
5,632
#include "c-product.cuh" #include <stdio.h> #include <stdlib.h> __global__ void product_iterator(unsigned char* set[], int size[], int count, long int all) { int *index; index = (int *)malloc(count * sizeof(int)); int *delta; delta = (int *)malloc(count * sizeof(int)); // Block and thread params ...
5,633
#include <stdlib.h> #include <stdio.h> __global__ void square(float *d_out, float *d_in) { int i = threadIdx.x; float f = d_in[i]; d_out[i] = f*f; } int main(int argc, char *argv[]) { const int ARRAY_COUNT = 64; float h_in[ARRAY_COUNT], h_out[ARRAY_COUNT]; for(int i=0 ; i<ARRAY_COUNT ; ++i) {...
5,634
#include <stdlib.h> #include "mesh.cuh" #include "constants.cuh" //------------------------------------------PROTOTIPES---------------------------------------------- void define_freedofs(int *fixeddofs, int *alldofs, int *freedofs, struct mesh *mesh); //-----------------------------------------BODIES---------------...
5,635
#include "includes.h" __global__ void mapAdjacencyToBlockKernel(int size, int *adjIndexes, int *adjacency, int *adjacencyBlockLabel, int *blockMappedAdjacency, int *fineAggregate) { int idx = blockIdx.x * blockDim.x + threadIdx.x; if (idx < size) { int begin = adjIndexes[idx]; int end = adjIndexes[idx + 1]; int thisBlo...
5,636
#include<stdlib.h> #include<stdio.h> #include <cuda_runtime.h> #define TILE_WIDTH 16 #define seed 13 __global__ void matrixMul(float *dev_A, float *dev_B, float *dev_C, int matrixWitdh) { __shared__ float A_tile[TILE_WIDTH][TILE_WIDTH]; __shared__ float B_tile[TILE_WIDTH][TILE_WIDTH]; int bx = blockIdx.x; int by = b...
5,637
//#include <cuda_runtime.h> #include <stdio.h> __global__ void checkIndex(void) { printf("threadIdx: (%d, %d, %d); blockIdx: (%d, %d, %d); blockDim: (%d, %d, %d); gridDim: (%d, %d, %d)", threadIdx.x, threadIdx.y, threadIdx.z, blockIdx.x, blockIdx.y, blockIdx.z, blockDim.x, ...
5,638
#include "includes.h" __global__ void sum(float *a, float *b, float *c) { int index = blockDim.x * blockIdx.x + threadIdx.x; if (index < N) { c[index] = a[index] + b[index]; } }
5,639
// Exhibits a bank conflict. // Gklee and Gkleep both detect this. #include <cstdio> #define N 32 __global__ void bc(char* in, char* out) { __shared__ int smem[512]; int tid = threadIdx.x; smem[tid*2]=in[tid]; __syncthreads(); smem[tid*4]=in[tid]; __syncthreads(); smem[tid*8]=in[tid]; __syncthrea...
5,640
/* HPC ASSIGNMENT 1 : QUESTION 3 Name : Arvind Sai K , Derik Clive RollNo: 15CO207 , 15CO213 */ #include <stdio.h> #include<math.h> #include <time.h> #include <stdlib.h> #define HANDLE_ERROR( err ) ( HandleError( err, __FILE__, __LINE__ ) ) static void HandleError( cudaError_t err, const char *file, int line ...
5,641
//#include "kernel.cuh" #include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> #include "cuda_runtime.h" #include "device_launch_parameters.h" #define N 5000 int main() { system("pause"); return 0; }
5,642
#define IDX3(X, n1, n2, n3, i1, i2, i3) (X[(i1)*((n2)*(n3)) + (i2)*(n3) + (i3)]) template<class T> __device__ void im2col_ker(const T *im, T *patches, int im_ni, int im_nj, int nimgs, int p_ni, int p_nj, int npatches) { int total_threads = gridDim.x * blockDim.x; ...
5,643
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <iostream> #include <vector> #include <time.h> #define MAX_SHIFT 2 #define BLOCK_SIZE 128 #define SHIFT 3 using namespace std; float* generateSimpleCyclicMatrix(int n, int m) { srand(time(0)); float* a = new float[n * m]; v...
5,644
// To compile - gcc -o 3dFDTD FDTD3D.c -lm #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <sys/time.h> #include <cuda_runtime.h> // This was taken from stackoverflow.com/questions/14038589/what-is-the-canonical-way-to-check-for-errors-using-the-cuda-runtime-api #define CHECK_ERR...
5,645
#include <stdio.h> #include <cuda.h> #include <stdlib.h> // This code assumes that your device support block size of 1024 #define MAX_RANGE 9999 #define funcCheck(stmt) do { \ cudaError_t err = stmt; \ if ...
5,646
/*************************************************************************** ************************************************************************** Spherical Harmonic Transform Kit 2.7 Copyright 1997-2003 Sean Moore, Dennis Healy, Dan Rockmore, Peter Kostelec Copyright 2004...
5,647
#include "FloatVector.cuh" FloatVector::FloatVector(long height, FLOAT_VEC_TYPE* data) { this->height = height; this->data = data; } long FloatVector::getHeight() { return height; } FLOAT_VEC_TYPE * FloatVector::getData() { return data; }
5,648
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <iostream> #include <stdio.h> #include <ctime> typedef unsigned char uchar; #define EROSION_SIZE 5 const int EROSION_MATRIX[EROSION_SIZE * EROSION_SIZE] = { 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, ...
5,649
#include <stdio.h> #define WIDTH_ARRAY 10 #define HEIGHT_ARRAY 10 __global__ void shareArray (int *modArray, int *sum) { int i, j, n, index, countVal; __shared__ int sumColumn[WIDTH_ARRAY], tmpModArray[WIDTH_ARRAY][HEIGHT_ARRAY]; i = threadIdx.x; j = threadIdx.y; index = i +...
5,650
// Note that in this model we do not check // the error codes and status of kernel call. /* In this exercise we will write a simple cuda program that sets the value of an array: A[i] = i. Take a look at the file set.cu, that includes a skeleton of the code. Here we will complete the code by completing these steps (a...
5,651
#include <stdio.h> #include <stdint.h> const int TILE_DIM = 32; const int BLOCK_ROWS = 8; #define BLOCK_SIZE 8 // Matrices are stored in row-major order: // M(row, col) = *(M.elements + row * M.width + col) typedef struct { int width; int height; uint64_t* elements; } Matrix; // Forward declaration of...
5,652
// Liao 11/30/2011 // based on liao6@tux322:/usr/local/cuda/include/cuda_runtime_api.h #include <stdio.h> int main() { cudaDeviceProp prop; int count; cudaGetDeviceCount (&count); for (int i =0; i< count; i++) { cudaGetDeviceProperties (&prop, i); printf ("Name: %s\n", prop.name); printf ("Glo...
5,653
#include "includes.h" __global__ void sync_streams(){}
5,654
#include "includes.h" __global__ void kern_PropogateUp(float* working, int span, int imageSize) { int idx = CUDASTDOFFSET; float inputValue1 = working[idx]; float inputValue2 = working[idx+span]; float outputVal = (inputValue1 > inputValue2) ? inputValue1: inputValue2; if(idx+span < imageSize) { working[idx] = outputVa...
5,655
#include <cuda_runtime.h> __device__ void positive(float x, int &counter) { if (x > 0.) { atomicAdd(&counter, 1); } } __global__ void kernel(float *data, int *counter, unsigned int size) { __shared__ int shared; if (threadIdx.x == 0) { shared = 0; } __syncthreads(); auto first_thread = thr...
5,656
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> #include <math.h> __device__ int getTid() { int bid = blockIdx.y * gridDim.x + blockIdx.x; int tid = threadIdx.y * blockDim.x + threadIdx.x; int tPB = blockDim.x * blockDim.y ; int fin = bid*tPB+tid; } __global_...
5,657
#include "includes.h" __global__ void incSumScan_kernel(unsigned int* d_outVals, unsigned int* d_inVals, size_t numVals) { unsigned int tIdx = threadIdx.x; unsigned int gIdx = blockIdx.x * blockDim.x + threadIdx.x; extern __shared__ unsigned int s_incScan[]; if (gIdx >= numVals) return; s_incScan[tIdx] = d_inVals[tId...
5,658
#include "includes.h" __global__ void Fprop1(const float* in, const float* syn1, float* layer1) { int i = threadIdx.x; //256 int j = blockDim.y*blockIdx.y + threadIdx.y; //64 int k = blockIdx.x; //Data.count atomicAdd(&layer1[256*k + i], in[64*k + j] * syn1[j*256 + i]); ...
5,659
#include "includes.h" #define checkCudaErrors(val) check_cuda( (val), #val, __FILE__, __LINE__ ); __global__ void render( float* framebuffer, int width, int height ) { int i = threadIdx.x + blockIdx.x * blockDim.x; int j = threadIdx.y + blockIdx.y * blockDim.y; if( i >= width || j >= height ) { return; } int pixe...
5,660
#include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <cuda_profiler_api.h> #include <time.h> #include <math.h> #define SIZE 1000 #define BLKS 4 #define THREADSPBLKS 256 #define TILE_WIDTH 8 __global__ void heatCalcKernel(float * g_d,float * h_d, int width, int itr,int count) { int blockId = blockIdx.x +...
5,661
#include "includes.h" __global__ void convertFloatToRGBA_kernel(uchar4 *out_image, const float *in_image, int width, int height) { const int x = blockIdx.x * blockDim.x + threadIdx.x; const int y = blockIdx.y * blockDim.y + threadIdx.y; uchar4 temp; if (x < width && y < height) { int IND = y * width + x; float val = in...
5,662
#include "includes.h" __global__ void fupdate_inter(float *z, float *g, float invlambda, int nx, int ny) { int px = blockIdx.x * blockDim.x + threadIdx.x; int py = blockIdx.y * blockDim.y + threadIdx.y; int idx = px + py*nx; float DIVZ; if (px<nx && py<ny) { // compute the divergence DIVZ = 0; if ((px<(nx - 1))) DIVZ ...
5,663
extern "C" __global__ void compute_probs(double* alphas, double* rands, double* probs, int n, int K, int M) { // assign overall id/index of the thread = id of row int i = blockIdx.x * blockDim.x + threadIdx.x; int threads_per_block = blockDim.x; // set up shared memory: half for probs and half for w ...
5,664
//pass //--blockDim=10 --gridDim=64 --no-inline #include <stdio.h> #include <cuda.h> #include <assert.h> #define N 2 __global__ void foo() { __shared__ int A[10]; A[threadIdx.x] = 2; __syncthreads (); //evita corrida de dados int x = A[threadIdx.x + 1]; }
5,665
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/time.h> #define min(a,b) ((a) < (b) ? (a) : (b)) #define bufferSize 1024 #define NUMTHREAD 256 #define NUMBLOCK 64 char buffer[bufferSize]; int deviceNum = 1, debug = 0, randGen = 0, lenS, m; int nSerialInputs =1; // the number of serial inputs ...
5,666
// source https://www.computer-graphics.se/hello-world-for-cuda.html // This is the REAL "hello world" for CUDA! // It takes the string "Hello ", prints it, then passes it to CUDA // with an array of offsets. Then the offsets are added in parallel // to produce the string "World!" // By Ingemar Ragnemalm 2010 // nvcc ...
5,667
#include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include "string.h" #include<time.h> #include<float.h> __constant__ int PIC[28*28]; __global__ void conv1(int *filterd, int *resultd){ int xsize = 28; int filterdim = 5; __shared__ int fil[25]; int i,j,l; int sum, offset; i = threadIdx.y; j = t...
5,668
#include <cuda.h> #include <cuda_runtime.h> #define TPB 64 __global__ void D3Q19_RegBC_LBGK_ts(const double * fIn, double * fOut, const int * SNL, const int * VW_nl, const double VW_uz, const int * PE_nl, const double rho_out, const double omega, const int Nx, const int Ny, con...
5,669
#include<iostream> #include<cstdio> #include<cstdlib> #include<cuda_runtime.h> using namespace std; __global__ void minimum(int *input) { int tid=threadIdx.x; auto step_size=1; int number_of_threads=blockDim.x; while(number_of_threads>0) { if(tid<number_of_threads) { int first=tid*ste...
5,670
/** * correlation.cu: This file is part of the PolyBench/GPU 1.0 test suite. * * * Contact: Scott Grauer-Gray <sgrauerg@gmail.com> * Louis-Noel Pouchet <pouchet@cse.ohio-state.edu> * Web address: http://www.cse.ohio-state.edu/~pouchet/software/polybench/GPU */ #include <stdio.h> #include <stdlib.h> #include <ma...
5,671
#include <stdio.h> #include <iostream> #include <ctime> #include <unistd.h> #include <cmath> #define N 1000000 #define BLOCK_SIZE 64 #define TIME_CHECK clock()/float(CLOCKS_PER_SEC) using namespace std; float hArray[N]; float *dArray; int blocks; void prologue(void) { cudaMalloc((void**)&dArray,...
5,672
#include "includes.h" __global__ void sReduceSum(int *idata,int *odata,unsigned int ncols) { int i; unsigned int tid = threadIdx.x; extern __shared__ int sdata[]; unsigned int startPos = blockDim.x + threadIdx.x; int colsPerThread = ncols/blockDim.x; int blockOffset = threadIdx.x *(ncols/blockDim.x); int myPart = 0; fo...
5,673
#include <stdio.h> #include <stdlib.h> #include <cuda.h> #define CUDA_SAFE_CALL( err ) (safe_call(err, __LINE__)) #define MAX_THREADS_PER_BLOCK 1024 void safe_call(cudaError_t ret, int line) { if(ret!=cudaSuccess) { printf("Error at line %d : %s\n",line,cudaGetErrorString(ret)); exit(-1); } } struct Edge { i...
5,674
#include <cuda.h> #include <iostream> using namespace std; void cudasafe(int error, string message, string file, int line) { if (error != cudaSuccess) { cout<<stderr<< " CUDA Error: "<<message<<" : "<<error<<". In "<<file<<" line "<<line<<endl; exit(-1); } } int main(...
5,675
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <iostream> #include <cmath> #include <time.h> using namespace std; class Matrix { private: int rozmiar_macierzy; double** macierz; public: Matrix(int rozmiar) { rozmiar_macierzy = rozmiar; mac...
5,676
#include <stdio.h> #include <cuda_runtime.h> // #include <helper_cuda.h> #define N 20 __global__ void doubleElements(int *a){ int i = blockIdx.x * blockDim.x + threadIdx.x; if(i < N) a[i] *= 2; } int main(void){ cudaError_t err = cudaSuccess; size_t size = N * sizeof(int); int *a; cudaMallocManaged(&a, size...
5,677
/* 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,int 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 var_...
5,678
#include <iostream> #include <stdlib.h> #include <stdio.h> #include <cuda.h> using namespace std; #define TILE 10 __global__ void multiplys(int m, int k, int n, int *A, int *B, int *C) { __shared__ int dA[TILE][TILE]; __shared__ int dB[TILE][TILE]; int bx = blockIdx.x; int by = blockIdx.y; int tx = threadIdx...
5,679
#include <iostream> #include <cmath> // nvcc cuda.cu -Xcompiler=-fPIC -g -gencode arch=compute_12,code=sm_12 __global__ void add(int n, float *x, float *y) { int index = blockIdx.x * blockDim.x + threadIdx.x; int stride = blockDim.x * gridDim.x; for (int i = index; i < n; i += stride) { y[i] += x[...
5,680
/** * jrc_cuda_rho.cu * block loading rho calculation. should be much faster * system('nvcc -ptx -m 64 -arch sm_35 jrc_cuda_rho.cu') * i1 is multiple of chunk (16) * J. James Jun, Vidrio Technologies, LLC., 2017 Jun 11 * 7/13/17: fDc_spk option added, which uses spike-specific distance cut-off (dc) */ #include <...
5,681
#include <cuda.h> #include <cuda_runtime.h> #include <stdio.h> #include <stdlib.h> #include <string.h> __global__ void dotProduct( float* matrixA, float* matrixB, float* matrixC, int n) { int j = blockIdx.x * blockDim.x + threadIdx.x; int i = blockIdx.y * blockDim.y + threadIdx.y; float value = 0; ...
5,682
#include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <cuda_runtime.h> #ifndef NDEBUG #define CHECK_STATUS(status) \ if (status != cudaSuccess) \ fprintf(stderr, "File: %s\nLine:%d Function:%s>>>%s\n", __FILE__, __LINE__, __FUNCTION__,\ cudaGetErrorString(status)) #else #define CHECK_S...
5,683
#include "includes.h" #define BLOCK_SIZE 512 #define BLOCK_SIZE_HOUGH 360 #define STEP_SIZE 5 #define NUMBER_OF_STEPS 360/STEP_SIZE // Circ mask kernel storage __constant__ int maskKernelX[NUMBER_OF_STEPS]; __constant__ int maskKernelY[NUMBER_OF_STEPS]; // Function to set precalculated relative coordinates for circl...
5,684
/***************************************************************************** C-DAC Tech Workshop : hyPACK-2013 October 15-18, 2013 Example : singleStream.cu Objective : Write a CUDA program to add the values of two array and print the execution time in ms using streams. ...
5,685
//ly2352, Lu Yang, Adaboost, Host version #include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> #include <cuda_runtime.h> #define nums 2000 #define cols 256 //int nums = 200,cols = 256; float **usps; float *w; float *d_w; float *d_sum_w; int *y; int *d_y; float *d_vec, *d_err1, *d_err2; struct par...
5,686
#include "includes.h" __global__ void kernelCulcRhoReal(const int N, double *rho, double *q, double *p, const double lambda, const double g) { int i = blockIdx.x * blockDim.x + threadIdx.x; if (i < N) { double qi = q[i]; double pi = p[i]; rho[i] = 0.5 * qi * qi; rho[i] += 0.5 * pi * pi; rho[i] += (lambda / 4.0) * qi *...
5,687
/* **************************************** * * CUDA Kernel: matrix minus * */ /* **************************************** * * sub2ind - Column-major indexing of 2D arrays * */ template <typename T> __device__ __forceinline__ T sub2ind( T i, T j, T height ) { return (i + height*j); } // end function 'sub2in...
5,688
#include <stdio.h> #include <cuda_runtime.h> #define N (32 * 1024) #ifndef checkCudaErrors #define checkCudaErrors(err) __checkCudaErrors(err, __FILE__, __LINE__) void __checkCudaErrors(cudaError_t err, const char *file, const int line) { if(cudaSuccess != err) { fprintf(stderr, "checkCudaErrors() Driver AP...
5,689
#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 :...
5,690
#include <stdio.h> #include <cuda.h> __global__ void dkernel() { printf("Hello World.\n"); } int main() { dkernel<<<1, 1>>>(); cudaThreadSynchronize(); return 0; }
5,691
#include <stdio.h> #define ARRAY_SIZE 128 // Helper function to print an array void print_array(float *array, int array_size) { printf("{ "); for (int i = 0; i < array_size; i++) { printf("%0.2f, ", array[i]); } printf("}\n"); } // Using shared memory (For clarity, hardcoding 128 threads/el...
5,692
#include <cstdio> #include <cstdlib> #define N 8 __global__ void mmax(int* in, int* out) { // ask Mark, I have no idea - Ian int idx = threadIdx.x + blockDim.x*blockIdx.x; __shared__ int rslt[N]; rslt[idx] = in[idx]; int lim = N/2; int temp = 0; while (lim > 0) { __syncthreads(); if(idx < li...
5,693
/** Cで学ぶアルゴリズムとデータ構造 ステップバイステップでN−クイーン問題を最適化 一般社団法人 共同通信社 情報技術局 鈴木 維一郎(suzuki.iichiro@kyodonews.jp) コンパイル $ nvcc CUDA01_N-Queen.cu -o CUDA01_N-Queen 実行 $ ./CUDA01_N-Queen 1. ブルートフォース 力任せ探索  全ての可能性のある解の候補を体系的に数え上げ、それぞれの解候補が問題の解とな るかをチェックする方法 (※)各行に1個の王妃を配置する組み合わせを再帰的に列挙組み合わせを生成するだ けであって8王妃問題を解いて...
5,694
#include <stdio.h> #include <cuda_runtime.h> int main(int argc, char ** argv){ cudaError_t error; printf("%s running...\n", argv[0]); int devCount; cudaGetDeviceCount(&devCount); printf("number of devices: %d\n", devCount); cudaDeviceProp devProp; cudaGetDeviceProperties(&devProp, 0); ...
5,695
#include <assert.h> #include <cuda.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <cuda_runtime.h> #include <cuda_runtime_api.h> #include <device_launch_parameters.h> #include <math.h> #include <sys/time.h> //#include <Windows.h> #ifndef __CUDACC__ #define __CUDACC__ #endif #include <device_fu...
5,696
#pragma once namespace cuFIXNUM { namespace internal { /* * Return floor(log2(x)). In particular, if x = 2^b, return b. */ __device__ constexpr unsigned floorlog2(unsigned x) { return x == 1 ? 0 : 1 + floorlog2(x >> 1); } /* * The following function gives a reasonable c...
5,697
#include <iostream> #include <thrust/device_vector.h> #include <thrust/host_vector.h> #include <thrust/random/linear_congruential_engine.h> #include <thrust/random/uniform_real_distribution.h> // nvcc -arch=sm_70 -std=c++14 exemplo5.cu -o exemplo5 && ./exemplo5 struct raw_access { thrust::minstd_rand rng; thr...
5,698
#include <iostream> #include <chrono> #include <cassert> #include <cmath> #include <cstdlib> #include <vector> #include <algorithm> #define BLOCKSIZE 128 #define LOG_BLOCKSIZE 7 // MUST BE ASSOCIATIVE __device__ inline int f(int a, int b){ return a + b; } /** * In this variant, one optimization was applied on t...
5,699
#include "includes.h" __global__ void device_transpose () { int ivis, ihid ; ivis = blockIdx.x * blockDim.x + threadIdx.x ; if (ivis >= d_n_inputs) return ; ihid = blockIdx.y ; d_wtr[ivis*d_nhid_cols+ihid] = d_w[ihid*d_n_inputs_cols+ivis] ; }
5,700
#include <stdio.h> #include <stdlib.h> __global__ void print_from_gpu(void) { printf( "Hello World from device!\n\ threadIdx.x: %d\n\ threadIdx.y: %d\n\ blockIdx.x: %d\n\ blockIdx.y: %d\n\ blockDim.x: %d\n\ blockDim.y: %d\n", threadIdx.x, threadIdx.y, blockIdx.x, blockIdx.y, block...