serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
601
/* from: https://devblogs.nvidia.com/parallelforall/even-easier-introduction-cuda/ * Jialin Liu * Simple starting cpp cuda program * Jun 24 2017, Saturday, 2:09pm * Compile and test on Maeve, a 3GPU single node at NERSC, LBNL, CA. */ #include<iostream> #include<math.h> using namespace std; //CUDA kernel functio...
602
#include <stdio.h> /* //=========== PART-1 ======================== __global__ void hello() { } int main(void) { hello<<< 1, 1 >>>(); cudaDeviceSynchronize(); printf("Hello World\n"); return 0; } */ //=========== PART-2 ======================== __device__ const char *STR = "HELLO WORLD!"; const char STR_LENGTH...
603
__global__ void exampleDevice( float * d ) { int idx = blockIdx.x * blockDim.x + threadIdx.x; d[ idx ] = idx; } extern "C" void exampleHost( float * h, int blockDim, int threadDim ) { float * d; cudaMalloc( ( void** )&d, blockDim * threadDim * sizeof( float ) ); exampleDevice<<<blockDim, threadD...
604
#include "includes.h" __global__ void kernel_512_one_128(float *A, float *B, float *bnBias, float *bnScale, float *C) { int tile = blockIdx.x, in_channel = threadIdx.x, line = threadIdx.y; int ind = line*128 + in_channel; extern __shared__ float shared_[]; float *weights = shared_ + 512*4, *output = weights + 128*64, ...
605
//Parallel programming for many core GPUs //Name: Gesu Bal //Instructor name: Meilin Liu /* this is a simple cuda program calculating Tiled Matrix vector multiplication for 2 dimensions on GPU device I multiplied two double two-dimensional matrices A, B on the device GPU. After the device matrix multiplication kernel ...
606
#include <stdio.h> int main() { int dimx = 10; int num_bytes = dimx * sizeof (int); // device and host pointers int *d_a = 0; int *h_a = 0; /*Aloca memria na CPU para n inteiros*/ h_a = (int*) malloc(num_bytes); printf("%i\n", num_bytes); /*Aloca memria na GPU para n inteiros*...
607
// // include files // #include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> //#include <cutil_inline.h> #include "cuda_runtime.h" //#include "MyFirst_kernel.cu" __global__ void my_first_kernel(float *x) { // Uncomment line below and define integer "tid" as global index to vector "x" int tid ...
608
#include "includes.h" __global__ void kernel_test7_write(char* _ptr, char* end_ptr, char* _start_ptr, unsigned int* err) { unsigned int i; unsigned int* ptr = (unsigned int*) (_ptr + blockIdx.x*BLOCKSIZE); unsigned int* start_ptr = (unsigned int*) _start_ptr; if (ptr >= (unsigned int*) end_ptr) { return; } for (i = ...
609
/** * @file CUDA_Hardware.cu * @brief Report essential characteristics of GPU. * * */ #include <cstdio> #include <cstdlib> #include <iostream> using namespace std; int main(int argc, char** argv) { int count = 0; cudaGetDeviceCount(&count); printf("Report on GPU configuration (GPUs: %i).\n", count); fo...
610
__device__ int get(int x, int y,int width){ return y * width +x; } __device__ int normeValue(int x, int width){ if(x < 0) //-1 return width - 1; if(x == width) return 0; return x; } __device__ int* neighborsIndexes(int i, int j, int width, int height){ int dir[8]; dir[0] = get(normeValue(i+1,width), j, wid...
611
#include <iostream> #include <complex> #include <cmath> #include <iomanip> #include <string> #include <fstream> using namespace std; __global__ void z_funct(double * d_mat_re, double * d_mat_im, int *d_img, int nb_ite) { int i = blockDim.x * blockIdx.x + threadIdx.x; double c_re = d_mat_re[i]; double c_im = ...
612
#include <stdio.h> #include <stdint.h> #include <thrust/device_vector.h> #include <thrust/copy.h> #include <thrust/sort.h> #include <algorithm> #define CHECK(call) \ { \ const cud...
613
#include "includes.h" __global__ void set_kernel(const int n, const float alpha, float *y) { for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < (n); i += blockDim.x * gridDim.x) { y[i] = alpha; } }
614
#include <stdio.h> #include <cuda.h> typedef unsigned char u8; typedef struct cell { u8 state; size_t* neighbor; u8 neighborSize; } cell; typedef enum type {life, koNeiman, koNeimanMur, koMur} type; u8*** hStates; size_t hX, hY, hZ; type hT; __device__ u8* dStates; __device__ size_t *pdX, *pdY, *pdZ; _...
615
#include "includes.h" __global__ void reduction_kernel_2(float *g_out, float *g_in, unsigned int size) { unsigned int idx_x = blockIdx.x * blockDim.x + threadIdx.x; extern __shared__ float s_data[]; s_data[threadIdx.x] = (idx_x < size) ? g_in[idx_x] : 0.f; __syncthreads(); // do reduction // sequential addressing f...
616
#include <cstdio> #include <random> #include <string.h> #include <stdlib.h> #include <time.h> #include <math.h> #include <algorithm> #include <chrono> #include <iostream> #include <limits> #include <cctype> __device__ int cost_index[16] = { 1,-1,-1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,1 }; #define LENGTH_REFERENCE 40000 ...
617
#include <stdio.h> #include <time.h> #include <unistd.h> #include <stdlib.h> #include <math.h> /* Instruções COMPILAR --> nvcc 2DstencilGPUSharedMemoryBlankBorderTimeSpaceSharingOpencvKarma.cu -o go `pkg-config --cflags --libs opencv` -w EXECUTAR --> ./go DOMAIN_DIMS STENCIL_ORDER SPACE_TIME_BLOCK_TIMES BLOCK_DIM_X ...
618
#include "includes.h" __global__ void transposedMatrixKernel(int* d_a, int* d_b) { int i = threadIdx.x + blockDim.x * blockIdx.x; int j = threadIdx.y + blockDim.y * blockIdx.y; d_b[i * N + j] = d_a[j * N + i]; }
619
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <cuda_runtime.h> #include <vector> #include <algorithm> #define num 25 __global__ void gpuAdd(int *d_a, int *d_b, int* d_c, int N=num) { printf("%d -- ", threadIdx.x); int tid = blockIdx.x*blockDim.x + threadIdx.x; int sum=0; whi...
620
#include "includes.h" //header files included //declaring the tile width and height //for tile based matrix multiplication #define TILE_WIDTH 32 #define TILE_HEIGHT 32 //Namespace for std using namespace std; //structure declaration for storing rows and columns for a matrix struct matrix{ unsigned int rows; //storin...
621
#include <stdio.h> int main(void) { int dev = 0; cudaSetDevice(dev); int driverVersion = 0, runtimeVersion = 0; cudaDeviceProp deviceProp; cudaGetDeviceProperties( &deviceProp, dev ); printf("Device %d; \"%s\"\n", dev, deviceProp.name); cudaDriverGetVersion( &driverVersion ); cudaRu...
622
__device__ void saxpy( float a, float *b, float *c ) { c[0] += a*b[0]; c[1] += a*b[1]; c[2] += a*b[2]; c[3] += a*b[3]; c[4] += a*b[4]; c[5] += a*b[5]; c[6] += a*b[6]; c[7] += a*b[7]; c[8] += a*b[8]; c[9] += a*b[9]; c[10] += a*b[10]; c[11] += a*b[11]; c[12] += a*b[12]; c[13] += a*b[13]; c[14] += a*b[14]; ...
623
#include <stdio.h> #include <stdlib.h> #include <iostream> #define CSC(call) \ do { \ cudaError_t res = call; \ if (res != cudaSuccess) { \ fprintf(stderr, "ERROR in %s:%d. Message: %s\n", \ __FILE__, __...
624
#include<iostream> #include<fstream> #include<time.h> #include<vector> #include<iterator> #include<cuda.h> #include<stdio.h> #define SIZE 120000000 #define max_threads 80 #define normalizeNum 1000 /* Define num elements of each bucket */ #define range 100000 #define bucketLength (SIZE/range * 2) /* Each block sorts o...
625
#include <stdio.h> #include <stdlib.h> #include <iostream> #include <math.h> #include <string> #include <locale> using namespace std; /*****************************************************************************/ __global__ void calcularC (const float * A, const float * B, float * C, const int size) { uint block_...
626
#include <cuda.h> #include <stdio.h> #define iMin(a, b) (a<b?a:b) const int N = 17*1024; const int threadsPerBlock = 256; const int blocksPerGrid = iMin(16, (N+threadsPerBlock-1)/threadsPerBlock); // kernel code for adding two vector elements __global__ void vecDot(float* a, float* b, float* c) { __shared__ float c...
627
#include <stdio.h> float uniform(float low, float high) { return low + (static_cast<float>(rand())/RAND_MAX)*(high - low); } int main() { int size = static_cast<int>(1 << 25); float* host_arr = (float*) malloc(size*sizeof(float)); for(size_t i = 0; i < size; ++i) { host_arr[i] = uniform(0.0,...
628
#include <stdio.h> __global__ void use_local_memory_GPU(float in) { float f; f = in; } __global__ void use_global_memory_GPU(float *array) { // array is a pointer into global memory on the device array[threadIdx.x] = 2.0f * (float) threadIdx.x; } __global__ void use_shared_memory_GPU(float *array) {...
629
extern "C" #define BLOCK_WIDTH 16 #define BLOCK_HEIGHT 16 __global__ void filter(int *Input_Image, int *Output_Image, int Image_Width, int Image_Height) { const int tx_l = threadIdx.x; // --- Local thread x index const int ty_l = threadIdx.y; // --- Local t...
630
#include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include <assert.h> #include <math.h> /* Returns the current time in miliseconds. */ double getMilitime(){ struct timeval ret; gettimeofday(&ret, NULL); return ((ret.tv_sec ) * 1000000u + ret.tv_usec) / 1.e6; } #define TYPE doubl...
631
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> #include <cuda.h> #include <cuda_runtime.h> #include <cuda.h> #include <device_launch_parameters.h> #define LIST_SIZE 100000 extern "C" __device__ long long instCountList[LIST_SIZE]; void bambooLogRecordOff(){ } void bambooLogKernelBegin(...
632
#include "includes.h" __global__ void swan_fast_fill( uint4 *ptr, int len ) { int idx = threadIdx.x + blockDim.x * blockIdx.x; if( idx<len) { ptr[idx] = make_uint4( 0,0,0,0 ); } }
633
/***************************************************************************//** * \file LHS2.cu * \author Christopher Minar (minarc@oregonstate.edu) * \brief kernels to generate the left hand side for the poission solve */ #include "LHS2.h" namespace kernels { /* * calculates the boundary terms for the left han...
634
//Author: Xinrea //Date: 2018/7/5 //Basic Sample of using CUDA #include <cuda_runtime.h> #include <device_launch_parameters.h> #include <cstdio> cudaError_t addData(int size,int a[],int b[],int c[]); __global__ void addKernel(int dev[],int size){ int i = threadIdx.x; dev[2*size+i] = dev[i]+dev[size+i]; } in...
635
// addNext.cu // Second program from Dr Dobbs tutorial. http://drdobbs.com/parallel/207402986 #include <cuda.h> #include <stdio.h> #include <assert.h> // Host kernel = increment each element by 1 void incOnHost(float *a, int N) { int i; for (i=1; i<N; i++) { a[i] = a[i] + a[i-1]; } } // Devi...
636
extern "C" __global__ void kernel_dummy(float *ptr) { ptr[blockIdx.x] = 0; }
637
/* * Compile and run: nvcc -arch=sm_20 kGrid.cu -run */ #include <stdio.h> /*__global__ void kGrid(int n, int *k) { int l = blockIdx.x * blockDim.x + threadIdx.x; if(l < n) { for(int* i = 0; i < k; i++) { for(int* j = 0; j < k; j++) { printf("%i", j) } printf("\n"); } } } int main(void) { int N = ...
638
#include<stdio.h> #include<stdlib.h> #define TPB 8 #define N 32 __device__ float distance(float x1, float x2) { return sqrt ((x2-x1)*(x2-x1)); } __global__ void distanceKernel(float *d_out, float *d_in, float ref) { const int i=blockIdx.x*blockDim.x+threadIdx.x; const int j=blockIdx.x; const int k=threadIdx.x; ...
639
/* This is a automatically generated test. Do not modify */ #include <stdio.h> #include <stdlib.h> #include <math.h> __global__ void compute(float comp, float var_1,float 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,floa...
640
#include "includes.h" __device__ inline unsigned int RM_Index(unsigned int row, unsigned int col, unsigned int width) { return (row * width + col); } __global__ void MultinomialNBLearnKernel(float *feature_probs, float *class_priors, const float *d_row_sums, unsigned int n_samples_, unsigned int n_classes_, unsigned in...
641
#include "includes.h" const int Nthreads = 1024, NrankMax = 3, nt0max = 71, NchanMax = 1024; ////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////...
642
// // kernel routine // __global__ void VecAdd_kernel(const float* A, const float* B, float* C, int N) /* Naive kernel */ { // Uncomment line below and define global index form block and thread indexes int i = threadIdx.x + blockDim.x * blockIdx.x; if(i < N){ C[i] = A[i] + B[i]; } }
643
#include <cuda_runtime.h> #include <device_launch_parameters.h> #include <stdio.h> __global__ void vecAddKernel(int *a, int *b, int *c){ int i = threadIdx.x; c[i] = a[i] + b[i]; } int main(){ int v1[5] = {1,2,3,4,5}; int v2[5] = {6,7,8,9,10}; int *cuda_a, *cuda_b, *cuda_c; cudaMalloc((void**) &cuda_a, 5*sizeo...
644
#include <iostream> #include <fstream> #include <cuda_runtime.h> using namespace std; //nvcc cudaProperty.cu -o cudaProp bool InitCUDA() { int count; cudaGetDeviceCount(&count); if(count == 0) { cout << "There is no device."<< endl; return false; } int i; for(i = 0; i < count...
645
/* * singleGpuSpectrometer * * Version 2.0, April 12 2010 * * This program was written by Hirofumi Kondo at the Supercomputing Engineering Laboratory, * Graduate School of Information Science and Technology, Osaka University, Japan. * * Copyright 2010 Supercomputing Engineering Laboratory, Graduate School of I...
646
#include "includes.h" __global__ void set_unavailable(bool *available, int n_rows, const int *idx, int n_selected) { int tid = threadIdx.x + blockIdx.x * blockDim.x; if (tid < n_selected) { available[idx[tid]] = false; } }
647
 //#include "cuda_runtime.h" //#include "device_launch_parameters.h" //#include <stdio.h> #include <stdio.h> #include <cuda_runtime.h> // device kernel __global__ void helloWorldDevice() { printf("Hello world from device %d!\n", threadIdx.x); } int main() { printf("Hello world from host!\n"); // run kernel in ...
648
#include "includes.h" __global__ void lga_filtering_forward (const int n, const float *bottom_data, const float *filters, const int height, const int width, const int channel, const int radius, float *top_data){ int index = blockIdx.x * blockDim.x + threadIdx.x; // printf("OK\n"); // printf("%d, %.2f, %.2f\n", in...
649
char *title = "gauss filtering"; char *description = "gauss filtering"; #include <iostream> #include <cstdio> #include <cstdlib> #include <assert.h> #include <time.h> #include <cuda.h> #include <cuda_runtime.h> #include <math.h> /* exp */ #ifndef max #define max( a, b ) ( ((a) > (b)) ? (a) : (b) ) #endif #ifn...
650
#include "addition.cuh" #include <stdio.h> __global__ void addition(int* a, int* b, int* c){ *c = *a + *b; } void setupCuda(int* &D_A, int* &D_B, int* &D_C, int* &A, int* &B, int* &C){ cudaMalloc((void**)&D_A, sizeof(int)); cudaMalloc((void**)&D_B, sizeof(int)); cudaMalloc((void**)&D_C, sizeof(int)); ...
651
#include "includes.h" __global__ void bcnn_op_cuda_ramp_kernel(int n, float *x, float *y) { int i = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x; if (i < n) { y[i] = x[i] * (x[i] > 0) + 0.1 * x[i]; } return; }
652
#include "cuda_runtime.h" #include <stdint.h>
653
#include <cuda_runtime.h> int main() { int* a; cudaMalloc(&a, 100); cudaFree(a); return 0; }
654
#include <cuda_runtime.h> #include <device_launch_parameters.h> #include <cstdio> #include <iostream> #include <cstdlib> #define BLOCK_SIZE 64 #define N 64 using namespace std; void displayLastError(const string &msg) { cout << "Last Error (" << msg << "):\t" << cudaGetErrorString(cudaGetLastError()) << endl; } ...
655
#include "includes.h" __global__ void sgemm_kernel_v2(const float *A, const float *B, float *C, int M, int N, int K, float alpha, float beta) { int bid_x = blockIdx.x * blockDim.x; int bid_y = blockIdx.y * blockDim.y; int tid_x = threadIdx.x; int tid_y = threadIdx.y; float element_c = 0.f; __shared__ float s_tile_A[BL...
656
// My first CUDA program! // 2018.9.1 #include <stdio.h> __global__ void helloFromGPU(void) { printf("Hello GPU! from thread \n"); } int main(void) { printf("Hello cPU! \n"); helloFromGPU <<<1,10>>>(); //cudaDeviceReset(); cudaDeviceSynchronize(); return 0; }
657
#include <cuda.h> #include <stdio.h> #include <time.h> #define N 100 __global__ void addVectorGPU(int* a, int* b, int* c) { int tid = blockIdx.x * blockDim.x + threadIdx.x; if (tid < N) { c[tid] = a[tid] + b[tid]; } } void addVectorCPU(int* a, int* b, int* c) { for (int i = 0; i < N; i++) { c[i] = a[i...
658
/** * Concurrent Wave Equation * Compilation Command: nvcc cuda1.cu -o cuda1 * This program was originally written in serial method by the teacher. */ #include <stdio.h> #include <stdlib.h> #include <time.h> #define MAXPOINTS 1000000 #define MAXSTEPS 1000000 #define MINPOINTS 20 static void handleError(cudaErro...
659
#include <cuda_runtime.h> #include "device_launch_parameters.h" #include <stdio.h> #include <iostream> #include <omp.h> #include <chrono> #include <random> #include <iomanip> #include <cmath> #include "matrix_operations.cuh" #define BLOCKSIZE_1 16 __global__ void kernel_naive_multiply_cuda(double* Ad, double* Bd, d...
660
extern "C" __global__ void noarg() {} extern "C" __global__ void simple_add(float * A) { int id = blockIdx.x * blockDim.x + threadIdx.x; A[id] += 1.0; } extern "C" __global__ void four_mad(float * A) { int id = blockIdx.x * blockDim.x + threadIdx.x; float f = A[id]; f *= 41.0; f += 37.0; f *= 11.0; f += 23.0;...
661
/* #include "SiPotential.h" //-------------------- force between two Si particles ---------------------// __host__ __device__ double f2_derivative_of_rij_tag(double r_ij_tag) { double first = -4*B_Si*(1.0/(r_ij_tag*r_ij_tag*r_ij_tag*r_ij_tag*r_ij_tag)); double second = ((B_Si*(1.0/(r_ij_tag*r_ij_tag*r_ij_tag*r_ij_t...
662
//Header from standard libraries #include <fstream> //size of blocks in grid #define BLOCK_SIZE 16 //kernel function to multiply c=a*b __global__ void Muld(float* a,float* b,float* c,int n) { int i = blockIdx.x * blockDim.x + threadIdx.x; int j = blockIdx.y * blockDim.y + threadIdx.y; float sum = 0; if(i>=n ||...
663
// ########################################################## // By Eugene Ch'ng | www.complexity.io // Email: genechng@gmail.com // ---------------------------------------------------------- // The ERC 'Lost Frontiers' Project // Development for the Parallelisation of ABM Simulation // ------------------------------...
664
/* Solving the 2D acoustic wave equation using explicit finite * difference method * Copyright 2018 Chaiwoot Boonyasiriwat. All rights reserved. */ #include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> //Kernel __global__ void Wcalculate(float *u0,float *u1,float *u2,float C2,int nx,int ny){ ...
665
#include <stdio.h> #include "Queue.cuh" Queue** createQueue(int width, int height){ Queue** queue=(Queue**)calloc(1, sizeof(Queue*)); *queue=(Queue*)calloc(1, sizeof(Queue)); (*queue)->width=width; (*queue)->height=height; (*queue)->entries=0; (*queue)->queue=(int**)calloc(height, sizeof(int*)); for(int ent...
666
#include <stdio.h> #include <stdint.h> #include <math.h> #include <cuda_runtime.h> #define FLT_MIN 1.175494351e-38F __device__ float FCC_KR = 0.3; __device__ float FCC_KB = 0.11; __device__ float SMPTE_240M_KR = 0.212; __device__ float SMPTE_240M_KB = 0.087; __device__ float REC_601_KR = 0.299; __device__ float REC_601...
667
/* * Kernel for calulating the element-wise product of two matrices * m, n --> dimensions of matrices A, B, C */ extern "C" { __global__ void hadamard(int m, int n, float *A, int lda, float *B, int ldb, float *C, int ldc) { int i = blockIdx.x * blockDim.x + threadIdx.x; int j = blockIdx.y * blockDim.y + thre...
668
#include <cuda.h> /*Lx2Cuda performs the 2-D convolution of matrices A and row vector B*/ __global__ void Lx2(const float *d_in,float *d_out,int numRows,int numCols, float *mask) { //Calculate the row # of the d_in and d_out element to process int Col = blockIdx.y*blockDim.y + threadIdx.y; //Calculat...
669
/* * ExBottomUpdater.cpp * * Created on: 01 февр. 2016 г. * Author: aleksandr */ #include "ExBottomUpdater.h" #include "SmartIndex.h" /* * indx должен пренадлежать участку от [0, sizeX-1] */ __device__ void ExBottomUpdater::operator() (const int indx) { int m = indx; Ex(m, 0) = coeff[0] * (Ex(m, 2) + Ex...
670
/* * EzBottomUpdater.cpp * * Created on: 23 янв. 2016 г. * Author: aleksandr */ #include "EzBottomUpdater.h" #include "SmartIndex.h" #define EzBottom(N, Q, M) EzBottom[(M) * 6 + (Q) * 3 + (N)] /* * indx должен пренадлежать участку от [0, sizeX-1] */ __device__ void EzBottomUpdater::operator() (const int i...
671
/* * CS 4444 * Steven Stetzler * Homework 5: Matrix-Matrix Multiplication with CUDA */ #include <stdio.h> #include <assert.h> #include <cuda.h> #include <cuda_runtime.h> #include <sys/time.h> #include <stdlib.h> #include <iostream> using namespace std; // If the specified error code refers to a real error, repor...
672
#include <iostream> #include <stdlib.h> #include "load_matrix.cuh" int load_matrix(double ***matrix, int *size, char* filename) { FILE* ip; int i, j; if ((ip = fopen(filename, "r")) == NULL) { return 1; } fscanf(ip, "%d\n\n", size); (*matrix) = alloc_mem(*size, (*size) + 1); for (i = 0; i < *size; ++i) { ...
673
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <cuda.h> /** * Encrypt Program Cuda * * This program encrypts a file using a degree 2 formula using Cuda * Parallelization and then decrypts the file using another degree 2 * formula. * * @Author: Clayton Chase Glenn */ #def...
674
/* Copyright (C) 2012 Fabrizio Gueli * * This file is part of Cuda-complex-sim * * Cuda-complex-sim 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 3 of the License, or (at your...
675
// dimensions layout: // 0-2 target offset_size (flat) // 3-5 source and inclusion size (incremental) // 6-8 filter size (not incremental) // 9 sample_count __global__ void cuda_filter_tips_fast( float *target_image, float const *const source_image, float const *const inclusion_image, ...
676
#include "test.cuh" __global__ void cuda_lanch_add(float *ptr, const int len) { int index = threadIdx.x + blockIdx.x * blockDim.x; int stride = blockDim.x * gridDim.x; for(int i = index; i < len; i = i + stride) { if(i < len){ ptr[i] = ptr[i] * 2; } } } void add(f...
677
/*----------- * * square.cu * * This is the source file of an increment kernel. * * This kernel is from CUDA samples. simpleOccupancy.cu * * streamsOptBenchmark/square.cu * * By Hao Li * *------------ */ // #include "functions.h" //////////////////////////////////////////////////////////////////////////...
678
#include "matrix.cuh" #define ROW_INDEX 0 #define COL_INDEX 1 #define NUM_INDEXES 2 __device__ matrix_t* device_roll_matrix_list(buffer_t* buffer, matrix_list_t* list) { unsigned int i; //assert(list != NULL); //for(i=0; i<list->num; i++) //{ // assert(list->matrix_list[i] != NULL); //} unsigned int vector_si...
679
#include <cstdio> int deviceQuery() { int deviceCount; cudaGetDeviceCount(&deviceCount); for (int dev = 0; dev < deviceCount; dev++) { cudaDeviceProp deviceProp; cudaGetDeviceProperties(&deviceProp, dev); if (dev == 0) { if (deviceProp.major == 9999 && deviceProp.minor == 9999) {...
680
#include <iostream> #include <cstdio> #include <cstdlib> using namespace std; int main() { cudaDeviceProp prop; int count; cudaGetDeviceCount(&count); cout << count << endl; for(int i = 0; i < count;++i) { cudaGetDeviceProperties(&prop,i); printf("Name: %s\n",prop.name); printf("Cumpute capability: %d.%d\n...
681
#include "includes.h" __global__ void _bcnn_pow_kernel(int n, float *x, float a, float *y) { int i = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x; if (i < n) y[i] = pow(x[i], a); }
682
#include <iostream> #include <cstdlib> using namespace std; __global__ void MatrixMultiplication(unsigned long* Md, unsigned long* Nd, unsigned long* Pd, int width) { int tx = threadIdx.x; // x-index of threads int ty = threadIdx.y; // y-index of threads // Pvalue stores the Pd element that is computed b...
683
#include <stdio.h> #include <string.h> #define tpb 32 __global__ void oddCheck(int* nums,int*len, int* out, int* last){ int index=threadIdx.x + blockIdx.x*tpb; if (index<*len) out[index]=nums[index]%2; if(index==((*len)-1)) *last=out[index]; } __global__ void exToIn(int* inp, int* out, int*len, int*last)...
684
#include<stdio.h> #include<cuda.h> #define row1 10 #define col1 10 #define row2 10 #define col2 10 typedef long long int LLI; __global__ void matproductsharedmemory(LLI *l,LLI *m, LLI *n) { LLI x=blockIdx.x; LLI y=blockIdx.y; __shared__ LLI p[col1]; LLI i; LLI k=threadIdx.x; n[col2*y+x]=0...
685
#include <stdio.h> #include "cuda_profiler_api.h" #define SIZE 20480 __global__ void vecAdd(int *a,int *b, int *c, int len) { int i=threadIdx.x+blockDim.x*blockIdx.x; if(i<len) c[i] = a[i] + b[i]; } void vecAdd_CPU(int *a,int *b, int *c, int len) { int i=0; for(i=0;i<len;i++) c[i] =a[i]+b[i]; } voi...
686
#include<stdlib.h> #include<stdio.h> #include<malloc.h> #include<time.h> #define arm 32 __device__ int globalArray[32]; __global__ void add(int *a,int *c) { int tid = threadIdx.x; int temp=a[tid]; int count=0; while(temp!=0) { count++; temp=temp/2; } atomicAdd(&globalArray[...
687
#include "includes.h" __global__ void calc_lut(int *lut, int * hist_in, int img_size, int nbr_bin){ __shared__ int shared_hist[256]; shared_hist[threadIdx.x] = hist_in[threadIdx.x]; __syncthreads(); __shared__ int cdf[256]; __syncthreads(); int i, min, d; //int cdf = 0; min = 0; i = 0; while(min == 0){ min = share...
688
#include <iostream> #include <cuda.h> #include <cstdlib> #include <stdlib.h> #include <stdio.h> #include <time.h> const int BLOCK = 256; __global__ void AddListK(float *I, float *O, int l) { int b = blockIdx.x; int t = threadIdx.x; __shared__ float pSum[BLOCK*2]; unsigned int start = 2*blockDim.x*...
689
#include <stdio.h> #include <cuda_runtime.h> __global__ void test(const int *in, int *answer) { const int tid = threadIdx.x; if (tid == 0) printf("hello!\n"); int sum = in[tid]; if (tid == 0) printf("sum[0] is %d\n", sum); *answer = sum; } int main() { int *h_data, *d_data; int N = 64; ...
690
#include <stdio.h> #define TILE 32 // Thread block dimension #define N 8192 // Side of the matrix #define MATSIZE N * N // Total size of the matrix #define MEMSIZE MATSIZE * sizeof(double) // Size of matrix in memory // Generic function to be called for bandwidth testing on GPUs. typedef void (*kernelFunc)(double *, ...
691
__global__ void findCoordinate(float *A, int *keypoints, int *newKeypoints, int lenght){ int index = blockIdx.x * blockDim.x + threadIdx.x; if(index < lenght){ float a00 = A[0]; float a01 = A[1]; float a10 = A[3]; float a11 = A[4]; float t0 = A[2]; float t1 =...
692
#include "Data.cuh" #include "Data_kernel.cuh" #include <fstream> #include <iostream> #include <limits> Data::Data(): rowSize(0), columnSize(0)//, flow(0) { } Data::~Data() { delete[] this->weightLeft; delete[] this->weightRight; delete[] this->weightUp; delete[] this->weightDown; delete[] this...
693
#include<stdio.h> #include<stdlib.h> #include<cuda.h> #include <sys/time.h> #include<thrust/sort.h> #include<math.h> #define BLOCKSIZE 1024 struct vehicle { float time ; int id; }; struct cmp { __host__ __device__ bool operator()(const vehicle& o1, const vehicle& o2) { if (o1.time == o2.time) retur...
694
#include "includes.h" __device__ void out_of_bounds_function(void) { *(int*) 0x87654320 = 42; } __global__ void out_of_bounds_kernel(void) { out_of_bounds_function(); }
695
// Copyright (c) 2013 Craig Wright (kungfucraig@gmail.com) // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in // the Software without restriction, including without limitation the rights to use, // copy,...
696
#include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <thrust/copy.h> #include <thrust/transform.h> #include <iostream> struct sample_functor { double alpha; double beta; sample_functor(double _alpha, double _beta) { alpha = _alpha; beta = _beta; } __device__ double operator() ...
697
#include <stdio.h> #include <stdlib.h> #include <cstdio> #include <cstdlib> #include <fstream> #include <iostream> #include <cuda_runtime.h> #include <chrono> using namespace std; const int INF = ((1 << 30) - 1); // const int V = 50010; void input(char* inFileName); void output(char* outFileName); void block_FW(in...
698
#include <stdio.h> #include <cuda_runtime.h> __global__ void kernel(void) { printf("GPU: Hello world\n"); } int main(int argc, char* argv[]) { kernel<<<2, 4>>>(); cudaDeviceSynchronize(); return 0; }
699
#include "user.cuh" using namespace std; int main(int argc, char *argv[]) { // Preapre file I/O string fileName; if (argc == 1) fileName = "maxFloatNum.csv"; else fileName = argv[1]; CSV_Data cd(fileName, true); // Generate Vector printf("[INFO] Generating vector...\n"); float minVal ...
700
#include <iostream> __global__ void vecAddKernel(float *A, float *B, float *C, int n) { int i = blockDim.x * blockIdx.x + threadIdx.x; if(i < n) { C[i] = A[i] + B[i]; } } void vecAdd(float* h_A, float* h_B, float* h_C, int n) { int size = n * sizeof(float); float *d_A, *d_B, *d_C; ...