serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
18,101
/* LodePNG version 20201017 Copyright (c) 2005-2020 Lode Vandevenne This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, incl...
18,102
extern "C" __global__ __launch_bounds__(32) void sconv_bprop_C1_N64( float *param_test, float *param_I, const float *param_E, const float *param_F, float param_alpha, float param_N, float param_K, float param_D, float param_H, float param_W, float...
18,103
/* Program name: gld_throughput.cu Author name: Dr. Nileshchandra Pikle Email: nilesh.pikle@gmail.com Contact Number: 7276834418 Purpose: Program to demonstrate effect on performance for global memory access pattern Description: Two vector addition kernels are implemented, one with co...
18,104
#include<iostream> using namespace std; int main() { cudaSharedMemConfig config; cudaDeviceGetSharedMemConfig(&config); switch(config) { case cudaSharedMemBankSizeDefault: cout << "default SharedConfig" << endl; break; case cudaSharedMemBankSizeFourByte: cout << "fourbyte SharedConfig" <...
18,105
#include <string> #include <cstring> #include <cctype> #include <cstdlib> #include <cstdio> #include <iostream> #include <fstream> #include <bitset> #include <cuda_runtime.h> #include <stdio.h> #define DIM 128 #include "csv.hpp" #include "timer.h" using namespace std; extern __shared__ int dsmem[]; int recursiveRed...
18,106
#include<iostream> #include<cuda_runtime.h> __global__ void VecAdd(double *A, double *B, double *C, int N) { int i = blockDim.x * blockIdx.x + threadIdx.x; if( N > i ) C[i] = 0.01*A[i] + B[i]; } int main(int argc, char *argv[]) { int N = 100; size_t size = N * sizeof(double); double *h_A = (double*)malloc...
18,107
#include "includes.h" __global__ void calcConvolutionBackwardResetGradGPU( float *filter_grads, int in_size_z, int kernel_size, int filter_size, int elements ) { int id = (blockIdx.x + blockIdx.y*gridDim.x) * blockDim.x + threadIdx.x; if ( id < elements ) { int i = id % kernel_size; id /= kernel_size; int j = id % ker...
18,108
#define COALESCED_NUM 16 #define blockDimX 16 #define blockDimY 1 #define gridDimX (gridDim.x) #define gridDimY (gridDim.y) #define idx (blockIdx.x*blockDimX+threadIdx.x) #define idy (blockIdx.y*blockDimY+threadIdx.y) #define bidy (blockIdx.y) #define bidx (blockIdx.x) #define tidx (threadIdx.x) #define tidy (threadIdx...
18,109
#include "includes.h" __global__ void BilinearResampleKernel(float *input, float *output, int inputWidth, int inputHeight, int outputWidth, int outputHeight) { int id = blockDim.x * blockIdx.y * gridDim.x + blockDim.x * blockIdx.x + threadIdx.x; int size = outputWidth * outputHeight; float iT, iB; if (id < size) { //o...
18,110
// RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args #include <iostream> #include <algorithm> // CHECK: #include <hip/hip_runtime.h> #include <cuda.h> template<typename T> __global__ void axpy(T a, T *x, T *y) { y[threadIdx.x] = a * x[threadIdx.x]; } template<typename T1, typename T2> __global__ void axpy_...
18,111
#include <iostream> #include <cstdio> #include <cstdlib> // #include <helper_cuda.h> // #include <helper_string.h> /* Run with only HOST code *\ // additional comment + some other additional comment int main(void) { printf("Goodbye Universe!\n"); // FUTURE: comment return 4; } */ /* Run with DEVICE test code */...
18,112
/* * Implementation of DES Algorithm. * Author : Minsu Kim * CUDA modification : Jesper Hansson Falkenby * Description : This code implements DES Algorithm. */ #include "des.cuh" #include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> #include <math.h> #define THREADS_PER_BLOCK 1...
18,113
#include "includes.h" __global__ void AddUtilityKernel( int s1, int s2, float *distance, float *utility ) { int threadId = blockDim.x*blockIdx.y*gridDim.x //rows preceeding current row in grid + blockDim.x*blockIdx.x //blocks preceeding current block + threadIdx.x; if(threadId < 1) { utility[s1] += distance[s2] -...
18,114
#include <stdio.h> #include <time.h> // utilize global memory --> shared memory to accelerate matrix multiplication void naiveMultiply(float *a, float *b, float *c, int M, int N, int w) { for (int row = 0; row < M; ++row) for (int col = 0; col < N; ++col) { float sum = 0.0f; for (int i = 0; i < w; ++i) { ...
18,115
extern "C" __global__ void add(float *a, float *b) { } // Strange, but valid formatting extern "C" __global__ void add2( float * a, float *b) { } // This function gets called with too few arguments extern "C" __global__ void toofew(float *a, flo...
18,116
//#include <hayai/hayai.hpp> // //#include "LSM.cuh" // //#include "concurrent-xfasttrie-fixture.cu" // //using LSM = gpu::lsm<key_type, mapped_type, 16u * 32u>; //using LSMInsertionFixture = XTrieInsertionFixture<LSM, Structure::LSM>; //using LSMGetThreadFixture = XTrieGetThreadFixture<LSM, Structure::LSM>; //using LS...
18,117
#include <string.h> #include <stdlib.h> #include <stdio.h> #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } extern "C" { __constant__ char parseStack[4096]; inline void gpuAssert(cudaError_t code, char *file, int line, bool abort=true) { if (code != cudaSuccess) { fprintf(stderr,"GPUasse...
18,118
#include <iostream> #include <math.h> #include <cstdlib> // CPU kernel void addCPU(int n, float *x, float *y) { for (int i = 0; i < n; i++) y[i] = x[i] + y[i]; } // GPU kernel with 1 block and 1 thread per block __global__ void addGPU_1_1(int n, float *x, float *y) { for (int i = 0; i < n; i++) y[i] = x[...
18,119
#include <stdio.h> #include <stdlib.h> #include <cuda_runtime.h> int main( void ) { cudaDeviceProp prop; FILE* fptr; fptr=fopen("GPUspec.txt","w"); if(fptr==NULL){ printf("FILE cannot be opened.\n"); exit (1); } int count; cudaGetDeviceCount( &count ); for (int i=0; i< c...
18,120
/* * Copyright 2014. All rights reserved. * * CUDA Kernel Device code * Rowan Hughes */ #define SDATA( index) sdata[index] extern "C" __global__ void reductionKernel( float* g_idata, int chanels, int sizeData) { // shared memory // the size is determined by the host application extern __shared__ float sd...
18,121
#include "includes.h" __global__ void UpdateVelocitiesKernel (double *VthetaInt, double *VradInt, double *invRmed, double *Rmed, double *Rsup, double *Rinf, double *invdiffRmed, double *invdiffRsup, double *Dens, double *invRinf, double *TAURR, double *TAURP, double *TAUPP, double DeltaT, int nrad, int nsec) { int j = ...
18,122
#include "includes.h" using namespace std; #define nsamples 250000 #define threadsPerBlock 500 #define num_blocks 500 // function to count samples in circle using cpu __global__ void count_samples_GPU(float *d_X, float *d_Y, int *d_countInBlocks, int num_block, int samples) { __shared__ int shared_blocks[500]; ...
18,123
/* Parallel computation of eigenvalues in 3D. This follows appendix G in * Gunnar Farnebck's PhD thesis "Polynomial Expansion for Orientation and * Motion Estimation" * * Elements are passed as arguments t1-t6 according to the layout: * | t1 t2 t3 | * T = | t2 t4 t5 | * | t3 t5 t6 | * * Author: Gunnar...
18,124
__global__ void create_string_index(long string_index_size, long *quote_index, char *quote_counts) { int index = blockIdx.x * blockDim.x + threadIdx.x; int stride = blockDim.x * gridDim.x; long elements_per_thread = (string_index_size + stride - 1) / stride; long start = index * elements_per_thread; long end...
18,125
/* NiuTrans.Tensor - an open-source tensor library * Copyright (C) 2017, Natural Language Processing Lab, Northeastern University. * All rights reserved. * * 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 o...
18,126
#include "includes.h" __global__ void _logpforw(int nrows, int ncols, float *y) { /* y is layer output, i.e. unnormalized log probabilities. On output y will contain normalized probabilities. */ float ymax, z, logz; int i0, i1; int col = threadIdx.x + blockIdx.x * blockDim.x; while (col < ncols) { i0 = col * nrows; i1 ...
18,127
//This code is a modification of L1 cache benchmark from //"Dissecting the NVIDIA Volta GPU Architecture via Microbenchmarking": https://arxiv.org/pdf/1804.06826.pdf //This benchmark measures the latency of L1 cache //This code have been tested on Volta V100 architecture #include <stdio.h> #include <stdlib.h> #...
18,128
/* Matrix Multiplication w/GPU using Tiling (cuda) Víctor Rendón Suárez A01022462 */ #include <cuda_runtime.h> #include <stdio.h> #include <cmath> #include <chrono> #include <stdlib.h> // #include "common.h" using namespace std; #define SIZE 2000 #define TS 32 void initialize_matrix(float *matrix, const int n)...
18,129
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <cuda.h> #include <curand_kernel.h> __global__ void setup_kernel ( curandState * state, unsigned long seed ) { int id = threadIdx.x; curand_init ( seed, id, 0, &state[id] ); } __global__ void generate( curandState* globalState, float* array ) ...
18,130
// Copyright (c) 2015 Patrick Diehl // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) extern "C" { __global__ void sum2(unsigned int* array, unsigned int* count, unsigned int* n) { for (int i = blockDim.x...
18,131
#include <stdio.h> #include <cuda.h> #include <string.h> #include <math.h> #include <stdbool.h> #define BNUM 180 #define TNUM 1024 unsigned long long MakeNum(bool *number,unsigned long long size){ unsigned long long i,j,now=0; for(i=0;i<size;i++) number[i]=0; number[2]=1;number[3]=1; for(i=5,j=2;i<size;i+=j,j=6-...
18,132
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <string> #include <iostream> #include <iomanip> #include <fstream> #include <vector> #include <locale> #include <algorithm> #include <cstdio> #include <thrust/host_vector.h> #include <thrust/device_vector.h> using namespace std; const int maxWo...
18,133
/* This code illustrates the use of the GPU to perform vector addition on arbirarily large vectors. Author: Naga Kandasamy, 02/15/2017 */ #include <stdlib.h> #include <stdio.h> #include <time.h> #include <string.h> #include <math.h> #include <float.h> // includes, kernels #include "vector_addition_kernel.c...
18,134
/****************************************************************************************/ /* CS023 Course Project: Bloomtree GPU implementation using CUDA library */ /* CUDA implementation of all relevant functions */ /* */ /**********************************************************...
18,135
float h_A[]= { 0.8697172733992931, 0.7693666893570357, 0.5687568839290045, 0.8521512729384983, 0.6896448200107215, 0.7026725183781855, 0.8678269614314527, 0.8433880560245508, 0.8129175071892732, 0.8061655160221067, 0.8901613805018374, 0.998459112765671, 0.5359504309411578, 0.7795175273802036, 0.7772618683490158, 0.7775...
18,136
#include<bits/stdc++.h> #include <cuda.h> #include<iostream> #include <fstream> #include<stdio.h> #include<stdlib.h> //#define f first //#define s second using namespace std; struct eltype{ int f; int rowno; int colno; }; vector< vector < struct eltype > > g; int find_col(vector< vector < struct e...
18,137
#include "includes.h" __global__ void SumOverLargeBuffer( float* buffer, int spread, int size ){ int offset = CUDASTDOFFSET; float value1 = buffer[offset]; float value2 = buffer[offset+spread]; if( offset+spread < size ) buffer[offset] = value1+value2; }
18,138
#include "includes.h" # define MAX(a, b) ((a) > (b) ? (a) : (b)) # define GAUSSIAN_KERNEL_SIZE 3 # define SOBEL_KERNEL_SIZE 5 # define TILE_WIDTH 32 # define SMEM_SIZE 128 __global__ void nonMaxSuppressionDevice(int width, int height, float *d_gradientX, float *d_gradientY, float* d_gradientMag, float* d_nonMax) { in...
18,139
__global__ void vectoradd ( int size, const float* vecA, const float* vecB, float* vecC ) { int idx = threadIdx.x + blockDim.x*blockIdx.x; if (idx >= size) return; vecC[idx] = 0; for (int i = 0; i < 100000; i++) atomicAdd(&vecC[idx], vecA[idx] + vecB[idx]); } void vectoradd ( cudaStream_t stream, ...
18,140
#include "includes.h" __global__ void cunnx_BlockSparse_accGradParameters_kernel( float *gradWeight, float* gradBias, float *gradOutput, float *input, float *inputIndice, float *outputIndice, int inputSize, int outputSize, int nInputBlock, int nOutputBlock, int inputWindowSize, int outputWindowSize, float scale) { __sh...
18,141
// very simple vector add example discussed in class // --everything is in one *.cpp program // --no error checking; not a good idea using namespace std; #include <iostream> #define TILE_WIDTH 256 // iceil macro // returns an integer ceil value where integer numerator is first parameter // and integer denominator is...
18,142
#include <iostream> #include <math.h> #include <chrono> __global__ void init(int length, float *a, float *b) { int index = blockIdx.x * blockDim.x + threadIdx.x; int stride = blockDim.x * gridDim.x; for (int i = index; i < length; i += stride) { a[i] = 2.3423; b[i] = 1.4214; } } __...
18,143
/************************************************ FILENAME: example3dcuda.cu AUTHOR: Anuva K DESCRIPTION: Transfer subvolume to GPU. Allocate memory for pencil signal. Copy part of signal into the allocated signal. The rest is zero padding. Compute pencil FFT. for now, let us consider 1d signal */ #include <cufft.h...
18,144
#include <iostream> #include "../ginkgo/GOrder.h" #include "../include/lglist.h" #include <thrust/device_vector.h> #define def_dvec(t) thrust::device_vector<t> using namespace std; const int MAX_LENGTH = 20; typedef gpu_ginkgo::Order gorder; __device__ void printList(gpu_linearized_stl::list<gpu_ginkgo::Order, MAX_L...
18,145
/*************************************************************************** * * (C) Copyright 2010 The Board of Trustees of the * University of Illinois * All Rights Reserved * ***************************************************************************/ ...
18,146
#include <stdio.h> #define N 64 // Specify a constant value for array length. #define TPB 32 // Threads per block // A scaling function to convert integers 0,1,...,N-1 // to evenly spaced floats ranging from 0 to 1. __device__ float scale(int i, int n) { return ((float)i) / (n - 1); } // Compute the distance betwee...
18,147
#include <unistd.h> #include <ctype.h> #include <stdio.h> #include <stdlib.h> #define N 50000 #define CORES 50000 /* run the collatz conjecture and return the number of steps */ __global__ void collatz(unsigned int* step) { //Set x to the initial value of step unsigned int x = step[blockIdx.x]; //Reset st...
18,148
#include<stdio.h> int main(void){ // init pointer to data char *data; // specify 32 GB of memory in bytes size_t numBytes = 1024*1024*1024; // Allocate 32 GB cudaError_t err = cudaMallocManaged(&data, numBytes/2); // blab about it printf("malloc status: %s\n",cudaGetErrorString(err)); ret...
18,149
#include<stdio.h> #include<assert.h> __global__ void _array(int *a, int N) { int index = threadIdx.x+blockIdx.x*blockDim.x; int stride = gridDim.x*blockDim.x; for(int i = index; i <N; i+=stride) { a[i] = 1; } } int main(void) { int n = 10000; size_t size = sizeof(int)*n; ...
18,150
#include <stdio.h> #include <time.h> #define DEBUG false // Simple SAXPY operation. __global__ void cuda_saxpy_mat_1(int N, float a, float *x, float *y) { int index = blockIdx.x*blockDim.x + threadIdx.x; if (index < N*N) { y[index] = a * x[index] + y[index]; } } void wait() { puts("Press any key to continue....
18,151
//****************************************************************************** // // File: MetricCenterGpu.cu // This file is a part of project 3 of the course:Foundation of Parallel Computing, // under taken in Fall 2015 at Rochester Institute of Technology. //******************************************************...
18,152
#include "includes.h" __global__ void Return32( int *sum, int *out, const int *pIn ) { extern __shared__ int s[]; s[threadIdx.x] = pIn[threadIdx.x]; __syncthreads(); (void) atomicAdd( &s[threadIdx.x], *pIn ); __syncthreads(); out[threadIdx.x] = s[threadIdx.x]; }
18,153
/* compile as: nvcc bindlessTexture.cu */ #include <stdio.h> #include <stdlib.h> #include <math.h> #define N 1024 // texture object is a kernel argument __global__ void kernel(cudaTextureObject_t tex) { int i = blockIdx.x *blockDim.x + threadIdx.x; float x = tex1Dfetch<float>(tex, i); // do some work using x ....
18,154
#include<iostream> #include<cuda.h> #include<cuda_runtime.h> using namespace std; __global__ void colonel(int *a_d){ //std::cout<<"\nHello Cuda"; //cannot be used in global device // *a_d = 2; printf("\nblockIdx.x: %d\tblockIdx.y: %d\ttheradIdx.x: %d\tthreadIdx.y: %d",blockIdx.x,blockIdx.y,threadIdx.x,threadIdx.y)...
18,155
/* Copyright (c) 1993-2015, NVIDIA CORPORATION. All rights reserved. * * 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, this list of ...
18,156
/****************************************************************************** *cr *cr (C) Copyright 2010 The Board of Trustees of the *cr University of Illinois *cr All Rights Reserved *cr *****************************************************************...
18,157
#include "cuda_runtime.h" #include "kernel.cuh" #include <device_launch_parameters.h> __global__ void LevelDiscretizationKernel(unsigned char* frame, int width, int height, unsigned char scale) { int x = blockDim.x * blockIdx.x + threadIdx.x; int y = blockDim.y * blockIdx.y + threadIdx.y; auto currentIdx = y * wi...
18,158
#include <cuda.h> #include <math.h> #include <chrono> #include <iostream> #define N 1024 typedef unsigned long long int int64_cu; __global__ void is_prime(int64_cu *prime, int64_cu *root, bool *c){ if(*prime<2) {*c = false; return;} if(*prime % 2 == 0) {*c = false; return;} for(int64_cu k = 3+(2*blockIdx...
18,159
#include "layer.cuh" Layer::Layer(int input_shape, int output_shape) { this->input_shape = input_shape; this->output_shape = output_shape; }
18,160
#include "includes.h" __global__ void matrixMultiply3(float* A, float* C, int size) { float CValue = 0; int Row = blockIdx.y * TILE_WIDTH + threadIdx.y; int Col = blockIdx.x * TILE_WIDTH + threadIdx.x; __shared__ float As[TILE_WIDTH][TILE_WIDTH]; for (int k = 0; k < (TILE_WIDTH + size - 1)/TILE_WIDTH; k++) { if (k...
18,161
#include "includes.h" #define N 100000000 __global__ void daxpy(int n, double alpha, double *x, double *y) { for (int idx = blockIdx.x * blockDim.x + threadIdx.x; idx < n; idx += blockDim.x * gridDim.x) { y[idx] += alpha * x[idx]; } }
18,162
#include <iostream> int main() { const int block_size = 1024; const int array_size = 1 << 20; int* h_array = new int[array_size]; for (int i = 0; i < array_size; ++i) { h_array[i] = 1; } int* output = new int[array_size]; cudaEvent_t start; cudaEvent_t stop; // Creating ...
18,163
#include "includes.h" // customDllFunctions.cu ////////////////////////// // Template to write .dlls ////////////////////////// /* Include the following directories for the program to run appropriately: /////////////////////// in the VC++ directories: $(VC_IncludePath); $(WindowsSDK_IncludePath); C:\ProgramData\NVID...
18,164
#include <cuda.h> #include <stdio.h> #include <sys/time.h> #include <time.h> #include <math.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",\ cudaGetErrorString(_m_cudaStat), __LINE__, __FILE__);\ exi...
18,165
#include<iostream> #include<stdio.h> #include<stdlib.h> #include <cuda.h> #include <math.h> int checkResults(float*res, float* cudaRes,int length) { int nDiffs=0; const float smallVal = 0.01f; // Keeping this extra high as we have repetitive addition and sequence matters for(int i=0; i<length; i++) if(fabs(cudaR...
18,166
/* Authors: Anant Shah and Abhishek Nair Roll No: EE16B105 and EE16B060 */ /* Code to implement the convolution operation on images with a regular sparsity pattern. */ /* --------------------------- CONSTRAINTS ---------------------------------- Input Tensor Format : N x H x W x C Input Tensor Size Limit...
18,167
#include <stdio.h> #define N 10000 __global__ void vectorAdd(int *a, int *b, int *c) { int i = blockIdx.x*blockDim.x + threadIdx.x; c[i] = a[i] + b[i]; } __global__ void matrixAdd(int **a,int **b, int**c) { int i = blockIdx.x*blockDim.x + threadIdx.x; int j = blockIdx.y*blockDim.y + threadIdx.y; ...
18,168
#include <stdio.h> /* #define TRACE_DX #define TRACE_DZ #define TRACE_DIFFLUX_UX #define TRACE_DIFFLUX_UY #define TRACE_DIFFLUX_UZ #define TRACE_DIFFLUX_E #define TRACE_UPDATE_RHO #define TRACE_UPDATE_E #define TRACE_UPDATE_U #define TRACE_UPDATE_U_ALT */ #define RADIUS 4 #define TYPE double #define CACHE_LINE_SIZE...
18,169
#include<iostream> __global__ void fill(int * v, std::size_t size) { auto id = blockIdx.x * blockDim.x + threadIdx.x; if( id < size) { v [ id ] = id; } } int main() { std::size_t size = 2048; int * v_h = nullptr; int * v_d = nullptr; cudaMallocHost( &v_h, size * sizeof(int)); //ou : v_h...
18,170
#include<iostream> #define M 6 #define N 6 #define THREADS_PER_BLOCK 256 using namespace std; __global__ void add_matrix(int mat_1[], int mat_2[], int mat_sum[]) { int global_thread_ID = blockIdx.x * THREADS_PER_BLOCK + threadIdx.x; if(global_thread_ID < M * N) mat_sum[global_thread_ID] = mat_1[global_thread_ID] ...
18,171
#include "includes.h" __global__ void Matrix_PermuteRows(const float * A , int Acount, int Acols, const float * B , int Bcount, int Bcols, float * out0 , int out0count, int out0cols) { int id = blockDim.x*blockIdx.y*gridDim.x + blockDim.x*blockIdx.x + threadIdx.x; int id_row, id_col, id_rowNew; if (id<Acount) { i...
18,172
#include "includes.h" __global__ void ConvolutionRowGPU(float *d_Dst,float *d_Src,float *d_Filter,int filterR){ int x =threadIdx.x; int y =threadIdx.y; int k; float sum=0; for (k = -filterR; k <= filterR; k++) { int d = x + k; if (d >= 0 && d < blockDim.x) { sum += d_Src[y*blockDim.x+d] * d_Filter[filterR- k]; } d_Ds...
18,173
#include<stdio.h> __global__ void print() { int i = threadIdx.x; printf("%d\n",i); } int main() { print<<<1,4>>>(); cudaDeviceSynchronize(); cudaDeviceReset(); return 0; }
18,174
/** * FIXME FIXME FIXME: this is just a placeholder * should have groupby+partial aggregate kernel */
18,175
#include<iostream> #include<cstdio> using namespace std; __global__ void sum(int *a,int *b,int n) { int block=256*blockIdx.x; int sum=0; for(int i=block;i<min(block+256,n);i++) { sum=sum+a[i]; } b[blockIdx.x]=sum; } int main() { cout<<"Enter the no of elements:"; int n; cin>>n; int a[n]; for(int i=0;i<n;i...
18,176
#include <stdio.h> #include <time.h> #include <stdlib.h> #include <cuda.h> #define n 6 void fillMatrix(double *w){ double count = 0; for(int i=0; i<n; i++){ for(int j=0; j<n; j++){ w[i*n+j] = count; count++; } } } void print(double *w){ for(int i=0; i<n; i++){ for(int j=0; j<n; j++){ ...
18,177
#include "includes.h" __global__ void createMovieRatingsKernel(const float *weights, const float *initial_hidden_feature_probs, float* movie_rating_probs, int num_movies, int num_hidden_features) { // weights[NUM_MOVIES][5][NUM_FEATURES] // initial_hidden_feature_probs[NUM_FEATURES] // final_movie_ratings[NUM_MOVIES][...
18,178
#include "kernel.cuh" namespace kernel { __device__ void Swap(int* a, int* b) { int temp = *a; *a = *b; *b = temp; } __device__ int Partition(int* arr, int l, int r) { int i = l - 1; int j = r; int v = arr[r]; while (true) { while (arr[++i] < v); while (v < arr[--j]) ...
18,179
/* * Copyright (c) 2012 by Jörn Dinkla, www.dinkla.com, All rights reserved. */ #include <stdio.h> // extern "C" ist notwendig, damit cuModuleGetFunction die Funktion findet extern "C" __global__ void hello() { int i = threadIdx.x; int j = blockIdx.x; printf("Hello World %i %i\n", i, j); }
18,180
#include "includes.h" #define max(a, b) a > b ? a : b #define min(a, b) a < b ? a : b struct Edge{ long long int x; }; ///* //*/ __global__ void update_states(int* parent, int* vertex_state, int n){ int bid = blockIdx.x; int id = bid*blockDim.x + threadIdx.x; if(id < n) vertex_state[id] = parent[id] == i...
18,181
#include <stdio.h> #include <stdlib.h> __global__ void colonel(int *dev_a){ *dev_a = *dev_a + 1; } int main(){ // Declare variables and allocate memory on the GPU. int a[1], *dev_a; cudaMalloc((void**) &dev_a, sizeof(int)); // Intitialize argument a, executed kernel, and store result back in a. a[0] = 1...
18,182
#include <cooperative_groups.h> #include <cuda.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <fstream> #define DTYPE float namespace cg = cooperative_groups; //First Kernel: Repeated call of a shared memory reduction kernel (Wiederholter Aufruf des Kernels, bis Ergebnis fina...
18,183
#include<cuda_runtime.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char **argv){ cudaDeviceProp prop; int count; cudaGetDeviceCount(&count); printf("Number of GPUs on the Node is %d\n", count); for (int i=0; i < count; ++i){ cudaGetDeviceProperties(&prop, i); printf...
18,184
//pass //--blockDim=[8,8] --gridDim=[1,1] #include <cuda.h> #define _2D_ACCESS(A, y, x, X_DIM) A[(y)*(X_DIM)+(x)] ////////////////////////////////////////////////////////////////////////////// //// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF //// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING...
18,185
#include "includes.h" __global__ void convertFlowToRGBA_kernel(uchar4 *d_flowx_out, uchar4 *d_flowy_out, const float *d_flowx_in, const float *d_flowy_in, int width, int height, float lowerLim, float upperLim, float minMag) { const int x = __mul24(blockIdx.x, blockDim.x) + threadIdx.x; const int y = __mul24(blockIdx.y,...
18,186
// // Example from: // https://devblogs.nvidia.com/even-easier-introduction-cuda/ // // Compiles as follows: // nvcc add_v02.cu -o add_v2_cuda // // nvcc is set as follows: // export PATH=/usr/local/cuda-10.0/bin:$PATH #include <iostream> #include <math.h> // CUDA *kernel* function to add the elements of two arrays ...
18,187
/* * Do not change this file */ #include <iostream> #include <fstream> #include <cassert> #include <cstring> #include <string> #include <chrono> #include <cstdlib> #include <ctime> #define MAX_LENGTH 1024 /** * Read file, save edges to array (x_x) and * record the size of each type of edge array (x_x_count). */...
18,188
//pass //--gridDim=64 --blockDim=256 __global__ void testKernel(int *g_odata) { // access thread id const unsigned int tid = blockDim.x * blockIdx.x + threadIdx.x; // Test various atomic instructions // Arithmetic atomic instructions // Atomic addition atomicAdd(&g_odata[0], ...
18,189
/*---------------------------------------- * Por Juan Pablo Pineda 19087 * Alejandra Gudiel 19232 * Oscar Saravia 19322 * Julio Herrera 19402 * Andres Emilio Quinto 18288 * --------------------------------------- * UNIVERSIDAD DEL VALLE DE GUATEMALA * CC3056 - Programacion de Microprocesadores ...
18,190
/* * Copyright 2019 Australian National University * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applic...
18,191
#include "includes.h" __global__ void symmetrize1D( float *h, int *blockPositions, int *blockSizes, int numBlocks ) { int blockNum = blockIdx.x * blockDim.x + threadIdx.x; if( blockNum >= numBlocks ) { return; } // blockSizes are given in terms of atoms, convert to dof const unsigned int blockSize = 3 * blockSizes[blo...
18,192
#include "includes.h" __global__ void kernel(float *array, int size) { int index = blockIdx.x * blockDim.x + threadIdx.x; if (index < size) { array[index] += 1.f; //if (index == 0) // printf("### array[%d] = %f\tArray size: %d\n", index, array[index], size); } }
18,193
#include "includes.h" __global__ void matrixMultTiled(float* d_A, float* d_B, float* d_C, int width) { __shared__ float ds_A[TILE_WIDTH][TILE_WIDTH]; __shared__ float ds_B[TILE_WIDTH][TILE_WIDTH]; int bx = blockIdx.x; int by = blockIdx.y; int tx = threadIdx.x; int ty = threadIdx.y; // Identify the row and column of t...
18,194
#include "includes.h" __global__ void render_depth(float *points3d_polar, unsigned int * depth_render) { int x = blockIdx.x * TILE_DIM + threadIdx.x; int y = blockIdx.y * TILE_DIM + threadIdx.y; int w = gridDim.x * TILE_DIM; int h = w /2; for (int j = 0; j < TILE_DIM; j+= BLOCK_ROWS) { int iw = x; int ih = y + j; int ...
18,195
#include <iostream> #include <cstdio> #include <string> #define TOGG(k) ( ( ( (k) & 1 ) << 5 ) ) #define RAN(charac) ( 65 + ( charac % 26 ) + TOGG ( charac ) ) using namespace std; __global__ void RunLengthEncodingComputation (char *orig, int *_encoXst, int n) { int index = ( (blockIdx.x * blockDim.x) + threadId...
18,196
// ######################################################################## // Practical Course: GPU Programming in Computer Vision // Technical University of Munich, Computer Vision Group // ######################################################################## #include <cuda_runtime.h> #include <iostream> using na...
18,197
//xfail:ASSERTION_ERROR //--blockDim=1024 --gridDim=1 --no-inline #define tid (blockIdx.x * blockDim.x + threadIdx.x) __device__ float multiplyByTwo(float *v, unsigned int index) { return v[index] * 2.0f; } __device__ float divideByTwo(float *v, unsigned int index) { return v[index] * 0.5f; } typedef float(...
18,198
#include <thrust/device_vector.h> #include <thrust/host_vector.h> #include <thrust/functional.h> #include <thrust/transform.h> #include <iostream> int main() { // Alocação do vetor na CPU e leitura de dados da entrada-padrão thrust::host_vector<double> vcpu(2518); for(int i=0;i<2518;i++) std::cin>>v...
18,199
#include <iostream> #include <stdlib.h> #define N (2048*2048) #define THREADS_PER_BLOCK 512 using namespace std; __global__ void mykernal() { // Run on device and called by host } __global__ void add(int *a, int *b, int *c, int n) { // *c = *a + *b; int index = threadIdx.x + blockIdx.x * blockDim.x; if (...
18,200
#include "stdio.h" #include "time.h" #include <iostream> // Defining Number of elements in Array #define N 10000000 // Defining vector addition function for CPU void cpuAdd(int *h_a, int *h_b, int *h_c) { int tid = 0; while (tid < N) { h_c[tid] = h_a[tid] + h_b[tid]; tid += 1; } } int main(void) { int *h_a,...