serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
20,001
#include "includes.h" __global__ void BaseNeuronSetIntPtArray(int *arr, int *pos, int n_elem, int step, int val) { int array_idx = threadIdx.x + blockIdx.x * blockDim.x; if (array_idx<n_elem) { arr[pos[array_idx]*step] = val; } }
20,002
#include "includes.h" __global__ void gpu_copy_velocity( const int num_atoms, const int offset, const int* g_group_contents, const double* g_vx_i, const double* g_vy_i, const double* g_vz_i, double* g_vx_o, double* g_vy_o, double* g_vz_o) { const int n = threadIdx.x + blockIdx.x * blockDim.x; if (n < num_atoms) { const...
20,003
#include "../headers/isinge.cuh"
20,004
#include "includes.h" __global__ void rotate_2D(float* coords, size_t dim_y, size_t dim_x, float cos_angle, float sin_angle){ size_t index = blockIdx.x * blockDim.x + threadIdx.x; size_t total = dim_x * dim_y; float new_y, new_x; float old_y = coords[index]; float old_x = coords[index + total]; if(index < total){ new_y...
20,005
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdlib.h> #include <stdio.h> cudaError_t forwardPass(double *x, double *y, double *W, int row, int column); __global__ void vectorMultiplicationKernel(double *x, double *y, double *W, int row, int column) { int tid = blockIdx.x; ...
20,006
#include <stdio.h> __device__ double power(double x) { double y = (x-x)/(x-x); return x*x + 2.0 + y; } __global__ void compute(double x) { double y = power(x); y = y + x; int tid = blockIdx.x * blockDim.x + threadIdx.x; if (tid == 0) { printf("y: %f\n", y); } }
20,007
// We require std::filesytem, but just requireing std=c++17 does not enforce this for all compilers, so check it works. (I.e. GCC < 8 is a problem.) // CMake doesn't appear to have knowledge of this feature. #include <filesystem> int main() { return 0; }
20,008
#include <cstdio> #include <cstdlib> #include <random> #include <sys/time.h> /******************************************************* ****************** Device code ************************ ******************************************************/ __constant__ double d_alpha; __global__ void axpy (const double* A,...
20,009
__global__ void f2d3(float * __restrict__ ptr1, float * __restrict__ ptr2, float * __restrict__ ptr3) { ptr1[threadIdx.x] += 1; ptr2[threadIdx.x] += 1; ptr3[threadIdx.x] += 1; return; } // __global__ void f2(float * __restrict__ ptr1, float * __restrict__ ptr2, float * __restrict__ ptr3, float * __restric...
20,010
/* * @Author: grantmcgovern * @Date: 2015-10-28 12:52:26 * @Last Modified by: grantmcgovern * @Last Modified time: 2015-11-04 16:31:11 */ #include <string.h> #include <curand.h> #include <curand_kernel.h> #include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> #include <unistd.h> #define N 99...
20,011
#include <iostream> #include <fstream> #include <stdlib.h> using namespace std; // get a uniform random number between -1 and 1 inline float f_rand() { return 2*(rand()/((float)RAND_MAX)) -1.; } template <typename Real> void genData(ofstream &outFile, int nVec, Real xVar) { Real xMax = 1.1; Real xMin = -xMax; R...
20,012
/* • Implement a matrix multiplication using a GPU to solve the operation instead of a CPU. Create the matrices in the CPU pass them to the GPU calculate the answer and show the answer in the console in an ordered way. */ #include "cuda_runtime.h" #include <stdio.h> #include <stdlib.h> // rand(), srand() #includ...
20,013
#include <iostream> #include <fstream> #include <stdlib.h> #include <math.h> #include <vector> #include <time.h> #define ancho 1280 #define alto 720 #define totalPixeles ancho*alto #define totalhilos 32 typedef int tamPixel; using namespace std; void llenarVectores(tamPixel *V){ for(int i=0;i<totalPixele...
20,014
/*--------------------------------------------------------------------*/ /* CUDA special utility Library */ /* written by Viktor K. Decyk, UCLA */ #include <stdlib.h> #include <stdio.h> #include "cuda.h" static cudaError_t crc; /*--------------------------------------------------------------------*/ extern "C" void ...
20,015
#include <iostream> #include <cstdlib> #include <cuda.h> #include <ctime> #include <sys/time.h> using namespace std; /*the kernel code to run on the GPU device */ __global__ void matrix_mult_kernel(float* A, float* B, float* C, int M, int block_size){ /* using specified conventions*/ ...
20,016
#include <stdio.h> #include <cuda.h> __global__ void MyKernel() { printf("in mykernel\n"); } void MyCallback(cudaStream_t stream, cudaError_t status, void *data){ printf("Inside callback %d\n", (long)data); MyKernel<<<1, 1>>>(); cudaDeviceSynchronize(); cudaError_t err = cudaGetLastError(); printf("error=%d,...
20,017
// input: 1 2 3 4 5 6 // ouput: 3 6 12 20 30 #include <iostream> #include "cuda.h" using namespace std; #define N 64 __global__ void myKernel(int *retArray, int *Array) { extern __shared__ int sharedArray[]; const int tid = blockIdx.x * (blockDim.x * blockDim.y) + blockDim.x * threadIdx.y + threadIdx...
20,018
#include <cuda.h> #include <stdio.h> #include <iostream> #include <time.h> using namespace std; __host__ void inizializzaArray(int *a,int n){ srand((unsigned int)time(NULL)); for(int i=0;i<n;i++) a[i]=1+rand()%10; } __host__ void calcolaProdEsterno(int *a,int *b,int m,int n,int *c){ for(int i=0;i<m;i++) for(i...
20,019
/************************************************************************************\ * * * Copyright � 2014 Advanced Micro Devices, Inc. * * Copyright (c) 2015 Mark D. Hill and David A. Wood ...
20,020
#include "includes.h" __global__ void gpu_update_sign(int *G, double *w ,int *neighbors , int k , int n ,int *temp, int *flag,int it_b ,int it_t) { int buf=0; for (int off1 = 0; off1 < it_b; off1++) { for(int off2 = 0; off2<it_t;off2++){ int result; double sum = 0.0; int x = blockIdx.x+off1*gridDim.x; int y = thread...
20,021
extern "C" __global__ void sgemm_tn_vec_128x128( float* param_C, const float* param_A, const float* param_B, float param_alpha, float param_beta, int param_flags, int param_lda, int param_ldb, int param_ldc, int param_m, int param_n, int param_k, ...
20,022
#ifndef WINDOWS #include <unistd.h> #endif #include <stdio.h> #include <cuda.h> int main(int argc, char *argv[]) { int ndev=0; int id=0; cudaError_t error; cudaDeviceProp features; int rtver=0; int dver=0; /* Get number of devices */ error = cudaGetDeviceCount(&ndev); if (error != cudaSuccess) { ...
20,023
/* Copyright (c) 2014 Matthew Simons 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, modify, merge, publish, distribute, ...
20,024
#include "includes.h" __global__ void lineark(int *ip,int *weight,int *op,int N,int M,int L){ unsigned int input_id = (blockIdx.x*gridDim.y + blockIdx.y + blockIdx.z*gridDim.x*gridDim.y)*blockDim.x + threadIdx.x; int i = input_id/(M*L); input_id = input_id%(M*L); int j = input_id/L; int k = input_id%L; int temp = (*(i...
20,025
#include <cuda_runtime.h> #include <float.h> __global__ void solution_ker(double* A, int M, int N, int K){ int i = threadIdx.x; int j = threadIdx.y; int k = threadIdx.z; int ind = (i*N+j)*K + k; if (i == 0 || j == M-1 || j == 0 || j == N-1 || k == 0 | k == K-1) { A[ind] = 10.*i ; //finish thi...
20,026
#include <cuda.h> #include <iostream> #include <vector> #include <iomanip> #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: %s %s %d\n", cudaGetError...
20,027
#include "includes.h" __global__ void Matrix_MultiplElementWise_naiveOLD(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; if (id<Acount) { if ...
20,028
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <iostream> #include <cmath> using namespace std; extern float dz, dt; extern int size_space, size_time; const float C = 3e8f; void src_init() { dz = 0.015; dt = dz / (2 * C); } void src_checkout() { cout << "dz: " << dz << endl; cout << "d...
20,029
#include "includes.h" __global__ void kTranspose(float* a, float* dest, int width, int height) { const int bx = blockIdx.x * blockDim.x; const int by = blockIdx.y * blockDim.y; const int tx = bx + threadIdx.x; const int ty = by + threadIdx.y; // unsigned int idx = ty * width + tx; __shared__ float smem[ADD_BLOCK_SI...
20,030
#include <stdio.h> #include <stdlib.h> __global__ void print_from_gpu(void) { printf("Hello World from thread [%d, %d]! From device\n", threadIdx.x, blockIdx.x); } int main(void) { printf("Hello World from host!\n"); print_from_gpu<<<1,2>>>(); cudaDeviceSynchronize(); return 0; }
20,031
#include <stdio.h> #include <cuda.h> #include <cuda_runtime.h> #define LOG_INPUT if(1) #define LOG_SCAN if(0) #define LOG_OUTPUT if(1) void print_array(float *A, int N) { for(int i=0;i<N;i++) printf("%.2f ",A[i]); printf("\n"); } #define TILE_SIZE 512 __global__ void Convolution1D(float *N, float ...
20,032
#include <iostream> // __global__ alerts the compiler that a function should be built to run on a device, not the host __global__ void kernel(void) { } // This function is built for the host as normal int main(void) { kernel<<<1,1>>>(); // The angled brackets denote arguments to be passed to the device runtime prin...
20,033
#include "includes.h" __global__ void ker_gkylCartFieldAssignAll(unsigned s, unsigned nv, double val, double *out) { for (int n = blockIdx.x*blockDim.x + threadIdx.x + s; n < s + nv; n += blockDim.x * gridDim.x) out[n] = val; }
20,034
#include <iostream> #include <sys/time.h> #define TILE_DIM 32 using namespace std; /* cudaMallocPitch example: * compares normal device memory allocation and allocation using cudaMallocPitch * for different matrix sizes. * When matrix width is not a multiple of 16 cudaMallocPitch should be preferred. */ // kern...
20,035
#include<iostream> #include<fstream> #include<time.h> using namespace std; typedef struct{ int *x; int *y; int nr_vertice; int mbr[4]; int *boxes; }polygon; __device__ int PtInPolygon(int x,int y, int *poly_x, int *poly_y, int nCount){ int nCross=0,i; int x1,x2,y1,y2; double ix; f...
20,036
#include <stdio.h> #include <errno.h> #include <stdlib.h> #include <unistd.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/ioctl.h> #include <string.h> #include <sys/mman.h> #include <sys/time.h> #include <sys/wait.h> #include <sys/ipc.h> #include <sys/shm.h> #include <cuda_runtime.h> __global__ void VecAdd(...
20,037
#include "includes.h" __global__ void smoothGray (unsigned char *imagem, unsigned char *saida, unsigned int cols, unsigned int linhas) { unsigned int indice = (blockIdx.y * blockDim.x * 65536) + (blockIdx.x * 1024) + threadIdx.x; // calcula o indice do vetor com base nas dimensões de bloco e indice da thread ...
20,038
#include "includes.h" __global__ void oneOfNSelection(float *buffer, int* index, int size, float value) { 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 < size && threadId != index[0]) { buf...
20,039
// includes #include <stdio.h> #include <stdlib.h> // Funcion de liberacion de memoria para el vector que representa la Matriz void liberaVector(float *vec) { free(vec); return; }
20,040
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> /** * Quickhull.cu * Author: Michael Gruesen * A quickhull implementation for NVIDIA GPGPU Compute Capability 2.0 * * Serial QSort Code Adapted * from : Aashish Barnwal * source: http://www.geeksforgeeks.org/iterative-quick-sort/ * * Parall...
20,041
#include <stdlib.h> #include <time.h> void sumArraysOnHost(float* A, float* B, float* C, const int N){ int idx; for(idx = 0; idx < N; idx++){ C[idx] = A[idx] + B[idx]; } } void initialData(float* ip, int size){ time_t t; srand((unsigned int) time(&t)); for(int i = 0; i < size; i++){ ...
20,042
#include <stdio.h> #include <cuda.h> #include <time.h> #include <iostream> using namespace std; #define H 1000 #define W 1000 __global__ void multMatCUDA(int *d_a,int *d_b,int *d_c){ int row = blockIdx.y * blockDim.y + threadIdx.y; int col = blockIdx.x * blockDim.x + threadIdx.x; if(row < H && col < W){ ...
20,043
__global__ void drawAccum(unsigned int* accum, unsigned char* image_accum, int w_accum, int h_accum, int* max) { int x = blockDim.x * blockIdx.x + threadIdx.x; int y = blockDim.y * blockIdx.y + threadIdx.y; int tid = y * w_accum + x; int _r = w_accum * h_accum * 0; int _g = w_accum * h_accum * 1; int _...
20,044
#include<cstdlib> #include<stdio.h> using namespace std; __device__ void getGausspoints(double *gausspoints,double *weights,int nint) { //cout<<"nint "<<nint<<endl; switch (nint) { case 1: { double xk[1]={0.000000000000000000000000}; double wk[1]={2.000000000000000000000000}; gausspoints[0]=xk[1]; weights[0]=w...
20,045
#define DIM 3 #define P_SCALE 30.0f #define RIGHT P_SCALE #define LEFT -P_SCALE #define UP (2*P_SCALE) #define DOWN 0 #define FRONT P_SCALE #define BACK -P_SCALE #define OFFSET 0.01 #define SPHERE_RADIUS 1.0 __device__ bool Sphere_SphereTest(float c1_x,float c1_y,float c1_z,float c1_size, float c2_x,float c2...
20,046
#include "activ.hh" #include "../ops/ops-builder.hh" #include "../ops/vect-relu-leaky.hh" #include "../ops/vect-relu.hh" #include "../ops/vect-sigmoid.hh" ops::Op* leaky_relu(ops::Op* x) { auto& builder = ops::OpsBuilder::instance(); return builder.vect_relu_leaky(x); } ops::Op* relu(ops::Op* x) { auto& b...
20,047
/* v2 for calculating maximum gain, (square root)*2 method is used to get number of parallel threads calculating maximum gain better for large number of MODULES */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #define MAX_TH 1024 //GPU KERNEL--------------------------------------------...
20,048
#include <stdio.h> #include <time.h> #include <unistd.h> #include <stdlib.h> #include <math.h> using namespace std; #define TYPE float __global__ void fwd_3D_16x16_order8( TYPE *g_input, TYPE *g_output, TYPE *g_vsq, /* output initially contains (t-2) step*/const int dimx, const int dimy, const int dimz) { #define BDI...
20,049
/* * Ejercicio 3 Práctica 4: CUDA * Mariana Hernández * Alan Córdova */ #include <stdio.h> #define STRIDE 32 #define OFFSET 0 #define GROUP_SIZE 512 // tamanio #define n 2000 #define m 2000 /* Utilidad para checar errores de CUDA */ void checkCUDAError(const char*); // Kernel that executes on ...
20,050
#include <stdio.h> #include <math.h> #include <unistd.h> #include <cuda_runtime_api.h> #include <time.h> #include <errno.h> /***************************************************************************** * * * * * * Compile with: * nvcc -o cuda_lr cuda_linear.cu * * Dr Kevan Buckley, University of Wolve...
20,051
#include "includes.h" __global__ void vecSum(double* devIn, int pow_step, int n) { //The thread ID (including its block ID) int i = blockIdx.x * blockDim.x + threadIdx.x; //Safety check to prevent unwanted threads. if(pow_step*i < n) //The two 'adjacent' elements of the array (or //the two children in the segment tree...
20,052
#include <stdio.h> #include <cuda.h> __device__ int sumg = 0; __global__ void K() { int num = blockIdx.x * blockDim.x + threadIdx.x; num += num; ++num; atomicAdd(&sumg, num); __shared__ int sum; sum = 0; __syncthreads(); sum += num; } int main() { K<<<100, 32*5>>>(); cudaDeviceSynchronize(); return 0; }
20,053
#include "includes.h" __global__ void tex_kernel(cudaTextureObject_t texture_obj, int num_samples, float* output) { unsigned int idx = blockIdx.x*blockDim.x + threadIdx.x; if (idx < num_samples) { float u = idx / static_cast<float>(num_samples); output[idx] = tex1D<float>(texture_obj, u); } }
20,054
#include <cuComplex.h> #include <cufft.h> #include <vector> #include <stdio.h> #include <cuda.h> #include <thrust/functional.h> #include <thrust/device_ptr.h> #include <thrust/transform_scan.h> #include <thrust/sequence.h> #include <float.h> #include <chrono> using std::vector; static const int THREADS_PER_BLOCK = 10...
20,055
#ifdef _WIN32 # define NOMINMAX #endif #include "kernels.cu" #include <stdio.h> #include <stdlib.h> #include <iostream> #include <string> #include <fstream> #include <math.h> #include <random> //#include <math> #define NUMY 10 #include <time.h> using std::ifstream; using std::string; using std::ofstream; int hibit(...
20,056
#include <stdio.h> #include <random> const unsigned long N = 1lu << 16; const unsigned long block_size = 256; const float epsilon = 1e-5; void rand_array(float* const array, const unsigned long size) { std::mt19937 mt(std::random_device{}()); std::uniform_real_distribution<float> dist(-1.f, 1.f); for (unsigned lo...
20,057
#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 i...
20,058
#include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <thrust/generate.h> #include <thrust/sort.h> #include <thrust/copy.h> #include <algorithm> #include <cstdlib> #include <iostream> int main( int argc, char* argv[] ) { std::cout << "Hello from [ " << argv[ argc - 1 ] << " ]!" << std::endl; ...
20,059
extern __device__ double myDeviceFunc(double* in, int nword) { double z=0.; while(z < 7.777777){ z += 1.0e-5; } return ((double)z); }
20,060
#include "includes.h" __global__ void hello(char *a, int *b) { a[threadIdx.x] += b[threadIdx.x]; }
20,061
//THE SHARED MEMORY PROGRAM FOR MATRIX MULTIPLICATION //AUTHOR : SAURAV RAI //REGD NO: 17558 #include<cuda.h> #include<stdio.h> #include<stdlib.h> #define blockD 32 #define TILE_DIM 32 __global__ void MatrixMulKernel(float* , float* , float*,int ); void MatrixMultiplication(float *, float *, float *,int );...
20,062
/* autor fredy m uaem desonses@gmail.com para mas comentarios */ #include <stdio.h> #include <stdlib.h> #include <cuda_runtime.h> #include <device_launch_parameters.h> /* ejemplo que llena un vector que invierte sus valores */ #define N 30 //tamano de los vectores __global__ void invierte(float *a, float *b) { i...
20,063
#include <stdio.h> #include <cuda.h> #include<math.h> // Kernel that executes on the CUDA device __global__ void square_array(float *a, int N) { int idx = blockIdx.x * blockDim.x + threadIdx.x; if (idx<N) a[idx] = a[idx] * a[idx]; } __global__ void reduce_partials(float *d_in, int step) { int idx = blockIdx.x *...
20,064
// This CUDA program implements vector addition on both the CPU & GPU // // To compile: // nvcc -O3 vector_add.cu -o vector_add // Note: if /usr/local/cuda/bin is not in your $PATH, you will need to // specify the full path to nvcc: /usr/local/cuda/bin/nvcc // // To run: // ./vector_add N // (where N is the number ...
20,065
#include "includes.h" #define SIZ 20 #define num_inp 4 using namespace std; typedef struct edge { int first, second; } edges; __global__ void grads_w2_kernel(double * grads_W2,double * W2,double reg, int size) { int i = blockIdx.x; int j = threadIdx.x; grads_W2[i*size + j] += W2[i*size + j] * reg; }
20,066
/* Copyright 2013--2018 James E. McClure, Virginia Polytechnic & State University This file is part of the Open Porous Media project (OPM). OPM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either ver...
20,067
#include "includes.h" __global__ void maxKernel(float *array, int size, float* max) { extern __shared__ float sdata[]; unsigned int tid = threadIdx.x; unsigned int i = blockIdx.x * 2 * blockDim.x + threadIdx.x; int stride = blockDim.x * 2 * gridDim.x; sdata[tid] = 0; while (i < size) { sdata[tid] = fmaxf(array[i], arra...
20,068
/* Name: Prashanth Mallyampatti Student Id: 200250501 Unity Id: pmallya Algorithm: Bitonic Sort */ #include <stdio.h> #include<stdlib.h> #include <time.h> #include<assert.h> #include<sys/time.h> int threads_ = 0, blocks_ = 0; #ifdef __cplusplus extern "C" { #endif __global__ void bitonic_sort(float *values, int ...
20,069
#include <stdio.h> #define SIDE_SIZE 8 __device__ unsigned long long int cIndex(const unsigned long long int slicesRow, const unsigned long long int row, const unsigned long long int col) { return slicesRow * row + col; } __device__ double cLeft(double* grid, const unsigned long long int slicesRow, const unsigne...
20,070
#include "includes.h" __global__ void blob_rearrange_kernel2_1d(const float *in, float *out, int num, int channels, int width, int height, int widthheight, int padding, int pwidthheight) { int xy = blockIdx.x*blockDim.x + threadIdx.x; if(xy>=widthheight) return; int ch = blockIdx.y; int n = blockIdx.z; float value=...
20,071
#include <stdio.h> __global__ void add(int *a, int *b, int *c, int num) { int i = threadIdx.x; if (i < num) { c[i] = a[i] + b[i]; } } int main(int argc, char* argv[]) { int num = 10; int a[num], b[num], c[num]; int *a_gpu, *b_gpu, *c_gpu; for (int i = 0; i < num; i++) { a...
20,072
#include "includes.h" __global__ void fmad_kernel(double x, double y, double *out) { int tid = blockIdx.x * blockDim.x + threadIdx.x; if (tid == 0) { *out = x * x + y; } }
20,073
#include "includes.h" __global__ void matrix_multiply_kernel(double *matrix, double *vector_in, double *vector_out, long dim_mn){ double out; long i, j; i = threadIdx.x + blockIdx.x * blockDim.x; if (i<dim_mn){ out = 0.; for (j=0; j<dim_mn; j++){ out += matrix[i*dim_mn+j] * vector_in[j]; } vector_out[i] = out; } }
20,074
//#include "../include/clion_cuda.h" #include <iostream> #include <stdio.h> #include <cuda_runtime.h> __global__ void add_f(float *array) { int k = blockIdx.x * blockDim.x + threadIdx.x; array[k] = 10.0; } int main() { int blocks = 1024; int thread_pre_blocks = 30; float *array_host = new float[blocks * thr...
20,075
#include "includes.h" __global__ void getMaxPorb(const int size, const float* class_prob, const int class_num, float* max_prob, int* idx, int *class_idx, const int conf_thresh) { int index = blockIdx.x * blockDim.x + threadIdx.x; if(index < size) { // printf("run here %d!\n", index); float temp_max_prob = 0.0f; const f...
20,076
// Copyright (c) 2020 Saurabh Yadav // // This software is released under the MIT License. // https://opensource.org/licenses/MIT #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <cuda_runtime.h> int main() { cudaError_t err = cudaSuccess; int device_count; err = cudaG...
20,077
// RUN: c-index-test -test-load-source all -x cuda %s | FileCheck %s __attribute__((device)) void f_device(); __attribute__((global)) void f_global(); __attribute__((constant)) int* g_constant; __attribute__((host)) void f_host(); // CHECK: attributes-cuda.cu:3:30: FunctionDecl=f_device:3:30 // CHECK-NEXT: at...
20,078
#include <iostream> #include <chrono> #include "cuda_runtime.h" #include "cuda.h" #include "device_launch_parameters.h" static void HandleError( cudaError_t err, const char *file, int line ) { if (err != cudaSuccess) { printf( "%s in %s at line %d\n", cudaGetErrorString( err ), file, ...
20,079
/** File: modified_SMO.cu * Purpose: Parallel Programming 2017 Final Project: Training Support Vector Machine on multiprocessors and GPUs * the CUDA version. * * Compile: nvcc -o modified_SMO modified_SMO.cu * Run: ex: ./modified_SMO ./data/train-mnist ./data/train-mnist.model 10000 784 1 0.01 0.001 ...
20,080
//__device__ bool inLeftBorder(); //__device__ bool inRightBorder(); //__device__ bool inTopBorder(); //__device__ bool inBottomBorder(); __device__ bool inRange(const int x, const int y, const int x_range, const int y_range); __device__ int globalAddr(const int x, const int y, const int x_size); __device__ int findRo...
20,081
#ifndef __CUDACC__ #define __CUDACC__ #endif #include "cuda_runtime.h" #include "device_launch_parameters.h" #include <cuda.h> #include <device_functions.h> #include <cuda_runtime_api.h> #include<stdio.h> #include<stdlib.h> #include<math.h> #include <string.h> //#define WEI 11 //#define ITEN 5 //void inserirPeso(int...
20,082
#ifndef _GENSPARSEMAT_ #define _GENSPARSEMAT_ void GenSparseMat(float *conVec, int rows, int clms, int* sparseVec, int* idxVec, int* nPostNeurons ) { /* generate sparse representation conVec : input vector / flattened matrix sparseVec : sparse vector idxVec : every element is the start...
20,083
/************************************************************** * * --== Simple CUDA kernel ==-- * author: ampereira * * * Fill the rest of the code * * Insert the functions for time measurement in the correct * sections (i.e. do not account for filling the vectors with random data) * * Before compile cho...
20,084
#include "includes.h" __global__ void pack_kernel(float *d_output, float *d_input, float *d_predicates, float *d_scanned, int length) { int idx = blockDim.x * blockIdx.x + threadIdx.x; if (idx >= length) return; if (d_predicates[idx] != 0.f) { // address int address = d_scanned[idx] - 1; // gather d_output[address] ...
20,085
/* Small CUDA exercise to try to improve efficiency by using two separate streams to set up a staged copying and execution (when instead of one large copy, followed by one large kernel computation, one does it in many small chunks, with copying and computing done in parallel in two streams, after first chun...
20,086
float h_A[]= { 0.71258353642576, 0.9437452696564885, 0.9206953881231721, 0.8592231084651001, 0.8334756851657088, 0.9522180011198649, 0.8877285085592034, 0.5696394460435252, 0.5060703997456785, 0.7131640220581139, 0.8365663893428747, 0.67184394960691, 0.8337799946328023, 0.9468270925152771, 0.924509634091081, 0.57871466...
20,087
#include <stdio.h> #include <math.h> #include <stdlib.h> #include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <iostream> __global__ void jacobi(double *dev_A, double *dev_V, int *dev_pair, int size, int *d_cont, int tolerance); void check (double *A, int n, double tolerance, thrust::host_vector<...
20,088
#include <iostream> #include <cstdlib> using namespace std; __global__ void add_vector(int* a, int* b, int* c, int size) { int id = blockIdx.x * 96 + threadIdx.x; if (id<size) { c[id] = a[id] + b[id]; } } int main() { int v1, v2; cout << "First value ? " << endl; cin >> v1; ...
20,089
#include <stdio.h> #include <cuda.h> #include <cuda_runtime.h> #include <string.h> __device__ int d_islower(char c) { if (c > 96 && c < 123) return 1; else return 0; } __device__ int d_toupper(char c) { if (c > 64 && c < 91) return c; else return c - 32; } __global__ void toUpperString(char* c) { if (d_isl...
20,090
#include <cuda_runtime.h> #include "device_launch_parameters.h" #include <iostream> __global__ void prefix_sum(int iter, int* tooffsets, const int* input, int64_t length, int loader) { int thid = threadIdx.x; extern __shared__ int temp[]; int pout = 0, pin = 1; if (thid < length) { temp[thid] = input[thid +...
20,091
/** * @brief: Dijkstra implementation with CUDA * @author 557966 * @date 31 V 2020 * * make sure the graph file starts with p sp! * nvcc dijkstra2.cu -o dipa2; ./dipa2 ../resources/sampleGraph-1.gr 0 4 * dijkstraCUDA/dicu resources/ny-roads.gr 0 25906 */ #include "cuda_runtime.h" #include "device_launch_param...
20,092
#include <stdio.h> #include <stdlib.h> #include <math.h> /******************************************************************************/ #define BLOCK_SIZE_X 256 #define BLOCK_SIZE_Y 1 __constant__ int c_maxiter; __constant__ float c_xmin; __constant__ float c_ymin; __constant__ float c_x_step; __constant__ float c...
20,093
// From CUDA for Engineering // dist_v2_cuda_unified/kernel.cu #include <iostream> #include <stdio.h> #include <cuda_runtime.h> #define N 1000000000 #define TPB 32 #define DEBUG 0 float scale(int i, int n) { return ((float)i) / (n - 1); } __device__ float distance(float x1, float x2) { return sqrt((x2 - ...
20,094
#include "includes.h" __global__ void computeMinEnergyMatrix(float *energy, float *min_energy, int height, int width) { const int bid = blockIdx.x; const int tid = threadIdx.x; const int pos = bid * blockDim.x + tid; extern __shared__ float shared_row_energy[]; if(pos < width) { for(int i=tid; i<width; i += blockDim....
20,095
/* This works for all. */ #include <stdio.h> #include <stdlib.h> #include <string> #include <float.h> #include <math.h> #include <iostream> #include <climits> #include <vector> #include <stack> using namespace std; //#include <thrust/host_vector.h> //#include <thrust/device_vector.h> struct edge{ int flow,capacity,...
20,096
/* Furthest point sampling GPU implementation * Author Zhaoyu SU * All Rights Reserved. Sep., 2019. * Happy Mid-Autumn Festival! :) */ #include <stdio.h> #include <time.h> #include <sys/time.h> #include <iostream> #define USECPSEC 1000000ULL __global__ void get_bbox_gpu_kernel(int batch_size, int npoint, int nbbox...
20,097
#include "includes.h" __global__ void cinzaGPU1d( unsigned char *image1, unsigned char *res, int pixels ) { int i = threadIdx.x + blockIdx.x*blockDim.x; int cinza; if( i < pixels ) { int idx = 3*i; int r = image1[ idx+2 ]; int g = image1[ idx+1 ]; int b = image1[ idx ]; cinza = (30*r + 59*g + 11*b)/100; res[ id...
20,098
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <iomanip> #include <iostream> #include <vector> #define C 4 #define THREADS 1024 // 2^10 #define MAX 85 #define MAX_S MAX* MAX #define PERM_MAX (MAX * (MAX - 1) * (MAX - 2) * (MAX - 3)) / 24 #define pb push_back #define mp make_pair #...
20,099
#include <stdbool.h> #include <stdio.h> #include <string.h> #include <getopt.h> #include <curand_kernel.h> #include <stdlib.h> #include <cuda.h> #include <sys/time.h> #include "cudaSNormalizeROIs_kernel.cu" #include<chrono> #include<iostream> using namespace std; using namespace std::chrono; int blocks_[20][2] = {{8,8}...
20,100
#include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <string.h> #include <math.h> #define TAM 8 #define NITERACIONES 10 #define TAMBLOCK 2 __global__ void stencil(float *a, float *b){ //Kernel, salto a la GPU. Esta funcion es ejecutada por todos los hilos al mismo tiempo. int idx = blockIdx.x*blockDim....