serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
6,401 | #include <stdio.h>
#include <cuda_runtime.h>
#include <assert.h>
#include <math.h>
struct Matrix {
float* addr;
int height;
int width;
};
#define TILE_WIDTH 32
#define BLOCK_WIDTH 32
#define CHECK(call) { \
const cudaError_t error = call; \
if (error != cudaSuccess) { ... |
6,402 | #include<iostream>
#include<cstdio>
using namespace std;
__global__ void maxi(int *a,int *b,int n)
{
int block=256*blockIdx.x;
int max=0;
for(int i=block;i<min(256+block,n);i++)
{
if(max<a[i])
{
max=a[i];
}
}
b[blockIdx.x]=max;
}
int main()
{
cout<<"Enter the size of array: ";
int n;
cin>>n;
in... |
6,403 | //headers
#include <stdio.h>
#include <cuda.h>
#define imin(a, b) ((a < b) ? a : b)
#define sum_squares(x) (x * (x + 1) * (2 * x + 1) / 6)
//global variables
float *hostA = NULL;
float *hostB = NULL;
float *partial_hostC = NULL;
float *deviceA = NULL;
float *deviceB = NULL;
float *partial_deviceC = NULL;
co... |
6,404 | #include <thrust/sort.h>
#include <thrust/device_ptr.h>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <iostream>
#include <cuda_runtime.h>
#include <algorithm>
using namespace std;
int main(void)
{
uint64_t number_of_elements = 1024L*1024*1024;
uint64_t *h_key_array;
... |
6,405 | #include "includes.h"
__global__ void idwt_per_Y_1(float *d_dst, float *src_A, float *src_D, int rows, int cols, int next_rows, int filt_len, int halo) {
extern __shared__ float s_Data[];
//Offset to the upper halo edge
const int baseX = blockIdx.x * I_Y_BLOCKDIM_X + threadIdx.x;
const int baseY = ((blockIdx.y * I_Y_... |
6,406 | #include "Sha2.cu"
#include "Sha2.cuh"
#define SHA256_DIGESTSIZE 32
#define SHA256_BLOCKSIZE 64
#define SALT_SIZE 16
__constant__ int ITERATIONS = 100000;
__constant__ unsigned char SHA256_IPAD_CONST = (unsigned char) 0x36;
__constant__ unsigned char SHA256_OPAD_CONST = (unsigned char) 0x5C;
__constant__ __device__ u... |
6,407 | #include <stdio.h>
#include <assert.h>
#include <cuda.h>
#include <sys/time.h>
#define CUDA_CHECK(cmd) {cudaError_t error = cmd; if(error!=cudaSuccess){printf("<%s>:%i ",__FILE__,__LINE__); printf("[CUDA] Error: %s\n", cudaGetErrorString(error));}}
const int blocksize=16;
const int N=256;
// only works for squared b... |
6,408 |
/* 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,int var_2,int var_3,int var_4,int var_5,int 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_14,f... |
6,409 | #include "includes.h"
__global__ void Copy_A_to_B (float * A , float * B , int size){
int id = blockDim.x*blockIdx.y*gridDim.x + blockDim.x*blockIdx.x + threadIdx.x;
if (id<size)
B[id] = A[id];
} |
6,410 | #include <cuda.h>
#include <cuda_runtime.h>
#include <curand.h>
#include <curand_kernel.h>
#include <iostream>
#include <thrust/scan.h>
#define NUM_BANKS 16
#define LOG_NUM_BANKS 4
#define CONFLICT_FREE_OFFSET(n) \ ((n) >> NUM_BANKS + (n) >> (2 * LOG_NUM_BANKS))
typedef unsigned long long int size_int;
using na... |
6,411 | // file: memoryCheck.cu
__global__ void badMemoryReference(int *A) {
A[threadIdx.x] = 0; // line 3 - faulting store
}
int main() {
/*
int *invalidPtr = 0x0234; // pointer arbitrarily chosen,
// not allocated via cudaMalloc()
*/
int *invalidPtr = reinterpret_cast<int *>(0x0234);
in... |
6,412 | /*MIT License
Copyright (c) 2019 Xavier Martinez
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish,... |
6,413 | #include "includes.h"
__global__ void DrawRgbBackgroundKernel(float *target, int inputWidth, int inputHeight, float r, float g, float b)
{
int column = threadIdx.x + blockDim.x * blockIdx.z;
if (column >= inputWidth)
return;
int id = inputWidth * ( blockIdx.y * gridDim.x + blockIdx.x) // blockIdx.x == row, blockIdx.y ... |
6,414 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
__global__ void testCollatz(long n, long blockSize, long* counterEx) {
long lowRange = ceil(n * 1.0 / blockSize) * blockIdx.x;
long highRange = ceil(n * 1.0 / blockSize) * (blockIdx.x + 1);
long i;
for (i = lowRange; i < highRange && i <= n; i++) {
long ... |
6,415 | #include "includes.h"
__global__ void TestpermuteWalkers ( const int dim, const int nwl, const int *kr, const float *xxC, float *xxCP ) {
int i = threadIdx.x + blockDim.x * blockIdx.x;
int j = threadIdx.y + blockDim.y * blockIdx.y;
int t = i + j * dim;
if ( i < dim && j < nwl ) {
xxCP[t] = xxC[t];
}
} |
6,416 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <cuda_runtime.h>
__global__ void vecAdd( 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];
}
int main(void)
{
srand(time(0));
int N = 1024*1024;
size_t sz = ... |
6,417 | /*------------------------------------------------------------------------------
Copyright © 2015 by Nicola Bombieri
H-BF is provided under the terms of The MIT License (MIT):
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Softwar... |
6,418 | #include "includes.h"
__global__ void Matrix_getRow_FloatId_naive(const float * A , int Acount, int Acols, float * out0 , int out0count, int out0cols, const float row_id)
{
int id = blockDim.x*blockIdx.y*gridDim.x + blockDim.x*blockIdx.x + threadIdx.x;
if (id<Acols)
{
out0[id] = A[id+(int)row_id*Acols];
}
} |
6,419 | #include "includes.h"
__global__ void sum_2( float4 *localbuf, float4 *ptrd, int offset_0, int offset_1, int N ) {
int idx= blockDim.x * blockIdx.x + threadIdx.x;
if( idx < N ) {
float4 t1 = ptrd[ offset_0 + idx ];
float4 t2 = ptrd[ offset_1 + idx ];
t1.x += t2.x;
t1.y += t2.y;
t1.z += t2.z;
t1.w += t2.w;
localbuf[... |
6,420 | #ifndef _SHERMANMORRISON_KERNEL_
#define _SHERMANMORRISON_KERNEL_
#endif |
6,421 | extern "C" {
__device__ inline int threadIdx_x() { return threadIdx.x; }
__device__ inline int threadIdx_y() { return threadIdx.y; }
__device__ inline int threadIdx_z() { return threadIdx.z; }
__device__ inline int blockIdx_x() { return blockIdx.x; }
__device__ inline int blockIdx_y() { return blockIdx.y; }
__device__ ... |
6,422 | #include "mode.hh"
#include <cstdlib>
#include <cstring>
#include "../cpu/kernels.hh"
namespace
{
ProgramMode compute_mode()
{
auto mode = getenv("RT_MODE");
if (mode == nullptr)
return ProgramMode::MONOTHREAD;
else if (!strcmp(mode, "CPU"))
return ProgramMode::M... |
6,423 | #include "includes.h"
using namespace std;
__global__ void addition(int *a, int *b, int *c)
{
*c = *a + *b;
} |
6,424 | #include <chrono>
#include <iostream>
//Kernel definition
template<typename T>
__global__
void copyKernel (T* out,
T* in,
const unsigned int N)
{
const unsigned int id = threadIdx.x + blockIdx.x * blockDim.x;
for (unsigned int i= id; i < N; i = i + blockDim.x * gridDim.x)
{
const unsigned el_id = i;
((T*)... |
6,425 | //#include <iostream>
//#include <assert.h>
//
//#include "Device.h"
//#include "RayTracing.h"
//#include "Sphere.h"
//#include "cudaTools.h"
//
//#include <limits>
//
//using std::cout;
//using std::endl;
//
///* ========== DECLARATION ========== */
//
//extern __global__ void rayTracing(uchar4* ptrDevPixels, uint w, ... |
6,426 | #include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include <algorithm>
#include <chrono>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <cuda.h>
#include <unistd.h>
//#define _DEBUG_
//#define _TIME_MEASURE_
#ifdef _DEBUG_
#include <string>
#include <sstream>... |
6,427 | #include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <chrono>
#include <fstream>
#include <iostream>
#include <random>
#include <sstream>
#include <stdexcept>
#include <vector>
#include <chrono>
#include <time.h>
double gpu_time_used;
#define I(row, col, ncols) (row * ncols + col)
#d... |
6,428 | #include <stdio.h>
#include <curand_kernel.h>
extern "C"
__device__ int get_max(int x,int y){
if(x>y)
return x;
return y;
}
extern "C"
__device__ int get_min(int x,int y){
if(x<y)
return x;
return y;
}
extern "C"
__global__ void multiply_them(float *dest, float *a, float ... |
6,429 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <algorithm>
#include <curand.h>
#define MAXTHREADS 512u
#define checkCudaErrors(ans) { gpuAssert((ans), __FILE__, __LINE__); }
using namespace std;
inline void gpuAssert(cudaError_t code, const char *file, int line, bool abor... |
6,430 | #include "pgm.cuh"
#include <cstdio>
#include <cstdlib>
#include <cctype>
/*
Source for some of the parsing code:
http://ugurkoltuk.wordpress.com/2010/03/04/an-extreme-simple-pgm-io-api/
*/
void skipFileComments(FILE *fp);
float* loadPGM(const char *filename, int *width, int *height) {
printf("Loading im... |
6,431 | #include "includes.h"
__global__ void scan(int *v, const int n)
{
int tIdx = threadIdx.x;
int step = 1;
while (step < n) {
int indiceDroite = tIdx;
int indiceGauche = indiceDroite + step;
if (indiceGauche < n) {
v[indiceDroite] = v[indiceDroite] + v[indiceGauche];
}
step = step * 2;
__syncthreads();
}
} |
6,432 | #include <cufft.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cuda_runtime.h>
#include <cuda.h>
#define NUM 1024//4096//256//1024//256//844800
#define NUM2 39//1213//4000000//250000//1212
#define batch 375//206//1//825//16//3300//1
int main(int argc,char *argv[])
{
FILE *fp;
FILE *file;
... |
6,433 | #include "includes.h"
# define MAX(a, b) ((a) > (b) ? (a) : (b))
# define GAUSSIAN_KERNEL_SIZE 3
# define SOBEL_KERNEL_SIZE 5
# define TILE_WIDTH 32
# define SMEM_SIZE 128
__global__ void computeSum(float *d_filteredImage, float *d_imageSumGrid, unsigned int n)
{
__shared__ float smem[SMEM_SIZE];
unsigned int tid = t... |
6,434 | #include "includes.h"
// create an image buffer. return host ptr, pass out device pointer through pointer to pointer
__global__ void resultant(unsigned char *a, unsigned char *b, unsigned char *c)
{
int idx = (blockIdx.x * blockDim.x) + threadIdx.x;
float opposite_side = float(a[idx]);
float adjacent_side = float(... |
6,435 | #include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <fstream>
#include <bitset>
#include <cuda_runtime.h>
#include <stdio.h>
#define DIM 128
#include "csv.hpp"
#include "timer.h"
using namespace std;
extern __shared__ int dsmem[];
int recursiveRed... |
6,436 | #define NUM_ELEMENTS 512
// CUDA kernel to perform the reduction in parallel on the GPU
//! @param g_idata input data in global memory
// result is expected in index 0 of g_idata
//! @param n input number of elements to scan from input data
__global__ void reduction(float *g_data, int n)
{
... |
6,437 | #include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <stdio.h>
#include <iostream>
// Define kernel function.
__global__ void gpuAdd(int *device_a, int *device_b, int *device_c)
{
*device_c = *device_a + *device_b;
}
int main(int argc, char **argv)
{
// Define host variables and device pointer... |
6,438 | #include <stdio.h>
#include <sys/time.h>
//////////////////////////////////////////////////////
// Simple vector addition in CUDA
//////////////////////////////////////////////////////
#define N 1024*1024 //Number of elements in the vector
// Definition of the kernel that will be executed by all threads on the GPU
_... |
6,439 | #include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <iostream>
#include <vector>
template<typename T>
thrust::device_vector<T> concatInSingleVector(std::vector<thrust::device_vector<T>> const& vectors)
{
// calculate final size
size_t size = 0;
for (auto const& vec : vectors)
{
... |
6,440 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
__global__ void prt_details_wrp()
{
int gid=blockIdx.y*gridDim.x*blockDim.x+blockIdx.x*blockDim.x+threadIdx.x;
int warpid=threadIdx.x/32;
int flatbid = blockIdx.y*gridDim.x+blockIdx.x;
printf("gid :... |
6,441 | #include "includes.h"
__device__ inline unsigned int RM_Index(unsigned int row, unsigned int col, unsigned int width) {
return (row * width + col);
}
__global__ void BernoulliNBLearnKernel(float *feature_probs, float *class_count_, const float *d_row_sums, unsigned int n_samples_, unsigned int n_classes_, unsigned int ... |
6,442 | /*
Authors
- Dibyadarshan Hota 16CO154
- Omkar Prabhu 16CO233
*/
#include <iostream>
#include <string>
#include <sstream>
#include <cuda.h>
#include<stdio.h>
#include <ctime>
#include <iomanip>
#include <thrust/device_vector.h>
#include <thrust/extrema.h>
#include <thrust/device_free.h>
#define ll long long
using na... |
6,443 | #include "includes.h"
__global__ void matrixMultiply(float *A, float *B, float *C, int numARows, int numAColumns, int numBRows, int numBColumns, int numCRows, int numCColumns) {
//@@ Insert code to implement matrix multiplication here
// Calculate the row index
int numRows = blockIdx.y*blockDim.y+threadIdx.y;
// Calcul... |
6,444 | /*
**********************************************
* CS314 Principles of Programming Languages *
* Spring 2020 *
**********************************************
*/
#include <stdio.h>
#include <stdlib.h>
__global__ void strongestNeighborScan_gpu(int * src, int * oldDst, int * newDst, ... |
6,445 | #include<stdio.h>
#include<time.h>
#include<time.h>
#include<stdlib.h>
#include<math.h>
__global__ void func1(int *c,int *a,int *b, int n)
{
int i = blockIdx.x*blockDim.x + threadIdx.x;
// printf("i = %d\n", i);
if(i < n)
{
a[i] = 2;
b[i] = 3;
}
}
__global__ void func2(int *c,int *a,int *b, int n)
{
int i = bloc... |
6,446 | #include "includes.h"
__global__ void process_coarseness_ek_pix(double * output_ak, double *output_ekh, double *output_ekv,int colsize, int rowsize,long lenOf_ek)
{
int y = threadIdx.x + blockIdx.x * blockDim.x;
int x = threadIdx.y + blockIdx.y * blockDim.y;
double input1,input2;
int posx1 = x+lenOf_ek;
int posx2 = x-... |
6,447 | #include "includes.h"
__global__ void STREAM_Add(float *a, float *b, float *c, size_t len)
{
size_t idx = threadIdx.x + blockIdx.x * blockDim.x;
while (idx < len) {
c[idx] = a[idx]+b[idx];
idx += blockDim.x * gridDim.x;
}
} |
6,448 | #include "includes.h"
__global__ void reduction(float *g_data, int n)
{
__shared__ float partialSum[NUM_ELEMENTS];
unsigned int t = threadIdx.x;
partialSum[t] = g_data[t];
for (int i = blockDim.x/2; i > 0; i>>=1)
{
__syncthreads();
if(t<i)
{
partialSum[t] += partialSum[t + i];
}
}
if(t==0)
{
g_data[0] = partialSum[0];... |
6,449 | #include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "cdist.cuh"
__global__ void sqdistKernel(float* x, float* y, int dim, float* z) {
int ix = blockIdx.x * blockDim.x + threadIdx.x;
if (ix < dim * dim) {
int x_ix = ix / dim;
int y_ix = ix - x_ix * dim;
float diff = x[x_ix] - y[y_ix];
... |
6,450 | #include <chrono>
#include <iostream>
#include <stdlib.h>
#include <unistd.h>
static int SLEEP_TIME = 50000;
static int GENERATION_STEP = 1;
__global__ void singleBlockLifeKernel(uint32_t *cols, int numGenerations) {
__shared__ uint8_t grid[1024]; // TODO Should this be uint32_t?
int colIdx = threadIdx.x;
// ... |
6,451 | #include <stdio.h>
#include <stdlib.h>
// these are just for timing measurments
#include <time.h>
// Computes minimum in a 3D volume, at each output point
// To compile it with nvcc execute: nvcc -O2 -o grid3d grid3d.cu
//define the window size (cubic volume) and the data set size
#define WSIZE 6
#define DATAXSIZE 100
... |
6,452 | ////
//// Created by Chen on 11/8/2020.
////
#include <cufft.h>
#include <cstdio>
#include "common.cuh"
#define PI 3.14159265358979324f
__global__
void waveSliceTransmitKernel(cufftComplex *wave, cufftReal const *slice, unsigned nPix,
float waveLength, float relativityGamma,
... |
6,453 | #include "definitions.cuh"
//Performs CFD calculation on global memory. This code does not use any advance optimization technique on GPU
// But still acheives many fold performance gain
__global__ void calculateCFD_V1( float* input, float* output, unsigned int Ni, unsigned int Nj,
float h)
{
unsigned int... |
6,454 | #include <cuda_runtime.h>
#include <cstdio>
#include <iostream>
/**
* @property 图像饱和度降低
* @func 将图像转换为几种HSL图像
* @param_out out_image 转换后的图像
* @param_in in_image 待转换图像
* @param_in pixel_amount 像素点个数
* @param_in type 亮度类型
* @par... |
6,455 | /******************************************************************************
LICENSE
Copyright (c) 2015 Codeplay Software Ltd.
Copyright (c) 2006-2008 Kevin Beason (kevin.beason@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation fil... |
6,456 | #include <stdio.h>
#include <ctime>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <dirent.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <vector>
#include <iostream>
#include <fstream>
#include <climits>
using namespace std;
bool scan_dir(const char* dir, vector<stri... |
6,457 | #include <stdio.h>
#define MAX_BUF 100000000
typedef unsigned int UINT;
UINT buffer[MAX_BUF];
// 核函数统一使用该命名,参数列表可自定义
__global__ void kernel()
{
}
UINT ReadFile(const char *szFile, UINT data[])
{
UINT len;
FILE *fp;
fp = fopen(szFile, "rb");
fread(&len, sizeof(UINT), 1, fp);
if (len > MAX_BUF)
{
fclose(fp);... |
6,458 | #include <cmath>
__global__ void myexp(float* value)
{
value[threadIdx.x] = std::exp(value[threadIdx.x]);
}
|
6,459 | #include "includes.h"
__device__ void get_conflict_col_id(bool *dl_matrix, short *deleted_cols, int *conflict_col_id, int *conflict_edge, int total_dl_matrix_col_num, int vertex_num) {
// if(threadIdx.x==0){
// printf("conflict edge a %d edge b
// %d\n",conflict_edge[0],conflict_edge[1]);
// }
bool *edge_a_dlmatrix =... |
6,460 | __global__ void matching(int *keypoints ,const unsigned char *in, int *allProbablities, int *allIndexList, int *matchingResult , int width, int height, int lenght, int fernNum, int fernSize, int patchLenght){
int index = blockIdx.x * blockDim.x + threadIdx.x;
int patchSize =(int)(patchLenght /2);
int x ... |
6,461 | #include "includes.h"
// Jim Samson
// CSF441 Computer Architecture
// Assignment 4
// Most code is written by Dr. Mock
// This HW Assignment uses cuda and the Sobel filter to convert an image.
/***********************************************************************
* sobel-cpu.cu
*
* Implements a Sobel filter on the ... |
6,462 | #include <stdio.h>
int main(int argc, char **argv) {
int nDevices;
cudaDeviceProp prop;
cudaGetDeviceProperties(&prop, 0);
printf("Device name: %s\n", prop.name);
printf("Capabilities: %d.%d\n", prop.major, prop.minor);
printf("Global mem: %lu\n", prop.totalGlobalMem / 1024 / 1024 / 1024);
... |
6,463 | #include "includes.h"
__device__ void softmax_device(int n, float *input, float temp, float *output)
{
int i;
float sum = 0;
float largest = -INFINITY;
for (i = 0; i < n; ++i) {
int val = input[i];
largest = (val>largest) ? val : largest;
}
for (i = 0; i < n; ++i) {
float e = expf(input[i] / temp - largest / temp);
sum... |
6,464 | /*
CUDA kernels and functions
Kurt Kaminski 2016
*/
#ifndef __FLUID_KERNELS__
#define __FLUID_KERNELS__
#include <cuda_runtime.h>
//__device__ const int BLOCK_SIZE = 8;
//__device__ const int GRID_SIZE = 64;
__device__ int
clamp(int i)
{
if (i < 0) i = 0;
if (i > 255) i = 255;
return i;
}
__device__ float
cl... |
6,465 | #include <iostream>
#include <stdexcept>
#include <stdint.h>
#include <cuda_runtime.h>
#include <cuda_fp16.h>
// Not very optimized, but it's just for the test/example
__global__ void half2float_kernel(half* input, size_t input_pitch,
uint16_t width, uint16_t height,
... |
6,466 | #include "includes.h"
__global__ void softmax_gradient_kernel( const int dim, const float* Y, const float* dY, float* dX) {
Y += blockIdx.x * dim;
dY += blockIdx.x * dim;
dX += blockIdx.x * dim;
const int idx = threadIdx.x;
__shared__ float reduction_buffer[SOFTMAX_NUM_THREADS];
float tmp;
// A two-level reduction to ... |
6,467 | #include "includes.h"
__global__ void kCumsum(float *mat, float *target, float *temp, unsigned int height) {
// extern __shared__ float temp[];// allocated on invocation
const int thid = threadIdx.x;
if (2*thid < height) {
const int super_offset = blockIdx.x * height;
target += super_offset;
mat += super_offset;
temp... |
6,468 | #include <stdio.h>
#include <stdlib.h>
__global__ void hello_kernel(void)
{
//int i = threadIdx.x;
int i = blockIdx.x * blockDim.x + threadIdx.x;
int b = blockIdx.x;
printf("Hello from block : %d, threadId : %d\n", b, i);
}
int main()
{
hello_kernel<<< 4, 16>>>();
//printf from device are not automatica... |
6,469 | __global__ void cost_value(double * * result,
double * * Il,
double * * Ir,
double Tc,
double Tg,
double Tb)
{
} |
6,470 | #include <stdio.h>
__global__
void hello_kernel() {
printf("hello world from cuda thread %d\n", int(threadIdx.x));
}
int main(void) {
hello_kernel<<<1, 32>>>();
//cudaDeviceSynchronize();
cudaError_t cudaerr = cudaDeviceSynchronize();
if (cudaerr != cudaSuccess)
printf("kernel launch faile... |
6,471 | //~ #include <half.hpp>
__device__ void Vec_add(float *x, float *y , float* z, float gaaa[], int n) {
/* blockDim.x = threads_per_block */
/* First block gets first threads_per_block components. */
/* Second block gets next threads_per_block components, etc. */
int i = blockD... |
6,472 | /*
example to show how to use stream and async method to make the data
transfer and kernel function executed concurrently.
*/
#include <iostream>
using namespace std;
static void HandleError( cudaError_t err,const char *file, int line ) {
if (err != cudaSuccess) {
cout << cudaGetErrorString(err) << file <... |
6,473 | #include "includes.h"
__global__ void diffKernel( float *in, float *out, int n )
{
// Wrtie the kernel to implement the diff operation on an array
int id = (blockDim.x * blockIdx.x) + threadIdx.x;
if(id < n-1)
out[id] = in[id+1] - in[id];
} |
6,474 | #include <stdio.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
int main()
{
int device_count = 0;
cudaGetDeviceCount(&device_count);
printf("gpu count: %d\n", device_count);
cudaDeviceProp device_prop;
for (int i = 0; i < device_count; i++)
{
cudaGetDeviceProperties(&device_prop, i);
... |
6,475 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <cuda.h>
__global__ void getmaxcu(unsigned int num[], unsigned int size, unsigned int gap)
{
unsigned int i=gap, //loop variables
start = (threadIdx.x)*gap;
if(start%2!=0 || size<=... |
6,476 | #include "includes.h"
const int Nthreads = 1024, maxFR = 5000, NrankMax = 6;
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////... |
6,477 | # include <bits/stdc++.h>
# include <cuda.h>
#define TILE_WIDTH 32 //(TITLE_WIDTH = BLOCKSIZE)
using namespace std;
// ::::::::::::::::::::::::::::::::::::::::::GPU::::::::::::::::::::::::::::::::
__global__ void KernelNormalMul(float *Mat1,float *Mat2,float *Mat3,int m,int n,int p){
int j = threadIdx.y + blockDim... |
6,478 | #include <algorithm>
#include <iostream>
#include <cassert>
#include <cmath>
#include <chrono>
using namespace std;
#define TIMER_SET(t0) std::chrono::time_point<std::chrono::steady_clock> t0 = std::chrono::steady_clock::now()
#define TIMER_DIFF(t0, t1) std::chrono::duration_cast<std::chrono::microseconds> (t1 - t0).... |
6,479 | #include <cuda_runtime.h>
__global__ void computeForcesKernel(int N, const double3 *p, double3 *f) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx >= N)
return;
double3 ftot{0.0, 0.0, 0.0};
for (int i = 0; i < N; ++i) {
double dx = p[i].x - p[idx].x;
double dy = p[i]... |
6,480 | #include <stdio.h>
#include <iostream>
#include <math.h>
#include "cuda.h"
#include <time.h>
#define BLOCK_DIM 16
__global__ void computeDistance(float* A, int wA, int pA, float* B, int wB, int pB, int dim, float* AB) {
// Declaration of the shared memory arrays As and Bs used to store the sub-matrix of A and B... |
6,481 | /*
*
* test.c
* tim.burgess@noaa.gov
*
* A place for trying out various code
*/
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <cuda.h>
#define NPIXELS 100
static char daytab[2][13] = {
{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
{0, 31, 29, 31, 30, 31, 30, 31, 31, 30, ... |
6,482 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2021 Brian Hamilton //
// ... |
6,483 | #include <stdio.h>
#include <time.h>
#include <cuda.h>
// kernel
__global__ void antialiasingDevice(int *mat, int a, int b,int *res)
{
int sum = 0;
int neig = 0;
int j = blockIdx.x*blockDim.x + threadIdx.x;
int i = blockIdx.y*blockDim.y + threadIdx.y;
if((i < a) && (j < b)){
for (int dx = -1; dx ... |
6,484 | #include "includes.h"
__global__ void sub3(float *val1, float *val2, int *num_elem)
{
int i = threadIdx.x;
val1[i] += val2[i]+1;
} |
6,485 | #include "includes.h"
__global__ void binarySearch( const int limit, const int databaseSize, const long* databaseArray, const long* inputArray, int* outputArray) {
const int bIdx = gridDim.x * blockIdx.y + blockIdx.x;
const int tIdx = blockDim.x * bIdx + threadIdx.x;
if(tIdx < limit) {
const long input = inputArray[tI... |
6,486 | #include <stdio.h>
#include <cuda.h>
#include <cuda_runtime_api.h>
#define SIZE 1024
#define THREADS 1024
#define BLOCKS SIZE / THREADS
#define CHECK
double a[SIZE][SIZE];
double b[SIZE][SIZE];
double c[SIZE];
__global__ void sum_matrix_lines(double *matrix, double *vec) {
int y = (blockIdx.y * BLOCKS) + threa... |
6,487 | /*
* Do not change this file
*/
#include <iostream>
#include <fstream>
#include <cassert>
#include <cstring>
#include <string>
#include <chrono>
#include <cstdlib>
#include <ctime>
#define MAX_LENGTH 4096
/**
* Read file, save edges to array (x_x) and
* record the size of each type of edge array (x_x_count).
*/... |
6,488 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
__global__ void add(int *a, int *b,int *c)
{
*c = *a + *b;
}
int main()
{
int a, b, c; // host copies of a, b, c
int *d_a, *d_b, *d_c; // device copies of a, b, c
int size =sizeof(int);// Allocate space for device copies of... |
6,489 | #include <stdio.h>
#define Width 32
#define TILE_WIDTH 16
__global__ void MatrixMulKernel(float *Md, float *Nd, float *Pd, int ncols){
int row = blockIdx.y * blockDim.y + threadIdx.y;
int col = blockIdx.x * blockDim.x + threadIdx.x;
float PValue = 0; //PValue is used to store element of the output MatrixMulKerne... |
6,490 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <inttypes.h>
#include <cuda.h>
#include <cuda_runtime.h>
#define BLOCK_WIDTH 32
#define TAILLE 2048
#define gettime(t) clock_gettime(CLOCK_MONOTONIC_RAW, t)
#define get_sub_seconde(t) (1e-9*(double)t.tv_nsec)
/** return time in second
*/
double get_ela... |
6,491 | /*
**********************************************
* CS314 Principles of Programming Languages *
* Fall 2020 *
**********************************************
*/
#include <stdio.h>
#include <stdlib.h>
__global__ void check_handshaking_gpu(int * strongNeighbor, int * matches, int nu... |
6,492 | // includes
#include <stdio.h>
#include <stdlib.h>
//-------------Funcion llenar "velocidad"
void llenarVelocidad(float * pmat, int row, int colum){
FILE *fichero;
int node=row*colum;
int i,j;
int nvel=9;
float leer;
fichero = fopen("matriz_con_func_dist.txt","r");
if (fichero==NULL)
{
prin... |
6,493 | #include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "constants.cuh"
#include "mesh.cuh"
#include "matrix_functions.cuh"
#include "material.cuh"
#include "sys.cuh"
void compute_xphys(struct sparse *h ,double *hs, double*x, double *xphys, struct mesh *mesh) {
double *x_lin, *xphys_tmp;
x_lin = (do... |
6,494 | #include "includes.h"
__global__ void add( float *x, float *y, float *z, float *deltaX, float *deltaY, float *deltaZ ) {
int tid = blockIdx.x; // this thread handles the data at its thread id
if (tid < N)
x[tid] = x[tid] + deltaX[tid];
if (tid < N)
y[tid] = y[tid] + deltaY[tid];
if (tid<N)
z[tid] = z[tid] + deltaZ[t... |
6,495 | #include "includes.h"
extern "C" {
}
#define TB 256
#define EPS 1e-4
__device__ bool InverseMat4x4(double m_in[4][4], double inv_out[4][4]) {
double m[16], inv[16];
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
m[i * 4 + j] = m_in[i][j];
}
}
inv[0] = m[5] * m[10] * m[15] -
m[5] * m[11] * m[14] -
m[... |
6,496 | #include <math.h>
#include <float.h>
#include <cuda.h>
#define BLOCK_SIZE 256
__global__ void gpu_Reduce (float *s, int N, int skip) {
__shared__ float sdata[BLOCK_SIZE];
int i = (blockIdx.x * blockDim.x + threadIdx.x) * skip;
sdata[threadIdx.x] = i < N? s[i] : 0.0;
__syncthreads();
// Do reduction in shared mem... |
6,497 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <cuda.h>
unsigned int getmax(unsigned int *, unsigned int);
//my function to get the max number in the array using Nvdia parallel reduction techniques.
__global__ void getmaxcu(unsigned int* numbersDevice, unsigned int size, unsigned... |
6,498 | #include <cstdio>
#define N 64
#define TPB 16
__device__ float scale(int i, int n)
{
return ((float) i)/(n - 1);
}
__device__ float distance(float x1, float x2)
{
return sqrt( (x2 - x1)*(x2 - x1) );
}
__global__ void distanceKernel(float *d_out, float ref, int len)
{
const int i = blockIdx.x*blockDim.x +... |
6,499 | #include<stdio.h>
#include<cuda.h>
__global__ void kernel( void ) {
}
int main( void ) {
kernel<<<1,1>>>();
printf( "Hello, World!" );
return 0;
} |
6,500 | #include <cuda.h>
#include <cuda_runtime.h>
#include <fstream>
#include <iostream>
#include "cuda_kernel.cuh"
__global__ void raw2gray_kernal(int width, int height, unsigned char *gpu_bayer,
unsigned char *gpu_gray) {
int index_x = blockIdx.x * blockDim.x + threadIdx.x;
int index_y ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.