serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
6,301 | #include <stdio.h>
#include <stdlib.h>
#include <iostream>
#define KERNEL_LOOP 4096 // Used to exacerbate runtime affects
#define NUM_ELEMENTS 4096
#define MAX_THREADS_PER_BLOCK 1024
__constant__ unsigned int const_data_gpu[NUM_ELEMENTS];
static unsigned int const_data_host[NUM_ELEMENTS];
__device__ void manipulate... |
6,302 | #include <cstdlib>
#include <iostream>
#include <math.h>
#include <ctime>
#include <chrono>
#include <vector>
using namespace std;
#define N 4000
#define count N*N
#define threadsPerBlock 1000
#define numberBlocks N*N/threadsPerBlock
// __device__ int partition(double* input, int start, int end)
// {
// double pi... |
6,303 | #include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <iostream>
#include <chrono>
int main() {
int N = 2518;
thrust::host_vector<double> host(N);
double tmp;
for(int i = 0; i < N; i++){
std::cin >> tmp;
host[i] = tmp;
}
/* na linha abaixo os dados são copia... |
6,304 |
#include <stdio.h>
#include <cuda.h>
// Kernel that executes on the CUDA device
__global__ void temp_calc(float *a, float *b, int N, int edge) // a: Source array, b: Target array, N: Total size, edge: Length of edge
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
// Calculates the row and column number
int ... |
6,305 | // CUDA_Device_Properties.cpp : Definiert den Einstiegspunkt fr die Konsolenanwendung.
/*
* Description:
* Acquire info about CUDA devices on system.
*
* Author: P Stegmann
* Date: 2014-10-22
*/
//
#include <stdio.h>
#include <iostream>
#include <cuda.h>
#include <cuda_runtime.h>
#include "device_launch_parameters.h"
... |
6,306 | #include <iostream>
#include <fstream>
#include <cstdlib>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/sort.h>
int main(void)
{
using namespace std;
int DIM = 1 << 24;
thrust::host_vector<double> x_h(DIM);
cout << "CUDA-C (Thrust) version\n";
cout << "Filling vector with ... |
6,307 | #include <time.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
__global__ void GPuEuler(float *y, float t_0, float y_0 ,int N, float delta) {
int myID = threadIdx.x + blockDim.x * blockIdx.x;
if (myID <N) {
y[myID] = y_0;
for(int i=0;i<myID;i++){
float j_del = de... |
6,308 | #include "hashtable.cuh"
template <typename T>
__global__ void init_hash_kernel(hashbucket<T>* d_hashtable, const int hash_table_rows)
{
int row = threadIdx.x + blockDim.x * blockIdx.x;
if (row < hash_table_rows) {
d_hashtable[row].key_row = EMPTYMARKER;
d_hashtable[row].max = 0;
d_hash... |
6,309 | #include <stdlib.h>
#include <math.h>
__global__ void VecEval(float *C)
{
int i = threadIdx.x;
int j;
for (j=0; j<=100; j++)
C[i] = 1./sqrt(1.+i) + j*sin(2.*sin(0.1*i));
}
int main()
{ const int N=1000000;
float C[N];
// Kernel invocation with N threads
VecEval<<<1, N>>>(C);
}
|
6,310 | #include <cuda.h>
#include <time.h>
#include <stdio.h>
__global__ void vecAddKernel(float* A, float* B, float* C, int n){
int i = blockDim.x*blockIdx.x + threadIdx.x;
if(i<n){
C[i] = A[i] + B[i];
}
}
void vecAdd(float* A, float* B, float* C, int n)
{
int size = n * sizeof(float);
static float *d_A, *d_B, *d_C;... |
6,311 | #include <iostream>
#include <algorithm>
#include <list>
#include <vector>
#include <iterator>
#include <functional>
#include <time.h>
#include <chrono>
#include <cstdlib>
using namespace std;
struct triple
{
long long int set; //Set denotes which Elements are in the Subset
double w; //Weight of the Triple
d... |
6,312 | #define EIGEN_USE_GPU
#include <cuda.h>
#include <stdio.h>
__global__ void AddOneKernel(const int* in, const int N, int* out) {
for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < N;
i += blockDim.x * gridDim.x) {
out[i] = in[i] + 1;
}
}
void AddOneKernelLauncher(const int* in, const int N, int* ou... |
6,313 | //
// Created by Peter Rigole on 2019-04-24.
//
#ifndef AXONBITS_TEST_H
#define AXONBITS_TEST_H
#include <cuda_runtime.h>
#include <string>
#include <assert.h>
#include <stdexcept>
/**
* Test base class.
* Mind that classes with virtual functions can't have a header file.
*/
class Test {
public:
Test() {}
... |
6,314 | #include <thrust/sequence.h>
#include <thrust/device_vector.h>
#include <thrust/host_vector.h>
int main(void)
{
int N = 20;
// --- Filter parameters
double alpha = 2.7;
double beta = -0.3;
// --- Defining and initializing the input vector on the device
thrust::device_vector<double> d_... |
6,315 | #include <stdio.h>
#include <assert.h>
#include <cuda.h>
// Notice: this function could only be used to detect Cuda function whose return value type is not void.
// we could use cudaGetLastError() to detect such cuda function (ex, self_define kernel function.)
cudaError_t checkCuda(cudaError_t result){
if(result ... |
6,316 | #include <cuComplex.h>
__global__ void get_Gj(double *Fj, double *ph, cuDoubleComplex *Gj)
{
int idx = threadIdx.x + blockIdx.x * blockDim.x;
double s, c;
sincos(ph[idx], &s, &c);
Gj[idx].x = Fj[idx] * c;
Gj[idx].y = Fj[idx] * s;
}
__global__ void mult_complex_1to1(cuDoubleComplex *A, cuDoubleCom... |
6,317 | /**
* File: fw-cuda.cu
*
* Floyd Warshall algorithm CUDA implementation
*
* @author Mateusz Bojanowski
* @source https://github.com/MTB90/CUDA_Blocked_Floyd-Warshall
*/
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
// CUDA Headers
#include "cuda.h"
#include "cuda_runtime.h"
#include "device_launch_pa... |
6,318 | //xfail:BOOGIE_ERROR
//--blockDim=32 --gridDim=64 --no-inline
//error: possible write-write race on
#include <stdio.h>
#include "cuda.h"
#include <assert.h>
#include <cuda_runtime_api.h>
#define M 2//32
#define N 4//64
__global__ void foo(int* p) {
__shared__ unsigned char x[N];
for (unsigned int i=0; i<(N/4); ... |
6,319 | #include <stdio.h>
#define BLOCK_SIZE 128
#define BLOCK_SIZE_F 128.0
__global__
void sumRedKernel(float *A, int n){
__shared__ float partialSum[BLOCK_SIZE*2];
int i = (threadIdx.x + blockDim.x * blockIdx.x)*2;
unsigned int t = threadIdx.x * 2;
partialSum[t] = A[i];
partialSum[t+1] = A[i+1];
t = threadIdx.x... |
6,320 | //#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <cuda.h>
//#include <math.h>
#define BLOCK_SIZE 512
int checkResults(float*res, float* cudaRes,int length)
{
int nDiffs=0;
const float smallVal = 0.01f; // Keeping this extra high as we have repetitive addition and sequence matters
for(int i=0; i<l... |
6,321 | #include <cuda.h>
#include <vector>
#include <iostream>
#include <stdio.h>
/*
To compile, use: nvcc -Xcompiler /wd4819 test1.cu
*/
void vecAddonHost(double *h_A,double *h_B,double *h_C,int n) {
for (int i=0; i<n; i++) {
h_C[i] = h_A[i] + h_B[i];
}
}
// CUDA kernel
// each thread for each element
... |
6,322 | // Author: Ayush Kumar
// Roll No: 170195
// Compile: nvcc -g -G -arch=sm_61 -std=c++11 assignment5-p3.cu -o assignment5-p3
#include <cmath>
#include <iostream>
#include <sys/time.h>
#define SIZE 1024
#define BLOCK_SIZE 16
#define THRESHOLD (0.000001)
using std::cerr;
using std::cout;
using std::endl;
double rtcloc... |
6,323 | #include "includes.h"
__global__ void sneldiv(unsigned short *inA, float *inB, int *sub, int Nprj, int snno)
{
int idz = threadIdx.x + blockDim.x*blockIdx.x;
if (blockIdx.y<Nprj && idz<snno) {
// inB > only active bins of the subset
// inA > all sinogram bins
float a = (float)inA[snno*sub[blockIdx.y] + idz];
a /= inB... |
6,324 | #include <stdio.h>
#include <stdlib.h>
#include <string.h> /* memcpy */
/* C99 syntax test (currently only a subset is parsed) */
/* @todo Also typedef struct */
typedef struct Car
{
const char *name;
int year;
float max_speed;
} Car; /* @todo Allow unnecessary ; */
int main()
{
int test_integer;
... |
6,325 | #include <cuda_runtime.h>
#include <stdio.h>
__global__ void checkIndex(void){
printf("threadIdx:(%d, %d, %d) \n blockIdx:(%d, %d, %d) \n blockDim:(%d, %d, %d) \n gridDim:(%d, %d, %d) \n",
threadIdx.x, threadIdx.y, threadIdx.z,
blockIdx.x, blockIdx.y, blockIdx.z,
gridDim.x, gridDim.y, gridDim.z
);
}
i... |
6,326 | #include "includes.h"
__global__ void DataPointMap(int size, const double *inputX, const double *inputY, double *output, const double *inFreeArray, int length) {
const long ix = threadIdx.x + blockIdx.x * (long)blockDim.x;
if (ix < size) {
// copy int array
const double *inArrayBody = &inputX[ix* length];
double *outAr... |
6,327 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <string.h>
#include <curand.h>
#include <curand_kernel.h>
//to get data yahoo finance
//time period: Apr 01 2016 -> Apr 01 2019
//freq: Weekly
#define NUM_ELEMENTS 100 //why when I change this everything breaks & this should not change ... |
6,328 | #include "includes.h"
__global__ void Naive_Hist(int* d_result, int* d_hist, int n_vertices) {
//each block compares the same row to all others row2
int row = blockIdx.x;
int row2 = threadIdx.x;
bool equal;
//shared count for whole block/same vertice
__shared__ int count;
//one thread sets count to zero and syncsthr... |
6,329 | #include "includes.h"
__global__ void inc (int n, float* a) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < n) {
a[i] += 1;
}
}; |
6,330 | #include <stdio.h>
#include <stdlib.h>
#include <curand_kernel.h>
#define TRIALS_PER_THREAD 1000
#define BLOCKS 256
#define THREADS 256
#define PI 3.14159265358979 // known value of pi
long pi_mc(unsigned long long trials) {
double x, y;
long points_in_circle=0;
for(long i = 0; i < trials; i++) {
x = rand(... |
6,331 | //#ifndef _MATRIXMUL_KERNEL_H_
//#define _MATRIXMUL_KERNEL_H_
#define BLOCK_SIZE_X 16
#define BLOCK_SIZE_Y 16
#define GRID_SIZE_X 8
#define GRID_SIZE_Y 8
extern "C"
/* Signature:
float* d_array_in, int count, uint single_in
->
float* d_array_out, uint* d_array_len, int* memstruct, uint* single_out
*/
__global... |
6,332 | //pass
//--blockDim=64 --gridDim=64 --no-inline
#include "cuda.h"
__device__ void bar(int x) {
}
__global__ void foo() {
bar(5);
}
|
6,333 | // Add a scalar to the vector
//
// IMPORTANT: Prevent symbol mangling by setting: extern "C"
extern "C"
__global__ void vadd(int *const v, int const a, size_t const len) {
const unsigned int gid = blockDim.x * blockIdx.x + threadIdx.x;
const unsigned int gsize = gridDim.x * blockDim.x;
for (size_t i = gid; i < len... |
6,334 | #include <stdio.h>
#include <cuda.h>
#define N 1<<7
#define THREADS_PER_BLOCK 1024
__global__ void dot(float *a, float *b, float *c) {
__shared__ float temp[THREADS_PER_BLOCK];
int index = threadIdx.x + blockIdx.x * blockDim.x;
if (index >= N) return;
temp[threadIdx.x] = a[index] * b[index];
__sy... |
6,335 | #include <iostream>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <random>
#include <vector>
#include <chrono>
#define TILE_DIM 32
#define BLOCK_ROWS 8
__global__ void transposeNaive(int *odata, const int *idata, const int n, const int m) {
int x = blockIdx.x * TILE_DIM + threadIdx.x;
int y... |
6,336 | #include <stdio.h>
#define N 2048
#define N2 N*N
#define BLOCK_SIZE 32
__global__ void matrix_mult( const int *dev_a, const int *dev_b, int *dev_c)
{
int row = blockIdx.y * blockDim.y + threadIdx.y;
int col = blockIdx.x * blockDim.x + threadIdx.x;
int tmp_sum = 0;
for(int k = 0; k < N; ++k){
... |
6,337 | #include "includes.h"
__global__ void ForwardSoftmax(float *Z, int nColsZ, float *sumExp, float *A)
{
int row = threadIdx.x;
int col = blockIdx.x;
atomicAdd(&sumExp[col], exp(Z[row * nColsZ + col]));
__syncthreads();
A[row * nColsZ + col] = exp(Z[row * nColsZ + col]) / sumExp[col];
} |
6,338 | #include <iostream>
#include <math.h>
#include <cuda_profiler_api.h>
// function to add the elements of two arrays
void add_cpu(int n, float *x, float *y)
{
for (int i = 0; i < n; i++)
y[i] = x[i] + y[i];
}
void on_cpu(){
std::cout << "Running on cpu." << std::endl;
int N = 1<<20; // 1M eleme... |
6,339 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
__global__ void initialize (int N, float *a, float *b, float *c){
int i = (blockIdx.x * blockDim.x) + threadIdx.x;
c[i] = 0;
a[i] = 1 + i;
b[i] = 1 - i;
}
__global__ void addVectors (int N, float *a, float *b, float *c){
int i = (blockIdx.... |
6,340 | /**
* @file : activationf.cu
* @brief : activation functions content/source file in CUDA C++14,
* @author : Ernest Yeung <ernestyalumni@gmail.com>
* @date : 20171020
* @ref :
*
* If you find this code useful, feel free to donate directly and easily at this direct PayPal link:
*
* https://www.pa... |
6,341 | #include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
/* Initialize the two arrays referenced by the first two parameters in preparation for
* jacobi iteration. The width and height of the arrays are given by the integer parameters.
* Border elements are set to 5.0 for both arrays, and the in... |
6,342 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <assert.h>
#include <sys/time.h>
#define THREADS 512
#ifdef __cplusplus
extern "C"
{
#endif
__global__ void bitonic_sort(float *arr, int i, int j)
{
int index = blockIdx.x * blockDim.x + threadIdx.x;
int p = index ^ j;
int q = index & i;
float ... |
6,343 | #include<cuda.h>
#include<stdio.h>
#include<cuda_runtime.h>
void matricMul(int *A, int *B, int *C, int size) {
for (int col = 0; col < size; col++) {
for (int row = 0; row < size; row++) {
int outidx = col * size + row;
for (int idx = 0; idx < size; idx++) {
C[outidx] += A[col*size + idx] * B[idx*size + r... |
6,344 | #include "includes.h"
const int Nthreads = 1024, maxFR = 10000, NrankMax = 3, nt0max=81, NchanMax = 17;
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////... |
6,345 | #include "credit.cuh"
__device__ double RationalApproximation(double t)
{
double c[] = {2.515517, 0.802853, 0.010328};
double d[] = {1.432788, 0.189269, 0.001308};
return t - ((c[2]*t + c[1])*t + c[0]) /
(((d[2]*t + d[1])*t + d[0])*t + 1.0);
}
__device__ double qNorm(double p)
{
if ( (p... |
6,346 | #include "includes.h"
__device__ void trace_subm(int j, int k, int *daG, int *dbG, double *AB, double *A){
int l;
for(l=0; l<(*dbG); l++){
*(A+j*(*daG)+k) += *(AB+j*(*dbG)+l+k*(*dbG)+l);
}
}
__global__ void ptrBp(int *daG, int *dbG, double *ABg, double *Ag) {
int k = blockIdx.x*blockDim.x + threadIdx.x;
int j = blockId... |
6,347 | extern "C" {
/*
* Kernel to separate RGB channels
*/
__global__
void separateChannels(const uchar4* const inputImageRGBA,
int numRows,
int numCols,
unsigned char* const redChannel,
unsigned char* const greenChannel,
... |
6,348 | #include <cuda.h>
#include <cuComplex.h>
#include <math_constants.h>
#define __SET_MAP \
const int \
x = blockIdx.x * blockDim.x + threadIdx.x \
, y = blockIdx.y * blockDim.y + threadIdx.y \
;
template <int max_support>
__device__ __inl... |
6,349 | #include<iostream>
#include<cuda.h>
#include<cuda_runtime.h>
#define SIZE 9
using namespace std;
__global__ void vectoradd(int *p,int *q,int *result){
int tid = threadIdx.x + blockDim.x * blockIdx.x;
if(tid<SIZE){
// for(int i=0;i<SIZE;i++){
result[tid] = p[tid] + q[tid];
// }
}
}
int main(int argc, char... |
6,350 | #include <iostream>
#include <cuda.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include "parallel.cuh"
#define ELEMENTS 5
#define errCheck(code) { errorCheck((code), __FILE__, __LINE__); }
void addWithCuda(const int* a, const int* b, int* c, int elements);
using std::cout;
using std::flush;
... |
6,351 | #include <stdio.h>
#include <stdlib.h>
#define RADIUS 3
#define BLK_SIZE 256
#define NUM_ELEMENTS (BLK_SIZE * 32) // 256 * 32 = 8192
__global__ void stencil_1d(int *d_in, int *d_out){
__shared__ int temp[ BLK_SIZE + 2*RADIUS ]; // Stored in shared memory
int gindex = (blockIdx.x * blockDim.x) + threadIdx.x + RAD... |
6,352 | // probado en cuda 10.1 agosto 2020
// nvcc suma.cu -o v && ./v
#include <bits/stdc++.h>
using namespace std;
#define THREADS_PER_BLOCK 1024 //depende de la arquitectura
//#define g 10/2
void random_ints(int *a, int tam){
for (int i =0; i < tam; ++i){
a[i] = 1;//+rand()%10;
}
}
void imprimir(int *&v, int t... |
6,353 | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <cuda_runtime.h>
#define ASCII_CHARS 128
int mod(int a, int b) {
return (a%b+b)%b;
}
void printrow(float *msg_v_list) {
int i;
for (i = 0; i < 16; i++) {
printf("PRINTROW: %f\n", msg_v_list[i]);
}
}
__global__ void mt... |
6,354 | //optimization homework #4 cs 677 Theodore Jagodits
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include "string.h"
#include <iostream>
#define DEFAULT_ROW 128
#define DEFAULT_COL 128
#define TILE_SIZE 16
#define MAX_CONST 16000
#define GPU_SPEED_LO_LIMIT 1
//add constant memory
__constant__ float c_inp... |
6,355 | #include "includes.h"
__global__ void reduce_v2(float* in,float* out, int n){
int tx = threadIdx.x;
int bx = blockIdx.x;
int BX = blockDim.x; //same as THEAD_MAX
int i = bx*BX+tx;
__shared__ float S[THEAD_MAX];
S[tx] = i < n ? in[i] : 0;
__syncthreads();
for(int s=BX/2; s>0 ;s>>=1){
if(tx < s)
S[tx] += S[tx+s];
__s... |
6,356 | #include "includes.h"
__global__ void mult3_kernel(double *g_out, double *a, double *b, double *ct, int n) {
const int j2 = blockIdx.x * blockDim.x + threadIdx.x;
double wkr, wki, xr, xi, yr, yi, ajr, aji, akr, aki, bjr, bji, bkr, bki;
double new_ajr, new_aji, new_akr, new_aki;
const int m = n >> 1;
const int nc = n >>... |
6,357 | #include <thrust/sort.h>
#include <thrust/device_ptr.h>
//---------------------------------------------------------------------------
// NVCC is not yet able to compile C++11 code.
// Hence the need to keep Thrust and VexCL code in separate files.
//---------------------------------------------------------------------... |
6,358 | #include "includes.h"
__global__ void initializeElementsTo(int initialValue, int *a, int N)
{
int i = threadIdx.x + blockIdx.x * blockDim.x;
a[i] = initialValue;
} |
6,359 | /*
*
* GPU Computing: Benchmarking CUDA with the Scalar-Vector Product
* Computes only one element in a single thread and uses N threads with 1
* Single Thread-Per-Block.
*
*/
#include <stdio.h>
#include <time.h>
#include <cuda.h>
#define SCALAR 3
float printRunTime(const char *string, struct timespec *ti1... |
6,360 | #include "includes.h"
__device__ float f(float x)
{
return 4.f / (1.f + x * x);
}
__global__ void searchGPU(float *data, const float x, int *result)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (data[idx] == x)
{
result[0] = static_cast<int>(data[idx]);
result[1] = idx;
}
} |
6,361 | #include <cstdio>
#include <cuda_runtime.h>
#include "ray.cuh"
__global__
void cudaRayKernel(float *vel, float *thick, float *rho, float *c_rho,
int n_layers, int l_rho, float start, float end, float threshold) {
/* get current thread's id */
unsigned int index = blockIdx.x * blockDim.x + threadIdx.x;
/* c... |
6,362 | #include <stdio.h>
#include <math.h>
#define N (2048*2048)
#define THREAD_PER_BLOCK 512
__global__ void mul( int *a, int *b, int *c) {
int i = blockIdx.x/4;
int j = (blockIdx.x%4) * blockDim.x + threadIdx.x;
c[i*2048+j] = 0;
for(int k=0; k<N; ++k){
c[i*2048+j] += a[i*2048+k... |
6,363 | #include "includes.h"
__global__ void gpu_array_dot_product_r8__(size_t tsize, const double *arr1, const double *arr2, volatile double *dprod)
{
extern __shared__ double dprs_r8[]; //volume = blockDim.x
size_t l;
int i,j;
double dpr;
dpr=0.0; for(l=blockIdx.x*blockDim.x+threadIdx.x;l<tsize;l+=gridDim.x*blockDim.x){dpr+... |
6,364 | float h_A[]= {
0.7245594750728803, 0.9334832772187478, 0.6147443465961931, 0.8405796256479755, 0.6309850339877101, 0.7313930624677627, 0.525553960411304, 0.986234971765087, 0.7456872093986107, 0.7819641354464738, 0.5946793124470292, 0.8427630239072432, 0.9119028973735356, 0.9771978620765018, 0.5317018571524268, 0.76850... |
6,365 | #include <float.h>
/*
* Author:
* Oren Freifeld, freifeld@csail.mit.edu
*/
__global__ void honeycomb( int* seg,
double* centers,
int K,
int nPts, int xdim, int ydim
){
int idx = threadIdx.x + bloc... |
6,366 | /* computes the force array */
#include <math.h>
#include <stdio.h>
__global__ void force_aux(long, double *, float *, float *, double *,double *);
__global__ void force_aux2(long, double, double, double *, double *, float *, float *);
void force(long n, long nblock, long nthread, double *mx, double *my, double *... |
6,367 | #include <iostream>
#include <math.h>
// CUDA kernel to add elements of two arrays
__global__
void add(int n, float *x, float *y)
{
int index = blockIdx.x * blockDim.x + threadIdx.x;
int stride = blockDim.x * gridDim.x;
for (int i = index; i < n; i += stride)
y[i] = x[i] + y[i];
}
int main(void)... |
6,368 | #include <iostream>
#include <random>
#include "cuda_runtime_api.h"
double *InitializeArray(const int length, const int seed) {
double *A = (double*)malloc(length * sizeof(double));
std::default_random_engine e;
std::uniform_real_distribution<double> rand(0, 10);
e.seed(seed);
for (int i = 0; i <... |
6,369 | //
// include files
//
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
//
// CPU addition
//
void VecAdd(float* A, float* B, float* C, int N)
{
for (int i = 0; i < N; i++)
C[i] = A[i] + B[i];
}
//
// main code
//
int main(int argc, char **argv)
{
cudaSetDevice(1);
... |
6,370 | #include <stdio.h>
__global__ void hello_from_gpu()
{
const int bid = blockIdx.x;
const int tid = threadIdx.x;
printf("Hello World from the GPU in block %d thread %d!\n", bid, tid);
}
int main(void)
{
hello_from_gpu<<<2, 4>>>();
cudaDeviceSynchronize();
return 0;
} |
6,371 | int main0(int argc, const char **argv) {
}
int main1(int argc, const char *argv[]) {
}
void fp0(const int *x) {
}
void fp1(const int *x = (const int*)0) {
}
void fa0(int x[]) {
}
|
6,372 | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<float.h> //DBL_MAX
#include <cuda_runtime_api.h>
#define restrict __restrict__
#define PADDINGCLASS -2
#define EXP 2
#define OUTPUT_FILE "ocuda"
#define INPUT_FILE "data"
void printStats(size_t bytes, cudaEvent_t before, cudaEvent_t after, const char *m... |
6,373 |
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#define SIZE 32
/* Autores:
*
* Antonio J. Cabrera
* Paul Gazel-Anthoine
*/
// Structs (H)
typedef struct bmpFileHeader {
/* 2 bytes de identificación */
uint32_t size; /* Tamaño del archivo */
uint16... |
6,374 | /*
1. Recibimos como parametros, el canal RGB con el que se va a trabajar
2. lugar en donde se va almacenar el resultado
3. ancho de la imagen
4. alto de la imagen
5. matriz de gauss
6. dimension de la matriz de gauss 3 o 5
*/
__global__ void aplicarFiltroGauss(const unsigned char *inputEspacioC... |
6,375 | //cuda.cu
//simple CUDA functions
//by Wasit 20-8-2011
#include <stdio.h>
#include <cuda_runtime.h>
//memory allocation on device side
extern "C" void CUDA_Constructor(int** g_A,int** g_B,int size){
cudaMalloc(g_A,sizeof(int)*size);
cudaMalloc(g_B,sizeof(int)*size);
}
//copying data from host to device
extern "... |
6,376 | __global__ void edge(int* src, int* des, int* w, int* m, int* dist){
const int e0 = threadIdx.z * blockDim.x * blockDim.y + threadIdx.y * blockDim.x + threadIdx.x;
const int offset = blockDim.x * blockDim.y * blockDim.z;
int e = -1;
__shared__ int quickBreak[1];
while(1){
e = e0;
if(e == 0){
quic... |
6,377 | #include <stdio.h>
#include <math.h>
#define NBLOCKS 1024
#define NTHREADS 256
//Model-1 & 4
__global__ void dvc_ScaLBL_D3Q19_AAodd_GreyscaleColor(int *neighborList, int *Map, double *dist, double *Aq, double *Bq, double *Den,
double *Phi, double *GreySolidGrad, double *Poros,double *Perm, double *Velocity,
... |
6,378 | #include "includes.h"
__global__ void LSTMGateGradientKernelBPTT( float *input, float *previousOutput, float *cellStates, float *inputGateDeltas, float *forgetGateDeltas, float *outputGateDeltas, float* outputGateWeightGradient, float* inputGateWeightGradient, float* forgetGateWeightGradient, int inputCount, int pre... |
6,379 | #include "includes.h"
__global__ void fillArray(int8_t *dest, int loop) {
const size_t i = blockDim.x * blockIdx.x + threadIdx.x;
const size_t k = blockDim.x * gridDim.x;
for (int n=0; n<loop; n++) {
dest[i+n*k] = sin((i+n*k)/(float)100.0)*30;
}
} |
6,380 | #include "DomainTransformKernels.cuh"
namespace mn {
// mark the boundary where the page # changes
__global__ void markPageBoundary(const int numParticle,
const uint64_t *_offsets,
int32_t *_marks) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
i... |
6,381 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cuda.h>
#include <curand_kernel.h>
const int THREADS = 128; //threads per block
const int trial_number = 1024; //trial numbers per thread
const int BLOCKS = 16; //blocks per grid
const float PI = 3.1415926535;
__global__ void pi_estimation(float *pi, ... |
6,382 | #include <stdio.h>
/*
* Initialize array values on the host.
*/
void init(int *a, int N)
{
int i;
for (i = 0; i < N; ++i)
{
a[i] = i;
}
}
/*
* Double elements in parallel on the GPU.
*/
__global__
void doubleElements(int *a, int N)
{
int i;
i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < N)... |
6,383 | #include <iostream>
#include<curand.h>
#include<curand_kernel.h>
#include <vector>
#include <ctime>
#include <cstdlib>
#include <fstream>
using namespace std;
#define PRECISION 10000
#define BLOCKS_NUBMER 4096
#define THREADS_NUMBER 1
__device__ float generate( curandState* globalState, int ind )
{
//int ind = th... |
6,384 | #include "includes.h"
__global__ void cmax(float *d_in, float *max, int len)
{
extern __shared__ float smax[];
unsigned int tid = threadIdx.x;
unsigned int i = blockIdx.x * blockDim.x + threadIdx.x;
smax[tid] = d_in[i]>d_in[i+len] ? d_in[i] : d_in[i+len];
__syncthreads();
if(blockDim.x > 512 && tid<512) {if(smax[ti... |
6,385 | #include "includes.h"
__global__ void updhgF_SoA(float *f, float *z1, float *z2, float *g, float tf, float invlambda, int nx, int ny)
{
int px = blockIdx.x * blockDim.x + threadIdx.x;
int py = blockIdx.y * blockDim.y + threadIdx.y;
int idx = px + py*nx;
float DIVZ;
if (px<nx && py<ny)
{
// compute the divergence
DIVZ ... |
6,386 |
#define N 5
__global__ void MatAdd(float A[N][N], float B[N][N], float C[N][N])
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
int j = blockIdx.y * blockDim.y + threadIdx.y;
if (i < N && j < N)
C[i][j] = A[i][j] + B[i][j];
}
|
6,387 | extern "C"
{
__global__ void DmeanSquareLoss_32(const int lengthx, const float pref, const float *gradc, const float *x,const float *y, float *gradn )
{
int i = threadIdx.x + blockIdx.x * blockDim.x;
if (i<lengthx)
{
gradn[i] += pref * gradc[0] * (x[i]-y[i]);
}
}
} |
6,388 | #include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
#include <cuda.h>
#define SIZEOFINT sizeof(int)
#define BLOCK_DIM 64
#define TH_DIM 32
const int INF = ((1 << 30) - 1);
int n, m, padding_n, pitch_k, Dist_row_size_in_byte;
size_t pitch;
int up_part_size_in_block = 0, bottom_part_size_in_block = 0, up_p... |
6,389 | /**
* Assignment 07 Program - moving_average.cu (edited from module 6 for 7)
* Sarah Helble
* 10/16/17
*
* Calculates the average of each index and its neighbors
*
* Usage ./a.out [-v] [-n num_elements] [-b threads_per_block] [-m max_int]
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <c... |
6,390 | //#define REARRANGED_DOMAIN
__global__ void _balance_deep_and_shallow(
int N,
double H0,
double alpha_balance,
int tight_slope_limiters,
int use_centroid_velocities,
double* wc, // stage_centroid_values
double* zc, // elevation_centroid_values
do... |
6,391 | #include<stdio.h>
__global__ void cuda_hello()
{
printf("Hello World from GPU!\n");
}
int main()
{
printf("Hello World from CPU!\n");
cuda_hello<<<2,3>>>();
cudaDeviceReset();
return 0;
}
|
6,392 | //#include <cuda_runtime_api.h>
#include <cuda.h>
#include <stdio.h>
#include <cstdlib>
#define SIZE 1024
/*
void VectorAdd(int *a, int *b, int *c,int n) {
int i = 0;
for(; i < n; ++i) {
c[i] = a[i] + b[i];
}
}
*/
__global__ void VectorAdd(int *a, int *b, int *c,int n) {
int i = threadIdx.x;
... |
6,393 | #include <iostream>
#include <cmath>
#define CUDA_CHECK_RETURN(value) {\
cudaError_t _m_cudaStat = value;\
if (_m_cudaStat != cudaSuccess) {\
fprintf(stderr, "Error %s at line %d in file %s\n", cudaGetErrorString(_m_cudaStat), __LINE__, __FILE__);\
exit(1);\
}\
}
using namespace std;
__gl... |
6,394 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <complex>
#include <cuda.h>
#include <cufft.h>
#include <math.h>
#include <vector>
#include <stdio.h>
#include <iostream>
//#include <cuPrintf.cu>
#define M_PI 3.1415926
using namespace std... |
6,395 | #include "includes.h"
__global__ void kernel_push_stochastic1( int *g_push_reser, int *s_push_reser, int *g_count_blocks, bool *g_finish, int *g_block_num, int width1)
{
int x = __umul24( blockIdx.x, blockDim.x ) + threadIdx.x ;
int y = __umul24( blockIdx.y , blockDim.y ) + threadIdx.y ;
int thid = __umul24( y , widt... |
6,396 | #include <stdio.h>
#include <string.h>
#include <math.h>
#include <cuda_runtime.h>
#include <sys/time.h>
#include <time.h>
#ifndef BLOCK_SIZE
#define BLOCK_SIZE 256
#endif
#ifndef N_ELEMS
#define N_ELEMS 753411
#endif
// Src: Lab1-CudaIntro. Get time difference
int timeval_subtract(
struct timeval *resul... |
6,397 | #include "includes.h"
__global__ void fm_order2_dgrad_kernel(const float* in, const float* top_grad, float* dgrad, int batch_size, int slot_num, int emb_vec_size) {
int tid = threadIdx.x;
int bid = blockIdx.x;
if (tid < emb_vec_size && bid < batch_size) {
float emb_sum = 0.0f;
int offset = bid * slot_num * emb_vec_siz... |
6,398 |
extern "C"
__global__ void reverseVec(int n, float *a, float *b)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i<n)
{
b[n-1-i] = a[i];
}
}
|
6,399 | #include <iostream>
#include <cstdlib>
int main() {
int* vetor; //Declares a integer pointer
int* vetor_d; //Declares a integer pointer
int N = 10; //Declares and initializes N to 10
int buffer_size = sizeof(int)*N; //Number of bytes in our array
vetor = (int*) malloc (buffer_size); //Allocates the host vect... |
6,400 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <iostream>
#include <time.h>
#include <cstdlib>
using namespace std;
#define N 2048
#define Iteration 100
__global__ void matrixTranspose(int *a, int *b)
{
int i = blockIdx.y * blockDim.y + threadIdx.y; // row
int j = block... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.