serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
22,401
#include <stdio.h> #include <cuda_runtime.h> #include <time.h> #include <vector> using namespace std; const int GPUs[] = {0,5}; // If left blank all available GPUs will be used. vector<int> g(GPUs, GPUs + sizeof(GPUs)/sizeof(int)); void configure(size_t size, vector<int*> &buffer_s, vector<int*> &buffer_d, ...
22,402
__global__ void norec(float const * x, float const * y, float const * z, float * q) { auto i = threadIdx.x;; q[i] = x[i] + y[i]*z[i]; } __global__ void rec(float const * __restrict__ x, float const * __restrict__ y, float const * __restrict__ z, float * __restrict__ q) { auto i = threadIdx.x;; q[i] = x[i] ...
22,403
#include "includes.h" // filename: eeTanh.cu // a simple CUDA kernel to square the elements of a matrix extern "C" // ensure function name to be exactly "eeTanh" { } __global__ void tanhGradient(int N, int M, float *z, float *tanh_grad_z) { int i = blockIdx.x * blockDim.x + threadIdx.x; int j...
22,404
#include "includes.h" __global__ void Add(float* d_a, float* d_b, float* d_c, int N) { int id = blockIdx.x * blockDim.x + threadIdx.x; if(id < N) d_c[id] = d_a[id] + d_b[id]; }
22,405
#include <stdio.h> // Function that catches the error void testCUDA(cudaError_t error, const char *file, int line) { if (error != cudaSuccess) { printf("There is an error in file %s at line %d\n", file, line); exit(EXIT_FAILURE); } } // Has to be defined in the compilation in order to get the correct...
22,406
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <functional> #include <curand_kernel.h> #define threadsPerBlock 256 typedef struct path_struct_t { double cost; // path cost. int *path; // best order of city visits } path_t; #define DEBUG #ifdef DEBUG #define cudaCheckError(a...
22,407
#include "includes.h" __global__ void multiply(float *dest, float *a, float *b) { const int i = threadIdx.x; dest[i] = a[i] * b[i]; }
22,408
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include<stdio.h> __global__ void k_means_gpu(int b, int n, int num, const float *xyz, const float *init_xyz, int *result) { //xyz(b,n,3) result(b,n) init_xyz(b,num,3) int batch_idx = blockIdx.x; xyz += batch_idx*n*3; init_xyz += batch_idx*num*3; ...
22,409
#include <math.h> #include <stdio.h> #include <cuda_runtime.h> // Array access macros #define f(i,j) A[(i) + (j)*(m)] #define B(i,j) B[(i) + (j)*(m)] #define Z(x,y) Z[(x) + (y)*(m)] #define f_(x,y) f_[(x) + (y)*(m)] __global__ void Zcalc(float const * const A, float *Z,float const * const H,int patchSize,float patchS...
22,410
#include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <curand_kernel.h> #include <math_constants.h> #include <math.h> //for boolean functionality #include <stdbool.h> extern "C" { __global__ void rtruncnorm_kernel(float *vals, int n, float *mu, float *sigma, float *...
22,411
__global__ void FlexFDM1D_naive(float* U, float* Ux, int N, int alpha, float* stencils) // // Naive version where only global memory and automatic variables are accessed. // { // YOUR TASKS: // - Write body of kernel for computing Finite Difference Approksimations for // threads in the grid. // - Arbitrary size...
22,412
#include <stdio.h> #include <cstdio> #include <stdlib.h> #define WIDTH 10000 typedef struct input{ int x; }input; __global__ void inputkernel(input *c, const input *a) { int i = threadIdx.x + blockIdx.x *100; c[i].x = a[i].x+1; } int main(void) { input *inputt=0; input *minput=0; int *cary=0; int *cary2=0;...
22,413
#include <stdio.h> #include <assert.h> #define N 1000000 __global__ void vecadd(int *a, int *b, int *c){ int idx=blockIdx.x*blockDim.x+threadIdx.x; if (idx<N) c[idx]=a[idx]+b[idx]; } int main (int argc, char **argv){ int a_host[N], b_host[N], c_host[N]; int *a_device, *b_device, *c_device; int i; in...
22,414
#include <stdio.h> // Beginning of GPU Architecture definitions inline int _ConvertSMVer2Cores(int major, int minor) { // Defines for GPU Architecture types (using the SM version to determine // the # of cores per SM typedef struct { int SM; // 0xMm (hexidecimal notation), M = SM Major version, // and m...
22,415
#include <stdio.h> #include <time.h> __global__ void bin_search(int* a, int* l, int* r, int* e, int* searchValue) { int idx = threadIdx.x; int lm = l[0]; int rm = r[0]; int gap = (int)ceil((float)(rm-lm+1)/(float)(256)); int num_proc = (int)ceil((float)(rm - lm + 1)/(float)gap); int currl = idx*gap + lm; if(cur...
22,416
#include <stdio.h> #define BLOCKDIM 512 __global__ void partial (const char *cuStr, int *cuPos, int strLen) { int tid = threadIdx.x; int gid = blockIdx.x * blockDim.x + threadIdx.x; __shared__ int buf[BLOCKDIM]; if (gid > strLen) { return ; } buf[tid] = (cuStr[gid] == ' ') ? tid : -1; for (int i = 1; i <= t...
22,417
/* This program finds the count of Odd numbers in an input integer array. * The program uses shared memory to count the occurence of odd number in each block. * The shared memory counter is then added using parallel reduction algorithm. * Bank conflicts are avoided using padding in the shared memory. * Output of e...
22,418
#include <stdio.h> #include <math.h> #include <time.h> #include <iostream> #include <cuda.h> #include <curand.h> #include <curand_kernel.h> #define MAX_TRIES 100 #define N_LIMIT 20 #define MAX_TEMP_STEPS 500 #define TEMP_START 20 #define COOLING 0.95 #define THREADS 256 #define MAX_CITY 512 #define BOLTZMANN_COEFF 0.1...
22,419
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <float.h> __global__ void transformKernel(float *x ,float *y,float *z,float *transform) { int i=blockIdx.x*blockDim.x+threadIdx.x; /*if (_finite(x[i])|| _finite(y[i])|| _finite(z[i])) return;*/ float x_,y_,z...
22,420
#include <stdio.h> inline void checkCuda(cudaError_t result) { if(result != cudaSuccess) printf("CUDA Error: %s\n", cudaGetErrorString(result)); } void initWith(float num, float *a, int N) { for(int i = 0; i < N; ++i) { a[i] = num; } } __global__ void addVectorsInto(float *result, float *a, float *b, i...
22,421
/** * * * * * Designed and Developed By: Tahir Mustafa - tahir.mustafa53@gmail.com / k132162@nu.edu.pk Akhtar Zaman - k132168@nu.edu.pk Jazib ul Hassan - k132138@nu.edu.pk Mishal Gohar - k132184@nu.edu.pk * * For BS(CS) Final Year Project 2017, NUCES-FAST * Under the supervision of: Dr Jawwad Shamsi (...
22,422
#include <stdlib.h> #include <stdio.h> #include <math.h> __global__ void reduce_kernel(float *in, float *out, int ntot) { // TODO : coder ici int nthreads = 1; int totthreads = blockDim.x; int test = 2; int index = blockIdx.x * blockDim.x + threadIdx.x; while(nthreads!=totthreads) { ...
22,423
#include "includes.h" using namespace std; __global__ void multiplyDigits(char* d_str1, char* d_str2, int* d_matrix, int str1_len, int str2_len) { int row = blockDim.y * blockIdx.x + threadIdx.y; int col = blockDim.x * blockIdx.y + threadIdx.x; int idx = row * str1_len + (col + (str2_len * row)) + 1 + (row); d_m...
22,424
#include <iostream> #include <ctime> #include <time.h> using namespace std; __global__ void GPU_MatMul(float *A, float *B, float *C, int N) { // Multiplication for NxN matrices C=A*B // Every thread computes a single element of C int row = blockIdx.y*blockDim.y + threadIdx.y; int col = blockIdx.x*blockDim.x + thre...
22,425
#include <cuda_runtime.h> #include <math.h> // for truncf #include <stdio.h> #include <curand_kernel.h> /**************************************** ** Helper functions for CUDA encoding ** ** Written by Julieta Martinez, 2016 ** ** jltmtzc@gmail.com ** ** https://www.cs.ubc.ca/~julm/ ** *****...
22,426
#include "includes.h" extern "C" { #ifndef DTYPE #define DTYPE float #endif } __global__ void tensor_5d_equals (const int n, const int c, const int d, const int h, const int w, const DTYPE* x, const int offset_x, const int n_x, const int c_x, const int d_x, const int h_x, const int w_x, const DTYPE* y, const int...
22,427
/* 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 tmp_1 = +1.8785E-20f / atan2f((+1.7303E-35f / acosf(-1.3519E-35f / var_1)), var_2 / +1.9360E35f); float tmp_2 = coshf(+...
22,428
// Matrix addition, GPU version // nvcc matrix_gpu.cu -L /usr/local/cuda/lib -lcudart -o matrix_gpu #include <stdio.h> const int blocksize = 16; const int N = 256; const int gridsize = N / blocksize; __global__ void add_matrix(float *a, float *b, float *c, int N) { // coalesced /* int index_x = blockIdx.x...
22,429
/* 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...
22,430
#include <iostream> #include <math.h> #include <algorithm> #include <map> #include <random> #include <time.h> #include <cuda_runtime.h> using namespace std; __host__ __device__ unsigned hash_func(unsigned key, int hash_num, unsigned tablesize){ int c2=0x27d4eb2d; switch (hash_num){ case 0: key = (key+0x7ed55...
22,431
#include "includes.h" __global__ void bp_output_conv(float *d_output, float *weight, float *nd_preact, const int size, const int kernel_size, const int n_size, const int in_channel, const int out_channel, bool CONV, bool SAME) { const int pos = blockIdx.x * blockDim.x + threadIdx.x; const int totalPos = blockDim.x * gr...
22,432
#include <stdio.h> int main(void){ cudaDeviceProp prop; int count; cudaGetDeviceCount(&count); printf("\nNumber of Devices: %d\n", count); for(int i=0; i<count; i++){ cudaGetDeviceProperties(&prop, i); printf("\n ---Device %d Information---\n", i); printf("Name: %s\n", prop.name); /...
22,433
__global__ void main_kernel() { }
22,434
#include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <thrust/scan.h> extern "C" { void scan_int_wrapper( int *data_in, int N, int *data_out) { thrust::device_ptr<int> dev_ptr_in(data_in); thrust::device_ptr<int> dev_ptr_out(data_out); thrust::inclusive_scan(dev_ptr_in, dev_ptr_...
22,435
// N-S equation demonstration // High Performance Scitific Computation // Cavity Lid Driven Flow // CUDA version // 19M18085 Lian Tongda #include <iostream> #include <cmath> #include <cstdlib> #include <iomanip> #include <fstream> #include <sstream> #include <string> #include <algorithm> using namespace std; // Init...
22,436
#include "includes.h" __global__ void trans_norm_vector(double* A, double* x, double* y, double* tmp, int NX, int NY) { int j; int i = blockDim.x * blockIdx.x + threadIdx.x; tmp[i] = 0; //Α*Χ for (j = 0; j < NY; j++) { tmp[i] = tmp[i] + A[i*NY + j] * x[j]; } }
22,437
#include <iostream> #include <math.h> using namespace std; #define W 500 #define H 500 #define TPB 32 __device__ float square(float x) { return (x*x); } __global__ void distKernel(float *dout, int w, int h, float2 pos) { const int c = blockIdx.x*blockDim.x + threadIdx.x; const int r = blockIdx.y*blockDim.y + thre...
22,438
#include <stdio.h> #include <stdlib.h> #include <math.h> #define RAD_CONV_FAC (1.0f/60.0f)*(M_PI/180.0f) #define DEG_CONV_FAC 180.0f/M_PI /* Compile with: nvcc -O3 -Xptxas="-v" -arch=sm_30 galaxy_distribution.cu Run with: time ./a.out real.txt sim.txt */ /* ---------- Device code ---------- */ /* N = num...
22,439
/** * @file coeff.cu * @brief Filter coefficients * @author John Melton, G0ORX/N6LYT */ /* Copyright (C) * 2015 - John Melton, G0ORX/N6LYT * * Based on code from WDSP written by Warren Pratt, NR0V * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public L...
22,440
//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 maximum read bandwidth of L1 cache for 64 bit read //This code have been tested on Volta V100 architecture #include <std...
22,441
__device__ float g_a = 0; extern "C" __global__ void test(float *a, float *b, const float c) { size_t i = blockDim.x * blockIdx.x + threadIdx.x; a[i] += b[i] * c; }
22,442
#include <iostream> int main(int argc, char* argv[]) { cudaDeviceProp dev_prop; int dev_cnt = 0; cudaGetDeviceCount(&dev_cnt); for(int i=0; i < dev_cnt; ++i) { cudaGetDeviceProperties(&dev_prop, i); std::cout << "Device : " << i << " has compute capability " << dev_prop.major << "."...
22,443
__global__ void init_kernel(int * domain, int domain_x) { // Dummy initialization /*domain[blockIdx.y * domain_x + blockIdx.x * blockDim.x + threadIdx.x] = (1664525ul * (blockIdx.x + threadIdx.y + threadIdx.x) + 1013904223ul) % 3; */ int iy = blockDim.y * blockIdx.y + threadIdx.y; int ix = blockDim.x * bloc...
22,444
#include <cuda.h> #include <stdint.h> extern "C" __global__ void vectorAdd(int *A, int *B, int *C, uint64_t N) { uint64_t i = (uint64_t)blockDim.x * blockIdx.x + threadIdx.x; if (i < N) C[i] = A[i] + B[i]; }
22,445
// RUN: %clang_cc1 -triple spirv64 -aux-triple x86_64-unknown-linux-gnu \ // RUN: -fcuda-is-device -verify -fsyntax-only %s #define __device__ __attribute__((device)) __int128 h_glb; __device__ __int128 d_unused; // expected-note@+1 {{'d_glb' defined here}} __device__ __int128 d_glb; __device__ __int128 bar() { ...
22,446
//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> #...
22,447
///////////////////////////////////////////////////////////////////////////////// //// //// The MIT License //// //// Copyright (c) 2006 Scientific Computing and Imaging Institute, //// University of Utah (USA) //// //// License for the specific language governing rights and limitations under //// Permission is hereby ...
22,448
// Create a sample address sanitizer bitcode library. // RUN: %clang_cc1 -x ir -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm-bc \ // RUN: -disable-llvm-passes -o %t.asanrtl.bc %S/Inputs/amdgpu-asanrtl.ll // Check sanitizer runtime library functions survive // optimizations without being removed or parameter...
22,449
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <iostream> #include <chrono> using namespace std; using namespace std::chrono; int SIZE = 50; const float BLOCK_WIDTH = 8; void add_matrix(int* , int* , int* , int, char); //Just work with same sizes matrices. __global__ void add_matrix_kernel...
22,450
#include <cstdio> #include <cstdlib> #include <iostream> #define Width 32 #define Element 1024 using namespace std; __global__ void MatrixMulKernel(int* Md, int* Nd, int* Pd) { //Thread Index int ty = threadIdx.y; //Row int tx = threadIdx.x; //Col //Pvalue is used to store the element of the matrix //Th...
22,451
#include "includes.h" __global__ void vadd(const float *A, const float *B, float *C, int ds){ for (int idx = threadIdx.x+blockDim.x*blockIdx.x; idx < ds; idx+=gridDim.x*blockDim.x) // a grid-stride loop C[idx] = A[idx] + B[idx]; // do the vector (element) add here }
22,452
/* 1. so vsi proteini enako dolgi ? 2. mutacija */ #include "cuda_runtime.h" #include "device_launch_parameters.h" #include <iostream> #include <stdio.h> #include <time.h> #include <stdlib.h> #include <random> #include <algorithm> // dolzina proteina 5 - 256 #define maxLenProtein 256 #define minLenProtein 5 #define ...
22,453
#include "includes.h" __global__ void cuArraysCopyExtractVaryingOffset(const float *imageIn, const int inNX, const int inNY, float *imageOut, const int outNX, const int outNY, const int nImages, const int2 *offsets) { int outx = threadIdx.x + blockDim.x*blockIdx.x; int outy = threadIdx.y + blockDim.y*blockIdx.y; if(ou...
22,454
/* compile using : nvcc -std=c++11 -arch=sm_35 -DnumOfArrays=<number of arrays> -DmaxElements=<maximum number of elements per array> GPU-ArraySort.cu -o out */ /* Copyright (C) Muaaz Gul Awan and Fahad Saeed This program is free software; you can redistribute it and/or modify it under the terms of the GNU General...
22,455
#include <stdio.h> #include <stdlib.h> #include <time.h> /* square root of number of threads in a block (the number of threads in a block is NT^2) */ #define NT 32 /* length of the target domain */ #define L 10.0 /* number of division for the discretization of the target domain */ #define N 256 /* dimensionless...
22,456
#include "includes.h" __global__ void Sin( float * x, size_t idx, size_t N, float W0) { for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < N; i += blockDim.x * gridDim.x) { x[(idx-1)*N+i] = sin(W0*x[(idx-1)*N+i]); } return; }
22,457
#include <stdio.h> #include <stdlib.h> void cudaHandleError( cudaError_t err,const char *file,int line ) { if (err != cudaSuccess) { printf( "CUDA Error\n%s in %s at line %d\n", cudaGetErrorString( err ),file, line ); exit( EXIT_FAILURE ); } } __host__ __device__ int threads_ceildiv(int size,int blocks){ return...
22,458
/* Copyright 2017 the arraydiff authors 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 applicable law or agreed to in writing, so...
22,459
#include <stdio.h> #include <stdlib.h> __global__ void add(int* d_a, int* d_b, int* d_c) { int t = threadIdx.x; int index = t + blockIdx.x*blockDim.x; d_c[index] = d_a[index] + d_b[index]; } int main( void) { const int N = 512; const int M = 64; int size = N*sizeof(int); int *a, *b, *c; ...
22,460
#include<vector> #include<iostream> #include<algorithm> using namespace std; const int know_stop_size = 100000 + 10; vector<int > know_stop_num[know_stop_size], know_stop_len[know_stop_size]; int nlz(unsigned x){ int n; if (x == 0) return(32); n = 1; if ((x >> 16) == 0) {n = n +16; x = x <<16;} if ((x ...
22,461
/* * Example of using reducing (tree) type algorithms to parallelize finding the sum of * a set of numbers. On a GF 8600 GT the two parallel algorithms (sumControl = 0 or 1) * are about 35 times faster than the serial algorithm also running on the GPU but using * global memory (sumControl=2), for an array of 512...
22,462
#pragma once #include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdlib.h> #include <stdio.h> dim3 *dim3Ctr(int x, int y = 1, int z = 1) { dim3 *a; a = (dim3 *)malloc(sizeof(dim3)); a->x = x; a->y = y; a->z = z; return a; } dim3 *dim3Unit() { dim3 *a; a = (dim3 *)malloc(sizeof(dim3)); ...
22,463
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <assert.h> #include <unistd.h> #include <sys/time.h> #include <cuda.h> #include <cuda_runtime.h> /* Problem size */ #define M 1024 #define N 1024 #define BDIMX 16 #define BDIMY 16 #define FLOAT_N 3214212.01 void init_arrays(double* data) { int i, j;...
22,464
#include "imageprocessing.cuh" #include <stdio.h> #include <iostream> #include <string.h> #include <string> #include <math.h> #include <assert.h> #include <sstream> #include <cuda_runtime.h> // TODO: read about the CUDA programming model: https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#programming-mod...
22,465
#include <iostream> #include <vector> #include <random> #include <time.h> #include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <thrust/transform.h> #include <thrust/copy.h> using std::vector; using std::random_device; using std::mt19937; using std::uniform_real_distribution; #define SIZE 100000...
22,466
/* * Copyright 1993-2008 NVIDIA Corporation. All rights reserved. * * NOTICE TO USER: * * This source code is subject to NVIDIA ownership rights under U.S. and * international Copyright laws. Users and possessors of this source code * are hereby granted a nonexclusive, royalty-free license to use this code * ...
22,467
#include <limits.h> #include <stdio.h> #define ALLOC_SIZE 1024 __global__ void simple_kernel() { int devMem[ALLOC_SIZE]; int i = devMem[0]; i = i*i; // for unreferenced warning } int main() { simple_kernel<<<1, 1>>>(); cudaDeviceReset(); return 0; }
22,468
#include <iostream> #include <ctime> #include <stdio.h> #define N 500000 __global__ void add_kernel(int *a, int *b, int *c) { // blockIdx contains the value of the block index of the block // running // blockIdx can be defined in 2 dim int i = blockIdx.x; // built in variables defined by cuda p...
22,469
#include <stdio.h> __global__ void helloFromGPU(void) { printf("Hello World from GPU %d!\n",threadIdx.x); } int main(void) { printf("Hello World from CPU\n"); helloFromGPU <<<1, 100>>>(); cudaDeviceSynchronize(); return 0; }
22,470
#include "includes.h" __global__ void init(){}
22,471
#include "includes.h" __global__ void Image_SumReduceStep_Kernel( int* devBufIn, int* devBufOut, int lastBlockSize) { // ONLY USE THIS FUNCTION WITH BLOCK SIZE = (256,1,1); // NOTE: This method was originally written to use exactly the amt // of shared memory available for each block, but I believe // I l...
22,472
/* * ARQUITECTURA DE COMPUTADORES * 2º Grado en Ingenieria Informatica * * PRACTICA 2: "Suma De Matrices Paralela" * >> Arreglar for en __global__ * >> Pasar numElem como argumento * * AUTOR: Ivanes */ /////////////////////////////////////////////////////////////////////////// // Includes #include <stdio.h> #include <s...
22,473
#include <cuda_runtime.h> #include <stdio.h> #define CHECK(call)\ {\ const cudaError_t error = call;\ if (error != cudaSuccess)\ {\ printf("Error: %s:%d, ", __FILE__, __LINE__);\ printf("code: %d, reason: %s\n", error, cudaGetErrorString(error));\ exit(1);\ }\ } void initialInt(int *ip, int size) { for (...
22,474
extern "C" __global__ void updateCenters(float *centers, float *images, int *updates, int noClusters) { int gid = blockIdx.x * blockDim.x + threadIdx.x; int imagesOffset; int centersIndex=0; float sum=0; int index=0; float weight; float min; int minCenterIndex=-1; int imageSize=784; float pImage[784]; im...
22,475
 #include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #define NUM_BLOCKS 16 #define BLOCK_WIDTH 1 __global__ void hello() { printf("I am the thread of block %d\n", blockIdx.x); } int main() { hello<<<NUM_BLOCKS, BLOCK_WIDTH>>>(); cudaDeviceSynchronize(); printf("This ...
22,476
#include "includes.h" extern "C" { } __global__ void reverse_conv_filter(const float* x, float beta, float* y, unsigned int filter_len, unsigned int len) { int tid = blockIdx.x*blockDim.x + threadIdx.x; if (tid < len) { if (beta == 0.0f) { for(int i = 0; i < filter_len; ++i) { y[tid*filter_len + i] = x[tid*filter_len +...
22,477
/* Demo: CUDA program to compute the squares of the first N natural numners */ #include <stdio.h> typedef float data_t; // makes it easy to change type later __global__ void square(data_t *d_in, data_t *d_out); // kernel function // note the use of __global_...
22,478
#include "includes.h" __global__ void calcReluForwardGPU(float *in, float *out, int elements) { int id = (blockIdx.x + blockIdx.y*gridDim.x) * blockDim.x + threadIdx.x; if( id < elements ){ float v = in[id]; if ( v < 0 ){ v = 0.0; } out[id] = v; } /* original for( unsigned i = 0; i < data_size; ++i ){ float v = in.dat...
22,479
//Based on the work of Andrew Krepps #include <stdio.h> #include <stdlib.h> #include <assert.h> #define N 256 #define BLOCK_SIZE 16 #define NUM_BLOCKS N/BLOCK_SIZE #define ARRAY_SIZE N #define ARRAY_SIZE_IN_BYTES (sizeof(int) * (ARRAY_SIZE)) ///generate data// __host__ void generateData(int * host_data_ptr, int arra...
22,480
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> #include <math.h> __global__ void complement(int* a , int* b,int n) { int id = threadIdx.x; int m = blockDim.x; int j = 0; if(id!=0 && id!=(m-1)) { for(j=1;j<n-1;j++) { int rem = 0,p=0; int d = a[id*m...
22,481
// the subroutine for GPU code can be found in several separated text file from the Brightspace. // You can add these subroutines to this main code. //////////////////////////////////////////// #include <stdio.h> #include <math.h> #include <stdlib.h> #include <string.h> #include <time.h> #include "cuda.h" const int...
22,482
// g++ -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_OMP -I../../../thrust/ -fopenmp -x c++ exemplo2.cu -o exemplo2 && ./exemplo2 < ../17-intro-gpu/stocks2.csv #include <thrust/device_vector.h> #include <thrust/host_vector.h> #include <iostream> #include <math.h> #include <thrust/iterator/constant_iterator.h> int main()...
22,483
#include <stdio.h> __global__ void initFun(int *nf) { int n = threadIdx.x + blockIdx.x * blockDim.x; nf[n] *= 10; } int main(int argc, char* argv[]) { if (argc < 2) { fprintf(stderr, "USAGE: main <num_of_devices> " "<device_indices>\n"); return -1; } int *info_...
22,484
#include <iostream> #include <numeric> #include <random> #include <vector> // Here you can set the device ID that was assigned to you #define MYDEVICE 1 #define BLOCK_SIZE 512 #define BLOCKS_NUMBER 512 // Part 1 of 6: implement the kernel __global__ void block_sum(const int* input, int* per_block_results, ...
22,485
#include <stdio.h> #include <iostream> #include <fstream> #include <cstring> #include <string> #include <cstdio> #include <cstdlib> #include <cmath> #include <vector> #include <set> #include <iterator> #include <algorithm> using namespace std; // Training image file name const string training_image_fn = "train-images...
22,486
#include <stdio.h> #include <stdlib.h> #define N 250000 struct Strategy { double profitLoss; void (*backtest)(struct Strategy *, struct Tick *); }; struct Tick { long timestamp; double open; double high; double low; double close; double rsi2; double rsi5; double rsi7; doub...
22,487
#include <stdlib.h> #include <stdio.h> #include <limits> #include <algorithm> using namespace std; #define BLOCK_SIZE 512 __global__ void reduce_max(float * in, float * out, int numel, float smallest) { //@@ Load a segment of the input vector into shared memory __shared__ float s[2 * BLOCK_SIZE]; unsigned...
22,488
#include <ctime> #include <cuda.h> #include <iomanip> #include <iostream> using namespace std; #define MASK_WIDTH 5 #define WIDTH 7 // Secuencial void convolution_2D(double *m, double *mask, double *result) { for (int i = 0; i < WIDTH; i++) { for (int j = 0; j < WIDTH; j++) { double Pvalue = 0; in...
22,489
#include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include <cuda_runtime.h> #define WIDTH 512 // 64 ~ 512 #define TILE_WIDTH 16 #define ARYTYPE float ARYTYPE M[WIDTH][WIDTH] = {0}; ARYTYPE N[WIDTH][WIDTH] = {0}; ARYTYPE P[WIDTH][WIDTH] = {0}; ARYTYPE MxN[WIDTH][WIDTH] = {0}; __device__ ARYTYPE Ge...
22,490
#include <stdio.h> #include <stdlib.h> #define TOTAL_THREADS 1024 #define THREADS_PER_BLOCK 256 #define DIVUP(m, n) ((m) / (n) + ((m) % (n) > 0)) __global__ void gather_points_kernel(int b, int c, int n, int m, const float *__restrict__ points, ...
22,491
#include "includes.h" __device__ double dnorm(float x, float mu, float sigma) { float std = (x - mu)/sigma; float e = exp( - 0.5 * std * std); return(e / ( sigma * sqrt(2 * 3.141592653589793))); } __global__ void log_truncNorm(float *out, float *unifVals, int N) { int myblock = blockIdx.x + blockIdx.y * gridDim.x; /* h...
22,492
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <iostream> int main() { int device; cudaDeviceProp properties; cudaError_t err = cudaSuccess; err = cudaGetDevice(&device); err = cudaGetDeviceProperties(&properties, device); std::cout << "processor count" << properties.multiProcessorC...
22,493
#include<cuda_runtime.h> #include<stdio.h> #include<iostream> //define the multithread action __global__ void cube(float * d_out, float * d_in){ int idx = threadIdx.x; float f = d_in[idx]; d_out[idx] = f*f*f; } //start main activity int main(int argc,char **argv){ //initilize array specs const int ARRA...
22,494
//xfail:BOOGIE_ERROR //main.cu: error: possible read-write race //however, this didn't happen in the tests // In CUDA providing static and __attribute__((always_inline)) SHOUD NOT // keep a copy of inlined function around. //ps: the values from A[N-1-offset] to A[N-1] always will receive unpredictable values, //because...
22,495
#include<stdio.h> #include<cuda.h> #include<string.h> #include<stdlib.h> void print_matrix(int* mat, int rows, int cols) { for(int i=0; i<rows; i++) { for(int j=0; j<cols; j++) { printf("%d ", mat[i*cols + j]); } printf("\n"); } } void print_matrix_file(FILE* f, int* mat, i...
22,496
#include "date.hh" #include <chrono> namespace date { long now() { return std::chrono::duration_cast<std::chrono::milliseconds>( std::chrono::system_clock::now().time_since_epoch() ).count(); } }
22,497
#include<stdio.h> #include<stdlib.h> // This value is the largest subsets we must unrank. #define LARGEST_SUBSET 5 // This is value is the largest number a graph could have. // It is 2^(LARGEST_SUBSET*LARGEST_SUBSET)-1 (i.e. the LARGEST_SUBSET x LARGEST_SUBSET matrix of all 1's). #define SMALLEST_GRAPH 33554431 // D...
22,498
#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <thrust/device_vector.h> #include <thrust/execution_policy.h> #include <thrust/host_vector.h> #include <thrust/scan.h> #define MAX_VALUE ((1UL << 24) + 1U) #define BLOCK_DIM (16U) #define GRID_DIM (16U) typedef unsigned uint; #define CSC(call) \ ...
22,499
#include <string.h> #include <stdint.h> #include <sys/types.h> #include "seq_sha1.cuh" #ifdef HMAC_SHA1_DATA_PROBLEMS unsigned int sha1_data_problems = 1; #endif void lrad_hmac_sha1(const unsigned char *text, int text_len, const unsigned char *key, int key_len, unsigned char *digest...
22,500
/* * Title: prefixScan.cu * Author: 陈志韬 * Student ID: SA12011089 */ #include<stdio.h> #include<stdlib.h> #include<assert.h> /*#include<c*/ #define NUM_BANKS 16 #define LOG_NUM_BANKS 4 #define CONFLICT_FREE_OFFSET(n) \ ((n) >> NUM_BANKS + (n) >> (2 * LOG_NUM_BANKS)) #define DATA_SIZE 32 #define DEFAULT_BLOCK_...