serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
22,101
#include "includes.h" __global__ void relax(int* U, int* F, int* d, size_t gSize, int* adjMat) { int globalThreadId = blockIdx.x * blockDim.x + threadIdx.x; if (globalThreadId < gSize) { if (F[globalThreadId]) { for (int i = 0; i < gSize; i++) { if(adjMat[globalThreadId*gSize + i] && i != globalThreadId && U[i]) { ato...
22,102
/* @Author: 3sne ( Mukur Panchani ) @FileName: q1FindSubstring.cu @Task: CUDA program that finds a substring in a given string. */ #include <stdio.h> #include <stdlib.h> #include <cuda_runtime.h> void resetBuf(char* b, int blen) { for ( int i = 0; i < blen; i++ ) b[i] = '\0'; } __g...
22,103
void MatrixMultiply_Banded(double *x,double *b,int m,int n,int Bandwidth) { int i,j; int j_start,j_end; double A; for(i=0;i<m;i++) { if(i>=0 && i<Bandwidth-1) {j_start = Bandwidth-1-i;j_end = n;} else if(i>=Bandwidth-1 && i<m-Bandwidth+1) {j_start = 0;j_end = n;} else if(i>=m-Bandwidth+1 && i<m) {j_s...
22,104
#include "cuda.h" __device__ float integration(float *data, int length, int channel_amount) { float sum = 0; for (int i = 0; i < length; i++) { sum += data[i*channel_amount]; } return sum; } __global__ void remove_empty(float *inds, int *anchors, float *view, int *anchors_shape, int *view_shap...
22,105
/* * Copyright (c) 2022 Mohamed Khaled <Mohamed_Khaled_Kamal@outlook.com> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the ...
22,106
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <time.h>//Time heading //Password Cracking using CUDA __device__ char* encryptDecrypt(char* tempPassword){ char * generatedPwd = (char *) malloc(sizeof(char) * 11); generatedPwd[0] = tempPassword[0] + 2; generatedPwd[1] = te...
22,107
#include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include <assert.h> #ifndef THREADS_PER_BLOCK #define THREADS_PER_BLOCK 1024 #endif //#define VERBOSE //#define PROF #define CUDA_ERROR_CHECK #define CudaSafeCall( err ) __cudaSafeCall( err, __FILE__, __LINE__ ) #define CudaCheckError() __cudaCheckError...
22,108
#include <iostream> #include <stdio.h> #include <math.h> #define kx 3 #define ky 3 #define nx 224 #define ny 224 #define ni 64 #define nn 64 #define batch 64 #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true) { if (...
22,109
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> #include <limits.h> #define M_PI 3.1415926535897 #define VECTOR_COUNT 2 cudaError_t computeElementsHelper(int* a, int* b, int* lengthNoSqrt, int* dotProduct, int N, int blockSi...
22,110
template<typename Destination, typename Data> __global__ void absArrays(size_t elements, Destination *dst, Data *src) { const size_t kernelIndex = blockDim.x * blockIdx.x + threadIdx.x; if (kernelIndex < elements) { dst[kernelIndex] = abs(src[kernelIndex]); } }
22,111
extern "C" { __global__ void rgb2gray(uchar3 *dataIn, unsigned char *dataOut, int imgHeight, int imgWidth) { int xIndex = threadIdx.x + blockIdx.x * blockDim.x; int yIndex = threadIdx.y + blockIdx.y * blockDim.y; if (xIndex < imgWidth && yIndex < imgHeight) { uchar3 rgb = dataIn[yIndex * imgWi...
22,112
#include<iostream> __global__ void add(int a,int b,int *c) { *c = a+b; } int main() { int c; int *dev_c; cudaMalloc((void **)&dev_c,sizeof(int)); add<<<1,1>>>(2,7,dev_c); cudaMemcpy(&c,dev_c,sizeof(int),cudaMemcpyDeviceToHost); std::cout<<c<<std::endl; cudaFree(dev_c); return 0; }
22,113
#include <stdio.h> #include <stdlib.h> #define SIZE 1000 __global__ void demo(int * p){ int tx=threadIdx.x; int bx=blockIdx.x; int thid = tx+bx*blockDim.x; // Some of the threads try to access memory out of array boundary. // The program may not get any error message, but will pose a potential bug. p[thid]=t...
22,114
/* 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 ...
22,115
#include "includes.h" __global__ void tileMatMul(float* matA, float* matB, float* matC, int aRows, int aCols, int bRows, int bCols, int cRows, int cCols) { //define row and column values int Row = blockIdx.y * TILE_DIM + threadIdx.y; int Col = blockIdx.x * TILE_DIM + threadIdx.x; //shared memory arrays __shared__ floa...
22,116
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <cuda.h> #include <cuda_runtime.h> #include <time.h> #define dT 0.2f #define G 0.6f //#define BLOCK_SIZE 32 //#define BLOCK_SIZE 64 //#define BLOCK_SIZE 128 //#define BLOCK_SIZE 256 #define BLOCK_SIZE 512 // Global variables int num_planets; int num_t...
22,117
#include "includes.h" __device__ float Sat(float r, float g, float b){ float min = fmin(fmin(r, g), b); float max = fmax(fmax(r, g), b); float delta = max - min; float S = max != 0.0f ? delta / max : 0.0f; return S; } __global__ void FilmGradeKernelC( float* p_Input, int p_Width, int p_Height, float p_ContR, float p_Co...
22,118
#include "includes.h" __global__ void conv_2d(int* Mat, int* res, int n) { int row = blockIdx.y * blockDim.y + threadIdx.y; int col = blockIdx.x * blockDim.x + threadIdx.x; int start_r = row - MASK_OFFSET; int start_c = col - MASK_OFFSET; int temp = 0; for (int i = 0; i < MASK_LEN; i++) { for (int j = 0; j < MASK_LE...
22,119
#include <iostream> #include <cuda.h> using namespace std; ///usr/local/bin/nvcc mult-matriz-vector.cu -o mult.out __global__ void MultMatrizVectKernel(float *A, float *B, float *C, int n) { int i = n * blockIdx.x; float sum; if(i < n*n) { for(int j = 0; j < n ; ++j) { sum += A[i + j] * B[j];...
22,120
#include <fstream> #include <iomanip> #include <string> #include <thrust/for_each.h> #include <thrust/host_vector.h> #include <thrust/tuple.h> #include <thrust/iterator/zip_iterator.h> typedef thrust::tuple<double, double, double> CVec3; struct functor_output_tuple : public thrust::unary_function<CVec3, void...
22,121
//Based on the work of Andrew Krepps #include <iostream> #include <random> #include <chrono> #include <stdio.h> static const int CYPHER_OFFSET = 3; __global__ void add(int * a, int * b, int * c) { const unsigned int thread_idx = (blockIdx.x * blockDim.x) + threadIdx.x; c[thread_idx] = a[thread_idx] + b[t...
22,122
// PGPGU Class: Hello World #include<stdio.h> #include<stdlib.h> #include<cuda.h> __global__ void hello_kernel(char *odata, int num) { char hello_str[12]="Hello CUDA!"; int idx = blockIdx.x*blockDim.x+threadIdx.x; if (idx < num) odata[idx]=hello_str[idx]; } int main(void) { char *h_data,*d_data; const int st...
22,123
#include "includes.h" __global__ void build_expected_output(int *output, int n_rows, int k, const int *labels) { int row = threadIdx.x + blockDim.x * blockIdx.x; if (row >= n_rows) return; int cur_label = labels[row]; for (int i = 0; i < k; i++) { output[row * k + i] = cur_label; } }
22,124
/*---------------------------------------------------------------------- Program pdf0.c computes a pair distribution function for n atoms given the 3D coordinates of the atoms. ----------------------------------------------------------------------*/ #include <stdio.h> #include <math.h> #include <time.h> #include <stdli...
22,125
#include "includes.h" __global__ void global_memory_kernel(int *d_go_to_state, unsigned int *d_failure_state, unsigned int *d_output_state, unsigned char *d_text, unsigned int *d_out, size_t pitch, int m, int n, int p_size, int alphabet, int num_blocks ) { int idx = blockIdx.x * blockDim.x + threadIdx.x; int effective...
22,126
#include <cuda_runtime.h> #include <stdio.h> #include <sys/time.h> double seconds(){ struct timeval tp; struct timezone tzp; int i = gettimeofday(&tp,&tzp); return ((double)tp.tv_sec+(double)tp.tv_usec*1.e-6); } void initialData(float *ip, int size){ for (int i = 0; i < size; i ++){ ip...
22,127
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <cuda.h> #include <cuda_runtime.h> #define N (1024) __global__ void inc(int *s, int *d, int len) { int i,j; int part; // 各スレッドが担当するデータの個数 int idx_start, idx_end; // 各スレッドの担当範囲 part = len / (gridDim.x * blockDim.x); // blockDim:1ブロック中のスレッド数 idx_sta...
22,128
#include <stdio.h> #include <stdlib.h> #include <sys/stat.h> #include <ctype.h> #include <fcntl.h> #include <unistd.h> #include <sys/mman.h> #include <time.h> #include <sys/time.h> #include "imageFilter_kernel.cu" #define IMG_DATA_OFFSET_POS 10 #define BITS_PER_PIXEL_POS 28 int swap; void test_endianess(); void sw...
22,129
#include "conv2d-bias-add.hh" #include "conv2d-bias-add-grad.hh" #include "graph.hh" #include "../runtime/graph.hh" #include "../runtime/node.hh" #include "../memory/alloc.hh" #include "ops-builder.hh" #include <cassert> #include <stdexcept> namespace ops { Conv2DBiasAdd::Conv2DBiasAdd(Op* z, Op* bias) : ...
22,130
#include<stdio.h> #include<stdlib.h> #include<time.h> #include<cuda_runtime.h> #define THREAD_NUM 256 #define MATRIX_SIZE 1000 int blocks_num = (MATRIX_SIZE + THREAD_NUM - 1) / THREAD_NUM; void generateMatrix(float *a, float *b) //a for matrix b for vector { int i; int size = MATRIX_SIZE * MATRIX_SIZE; for (i = ...
22,131
#include <stdio.h> #include <stdlib.h> #include <limits.h> #include <string.h> #include <sys/time.h> #include <time.h> #include <iostream> using namespace std; /*structure of the nodes of the tree*/ __host__ __device__ int strcmp_(char* str1,char* str2){ const unsigned char* ptr1= (const unsigned char*)str1; con...
22,132
#define M_PI 3.14159265358979323846 #include <cstdio> #include <cstdlib> #include <ctgmath> #include <ctime> //#include <complex> // For the CUDA runtime routines (prefixed with "cuda_") //#include <cuda.h> #include <curand_kernel.h> #include <curand.h> #include <cuComplex.h> //#include <cuda_runtime.h> //#include <d...
22,133
#include "includes.h" __global__ void kernel_move_inv_write(char* _ptr, char* end_ptr, unsigned int pattern) { unsigned int i; unsigned int* ptr = (unsigned int*) (_ptr + blockIdx.x*BLOCKSIZE); if (ptr >= (unsigned int*) end_ptr) { return; } for (i = 0;i < BLOCKSIZE/sizeof(unsigned int); i++){ ptr[i] = pattern; } ret...
22,134
/* 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,float 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 va...
22,135
#include <stdio.h> __global__ void add(int *a, int *b, int *c){ *c = *a + *b; } int main(void){ int a,b,c; int *d_a,*d_b,*d_c; int size = sizeof(int); cudaMalloc((void **)&d_a,size); cudaMalloc((void **)&d_b,size); cudaMalloc((void **)&d_c,size); a = 3; b = 5; cudaMemcpy(d_a,&a,size,cudaMemcpyHostToDevic...
22,136
/** * @file collateSegments.cu * @date Spring 2020, revised Spring 2021 * @author Hugo De Moraes */ #include <stdio.h> #include <stdlib.h> /** * Scans input in parallel and collates the indecies with important data * * @param src the original unfiltered array * @param scanResult the output array of strongestNe...
22,137
#include<iostream> #include<stdlib.h> #include<time.h> #define N 999999 #define nblocks 100 using namespace std; __global__ void cudaArrayMax(float *a, float *b) { int id = threadIdx.x + blockDim.x *blockIdx.x; int stride = nblocks; __shared__ float cache[nblocks]; float thmax = a[id]; for (int ...
22,138
// tests cuEventCreate #include <iostream> #include <memory> using namespace std; #include <cuda.h> __global__ void longKernel(float *data, int N, float value) { for(int i = 0; i < N; i++) { data[i] += value; } } int main(int argc, char *argv[]) { int N = 102400; // * 1024; CUstream stream...
22,139
// mul 2 arr(2D) on device-GPU
22,140
#include<stdio.h> __global__ void myKernel(int64_t **dA) { for (int i = 0; i < 2; i++) { for (int j = 0; j < 256*(i+1); j++) { dA[i][j] = dA[i][j] + 1; } } } extern "C" { void kernelLOW(int64_t **hPtrs, size_t *hPtrSizes, int64_t N) { int64_t **dA = (int64_t**)malloc(siz...
22,141
#include <iostream> using namespace std; int print_cuda_version() { int count = 0; if (cudaSuccess != cudaGetDeviceCount(&count)) { return -1; } if (count == 0) { return -1; } for (int device = 0; device < count; ++device) { cudaDeviceProp prop; if (cudaSucc...
22,142
#include <stdio.h> #include <stdlib.h> #include <time.h> #include "cuda_runtime.h" #include "device_launch_parameters.h" #include "common.h" #define SHARED_ARRAY_SIZE 128 __global__ void smem_static_test(int * in, int * out, int size) { int tid = threadIdx.x; int gid = blockIdx.x * blockDim.x + threadIdx.x; __s...
22,143
#include "includes.h" /**************************************************************************** Floyd - Warshall Algorithm developed using CUDA. A 2011-2012 assignement for Parallel Programming Course of Electrical and Computer Engineering Department in the Aristotle Faculty of Enginnering - Thessaloniki. ********...
22,144
/** * Adds up 1,000,000 times of the block ID to * a variable. * What to observe/ponder: * - Any difference between shared and global memory? * - Does the result differ between runs? */ #include <stdio.h> __device__ __managed__ volatile int global_counter[2]; void check_cuda_errors() { cudaError_t rc; ...
22,145
#include <math.h> #include <cuda_runtime.h> // the rbf kernel function __host__ __device__ float rbf_kernel(int tx, int ty, float *a, float *b, int len, int invert) { float sigma = 10.; float beta = 0.5/sigma/sigma; float d = 0; float k = 0; float x,y; if(invert == 0) { for(int i=0;i<len;i++) { x = a[tx*l...
22,146
#include <stdio.h> #include <stdlib.h> #include <math.h> #define err 0.000001 __device__ void f(float x, float *y) { // *y = exp(x)-5*pow(x,2); // slide *y = ((70 + 1.463/pow(x, 2)) * (x - 0.0394)) - (0.08314 * 215); } __device__ void g(float x, float *y) { // *y = exp(x)-10*x; // slide *y = 70 - 1.4...
22,147
/** @file * Name: Parallel LU Decomposition - CUDA Version * Authored by: Team Segfault * Description: This program performs Lower/Upper decomposition on a square matrix and * subsequently solves the associated system of equations with Forward and Backward substitution. * Implementation Date: 11/23/2020 */ ...
22,148
#include <stdio.h> #include <stdlib.h> // cuda include #include <cuda.h> #include <curand.h> #include <curand_kernel.h> typedef struct{ int *gene; int fitness; }Indiv; __device__ float Grand(curandState *state){ //get index int index = blockIdx.x * blockDim.x + threadIdx.x; //gen local_state curandState...
22,149
//fail: assertion //--blockDim=64 --gridDim=64 --no-inline #include <stdio.h> #include <cuda.h> #include <stdlib.h> #include <assert.h> #define N 2//64 __device__ int f(int x) { return x + 1; } __global__ void foo(int *y) { *y = f(2); }
22,150
#include <iostream> using namespace std; #include <thrust/reduce.h> #include <thrust/sequence.h> #include <thrust/host_vector.h> #include <thrust/device_vector.h> __global__ void fillKernel(int *a,int n) { int tid = blockIdx.x * blockDim.x + threadIdx.x; if(tid < n) a[tid] = tid; } void fill(int * d_a, int n...
22,151
#include "includes.h" __global__ void KernelNormalMul(float *Mat1,float *Mat2,float *Mat3,int m,int n,int p){ int j = threadIdx.y + blockDim.y * blockIdx.y; // row int i = threadIdx.x + blockDim.x * blockIdx.x; // col if((j<m) && (i<p)){ float value=0.0; for(int k=0;k<n;++k){ value+=Mat1[n*j+k]*Mat2[p*k+i]; } Mat3[p*j...
22,152
#include <stdio.h> #include <stdlib.h> #include <sys/time.h> #define NUM 10000 #define SEED 18 #define CUDA_ERROR_EXIT(str) do{\ cudaError err = cudaGetLastError();\ if(err!=cudaSuccess){\ printf("Cuda Error: %s for %s \n",cudaGetErrorString(err),str);\ exit(-1);\ }\ }while(0); #define TD...
22,153
#include "includes.h" __global__ void kernel() { }
22,154
#include <stdio.h> #include <assert.h> #include <stdlib.h> #include <errno.h> #include <time.h> #include <stdbool.h> /* References - https://www.drdobbs.com/parallel/cuda-supercomputing-for-the-masses-part/208801731?pgno=2 */ /* reverseArray - reverses an array in kernel @params int*A, int dim_a...
22,155
/* * File: mandel.c * Author: davidr * * Created on May 22, 2013, 9:42 AM */ #include <stdlib.h> #include <math.h> #include <stdio.h> #include <time.h> # define NPOINTS 2000 # define MAXITER 2000 struct complex{ double real; double imag; }; void checkCUDAError(const char*); __global__ void mandel_nump...
22,156
/* To query the number of CUDA-capable GPUs in a host and the capabilities of each GPU. Run it on the Hummingbird GPU node and report the results. */ #include<stdio.h> int main() { int nDevices; cudaGetDeviceCount(&nDevices); for (int i = 0; i < nDevices; i++) { cudaDeviceProp prop; cuda...
22,157
/* 1.Input Data 2.What Need to be calculated 3.Design your threads and thread blocks 4. Implementation on CPU and GPU 5. Built in check points 6. Output data */ #include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> #include<cuda.h> #include<cuda_runtime.h> #include<time.h> #define Nu...
22,158
#include <stdio.h> #include <cuda_runtime.h> #include <cuda.h> #include <string.h> int log2 (int i) { int r = 0; while (i >>= 1) r++; return r; } int bit_reverse (int w, int bits) { int r = 0; for (int i = 0; i < bits; i++) { int bit = (w & (1 << i)) >> i; r |= bit << (bits - i - 1); } return r; } __globa...
22,159
#include "includes.h" #define INF 2147483647 extern "C" { } __global__ void oneMove(int * tab, int dist, int pow, int blocksPerTask, int period) { __shared__ int tmp_T[1024]; __shared__ int begin; if(threadIdx.x == 0) begin = (blockIdx.x/blocksPerTask)*dist*2 + (blockIdx.x%blocksPerTask)*512*pow; __syncthreads...
22,160
/* * Solves the Panfilov model using an explicit numerical scheme. * Based on code orginally provided by Xing Cai, Simula Research Laboratory * and reimplementation by Scott B. Baden, UCSD * * Modified and restructured by Didem Unat, Koc University * * Refer to "Detailed Numerical Analyses of the Aliev-Panfi...
22,161
#include<bits/stdc++.h> using namespace std; __global__ void add(int * dev_a[], int * dev_b[], int * dev_c[]) { dev_c[threadIdx.x][blockIdx.x]=dev_a[threadIdx.x][blockIdx.x]+dev_b[threadIdx.x][blockIdx.x]; } __global__ void add2(int * dev_a, int * dev_b, int * dev_c) { dev_c[threadIdx.x + blockDim.x * blockId...
22,162
/******************************************************************************* * serveral useful gpu functions will be defined in this file to facilitate * the extension scheme ******************************************************************************/ typedef struct { double sR; double sL; } double_eno_de...
22,163
#include <stdio.h> #define NUM_BLOCKS 16 #define BLOCK_WIDTH 1 __global__ void hello() { printf("hello world, I am a thread in block %d\n",blockIdx.x); } int main(int argc, char **argv) { // lauch the kernel hello<<<NUM_BLOCKS,BLOCK_WIDTH>>>(); //force the printf() to flush cudaDeviceSynchroniz...
22,164
// Testing class objects passing // Author: alpha74 #include "cuda_runtime.h" #include "device_launch_parameters.h" #include <iostream> #include <stdio.h> using namespace std; class Marks { public: int m1; int m2; // Default ctor Marks() { m1 = 0; m2 = 0; } }; const int N = 10; __global__ void...
22,165
#include<stdio.h> void CPUFunction() { printf("This function is defined to run on the CPU.\n"); } __global__ void GPUFunction() { printf("This function is defined to run on the GPU.\n"); printf("This function is defined to run on the GPU.\n"); printf("This function is defined to run on the GPU.\n"); } int main()...
22,166
#include <cstdio> __global__ void helloWorldKernel() { printf("Hello World from GPU\n"); } __global__ void helloWorldwithThreadKernel() { printf("Hello World from GPU block: %d thread: %d\n", blockIdx.x, threadIdx.x); } int main() { std::printf("Hello World from CPU\n"); std::printf("----------------...
22,167
#include <stdio.h> #include "VecAdd_kernel.cu" int main(int argc, char *argv[]) { int N = 100; unsigned int size; float *d_A, *d_B, *d_C; float *h_A, *h_B, *h_C; /**************************** * Initialization of memory * ****************************/ size = N * sizeof(float); h_A = (float *) malloc(size); ...
22,168
#include "includes.h" __global__ void rMD_ED_D(float *S, float *T, int window_size, int dimensions, float *data_out, int trainSize, int gm) { long long int i, j, p; float sumErr = 0, dd = 0; int idx = blockIdx.x * blockDim.x + threadIdx.x; if (gm == 0) { extern __shared__ float T2[]; // offset training set int s = ...
22,169
#include <thrust/device_vector.h> #include <thrust/host_vector.h> #include <thrust/random/linear_congruential_engine.h> #include <thrust/random/uniform_real_distribution.h> #include <iostream> // nvcc -std=c++14 -O3 tarefa2.cu -o t2 && ./t2 struct fillRand { thrust::uniform_real_distribution<double> dist; thr...
22,170
#include "includes.h" __global__ void backProp1(float* in, float* dsyn1, float* layer1, float* syn2, float* label, float* out) { int j = blockDim.x*blockIdx.x + threadIdx.x; int k = blockDim.y*blockIdx.y + threadIdx.y; float error = 0.0; #pragma unroll for (int l=0; l < 10; ++l) error += (label[l] - out[l]) * syn2[k*1...
22,171
#include "includes.h" __global__ void r_step( float4 *__restrict__ devPos, float4 *__restrict__ deviceVel, unsigned int numBodies, float dt) { int index = blockIdx.x * blockDim.x + threadIdx.x; if (index > numBodies) {return;}; devPos[index].x += deviceVel[index].x * dt; devPos[index].y += deviceVel[index].y * dt; devP...
22,172
#if __CUDA_ARCH__ < 600 #define atomicMin_block(X,Y) atomicMin(X,Y) #define atomicAdd_block(X,Y) atomicAdd(X,Y) #endif __global__ void glo(int * x, int * y) { atomicAdd(x+3,1); } __global__ void blo(int * x, int * y) { atomicAdd_block(x+3,1); } __global__ void sha(int * x, int * y) { __shared__ int c...
22,173
#include "includes.h" __global__ void dev_get_potential_energy( float *partial_results, float eps2, float *field_m, float *fxh, float *fyh, float *fzh, float *fxt, float *fyt, float *fzt, int n_field) { extern __shared__ float thread_results[]; unsigned int i, j; float dx, dy, dz, r, dr2, potential_energy = 0; for (j=t...
22,174
#include <iostream> #include <set> #include <algorithm> #include <assert.h> #include "cuda_runtime.h" using namespace std; #define ITERATIONS (10000) //times of memory visit for each thread #define KB (1024/sizeof(int)) #define MB (KB*1024) #define MAX_N...
22,175
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #define MAXBLOCKS 1 #define MAXTHREADS 10 //Helper method cudaError_t addWithCuda(int *c, const int *a, const int *b, unsigned int size); //__global__ (paralellized method) __global__ void VectorAdd(int *c, const int *a, const int *...
22,176
#include <stdio.h> #include <stdlib.h> #include <math.h> #define IDX(i,j,cols,mbc) i*cols + j + mbc __global__ void heat2d_update(int Nx, int Ny, int mbc, double dx, double dy, double dt, double ***q, double*** qp); __global__ void setup_arrays2d_cuda(int Nx, int Ny, int mbc, ...
22,177
#include <time.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <cuda_runtime.h> __global__ void GPUEuler2(float *y, float t_i, float delta,int N) { int myID = threadIdx.x + blockDim.x * blockIdx.x; if(myID < N) { y[myID] = y[myID] + delta * (4*t_i - y[myID]+3+myID); } } int main(int argc, ch...
22,178
#include <stdio.h> #include <math.h> #include <time.h> #include <unistd.h> #include <cuda_runtime_api.h> #include <errno.h> #include <unistd.h> /****************************************************************************** * This program takes an initial estimate of m and c and finds the associated * rms error. It...
22,179
#include <iostream> __global__ void kernel() { printf("test\n"); } int main(int, char**) { kernel<<<1,2>>>(); cudaDeviceSynchronize(); std::cout << "Hello, world!\n"; }
22,180
#include "includes.h" __global__ void add(int n, float *x, float *y) { for (int i = 0; i < n; ++i) { y[i] = x[i] + y[i]; } }
22,181
/******************************* *** *** TASK-3 *** NAME: - SOAIBUZZAMAN *** Matrikel Number: 613488 *********************************/ #include <stdio.h> #include <stdlib.h> #include <cuda.h> const int N = 200; const int block_size = 32; const int num_blocks = N / block_size + (N % block_size == 0 ? 0 : 1); // Devi...
22,182
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <sys/time.h> #include <cuda_runtime.h> // RG*RG*MAXN must fit within mytype #define MAXN 100000 #define RG 10 #define USECPSEC 1000000ULL #define nTPB 256 typedef double mytype; void conv(const mytype *A, const mytype *B, mytype* out, int N) { f...
22,183
#include <stdio.h> #include <stdlib.h> #define block_size 32 #define vector_size 1000000 __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[...
22,184
#include <stdio.h> // Function that catches the error void testCUDA(cudaError_t error, const char *file, int line){ if (error != cudaSuccess){ printf("Error in file %s at line %d \n", file , line); exit(EXIT_FAILURE); } } // Has to be define in the compilation in order to get the correct value of // of th...
22,185
#include <stdio.h> #include <cuda.h> int main() { /* Get Device Num */ int cudaDeviceNum = 0; cudaGetDeviceCount(&cudaDeviceNum); printf("%d devices found supporting CUDA\n", cudaDeviceNum); if ( cudaDeviceNum == 0 ) { printf("No GPU\n"); return 0; } for (int i = 0; i < cudaDeviceNum; i++) { cudaDeviceP...
22,186
#include "includes.h" /* * get_da_peaks is a gpu_accelerated local maxima finder * [iprod] = get_da_peaks(i1, r, thresh); * Written by Andrew Nelson 7/20/17 * * * * */ // includes, project // main __global__ void da_peaks(float *d_i1, float thresh, int m, int n, int o) { int tx = threadIdx.x; int ty = threadIdx.y; ...
22,187
#include <stdlib.h> #include <stdio.h> #include <vector> #include <math.h> #include <cuda_runtime.h> #define N (1 << 12) #define tile_size 32 #define block_size tile_size void checkCUDAError(const char *msg) { cudaError_t err = cudaGetLastError(); if( cudaSuccess != err) { fprintf(stderr, "Cuda error:...
22,188
#include <stdio.h> #include <time.h> #define N 10000000 //Job Size = 1K, 10K, 100K, 1M and 10M #define M 128 //Threads per block = 128 #define R 2 //Radius = 2,4,8,16 // CUDA API error checking macro static void handleError(cudaError_t err, const char *file, ...
22,189
#include <cuda_runtime.h> #include <stdlib.h> #include <stdio.h> #define N 16 int testfunc() { float* A; float* B; float* C; cudaMalloc((void**)&A, sizeof(float)*N); cudaMalloc((void**)&B, sizeof(float)*N); cudaMalloc((void**)&C, sizeof(float)*N); //cudaFree(A); //cudaFree(B); cu...
22,190
__global__ void divmod(int *a, int *q, int *r, int *d){ int tmp = a[0]; /* q[0] = tmp/d[0]; */ r[0] = tmp%d[0]; }
22,191
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <math.h> __global__ void add(int *a,int *b){ int tid = threadIdx.x; int y=0,z,i=1; z = a[tid]; while(z!=0){ y += (z % 8)*i; i = i*10; z = z/8; } b[tid] = y; } int main(void){ int n,a[1000],b[1000],i,size,*d_a,*d_b...
22,192
#include "includes.h" #define N 1200 #define THREADS 1024 __global__ void matrixMultKernel (double *a, double *b, double *c, int n) { int row = blockIdx.y * blockDim.y + threadIdx.y; int col = blockIdx.x * blockDim.x + threadIdx.x; if((row < n) && (col < n)){ double v = 0; for(int k = 0; k < n; k++){ v += a[row * n...
22,193
int launch_bf_sig_insert(unsigned char *d_sig_cache, size_t num_sigs, unsigned char *d_bloom_filter) { /* TODO: Call kernel that inserts signatures into bloom filter */ return -1; }
22,194
#include <iostream> using namespace std; int main () { int device_count; cudaGetDeviceCount(&device_count); cudaDeviceProp dp; cout << "CUDA device count: " << device_count << endl; for(int i = 0; i < device_count; i++) { cudaGetDeviceProperties(&dp, i); cout << i << ": " << dp.name << " with CUD...
22,195
__global__ void matmul(float *a, float *b, float *c, int n) { // compute each thread's row int row = blockIdx.y * blockDim.y + threadIdx.y; // compute each thread's column int col = blockIdx.x * blockDim.x + threadIdx.x; int temp_sum = 0; if((row < n) && (col < n)) { // Iterate of ro...
22,196
#include<iostream> #include<time.h> #include<cstdlib> #include<stdlib.h> using namespace std; __global__ void matrixMultiplication(int* A,int* B,int* C,int N); void mm(int* A,int* B,int* C,int N); int main() { cudaEvent_t start,end,start1,end1; cudaEventCreate(&start); cudaEventCreate(&end); cudaEventCreate(&st...
22,197
// // Created by root on 2020/11/12. // #include "cuda_runtime.h" #include "stdio.h" __global__ void unrollTestKernel(int *count) { #pragma unroll 4 for (int i = 0; i < 20; i++) { (*count)++; } } int main() { int *n_h = (int *) malloc(sizeof(int ) ); *n_h = 0; int *h_d; cudaMalloc(&h_...
22,198
/** Thrust Library **/ #include <thrust/random.h> #include <thrust/device_vector.h> #include <thrust/transform.h> #include <thrust/iterator/counting_iterator.h> #include <thrust/host_vector.h> #include <thrust/device_vector.h> /** Std library **/ #include <iostream> #include <stdio.h> #include <stdlib.h> #include <mat...
22,199
#include "includes.h" __global__ void group_point_gpu(int b, int n, int c, int m, int nsample, const float *points, const int *idx, float *out) { int batch_index = blockIdx.x; points += n*c*batch_index; idx += m*nsample*batch_index; out += m*nsample*c*batch_index; int index = threadIdx.x; int stride = blockDim.x; for...
22,200
/* * Copyright 1993-2009 NVIDIA Corporation. All rights reserved. * * NVIDIA Corporation and its licensors retain all intellectual property and * proprietary rights in and to this software and related documentation and * any modifications thereto. Any use, reproduction, disclosure, or distribution * of this ...