serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
16,101 | // This is a generated file, do not edit it!
#pragma once
#include <stdint.h>
typedef struct CategoricalDataPoint {
int32_t DataPointId;
float Weight;
uint8_t Class;
uint32_t Categories;
} CategoricalDataPoint;
|
16,102 | #include <cstdlib>
#include <iostream>
using namespace std;
cudaEvent_t start, stop;
void startKernelTime (void) {
cudaEventCreate(&start);
cudaEventCreate(&stop);
cudaEventRecord(start);
}
void stopKernelTime (void) {
cudaEventRecord(stop);
cudaEventSynchronize(stop);
float milliseconds = 0;
cudaEventElap... |
16,103 | #include <stdio.h>
#include <curand.h>
int main() {
int n = 20;
float* h_xs;
float* d_xs;
h_xs = (float*)malloc(n*sizeof(float));
cudaMalloc(&d_xs, n*sizeof(float));
curandGenerator_t prng;
curandCreateGenerator(&prng, CURAND_RNG_PSEUDO_MTGP32); // single-precision
curandSetPseudoRan... |
16,104 | // Using CUDA device to calculate pi
#include <stdio.h>
#include <cuda.h>
extern "C" double getTime(void);
#define NBIN 1000000000 // Number of bins
// Kernel that executes on the CUDA device
__global__ void cal_pi(double *sum, int nbin, double step, int nthreads, int nblocks) {
int i;
double x;
int idx = blockId... |
16,105 | #include <stdio.h>
#include <iostream>
#include <math.h>
using namespace std;
const int max_movie = 1683;
const int max_user = 944;
#define THREAD_NUM 256
#define BLOCK_NUM 32
__global__ static void test(float* rate,float* result)
{
const int tid=threadIdx.x;
const int bid=blockIdx.x;
int i,k,j;
float sum;
for(i=... |
16,106 | #include <cuda.h>
#include <stdio.h>
__device__ int counter;
__host__ __device__ void fun() {
++counter;
}
__global__ void printk() {
fun();
printf("printk (after fun): %d\n", counter);
}
int main() {
//counter = 0;
//printf("main: %d\n", counter);
printk <<<1, 1>>>();
cudaDeviceSynchronize();
//fun();
//p... |
16,107 | #include <stdlib.h>
#include <cstdio>
#include <math.h>
// this kernel computes the vector sum c = a + b
// each thread performs one pair-wise addition
__global__ void vector_add(const float *a,
const float *b,
float *c,
const size_t n){
... |
16,108 |
template <class T>
class Complex {
private:
T _real;
T _imag;
public:
__device__ Complex() {
this->_real = 0;
this->_imag = 0;
}
__device__ Complex(T real, T imag) {
this->_real = real;
this->_imag = imag;
}
__device__ T real() { return this->_real; }
__device__ T imag() { return ... |
16,109 | //$Id: mycudamath.cu,v 1.2 2010/05/15 16:24:57 afs Exp $
__device__ void choldcU(float* a, int* pn, float* y)
{
int n = *pn;
int i,j,k;
float sum;
unsigned int ij, ik, jk, ii, ji, nk;
//
for (i=0;i<n;i++)
for (j=0;j<n;j++) {
ij=i+n*j;
y[ij] = a[ij];
}
//
for (i=0;i<n;i++) {
for (j=i;j<n;j++) {... |
16,110 | //#ifndef CONFIG_GOL3D_CU_
//#define CONFIG_GOL3D_CU_
//
//#include <stdio.h>
//#include <stdlib.h>
//
////3D functions CA definition
////proto functions defined by user in config.cpp for 2D automaton
//
//void callback3D(unsigned int currentsteps){
//
// printf("callback 3D %d", currentsteps);
//
//}
//
//
////mod 2 a... |
16,111 | #include "includes.h"
__global__ void saxpy_kernel(const float a, const float* x, const float* y, float* result, unsigned int len) {
unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < len) result[idx] = a * x[idx] + y[idx];
} |
16,112 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define A_COL 7
#define A_ROW 2
#define B_COL 12
#define B_ROW 7
/*
Must be a power of 2
*/
#define THREADS_PER_BLOCK 4
__global__ void matProd(int *a,int *b,int *res){
int colIdx=threadIdx.x+blockDim.x*blockIdx.x;
int rowIdx=threadIdx.y+blockDim.y*blo... |
16,113 | #include "includes.h"
__global__ void VecSubFp32(float* in0, float* in1, float* out, int cnt)
{
int tid = blockIdx.x * blockDim.x + threadIdx.x;
if (tid < cnt) {
out[tid] = in0[tid] - in1[tid];
}
} |
16,114 | #include "includes.h"
__global__ void reduceInterleaved (int *g_idata, int *g_odata, unsigned int n)
{
// set thread ID
unsigned int tid = threadIdx.x;
unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x;
// convert global data pointer to the local pointer of this block
int *idata = g_idata + blockIdx.x * blockDi... |
16,115 | #include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
__global__ void sum(float* input)
{
int tid = threadIdx.x;
float number_of_threads = blockDim.x;
int step_size = 1;
while(number_of_threads > 0){
if(tid < number_of_threads)
{
int first = tid*step_size*2;
int second = first + ... |
16,116 | #include <stdio.h>
#include <cuda_runtime_api.h>
__global__ void mykernel(int *data){
(*data)++;
}
int main(void)
{
int numDevices;
if (cudaGetDeviceCount(&numDevices) != cudaSuccess) {
fprintf(stderr, "Error calling cudaGetDeviceCount\n");
return -1;
}
printf("found %d devices\n", ... |
16,117 | /**
File name: bfs_cpu_array_multi.cu
Author: Yuede Ji
Last update: 21:54 10-02-2015
Description: Using array to implent CPU version of bfs.
Calculate the shortest distance between each other
**/
#include <stdio.h>
#include <queue>
#include <stdlib.h>
#include <string.h>
using namespace std;
#define N 1024 /... |
16,118 | #include "probe_reader.cuh"
|
16,119 | //source: https://github.com/lzhengchun/matrix-cuda/blob/master/matrix_cuda.cu
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <assert.h>
#define TYPE float
/*
Returns the current time in miliseconds.
*/
double getMilitime(){
struct timeval ret;
gettimeofday(&ret, NULL);
... |
16,120 | #define WINDOWS 1
#ifdef WINDOWS
// Import these libraries if using MS Visual Studio for development.
// They are needed by nvcc to interface with MS Visual Studio.
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#endif // !WINDOWS
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define SIZE... |
16,121 | #include <cstdio>
/* #include <cstdlib> */
/* #include <vector> */
__global__ void sort(int *key, int *bucket, int n, int range) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i >= n) return;
extern __shared__ int b[]; // buckets shared in each block
for (int j=0; j<range; j++) ... |
16,122 | #include <stdio.h>
#include <time.h>
#define N 64
#define TPB 32
#define K 3
#define MAX_ITER 10
__device__ float distance(float x1, float x2)
{
return sqrt((x2-x1)*(x2-x1));
}
__global__ void kMeansClusterAssignment(float *d_datapoints, int *d_clust_assn, float *d_centroids)
{
//get idx for this datapoint
const ... |
16,123 | /*
Barker Homework 8
Finding the problem with GPU dot product
To compile: nvcc dotProductRobustNot.cu -O3 -o dotProductRobustNot -lcudart
To run: ./dotProductRobustNot lengthofvector sizeofblock
*/
#include <sys/time.h>
#include <stdio.h>
// max number of block 65535
// max number of threads per block 1024
// m... |
16,124 | #include "includes.h"
__global__ void subsample(float *input, float *output, float *weight, float *bias, int input_n, int input_h, int input_w, int kH, int kW, int dH, int dW)
{
// iterators
int xx, yy;
// output size
int output_w = (input_w - kW) / dW + 1;
int output_h = (input_h - kH) / dH + 1;
// compute offsets b... |
16,125 | #include <iostream>
#include <stdio.h>
#include <cuda.h>
#define N 15000
using namespace std;
__global__ void MatrVectMul(int *d_c, int *d_a, int *d_b)
{
int i = blockIdx.x*blockDim.x+threadIdx.x;
if(i<N)
{
d_c[i]=0;
for (int k=0;k<N;k++)
d_c[i]+=d_a[i+k*N]*d_b[k];
}
}
//: threadIdx.x x,
... |
16,126 | #include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <fcntl.h>
#include <cuda.h>
#include "string.h"
#define DEFAULT_THRESHOLD 4000
#define DEFAULT_FILENAME "ansel3.ppm"
__global__ void sobel(unsigned int *ingoing, int *outgoing, int xsize, int ysize, int threshold) {
int x = th... |
16,127 | /*
The reference homepage
https://cuda-tutorial.readthedocs.io/en/latest/tutorials/tutorial01/
*/
#include<stdio.h>
#include<stdlib.h>
#define N 1000000
void vector_add(float *out, float *a, float *b, int n)
{
for(int i=0; i<n; ++i){
out[i] = a[i] + b[i];
}
}
/*cuda gpu kernel*/
/*naive kernel*/
__global__ ... |
16,128 | /**atomic operation 原子操作
* 考虑大量的线程需要同时访问同一内存区域的内存,特别进行写入操作,容易出现很危险的情况。
* 原子操作是不可以被其他线程扰乱的原子性的整体完成的一组操作。
* 《UNIX 环境高级编程》书籍中有对 原子操作 详细的讲解。
*/
#include <stdio.h>
// Define the number of threads.
#define NUM_THREADS 10000
// Define the size of vector.
#define SIZE 10
// Define the number of blocks.
#define BLOCK_WIDT... |
16,129 | #include <thrust/device_vector.h>
#include <thrust/transform.h>
#include <thrust/sequence.h>
#include <thrust/copy.h>
#include <thrust/fill.h>
#include <thrust/replace.h>
#include <thrust/functional.h>
#include <iostream>
struct saxpy_functor
{
const float a;
saxpy_functor(float _a) : a(_a) {}
__host__ __devic... |
16,130 | #include <stdio.h>
extern "C" {
void dtd_test_new_tile_init(int *dev_data, int nb, int idx);
void dtd_test_new_tile_sum_add(int *dev_data, int nb, int idx, int *acc, int verbose);
void dtd_test_new_tile_multiply_by_two(int *dev_data, int nb, int idx);
}
__global__ void dtnt_init(int *dev_data, int nb, int idx)
{
... |
16,131 |
#include "dcnv2.cuh"
#include <cublas_v2.h>
#include "common.cuh"
template<typename scalar_t>
static __device__ scalar_t dcn_im2col_bilinear(
const scalar_t* input, const int width_step,
const int width, const int height,
scalar_t y, scalar_t x
){
int y_low = floor(y);
int x_low = floor(x);
... |
16,132 | #include "includes.h"
__global__ void nan_kernel(float* data, const bool* mask, int len, float nan) {
int tid = threadIdx.x + blockIdx.x * blockDim.x;
if (tid >= len) return;
if (!mask[tid]) data[tid] = nan;
} |
16,133 | #include "includes.h"
__global__ void toGrayScale(unsigned char *output, unsigned char *input, int width, int height, int components)
{
int column = blockIdx.x * blockDim.x + threadIdx.x;
int row = blockIdx.y * blockDim.y + threadIdx.y;
if (row >= height || column >= width)
return;
int index = column + row * width;
u... |
16,134 | #include <stdio.h>
// add() will execute on the device and will be called from the host
// as add runs on the device, we need to use pointers because a,b and c must point to device memory and we need to allocate memory on the GPU
__global__ void add(int *a, int *b, int *c)
{
*c = *a + *b;
printf("Result %d ", ... |
16,135 | #include <stdio.h>
#include <cstdlib>
__global__
/* Kernel to square array on GPU */
void squareArray(unsigned int *input, unsigned int *result) {
unsigned int idx = (blockIdx.x * blockDim.x) + threadIdx.x;
result[idx] = input[idx] * input[idx];
}
unsigned int ARRAY_SIZE, ARRAY_BYTES;
/* Print array of integers, 2... |
16,136 | /*
Jaitirth Jacob - 13CO125 Vidit Bhargava - 13CO151
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define cudaCheckError() { \
cudaError_t e=cudaGetLastError(); \
if(e!=cudaSuccess) { ... |
16,137 | #include "includes.h"
__global__ void histogram_kernel(int* PartialHist, int* DeviceData, int DataCount,int* timer)
{
int tid = threadIdx.x;
int gid = blockIdx.x * blockDim.x + threadIdx.x;
int stride = blockDim.x * gridDim.x;
clock_t start_atomic=0;
clock_t stop_atomic=0;
extern __shared__ int hist[];
if(tid==0)
{
s... |
16,138 | #include "device_launch_parameters.h"
#include <iostream>
#include <stdio.h>
#include <cuda_runtime.h>
#include <time.h>
using namespace std;
#define eps 1e-4
__global__ void cal_hist(float *da, int *hist_da, int N, int M){
int bx = blockIdx.x;
int tx = threadIdx.x;
int idx = bx * blockDim.x + tx;
if(... |
16,139 | extern "C" __global__ void loop0(int* C, int* A, int* B) {
size_t id = blockIdx.x * blockDim.x + threadIdx.x;
C[id] = A[id] + B[id];
}
extern "C" __global__ void loop1(int* D, int* C) {
size_t id = blockIdx.x * blockDim.x + threadIdx.x;
D[id] = C[id] * 10;
}
extern "C" __global__ void loop2(int* E, int* D) {
... |
16,140 | /*
* reduction kernel. Initially, each thread will copy 1 item of data
* from global to shared memory. Then will will do the binary tree dance.
*/
__global__ void reduce(float* out, float* in, int size) {
__shared__ float temp[1024];
int index = blockDim.x*blockIdx.x + threadIdx.x;
int myId = threadIdx.x; // a... |
16,141 | __global__ void
mat_transpose(float *a, float *out, int size_x, int size_y)
{
const int i = blockDim.y * blockIdx.y + threadIdx.y,
j = blockDim.x * blockIdx.x + threadIdx.x;
if (i < size_x && j < size_y)
{
out[j * size_y + i] = a[i * size_y + j];
}
}
|
16,142 | #include "includes.h"
#define N 10000000 //input data size: 10,000,000
#define BLOCKSIZE 1024
/* prefix sum */
using namespace std;
__global__ void add(double* in, double* out, int offset, int n){
int gid = threadIdx.x + blockIdx.x * blockDim.x;
if(gid >= n) return ;
out[gid] = in[gid];
if(gid >= offset)
out[gid]... |
16,143 | #include <stdio.h>
#include <stdint.h>
#include <assert.h>
// CUDA runtime
#include <cuda_runtime.h>
// helper functions and utilities to work with CUDA
// #include <helper_functions.h>
// #include <helper_cuda.h>
// #define STRIDE 4 // stide to access new line
__global__ void measure_hit(const int* mem, const in... |
16,144 |
#include <stdio.h>
#include <cuda.h>
#define ARRAY_SIZE 2097120
#define N 5
#define HLINE "----------------------------------------------------\n"
#define NTIMES 10
void printResults();
void printDeviceDetails();
void cudaSafeMalloc(void ** , size_t );
void CudaGetDeviceProperties(cudaDeviceProp *, int);
void CudaGe... |
16,145 | #include <thrust/device_vector.h>
#include <thrust/extrema.h>
#include <thrust/transform.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/functional.h>
#include <thrust/sort.h>
#include <thrust/unique.h>
#include <thrust/copy.h>
#include <iostream>
#include <cstdint>
#define PRINTER(name) print(#nam... |
16,146 | __device__ double mc(double m, double c) {
return m*c;
}
|
16,147 | #include <cuda_runtime_api.h>
#include <stdio.h>
__global__ void kernel() {
int a = blockIdx.x * blockDim.x + threadIdx.x;
int b = blockIdx.x;
int c = gridDim.x;
int d = gridDim.x * blockDim.x;
printf("Hello World, my number: %d, block number: %d, blocks: %d, threads: %d\n", a, b, c, d);
}
... |
16,148 | #include "includes.h"
__global__ void x2(float* x3, float x4, int x5) {
int x6 = gridDim.x * blockDim.x;
int x7 = threadIdx.x + blockIdx.x * blockDim.x;
while (x7 < x5) {
x3[x7] = x4;
x7 = x7 + x6;
}
} |
16,149 | #include<stdio.h>
#include <stdlib.h>
#define Nrows 3
#define Ncols 5
__global__ void fillMatrix (float *devPtr, size_t pitch)
{
int tid = blockIdx.x * blockDim.x + threadIdx.x;
if (tid < Ncols)
{
*((float * )((char *) devPtr + pitch * 0) + tid) = 1.0f;
*((float * )((char *) devPtr + pitc... |
16,150 | #include "includes.h"
__global__ void mat_mult_kernel(int *mat_a, int *mat_b, int *result, int a_rows, int a_cols, int b_cols) {
int tid = threadIdx.x + blockIdx.x * blockDim.x;
while (tid < a_rows) {
for (int j = 0; j < b_cols; j++) {
int temp_res = 0;
for (int k = 0; k < a_cols; k++) {
temp_res += mat_a[tid * a_cols... |
16,151 | #include "math.h"
#define SMALLEST_FLOAT 1.175494351E-38
extern "C"
__global__ void transMatrixCalc(int n, double* ad, double* bd, double* ed, double* cd,
double bl, double catRate, double apRate, int catNum) {
__shared__ double as[32][32];
__shared__ double bs[32][32];
__shared__ double es[32];
... |
16,152 | /*
#ifndef __CUDACC__
#define __CUDACC__
#endif
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
static const int wholeArraySize = 100000000;
static const int blockSize = 16;
static const int gridSize = 4; //this number is hardware-dependent; us... |
16,153 | extern "C"
{
__global__ void stanh_32(const int lengthA, const float alpha, const float *a, float *b)
{
int i = threadIdx.x + blockIdx.x * blockDim.x;
if (i<lengthA)
{
b[i] = alpha*tanh(a[i]);
}
}
} |
16,154 | #include "includes.h"
__global__ void subtract_kernal(float* data, float f, const int totaltc)
{
int idx = threadIdx.x + (blockIdx.x + blockIdx.y*gridDim.x)*MAX_THREADS;
if(idx < totaltc){
data[idx] = data[idx] - f;
}
} |
16,155 | #include "includes.h"
extern "C"
extern "C"
extern "C"
extern "C"
extern "C"
extern "C"
__global__ void fSigmoid( const float* arguments, float* results, const long size ) {
const int X = gridDim.x;
const int index = gridDim.y * X * threadIdx.x + X * blockIdx.y + blockIdx.x;
if(index < size) {
results[index] = 1.... |
16,156 | #include "assignmentHPC2.cuh"
#include <iostream>
using namespace std;
int main() {
cout<<"\n\n--------------------------- RESULTS -------------------------------\n"<<endl;
// Vector Addition on CPU & GPU
cout<<"\n\n--------------------------- VECT ADD\n\n"<<endl;
vec_add();
// Matrix Vector... |
16,157 | #include "includes.h"
/*!
* Copyright (c) 2017 Microsoft
* Licensed under The MIT License [see LICENSE for details]
* \file deformable_psroi_pooling.cu
* \brief
* \author Yi Li, Guodong Zhang, Jifeng Dai
*/
/***************** Adapted by Charles Shang *********************/
#define CUDA_KERNEL_LOOP(i, n) ... |
16,158 | #include <sys/time.h>
#include <random>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#define ARRAY_SIZE (2<<28)
#define TPB 256
double cpuSecond() {
struct timeval tp;
gettimeofday(&tp, NULL);
return ((double)tp.tv_sec + (double)tp.tv_usec*1.e-6);
}
/*
Single-precision A*X + Y for c... |
16,159 | /* Written by : Eric Tan
*/
#include <iostream>
#include <cmath>
#include <array>
#include <cuda.h>
#define MAX_MASK_SIZE 50
#define TILE_SIZE 512
#define N_TILE 4
/*-------------------------------------------------------------------------------------------------
* GLOBAL CONSTANTS
*-----------------------------... |
16,160 | #include <thrust/device_ptr.h>
#include <thrust/sort.h>
#include <thrust/scan.h>
void sort(const int size, int * key, int * value) {
thrust::device_ptr<int> keyBegin(key);
thrust::device_ptr<int> keyEnd(key+size);
thrust::device_ptr<int> valueBegin(value);
thrust::sort_by_key(keyBegin, keyEnd, valueBegin);
}
... |
16,161 | // Stimulation of information diffusion in social network with
//respect to time in social network using CUDA
// Parallel Processing course assignment
// Author : Gourab Saha
//Contact : 9051110501
// To compile : nvcc prog5.0.cu
#include<stdio.h>
#include<cuda.h>
#include<math.h>
#include <stdlib.h>
#include <... |
16,162 | #include <stdio.h>
#include <cuda_runtime.h>
#include <asm/unistd.h>
#include <fcntl.h>
#include <inttypes.h>
#include <linux/kernel-page-flags.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/mount.h>
#include <sys/mman.h>
#include... |
16,163 | #include "includes.h"
__global__ void callOperation(int *a, int *res, int x, int n)
{
int tidx = blockDim.x * blockIdx.x + threadIdx.x;
int tidy = blockDim.y * blockIdx.y + threadIdx.y;
if (tidx >= n || tidy >= n) {
return;
}
int tid = tidx * n + tidy;
res[tid] = a[tid] * x;
} |
16,164 |
// GPU kernel
// data_size = data_size_per_thread
__global__ void summation_kernel(int data_size, float* data_out)
{
// Question 8
extern __shared__ float s_res[];
int ind = blockIdx.x * blockDim.x + threadIdx.x;
int tid = threadIdx.x;
float res = 0.0F;
int op = -1;
for(int j = ind * data_size; j < (ind + 1)... |
16,165 | __device__ static int hash[] = {208, 34, 231, 213, 32, 248, 233, 56, 161, 78, 24, 140, 71, 48, 140, 254, 245, 255, 247, 247, 40, 185, 248, 251, 245, 28, 124, 204, 204, 76, 36, 1, 107, 28, 234, 163, 202, 224, 245, 128, 167, 204, 9,
92, 217, 54, 239, 174, 173, 102, 193, 189, 190, 121, 100, 108, 167, 4... |
16,166 | #include <stdio.h>
const int ARRAY_LENGTH = 100000;
const int THREAD_COUNT = 1000;
const int ARRAY_BYTES = ARRAY_LENGTH * sizeof(float);
__global__ void array_init(float *d_in) {
int idx = blockIdx.x * THREAD_COUNT + threadIdx.x;
d_in[idx] = idx;
}
__global__ void cube(float *d_in, float *d_out) {
int id... |
16,167 | /**
* Vector addition: C = A + B.
*
* This sample is a very basic sample that implements element by element
* vector addition.
*/
#include <stdio.h>
# ifdef WIN32
# include <time.h>
# else
# include <sys/time.h>
# endif
// For the CUDA runtime routines (prefixed with "cuda_")
#include <cuda_runtime.h>
/* Small... |
16,168 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <cstdio>
__global__ void printHelloGPU()
{
printf("Hello World from the GPU\n");
}
int main()
{
printHelloGPU<<<5,5>>>();
cudaDeviceSynchronize();
getchar();
return 0;
} |
16,169 | #include <iostream>
#include <cmath>
#include <cstdio>
#define ILP 8
__global__
void add(int n, float* x, float* y, float* z) {
int tid = threadIdx.x + ILP * blockDim.x * blockIdx.x;
for (int i = 0; i < ILP; ++i) {
int current_tid = tid + i * blockDim.x;
z[current_tid] = 2.0f * x[curr... |
16,170 | #define TRIG_IMPL(NAME) \
template<typename Destination, typename Data> \
__global__ void NAME##Arrays(size_t elements, Destination *dst, Data *data) { \
const size_t kernelIn... |
16,171 | #include <stdio.h>
#define DSIZE 1024
__global__ void prescan(int *d_output, int *d_input, int n)
{
extern __shared__ int shmem[];
int T = threadIdx.x;
int offset = 1;
//there are n/2 threads so each thread must load 2 data points
shmem[2*T] = d_input[2*T]; // load even indices into shared memory... |
16,172 | #include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define true 1
#define false 0
__device__
int min_distance(int dist[], int spt_set[], int n) {
int min = INT_MAX, min_index;
for (int v = 0; v < n; v++) {
if (spt_set[v] == false && dist[v] <= min){
min = dist[v]... |
16,173 | #include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
#include <unistd.h>
int main(){
}
|
16,174 | #include <stdio.h>
#include "cuda.h"
#define max(x,y) ((x) > (y)? (x) : (y))
#define min(x,y) ((x) < (y)? (x) : (y))
#define ceil(a,b) ((a) % (b) == 0 ? (a) / (b) : ((a) / (b)) + 1)
void check_error (const char* message) {
cudaError_t error = cudaGetLastError ();
if (error != cudaSuccess) {
printf ("CUDA error :... |
16,175 | // nvcc -O3 -std=c++14 --expt-relaxed-constexpr -gencode arch=compute_70,code=sm_70 divergence.cu
#include<cmath>
#include<iostream>
#include<memory>
__global__
void set(double * v, int n, int flag, double * __restrict__ res) {
auto first = blockIdx.x * blockDim.x + threadIdx.x;
for (int i=first; i<n; i+=gridDim.x... |
16,176 | #include <stdio.h>
#include <cuda.h>
#define M 6
#define N 6
#define MN (M*N)
#define BLOCK_SIZE 2
#define IDX(i,j) (i*N+j)
void initialize1(float *mat, int m, int n) {
for(int i=0; i<m; i++) {
for(int j=0; j<n; j++) {
mat[IDX(i,j)] = i+j;
}
}
}
void initialize2(float *mat, int m,... |
16,177 | #include "includes.h"
#define FALSE 0
#define TRUE !FALSE
#define NUMTHREADS 16
#define THREADWORK 32
__global__ void gpuSignif(const float * gpuNumPairs, const float * gpuCorrelations, size_t n, float * gpuTScores)
{
size_t
i, start,
bx = blockIdx.x, tx = threadIdx.x;
float
radicand, cor, npairs;
start = bx ... |
16,178 | #include "includes.h"
/* This code will generate a fractal image. Uses OpenCV, to compile:
nvcc CudaFinal.cu `pkg-config --cflags --libs opencv` */
typedef enum color {BLUE, GREEN, RED} Color;
__global__ void convert_to_hsv(unsigned char *src, float *hsv, int width, int heigth, int step, int channels) {
float r,... |
16,179 | #include <iostream>
#include <math.h>
__global__ void reduce0(int *d_in, int *d_out){
extern __shared__ int sdata[];
unsigned int tid = threadIdx.x;
unsigned int i = blockIdx.x * blockDim.x + threadIdx.x;
sdata[tid] = d_in[i];
__syncthreads();
for (unsigned int s=1; s<blockDim.x; s*=2){
... |
16,180 | /****************************************************************************
Similar to factorise_3_0 but solves the problem with 4 threads using a
block method for search space partitioning. It is included here to
accompany a CUDA version of the program.
Compile with:
nvcc -o pswcuda pswcuda.cu
Dr... |
16,181 | #include<bits/stdc++.h>
using namespace std;
int main( void ) {
cudaDeviceProp prop;
int count;
cudaGetDeviceCount( &count );
cout<<"count: "<<count<<endl;
for (int i=0; i< count; i++) {
cudaGetDeviceProperties( &prop, i );
//Do something with our device's properties
}
}
|
16,182 | #ifndef __CHECK_PRIME_KERNEL
#define __CHECK_PRIME_KERNEL
#include "cuda.h"
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
__global__ void CheckPrime_Kernel(int A, int B)
{
// Because of the simplicity of this tutorial, we are going to assume that
// every block has 256 threads. Each thread simply ... |
16,183 | /*
* Hello World Program from GPU
*/
#include<stdio.h>
__global__ void helloWorldFromGPU(void)
{ int x= threadIdx.x;
printf("Hello World from GPU! thread id %d\n",x);
}
int main(void)
{
printf("Hello World from CPU!");
helloWorldFromGPU<<<1,10>>>();
cudaDeviceSynchronize();
return 0;
}
|
16,184 | #include <cuda_runtime.h>
#include <stdio.h>
#define CHECK(call) \
{ \
cudaError_t error = call; \
if(error != cudaSuccess){ \
printf("ERROR: %s:%d\n", __FILE__, __LINE__); \
printf("error: %d reason:%s\n", error, cudaGetErrorString(error)); \
} \
}
void initIntArray(int *ip, int size){
for(int idx=0; idx<s... |
16,185 | #include "includes.h"
// helper for CUDA error handling
__global__ void getWeights( const double* restoredEigenvectors , const double* meanSubtractedImages , double* weights , std::size_t imageNum , std::size_t pixelNum , std::size_t componentNum )
{
std::size_t row = blockIdx.x;
std::size_t col = blockIdx.y * block... |
16,186 | #include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<fstream>
#include<time.h>
#include<sys/time.h>
using namespace std;
#define num_threads 1000
// #define num_edges 700000
// #define num_vertices1 10000
// #define num_vertices2 10000
// #define num_edges 1000000
// #define num_vertices... |
16,187 | #include <stdio.h>
#define BLOCK_SIZE 500
__global__ void spmv_csr_kernel(unsigned int dim, unsigned int *csrRowPtr,
unsigned int *csrColIdx, float *csrData, float *inVector,
float *outVector) {
int row=blockDim.x*blockIdx.x+threadIdx.x;
if(row<dim)
{
float res=0;
int row_st=csrRowPtr[row];
... |
16,188 | #include <stdlib.h>
#include <math.h>
#include <stdio.h>
/* Function prototypes */
float ran2(long *);
void condini(long n, long *idum, double p0, double theta0, double r[], double p[])
{
long i;
double lt,ptot;
lt=0.0;
for (i=0;i<n;i++)
{
r[i]=((double) ran2(idum))*theta0;
p[i... |
16,189 | #include "includes.h"
//Bibliotecas Basicas
//Biblioteca Thrust
//Biblioteca cuRAND
//PARAMETROS GLOBAIS
const int QUANT_PAIS_AVALIA = 4;
int POP_TAM = 200;
int N_CIDADES = 20;
int BLOCKSIZE = 1024;
int TOTALTHREADS = 2048;
int N_GERA = 100;
const int MUT = 10;
const int MAX = 19;
const int MIN = 0;
const int ELI... |
16,190 | #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];
extern "C" __device__ unsigned long long record_flag;
voi... |
16,191 | /* ==================================================================
Programmer: Yicheng Tu (ytu@cse.usf.edu)
The basic SDH algorithm implementation for 3D data
To compile: nvcc SDH.c -o SDH in the C4 lab machines
==================================================================
*/
/* USF Fall 2019 CIS4930 Pro... |
16,192 | #include "includes.h"
__global__ void prefix_sum_scan(uint* dev_main_array, uint* dev_auxiliary_array, const uint array_size)
{
// Note: The first block is already correctly populated.
// Start on the second block.
const uint element = (blockIdx.x + 1) * blockDim.x + threadIdx.x;
if (element < array_size) {
cons... |
16,193 | /******************************************************************************
* PROGRAM: copyStruture
* PURPOSE: This program is a test which test the ability to transfer multilevel
* C++ structured data from host to device, modify them and transfer back.
*
*
* NAME: Vuong Pham-Duy.
* College student.
* Facul... |
16,194 | #include <stdio.h>
#include <sys/time.h>
#include <cuda.h>
const int THREADS = 512;
static void CudaTest(const char *msg)
{
cudaError_t e;
cudaDeviceSynchronize();
if (cudaSuccess != (e = cudaGetLastError())) {
fprintf(stderr, "%s: %d\n", msg, e);
fprintf(stderr, "%s\n", cudaGetErrorString(e));
exit... |
16,195 | // Author: Ayush Kumar
// Roll No: 170195
// Compile: nvcc -g -G -arch=sm_61 -std=c++11 assignment5-p2.cu -o assignment5-p2
#include <algorithm>
#include <cuda.h>
#include <iostream>
#include <sys/time.h>
#include <atomic>
#define THRESHOLD (0.000001)
#define BLOCKSIZE 128
#define CPT 4096
#define FAC 8
using std::c... |
16,196 | #include "includes.h"
__global__ void add(int *a,int *b,int *c)
{
int x = blockIdx.x;
int y = blockIdx.x;
int i = COL*y + x;
c[i] = a[i] + b[i];
} |
16,197 | #define REORDER 1
#define GOOD_WEATHER 0
#define BAD_WEATHER 1
#define TAG_Car 0
#define TAG_Pedestrian 1
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
//#include <random>
//#include <array>
#include <algorithm>
#define NUM_CARS 4096
#define NUM_PEDS 16384
#define NUM_STREETS 500
#define MAX_CONNECTION... |
16,198 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <iostream>
#include <numeric>
#include <math.h>
using namespace std;
#define BLOCK_SIZE 4;
__global__ void sum(int* input, int n) // global call to cuda function (host to device)
{
const int tid = threadId... |
16,199 | /**
* Author:易培淮
* Mail:yiph@ihep.ac.cn
* Function:Accelerate simulation with Single GPU
* 2018/11/27
*/
#include <cuda.h>
#include <cuda_runtime_api.h>
#include <curand.h>
#include <curand_kernel.h>
#include <stdio.h>
// #include <math.h>
// #include <math_constants.h>
// typedef struct arr
// {
// double *... |
16,200 | /* CUDA Library for Skeleton 2D Electrostatic GPU-MPI PIC Code */
/* written by Viktor K. Decyk, UCLA */
#include <stdlib.h>
#include <stdio.h>
#include "cuda.h"
extern int nblock_size;
extern int maxgsx;
static cudaError_t crc;
extern "C" void gpu_deallocate(void *g_d, int *irc);
extern "C" void gpu_iallocate(int... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.