serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
16,601 | #include <stdio.h>
#include <float.h>
/* Function that normalizes the image */
void
normalizeImage(float *image,int Size_i,int Size_j){
int Size = Size_i*Size_j;
/* Find MIN */
float min = FLT_MAX;
for(int i=0;i<Size;i++){
if (image[i]<min) min = image[i];
}
/* Subtract min */
for(int i=0;i<Size;i++)
image[i... |
16,602 | #include <iostream>
#include <vector>
#include <set>
#include <limits>
#include <stdlib.h>
#include <ctime>
#include <thread>
#include <iomanip>
#include <sys/time.h>
//#define INF std::numeric_limits<int>::max()
#define INF 1147483647
template<std::size_t n>
__device__ void dijkstra(int *graph, int graphIdx, int sour... |
16,603 | #include "cuda_utils.cuh"
#include <sstream>
void cuda_check(const std::string &file, int line)
{
static std::string prev_file;
static int prev_line = 0;
cudaError_t e = cudaGetLastError();
if (e != cudaSuccess)
{
std::stringstream ss;
ss << file << ", line " << line << ": " << cu... |
16,604 | //pass
//--blockDim=[8,8] --gridDim=[1,1]
#include <cuda.h>
#define _2D_ACCESS(A, y, x, X_DIM) A[(y)*(X_DIM)+(x)]
//////////////////////////////////////////////////////////////////////////////
//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING... |
16,605 | #include "curand_kernel.h"
#define NODE_TERMINAL -1
#define NODE_TOSPLIT -2
#define NODE_INTERIOR -3
__device__ void movedata() {
}
__device__ void sampledata(const int nclass, const int* nsamples, const int* samplefrom,
const int maxnsamples, int* bagstart, curandState_t *randstate)
{
//Select random samples
in... |
16,606 | #include "includes.h"
__global__ void saxpy(float *x, float *y, const float a)
{
const int i = blockIdx.x*blockDim.x + threadIdx.x;
if (i<ARRAY_SIZE) {
y[i] = a*x[i] + y[i];
}
} |
16,607 | #include "includes.h"
__global__ void fitness_kernel(int* chromosome, int* collision) {
/*unsigned int index = threadIdx.x + blockDim.x * blockIdx.x;
unsigned int stride = blockDim.x * gridDim.x;*/
unsigned int tid = threadIdx.x;
unsigned int bid = blockIdx.x;
int temp = chromosome[bid];
int d = 0;
extern __shared__ in... |
16,608 | #include "includes.h"
__global__ void _softback(int nrows, int ncols, float *y, float *dy) {
/* y is layer output, i.e. unnormalized log probabilities.
On output y will contain normalized probabilities.
Conceptually this is a forward calculation but we do it here for efficiency.
dy is the label matrix: each column is a... |
16,609 | #include <stdio.h>
// CUDA sample - elements
// This is not a complete app! Need to add the main section
// The memory is allocated and handled in a 'classical' way
// Matrices are stored in row-major order:
// M(row, col) = *(M.elements + row * M.width + col)
typedef struct {
int width;
int height;
float* ... |
16,610 | //##############################################################################################################################################################################################################//
//Aquila - An Open-Source GPU-Accelerated Toolkit for Cognitive and Neuro-Robotics Research ... |
16,611 | /**
* Author: Zachariah Bryant
* Description: Testing file for various purposes.
*/
// ********************
// * Headers *
// ********************
#include <sys/stat.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <fstream>
#include <string>
#include "./Headers/Complex.cuh"
#i... |
16,612 | #include <device_launch_parameters.h>
#include <cuda_runtime_api.h>
#include <cstdio>
// Device input vectors
int *d_a;
//Device output vector
int *d_b;
__global__ void naivePrefixSum(int *A, int *B, int size, int iteration) {
const int index = blockIdx.x * blockDim.x + threadIdx.x;
if (index < size) {
... |
16,613 | #include "includes.h"
__global__ void encryptKernel(char* deviceDataIn, char* deviceDataOut, int n, char *key, int keySize) {
unsigned index = blockIdx.x * blockDim.x + threadIdx.x;
if (index < n)
deviceDataOut[index] = deviceDataIn[index] + key[index % keySize];
} |
16,614 |
#include <stdio.h>
#include <math.h>
#define PI 3.1415926535898
int main () {
float r = 3.0;
int shell = 10;
float dr = r / shell;
int count = 0;
float r_iw, b_ij1, b_ij2, b_ijw, a_ijk1, a_ijk2, a_ijkw, w_x, w_y, w_z;
// b_ij1 = b_ij, b_ij2 = b_i(j-1); same for a_ijk.
for (int ii = 1; ii ... |
16,615 | /*
* Sum-Product Algorithm using GPU
*
* Written by: Zana Rashidi
*
* As part of the B.Sc. Project in Computer Engineering
*
* Computer Engineering Department, Sharif University of Technology
*
* Supervisor: Mahdi Jafari Siavoshani
*
* July 2017
*/
#include <iostream>
#include <cmath>
#include <fstre... |
16,616 | #include "includes.h"
__global__ void kernel_256_one_1024(float *A, float *B, float *bnBias, float *bnScale, float *C) {
int tile = blockIdx.x, part = blockIdx.y, in_channel = threadIdx.x, line = threadIdx.y;
int ind = line*256 + in_channel;
extern __shared__ float shared_[];
float *weights = shared_ + 256*4, *output ... |
16,617 | #include <stdio.h>
#include <cuda.h>
#include <sys/time.h>
__global__ void dkernel(unsigned *vector, unsigned vectorsize,int i) {
unsigned id = blockIdx.x * blockDim.x + threadIdx.x;
vector[id] = id;
for(int g=1;g<=i;g++)
__syncthreads();//barrier here
}
#define BLOCKSIZE 1024
int main(int nn, ch... |
16,618 | #include <stdio.h>
__global__ void add(int *a, int *b, int *c)
{
int i = threadIdx.x;
*(c+i) = *(a+i) + *(b+i);
}
int main(void)
{
int N=4;
int a[] = {3, 4, 5, 6};
int b[] = {5, 7, 8, 9};
int c[N];
// host copies of variables a, b & c
int *d_a, *d_b, *d_c;
// device copies of variables a, b & c
int size = N*... |
16,619 | #include <stdio.h>
//#define DEBUGPRINT 0
__global__ void compute_entropy_gpu_kernel(double *tlag, double *pr, double *vtrans,int ntot, int irho, double ntol , double rgam, double gmaref,int ltot ){
int id = blockIdx.x*blockDim.x+threadIdx.x;
if(id<ntot){
double rho= fmax(vtrans[ltot*(irho-1)+id],ntol);
tlag[... |
16,620 | #include "includes.h"
__global__ void ThirdAngle(int *a1, int *a2, int *a3)
{
*a3 = (180-*a1-*a2);
} |
16,621 | __global__ void add_two_array_kernel(int nx, int ny, float *output, float *arr1, float *arr2){
const int x = threadIdx.x + blockDim.x * blockIdx.x;
const int y = threadIdx.y + blockDim.y * blockIdx.y;
int ij = nx * y + x;
if (x < nx && y < ny){
output[ij] = arr1[ij] + arr2[ij];
}
}
|
16,622 | /**
豸ʶ
ǵijԶͨcuda API豸Ŀ
*/
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include "driver_types.h"
#include <stdio.h>
int main()
{
cudaError_t cudaStatus;
int num = 0;
cudaDeviceProp prop;
cudaStatus = cudaGetDeviceCount(&num);
// Choose which GPU to run on, change this on a multi-GPU system.
/... |
16,623 | /*
FFT_GPU
Ye Wang
*/
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
//#define M_PI 3.141592653589793f
#define thread_num 512
//#define N 1024
//#define N 2048
//#define N 4096
//#define N 8192
//#define N 16384
//#define N 32768
//#define N 65536
//#define N 131072
//#define N 262144
//#define N 524288
#d... |
16,624 | #include<stdio.h>
#include<stdlib.h>
#include<sys/time.h>
#define NUM 10000000
#define CUDA_ERROR_EXIT(str) do{\
cudaError err = cudaGetLastError();\
if( err != cudaSuccess){\
printf("Cuda Error: '%s' ... |
16,625 | #include "includes.h"
__global__ void cal_pi(float *sum, int nbin, float step, int nthreads, int nBLOCKS) {
int i;
float x;
int idx = blockIdx.x*blockDim.x+threadIdx.x; // Sequential thread index across the BLOCKS
for (i=idx; i< nbin; i+=nthreads*nBLOCKS) {
x = (i+0.5)*step;
sum[idx] += 4.0/(1.0+x*x);
}
} |
16,626 | #include <stdio.h>
#include <stdlib.h>
#define BLOCK_SIZE 16
#define RANDOM_MN_RANGE 64
// Matrices are stored in row-major order:
// M(row, col) = *(M.elements + row * M.stride + col)
struct Matrix {
int width;
int height;
int stride;
float* elements;
};
// Get a matrix element
__device__ float GetE... |
16,627 | #include <stdlib.h>
#include <stdio.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <time.h>
#include <string.h>
// taille du domaine
const int Nx = 64 ;
const int Ny = 64 ;
const int GridSize = Nx*Ny ;
// temps de simulation [s] et de reference
const float T = 2.e+2;
// boite de Lx*Ly [m]
const float Lx = ... |
16,628 | #include "includes.h"
// Number of elements to put in the test array
#define TEST_SIZE 16
#define NUM_BINS 10
////////////////////////////////////////////////////////////////
////////////////// COPY EVERYTHING BELOW HERE //////////////////
////////////////////////////////////////////////////////////////
// Number of... |
16,629 | // timestep subroutines
#include "interface.h"
__device__
static bool is_halo(sim_t &sim, int ibox)
{
if ((ibox % sim.nx) >= sim.nx-2) return true;
if ((ibox / sim.nx) % sim.ny >= sim.ny-2) return true;
if ((ibox / sim.nx) / sim.ny >= sim.nz-2) return true;
return false;
}
__global__... |
16,630 | #include <iostream>
__global__
void mult_mat_vec_kernel(float* d_A, float* d_B, float* d_C, int n)
{
int idx = threadIdx.x + blockDim.x * blockIdx.x;
if (idx < n)
{
int idx1 = idx * n;
float sum = 0.0;
for (int i = 0; i < n; ++i)
{
sum += d_A[idx1 + i] * d_B[i];... |
16,631 |
#include <cstdlib>
#include <iostream>
#include <cuda.h>
__global__ void increment(float *val)
{
val[0]++;
}
void
run_par_gpu() {
int device;
const int ngpu = 2;
float *values[ngpu], currentDevice, *fromDevice;
fromDevice = (float *)malloc(ngpu * sizeof(float));
for (device = 0; device < ngpu; device... |
16,632 | #include <cuda.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#define N (4)
#define threshold (0.000000001)
double rtclock();
void compare();
double *A, *B, *C,*RefOut;
#define bSizeX (2)
#define bNumx (N/bSizeX)
#define bNumy (N/2)
__global__ void p1_kernel(double*, double*, double*);
int main(){
... |
16,633 | #define BLOCK_SIZE 256
#define SOFTENING 1e-9f
typedef struct { float4 *pos, *vel; } BodySystem;
void randomizeBodies(float *data, int n) {
for (int i = 0; i < n; i++) {
data[i] = 2.0f * (rand() / (float)RAND_MAX) - 1.0f;
}
}
__global__
void applyForce(float4 *p, float4 *v, float4 *d, float dt, int n) {
... |
16,634 | #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
/**********************************... |
16,635 | //pass
//--blockDim=64 --gridDim=64 --no-inline
#include "cuda.h"
__global__ void foo() {
{
int x = 4;
}
{
int x = 2;
}
}
|
16,636 | // filename: freduce.cu
#include <stdint.h>
//======================================================================
__device__ __host__
void reduce_hash(uint32_t H[], uint8_t B[], int link_idx);
//======================================================================
__device__ __host__
void reduce_hash(uint32_t H[... |
16,637 | #include <cstdlib>
#include <iostream>
#include <cuda.h>
#include <stdio.h>
__global__ void gInitializeStorage(float* storage_d){
int i = threadIdx.x + blockIdx.x * blockDim.x;
int j = threadIdx.y + blockIdx.y * blockDim.y;
int N = blockDim.x * gridDim.x;
storage_d[i + j * N] = (float)(i + j * N);
}
_... |
16,638 | // This routine is used by SMS.
// This routine returns a pointer to an exchange variable.
// The pointers table in this routine must contain all the variables to be exchanged.
// Eventually PPP will generate the pointers table.
// Currently (April 2012) the pointers table is hard coded for FIM.
// Author: Jacques Mid... |
16,639 | #include <cuda.h>
#include "cuda_runtime.h"
// #include <cutil.h>
#include "texture_fetch_functions.h"
#include "device_functions.h"
#include "device_launch_parameters.h"
#include <cuda_profiler_api.h>
#include <stdio.h>
#include <iostream>
#define DATATYPE int
#define ARRAYLEN 128*1024*1024
inline void __getLastCu... |
16,640 | #include <fstream>
#include <iostream>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/sort.h>
#include <thrust/random.h>
using namespace std;
/*
Compares two integers lexicographically from least to greatest.
First the input integers are reversed. Next reversed integers are trave... |
16,641 | #include <stdio.h>
#include <cuda.h>
//Device functions can only be called from other device or global functions. __device__ functions cannot be called from host code.
//Global functions are also called "kernels". It's the functions that you may call from the host side using CUDA kernel call semantics (<<<...>>>).
__... |
16,642 | // Tests the phases generated for a CUDA offloading target for different
// combinations of:
// - Number of gpu architectures;
// - Host/device-only compilation;
// - User-requested final phase - binary or assembly.
// REQUIRES: clang-driver
// REQUIRES: powerpc-registered-target
// REQUIRES: nvptx-registered-target
... |
16,643 | // This example demonstrates parallel floating point vector
// addition with a simple __global__ function.
#include <stdlib.h>
#include <stdio.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... |
16,644 | // A2.cu
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cuda.h>
#include <cuda_runtime.h>
template <unsigned int blockSize>
__device__ void warpReduce(volatile double* sdata, int tid)
{
if (blockSize >= 64) sdata[tid] += sdata[tid + 32];
if (blockSize >= 32) sdata[tid] += sdata[tid + 16];
... |
16,645 | #include <stdio.h>
__global__
void square(float * out, float * in){
int idx = threadIdx.x;
float f = in[idx];
out[idx] = f * f;
}
int main(int argc, char ** argv) {
const int ARRAY_SIZE = 64;
const int ARRAY_BYTES = ARRAY_SIZE * sizeof(float);
// declare memory pointers
float * in, * out;
// Alloc... |
16,646 | #include <stdio.h>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <cuda_runtime_api.h>
#include <errno.h>
#include <unistd.h>
/******************************************************************************
* This program takes an initial estimate of m and c and finds the associated
* rms error. It... |
16,647 | extern "C" __global__ void kernel0(int* C, int loop) {
int id = threadIdx.x + blockIdx.x * blockDim.x;
for (int i = 0; i < loop; i++) {
for (int j = 0; j < loop; j++) {
C[id] += id;
}
}
}
extern "C" __global__ void kernel1(int* C, int loop) {
int id = threadIdx.x + blockIdx.x * blockDim.x;
for (int i... |
16,648 | /*--------------------------------------------------------------------------*\
Copyright (c) 2008-2010, Danny Ruijters. All rights reserved.
http://www.dannyruijters.nl/cubicinterpolation/
This file is part of CUDA Cubic B-Spline Interpolation (CI).
Redistribution and use in source and binary forms, with or without
mo... |
16,649 | #include <stdio.h>
#include <time.h>
#define N 4096//矩阵的N次方
#define BlockNum 1//block的数量
#define ThreadNum 64 //每个block中threads的数量
#define m 100//每个行有多少个元素,即矩阵的维度
__global__ void Gpu_martixN(double* Gpu_martix, double* Gpu_res)
{
//每个GPU核函数计算矩阵的一行
int tid=blockIdx.x*blockDim.x*blockDim.y+threadIdx.x;
doub... |
16,650 | #include "includes.h"
__global__ void sumArrayOnGPU(float *A, float *B, float *C){
// スレッドIDを割り当てる
int i = threadIdx.x;
C[i] = A[i] + B[i];
} |
16,651 | #include "includes.h"
#define N 10000000
__global__ void c_code(void){
} |
16,652 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
int main()
{
return 0;
} |
16,653 | #include <stdio.h>
#define N 8192
#define TILE 32
#define SIZE N*N
__global__ void transpose_gpu(double *b, const double *a, const int size)
{
int x = blockIdx.x * TILE + threadIdx.x;
int y = blockIdx.y * TILE + threadIdx.y;
int width = gridDim.x * TILE;
for (int i = 0; i < TILE; i+= size)
... |
16,654 | #include<stdio.h>
#include<cuda.h>
#define N 100
__global__ void func(int *a)
{
a[threadIdx.x] = threadIdx.x * threadIdx.x;
}
//This won't work since GPU and CPU will have different memory and the array is assigned in CPU
//The GPU can't access the same memory
// int main()
// {
// int a[N] = {0}, i = 0;
... |
16,655 | #include "includes.h"
__global__ void forward_maxpool_layer_kernel(int n, int in_h, int in_w, int in_c, int stride_x, int stride_y, int size, int pad, float *input, float *output, int *indexes)
{
int h = (in_h + pad - size) / stride_y + 1;
int w = (in_w + pad - size) / stride_x + 1;
int c = in_c;
int id = (blockIdx.x ... |
16,656 | /*
* Copyright 2016 Alexander Terenin
*
* 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 agr... |
16,657 | #include "includes.h"
/* Matrix normalization.
* Compile with "nvcc matrixNormCuda.c -lm"
*/
/* Program Parameters */
#define N 8000 /* Matrix size */
int blocks_per_grid = 32;
int threads_per_block = 256;
/* Matrices */
float A[N*N], B[N*N];
/* CUDA arrays */
float *A_d, *B_d;
/* Initialize A and B*/
__global__... |
16,658 | /*
{
std::cout << "calculate face centroids with cuda (gather)\n";
vector<float3> centroids;
auto time = ab::perf::execution_time([&] {calculate_face_centroids_he_parallel(&he_mesh, centroids); });
std::cout << "calculated centroids in " << time.count() << "ns\n";
string he_centroid_fn = fn + "-he-cuda-face-... |
16,659 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdint.h>
#define MASTER 0
#define MARGIN 1e+30
#define DIM 2 /* Two-dimensional system */
#define X 0 /* x-coordinate subscript */
#define Y 1 /* y-coordinate subscript */
#define GRAIN_SIZE 10
#define WORK_TAG 1
#define K... |
16,660 | //SAXPY - Single-Precision A*X Plus Y
#include <stdio.h>
#include <sys/time.h>
#define BLOCK_SIZE 400
#define NUM_PARTICLES 100000
#define NUM_ITERS 1000
struct particle{
float3 pos;
float3 v;
};
double cpuSecond() {
struct timeval tp;
gettimeofday(&tp,NULL);
return ((double)tp.tv_sec + (double)t... |
16,661 | #include "includes.h"
/*
Problem 1: initialize array of size 32 to 0
Problem 2: change array size to 1024
Problem 3: create another kernel that adds i to array[ i ]
Problem 4: change array size 8000 (check answer to Problem 3 still works)
*/
//initialize array to 0
//add i to array[ i ]
__global__ void kernel2( int ... |
16,662 | // Matrix Multiplication in gpu with and without tiling.
// Compile with: nvcc -o test matrix_multiplication.cu -std=c++11
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <random>
#include <iostream>
#include <chrono>
#define TS 32
// Multiplies matrices using GPU with 2D grid
__global__ void multi... |
16,663 | //pass
//--blockDim=[1024,1] --gridDim=[4,1]
#include <cuda.h>
//////////////////////////////////////////////////////////////////////////////
//// Copyright (c) Microsoft Corporation. All rights reserved
//// This software contains source code provided by NVIDIA Corporation.
//////////////////////////////////////////... |
16,664 |
#include<stdio.h>
//#include<cuda.h>
#include<cuda_runtime.h>
#define N 32
#define T 32 // max threads per block
#include <stdio.h>
__global__ void vecAdd (int *a, int *b, int *c);
int main() {
int a[N], b[N], c[N];
int *dev_a, *dev_b, *dev_c;
// initialize a and b with real values (NOT SHOWN)
int size = N * sizeo... |
16,665 | #include <cuda_runtime.h>
#include <stdio.h>
int
main(int argc, char **argv)
{
int devcnt = 0;
cudaError_t e = cudaGetDeviceCount(&devcnt);
if (e != cudaSuccess)
{
printf("cudaGetDeviceCount returned %d\n%s\n", (int) e,
cudaGetErrorString(e));
exit(EXIT_FAIL... |
16,666 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <cmath>
#define n 10000
#define BLOCK 10
__global__ void Su(float *S_d, float *x)
{
int i = threadIdx.x + blockIdx.x*blockDim.x;
float q = 1.0;
for (int j = 1; j <= *x; j++)
{
q = q*i;
}
S_d[i] = 1./q;
}
int main()
{... |
16,667 | #include "includes.h"
__global__ void gCopyCols(float* out, const float* in, size_t rows, size_t colsIn, const size_t* sourceColIdx, size_t colsOut) {
for(int bid = 0; bid < rows; bid += gridDim.x) {
int j = bid + blockIdx.x;
if(j < rows) {
const float* rowIn = in + j * colsIn;
float* rowOut = out + j * colsOut;
for(i... |
16,668 | #include <cstdio>
#include <cuda_runtime.h>
#define SIZE 5
#if defined(NDEBUG) // release mode
#define CUDA_CHECK(x)(x)
#else //debug mode
#define CUDA_CHECK(X) do{\
(X);\
cudaError_t e = cudaGetLastError();\
if(cudaSuccess != e){\
printf("cuda failure %s at %s : %d", cudaGetErrorStri... |
16,669 | /**********************************************************************
* DESCRIPTION:
* Serial Concurrent Wave Equation - C Version
* This program implements the concurrent wave equation
*********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <math... |
16,670 | /***************************************************************************//**
* \file calculateForce.cu
* \author Anush Krishnan (anush@bu.edu),
* \author Christopher Minar (minarc@oregonstate.edu)
* \based of original cuIBM
*/
#include "calculateForce.h"
namespace kernels
{
/**
* \brief Calculates drag usi... |
16,671 | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <assert.h>
/**
Max size 1024
*/
__global__ void kreduce(unsigned int *vec, int size){
int tid = threadIdx.x;
int gid = blockIdx.x * blockDim.x + tid;
for(int offset=(size/2);offset >= 1;offset /= 2){
if(tid < offset){
vec[... |
16,672 | #include "includes.h"
__global__ void kern_ApplyCapacity(float* sinkBuffer, float* capBuffer, int size)
{
int idx = CUDASTDOFFSET;
float value = sinkBuffer[idx];
float cap = capBuffer[idx];
value = (value < 0.0f) ? 0.0f: value;
value = (value > cap) ? cap: value;
if( idx < size )
{
sinkBuffer[idx] = value;
}
} |
16,673 | #include<cuda.h>
#include<cuda_runtime.h>
#include<stdio.h>
#include<stdlib.h>
__global__ void vectorAdd(float*, float*, float*, int);
//-------------------------------------------------------------
__global__
void vectorAdd(float* A, float* B, float *C, int n)
{
//CUDA kernel defination
int i = threadIdx.x... |
16,674 |
#include <stdio.h>
#define CHECK(e) { int res = (e); if (res) printf("CUDA ERROR %d\n", res); }
#define THRESH 10000
struct Image {
int width;
int height;
unsigned char *img;
unsigned char *dev_img;
};
int main(int argc, char **argv)
{
Image source;
if (argc != 2)
{
printf("Usage: exec filenam... |
16,675 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include <sys/types.h>
#define DEBUG_ENABLE 0
#define ERROR_TRACING 0
#define V 7000
#define INF 1000000
///const int INF = 1000000;
///const int V = 7000;
void input(char *inFileName);
void output(char *outFileName);
void block_APSP(int B)... |
16,676 | #include <stdlib.h>
#include <stdio.h>
__global__ void kernel11(int *a, int *b, int *c)
{
a[blockIdx.y*blockDim.x*gridDim.x+blockIdx.x*blockDim.x + threadIdx.x]=blockIdx.x;
b[blockIdx.y*blockDim.x*gridDim.x+blockIdx.x*blockDim.x + threadIdx.x]=blockIdx.y;
c[blockIdx.y*blockDim.x*gridDim.x+blockIdx.x*blockDim... |
16,677 | #include "includes.h"
__global__ void compute_Gamma_kernel(double* Gamma, int Gamma_n, int Gamma_ld, double* N, int N_r, int N_c, int N_ld, double* G, int G_r, int G_c, int G_ld, int* random_vertex_vector, double* exp_V, double* exp_delta_V) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
int j = blockIdx.y * blockDim... |
16,678 | /*
* Copyright (c) 2012 by Jrn Dinkla, www.dinkla.com, All rights reserved.
*/
#include <stdio.h>
__global__ void hello()
{
int i = threadIdx.x;
printf("Hello World %i\n", i);
}
int main()
{
hello<<<1, 3>>>();
cudaDeviceSynchronize();
}
|
16,679 | #include <stdlib.h>
#include <stdio.h>
#include <math.h>
__global__ void fibonacci(int n) {
int novoN = abs((n - (int) blockIdx.x + (int) threadIdx.x) % n);
int aux = novoN;
long long int a = 0;
long long int b = 1;
while (aux-- > 1) {
long long int t = a;
a = b;
b += t;
}
printf("Fibonacc... |
16,680 | extern "C"
__global__ void setCoeffPoolKernel(
int nBatch,int rbs,int nDegree,int nDScale,
// arrays pointer
float *CA,
float *SA,
// pointer of array of pointer to pointer of array in arrays, nevermind i just stun you.
// p(i) = data(i + size(data))
float **CP,
float **SP
)
{
int taskIdx = blockIdx.x * blockDim.x... |
16,681 | #include <stdio.h>
#define N 512
__global__ void add(int *a, int *b);
int main()
{
int *a, *b;
int *d_a, *d_b;
int i;
// allocate space for device copies
cudaMalloc(&d_a, N*sizeof(int));
cudaMalloc(&d_b, N*sizeof(int));
//cudaMalloc(&d_c, sizeof(int));
// allocate variables
a = (int *)malloc(N*sizeof(int)... |
16,682 | #define _USE_MATH_DEFINES
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
cudaError_t addWithCuda(int *c, const int *a, const int *b, unsigned int size);
void print_arr(int*, int, int);
void print_arr(double*, int, int);
do... |
16,683 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cuda_runtime.h>
// Host input vectors.
float *h_a;
float *h_b;
// Host output vector.
float *h_c;
// Device input vectors.
float *d_a;
float *d_b;
// Device output vector.
float *d_c;
// Size of arrays.
int n = 0;
/* CUDA kernel. Each thread takes c... |
16,684 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <cstdio>
__global__ void hello_cuda() {
printf("hello CUDA world\n");
}
int main(void)
{
// hello_cuda<<<1, 1>>>();
//hello_cuda<<<1, 20>>>();
// dim3 block(4);
// dim3 grid(8);
dim3 block(8, 2);
dim3 grid(2, 2);
hello_cuda<<<block, ... |
16,685 | // do fft by cuda
|
16,686 | #include <stdlib.h>
#include <iostream>
#include <string>
#include <fstream>
static void HandleError( cudaError_t err, const char *file, int line) {
if (err != cudaSuccess) {
std::cout << cudaGetErrorString( err ) << " in " << file << " line " << line << std::endl;
exit(EXIT_FAILURE);
}
}
#define HANDLE_ER... |
16,687 | //Source: https://kb.iu.edu/d/bdmg
//INDIANA UNIVERSITY
/********************** mat_mul.cu ******************************/
#include <stdlib.h>
#include <stdio.h>
#define M 256
#define P 128
#define N 64
#define BLKSIZ 16
__global__ void mat_mul(float *Ad, float *Bd, float *Cd);
int ma... |
16,688 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#define BLOCK_SIZE 16
#define HEADER_SIZE 122
#define BLOCK_SIZE_SH 18
typedef unsigned char BYTE;
/**
* Structure that represents a BMP image.
*/
typedef struct
{
int width;
int height;
float *data;
} BMPImage;
typ... |
16,689 | // metropolis1.cu
/*
* A simple CUDA-enabled program that approximates Pi by evaluating
* Integrate[ Sqrt[1-x^2], {x,-1,1} ]
* using Metropolis Monte Carlo, with the weight function A*(1-x^2)
* where A is a normalization factor
*/
#include <iostream>
#include <curand.h>
#include <curand_kernel.h>
#include <st... |
16,690 | /*
* Shift array forward and sync with barriers
*
* compile:
* nvcc -o barriers barriers.cu
*/
#include <stdio.h>
#define ARRAY_SIZE 16
__global__ void shiftArray() {
int idx = threadIdx.x;
__shared__ int array[ARRAY_SIZE];
array[idx] = threadIdx.x;
__syncthreads();
if (idx < ARRAY_SIZE - 1) {
i... |
16,691 | #include "includes.h"
__global__ void countRest(int *bin, int *bin_counters, const int num_bins, const int maxBin, const int n)
{
unsigned int xIndex = blockDim.x * blockIdx.x + threadIdx.x;
if ( (xIndex < n) & (bin[xIndex]<num_bins) )
if (bin[xIndex]>= maxBin) atomicAdd(bin_counters+bin[xIndex],1);
} |
16,692 | // ********************************************************************************************************************
// PURPOSE : Index calculations for 2D Grid block with 1D thread block *
// LANGUAGE : CUDA C / CUDA C++ *
// AS... |
16,693 | #include <cassert>
#include <chrono>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <random>
__global__
void multiplication( int * a, int * b, int * c,
int a_rows, int a_columns,
int b_rows, int b_columns,
int c_rows, ... |
16,694 | /*
* Copyright 2016 Alexander Terenin
*
* 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 agr... |
16,695 | #include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <sys/time.h>
#include <math.h>
#define warp_size 32
#define Hwarp_size 16
#define A 0
#define B 15
void checkCUDAError(const char* msg);
__host__ __device__ inline double f(double x)
{
return exp(x)*sin(x);
}
__global__ void romberg(double a, doubl... |
16,696 | #include "MuonSimu.cuh"
__global__ void
evt_calculate_add(int *evt_res_list,int *evt_res_back,int evtnum,int pmtnum)
{
int id = blockIdx.x*blockDim.x+threadIdx.x;
// int evt_res_by_pmt = 0;
if (id < evtnum) // The number of threads can't exceed the number of event
{
for(int i=0; i<pmtnum; i+... |
16,697 | #include <stdio.h>
#include <cuda.h>
const int N = 7;
const int blocksize = 7;
__global__ void hello(char *a, int *b)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x; // Finds the thread_id
//a[threadIdx.x] += b[threadIdx.x];
a[idx] += b[idx];
printf("yan yan yan! \n");
}... |
16,698 | #include "stdio.h"
#include <time.h>
#include <sys/time.h>
typedef int DTYPE;
void matrix_multiplication_serial_1(DTYPE* a, DTYPE* b, DTYPE* c, int m, int n, int l)
{
for(int i = 0; i < m; i++)
{
for(int j = 0; j < n; j++)
{
DTYPE temp = 0;
for(int k = 0; k < l; k++)
... |
16,699 | #include <stdio.h>
#define MAXN 2003
__device__ __host__ int CeilDiv(int a, int b) { return (a-1)/b + 1; }
__device__ int neighbor(int index, int n, char* cuT){
int num;
num = cuT[index-n-1] + cuT[index-n-0] + cuT[index-n+1]
+ cuT[index-0-1] + cuT[index-0+1]
+ cuT[index+n-1] + cuT[index+n-0] + cuT[index+... |
16,700 | #include <algorithm>
#include <assert.h>
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <cuda_runtime.h>
int N = 1024; // length of vector A
float* d_A = NULL; // Pointer to vector A in device memory
double time_memcpy = 0;
double time_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.