serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
19,801 | #include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <sys/time.h>
#include <math.h>
int const N = 32;
int const THREADS = 12;
int const BSZ = 3;
float const EPS2 = 0.0001;
double get_time()
{ struct timeval tim;
cudaThreadSynchronize();
gettimeofday(&tim, NULL);
return (doubl... |
19,802 | #include "includes.h"
__global__ void uniform_double(int n,double lower,double upper,double *result) {
int totalThreads = gridDim.x * blockDim.x;
int tid = threadIdx.x;
int i = blockIdx.x * blockDim.x + tid;
for(; i < n; i += totalThreads) {
double u = result[i];
result[i] = u * upper + (1 - u) * lower;
}
} |
19,803 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <ostream>
void ShowGPUProps(int DeviceID)
{
cudaDeviceProp DeviceProp;
cudaGetDeviceProperties(&DeviceProp, DeviceID);
printf("--- Card: %s --- Device Number: %d --- Integrated: %s ---\n", DeviceProp.name, DeviceID, DeviceP... |
19,804 | #include "includes.h"
__global__ void LSTMCellInputGradientKernelBPTT( float *input, float *previousOutput, float *cellInputDeltas, float *cellInputWeightGradient, int inputCount, int previousOutputCount, int cellsPerBlock )
{
int weightId = blockDim.x * blockIdx.y * gridDim.x //rows preceeding current row in grid
+ ... |
19,805 | #include <iostream>
#include <cuda.h>
#include <cuda_runtime.h>
#include <curand.h>
#include <curand_kernel.h>
#include <stdio.h>
#include <float.h>
void handleCudaError(cudaError_t cudaERR)
{
if (cudaERR != cudaSuccess)
{
printf("CUDA ERROR : %s\n", cudaGetErrorString(cudaERR));
}
}
struct pareto... |
19,806 | #include "threshold_computer.cuh"
template<class T>
void ThresholdComputer<T>::UpdateBuffer(std::vector<T> buf) {
thrust::host_vector<float> host_data_;
host_data_.assign(buf.begin(), buf.end());
device_data_ = host_data_; // copy data to device
is_sorted = false;
is_cached = false;
}
template<class T>
fl... |
19,807 | #include "includes.h"
__global__ void reshape(size_t num_values, float_t* src, float_t* dest, size_t ld_src, size_t ld_dest)
{
size_t index = blockIdx.x*blockDim.x + threadIdx.x;
if(index < num_values)
{
size_t src_index = (index/ld_dest)*ld_src+ index%ld_dest;
dest[index] = src[src_index];
}
} |
19,808 | #include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <time.h>
using namespace std;
__global__ void initArray( int *A) {
int tid;
tid = blockIdx.x * blockDim.x + threadIdx.x;
A[tid] = tid;
}
__global__ void swapArray( int *A, int size, int num_t) {
int tid = blockIdx.x * blockDim.x + threadId... |
19,809 | #include "includes.h"
__global__ void LreluBackward(float* srcDiff, float* dstDiff, float* srcData, int data_size)
{
int thread_index = threadIdx.x + blockIdx.x * blockDim.x;
int num_threads = blockDim.x * gridDim.x;
for(int i = 0; i < data_size; i += num_threads)
{
int index = i + thread_index;
if(index < data_size)
... |
19,810 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#define N 8
__global__ void reduceVector (float *d_a) {
int i = blockIdx.x*blockDim.x+threadIdx.x;
d_a[i] = d_a[i] + d_a[i+(N/2)];
__syncthreads();
if (threadIdx.x<(blockDim.x/2))
d_a[i] = d_a[i] +d_a[i+(N/4)];
__syncthreads();
if (threadIdx... |
19,811 | #include <iostream>
#include <string>
#include <iomanip>
#include <ctime>
#include <curand.h>
#include <curand_kernel.h>
using namespace std;
const string ALPHABET_SET = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
// device utility functions
__device__
int c_strlen(char *string)
{
int count... |
19,812 | #include "includes.h"
// Include files
// Parameters
#define N_ATOMS 343
#define MASS_ATOM 1.0f
#define time_step 0.01f
#define L 10.5f
#define T 0.728f
#define NUM_STEPS 10000
const int BLOCK_SIZE = 1024;
//const int L = ;
const int scheme = 1; // 0 for explicit, 1 for implicit
/**********************************... |
19,813 | #include <stdio.h>
#include <iostream>
#include <iomanip>
#include <cuda_runtime.h>
using namespace std;
void MatrixMul_host(float *a, int a_rows, int a_cols, float *b, int b_rows, int b_cols, float *c) {
for (int i = 0; i < a_rows; i++) {
for (int j = 0; j < b_cols; j++) {
float t = 0;
... |
19,814 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <cuda.h>
#define HOSTLEN 50
// Initial conditions
void initCoord(float *rA, float *vA, float *fA, \
float initDist, int nBod, int nI);
// Forces acting on each body
__global__ void forces(float *rA... |
19,815 | #include <stdio.h>
#define LIMIT 4
__global__ void cudabrot_kernel(unsigned char* buffer, unsigned int width, unsigned int height,
float cx, float cy, float scale) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
int x = index % width;
int y = index / width;
if (index < w... |
19,816 | #include <stdio.h>
#include <assert.h>
#define N 1000000
int main (int argc, char **argv){
int a_host[N], b_host[N];
int *a_device, *b_device;
int i;
// initialize data
for (i=0;i<N;i++) {
a_host[i]=i;
}
// allocate device memory
cudaMalloc((void**)&a_device,N*sizeof(int));
cudaMalloc((vo... |
19,817 | __global__ void axpbyKernel(double* x, double* y, double a, double b, uint L){
uint stride = gridDim.x * blockDim.x;
uint t = threadIdx.x + blockIdx.x * blockDim.x;
for (uint i = t; i < L; i += stride){
x[i] = a * x[i] + b * y[i];
}
}
__global__ void axpbyyKernel(double* x, double* y,
... |
19,818 | /**
* Copyright 1993-2014 NVIDIA Corporation. All rights reserved.
*
* Please refer to the NVIDIA end user license agreement (EULA) associated
* with this source code for terms and conditions that govern your use of
* this software. Any use, reproduction, disclosure, or distribution of
* this software and relate... |
19,819 | #include "includes.h"
__global__ void euclideanDistanceCuda(float3* pDotProducts, size_t pSize, float* results) {
int instance = blockIdx.x * blockDim.x + threadIdx.x;
while (instance < pSize) {
results[instance] = pDotProducts[instance].x - 2*pDotProducts[instance].y + pDotProducts[instance].z;
if (results[instance] ... |
19,820 | #include "includes.h"
__global__ void fp_bias_fc(float *preact, float *bias, const int n_channel)
{
const int pos = blockIdx.x * blockDim.x + threadIdx.x;
const int totalPos = blockDim.x * gridDim.x;
const int N = n_channel;
for (int idx = N * pos / totalPos; idx < N * (pos+1) / totalPos; ++idx) {
preact[idx] += bias... |
19,821 | //THRUST
#include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <thrust/generate.h>
#include <thrust/random.h>
//STL
#include <iostream>
#include <iomanip>
// define a 4d float vector
typedef thrust::tuple< float, float, float, float > vec4;
// return a random vec4 in [0,1)^2
vec4 make_random_vec4... |
19,822 | #include "includes.h"
__device__ unsigned int getGid3d3d(){
int blockId = blockIdx.x + blockIdx.y * gridDim.x
+ gridDim.x * gridDim.y * blockIdx.z;
int threadId = blockId * (blockDim.x * blockDim.y * blockDim.z)
+ (threadIdx.y * blockDim.x)
+ (threadIdx.z * (blockDim.x * blockDim.y)) + threadIdx.x;
return threadId;
}
_... |
19,823 | #include "includes.h"
__global__ void externSet(int* variablesMem,int* lastValuesMem, int nQueen,int nVariableCollection){
int index = threadIdx.x + blockIdx.x * blockDim.x;
if(index < nVariableCollection*nQueen*nQueen){
variablesMem[index] = 1;
if(index < nVariableCollection*nQueen)
lastValuesMem[index] = 0;
}
} |
19,824 | #include <iostream>
#include <cuda_runtime.h>
using namespace std;
// Derived class
class Rectangle
{
public:
Rectangle()
{
cudaMallocManaged(&width, sizeof(int));
cudaMallocManaged(&height, sizeof(int));
//width = (int *)malloc(sizeof(int));
//height = (int *)malloc(sizeof(int));
... |
19,825 | #include <stdlib.h>
#include <stdio.h>
#define a(i,l) A[(i)*k + (l)]
#define b(l,j) B[(l)*n + (j)]
#define c(i,j) C[(i)*n + (j)]
#define BLOCK_SIZE 16
#define num_el 4
// Declarations
extern "C" {
void matmult_gpu1(int m, int n, int k,double *h_A,double *h_B,double *h_C);
void matmult_gpu2(int m, int n, int k,double ... |
19,826 | #include <cstdio>
using namespace std;
__global__ void
foo_kernel(int step)
{
printf("loop: %d\n", step);
}
int main()
{
int n_loop = 5;
// execute kernels with the default stream
for (int i = 0; i < n_loop; i++)
foo_kernel<<< 1, 1, 0, 0 >>>(i);
cudaDeviceSynchronize();
return 0;
} |
19,827 | #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 comppilation in order to get the co... |
19,828 | #include <stdio.h>
#include <iostream>
#define MAX_THREADS 128
using namespace std;
const int threshold =25;
__global__ void bubble_sort(int *a, int left, int right)
{
int temp;
for(int i=left;i<right;i++)
for(int j=i+1;j<=right;j++)
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=... |
19,829 | class Complex
{
public:
float r;
float i;
__host__ __device__ Complex() : r(0), i(0) {}
__host__ __device__ Complex( float a, float b ) : r(a), i(b) {}
__host__ __device__ Complex(const Complex& x) : r(x.r), i(x.i) {}
__host__ __device__ float magnitude2( void ) {
return r * r + i * i;
}
__h... |
19,830 | /******************************************************************************
*cr
*cr (C) Copyright 2010 The Board of Trustees of the
*cr University of Illinois
*cr All Rights Reserved
*cr
*****************************************************************... |
19,831 | extern "C"{
const int Tile_width = 16;
// Kernel to Perform median filter operation on a image using Shared memory
__global__ void median_filter_shared(unsigned char* imaged, unsigned char* outputImaged,int width,int height ){
__shared__ unsigned char images[Tile_width+2][Tile_width+2]; // Creatin... |
19,832 | #ifndef VORTEX_KERNEL_CU
#define VORTEX_KERNEL_CU
#include <cuda.h>
#include <cuda_runtime.h>
__global__ void VortexIndicator(
double *device_arr, int symbol_count, int indic_len, int dataLength,
int time_len, int columns, double *device_outval, int win_size, double *error_val)
{
int blockID = blockIdx.y... |
19,833 | #include <stdio.h>
#include <assert.h>
const int radius = 4;
#define swap(x, y) { double t = (x); (x) = (y); (y) = (t); }
__inline__ __device__ void periodic_bc(double *u, const int n) {
int idx = threadIdx.x + blockDim.x * blockIdx.x;
if (idx >= radius) return;
// Copy the left data point... |
19,834 |
inline void create_beta_h(int *h_beta, int *h_left, int *h_rows, int *h_cols, int m, int nnz){
// Note: Index in h_rows and h_cols starts at 1
int *h_visited = (int*)malloc( sizeof(int) * m );
for(int i=0; i<m; i++) h_left[i] = -1;
for(int i=0; i<m; i++) h_visited[i] = 0;
for(int i=0; i<m; i++) h_b... |
19,835 | /*
* Copyright 1993-2010 NVIDIA Corporation. All rights reserved.
*
* Please refer to the NVIDIA end user license agreement (EULA) associated
* with this source code for terms and conditions that govern your use of
* this software. Any use, reproduction, disclosure, or distribution of
* this software and related... |
19,836 | #include "includes.h"
__global__ void AdaptRefVectorKernel( int cell, float *referenceVector, float oldErrorFraction, float youngErrorFraction, float decayFactor, int *winningCount, float *difference, int inputSize )
{
int threadId = blockDim.x*blockIdx.y*gridDim.x //rows preceeding current row in grid
+ blockDim.x*b... |
19,837 | #include <iostream>
#include <fstream>
#include <numeric>
#include <cstdlib>
#include <climits>
#include <stdexcept>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/tuple.h>
#include <thrust/generate.h>
#include <thrust/sort.h>
#include <thrust/copy.h>
#include <curan... |
19,838 | #include <thrust/device_vector.h>
#include <thrust/reduce.h>
#include <thrust/iterator/permutation_iterator.h>
#include <iostream>
int main()
{
// gather locations
thrust::device_vector<int> map(4);
map[0] = 3;
map[1] = 1;
map[2] = 0;
map[3] = 5;
// array to gather from
thrust::device_vector<int> source(6)... |
19,839 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <iostream>
using namespace std;
__global__ void runningSum(int* d) {
int threads = blockDim.x;
int tid = threadIdx.x;
for (int tc = threads, step = 1; tc > 0; step *= 2) {
if(tid < tc) {
d[tid + step] += d[tid];
... |
19,840 | #include "includes.h"
__global__ void windowBlackman(float* idata, int length)
{
int tidx = threadIdx.x + blockIdx.x*blockDim.x;
if (tidx < length)
{
idata[tidx] = 0.74 / 2 * -0.5 * cos(2 * PI_F*tidx / (length - 1)) + 0.16 / 2 * sin(4 * PI_F*tidx / (length - 1));
}
} |
19,841 | #include <stdio.h>
#include <cassert>
int main() {
int n_devices;
cudaGetDeviceCount(&n_devices);
assert(n_devices > 0);
cudaDeviceProp prop;
cudaGetDeviceProperties(&prop, 0);
printf("Device name: %s\n", prop.name);
printf("Shared memory per block (bytes): %ld\n", prop.sharedMemPerBlock);
printf("Max ... |
19,842 | #include "reduce.cuh"
#include "real.h"
#include "assert.h"
#include <iostream>
int main(){
real summands[1024];
for (int i=0; i!=1024; ++i)
summands[i]=1;
for (int j=0; j!=1000; ++j)
reducev2(summands,1024);
}
|
19,843 | #include <stdio.h>
__device__ int dev1(){
return 1;
}
__device__ int dev2(){
return 2;
}
/*
* __global__ prefix says a function is kernel,
* Will be executed by GPU
* runs multiple times specified by block and thread number
* must return void
*/
__global__ void myKernel(){
dev1();
dev2();
}
/... |
19,844 | #include<iostream>
#include<stdio.h>
#include<cuda.h>
#include<cuda_runtime.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<ctime>
#include<curand.h>
#include<curand_kernel.h>
using namespace std;
__device__ long int n_ok[1]={3};
__global__ void pi (int seed, float *x, float *y) {
curandState_t ... |
19,845 | /*
*
* pgm.cu
*
* Functions to load and store PGM (portable gray map) files.
*
* Copyright (c) 2011-2012, Archaea Software, LLC.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* ... |
19,846 | /*
STEPS
1. Allocate host memory and initialized host data e.g. malloc
2. Allocate device memory e.g cudaMalloc
3. Transfer input data from host to device memory e.g cudaMemcpy
4. Execute kernels
5. Transfer output from device memory to host
6. Free Host & CUDA memory e.g. free & cudaFree
*/
#include <stdio.h>
#inclu... |
19,847 |
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <stdlib.h>
#include <math.h>
#include <curand.h>
#include <time.h>
#define CUDA_CALL(x) do { if((x)!=cudaSuccess) { \
printf("Error at %s:%d : err => %s\n",__FILE__,__LINE__,cudaGetErrorString(x));\
return EXIT_FAILURE;}} while(0)
#define CURAN... |
19,848 | #include <stdio.h>
#include <stdlib.h>
#define BLOCK_SIZE 512
typedef struct Data {
double* a;
double* b;
double* c;
} Data;
__global__ void add( Data data, int vector_size ) {
// Calculate the index in the vector for the thread using the internal variables
int tid = blockIdx.x*blockDim.x + threadIdx.x;
... |
19,849 | #include <cuda_runtime.h>
#include <stdio.h>
#include <iostream>
__global__ void checkIndex(void) {
printf("threadIdx:(%d, %d, %d) blockIdx:(%d, %d, %d) blockDim:(%d, %d, %d) gridDim:(%d, %d, %d)\n",
threadIdx.x, threadIdx.y, threadIdx.z, blockIdx.x, blockIdx.y, blockIdx.z, blockDim.x, blockDim.y, blockDim.z,... |
19,850 | //
// simple_conv.cu
// Conv
//
// Created by DB on 12/27/18.
// Copyright © 2018 D Blalock. All rights reserved.
//
#include <stdio.h>
|
19,851 | __global__ void process_kernel1(float *A, float *B, float *C, int N)
{
int blockNum = blockIdx.z * (gridDim.x * gridDim.y) + blockIdx.y * gridDim.x+ blockIdx.x;
int threadNum = threadIdx.z * (blockDim.x* blockDim.y) + threadIdx.y * (blockDim.x) + threadIdx.x;
int globalThreadId = blockNum * (blockDim.x * blockDim.y ... |
19,852 | #include <iostream>
#include <stdio.h>
#include <ctime>
#define LOG_NUM_BANKS 5
#define NUM_BANKS 32
#define BLOCK_SIZE 64
#define DEBUG
#ifdef DEBUG
#define cudaCheckError(ans) { cudaAssert((ans), __FILE__, __LINE__); }
inline void cudaAssert(cudaError_t code, const char *file, int line, bool abort=true)
{
if (co... |
19,853 | #include "subroutines.cuh"
//-----------------------------------------------------------------------//
//* Some common small functions and constants *//
//-----------------------------------------------------------------------//
const int constSharedMemSize = 256;
const int maxThreads = 256; // number of threads p... |
19,854 | #ifndef HashTable_Tests_CU
#define HashTable_Tests_CU
#include "../SRC/HashTable.cu"
struct Example_t
{
// member declarations.
char name[20];
int id;
int age;
int GetHash()
{
return id;
}
bool equal(Example_t * Node0)
{
std::cout << "Compare:" << id << "-" << No... |
19,855 | #include "includes.h"
__global__ void sumGrad(float* output, float* input1, float* input2, float* input3, float* input4, const int numElem)
{
size_t pos = blockDim.x * blockIdx.x + threadIdx.x;
size_t size = blockDim.x * gridDim.x;
for(int i = numElem * pos / size; i < numElem * (pos+1) / size; i++){
output[i] = input... |
19,856 | #include <iostream>
#define N (256 * 256)
#define FULL_DATA_SIZE (N*20)
using namespace std;
__global__ void kernel(int *a, int *b, int *c)
{
int idx = threadIdx.x + blockIdx.x * blockDim.x;
if(idx < N)
{
int idx1 = (idx + 1) % 256;
int idx2 = (idx + 2) % 256;
float as = (a[idx] + a[idx1] + a[idx2]) / 3.0f;... |
19,857 | /**
* 2DConvolution.cu: This file is part of the PolyBench/GPU 1.0 test suite.
*
*
* Contact: Scott Grauer-Gray <sgrauerg@gmail.com>
* Louis-Noel Pouchet <pouchet@cse.ohio-state.edu>
* Web address: http://www.cse.ohio-state.edu/~pouchet/software/polybench/GPU
*/
#include <unistd.h>
#include <stdio.h>
#include <... |
19,858 | // Este codigo obtiene la derivada de la funcion u(x) = x*x
// utilizando diferencias finitas, donde el error es proporcional
// a dx
#include <stdio.h>
void derivCPU(float* u_h, float* du_h, float dx, int n)
{
// notar que este loop empieza en 1, porque?
for (int i=1; i < n; i++) du_h[i] = (u_h[i] - u_h[i-1... |
19,859 | #include <cmath>
#include <cstdio>
#include <iostream>
#include "canny.cuh"
using namespace std;
// __global__ functions can't be inlined actually
__forceinline__ __global__ void generateGaussian(float *filter, float sigma) {
int x_idx = threadIdx.x + blockDim.x * blockIdx.x;
int y_idx = threadIdx.y + blockDim.y * ... |
19,860 | #include <cuda.h>
#include <stdio.h>
__global__
void vecAddKernel(float *A, float *B, float *C, int n) {
int i = threadIdx.x+blockDim.x*blockIdx.x;
printf("i: %d\n", i);
if(i<n)
C[i] = A[i] + B[i];
}
void vecAdd(float *A, float *B, float *C, int n) {
int s = n*sizeof(float);
float *d_A, *d_B, *d_C;
cu... |
19,861 | /*
Vector addition
*/
#include <stdio.h>
#define N 128
__global__ void add( int *a, int *b, int *c ) {
int tid = threadIdx.x;
if(tid > N-1) return;
c[tid] = a[tid] + b[tid];
}
int main() {
int host_a[N], host_b[N], host_c[N];
int *dev_a, *dev_b, *dev_c;
for (int i=0; i<N; i++) { host_a[i] = i * i; host_b[... |
19,862 | #include <stdlib.h>
#include <string.h>
#include <time.h>
void sumArrayOnHost(float* A, float* B, float* C, const int N){
for(int 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++){
ip[i] =... |
19,863 | /*CWM HPC Part B Assignment: Monte Carlo Method for calculating pi value on GPU
2021/5/58 Jianhao Yuan */
// reference: https://blog.csdn.net/ichocolatekapa/article/details/18960223
//import libs
#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
//curand for random points generate
#include <curand.h>
#include <... |
19,864 | #include "includes.h"
__device__ unsigned int getGid3d3d(){
int blockId = blockIdx.x + blockIdx.y * gridDim.x
+ gridDim.x * gridDim.y * blockIdx.z;
int threadId = blockId * (blockDim.x * blockDim.y * blockDim.z)
+ (threadIdx.y * blockDim.x)
+ (threadIdx.z * (blockDim.x * blockDim.y)) + threadIdx.x;
return threadId;
}
_... |
19,865 | #include "imageprocessing.cuh"
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <math.h>
#include <sstream>
// TODO: read about the CUDA programming model: https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#programming-model
// If everything is setup correctly, this file is compiled by... |
19,866 | //pass
//--gridDim=[32768,1,1] --blockDim=[512,1,1]
__global__ void SimpleKernel(float *src, float *dst)
{
// Just a dummy kernel, doing enough for us to verify that everything
// worked
const int idx = blockIdx.x * blockDim.x + threadIdx.x;
dst[idx] = src[idx] * 2.0f;
}
|
19,867 | #include <stdio.h>
#include <stdlib.h>
extern int N;
__global__ void gpuReduction(int *g_num,
int *g_sum,
int TotalNum) {
// TODO: implement kernel code here
}
double reduction_cuda(int *array, int N) {
// TODO: implement host code here
return 0;
}
|
19,868 | #include<stdio.h>
#define N 100
#include <math.h>
__global__ void vector_add(float *out, float *a, float *b, int n) {
// get global thread id
int id = blockIdx.x *blockDim.x * blockDim.y + threadIdx.y*blockDim.x + threadIdx.x;
// make sure we dont go out of thread index
if( id ... |
19,869 | #include "includes.h"
__global__ void findID(double *a, int n){
// First we need to find our global threadID
int tPosX = blockIdx.x * blockDim.x + threadIdx.x;
// Make sure we are not out of range
if (tPosX < n){
a[tPosX] = tPosX;
}
} |
19,870 | #include <stdio.h>
#include <assert.h>
#include <math.h>
#include "CPUconvLayer.cuh"
__host__ void dotProduct(float* A, float* B, float* C, int n)
{
for (int i = 0; i < n; i++) {
*C += A[i] * B[i];
}
}
/*
input_maps: (N, N, N, F_in, S) input feature maps
weights: (K, K, K, F_out, F_in) fil... |
19,871 | #include "includes.h"
__global__ void cudaKernel(int n, double* gpuWeights, int* gpuG, int* gpuTempGrid, int *flag)
{
// Moment's coordinates in the grid //
int momentCol = blockIdx.x*blockDim.x + threadIdx.x;
int momentRow = blockIdx.y*blockDim.y + threadIdx.y;
// Shared memory allocated for weights //
__shared__ doub... |
19,872 |
template<int block_size, int elements_per_thread, int tiling_strategy>
__global__ void vector_add(int n, float* C, const float* A, const float* B) {
static_assert(
tiling_strategy >= 0 && tiling_strategy < 3,
"invalid tiling strategy");
for (int k = 0; k < elements_per_thread; k++) {
i... |
19,873 | extern "C"
__global__ void capByScalar(int n, float *a, float b, float *result)
{
float cap = b;
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i<n)
{
result[i] = a[i] < cap ? a[i] : cap;
}
}
extern "C"
__global__ void floorByScalar(int n, float *a, float b, float *result)
{
float floor =... |
19,874 | #include <cuda.h>
#include <bits/stdc++.h>
#define BLOCK_SIZE 32
#define EPSILON 0.1
#define MAX_MASK_SIZE 15
using namespace std;
__constant__ float g_mask[MAX_MASK_SIZE];
bool cmp_float (float a, float b){
if (fabs (a - b) > EPSILON)
return false;
else
return true;
}
void fill_vector_random (float *v... |
19,875 | /*******************
* npCase1: Matrix Multiplication
* Author : Fanny Nina-Paravecino
* Date : October 2016
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include <string.h>
#include <math.h>
#define COL 1024
#define ROW 1024
double wallS0, wallS1, wallP0, wallP1;
float sum;
... |
19,876 | #include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#define MAXWORDS 20000
//#define MAXWORDS 10
void print_to_file(int *h_hist, int N)
{
const char *fname = "assignment3_out";
FILE *f = fopen(fname, "w");
int loop, loop1,a,b;
for(loop = 0; loop < pow(20,N); loop++){
if (h... |
19,877 | #include <stdio.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <cuda_runtime.h>
extern "C" void listdev( int rank ){
cudaError_t err;
int dev_cnt = 0;
err = cudaGetDeviceCount( &dev_cnt );
assert( err == cudaSuccess || err == cudaErrorNoDe... |
19,878 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
// RG*RG*MAXN must fit within mytype
#define MAXN 100000
#define RG 10
#define USECPSEC 1000000ULL
#define nTPB 256
#define DSIZE 8192
//cuda error checking macros
#ifdef DEBUG
#define CUDA_CALL(F) if( (F) != cudaSuccess ) \
{printf("... |
19,879 | #include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<limits.h>
#include<algorithm>
using namespace std;
#define INF INT_MAX-1
int tilesize[2] = {2, INT_MAX};
int rowSize;
void print_matrix(float *d)
{
int i, j;
for (i = 0; i < 32; i++)
{
for (j = 0; j < 32; j++)
printf("%0.1f\t", d[i * ... |
19,880 |
/* This is a automatically generated test. Do not modify */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
__global__
void compute(float comp, int var_1,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,float... |
19,881 | __global__ void test_restrict() {
int a[5];
int* __restrict__ pa = a;
pa[0] = 1;
a[0];
}
__global__ void test_restrict_args(int* __restrict__ a, int* __restrict__ b, int n) {
for (int i = 0; i < n; i++) {
a[i] = b[i];
}
}
__global__ void test_no_restrict_violation(int* __restrict__ a, int* __restrict__ b, int... |
19,882 | #include "includes.h"
__global__ void add_thread(int *a, int *b, int *c){
c[threadIdx.x] = a[threadIdx.x] + b[threadIdx.x];
} |
19,883 | #include "knn.cuh"
#include "morton.cuh"
#include "coords.cuh"
#include "float3math.cuh"
#define PI 3.145927
__host__ __device__
uint4 toUint4(float3 value, uint32_t index) {
uint32_t scale = (1 << 30);
uint4 result = {value.x * scale, value.y * scale, value.z * scale, index};
return result;
}
__device__
... |
19,884 | #include <unistd.h>
#include <stdio.h>
#include<cmath>
#include <iostream>
#include <fstream>
#include <curand.h>
#include <curand_kernel.h>
using namespace std;
#define N 100000
#define MAX 2000
#define two_pi 2.0*3.14159265358979323846
void streamOut (float *uniform_hostNums, float *gaussian_hostNums1 , float *gaus... |
19,885 | #include "includes.h"
__global__ void ifpairmabite( int * v, std::size_t size )
{
// Get the id of the thread ( 0 -> 99 ).
auto tid = threadIdx.x;
// Each thread fills a single element of the array.
if (!(v[tid] % 2))
v[ tid ] *= 2;
} |
19,886 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <cuda.h>
#include <chrono>
#include <vector>
#define BLOCK_SIZE 16
using namespace std::chrono;
using std::cout;
using std::endl;
//Matrix struct from NIVDIA's CUDA programming guide
typedef struct{
int width;
int height;
flo... |
19,887 | #include <iostream>
// includes CUDA Runtime
#include <cuda_runtime.h>
#include <cuda_profiler_api.h>
// maybe you need also helpers
/*
written by George Strauch on 4/19/2020
c++ program for matrix multiply using 1d arrays on the GPU
the GPU makes use of parallelism to make processes like this much faster
This imp... |
19,888 | #include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
#include <unistd.h>
int main(int argc,char* argv[]){
cudaError_t res;
int i,j,k;
size_t width,height,depth,prevpitch = 512;
size_t prevwidth=0,prevheight=0,prevdepth=0;
struct cudaPitchedPtr pitchedDevPtr;
struct cudaExtent extent;
for(... |
19,889 | #include "includes.h"
__global__ void RBMInputForwardKernel( float *inputPtr, float *outputPtr, float *biasPtr, bool applyBias, int thisLayerSize )
{
// i: current neuron id
int i = blockDim.x * blockIdx.y * gridDim.x //rows preceeding current row in grid
+ blockDim.x * blockIdx.x //blocks preceeding current block
+... |
19,890 |
#define BLOCK_SIZE 1024
//numRows = numCols since L is square
// y,x
#define L_Matrix(row,col) matL[((row)*numRows + (col))]
__global__ void gpu_simple_solver_kernel(double* matL, double* vecX, double* vecB, int numRows, int i)
{
int idx = blockIdx.x*blockDim.x+threadIdx.x;
if (idx >= numRows)
... |
19,891 | #include <stdio.h>
#define N 1024000
__global__ void add(int *data) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < N) {
data[i]++;
}
}
int main() {
int data[N];
int *dev_data;
int i;
// Allocate memory on the GPU.
cudaMalloc((void**)&dev_data, N * sizeof(int));
... |
19,892 | #include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
#include <curand_kernel.h>
#ifdef LARGE
#define RENDER_WIDTH 1024
#define RENDER_HEIGHT 1024
#else
#define RENDER_WIDTH 128
#define RENDER_HEIGHT 128
#endif
#define TILE_SIZE 16
#define STACK_CAPACITY 128
#define SHARED_MEM_CAP STACK_CAPACITY * RENDER_... |
19,893 | #include <iostream>
#include <string.h>
#include <stdio.h>
#include <math.h>
using namespace std;
namespace GPUfunc{
static int nb = 64; //1024*1024*64*2; // max 1024*1024*64*2
static int nthre = 1; // max 65535
static int nthre_total = nb*nthre;
static int nword = 1024*1024*8;
static int mem_size = sizeof(do... |
19,894 | #include <stdio.h>
#include <stdlib.h>
#define block_size 32
__global__ void calculation( int *a,
int *b,
int *c,
int constant,
int vector_size ) {
// write your c... |
19,895 | __device__ __forceinline__ double sigmoid (double a) { return 1.0 / (1.0 + exp (-a)); }
__device__ __forceinline__ int idx_2d(int x, int y, int width) { return x*width+y; }
__global__ void lstm_gemm(float *input,
float *initial_hiddens,
float *weights,
... |
19,896 | // Using CUDA device to calculate pi
#include <stdio.h>
#include <cuda.h>
extern "C" double getTime(void);
#define NBIN 1000000000 // Number of bins
#define NUM_BLOCK atoi(argv[1]) // Number of thread blocks
#define NUM_THREAD atoi(argv[2]) // Number of threads per block
// Kernel that executes on the CUDA device... |
19,897 | #include <stdio.h>
__global__
void hello(void){
printf("Hello from the GPU\n");
}
int main(void){
printf("Hello from the CPU\n");
dim3 gridDim(2,3,1);
// setup 6 blocks
dim3 blockDim(10,2,3);
// setup 6 blocks, a diff setup;
hello<<<gridDim,blockDim>>>();
cudaDeviceReset();
return 0;
}
|
19,898 | #include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <iostream>
#include <ctype.h>
#include <vector>
#include <string>
typedef std::vector<double> double_vec;
int main()
{
double_vec stocks;
std::string value, prev_val;
while (true)
{
std::getline(std::cin, value);
... |
19,899 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
void init_timing(struct timeval* tstart)
{
gettimeofday(tstart, NULL);
}
float ellapsed_time(struct timeval tstart)
{
struct timeval tmp;
long long diff;
gettimeofday(&tmp, NULL);
diff = tmp.tv_usec - tstart.tv_usec;
diff += (tmp.tv_... |
19,900 |
#include <type_traits>
using tt = std::true_type;
using ft = std::false_type;
int __host__ static_cuda11_func(int x)
{
return x * x + std::integral_constant<int, 17>::value;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.