serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
19,101 | #include "includes.h"
__global__ void matadd_2d(const float *a, const float *b, float *c, int n, int m){
int i = blockDim.x * blockIdx.x + threadIdx.x;
int j = blockIdx.y;
if(i < n and j < m){
int idx = j * n + i;
c[idx] = a[idx] + b[idx];
}
} |
19,102 | /// stuff happening
// nvall -o mdCuda mdCuda.cu -g -G -lrt -lm
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#define LINUX 1 // is this on a linux machine??
#define NEAREST 0 // Are we going to use nearest alg... |
19,103 | #include <cuda.h>
#include <stdio.h>
int main(int argc,char *argv[]){
if(argc<3){
printf("Usage: ./test.cu <ptx_file> <cuda_device>\n");
exit(0);
}
// Error code
CUresult error;
// My number
unsigned int h_var=7;
// Initialize driver API
error = cuInit(0);
if((int)error!=0){
pri... |
19,104 | #include "includes.h"
__global__ void saxpy_baseline ( float* y, float* x, float a, clock_t * timer_vals)
{
for (int i=0; i < NUM_ITERS; i++) {
unsigned int idx = i * COMPUTE_THREADS_PER_CTA * CTA_COUNT + blockIdx.x * COMPUTE_THREADS_PER_CTA + threadIdx.x;
y[idx] = a * x[idx] + y[idx];
}
} |
19,105 | #include "DES-Cracker.cuh"
static __device__ __constant__ int E[48] = {
32, 1, 2, 3, 4, 5,
4, 5, 6, 7, 8, 9,
8, 9, 10, 11, 12, 13,
12, 13, 14, 15, 16, 17,
16, 17, 18, 19, 20, 21,
20, 21, 22, 23, 24, 25,
24, 25, 26, 27, 28, 29,
28, 29, 30, 31, 32, 1
};
static __device__ __constant__ int P[32] = {
16, 7, 20, 2... |
19,106 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <math.h>
double dwalltime(){
double sec;
struct timeval tv;
gettimeofday(&tv,NULL);
sec = tv.tv_sec + tv.tv_usec/1000000.0;
return sec;
}
__global__ void vecMult(double *d_vecA,unsigned long dist,unsigned long n,un... |
19,107 | #include<cstdio>
extern "C" {
__global__
void HelloWorld(){
int thid = (blockIdx.x * blockDim.x) + threadIdx.x;
printf("Hello World! thread #%d\n", thid);
}
}
|
19,108 | #include <random>
#include <assert.h>
#include <chrono>
#include <iostream>
using real = float;
#define DEBUG
const real tau_v = 20.;
const real tau_exc = 5.;
const real tau_inh = 10.;
const real v_thresh = -50.;
const real v_reset = -60.;
const real v_rest = -49.;
const real wgt_exc = 60.*.27/5;
const real wgt_inh ... |
19,109 | /*
Soma dois vetores
Ilustra a alocação dinâmica da memoria compartilhada
*/
#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#define TAM 16
#define TPB 2
__global__ void soma(int *vetA_glb, int *vetB_glb,int *vetC_glb){
// alocacao dinamica de vetC_shd
extern __shared__ int vetC_shd[];
int idx =... |
19,110 | #include <iostream>
#include <math.h>
int main() {
float *inputs, *weights, *bias, *output;
cudaMallocManaged(&inputs, 3*sizeof(float));
cudaMallocManaged(&weights, 3*sizeof(float));
cudaMallocManaged(&bias, sizeof(float));
cudaMallocManaged(&output, sizeof(float));
inputs[0] = 1.0f;
inputs[1] = 2.0f;
... |
19,111 | #include "includes.h"
__global__ void __word2vecFwd(int nrows, int ncols, int *WA, int *WB, float *A, float *B, float *C) {} |
19,112 | #include <math_constants.h>
#define RADIUS_IN_KM 6372.8
extern "C"
// Computes the haversine distance betwwen two points on Earth
__global__ void haversine(int *size, double *in, double *out) {
const int ix = threadIdx.x + blockIdx.x * blockDim.x;
if (ix < *size ) {
const int lat1ix = 4*ix,lon1ix = (4... |
19,113 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include <iostream>
#include <fstream>
using namespace std;
double get_wall_time(){
struct timeval time;
if (gettimeofday(&time,NULL)){
// Ha... |
19,114 | #include <iostream>
#include <stdio.h>
#include <sys/time.h>
#include <cuda.h>
using namespace std;
#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__, _... |
19,115 | #include "includes.h"
__global__ void grad_descent(float *odata, const float *idata, int size) {
int t = blockIdx.x * blockDim.x + threadIdx.x;
if (t < size) {
odata[t] -= LEARNIG_RATE * idata[t];
}
} |
19,116 | #include <cuda.h>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <chrono>
using namespace std;
/*MatVecMul_Kernel*/
__global__
void MatVecMul_Kernel(float* A, float* B, float* C, int n) {
int i = threadIdx.x;
int offset;
float sum = 0;
if (i < n) {
for (int j = 0; j < n; j++) {
offset = i*n ... |
19,117 | #include "includes.h"
__global__ void kernel0(int n, float a, float *x, float *y){
int i = blockIdx.x*blockDim.x + threadIdx.x;
//comment out this for-loop and uncomment the code in the main function for getting correct results
for (int i = 0; i < n; i++) {
x[i] = 1.0f;
y[i] = 2.0f;
}
if (i < n){
y[i] = a*x[i] + y... |
19,118 | #include "includes.h"
__global__ void calibrate_fix2float(float * dst, const float* sA, const float* sB, float alpha, float beta, int height, int width, int threads) {
int ri = blockIdx.x;
int tid = threadIdx.x;
int loop = (width / threads) + ((width % threads == 0) ? 0 : 1);
float rscale = (sA[ri] == 0.0f) ? 1.0f : s... |
19,119 | #include <stdio.h>
#include <stdlib.h>
__constant__ unsigned long long fatorial[20] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 6227020800, 87178291200, 1307674368000, 20922789888000, 355687428096000, 6402373705728000, 121645100408832000};
/*
__device__
unsigned long long fatorial(... |
19,120 | #include <iostream>
#include <vector>
#include <cuda.h>
#include <cuda_runtime.h>
using namespace std;
#define CUDA_CALL( call ) \
{ ... |
19,121 | #include<iostream>
#include<cuda.h>
using namespace std;
__global__ void kernel(int *data)
{
data[threadIdx.x + blockIdx.x * 8 ] = threadIdx.x + blockIdx.x;
}
int main(){
const int numElem = 16;
int hostArray[numElem], *dArray;
//
cudaMalloc ( (void**) &dArray, sizeof(int) * numElem );
cudaMemset (dArray,... |
19,122 | #include "includes.h"
//////////////////////////////////////////////////////////////////////////////////////////
__global__ void computeCost(const double *Params, const float *Ws, const float *mus, const float *W, const float *mu, const bool *iMatch, const int *iC, const int *Wh, float *cmax){
int j, tid, bid, Nspik... |
19,123 | #include "cuda.h"
#include "math_constants.h"
#include "cuda_runtime.h"
__global__ void runSinWaveKernel(float *data, int size,
float amp, float freq, float ip, int sr) // tt time interval is not needed
{
unsigned int x = blockIdx.x*blockDim.x + threadIdx.x;
if (x >= size) return;
f... |
19,124 | #include <stdio.h>
#include <assert.h>
#include <cuda.h>
#include <cuda_runtime.h>
__global__ void hello() {
printf("Hello CUDA from GPU!!!\n");
}
int main() {
cudaDeviceProp prop;
cudaGetDeviceProperties(&prop, 0);
hello<<<1, 1>>>();
cudaDeviceSynchronize();
printf("Hello CPU\n");
p... |
19,125 | #include "includes.h"
__global__ void RoundKernel(float* input, float* output, int size)
{
int id = blockDim.x * blockIdx.y * gridDim.x + blockDim.x * blockIdx.x + threadIdx.x;
if(id < size)
{
output[id] = round(input[id]);
}
} |
19,126 | #include <cuda.h>
#include <stdio.h>
#include <math.h>
#define BLOCK_WIDTH 16
#define TILE_WIDTH BLOCK_WIDTH
extern "C" void gpu_mat_mul(float* h_M, float* h_N, float* h_P, int m, int p, int n);
__global__
void gpu_mat_mul_kernel(float* M, float* N, float* P, int m, int p, int n){
__shared__ float Mds[TILE_WIDT... |
19,127 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <cuda_runtime.h>
__global__ void myKernel(double* dA, double* dB, double* dC, int size) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
if (index > size)
return;
dC[index] = dA[index] + dB[index];
}
double* read_array(const char* filename, in... |
19,128 | #include "includes.h"
__global__ void null_kernel() {
}; |
19,129 | #include<bits/stdc++.h>
#include<cuda.h>
using namespace std;
#define CEIL(a,b) ((a-1)/b+1)
#define N 1024
__global__ void sum(float* d_a, float* d_b, float* d_c, int size)
{
int index = blockIdx.x * blockDim.x + threadIdx.x;
if(index<size)
d_c[index]=d_a[index]+d_b[index];
}
bool verify(float a[], float... |
19,130 | #include <thrust/reduce.h>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
__constant__ double PI = 3.141592653589;
__global__ void bayesianKernel(float *nn,float *kp, float *pv, float *tp, float *C, int start, int end, int comp, float *weights, float *mags, float a_th, int *ppCentroid, int*... |
19,131 | #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 N_points 33554432
#define A 0
#define B 15
void checkCUDAError(const char* msg);
__host__ __device__ inline double f(double x)
{
return exp(x)*sin(x);
}
__global__ vo... |
19,132 | #define DEBUG
#include "Data.cuh"
int main(int argc, char *argv[])
{
Data * data = new Data;
data->Read(argv[1]);
int flow = data->GetFlow();
data->BfsFromT();
return 0;
}
|
19,133 | #include "includes.h"
// filename: vmult!.cu
// a simple CUDA kernel to element multiply two vectors C=alpha*A.*B
extern "C" // ensure function name to be exactly "vmultbang"
{
}
__global__ void binaryentropy(const int lengthX, const double *x, const double *y, double *z)
{
int i = threadIdx.x + blockIdx.x * blockD... |
19,134 | // includes, system
#include <stdio.h>
#include <assert.h>
// Here you can set the device ID that was assigned to you
#define MYDEVICE 0
// Simple utility function to check for CUDA runtime errors
void checkCUDAError(const char *msg);
///////////////////////////////////////////////////////////////////////////////
//... |
19,135 | //general parts
#include <stdio.h>
#include <vector>
#include <memory>
#include <string.h>
#include <chrono>
#include <thread>
#include <iostream>
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif
#include <inttypes.h>
//CUDA parts
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include... |
19,136 | #include <iostream>
#include <vector>
#include <cmath>
#include <random>
#define TPB 32 // tuning this parameter can improve CUDA perf
//control params
#define DIM 3
#define CENTROID_COUNT 8
#define POINTS_COUNT TPB * 40
#define POINTS_RANGE 256
#define ITERS 3
#define NORMAL_DIST false
#define PRINT true
///// UTIL... |
19,137 | #include <cuda.h>
#include <cuda_runtime.h>
#include <cuda_profiler_api.h>
#include <stdio.h>
__global__ void kernel_1(int repeat) {
__shared__ unsigned char s[12288];
int i = threadIdx.x;
s[i] = 0;
for (int n = 0; n < 45; n++) {
for (int n = 0; n < repeat; n++) s[i]++;
for (int n = 0; n < repeat; n++) s[i]--;... |
19,138 | #include "CudaComputing.cuh"
#include "cuda_runtime.h"
#include "device_functions.h"
#include "device_launch_parameters.h"
#include "math.h"
__device__ bool HasTheBall ;
__global__ void setDev_ball(bool dev_ball){
HasTheBall = dev_ball;
}
void setTheBall(bool Ball){
setDev_ball << <1, 1 >> >(Ball);
}
__device__ bo... |
19,139 | #include "includes.h"
// First solution with global memory
// Shared memory residual calculation
// Reduction code from CUDA Slides - Mark Harris
__global__ void gpu_HeatReduction (float *res, float *result) {
extern __shared__ float sdata[];
unsigned int tid = threadIdx.x;
unsigned int index= blockIdx.x*blockDim.x... |
19,140 | __global__ void findMaxInAccum(unsigned int* accum, int w_accum, int h_accum, int* dev_points, int* max)
{
int x = blockDim.x * blockIdx.x + threadIdx.x;
int y = blockDim.y * blockIdx.y + threadIdx.y;
int tid = y * w_accum + x;
if (x >= w_accum || y >= h_accum)
return;
int old = (int)accum[tid];
atomicMax(&... |
19,141 | #include "includes.h"
__global__ void kBlockify(float* source, float* target, int numdims, int blocksize) {
const unsigned int idx = threadIdx.x;
const unsigned int numThreads = blockDim.x;
const int off = blockIdx.x * numdims;
for (unsigned int target_ind = idx; target_ind < numdims; target_ind += numThreads) {
const... |
19,142 | #include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <iostream>
#include <fstream>
#include <vector>
#include <chrono>
#include <cuda_runtime.h>
// #include <cublas_v2.h>
#include <thrust/device_vector.h>
#include <thrust/reduce.h>
#include <thrust/iterator/constant_iterator.h>
#d... |
19,143 | #include <assert.h>
#include <cstdio>
#include <random>
using namespace std;
#define CUDA_CALL(F, ...)\
if((F(__VA_ARGS__)) != cudaSuccess){\
cudaError_t e = cudaGetLastError();\
printf("CUDA failure %s:%d: '%s'\n",__FILE__,__LINE__,cudaGetErrorString(e));\
return(EXIT_FAILURE);\
}
#d... |
19,144 | #include <math.h>
__device__ size_t calculateGlobalIndex() {
// Which block are we?
size_t const globalBlockIndex = blockIdx.x + blockIdx.y * gridDim.x;
// Which thread are we within the block?
size_t const localThreadIdx = threadIdx.x + blockDim.x * blockIdx.y;
// How big is each block?
size_t... |
19,145 | /******************************************************************
File : lcsBigBlockInitializationForVelocities.cu
Author : Mingcheng Chen
Last Update : January 31st, 2013
*******************************************************************/
#include <stdio.h>
#define BLOCK_SIZE 512
__global__ void BigBlockInitia... |
19,146 | #include "includes.h"
__global__ void nothingKernel(){ } |
19,147 | #include "includes.h"
__global__ void stencil_1d(int *in, int *out)
{
// blockDim is 3-dimensional vector storing block grid dimensions
// index of a thread across all threads + RADIUS
int gindex = threadIdx.x + (blockIdx.x * blockDim.x) + RADIUS;
int result = 0;
for (int offset = -RADIUS ; offset <= RADIUS ; offset+... |
19,148 | #include "includes.h"
__global__ void chooseDistance ( const int nwl, const int *kex, const float *didi11, float *didi1 ) {
int i = threadIdx.x + blockDim.x * blockIdx.x;
if ( i < nwl ) {
didi1[i] = didi11[i+kex[i]*nwl];
}
} |
19,149 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <math.h>
#define TILE_WIDTH 32
#define COMMENT "Centrist_GPU"
#define RGB_COMPONENT_COLOR 255
typedef struct {
unsigned char red, green, blue;
} PPMPixel;
typedef struct {
int x, y;
PPMPixel *data;
} PPMImage;
double rtclock()
{
s... |
19,150 | #include <stdio.h>
__global__
void areDivisible(int n, int Nb, int np, int *knownprimes, bool *ans)
{
int i = blockIdx.x*blockDim.x + threadIdx.x; // between [0 and Nb[
int ni = n+i; // number to be tested
if (i<Nb)
{
ans[i] = false;
for (int j=0; j<np; j++)
{
int p = knownprimes[j];
if (ni%p==0) ... |
19,151 | #include <random>
#include <iostream>
__global__ void scaleKernel(float *dataIn, float *dataOut, float scale, int count) {
unsigned idx = blockIdx.x*blockDim.x+threadIdx.x;
if (idx >= count)
return;
const float in = dataIn[idx];
dataIn[idx] = in * scale;
}
int main(void)
{
int size = 100000;
float *hostVal... |
19,152 | // #include <cuda_runtime.h>
#include <sys/time.h>
#include <stdio.h>
#include <string.h>
#define THREADS 10
#define ROOM_SIZE 10
#define BLOCKS (ROOM_SIZE * ROOM_SIZE + THREADS - 1) / THREADS
#define ITERATION_LIMIT 100
__global__ void simulate_room(float *H) {
int index = threadIdx.x + blockIdx.x * THREADS;
int... |
19,153 | //Based on the work of Andrew Krepps
#include <stdio.h>
#include <stdlib.h> //srand and rand
#include <math.h>
// Constant data declaration
#define WORKSIZE 1024 // define a default worksize for constant data
__device__ __constant__ int d_a_const[WORKSIZE];
__device__ __constant__ int d_b_const[WORKSIZE];
/*
Profi... |
19,154 | #include <iostream>
#include <stdio.h>
using namespace std;
int main ( void )
{
cudaDeviceProp prop;
int count;
cudaGetDeviceCount( &count );
for ( int i = 0; i < count; i++ )
{
cudaGetDeviceProperties( &prop, i );
printf( "=====================================================================================... |
19,155 | #include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define NN 200
__global__ void add_cuda_good(int *x,int *y)
{
int tid = threadIdx.x;
int bid = blockIdx.x;
for (int i = 0; i< NN ; i++) {
y[bid*blockDim.x + tid ] += x[bid*... |
19,156 | #include<cuda_runtime.h>
#include<stdio.h>
__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.... |
19,157 | extern "C" __global__ void
staggered_sharp(float* arr, float d)
{
int i = blockDim.x * blockIdx.x + threadIdx.x;
arr[i] = arr[i] / d;
} |
19,158 | /** Prints CUDA GPU information in a machine-readable user-friendly format.
*
* The output can be read with a YAML parser, and is an array with one element
* per CUDA GPU.
*
* Build with:
* nvcc -o cudainfo cudainfo.cu
*/
#include <stdio.h>
int main() {
cudaDeviceProp deviceProperties;
cudaError_t statu... |
19,159 | #include <stdio.h>
__global__ void loop()
{
int curr_loc = threadIdx.x + blockIdx.x * blockDim.x;
printf("This is iteration number %d\n", curr_loc);
}
int main()
{
/*
* we could also do <<<1,10>>> or <<<5,2>>>
*/
int threads = 5;
int blocks = 2;
loop<<<blocks, threads>>>();
cudaDevice... |
19,160 | #include <stdio.h>
#include <math.h>
long long res[64];
__global__ void fib(long long *res)
{
int idx = threadIdx.x;
res[idx] = (long long)(1.0/sqrt(5.0)*(pow((1+sqrt(5.0))/2.0, idx+1) - pow((1-sqrt(5.0))/2.0, idx+1)) + 0.5);
// printf("%d\n", res[idx]);
}
int main()
{
int n;
long long *gpures;
... |
19,161 | /*--
--*/
#include<stdio.h>
#include "../include/Initializer.cuh"
void Initialize_state(float *state){
for(int i = 0; i < DIM_X; i++){
state[i] = initial_state[i];
}
}
void Initialize_input(float *input){
for(int i = 0; i < DIM_U; i++){
input[i] = initial_input[i];
}
}
void Initializ... |
19,162 | #include <stdio.h>
void __global__ kernel_matrix_sum(int *A, int *B, int *C, const int nx, const int ny) {
int ix = threadIdx.x + blockIdx.x * blockDim.x;
int iy = threadIdx.y + blockIdx.y * blockDim.y;
int idx = iy + ny * ix;
if((ix < nx) && (iy < ny)) C[idx] = A[idx] + B[idx];
} |
19,163 | #include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/sort.h>
#include <stdio.h>
extern "C"
cudaError_t cuda_main()
{
printf("stau\n");
// generate bunch random numbers on the host
thrust::host_vector<int> h_vec(1 << 25);
thrust::generate(h_vec.begin(), h_vec.end(), rand);
... |
19,164 | #define N 1024
#include<stdio.h>
__global__ void add(int *a, int *b, int *c){
int i = threadIdx.x;
c[i] = a[i] + b[i];
}
int main(){
int a[N], b[N], c[N];
int *dev_a, *dev_b, *dev_c;
cudaMalloc((void **) &dev_a, N * sizeof(int));
cudaMalloc((void **) &dev_b, N * sizeof(int));
cudaMall... |
19,165 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
__global__ void kernel1()
{
printf("kernel #1\n");
}
__global__ void kernel2()
{
printf("kernel #2\n");
}
int main(int argc,char **argv)
{
printf("Testing multiple kernel launch and show in-order execution of two kernels \n");
int nThreadsPerBlock = 32;... |
19,166 | #include <stdio.h>
int main()
{
float y = 0;
float vy = 10000000000000;
float dt = 0.1;
float L = 1e-4;
y = y + vy*dt;
printf("%f %f %f\n", y, floor(y/L)*L, y - floor(y/L)*L);
y = y - floor(y/L)*L;
}
|
19,167 | #include <stdio.h>
#include <iostream>
#include <time.h>
//#include <cutil_inline.h>
using namespace std;
//*****************************************//
//ֽ豸ϱ __global__ʶ
template<typename T> __global__ void reducePI1(T* __restrict__ d_sum, int num){
//__restrict__ ˵ֻжȡݣʲôأ
//printf("blockIdx.x is %d\n",blockIdx.x);//߳... |
19,168 | //pass
#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <assert.h>
#define N 2//32
__global__ void kernel(uint4 *out) {
uint4 vector = {1,1,1,1};
out[threadIdx.x] = vector;
}
|
19,169 | #include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/copy.h>
#include <thrust/generate.h> // Allow for the
#include <thrust/reduce.h> // Include the reduce operation
#include <thrust/fill.h> // Include the fill operation
#include <thrust/functional.h> // In... |
19,170 | /**
* Copyright 1993-2013 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,171 | /*
* 日期: 2019-1-24
* 时间: 14:42
* 姓名: 杨丰拓
*/
//******************************************************************************************************************//
//对大量数据进行归约操作(例如,最大,最小,求和等)可通过使用共享内存缩短归约操作的时间.
//本程序预设目标归约2^20~2^30个数据,核划分为一维网格一维线程块,通过三次归约操作求出最大值.
//实际可处理数据为0~2^26.
//本程序可以处理0~2^20个数据,但实际上相对与处理的数据来说代... |
19,172 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
__global__ void vecAdd(float* A, float* B, float* C)
{
// threadIdx.x is a built-in variable provided by CUDA at runtime
int i = blockIdx.x * blockDim.x + threadIdx.x;
C[i] = A[i] + B[i];
}
#define cudaSafeCall(err) __cudaSafeCall(err, _... |
19,173 | #include "includes.h"
__global__ void MatrixMulKernel(float *Md, float *Nd, float *Pd, int Width) {
//2D Thread ID
int tx = threadIdx.x;
int ty = threadIdx.y;
//Pvalue stores the Pd element that is computed by the thread
float Pvalue = 0;
for(int k = 0; k < Width ; ++k) {
float Mdelement = Md[ty*Width + k];
float Nde... |
19,174 | #define W 500
#define H 500
#define D 500
#define TX 32
#define TY 32
#define TZ 32
int divUp(int a, int b){return (a+b-1)/b;}
__device__ float distance(int c,int r, int s ,float3 pos)
{
return sqrtf((c-pos.x)*(c-pos.x)+(r-pos.y)*(r-pos.y)+(s-pos.z)*(s-pos.z));
}
__global__
void distanceKernel(float *d_out, int w, ... |
19,175 | #include "includes.h"
__global__ void convolution_kernel(float *output, float *input, float *filter) {
//declare shared memory for this thread block
//the area reserved is equal to the thread block size plus
//the size of the border needed for the computation
//Write a for loop that loads all values needed by this thr... |
19,176 | #include "includes.h"
const int Nthreads = 1024, maxFR = 5000, NrankMax = 6;
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////... |
19,177 | /*
Group info:
hkhetaw Harsh Khetawat
asiddiq Anas Siddiqui
rkrish11 Rahul Krishna
*/
#include <math.h>
/* floating point precision type definitions */
typedef double FP_PREC;
//returns the function y(x) = fn
FP_PREC fn(FP_PREC x)
{
return x*x;
}
|
19,178 | //
// Created by saleh on 10/8/18.
//
__global__ void kernel_sqrt_float(const float * __restrict__ g_idata, float * __restrict__ g_odata, unsigned long len){
unsigned long idx = blockIdx.x * blockDim.x + threadIdx.x;
if(idx<len){
g_odata[idx] = sqrt(g_idata[idx]);
}
}
void sqrt_float(
cons... |
19,179 | #include "includes.h"
__global__ void matrixMult(int* m, int* n, int* p, int size)
{
int row = blockIdx.y * blockDim.y + threadIdx.y;
int col = blockIdx.x * blockDim.x + threadIdx.x;
int p_sum;
for (int i = 0;i < size;i++) {
p_sum += m[row * size + i] * n[col * size + i];
}
p[row * size + col] = p_sum;
} |
19,180 | #include "includes.h"
__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];
}
} |
19,181 | #include <stdio.h>
#include <thrust/device_vector.h>
#include <thrust/sort.h>
#include <thrust/execution_policy.h>
#include <thrust/unique.h>
#include <iostream>
int unique_gpu_launcher(long long* input_voxel_ids_temp,
int* input_point_ids_temp,
int input_npoint) {
// ... |
19,182 | #include <stdio.h>
#include <stdlib.h>
#define N 600
__global__ void MatAdd(int A[][N], int B[][N], int C[][N]){
int i = blockIdx.x;// genarating random genarated multidiomentional arrays
int j = blockIdx.y;
C[i][j] = A[i][j] + B[i][j]; // genarating random genarated multidiomention... |
19,183 | #include <cstdio>
#include <cstdlib>
#include <cuda_runtime.h>
const int VECTOR_SIZE = 1024;
__global__ void vector_add(int a[], int b[], int out[], size_t size) {
const size_t i = threadIdx.x;
if (i < size) {
out[i] = a[i] + b[i];
}
}
int main(int argc, char *argv[]) {
int *a, *b, *out;... |
19,184 |
////////////////////////////////////////////////////////////////////////
// define kernel block size for
////////////////////////////////////////////////////////////////////////
#define BLOCK_X 32
#define BLOCK_Y 8
// device code
__global__ void GPU_adi_rhs(int NX, int NY, int NZ, float lam,
const float* __restri... |
19,185 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <time.h>
#define TIMER_CREATE(t) \
cudaEvent_t t##_start, t##_end; \
cudaEventCreate(&t##_start); \
cudaEventCreate(&t##_end);
#define TIMER_START(t) \
cudaEventRecord(t##_start); ... |
19,186 | #include "includes.h"
__global__ void arrayOfPriors1 ( const int dim, const int nwl, const float *cn, const float *nhMd, const float *nhSg, const float *xx, float *pr ) {
int i = threadIdx.x + blockDim.x * blockIdx.x;
float sum; //, theta, kk;
if ( i < nwl ) {
//theta = powf ( nhSg[i], 2 ) / nhMd[i];
//kk = nhMd[i] / t... |
19,187 | #include <chrono>
#include <iostream>
#include <ncurses.h>
#include <thread>
__attribute__((noinline)) void _abortError(const char* msg, const char* fname,
int line)
{
cudaError_t err = cudaGetLastError();
std::clog << fname << ": "
<< "line: " << line <... |
19,188 | // Exemplo para o curso de Super Computacao
// Criado por: Luciano P. Soares
#include <stdio.h>
#include <stdlib.h>
/* Rotina para somar dois vetores na GPU */
__global__ void add(double *a, double *b, double *c, int N) {
int i=blockIdx.x*blockDim.x+threadIdx.x;
if(i<N) { // Importante checar valor do i pois... |
19,189 | #include <stdio.h>
#include <stdint.h>
#define CHECK(call) \
{ \
const cudaError_t error = call; \
if (error != cudaSuccess) ... |
19,190 | #include <stdio.h>
#include <stdlib.h>
#include <assert.h>
// For the CUDA runtime routines (prefixed with "cuda_")
#include <cuda_runtime.h>
#define DEBUG 0
#define ENUM_NUM 19 // the number of loops in each thread
#define UNKNOWN_NUM 64 // the number of unknowns
#define POLY_NUM 64 // the numbe... |
19,191 | #include<stdlib.h>
#include<stdio.h>
#include<math.h>
#include<cuda.h>
__global__ void add(float *a , float *b)
{
int id = blockIdx.x*blockDim.x+threadIdx.x;
b[id] = sinf(a[id]);
}
int main(void)
{
float *a , *b ;
float *d_a , *d_b ;
printf("Enter the value of N \n");
int n;
int i;
scanf("%d",&n);
a = (flo... |
19,192 | //Referred Dr.Swenson's Sample code and Nvidia PDF for some code syntaxes and Excerpts. File read logic reference taken from online sources
//like geeks for geeks and cplusplus.com.
/*
Akshaya Nagarajan
ECE 6122 P2
GTID: 903319262
*/
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.... |
19,193 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdlib.h>
#include <iostream>
using namespace std;
#define arraySize 4
__global__ void MatMul(float *C, float *A, float *B, int width, int b_width, int data_len)
{
unsigned int id = threadIdx.x + blockDim.x * blockIdx.x;
if (id > data_len) {
... |
19,194 | #include<fstream>
#include<stdio.h>
#include<iostream>
long long int read_file_to_memmory(FILE *pInfile , int *pPointer)
{
if(pInfile != NULL)
{
int mIndex =0;
int mSize = fread(pPointer+mIndex,1,sizeof(int),pInfile);
long long int mFileSize=0;
while(mSize!= 0)
... |
19,195 | #include "includes.h"
__global__ void kLogisticGrad(float* mat, float* targets, float* out_grad, unsigned int numEls) {
const unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x;
const unsigned int numThreads = blockDim.x * gridDim.x;
for (unsigned int i = idx; i < numEls; i += numThreads) {
out_grad[i] = (targets... |
19,196 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <cstdio>
#include <cuComplex.h>
#include <assert.h>
#include <cufft.h>
#include <cstdlib>
#include <cstring>
#define DEBUG
using namespace std;
const int N = 2e5 + 10;
int t, n;
__constant__ int T[1];
inline cudaError_t checkCuda(cudaError_t res... |
19,197 | #ifndef _AgentProperty_
#define _AgentProperty_
#include <limits>
#include <stdio.h>
#include <math.h>
#include "Vector3D.cu"
__device__ const float MAX_FORCE = 0.05f;
__device__ const float MAX_SPEED = 0.8f;
class AgentProperty
{
public:
Vector3D position;
Vector3D velocity;
Vector3D force;
__host__ __d... |
19,198 | /*
For DIRECTED GRAPH
*/
#include <cuda.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <string>
#include <algorithm>
using namespace std;
/***all macros**/
#define MAX_NODE 100000000
#define DEBUG 1
#defi... |
19,199 | /**
* Implementation of a Simple Matrix Multiplication kernel using CUDA
*
* @author: Yvo Elling
* @date: 10-03-23
*/
#include <stdio.h>
#include <iostream>
#include <cstdint>
#include <chrono>
#include <array>
#define NROF_TEST_RUNS 500
#define MATRIX_WIDTH 8192
#define MATRIX_HEIGHT 8192
#define MATRIX_SIZE M... |
19,200 | #include "includes.h"
__global__ void cu_divide(const float* numerator, float* dst, const float denominator, const int n){
int tid = threadIdx.x + blockIdx.x * blockDim.x;
int stride = blockDim.x * gridDim.x;
while(tid < n){
if(0 == denominator) dst[tid] = 0.0;
else dst[tid] = __fdividef(numerator[tid], denominator);
t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.