serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
23,701
//pass //--blockDim=64 --gridDim=64 --no-inline #include "cuda.h" __global__ void foo() { int a; int* local_ptr; local_ptr = &a; *local_ptr = 0; }
23,702
/*************************************************************************** *cr *cr (C) Copyright 2010 The Board of Trustees of the *cr University of Illinois *cr All Rights Reserved *cr ********************************************************************...
23,703
#include "includes.h" __global__ void morph(float* output, float* input1, float* input2, float ampCoeff, float freqCoeff, int length) { int i = threadIdx.x + blockIdx.x * blockDim.x; int j = i<<1; if (j < length) { output[j] = input1[j]*(1.0-ampCoeff) + input2[j]*(ampCoeff); output[j+1] = input1[j+1]*(1.0-freqCoeff) +...
23,704
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <limits.h> #define OUTPUT_FILE_NAME_B "q1b.txt" #define OUTPUT_FILE_NAME_MIN "q1a.txt" #define NUM_THREADS_A 32 #define NUM_BLOCKS_A 2 #define NUM_THREADS_B 32 #define NUM_BLOCKS_B 2 // int* fileToArray(char file1[], int* n){ // FILE* fptr = fopen(...
23,705
#include "includes.h" extern "C" { } __global__ void Vector_Addition(int *a, int *b, int *c) { int tid = blockIdx.x; if (tid < 100) c[tid] = a[tid] + b[tid]; }
23,706
#include "includes.h" #define BIN_WIDTH 0.25 #define BLOCK_DIM 256 #define COVERAGE 180 #define LINE_LENGTH 30 #define BINS_TOTAL (COVERAGE * (int)(1 / BIN_WIDTH)) typedef struct Galaxy { float declination; float declination_cos; float declination_sin; float right_ascension; } Galaxy; __global__ void measure_galax...
23,707
#include "includes.h" __global__ void VecAdd(double* A,double* B,double* C) { // extern __shared__ float sdata[]; int i=threadIdx.x; C[i]=A[i]+B[i]; }
23,708
//Three Dimensional Poisson solver using NVIDIA CUDA //Author: Arkavo Hait, 2021 #include <stdio.h> #include <iostream> #include <cmath> #include <time.h> #include <chrono> #include <string> #include <limits.h> #include <fstream> using namespace std; //Box struct struct BOX { int X; int Y; int Z; }; //...
23,709
/* Test to check basic functioning of Tic Tac Toe interface Rahul Kejriwal CS14B023 */ #include <iostream> #include "../GameInterfaces/TicTacToe.cu" using namespace std; __global__ void test_kernel(){ GameState *initial_stage = new TicTacToeState; initial_stage = initial_stage->makeMove(0); initial_stage = ini...
23,710
#include "includes.h" //----------------------------------------- // Autor: Farias // Data : January 2012 // Goal : Image treatment //----------------------------------------- /*************************************************************************************************** Includes *********************************...
23,711
#include <cuda_runtime.h> #define THREADS 128 __shared__ int smem[THREADS]; __global__ void sumKernel(int *data_in, int *sum_out) { int tx = threadIdx.x; smem[tx] = data_in[tx] + tx; if (tx == 0) { *sum_out = 0; for (int i = 0; i < THREADS; ++i) *sum_out += smem[i]; ...
23,712
#include <thrust/device_vector.h> #include <thrust/sort.h> #include <thrust/copy.h> #include <thrust/functional.h> #include <iostream> using namespace std; #define N 6 int main() { int A[N] = {1,4,2,8,5,7}; char B[N] = {'b', 'a', 'h', 'j', 'd', 'c'}; thrust::device_vector<int> D(N); thrust::device_vector<char> E...
23,713
#include "includes.h" __global__ void vecDiv(float* a,float* b,float* c,const int N){ const int i = blockIdx.x*blockDim.x + threadIdx.x; if(i<N) c[i] = __fdividef(a[i],b[i]); //c[i] = a[i]/b[i]; }
23,714
#include <stdio.h> __device__ void sleep0(void *p_kernel_time, int clockRate) { //This method will sleep for clockRate*kernel_time many clock ticks // which is equivalent to sleeping for kernel_time milliseconds int kernel_time = *((int *) p_kernel_time); int finish_clock; int start_time; for...
23,715
float h_A[]= { 0.8629824282246745, 0.9809381081792694, 0.6033353234247322, 0.9301837183870358, 0.7606145634335923, 0.7102338082874134, 0.9100867887912554, 0.6131782755390371, 0.7682624667626302, 0.9225130643212059, 0.7881034643389964, 0.7683203381565156, 0.6808946040344683, 0.6069419355000365, 0.7423359762916779, 0.690...
23,716
#include <cuda.h> #include <stdio.h> #include <iostream> #include <time.h> //programma per il calcolo matrice matrice, usando il primo approccio delle slide ma modificato da me per non avere race condition //si moltiplica una matrice a size lxm con b size mxn, ottenendo c size lxn //un elemento, tra gli lxn, di c, di...
23,717
#include "cudaCode.cuh" __device__ int x_error, y_error; __device__ int errorFlag = 0; __device__ int errorCode; __device__ void nanException(int x, int y, int e) { errorFlag = 1; errorCode = e; x_error = x; y_error = y; asm("trap;"); } __global__ void calcRhoGPU(float* data, float* rhos) { int tid = blo...
23,718
#include <stdlib.h> #include <stdio.h> #include <stdlib.h> #include <sys/time.h> __global__ void sim_cell_onelife(int* d_cell, int m, int n) { __shared__ int s_arr[100]; int neighbor = 0; int r = threadIdx.x % m; int c = threadIdx.x / m; int cell = d_cell[r + c * m]; int row = r - 1; int col = c...
23,719
#include "includes.h" #define getPos(a,k) (((a)>>(k-1))&1) extern "C" { } __global__ void replace(int * input_T, int * output_T, int * prefix_T, int * prefix_helper_T, int n, int k, int blockPower) { for(int i = 0; i<blockPower; i++) { int oldpos = threadIdx.x + 1024*blockIdx.x + i*1024*gridDim.x; if(oldpos >= n) ...
23,720
#include <bits/stdc++.h> #include <cuda.h> #include <curand.h> #include <curand_kernel.h> #define MAXEDGES 3000000 using namespace std; using namespace std::chrono; //sample comment2 int *edge_array,*edge_array_parent,*vertex_array,*vertex_array_parent,*start_interval,*end_interval; bool *is_leaf; int counter=0; __glo...
23,721
/****************************************************************************** *cr *cr (C) Copyright 2010 The Board of Trustees of the *cr University of Illinois *cr All Rights Reserved *cr *****************************************************************...
23,722
#include "./fitnessTransform.cuh" FitnessTransform::FitnessTransform(int dataSize) : dataSize(dataSize) {} __device__ float FitnessTransform::operator() (const float f) const { return f / dataSize; }
23,723
#include<stdio.h> //Vector Size #define N 32 //Device Function __global__ void add(int* a, int* b, int* c) { //perfrom single addition c[threadIdx.x] = a[threadIdx.x] + b[threadIdx.x]; //store result in c } //Generate N random integers, store in a void random_ints(int* a) { int i; for(i=0; i < N; i++) {...
23,724
// 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 hello-world.cu -L /usr/local/cuda/lib -lcudart -o hello-world #inclu...
23,725
#include <iostream> #include <fstream> #include <sstream> #include <string> #include <vector> #include <algorithm> #define NUM_THREADS 256 /********************* * GLOBAL VARIABLES * *********************/ float k; float starting_temp; int dimension; int timesteps; int width, height, depth; int num_fixed_points; st...
23,726
/****************************************************************************** *cr *cr (C) Copyright 2010 The Board of Trustees of the *cr University of Illinois *cr All Rights Reserved *cr *****************************************************************...
23,727
//Elapsed Real Time for input-4.txt: 0.603, 0.606, 0.599 //Elapsed Real Time for input-5.txt: 1.419, 1.391, 1.408 #include <stdio.h> #include <stdbool.h> #include <cuda_runtime.h> // Representation for a 2D point with integer coordinates. typedef struct { // Coordinates of the point. int x, y; } Point; // Return ...
23,728
#include <stdio.h> #include <cuda_runtime.h> // CUDA check error #define cuda_check_error(msg) \ { \ cudaError_t err = cudaGetLastError(); \ if( cudaSuccess != err) { \ fprintf(stderr, "[GPUJPEG] [Error] %s (line %i): %s: %s.\n", \ __FILE__, __LINE__, msg, cudaGetErrorSt...
23,729
//STL #include <iostream> #include <vector> #include <time.h> #include <algorithm> using std::cout; using std::endl; using namespace std; unsigned i; const unsigned N = 2048; unsigned gpuThr = 256; unsigned gpuBl = N / gpuThr; std::vector < float > inputVec( N ); //=========================== gpu ===================...
23,730
#include "RELU_Activation_Kernel.cuh" __global__ void Leaky_RELU_Kernel(float* tensor, int tensorSize) { int threadIndex = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x; if (threadIndex < tensorSize) { if (tensor[threadIndex] > 0) { tensor[threadIndex] = tensor[threadIndex]; } else {...
23,731
#include "includes.h" /* kernel.cu */ __global__ void AddVector( int vecSize, const float* vecA, const float* vecB, float* vecC) { int i = blockDim.x * blockIdx.x + threadIdx.x; if (i < vecSize) vecC[i] = vecA[i] + vecB[i]; }
23,732
#include "includes.h" __global__ void add(long* in, long* 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]; }
23,733
#include <stdio.h> #include <stdlib.h> #define EPS2 0.00000001 #define N 100 // Global variables __device__ float4 globalX[N]; __device__ float4 globalV[N]; __device__ float4 globalA[N]; // Function prototypes __global__ void calculate_forces(float4 globalX[N], float4 globalA[N]); __device__ float3 tile_calculation(...
23,734
#include <stdio.h> #include <stdlib.h> #include <iostream> #include <cuda_runtime.h> __global__ void matrixMulKernel(float *C, float *A, float *B, int width, int height){ int tx = blockIdx.x * blockDim.x + threadIdx.x; int ty = blockIdx.y * blockDim.y + threadIdx.y; if(tx >= width || ty >= height) return; ...
23,735
#include "includes.h" __global__ void divScalarMatrix(double *dMatrix, double *dScalar, int dSize){ int tid = threadIdx.x + blockIdx.x * blockDim.x; while (tid < dSize) { dMatrix[tid] = dMatrix[tid]/dScalar[0]; tid += blockDim.x * gridDim.x; } }
23,736
__host__ __device__ inline bool is_I_up(float a, float y, float Cp, float Cn) { return (y > 0 && a < Cp) || (y < 0 && a > 0); } __host__ __device__ inline bool is_I_low(float a, float y, float Cp, float Cn) { return (y > 0 && a > 0) || (y < 0 && a < Cn); } __host__ __device__ inlin...
23,737
// Rishabh Agarwal - 18JE0676 #include <bits/stdc++.h> #include <cuda.h> using namespace std; // kernel functions // single precision addition __global__ void MatrixAddFloatKernel(float *temp_ha, float *temp_hb, float *temp_hd, int n, int m) { int i = blockDim.x * blockIdx.x + threadIdx.x; if(i < n*m) { ...
23,738
#include <stdio.h> #define N 512 void random_ints(int* a, int n) { int i; for (i = 0; i < n; ++i) { a[i] = rand() %5000; } } // each parallel invocation of add() is referred to as a block : the set of blocks is referred to as a grid __global__ void add(int *a, int *b, int *c) { // each block hand...
23,739
//Complete 3SAT solver using CUDA // Parallel Processing course assignment // Author : Gourab Saha //Contact : 9051110501 // To compile : nvcc sat.cu #include<stdio.h> #include<cuda.h> #include<math.h> #include <stdlib.h> #include <set> #include <iostream> #include <map> #include <time.h> ...
23,740
/* * SPDX-FileCopyrightText: Copyright (c) 1993-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 * * 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 Lic...
23,741
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> #define BLOCK_DIM 32 #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true) { if (code != cudaSuccess) { fprintf(stderr,"GPUassert: %...
23,742
#include "includes.h" __global__ void multiplyKernel(float* Z, float* A, float* B, int size){ int id = blockDim.x * blockIdx.x + threadIdx.x; if(id < size){ Z[id] = A[id] * B[id]; } }
23,743
#include "includes.h" #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 // mX has order rows x cols // vectY has length rows __global__ void ftest(int diagFlag, int p, int rows, int colsx, int colsy, int rCols, int un...
23,744
#include <stdio.h> #include <assert.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <cuda.h> #define MAX 1000 #define DISPLAY 1 __global__ void histoKernel(int*, int, int*); __global__ void reduceKernel(int*, int*, int); static double CLOCK(); int main(int argc, char* argv[]) { double start,...
23,745
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <time.h> #include <math.h> #include <string.h> #define EPSILON 1E-9 #define BLOCK_SIZE_F 512 //Work with blocks of 512 threads due to double precision - shared memory #define BLOCK_SIZE_VP 1024 //Work with blocks of 512 threads due to double precision ...
23,746
#include <iostream> #include <stdio.h> #include <math.h> // CUDA kernel to add elements __global__ void add(int N, float *x) { int i = blockIdx.x * blockDim.x + threadIdx.x; if (i<N) x[i] = x[i] *2; } int main(void) { int N = 1<<20; float ...
23,747
 #include <thrust/reduce.h> #include <thrust/iterator/counting_iterator.h> int main() { thrust::counting_iterator<int> first(10); thrust::counting_iterator<int> last = first + 3; std::cout << first[0] << std::endl; // returns 10 std::cout << first[1] << std::endl; // returns 11 std::cout << first[100] << s...
23,748
#include "includes.h" __global__ void addRows(double *matrix, int *d_i){ int i=*d_i; int n=blockDim.x+i; int id= n*(blockIdx.x+i+1) + threadIdx.x+i; __shared__ double multiplier; if(threadIdx.x==0){ multiplier=matrix[n*(blockIdx.x+1+i)+i]/matrix[n*i+i]; } __syncthreads(); matrix[id]-=matrix[n*i+threadIdx.x+i]*multipl...
23,749
#include "includes.h" __global__ void subDiffuseKernel(float *data, int x, int y, float pressure) { data[NX * x + y] -= pressure; }
23,750
/******************************************* * * Program for 2D/3D array allocations of CUDA * a :zhonghy * date:2018-4-16 * ********************************************/ //#include "cuda.h" #include "cuda_runtime.h" #include "device_launch_parameters.h" #include "device_functions.h" #include <stdio.h> #include ...
23,751
extern "C" { __global__ void rgb2yiq(float3 * src,float3 * dst,int imgWidth,int imgHeight){ int xIndex = threadIdx.x + blockIdx.x * blockDim.x; int yIndex = threadIdx.y + blockIdx.y * blockDim.y; if (xIndex < imgWidth && yIndex < imgHeight) { float3 rgb = src[yIndex * imgWidth + xIndex]; ...
23,752
/** * APPROXIMATE PATTERN MATCHING * * INF560 */ #include <string.h> #include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <unistd.h> #include <sys/time.h> #include <cuda_runtime.h> #define APM_DEBUG 0 char * read_input_file( char * filename, int * size ) { char * buf ; off_t fsize; in...
23,753
#include <stdio.h> #include <iostream> #include <vector> __global__ void sum(int n, double *x, double *y, double *z) { int i = blockIdx.x*blockDim.x + threadIdx.x; if(i<n){ z[i]=x[i]+y[i]; printf("check from function i= %d %f + %f = %f\n",i,x[i],y[i],z[i]); } //blockIdx variabile di tipo dim3, co...
23,754
// from the following URL // https://www.sharcnet.ca/help/index.php/CUDA_tips_and_tricks /* * this program is a simple test of the binary tree recommended reduction * algorithm for CUDA * */ #include <iostream> #define TOTAL_SIZE 100000 #define nTPB 256 #define BLOCK_SIZE 64 // MUST BE A POWER OF 2!! //#defi...
23,755
#include "includes.h" __global__ void computeMoment(int *readArr, int *writeArr, double *weightArr, int n){ int row = blockIdx.x*blockDim.x + threadIdx.x; int col = blockIdx.y*blockDim.y + threadIdx.y; // If coordinates are between boundaries // update the write array accordingly if(row < 517 && col < 517){ float infl...
23,756
#include "includes.h" __global__ void kernel_updateweights(int N, double *wt, double *x, double *q, double nu){ unsigned int tid = blockIdx.x*blockDim.x + threadIdx.x; /* make sure to use only N threads */ if (tid<N) { wt[tid]=((nu+1.0)/(nu+x[tid]*x[tid])); q[tid]=wt[tid]-log(wt[tid]); /* so that its +ve */ } }
23,757
#include <stdio.h> #include <stdlib.h> #include <time.h> __global__ void convertToGray(int pixel, int cycle, unsigned char *red, unsigned char *green, unsigned char *blue, unsigned char *out) { for (int j = blockIdx.x; j < cycle; j+=gridDim.x) { for (int i = threadIdx.x; i < pixel; i+=blockDim.x) ...
23,758
#include "includes.h" __global__ void vecAdd_3(double *a, double *b, double *c, int n) { int id = threadIdx.x; int id_1; for(int i = 0; i < n; i++) { id_1 = id + i * n; c[id_1] = a[id_1] + b[id_1]; } }
23,759
#include <stdio.h> #include <stdlib.h> #include <math.h> #define GRADIENT_SIZE 16 #define C_X_MIN -0.188 #define C_X_MAX -0.012 #define C_Y_MIN 0.554 #define C_Y_MAX 0.754 #define IMAGE_SIZE 4096 #define ARRAY_SIZE (3 * IMAGE_SIZE * IMAGE_SIZE * sizeof(unsigned char)) #define PIXEL_WIDTH ((C_X_MAX - C_X_MIN) / IMA...
23,760
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> #include <math.h> #define NUM 1024 cudaError_t addWithCuda(double *c, const double *a, const double *b, long size); __device__ double test(int i); __global__ void addKernel(double *c, const double *a, const doubl...
23,761
// // Created by fiberhome on 2021/4/7. // // Device code #include "cuda_runtime.h" #include "iostream" __global__ void MyKernel(int *d, int *a, int *b) { int idx = threadIdx.x + blockIdx.x * blockDim.x; d[idx] = a[idx] * b[idx]; } // Host code int main() { int numBlocks; // Occupancy in terms of a...
23,762
#include "GpuProjectionProcessing.cuh" #include "GpuUtmWgsTransform.cuh" #include "GpuTimer.cuh" #include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> using namespace winGpu; __global__ void applyTransformUtmToWgsCoordsGpu(double xOrigin, double yOrigin, double xPixelSize, double yPixelSi...
23,763
#include "includes.h" __global__ void _setPrecisionKernel(float* data, size_t size, int* precision) { unsigned int idx = blockDim.x * blockIdx.x + threadIdx.x; if (idx >= size) return; int prec = precision[idx]; int mul = 1; while(prec--) mul *= 10; data[idx] = (float)(int)(data[idx]*mul); data[idx] /= mul; }
23,764
/* jacobi.c - Poisson problem in 3d * */ #include <math.h> #include <stdlib.h> #include <stdio.h> __device__ void jacobi_gpu(int N, double ***u, double ***v, double ***f, int iter_max) { //int counter = 0; int i = blockIdx.x * blockDim.x + threadIdx.x; int j = blockIdx.y * blockDim.y + threadIdx.y; ...
23,765
#include "includes.h" /** * Computación Paralela (curso 1516) * * Alberto Gil * Guillermo Cebrian */ // Includes generales // Include para las utilidades de computación paralela /** * Estructura antena */ typedef struct { int y; int x; } Antena; /** * Macro para acceder a las posiciones del mapa */ #define m(y,x...
23,766
#define DATA_SIZE 10000000 #define BLOCKS_COUNT 1 #define THREADS_COUNT 64 __global__ void findMean(unsigned int dataForBlock, float *inputData, float *results) { int index = blockIdx.x * blockDim.x + threadIdx.x; float result = 0; for (int i = 0; i < dataForBlock; i++) { result += inputData[i...
23,767
#include "includes.h" __global__ void concat(float* input1, float* input2, float* input3, float* input4, size_t num1, size_t num2, size_t num3, size_t num4, size_t maxNum, float* output, const int numPerBatch) { size_t i = blockDim.x * blockIdx.x + threadIdx.x; for(;i < maxNum; i += size_t(blockDim.x * gridDim.x)){ si...
23,768
#include <stdio.h> #include <stdlib.h> #define block_size 32 #define vector_size 100 __global__ void add( int *a, int *b, int *c ) { int tid = (blockIdx.x*blockDim.x) + threadIdx.x; // this thread handles the data at its thread id if (tid < vector_size){ c[tid] = a[tid] + b[tid]...
23,769
#include <iostream> #include <stdio.h> #include <math.h> __global__ void cuPi(float *sum, int nbin, float step) { // Write your pi calculation kernel here return; } int main(void) { int REAL_PI = 3.141592653589793238462643383; int NBINS = 10; // modify this to achieve better performance int S...
23,770
#include <cuda.h> #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> #define N 512; #define M 512; void colorTogrey_BLUR(int *, int *,int,int); // we have 3 channels corresponding to RGB // The input image is encoded as unsigned characters [0, 255] __global__ void blurKernel(int *Pin_d,...
23,771
#include <cuda_runtime.h> #include <stdio.h> unsigned char *d_red, *d_green, *d_blue; float *d_filter; uchar4 *d_inputImageRGBA__; uchar4 *d_outputImageRGBA__; float *h_filter__; __global__ void gaussian_blur(const unsigned char* const inputChannel, unsigned char* const outputChannel, ...
23,772
#include <stdio.h> #include <math.h> #include <stdlib.h> const int TILE_SIZE = 8; const int N_ROWS = 4; #define N_TEST 1 __global__ void naive_transpose(const float * A, float * B, int size) { int index = threadIdx.x + blockIdx.x * blockDim.x; int x = index % size; int y = index / size; B[y * size + x] = A[x...
23,773
template<typename T> __device__ void getColumnsValues(const T* matrix, const int* indices, T* result, const int rows, const int cols) { int bx = blockIdx.x; int tx = threadIdx.x; int row = bx * blockDim.x + tx; if (row < rows) { int col = indices[row]; result[row] = m...
23,774
// vAdd.cu // // driver and kernel call #include <stdio.h> #define BLOCK_SIZE 256 __global__ void getDensity (double *a_d, double *b_d, int numSlice) { // __shared__ double s[BLOCK_SIZE + 2]; int x = blockIdx.x * blockDim.x + threadIdx.x; if (x != 0 && x < numSlice - 1) { // if(thr...
23,775
#include "includes.h" __global__ void reduction_interleaved_pairs_1(int * int_array, int * temp_array, int size) { int tid = threadIdx.x; int gid = blockDim.x * blockIdx.x + threadIdx.x; if (gid > size) return; for (int offset = blockDim.x / 2; offset > 0; offset = offset / 2) { if (tid < offset) { int_array[gid] += ...
23,776
/********************************************************** * This code is intended for for computing multiplication * * for sub-product tree. * * 2*poly_length <= T * * According to this constraint subproduct tree level * * where poly_length is not more th...
23,777
#include "includes.h" /******************************************************************************* * *******************************************************************************/ /************************************************************************* /********************************************************...
23,778
#include <stdio.h> #include <math.h> #include <float.h> #include <thrust/extrema.h> #include <thrust/device_ptr.h> #define CSC(call) \ do { \ cudaError_t res = call; \ if (res != cudaSuccess) { \ fprintf(stderr, "ERROR in %s:%d. Message: %s\n", \ __FILE__, __LINE__, cudaGetErrorString(res)); ...
23,779
#include <cuda_runtime.h> #include <device_launch_parameters.h> #include <stdio.h> #include <time.h> #define CHECK(call)\ {\ const cudaError_t error = call;\ if(error != cudaSuccess)\ {\ printf("Error: %s:%d,", __FILE__,__LINE__)\ printf("code:%d,reason:%s\n",error,cudaGetErrorString(error));\ exit(1);\ ...
23,780
#include <iostream> #include <fstream> #include <cmath> // lattice size int const NX = 256; int const NY = 256; int const MaxIter = 200000; // number of Jacobi iterations void checkError(cudaError_t e) { if (e != cudaSuccess) { std::cerr << "CUDA error: " << int(e) << " : " << cudaGetErrorString(e) << '...
23,781
/* kernel routine starts with keyword __global__ */ #include <stdio.h> #define N 4096 __global__ void matrixadd(float* A, float* B, float* C) { int i = blockIdx.x*blockDim.x+threadIdx.x; int j = blockIdx.y*blockDim.y+threadIdx.y; int index = i+j*N; int k; // if ((i<N) && (j<N)) { for (k=0; k<N; k++)...
23,782
/* It is essential for the programmer to choose the correct GPU device from a list of GPU devices available to perform the calculations very efficiently, For Example: To run the double precision applications devices with compute capacity of more than 1.3 are desired. The following program utilizes the cudaDeviceProp ...
23,783
#include "includes.h" //Udacity HW 4 //Radix Sorting __global__ void scanBlks(unsigned int *in, unsigned int *out, unsigned int n, unsigned int *blkSums) { extern __shared__ int blkData[]; int i1 = blockIdx.x * 2 * blockDim.x + threadIdx.x; int i2 = i1 + blockDim.x; if (i1 < n) blkData[threadIdx.x] = in[i1]; if (...
23,784
#include "includes.h" #define CUDA_INPUT "input.txt" #define CUDA_OUTPUT "cuda_output.txt" int NUMPOINTS; double ENDTIME; double DT; double ENDVALUES; void InitialiseToZero(float* array); __device__ void PrintPointsGPU(float* array, int size, double currentTime); void PrintPointsCPU(float* array, double currentTime);...
23,785
#include <bits/stdc++.h> using namespace std; void add(int N, float *X, float *Y) { for (int i=0; i<N; i++) { Y[i] = X[i] + Y[i]; } } int main(void) { int N = 1<<27;//1.34217728 *10^8 elements. 512 MB //Allocate Memory (512*2=1GB). float *X = new float[N]; float *Y = new float[N]; // initialize x an...
23,786
//Perlin kernel (Rob Farber) #include <stdio.h> extern float gain, xStart, yStart, zOffset, octaves, lacunarity; #define Z_PLANE 50.f __constant__ unsigned char c_perm[256]; __shared__ unsigned char s_perm[256]; // shared memory copy of permuation array unsigned char* d_perm=NULL; // global memory copy of permutation...
23,787
#include <cstdio> #include <algorithm> #include <cuda.h> #include <sys/time.h> static const int ThreadsPerBlock = 512; static __global__ void collatz(const long upper, int* const maxlen) { const long i = threadIdx.x + blockIdx.x * (long)blockDim.x; // compute sequence lengths if (i < (upper + 1)/2) { long v...
23,788
/**************************************************************************** * * cuda-hello1.cu - Hello world with CUDA (with dummy device code) * * Written in 2017 by Moreno Marzolla <moreno.marzolla(at)unibo.it> * * To the extent possible under law, the author(s) have dedicated all * copyright and related an...
23,789
#include <stdio.h> #define CUDA_CHECK_RETURN( value ) { \ cudaError_t _m_cudaStat = value; \ if ( _m_cudaStat != cudaSuccess ) { \ fprintf( stderr, "Error '%s' at line %d in file %s\n"...
23,790
#include <stdexcept> #include <iostream> #include <stdio.h> #include <assert.h> #include <cmath> #include <cuda.h> #include <cuda_runtime.h> __global__ void sin_kernel(int* __restrict__ out, const float* __restrict__ x) { *out = std::pow(4,3); } //__global__ //void sinf_kernel(float* __restrict__ out, const float*...
23,791
#include <fstream> #include <time.h> using namespace std; class params{ private: double r_min_ini, r_min_trg; double r_max_ini, r_max_trg; double i_min_ini, i_min_trg; double i_max_ini, i_max_trg; public: int width, height; double r_min, r_max, i_min, i_max; int max; params(){ r_min_ini = -2.86, ...
23,792
#include <stdio.h> #include <stdint.h> typedef struct Node{ int a; Node *hasNext; } Node; int main(){ Node *node = (Node *) malloc(sizeof(Node)); int address = reinterpret_cast<uintptr_t>(node); Node *next = reinterpret_cast<Node *>(address); printf("%p %x %p\n", node, address, next); free(node); return 0...
23,793
#include <iostream> #include <cuda.h> #include <chrono> #include <stdlib.h> #include <ctime> #include <cmath> #include <limits> __global__ void sum_vectors_if(double *a, int size){ int idx = blockIdx.x * blockDim.x + threadIdx.x; if (idx < size) { if ((int(a[idx]) + idx) % 3 == 0) { a[idx]...
23,794
// #include<cuda.h> #include<stdio.h> #include<math.h> #include<ctime> #include<time.h> #define TILEWIDTH 32 #define TILE_WIDTH 32 __global__ void vecMulMatrixKernel(float* A, float* B, float* C, int n){ //each block loads the corresponding row of blocks of A matrix and column of blocks of B matrix, one block at a t...
23,795
#include<iostream> #include<cuda.h> #include<stdio.h> using namespace std; #define TILE_WIDTH 4 __global__ void MatrixMulKernel( int* A, int* B, int* C,int m, int n, int k) { __shared__ int ds_A[TILE_WIDTH][TILE_WIDTH]; __shared__ int ds_B[TILE_WIDTH][TILE_WIDTH]; int bx = blockIdx.x; int by = blockIdx.y; int tx = ...
23,796
#include <stdio.h> #include <stdlib.h> #include <inttypes.h> // Define constants and data types #define MAX_FILE_SIZE 1048576 #define STORAGE_SIZE 1085440 #define DATAFILE "./data.bin" #define OUTPUTFILE "./snapshot.bin" #define FILE_ENTRIES 1024 #define META_SIZE 31 #define DATA_SI...
23,797
#include <stdlib.h> #include <fstream> #include <thrust/sort.h> #include <stdio.h> #include <assert.h> #include <math.h> #include <cuda.h> #define NUM_THREADS 256 int main( int argc, char **argv ) { cudaThreadSynchronize(); }
23,798
#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 seqPheroUpdate(float *phero, float *pheroReal, ...
23,799
#include <err.h> #include <cuda.h> #include <stdio.h> #include <unistd.h> #include <stdint.h> #define BUFLEN (4096) int byte_sum(uint8_t* bytes, int size) { int i = 0; int sum = 0; for(; i< size; i++) { sum += bytes[i]; } return sum; } void print_nonzeros(uint8_t* bytes, int size) { ...
23,800
#include <stdio.h> #include <cuda_runtime.h> #include <time.h> #include <sys/time.h> #define CHECK(call) \ { \ const cudaError_t error = call; ...