serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
1,201 | #include <cstdlib>
#include <cstdio>
#include <cmath>
#include <cassert>
#define SIZE 32
__global__ void matrix_add(float** d_A, float** d_B, float** d_C, size_t size) {
size_t i = threadIdx.x + blockDim.x*blockIdx.x;
size_t j = threadIdx.y + blockDim.y*blockIdx.y;
printf("i: %d, j: %d, d_A[i][j]: %f\n", i, j, ... |
1,202 | #ifndef MATRIXMULTIPLICATIONKERNEL_CU
#define MATRIXMULTIPLICATIONKERNEL_CU
#include <curand.h>
__global__ void matrixMul(float * g_C, float * g_A, float *g_B,int wa, int wb){
int x = blockIdx.x * blockDim.y + threadIdx.x;
int y = blockIdx.y*blockDim.x + threadIdx.y;
float result = 0;
int i = 0;
for(... |
1,203 | #include <stdio.h>
__global__ void VecAdd(float * A, float * B, float * C)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
C[i] = A[i] + B[i];
}
void VecPrint(float * V, int len)
{
int to_print = 10;
if (to_print > len)
to_print = len;
for (int i=0; i<to_print; i++)
{
printf("... |
1,204 | __global__
void vecAdd(float *in1, float *in2, float *out, int len) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
if( i<len ) {
out[i] = in1[i]+in2[i];
}
}
|
1,205 | #include <cuda_runtime.h>
#include <stdio.h>
__global__ void kernel() {
int tid = threadIdx.x;
if (tid < 8) {
printf("inside the kernel\n");
}
else {
printf("outside the kernel\n");
}
}
int cuda(int a, int b) {
kernel<<<1, 10>>>();
cudaDeviceSynchronize();
return 0... |
1,206 | __device__ volatile float BigData[1024*1024];
|
1,207 |
/* 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 ... |
1,208 | #include "includes.h"
__global__ void vecAdd(float* a, float* b, float* c, const int N)
{
const int i = blockIdx.x*blockDim.x + threadIdx.x;
if(i<N)
c[i] = a[i] + b[i];
} |
1,209 | #include "includes.h"
__global__ void vector_add(float *out, float *a, float *b, int n) {
int tid = blockIdx.x * blockDim.x + threadIdx.x;
// Handling arbitrary vector size
if (tid < n){
out[tid] = a[tid] + b[tid];
}
} |
1,210 | #include <stdlib.h>
#include <stdio.h>
int main(void){
int num_elements = 16;
int num_bytes = num_elements*sizeof(int);
int *device_array = 0;
int *host_array = 0;
host_array = (int *)malloc(num_bytes);
cudaMalloc((void**)&device_array, num_bytes);
cudaMemset(device_array, 0, num_bytes);
cudaMemcpy(host_array, de... |
1,211 | #include <stdio.h>
#include <cuda_runtime.h>
#include <cuda.h>
#include <stdlib.h>
#include "device_launch_parameters.h"
#include <thrust/scan.h>
#include <thrust/device_vector.h>
#include <thrust/count.h>
const int BASE1 = 10000 + 7;
const int BASE2 = 100000 + 3;
const int MOD1 = 1000000 + 3;
const int MOD2 = 1000000 ... |
1,212 | #include <stdio.h>
#include <cuda.h>
__global__ void vecmul(float *A, float* B, float *C, int size)
{
// Row and Column indexes:
int row = blockIdx.y * blockDim.y + threadIdx.y;
int col = blockIdx.x * blockDim.x + threadIdx.x;
// Are they bellow the maximum?
if (col < size && row < size) {
... |
1,213 | /*
* Name: Nate Steawrt
* Date: 04-04-16
* Description: Serial implementation of Matrix morphism
*/
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#define RANDOM_VALUE_MIN 1.0
#define RANDOM_VALUE_MAX 2.0
#define NUM_ROWS 4097
#define NUM_COLS 4097
/*
* Calculate and return a random value between min... |
1,214 | #include "includes.h"
#define WEIGHTSUM 273
#define BLOCK_SIZE 16
int * heatmap;
size_t heatmap_pitch;
int * scaled_heatmap;
size_t scaled_heatmap_pitch;
int * blurred_heatmap;
size_t blurred_heatmap_pitch;
float* d_desiredPositionX;
float* d_desiredPositionY;
__global__ void computeScaledHeatmap(int* heatmap, si... |
1,215 | #include<stdio.h>
#include<math.h>
#include<cuda.h>
#define N 256
__global__ void matrix_vector_multi_gpu_2_128(float *A_d,float *B_d,float *C_d){
int i,j;
j=blockIdx.x*128+threadIdx.x;
A_d[j]=0.0F;
for(i=0;i<N;i++){
A_d[j]=A_d[j]+B_d[j*N+i]*C_d[i];
}
}
int main(){
int i,j;
float A[... |
1,216 | #include<stdio.h>
#include<stdlib.h>
#include<cuda.h>
// #include <opencv2/opencv.hpp>
#include<fstream>
// #include <TooN/TooN.h>
// #include <TooN/se3.h>
// #include <TooN/GR_SVD.h>
// using namespace cv;
using namespace std;
__device__ int get_pos(){
return threadIdx.x + blockIdx.x * blockDim.x;
}
struct ... |
1,217 |
void ocean() {
int m = 1 << 7;
int n = 1 << 7;
} |
1,218 | #include <stdio.h>
#include <cuda.h>
//size of array
#define N 4096
//vector addition kernel
__global__ void vectorAddKernel(int *a, int *b, int *c)
{
int tdx = blockIdx.x * blockDim.x + threadIdx.x;
if(tdx < N)
{
c[tdx] = a[tdx]+b[tdx];
}
}
int main()
{
//grid and block sizes
dim... |
1,219 | #include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <cuda.h>
#define n 2
void fillMatrix(double *w, int li, int lj){
double count = 0;
for(int i=0; i<li; i++){
for(int j=0; j<lj; j++){
w[i*lj+j] = count;
count++;
}
}
}
void print(double *w, int li, int lj){
for(int i=0; i<li... |
1,220 | #include<stdio.h>
#include<cuda_runtime.h>
#include <stdlib.h>
#define length 10
#define length_thread 256
#define test(a){\
for(int i =0;i<length;i++){\
printf("a[%d] = %d \n",i,a[i] );\
}\
}
#define pr_array(a,start,end){\
for(int i=start;i<=end;i++){\
printf("a[%d] = %d\n",i,a[i]);\
}\
}
//return b_end w... |
1,221 | /*
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
__global__ void addMultipleBlocks(float *d_a,float *d_b,float *d_c,int m,int n)
{
int i=blockIdx.x*blockDim.x+ threadIdx.x;
if(i<(m*n))
d_c[i]=d_a[i]+d_b[i];
}
__global__ void addSingl... |
1,222 | #include <iostream>
#include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <thrust/reduce.h>
using namespace std;
int main(int argc, const char *argv[]) {
string N;
if (argc > 1) {
N = string(argv[1]);
}
unsigned int n = atoi(N.c_str());
thrust::host_vector<int> H(n);
for (unsigned ... |
1,223 | #include<cuda_runtime.h>
#include<device_launch_parameters.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
__global__ void q1(int* d_a,int* d_r,int *d_m)
{
int n = threadIdx.x;
for(int i = 0;i<(*d_m);i++)
{
d_r[n*(*d_m)+i] = d_a[n*(*d_m)+i];
for(int j = 0;j<n;j++)
d_r[n*(*d_m)+i] *= d_a[n*(*d_m)+i... |
1,224 | #include "includes.h"
__global__ void calculateDelaysAndPhases(double * gpuDelays, double lo, double sampletime, int fftsamples, int fftchannels, int samplegranularity, float * rotationPhaseInfo, int *sampleShifts, float* fractionalSampleDelays)
{
size_t ifft = threadIdx.x + blockIdx.x * blockDim.x;
size_t iant = block... |
1,225 |
/* 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,int var_3,int 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 var... |
1,226 | /**
* Copyright 1993-2012 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... |
1,227 | extern "C"
__device__ float vxd(const float m,float Vy, float w, float ZpTei, float Xr, float Kvx)
{
if (Vy > 0) {
return ((m * Vy * w - Xr + ZpTei) * Kvx);
} else {
return ((m * Vy * w * 1.09f - Xr + ZpTei) * Kvx);//Vx*1.061 ;N0=3;k11=580.91f Ubuntu
//return ((m * Vy * w ... |
1,228 |
__global__ void mapping(double *point_cloud,
const double *img1, const double *img2,
const double *img3, const double *img4,
const double *T,
const double *P1, const double *P2, const double *P3, const double *P4,
const double *ratiox, const double *ratioy, const double *ratioz,
const int *img_width, const int *im... |
1,229 | #include "includes.h"
using namespace std;
// parameter describing the size of matrix A
const int rows = 4096;
const int cols = 4096;
const int BLOCK_SIZE = 16;
// transpose shared kernel
// transpose kernel
__global__ void transpose_naive(float* a, float*b) {
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y ... |
1,230 | #include <stdio.h>
template <typename T>
struct SinFunctor
{
__host__ __device__
T operator()(const T& x) const {
return sinf(x);
}
};
template <typename T>
struct CosFunctor
{
__host__ __device__
T operator()(const T& x) const {
return cosf(x);
}
};
struct OrderFunctor
{
... |
1,231 | #include <float.h>
#include <math.h>
#include <stdio.h>
__global__ void calculateAreas(const int recs, const double w, const int offset, double *areas) {
const int index = threadIdx.x + offset;
if (index >= recs) return;
const double x = index * w;
double h = 1 - x * x;
//Detect a 0 by accounting for roundof... |
1,232 | __global__ void subtract_and_square(float *dest, float *a, float *b, int n)
{
// const int index = threadIdx.x * (threadIdx.y + 1);
// dest[index] = ( a[index] - b[index] ) * ( a[index] - b[index] );
int index = blockDim.x * blockIdx.x + threadIdx.x;
if (index < n)
dest[index] = ( a[index] - b[i... |
1,233 | #include <cuda.h>
template<typename T>
__device__ __forceinline__ T ldg(const T* ptr) {
#if __CUDA_ARCH__ >= 350
return __ldg(ptr);
#else
return *ptr;
#endif
}
extern "C"
__global__
void transpose_constY(
int nx
, int ny
, int nz
, float * in
, float * out // XYZ -> ZYX
)
{
int kx = blockIdx.x*blockDim.x + th... |
1,234 |
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <sys/time.h>
#define NPB_VERSION "3.3.1"
using namespace std;
#define min(x,y) (x) <= (y) ? (x) : (y)
#define max(x,y) (x) >= (y) ? (x) : (y)
// block sizes for CUDA kernels
#define NORM... |
1,235 | #include "includes.h"
__global__ void bcnn_grad_scales_kernel(float *x_norm, float *delta, int batch, int n, int size, float *scale_updates) {
__shared__ float part[BCNN_CUDA_THREADS];
int i, b;
int filter = blockIdx.x;
int p = threadIdx.x;
float sum = 0;
for (b = 0; b < batch; ++b) {
for (i = 0; i < size; i += BCNN_CU... |
1,236 | #define ulong unsigned long long
#define uint unsigned int
#define MOD_P0 469762049LL
#define MOD_P1 1811939329LL
#define MOD_P2 2013265921LL
//Ř݂ɑfP^̂ŁAꂼ̗]肩猳̒l
//̂ƂP͑SČŒȂ̂ŏ]vZ͑Sߑłł
//E0`E2́AE3ɏo
//Jオl
//arrayLength2=arrayE3̔zTCY
__global__ void GarnerGPU(uint *arrayE0,uint *arrayE1,uint *arrayE2,uint *arrayE3,... |
1,237 | #include <stdio.h>
#include <cuda.h>
#include <stdlib.h>
#define N 17 // size of arrays
__global__ void transpose (int *a, int *b) {
int col = blockIdx.x*blockDim.x+threadIdx.x;
int row =blockIdx.y*blockDim.y+threadIdx.y;
int index1 = col + row * N;
... |
1,238 | #include "includes.h"
__global__ void Product (float *a, float *b, float *c)
{
// Out of all the threads created each one computes 1 value of C and stores into cval
float cval = 0.00;
int R = blockIdx.y * blockDim.y + threadIdx.y; //Row of the matrix
int C = blockIdx.x * blockDim.x + threadIdx.x; //Column of the matri... |
1,239 | #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.... |
1,240 | // filename: ax.cu
// a simple CUDA kernel to add two vectors
extern "C" // ensure function name to be exactly "ax"
{
__global__ void ax(const int lengthC, const double a, const double *b, double *c)
{
int i = threadIdx.x + blockIdx.x * blockDim.x;
if (i<lengthC)
{
c[i] = a*b[i]; // REMEMB... |
1,241 | #include "includes.h"
__global__ void dot_cmp_kernaldm(const float* data1, const float* data2, const float* dm, float* device_soln, const int size, const int num_threads, const int offset)
{
float dot = 0.0f;
float nnn = 0.0f;
int idx = threadIdx.x + blockIdx.x*num_threads + offset;
for(int i = 0; i < size; i++){
int... |
1,242 | /******************************************************************************
*cr
*cr (C) Copyright 2010 The Board of Trustees of the
*cr University of Illinois
*cr All Rights Reserved
*cr
*****************************************************************... |
1,243 | #include <cuda.h>
#include <stdio.h>
__global__ void K(int *p) {
*p = 0;
printf("%d\n", *p);
}
int main() {
int *x, *y;
cudaMalloc(&x, sizeof(int));
K<<<2, 10>>>(x);
cudaDeviceSynchronize();
y = x;
cudaFree(y);
K<<<2, 10>>>(x);
cudaDeviceSynchronize();
//cudaError_t err = cudaGetLastError();
//printf("e... |
1,244 | #include "includes.h"
char* concat(char *s1, char *s2);
__global__ void r_final_sum_and_alpha_calculation(float * r_squared ,float * p_sum ,int size)
{
int index = threadIdx.x ;
__shared__ float shared_r_squared[1024] ;
__shared__ float shared_p_sum[1024] ;
if (index < size)
{
shared_r_squared[index] = r_square... |
1,245 | #include "rgb_pixels_factory.cuh"
int RgbPixelsFactory::random(int max)
{
return rand() % max;
}
unsigned char RgbPixelsFactory::randomChar()
{
return random(256);
}
Pixel * RgbPixelsFactory::generate(int count, int maxX, int maxY)
{
Pixel* pixels = new Pixel[count];
for (int i = 0; i < count; i++)
{
pixels[i... |
1,246 | //
// CrossCorrelation.cu
// CrossCorrelation
//
// Created by Vivek Sridhar on 29/06/17.
// Copyright © 2017 Vivek Sridhar. All rights reserved.
//
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
template ... |
1,247 | #include "includes.h"
/**
* @brief cudaCreateBuffer Allocates a cuda buffer and stops the programm on error.
* @param size
* @return
*/
__global__ void kernelSetDoubleBuffer(float* gpuBuffPtr, float v, size_t size)
{
int index = threadIdx.x + blockIdx.x * blockDim.x;
if (index < size)
gpuBuffPtr[index] = v;
} |
1,248 | #include "includes.h"
__global__ void MatrixCopy_naive (const float * A , int Acount, int Acols, float * out0 , int out0count)
{
int id = blockDim.x*blockIdx.y*gridDim.x + blockDim.x*blockIdx.x + threadIdx.x;
if (id<out0count)
{
out0[id] = A[id];
}
} |
1,249 | // 3D convolution by CUDA
__global__ void cu_conv(const float *A,const float *K,const float *B, int kw, int kh, int kn, int cw_rem, int ch_rem, float *C){
// A : input data, K : Kernel, B : bias
int cx = threadIdx.x + blockIdx.x*blockDim.x;
int cy = threadIdx.y + blockIdx.y*blockDim.y;
int cz = blockI... |
1,250 | #include <iostream>
using namespace std;
int main(void)
{
cout << "Hello nvcc!" << endl;
return 0;
}
|
1,251 | __global__ void print_values(const int* ints, const double* dbls,
int* result)
{
int i = threadIdx.x;
result[i] = ints[i] + (dbls[i] > 0.0);
}
|
1,252 | #include <stdio.h>
#include <cuda_runtime_api.h>
#include <cuda.h>
#include <cstdlib>
#include <ctime>
#include <iostream>
__global__ void matmul(float* matA, float* matB, float* matC, int width){
float pVal = 0;
for(int i=0; i<width; ++i){
float elementMatA = matA[threadIdx.y*width+i];
float element... |
1,253 | #include <stdio.h>
#include <stdlib.h>
#define NUM_BLOCKS 32
#define BLOCK_WIDTH 1
__global__ void hello()
{
printf("Hello world! I'm thread %d in block %d\n", threadIdx.x, blockIdx.x);
}
int main(int argc,char **argv)
{
int num_blocks = NUM_BLOCKS, block_width = BLOCK_WIDTH;
if(argc>1){
num_blo... |
1,254 | #include "includes.h"
__global__ void add( double *a, double *b, double *c, int n )
{
int tid = threadIdx.x + blockIdx.x * blockDim.x;
// handle the data at this index
while (tid < n) {
c[tid] = a[tid] + b[tid];
tid += blockDim.x * gridDim.x;
}
//printf("Value of *ip variable: %f\n", a[tid] );
} |
1,255 | #include <stdio.h>
#define BLOCK_SIZE 256
#define NUM_ELEMENTS (4096*100)
// CUDA API error checking macro
#define cudaCheck(error) \
if (error != cudaSuccess) { \
printf("Fatal error: %s at %s:%d\n", \
cudaGetErrorString(error), \
__FILE__, __LINE__); \
exit(1); \
}
__global__ void reverse_1d(int ... |
1,256 | /* File: vec_add.cu
* Purpose: Implement vector addition on a gpu using cuda
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <chrono>
using namespace std;
using namespace std::chrono;
/* Kernel for vector addition */
__global__ void Vec_add(float x[], float y[], float z... |
1,257 | #include <iostream>
#include <cstdio>
using namespace std;
#include <cuda_runtime.h>
#define TIMES 24
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////HELP FUNCTIONS//////////////////////////////////////... |
1,258 | #include "includes.h"
__global__ void stencil_1d(int *in, int *out) {
// within a block, threads share data via shared memory ("global memory")
// data is not visible to threads in other blocks
// use __shared__ to declare a var/array in shared memory
__shared__ int temp[BLOCK_SIZE + 2 * RADIUS];
// each thread proces... |
1,259 | #include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <limits>
#include <sys/time.h>
#define ARRAY_SIZE 10000
#define BLOCK_SIZE 256
#define MICROSECONDS(start, end) ((end.tv_sec - start.tv_sec) * 1000000LL + end.tv_usec - start.tv_usec)
#define MILLISECONDS(start, end) MICROSECONDS(start, end) / 1000.... |
1,260 | int main()
{
const unsigned int N = 1048576;
const unsigned int bytes = N * sizeof(int);
int *h_a = (int*)malloc(bytes);
int *d_a;
cudaMalloc((int**)&d_a, bytes);
memset(h_a, 0, bytes);
cudaMemcpy(d_a, h_a, bytes, cudaMemcpyHostToDevice);
cudaMemcpy(h_a, d_a, bytes, cudaMemcpyDeviceToHo... |
1,261 | #include "Logger.cuh"
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <time.h>
#define PREFIX_SIZE 256
// Do not change order. It matches the values of LOGGER_LEVEL_XXXXX
static char* level_name_by_level[] = { "ERROR", "WARN", "INFO", "DEBUG" };
static void logger_print(const... |
1,262 | #include <stdlib.h>
#include <stdio.h>
#include <time.h>
//#include "cutil.h"
void checkCUDAError(const char *msg)
{
cudaError_t err = cudaGetLastError();
if (cudaSuccess != err)
{
printf("Cuda error: %s: %s.\n", msg, cudaGetErrorString(err));
printf("\nPress ENTER to exit...\n");
g... |
1,263 | #include <stdio.h>
#include <cuda_runtime.h>
void printMatrix(int *C, const int nx, const int ny){
int *ic = C;
printf("\n Matrix:(%d, %d)\n",nx,ny);
for(int i =0; i < ny; i++){
for(int j =0; j < nx; j++){
printf("%3d",ic[j + i*nx]);
}
printf("\n");
}
printf("\n... |
1,264 | #include <cuda.h>
/* Size of a block */
#define BLOCK_X 32
#define BLOCK_Y 16
__global__ void kernadd (float* mout, float* min1, float *min2, int nx, int ny, size_t pitch)
{
int i, j, index;
/* UP TO YOU edit line below so that the index is correctly evaluated */
i = blockDim.x * blockIdx.x +threadIdx.x;
j =... |
1,265 | //2 layered neural network with LIF neurons
//computing Vm in parallel, Computing Isyn
//all-all connectivity between 2 layers
//starting point of reading mnist set by 'start'
#include<stdio.h>
#include<math.h>
#include<time.h>
#include<stdlib.h>
#include "device_launch_parameters.h"
#include "cuda_runtime_api.h"
#... |
1,266 | #include <string.h>
#include <stdio.h>
#include <iostream>
struct DataElement
{
char *name;
int value;
};
__global__
void Kernel(DataElement *elem) {
printf("On device: name=%s, value=%d\n", elem->name, elem->value);
elem->name[0] = 'd';
elem->value++;
}
void launch(DataElement *elem, cudaStream_t &stream... |
1,267 | #include "includes.h"
__global__ void ElementwiseNorm(float * A, float *B, int size) {
int id = blockDim.x*blockIdx.y*gridDim.x + blockDim.x*blockIdx.x + threadIdx.x;
if (id < size)
A[id] /= B[id];
} |
1,268 | #include<stdio.h>
#include<stdlib.h>
#define TPB 8
#define W 4
#define H 4
#define TX 1
#define TY 1
int N=H*W;
__device__ float distance(float x1, float x2){
return sqrt ((x2-x1)*(x2-x1));
}
__global__ void distanceKernel(float *d_out, float *d_in, float ref, int w){
const int c=blockIdx.x*blockDim.x+threadIdx.x... |
1,269 | #include <thrust/device_vector.h>
#include <thrust/host_vector.h>
float* readData(char* filename)
{
FILE* handle = fopen(filename, "r");
if(handle == NULL)
{
printf("Error opening file: %s\n", filename);
exit(0);
}
int num, i;
fscanf(handle, "%d", &num);
float data[num];
for(i=0;... |
1,270 | // This example demonstrate how use the printf() function inside a kernel.
// In order to do that the code must be generate to architetures with compute capability greater than 2.0
// Compile:
// nvcc -gencode=arch=compute_30,code=sm_30 -g -o helloGPU helloGPU.cu
#include <stdio.h>
__global__ void helloCUDA(float f... |
1,271 | /* ==================================================================
Programmers:
Kevin Wagner
Elijah Malaby
John Casey
Omptimizing SDH histograms for input larger then global memory
==================================================================
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h... |
1,272 | #include "friction_update.cuh"
__global__ void friction_update
(
SimulationParameters sim_params,
SolverParameters solver_params,
real dt,
AssembledSolution d_assem_sol
)
{
int x = blockIdx.x * blockDim.x + threadIdx.x;
if (x < sim_params.cells + 2)
{
if (d_assem_sol.h_BC[x] > solver_p... |
1,273 | #include "includes.h"
__global__ void CalcAngMom(double *AngMomx_d, double *AngMomy_d, double *AngMomz_d, double *GlobalAMx_d, double *GlobalAMy_d, double *GlobalAMz_d, double *Mh_d, double *Rho_d, double A, double Omega, double *Altitude_d, double *Altitudeh_d, double *lonlat_d, double *areasT, double *func_r_d, int... |
1,274 | #include "includes.h"
__global__ void box_encode_kernel(float * targets_dx, float * targets_dy, float * targets_dw, float * targets_dh, float4 * boxes, float4 * anchors, float wx, float wy, float ww, float wh, size_t gt, size_t idxJump) {
int idx = blockIdx.x*blockDim.x + threadIdx.x;
size_t row_offset;
float anchors_... |
1,275 | #include <iostream>
#include <math.h>
#include <cuda.h>
#include <stdio.h>
// function to add the elements of two arrays
#define checkCudaErrors(val) check( (val), #val, __FILE__, __LINE__)
template<typename T>
void check(T err, const char* const func, const char* const file, const int line) {
if (err != cudaSuccess... |
1,276 | #include "cuda.h"
#define N 1000
__device__ float A[N][N];
__device__ float B[N][N];
__device__ float C[N][N];
__global__ void vectorAdd(float A[N][N], float B[N][N], float C[N][N])
{
int i = threadIdx.x;
int j = threadIdx.y;
C[i][j] = A[i][j] + B[i][j];
}
int main()
{
int bpg = 1;
d... |
1,277 | #include <stdio.h>
#include <stdlib.h>
#define CSC(call) \
do { \
cudaError_t res = call; \
if (res != cudaSuccess) { \
fprintf(stderr, "ERROR: file:%s line:%d message:%s\n", \
__FILE__, __LINE__, cudaGetErrorString(res)); \
exit(0); \
} \
}... |
1,278 | #include "includes.h"
__global__ void packcoo_kernel(int num_entries, int* row_indices, int* column_indices, int* aggridx, int* partidx, int* partlabel)
{
int entryidx = blockIdx.x * blockDim.x + threadIdx.x;
if(entryidx < num_entries)
{
int row = row_indices[entryidx];
int col = column_indices[entryidx];
int l = partl... |
1,279 | #include "includes.h"
__global__ void glcm_calculation_nol(int *A,int *glcm, const int nx, const int ny,int maxx)
{
int ix = threadIdx.x + blockIdx.x * blockDim.x;
int iy = threadIdx.y + blockIdx.y * blockDim.y;
unsigned int idx = iy * nx + ix;
//unsigned int idr = iy * (maxx+1) + ix;
int k,l;
int p;
//Calculate GLCM
... |
1,280 | #include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include "pinnedmem.cuh"
cudaError
mallocHost(void** h_mem ,uint memSize, memoryMode memMode, bool wc)
{
if( PINNED == memMode ) {
#if CUDART_VERSION >= 2020
return cudaHostAlloc( h_mem, memSize, (wc) ? cudaHostAllocWriteCombined : 0 );
#else
... |
1,281 | #include <cuda_runtime_api.h>
#include <device_launch_parameters.h>
#include <stdio.h>
#include <time.h>
// CUDA kernel. Each thread takes care of one element of c
__global__ void vecAdd(float *a, float *b, float *c, int n)
{
// Get our global thread ID
int id = blockIdx.x*blockDim.x+threadIdx.x;
// Ma... |
1,282 | // headers
#include <stdio.h>
#include <cuda.h> // for CUDA
// global variables
int inputLength=5;
float *hostInput1=NULL;
float *hostInput2=NULL;
float *hostOutput=NULL;
float *deviceInput1=NULL;
float *deviceInput2=NULL;
float *deviceOutput=NULL;
// global kernel function definition
__global__ void vecAdd(float ... |
1,283 | #include <stdio.h>
#include <cuda.h>
__global__ void alloutputs(int *counter) {
int oldc = atomicAdd(counter, 1);
if (*counter == 34) printf("%d\n", oldc);
}
int main() {
int *counter, hcounter = 0;
cudaMalloc(&counter, sizeof(int));
cudaMemcpy(counter, &hcounter, sizeof(int), cudaMemcpyHostToDevi... |
1,284 | #include <stdio.h>
__global__ void kicache_test4_2 (unsigned int *ts, unsigned int* out, int p1, int p2, int its);
__global__ void kicache_test4_4 (unsigned int *ts, unsigned int* out, int p1, int p2, int its);
__global__ void kicache_test4_6 (unsigned int *ts, unsigned int* out, int p1, int p2, int its);
__global__ ... |
1,285 | #include "includes.h"
__device__ size_t GIDX(size_t row, size_t col, int H, int W) {
return row * W + col;
}
__global__ void kernel_blur(float* d_I, float* d_Ib, int H, int W) {
size_t row = threadIdx.y + blockDim.y * blockIdx.y;
size_t col = threadIdx.x + blockDim.x * blockIdx.x;
size_t idx = GIDX(row, col, H, W);
i... |
1,286 | /**
* @file markFilterEdge.cu
* @date Spring 2020, revised Spring 2021
* @author Hugo De Moraes
*/
#include <stdio.h>
#include <stdlib.h>
__global__ void markFilterEdges_gpu(int * src, int * dst, int * matches, int * keepEdges, int numEdges) {
// Get Thread ID
const int NUM_THREADS = blockDim.x * gridDim.x;
con... |
1,287 | extern "C"
{
__global__ void DmeanSquareLoss(const int lengthx, const double pref, const double *gradc, const double *x,const double *y, double *gradn )
{
int i = threadIdx.x + blockIdx.x * blockDim.x;
if (i<lengthx)
{
gradn[i] += pref * gradc[0] * (x[i]-y[i]);
}
}
} |
1,288 | #include "includes.h"
__global__ void chol_kernel_cudaUFMG_division(float * U, int elem_per_thr) {
// Get a thread identifier
int tx = blockIdx.x * blockDim.x + threadIdx.x;
int ty = blockIdx.y * blockDim.y + threadIdx.y;
int tn = ty * blockDim.x * gridDim.x + tx;
//#define DEBUGDIV
#ifdef DEBUGDIV
int dbg = 0;
if... |
1,289 | //Based on the work of Andrew Krepps
#include <stdio.h>
#include <stdlib.h> //srand and rand
#include <math.h>
// add function d
__global__ void add(int *a, int *b, int *c, int n)
{
// Get our global thread ID
int id = blockIdx.x*blockDim.x+threadIdx.x;
// Make sure we do not go out of bounds
if (id <... |
1,290 | // filename: gaxpy2.cu
// a simple CUDA kernel to add two vectors
extern "C" // ensure function name to be exactly "gaxpy2"
{
__global__ void gaxpy4(const int n, const double *a, const double *b, double *c)
{
int i = threadIdx.x + blockIdx.x*blockDim.x;
if (i < n) {
c[i] = (double) i; // REMEMBER ... |
1,291 | #include<cstdio>
#define S 64
#define ZERO 0
#define PI 3.14159265
#define LOW 9
#define HIGH 18
#define QUEUE_SIZE 128
#define KERNEL_RADIUS 8
extern "C" {
__device__
bool btwn(int a, int x, int y){
return (a>=x && a<y);
}
__device__
void load_to_shared(int* src, int cache[][S], int th_x, int th_y, int n, int m){
... |
1,292 | #include <cstdio>
#include <functional>
#include <iostream>
#include <random>
#define BLOCKSIZE 256
void FillMatrix(float* matrix, int height, int width) {
std::mt19937 gen(time(0));
std::uniform_real_distribution<float> distribution(-1.0f, 1.0f);
auto generate = std::bind(distribution, gen);
for (in... |
1,293 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <cuda_runtime.h>
static const int N = 10;
#define CHECK_STATUS(status) \
if (status != cudaSuccess) \
fprintf(stderr, "File: %s\nLine:%d Function:%s>>>%s\n", __FILE__, __LINE__, __FUNCTION__,\
cudaGetErrorString(status))
//
__glob... |
1,294 | #include "includes.h"
__global__ void Ecalc2(float* out, const float* label)
{
int i = threadIdx.x; //4
//int j = blockDim.y*blockIdx.y + threadIdx.y; //Data.count
out[i] = label[i] - out[i];
} |
1,295 | #include "stdio.h"
#include <cuda.h>
#include <cuda_runtime.h>
#include <iostream>
// Defining number of elements in Array
#define N 50000
__global__ void gpuAdd(int *d_a, int *d_b, int *d_c) {
int tid = threadIdx.x + blockIdx.x * blockDim.x;
while (tid < N) {
d_c[tid] = d_a[tid] + d_b[tid];
tid += blockD... |
1,296 | #include <stdio.h>
__global__ void kadd(float *a, float *b, float *c, const unsigned int el_per_thread)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
unsigned int offset = i * el_per_thread;
for(unsigned int idx = 0; idx < el_per_thread; idx++) {
c[offset+idx] = a[offset+idx] + b[offset+idx];
}
}
|
1,297 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#define N 1000000
#define B 1024
__global__ void prescan( float *g_idata, float *INCR, int n);
void scanCPU(float *f_out, float *f_in, int i_n);
double myDiffTime(struct timeval &start, struct timeval &end)
{
double d_start, d_end;
d_start... |
1,298 | #include "includes.h"
using namespace std;
// this amazingly nice error checking function is stolen from:
//https://stackoverflow.com/questions/14038589/what-is-the-canonical-way-to-check-for-errors-using-the-cuda-runtime-api
__global__ void MatrixMulKernel(double *OutMat, double *Mat1, double *Mat2, int Arows, int ... |
1,299 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include <cuda.h>
//void Algorithm1();
void Algorithm4(int m, int n, int l);
//for gemm 4 algorithm
#define BLOCK_SIZE_x 16
#define BLOCK_SIZE_y 4
template<int block_size_x, int block_size_y>
__global__ void device_Matrix_multi(const dou... |
1,300 | #include <iostream>
#include <sys/time.h>
__global__ void saxpyDevice(int n, float a, float *x, float *y){
int i = blockIdx.x*blockDim.x + threadIdx.x;
if (i < n) y[i] = a*x[i] + y[i];
}
void saxpy(int n, float a, float *x, float *y){
float *d_x, *d_y;
// allocate GPU memory, and upload data
cuda... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.