serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
5,301 | //
// Compile:
//
// $ nvcc list_gpus.cu -o list_gpus
//
//
#include <cuda.h>
#include <curand_kernel.h>
#include <stdio.h>
int main() {
int deviceCount;
cudaGetDeviceCount(&deviceCount);
int device;
for (device = 0; device < deviceCount; ++device) {
cudaDeviceProp deviceProp;
cudaGet... |
5,302 | #include "includes.h"
__global__ void addOneColumnPerThread(double* a, double* b, double* c, int n)
{
// Get the column for current thread
int column = (blockIdx.x * blockDim.x + threadIdx.x);
// Make sure we do not go out of bounds
if (column < n)
{
for (int i = 0; i < n; i++)
{
c[i * n + column] = a[i * n + column] ... |
5,303 | #include <cuda_runtime.h>
#include <stdio.h>
int main(int argc,char ** argv)
{
int nElem=1024;
dim3 block(1024);
dim3 grid((nElem-1)/block.x+1);
printf("grid.x %d block.x %d\n",grid.x,block.x);
block.x=512;
grid.x=(nElem-1)/block.x+1;
printf("grid.x %d block.x %d\n",grid.x,block.x);
block.x=256;
gri... |
5,304 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <sys/resource.h>
//134217728
double dwalltime(){
double sec;
struct timeval tv;
gettimeofday(&tv,NULL);
sec = tv.tv_sec + tv.tv_usec/1000000.0;
return sec;
}
__global__ void vecSum_kernel_cuda(double *d_vecA,double *d_result,unsigned long d... |
5,305 | #include "includes.h"
// %%cu
// as data type is int, sum might overflow (depending on rand(), but the seq and parallel answers are still equal, or change int to long long (too lazy sorry))
#define THREADS_PER_BLOCK 256
using namespace std;
__global__ void calculate(int *arr_in, int* arr_out, int sz, int option){
int ... |
5,306 | #include <stdio.h>
#include <cuda.h>
#include <sys/time.h>
#define N 2048
__global__ void findMax(int *a, int *b){
b[0] = 0;
if(a[threadIdx.x] > b[0]){
b[0] = a[threadIdx.x];
}
__syncthreads();
}
int findMaxCPU(int *a){
int max = 0;
for(int i = 0; i < N... |
5,307 | #include "includes.h"
using namespace std;
// https://stackoverflow.com/questions/26853363/dot-product-for-dummies-with-cuda-c
__global__ void init_vec(float* vec, float value) {
int tid = blockIdx.x * blockDim.x + threadIdx.x;
vec[tid] = value;
} |
5,308 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <stdbool.h>
int nValues[15]={100,150,200,250,350,500,650,800,900,1000,1200,1400,1600,1800,2000};
// here you can put any values you want for k
// warning do not change the length of the array
int kValues[5]={10,20,45,80,100};
__device... |
5,309 | #include <math.h>
#include <stdio.h>
#include <stdint.h>
__device__ __forceinline__
int getLinearIndex(int row, int col, int slice, int nRows, int nCols){
//image indexing is column major
return slice*nRows*nCols + col * nRows + row;
}
__device__ __forceinline__
double getTileAverage(int row, int col, int slice... |
5,310 | # pragma warning (disable:4819)
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
#define ARRAYSIZE 5
#define checkCudaErrors( a ) do { \
if (cudaSuccess != (a)) { \
fprintf(stderr, "Cuda runtime error in line %d of file %s \
: %s \n", __LINE__, __FIL... |
5,311 | #include "../image_headers/convolution.cuh"
#include <iostream>
#include <cstdlib>
__device__ float calcFx(const unsigned char* image, int i, int j, int width, int height) {
if (0 <= i && i < width && 0 <= j && j < height)
{
return image[j * width + i];
}
else if ((0 <= i && i < width) || (0 <=... |
5,312 |
__global__ void transform_kernel( float4* outpos, float4* inpos, unsigned int width, unsigned int height, float* mvp_matrix, float* vp_matrix)
{
// Indices into the VBO data. Roughly like texture coordinates from GLSL.
unsigned int tx = blockIdx.x*blockDim.x + threadIdx.x;
unsigned int ty = blockIdx.y*bloc... |
5,313 | #include "includes.h"
__global__ void kLogregCost(float* probs, float* labels, float* maxProbs, float* labelLogProbs, float* correctProbs, const int numCases, const int numOut) {
const int tx = blockIdx.x * LOGREG_ERR_THREADS_X + threadIdx.x;
if (tx < numCases) {
const int label = int(labels[tx]);
const float maxp = m... |
5,314 | __global__
void deviceKernel(int *a, int N)
{
int idx = threadIdx.x + blockIdx.x * blockDim.x;
int stride = blockDim.x * gridDim.x;
for (int i = idx; i < N; i += stride)
{
a[i] = 1;
}
}
void hostFunction(int *a, int N)
{
for (int i = 0; i < N; ++i)
{
a[i] = 1;
}
}
int main()
{
int N = 2<<24... |
5,315 | /*******************************************************************************
* serveral useful gpu functions will be defined in this file to facilitate
* the surface redistance scheme
******************************************************************************/
typedef struct
{
double sR;
double sL;
} doub... |
5,316 | typedef unsigned int uint;
//Warp based summation
__device__ int inexclusive_scan_warp(volatile int *ptr,bool inclusive, const unsigned int idx, int value) {
const unsigned int lane = idx & 31;
if (lane >= 1) ptr[idx] = value = ptr[idx - 1] + value;
if (lane >= 2) ptr[idx] = value = ptr[idx - 2] + va... |
5,317 | #include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
using namespace std;
// 随机初始化两个 m*n 大小的矩阵
void Generate(float **a, float **b, float **c, int m, int n) {
*a = new float[m*n], *b = new float [m*n], *c = new float [m*n];
for (int i = 0; i < m; ++i)
for (int j = 0; j < n; ++j) {
... |
5,318 |
/*
* 2020.05.20 뷮ó ǥ
* Chapter 7. Parallel Patterns : Convolution Example Code
* Created by ̻
*/
// ش κ ּ Ǯ Ͽ ֽñ ٶϴ.
// * 7.4 ڵ ǥ Ͽ ۵մϴ.
/// __syncthread() ϱ
/// ٸ intellisense
/// NVIDIA
//#include "cuda_runtime.h"
//#include "device_launch_parameters.h"
//
//// for syncthreads()
//#ifd... |
5,319 | #include "includes.h"
__global__ void even(int *darr, int n) {
int k = threadIdx.x;
int t;
k = k * 2;
if (k <= n - 2) {
if (darr[k] > darr[k + 1]) {
t = darr[k];
darr[k] = darr[k + 1];
darr[k + 1] = t;
}
}
} |
5,320 | #include <stdio.h>
#include <cuda.h>
#define INIT 1000
#define k 2
void random(int* x){
for(int i=0;i<INIT*k;i++){
x[i] = rand() % 10;
}
}
__global__ void kernel(int *a, int *b, int *c){
// //計算區塊索引
// int block=(blockIdx.z*gridDim.y+blockIdx.y)*gridDim.x+blockIdx.x;
// //計算執行緒索引
// int t=(threadIdx.z*blo... |
5,321 | /* test_kernel.cu
it does not contain anything for the moment
device AJOUTER +1 en parallèle à chaque élément du tableau
*/
//kernel !
__global__ void kernel_1(int* T_device)
{
T_device[0] += 1;
}
__global__ void inc_gpu(int* a, int n)
{
int id = blockIdx.x * blockDim.x + threadIdx.x;
if (id < n)
a[id]++... |
5,322 | #include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<bool> vb;
typedef vector<float> vd;
typedef pair<int,int> ii;
typedef pair<long, long> ll;
typedef unordered_set<int> ui;
const int MAX_BLOCK_SIZE = 1024;
const int MAX_NUM_FEATURES = 32;
const int MAX_CASE_... |
5,323 | #include <stdio.h>
// From Robert Crovella on StackOverflow.com
// https://stackoverflow.com/questions/33150040/doubling-buffering-in-cuda-so-the-cpu-can-operate-on-data-produced-by-a-persiste/33158954#33158954
// with format cleanup for readability preference
constexpr int num_iterations = 1000;
constexpr size_t nu... |
5,324 | /******************************************************************************
*cr
*cr (C) Copyright 2010 The Board of Trustees of the
*cr University of Illinois
*cr All Rights Reserved
*cr
*****************************************************************... |
5,325 | #include "global_defines.cuh"
void LBM::bounceback(){
/*Fluid densities are rotated. By the next propagation step, this *
* results in a bounce back from obstacle nodes.*/
/*
.......bounce back from obstacles: this is the no-slip boundary-
condition.
The velocity vector of all fluid densities is in... |
5,326 | #include <iostream>
#include <stdio.h>
#include <cuda.h>
#include <device_launch_parameters.h>
#define SIZE 5
#define BLOCK_DIM 5
__global__ void MatrixAddition(float* d_M, float* d_N, float* d_P)
{
int row = blockIdx.y * blockDim.y + threadIdx.y;
int col = blockIdx.x * blockDim.x + threadIdx.x;
int index... |
5,327 | /*
autor fredy m
uaem
desonses@gmail.com para mas comentarios
*/
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "cuda_fp16.h"
/*
En el siguiente ejemplo se muestran las diferencias y las similitudes que existen a
la hora de reservar ... |
5,328 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <cuda.h>
#include <curand.h>
#include <curand_kernel.h>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
#include <assert.h>
#include <ctype.h>
#include <sys/time.h>
//number of threads PER BLOCK
#define NTHREADS 1024
#... |
5,329 | #include <cstdio>
void add(const int x, const int y, const int WIDTH, int* c, const int* a, const int* b) {
int i = y * (WIDTH) + x; // [y][x] = y * WIDTH + x;
c[i] = a[i] + b[i];
}
// main program for the CPU: compiled by MS-VC++
int main(void) {
// host-side data
const int WIDTH = 5;
int a[WIDTH][WIDTH];
int ... |
5,330 | #include "includes.h"
static __device__ float E = 2.718281828;
__global__ void reduceArgMaxKernel(float *src, float *dst, float *arg, int dim_size, int block_size)
{
int di = blockIdx.x * block_size + threadIdx.x;
int si = di * dim_size;
float now = src[si], max = now;
int maxi = 0;
for (int i = 1; i < dim_size; i... |
5,331 | template <int N>
__device__ int get_value(){
return N;
}
__global__ void foo_device(int * n){
int i = threadIdx.x;
n[i] = get_value<7>()*i;
//n[i] = 7*i;
}
template <typename T>
__global__ void bar_device(T * n){
T i = threadIdx.x;
//n[i] = get_value<7>()*i;
n[i] = 7*i;
}
template <typename T>
__global__ vo... |
5,332 | #include <stdio.h>
#include <malloc.h>
#include <cuda.h>
#define M 20
__global__ void add(int *A, int *B, int *C) {
int i = threadIdx.x;
C[i] = A[i] + B[i];
}
int main() {
int i, *A, *B, *C;
A = (int *) malloc(M * sizeof(int));
B = (int *) malloc(M * sizeof(int));
C = (int *) malloc(M * sizeof(int));
for (i = ... |
5,333 | #include "includes.h"
__global__ void vecProduct(int *d_x, int *d_y, int *d_z, int N) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < N) {
d_z[idx] = d_x[idx] * d_y[idx];
}
} |
5,334 | #include "GpuRetina.cuh"
#include <cstdio>
template<int BLOCK_SIZE>
__global__ void calculateRetina2d(
const TrackProjection* tracks,
int tracksNum,
const double* hitsX,
const double* hitsZ,
int hitsNum,
double sharpness,
double *values
)
{
int trackId = blockIdx.x;
unsigned int tid = threadIdx.x;
... |
5,335 | // Shim functions for calling cuRAND from Numba functions.
//
// Numba's ABI expects that:
//
// - The return value is used to indicate whether a Python exception occurred
// during function execution. This does not happen in C/C++ kernels, so we
// always return 0.
// - The result returned to Numba is passed as a ... |
5,336 | #include "includes.h"
__global__ void test(float *a, float *b, float *c, int N)
{
if(blockIdx.x<N)
c[blockIdx.x] = a[blockIdx.x]*b[blockIdx.x];
return;
} |
5,337 | ///////////////////////////////////////////////////////////////////////////////
// *Time: 5e-5 seconds
///////////////////////////////////////////////////////////////////////////////
//
/*
__global__
void pass1gpu(
scalar_t* pointValues, // input
int nx, int ny, int nz, // input
scalar_t isoval, //... |
5,338 | #include <stdio.h>
#include "ChessBoard.cuh"
/**
* Makes the chess board and assigns values for each piece
* Returns: a matrix of pieces
*/
Piece** makeChessBoard(){
Piece** board = (Piece**)(calloc(DIM, sizeof(Piece*)));
for(int row=0; row<DIM; row++){
board[row]=(Piece*)(calloc(DIM, sizeof(Piece)));... |
5,339 | #include <cuda.h>
#include <stdio.h>
int main()
{
cudaDeviceProp prop;
int count;
cudaGetDeviceCount(&count);
for(int i=0;i<count;++i)
{
cudaGetDeviceProperties(&prop,i);
printf( "--- General Information for device %d ---\n", i );
printf( "Name:%s\n", prop.name );
printf( "Compute capability:%d.%d\n", p... |
5,340 | // tests we can at least declare them and stuff
#include "cuda.h"
#include <iostream>
int returnerror() {
return CUDA_ERROR_INVALID_IMAGE;
}
int main(int argc, char *argv[]) {
CUdevice device;
std::cout << returnerror() << std::endl;
std::cout << CUDA_ERROR_INVALID_IMAGE << std::endl;
std::cout ... |
5,341 | /* *
* 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 relat... |
5,342 | #include "includes.h"
__global__ void dropout_train(float* data, float* outputPtr, int size, float probability)
{
int thread_index = threadIdx.x + blockIdx.x * blockDim.x;
int num_threads = blockDim.x * gridDim.x;
for(int i = 0; i < size; i += num_threads)
{
int index = i + thread_index;
if(index < size)
{
if(outputPt... |
5,343 | #include "includes.h"
__global__ void matrixAddPitch (int *a, int *b, int*c, int pitch) {
int idx = threadIdx.x + blockIdx.x * blockDim.x;
int idy = threadIdx.y + blockIdx.y * blockDim.y;
if (idx > pitch || idy > HEIGHT) return;
c[idy * pitch + idx] = a[idy * pitch + idx] + b[idy * pitch + idx];
} |
5,344 | #include "includes.h"
//================= Device matching functions =====================//
template <int size>
__device__ void InvertMatrix(float elem[size][size], float res[size][size])
{
int indx[size];
float b[size];
float vv[size];
for (int i=0;i<size;i++)
indx[i] = 0;
int imax = 0;
float d = 1.0;
for (int i... |
5,345 |
#include <stdio.h>
#include <stdlib.h>
__global__
void kernel1(int* d_data) {
const int tid = blockDim.x*blockIdx.x + threadIdx.x;
d_data[tid] += 1;
}
__global__
void kernel2(int* d_data, const int numElement) {
const int tid = blockDim.x*blockIdx.x + threadIdx.x;
const int nthread = blockDim.x*gridDim.x;
cons... |
5,346 | #include<stdio.h>
__global__ void replicate(int *__restrict__ in, int *__restrict__ out, size_t n, size_t rep) {
int tid = threadIdx.x + blockDim.x * blockIdx.x;
int gsize = blockDim.x * gridDim.x;
for (size_t i = tid; i < n; i += gsize) {
for (size_t j = 0; j < rep; j++) {
out[i + j*n] = in[i];
}
... |
5,347 | #include "includes.h"
__global__ void cudaGetError(int N, double *ana, double *cur, double *e_sum){
// Parallelly compute the error
int index = blockIdx.x*blockDim.x + threadIdx.x;
if(index < (N+1)*(N+1)) (*e_sum) += (ana[index] - cur[index])*(ana[index] - cur[index]);
return;
} |
5,348 | #include "includes.h"
__global__ void reduce( float *a, int size, int c) {
int tid = blockIdx.x; //Handle the data at the index
int index=c,j=0;//size=b
for(j=index+1;j<size;j++) {
a[((tid+index+1)*size + j)] = (float)(a[((tid+index+1)*size + j)] - (float)a[((tid+index+1)*size+index)] * a[((index*size) + j)]);
}
} |
5,349 | /* CUDA Project: Solving a tridiagonal system on GPUs
a: lower diagonal
b: diagonal
c: upper diagonal
y: A*x
x: solution of the system, x = inv(A)*y
*/
#include <stdio.h>
# include <assert.h>
#define NTPB 8
__host__ void thomas(float *a, float *b, float *c, float *y, float *x, int n){
/// ----------------... |
5,350 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <math.h>
#define COMMENT "Histogram_GPU"
#define RGB_COMPONENT_COLOR 255
#define TILE_WIDTH 16
typedef struct {
unsigned char red, green, blue;
} PPMPixel;
typedef struct {
int x, y;
PPMPixel *data;
} PPMImage;
double rtclock()
{
struct tim... |
5,351 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <time.h>
#include <cuda_runtime.h>
double my_timer()
{
struct timeval time;
double _ret_val_0;
gettimeofday(( & time), 0);
_ret_val_0=(time.tv_sec+(time.tv_usec/1000000.0));
return _ret_val_0;
}
#define BLOCK_SIZE 16
void matrixMulCPU(int8_t *A, ... |
5,352 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#define NUM 5
#define RANGE 10
int main(void){
double START,END;
START = clock();
srand(time(NULL));
int data[NUM];
// generate number
for(int i=0;i<NUM;i++){
data[i] = i;
}
// shuffle
for(i... |
5,353 | #include<iostream>
int main(void) {
cudaDeviceProp prop;
int count;
cudaGetDeviceCount(&count);
for (int i = 0; i < count; i++) {
cudaGetDeviceProperties(&prop, i);
std::cout << "--- General Information for device" << i << "---" << std::endl;
std::cout << "Name:" << prop.na... |
5,354 | #include <stdio.h>
#include <stdlib.h>
//example:
//k = 32
//input = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 401
int recursion(int* inputs, int current_val, int curr_index, int* result) {
int difference = current_val - inp... |
5,355 | #include <stdio.h>
__global__ void checkId(){
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.z, gridDim.x, gridDim.y, gridDim.z
);
}
void cudaFuncti... |
5,356 | //#include "caffe/layers/cosine_loss_layer.hpp"
//
//namespace caffe {
//
// template<typename Dtype>
// __global__ void channels_gpu_l2_norm(const int n, const int channels, const Dtype* bottom,
// Dtype *norm_data) {
// CUDA_KERNEL_LOOP(index, n) {
// caffe_gpu_l2norm(channels, bottom + index * channels, norm_dat... |
5,357 | #include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <fstream>
#include <iostream>
#include <chrono>
#define CHECK_CUDA_ERR(cudaerr) \
{ \
auto err = cudaerr; \
if (err != cud... |
5,358 | #include "includes.h"
__global__ void copy_mem(unsigned char *source, unsigned char *render)
{
int x = blockIdx.x * TILE_DIM + threadIdx.x;
int y = blockIdx.y * TILE_DIM + threadIdx.y;
int width = gridDim.x * TILE_DIM;
for (int j = 0; j < TILE_DIM; j+= BLOCK_ROWS)
for (int channel = 0; channel < 3; channel ++ )
render... |
5,359 | #include <cstdio>
__device__ void cuda_device_function()
{
printf("This function is called from device only. a=%d, \n", blockIdx.x);
}
// I'm using this function to test array indices/outputs (total variable)
__global__ void cuda_global_function()
{
int total = ((blockIdx.x+1)*(blockIdx.y+1))*(threadIdx.x+1)*(thre... |
5,360 | #include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include <bitset>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include<iomanip>
#include<string.h>
#include<istream>
#include<limits.h>
#include<cuda_runtime.h>
using namespace std;
// Matrices are stored in row-major order:
// M(... |
5,361 | #include <stdio.h>
#define N (1024*1024)
#define M (1000000)
__global__ void cudakernel(float *buf)
{
int i = threadIdx.x + blockIdx.x * blockDim.x;
buf[i] = 1.0f * i / N;
for(int j = 0; j < M; j++)
buf[i] = buf[i] * buf[i] - 0.25f;
}
int main()
{
float data[N];
float *d_data;
cudaMal... |
5,362 | #define N (2048 * 2048)
#define THREADS_PER_BLOCK 512
__global__ void add(int *a, int *b, int *c) {
int index = threadIdx.x + blockIdx.x * blockDim.x;
c[index] = a[index] + b[index];
}
void random_ints(int *a, int n){
int i;
for(i = 0; i < n; i++){
a[i] = i;
}
}
int main(void) {
int *a, *b, *c;
int... |
5,363 | #include <iostream>
#include <cmath>
#include <iomanip>
#include <fstream>
#include <algorithm>
using namespace std;
#define PI 3.14159265359
#define grid(i,j,ny) i*(ny+1)+j
#define omega 1.5
#define RelativeError 1e-4
#define epsilon 1e-10
#define threadx 16
#define thready 16
//------------------------------------... |
5,364 | /***************************************************************************//**
* \file structure.cu
* \author Christopher Minar (minarc@oregonstate.edu)
*/
#include "structure.h"
namespace kernels
{
/*
* Updates all the velocities and positions of the body nodes
* param double y y positions of the nodes
* p... |
5,365 | /*
skeleton code for assignment3 COMP4901D
Hash Join
xjia@ust.hk 2015/04/15
*/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <memory>
#include <limits>
#include <algorithm>
#include <vector>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <thrust/... |
5,366 | #include "includes.h"
__global__ void multMatriz(float *da, float *db, float *dc, int num){
float sum=0;
int j = threadIdx.x + blockIdx.x * blockDim.x;
int i = threadIdx.y + blockIdx.y * blockDim.y;
while(j<num){
while(i<num){
for (unsigned int k = 0; k<num; k++)
sum += da[i * num + k] * db[k * num + j];
dc[i*num + j] ... |
5,367 | #include <cuda.h>
#include <stdio.h>
#include <math.h>
#include <sys/time.h>
const int PARTITION_SIZE = 32;
#define AT(mtx, width, row, column) \
mtx[(row) * (width) + (column)]
inline double nowSec()
{
struct timeval t;
struct timezone tzp;
gettimeofday(&t, &tzp);
return t.tv_sec + t.tv_usec*1e-6;
}
... |
5,368 | #include <stdio.h>
#include <stdlib.h>
__global__ void foo(int *ptr) { *ptr = 7; }
int main(void) {
foo<<<1, 1>>>(0);
// make the host block until the device is finished with foo
cudaThreadSynchronize();
// check for error
cudaError_t error = cudaGetLastError();
if (error != cudaSuccess) {
// print ... |
5,369 | //===============================================================================
// Name : MatrixRotate.cpp
// Author : Soumil Datta
// Version : 1.0
// Description : CUDA program to rotate an NxN matrix by 90 degrees to the right
//======================================================================... |
5,370 | /********************************************************************
render.c is responsible for rendering the bodies' positions and
velocities to an ppm image
********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "string.h"
#define WIDTH 1024
... |
5,371 | #include <stdio.h>
#include <iostream>
// Número de elementos em cada vetor
#define N 2048 * 2048
__global__ void my_kernel(int * a, int * b, int * c)
{
// Determina a identificação de thread global exclusiva, por isso sabemos qual elemento processar
int tid = blockIdx.x * blockDim.x + threadIdx.x;
... |
5,372 | #include<cuda.h>
#include<cstdlib>
#include<cstdio>
#ifndef KERNELS
#define KERNELS
#define OP_NON 0
#define OP_ADD 1
#define OP_SUB 2
#define OP_MUL 3
#define OP_DIV 4
#define FN_SIGM 1 //sigmoid
#define FN_RELU 2 //relu
#define FN_DSIGM 3 //diffrentiation of sigmoid
#define FN_DRELU 4 //diffrentiation of relu
__d... |
5,373 | #ifndef __CUDACC__
#define __CUDACC__
#endif
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <cuda.h>
#include <device_functions.h>
#include <cuda_runtime_api.h>
#include <curand.h>
#include <curand_kernel.h>
#include <stdio.h>
#include <iostream>
#include <iomanip>
#define N 16
#define BLOCK... |
5,374 | #include "includes.h"
__device__ float hard_mish_yashas(float x)
{
if (x > 0)
return x;
if (x > -2)
return x * x / 2 + x;
return 0;
}
__device__ float mish_yashas(float x)
{
float e = __expf(x);
if (x <= -18.0f)
return x * e;
float n = e * e + 2 * e;
if (x <= -5.0f)
return x * __fdividef(n, n + 2);
return x - 2 * __f... |
5,375 | //**********************************************************************
// *
// University Of North Carolina Charlotte *
// *
//Program: Vecotr adder ... |
5,376 | #include "includes.h"
__global__ void divide(float *x, float* y ,float* out ,const int size)
{
const int index = blockIdx.x * blockDim.x + threadIdx.x;
if (index < size)
{
out[index] = x[index]/y[index] ;
}
} |
5,377 | #include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/sort.h>
#include <thrust/generate.h>
#include <chrono>
using namespace std::chrono;
int num_actions = 8;
int ncells = 100*100;
int nrzns = 5000;
int arr_size = ncells * nrzns;
int n_print = 30;
int my_mod_start = 0;
float my_mod(){
... |
5,378 | #include <stdio.h>
#include <cuda_runtime.h>
__global__ void foo_device(int * n){
int i = threadIdx.x;
n[i] = 7*i;
}
int main(int argc, char const *argv[])
{
int * device;
cudaError_t error;
int host[4];
error = cudaMalloc( (void **) &device, sizeof(int)*4);
if (error != cudaSuccess)
... |
5,379 | #include <cuda_runtime.h>
#include <device_launch_parameters.h>
class cuStopwatch{
// todo: add your internal data structure, all in private
private:
cudaEvent_t start_event;
cudaEvent_t end_event;
bool is_watching;
public:
cuStopwatch();
~cuStopwatch();
voi... |
5,380 | #include <stdio.h>
#define N 256
__global__ void vecAdd(int *A) {
int i = threadIdx.x;
A[i]=A[i]+1;
}
int main (int argc, char *argv[]){
int i;
int size = N*sizeof(int);
int a[N],*devA;
for (i=0; i< N; i++){
a[i] = i;
}
cudaMalloc( (void**)&devA,size);
cudaMemcpy( devA, a, size, cudaMemcpyHostToDevice)... |
5,381 | #include "includes.h"
__global__ void euclideanDistance(const float *data_a, int nrow_a, const float *data_b, int nrow_b, int ncol, float *ans)
{
/*
int myblock = blockIdx.x + blockIdx.y * gridDim.x;
int blocksize = blockDim.x * blockDim.y * blockDim.z;
int subthread = threadIdx.z*(blockDim.x * blockDim.y) + threadIdx.... |
5,382 | #include "includes.h"
__global__ void decryptKernel(char* deviceDataIn, char* deviceDataOut, int n) {
unsigned index = blockIdx.x * blockDim.x + threadIdx.x;
if (index < n)
deviceDataOut[index] = deviceDataIn[index]-1;
} |
5,383 | #include "Benchmarks.cuh"
Benchmarks::Benchmarks()
{
min = -100.0;
max = +100.0;
n_threads = 1;
n_blocks = 1;
n_dim = 100;
}
Benchmarks::~Benchmarks()
{
/* empty */
}
float Benchmarks::getMin(){
return min;
}
float Benchmarks::getMax(){
return max;
}
uint Benchmarks::getID(){
return ID;
}
void B... |
5,384 | #include "includes.h"
__global__ void kDotProduct_r(float* a, float* b, float* target, const uint numElements) {
__shared__ float shmem[DP_BLOCKSIZE];
uint eidx = DP_BLOCKSIZE * blockIdx.x + threadIdx.x;
shmem[threadIdx.x] = 0;
if (eidx < gridDim.x * DP_BLOCKSIZE) {
for (; eidx < numElements; eidx += gridDim.x * DP_B... |
5,385 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cuda.h>
#include <cuda_runtime.h>
#define CHECK(call) { const cudaError_t error = call; if (error != cudaSuccess) { printf("Error: %s:%d, ", __FILE__, __LINE__); printf("code:%d, reason: %s\n", error, cudaGetErrorString(error)); exit(1); }}
__glob... |
5,386 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdlib.h>
#include <stdio.h>
#define CHECK(_t, _e) if (_e != cudaSuccess) { fprintf(stderr, "%s failed: %s", _t, cudaGetErrorString(_e)); goto Error;}
#define HERR(_t, _e) if (_e != cudaSuccess) { fprintf(stderr, "%s failed: %s", _t, cudaGetErro... |
5,387 | #define NUM_THREADS 32
__global__ void euclidean_kernel(const float * vg_a, size_t pitch_a, size_t n_a,
const float * vg_b, size_t pitch_b, size_t n_b,
size_t k,
float * d, size_t pitch_d,
float p)
{
size_t x = blockIdx.x;
size_t y = blockIdx.y;
// If an element is to be computed
if(x < n_... |
5,388 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <iostream>
#include <algorithm>
#include <chrono>
#include <vector>
using namespace std::chrono_literals;
// Kernel definition
__global__ void vectorSum( float const * v1, float const * v2, float * v3)
{
v3[threadIdx.x] = v1[threadIdx.x] +... |
5,389 | #include <stdio.h>
#include <iostream>
using namespace std;
__global__ void mykernel(void){}
__global__ void add(int *n, int *a, int *b, int *c){
c[blockIdx.x] = a[blockIdx.x] + b[blockIdx.x];
c[blockIdx.x+(n[0]/10)] = a[blockIdx.x+(n[0]/10)] + b[blockIdx.x+(n[0]/10)];
c[blockIdx.x+2*(n[0]/10)] = a[blockIdx.x+2*(... |
5,390 | #include "blur.cuh"
__global__ void blurMain(unsigned int w, unsigned int r, unsigned int * src, unsigned int * output) {
unsigned int offset = ((32 * blockIdx.x + threadIdx.x) * w) * 3;
unsigned int endIndex = offset + r * 3;
//first pixel of the row
for (unsigned int index = offset; index <= endIndex; index += ... |
5,391 | #include<stdio.h>
#include<cuda.h>
#include<cuda_runtime.h>
#define N 512
#define BLOCK_SIZE 16
__global__ void MatAdd(float *A, float *B, float *C){
int i =blockIdx.x * blockDim.x + threadIdx.x;
int j =blockIdx.y * blockDim.y + threadIdx.y;
if(i<N && j<N)
C[i*N+j]=A[i*N+j]+B[i*N+j];
}
int ... |
5,392 | #include<stdio.h>
#define BS 8
#define N 10
void print(int *A,int n){
for(int i=0; i<n; i++)
printf("%d ",A[i]);
printf("\n");
}
__global__ void add_array(int *A, int *B, int n){
int i = blockDim.x * blockIdx.x + threadIdx.x;
if(i < n) A[i] = A[i] + B[i];
}
int main(void){
int threadsPerB... |
5,393 | #include "includes.h"
__global__ void matMultCuda(float *cu_C, float *cu_A, float *cu_B, unsigned int n) {
int row = (blockIdx.x * blockDim.x) + threadIdx.x;
int col = (blockIdx.y * blockDim.y) + threadIdx.y;
//Log row and col of each thread
//printf("row : %d , col : %d \n", row, col);
if (row < n && col < n) {
int... |
5,394 | #include "includes.h"
__global__ void MHDComputedUy_CUDA3_kernel(float *FluxD, float *FluxS1, float *FluxS2, float *FluxS3, float *FluxTau, float *FluxBx, float *FluxBy, float *FluxBz, float *FluxPhi, float *dUD, float *dUS1, float *dUS2, float *dUS3, float *dUTau, float *dUBx, float *dUBy, float *dUBz, float *dUPhi, f... |
5,395 | //pass
//--blockDim=512 --gridDim=512
#include <cuda.h>
//////////////////////////////////////////////////////////////////////////////
//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
//// THE IMPLIED WARRANTIES OF MERCHANT... |
5,396 | #include <cstdint>
#include <thrust/device_vector.h>
#include <thrust/sort.h>
template <typename K, typename V> void SortByFreq(K *freq, V *qcode, int size) {
using namespace thrust;
sort_by_key(device_ptr<K>(freq), //
device_ptr<K>(freq + size), //
device_ptr<V>(qcode));
}
temp... |
5,397 | extern "C"{
__global__ void threshold(unsigned char * src,unsigned char * dst,int width,int height,int thresh){
//Grid中x方向上的索引
int xIndex = threadIdx.x + blockIdx.x * blockDim.x;
//Grid中y方向上的索引
int yIndex = threadIdx.y + blockIdx.y * blockDim.y;
int idx = xIndex +... |
5,398 | #include <iostream>
__global__ void fac() { printf("aa\n"); }
int main() { fac<<<1, 10>>>(); } |
5,399 | // allocate pitch memory and cudaArray
#include <stdio.h>
#include <memory.h>
#include <cuda.h>
#include <cuda_runtime.h>
#define NX 1003
#define NY 1003
int main(){
size_t sizeByte = NX*NY*sizeof(float);
//host data declaration and initialization
float* hdata = (float* )malloc(sizeByte);
for(int i... |
5,400 | #include <stdio.h>
#include <cuda.h>
int main(int argc, char** argv){
printf("Hello, world!");
return 0;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.