serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
22,001 | #include "includes.h"
extern "C" {
}
__global__ void cross_entropy_forward(unsigned int batch_size, unsigned int nclasses, const float* x, const float* t, float* y) {
int tid = blockIdx.x * blockDim.x + threadIdx.x;
if (tid < batch_size) {
// compute max value of slice
float m = x[tid*nclasses];
for(int i = 1; i < ncla... |
22,002 | #include <stdio.h>
#include <stdlib.h>
#define BLOCK_SIZE 16
__global__ void rules(int size, int *simulation, int *newsimulation)
{
// We want id ∈ [1,size]
int d_row = blockDim.y * blockIdx.y + threadIdx.y + 1;
int d_col = blockDim.x * blockIdx.x + threadIdx.x + 1;
int id = d_row * (size+2) + d_col;... |
22,003 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#define thread_size 128
#include <stdio.h>
#include <math.h>
const long N = 16 * 16;
__global__ void Vector_Addition( long *dev_a)
{
//Get the id of thread within a block
unsigned int tid = threadIdx.x + blockIdx.x*blockDim.x;
if (tid < N) // check... |
22,004 | /*
* Copyright (C) 2009 by Vitsios Dimitrios, Thomaidis Panagiotis
*
* 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
* ... |
22,005 | #include <iostream>
#include "matrix.cuh"
__global__ void add(Matrix * m1, Matrix * m2){
int index = threadIdx.x * m1->getCols() + blockIdx.x;
m1->add(index,m2->getVal(index));
}
void sync(){
cudaDeviceSynchronize();
cudaError_t error = cudaGetLastError();
if(error != cudaSuccess){
fprintf... |
22,006 | #include <iostream>
#include <stdio.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <math.h>
// This defines size of a small square box or thread dimensions in one block.
// 分块矩阵计算,每一个块中线程将计算这些分块矩阵的元素,
// 进行矩阵乘法的总块数等于原始矩阵的大小除以分块的大小计算得到。
#define TILE_SIZE 2
// Define size of the square matrix.
const int size =... |
22,007 | #include <vector>
#include <iostream>
#include <fstream>
__device__ void remove_index_from_array(char* arr, int index, int temp_length) {
for (int i = 0; i < temp_length - 1; i++) {
if (i >= index) {
arr[i] = arr[i+1];
}
}
}
__device__ void remove_index_from_shared_memory_array(char* arr, int index... |
22,008 | #include <stdlib.h>
#include <stdio.h>
__global__ void kernel(int *array){
int index = blockIdx.x*blockDim.x + threadIdx.x;
array[index] = index;
}
int main(){
int num_elements = 256;
int num_bytes = num_elements*sizeof(int);
int *device_array = 0;
int *host_array = 0;
host_array = (int *)malloc(num_bytes);
cuda... |
22,009 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
void load(const char* path, float** imageData, int* imgRows, int* imgCols, float** convKernelData, int* convKernelSize, float* convKernelCoeff)
{
FILE* ... |
22,010 | #include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
using namespace std;
#define CAFFE_CUDA_NUM_THREADS 196
inline int CAFFE_GET_BLOCKS(const int N) {
return (N + CAFFE_CUDA_NUM_THREADS - 1) / CAFFE_CUDA_NUM_THREADS;
}
template <typename Dtype>
__global__ void ConvForward(const int nthre... |
22,011 | // filename: vmult!.cu
// a simple CUDA kernel to element multiply two vectors C=alpha*A.*B
extern "C" // ensure function name to be exactly "vmult!"
{
__global__ void vmult(const int lengthA, const double alpha, const double *a, const double *b, double *c)
{
int i = threadIdx.x + blockIdx.x * blockDim... |
22,012 | #include "matrix.cuh"
__device__ float device_vector_get(matrix_t* v, unsigned int x)
{
//assert(v->rows == 1);
//assert(v->cols >= 0);
return v->matrix[x];
}
__device__ void device_vector_set(matrix_t* v, unsigned int x, float value)
{
//assert(v->rows == 1);
//assert(v->cols >= 0);
v->matrix[x] = value;
}
|
22,013 | #include<stdio.h>
#include<stdlib.h>
#include<cuda.h>
__global__ void add(int *a, int *b,int * c)
{
int col=10;
int i= blockIdx.y*blockDim.y+threadIdx.y;
int j=blockIdx.x*blockDim.x+threadIdx.x;
*(c + i * col +j)= *(a + i * col + j) + *(b + i * col + j);
}
int main()
{
int row = 10;
int col = 10;
... |
22,014 | #include <stdio.h>
#include <stdlib.h>
#define CUDA_CHECK_ERROR(X)({\
if((X) != cudaSuccess){\
fprintf(stderr, "CUDA error %d (%s:%d): %s\n", (X), __FILE__, __LINE__, cudaGetErrorString((cudaError_t)(X)));\
exit(1);\
}\
})
#define MALLOC_CHECK_ERROR(X)({\
if ((X) == 0){\
fprin... |
22,015 | #define N 3
#include <stdio.h>
__global__ void matrixMult (int *a, int *b, int *c, int width)
{
int i, sum = 0;
int col = threadIdx.x + blockDim.x * blockIdx.x;
int row = threadIdx.y + blockDim.y * blockIdx.y;
if(col < width && row < width)
for (i = 0; i< width; i++)
{
sum += a[row * width + i] * b[i * width + col];
}... |
22,016 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <math.h>
#include <cuda.h>
#define COMMENT "Histogram_GPU"
#define RGB_COMPONENT_COLOR 255
#define BLOCK_SIZE 1024
// STRUCTS
typedef struct {
unsigned char red, green, blue;
} PPMPixel;
typedef struct {
int x, y;
PPMPixel *data;
} PPMImage;
... |
22,017 | #include "includes.h"
__global__ void calculate_A_ch_1_2(float* rho, float* dz, float* s_a, float* xx_or_yy, float* s_b, float K, int npix, int nchannels, int nimages, float* A_ch) {
int i = blockIdx.x*blockDim.x + threadIdx.x;
int j = blockIdx.y*blockDim.y + threadIdx.y;
int c = blockIdx.z*blockDim.z + threadIdx.z;
if... |
22,018 |
// MyCudafy.CudafyMultiDimentionalArray
extern "C" __global__ void LaplaceSolver( double* prev, int prevLen0, double* next, int nextLen0, int* sizes, int sizesLen0, int* extV, int extVLen0, int* intV, int intVLen0, double* w, int wLen0);
// MyCudafy.CudafyMultiDimentionalArray
extern "C" __global__ void Copy( dou... |
22,019 | // From CUDA for Engineers
// Listing 6.1: parallel_dot/kernel.cu
#include <cuda_runtime.h>
#include <iostream>
#include <stdio.h>
#define TPB 64
#define ATOMIC 1 // 0 for non-atomic addition
#define N 1024
__global__
void dotKernel(int *d_res, const int *d_a, const int *d_b, int n)
{
int i = blockIdx.x * bl... |
22,020 | //
// Created by songzeceng on 2020/11/8.
//
#include <stdio.h>
struct __align__(8) {
int x;
int y;
} A;
struct __align__(16) {
int x;
int y;
int z;
} B;
int main() {
int deviceCount;
cudaGetDeviceCount(&deviceCount);
int device;
for (device = 0; device < deviceCount; ++device) {
... |
22,021 | #include<stdio.h>
#define N 200
__global__ void addvector(int* a,int* b,int* c)
{
int x=threadIdx.x;
if(x<N)
{
c[x]=a[x]+b[x];
}
}
int main()
{
int ch,arr[N],brr[N],result[N],*gpu1,*gpu2,*res;
printf("Enter A Number Between 1 and 200 ... |
22,022 | // 各ブロックが出力の各チャネルを操作する
// 各スレッドが出力の各ピクセルの値を決定する
template <int InSize, int InChannels, int InSize2,
int OutSize, int OutSize2,
int KernelSize, int KernelSize2>
__global__ void conv2D(float* inImg, float* outImg,
float* weight, float* bias)
{
/*
BlockDim.x == the ... |
22,023 | //
// Created by ameen on 30/04/20.
//
#include "Data.cuh"
Data::Data(std::string tableName) {
joinObject = false;
this->tableName = tableName;
this->writeHappened = false;
mdata = Metadata(tableName);
chunkSize = ((500 * 1024 * 1024) / (mdata.rowSize)); // read 500 MB
readCount = 0;
f.... |
22,024 | //pass
//--blockDim=64 --gridDim=64 --no-inline
#include "cuda.h"
__global__ void foo() {
float x = 2.0f;
float y = 2.0f;
if(x < y) {
}
}
|
22,025 | #include "includes.h"
__global__ void scatter_kernel(unsigned int* d_inputVals, unsigned int* d_inputPos, unsigned int* d_outputVals, unsigned int* d_outputPos, unsigned int* cu_outputVals, size_t numElems) {
//unsigned int tid = threadIdx.x;
unsigned int mid = threadIdx.x + blockIdx.x * blockDim.x;
unsigned int val;
i... |
22,026 | #include <iostream>
#include <cstdlib>
#include <cstdio>
#include <curand_kernel.h>
#include <thrust/reduce.h>
#include <thrust/functional.h>
#include <thrust/execution_policy.h>
#include <thrust/extrema.h>
#include <thrust/device_ptr.h>
using namespace std;
__global__ void setup_kernel (curandState * state, unsig... |
22,027 | /*
KAM PUI SO (ANTHONY)
CS 510 GPU
Device Properity Check
*/
#include <sys/time.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define WIDTH 1024
#define HEIGHT 1024
#define MASK_WIDTH 127
#define MASK_HEIGHT 127
#define LOOPMAX 20
#define TILESIZE 32
#define RANGE 10
#define ROW 0... |
22,028 | #include <iostream>
#include <array>
#include <cuda_runtime.h>
__global__
void saxpy(float* a_ptr, float* b_ptr, int N) {
const int thread_index = blockIdx.x*blockDim.x + threadIdx.x;
if (thread_index >= N) { return; }
a_ptr[thread_index] = a_ptr[thread_index] + b_ptr[thread_index];
}
__global__ void reduce(fl... |
22,029 | /*******************************************************************************
* PROGRAM: canny_edge_detector
* FILE: gaussian_smooth.cu
* PURPOSE: Apply Gaussian Smooth to input pgm image
* NAME: Vuong Pham-Duy
* Faculty of Computer Science and Technology
* Ho Chi Minh University of Technology, Viet Nam... |
22,030 | template <typename T>
struct Neighbours3x3 {
T p11; T p12; T p13;
T p21; T p22; T p23;
T p31; T p32; T p33;
};
template <typename T>
__device__ T d_getPixel(const T* const src, int x, int y, int width, int height){
int colaced_loc = (x + y*width);
if (colaced_loc < 0) {
return make_uchar1(0);
}
if (colaced... |
22,031 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <unistd.h>
#include <cuda.h>
#include <string.h>
#define X 1024
#define Y 1024
#define BX 4
#define BY 4
#define USEC_ELAPSED(start,end) ((end.tv_sec - start.tv_sec) * 1000 * 1000 + (end.tv_usec - start.tv_usec))
#define CHECK_RET(x) \ ... |
22,032 | #include <stdio.h>
#include <cuda_runtime.h>
int main(void){
cudaDeviceProp prop;
if(cudaGetDeviceProperties(&prop, 0) != cudaSuccess){
fprintf(stderr, "no device avalible, go a hell, man\n");
}
fprintf(stdout, "get prop success\n");
fprintf(stdout, " name: %s\n", prop.name);
fprint... |
22,033 | #include <stdio.h>
/* experiment with N */
/* how large can it be? */
#define N (2048*2048)
#define THREADS_PER_BLOCK 512
__global__ void vector_add(int *a, int *b, int *c)
{
/* insert code to calculate the index properly using blockIdx.x, blockDim.x, threadIdx.x */
int index = int(blockIdx.x) * int(blockDim... |
22,034 | #include <stdio.h>
#include "cuda.h"
#define max(x,y) ((x) > (y)? (x) : (y))
#define min(x,y) ((x) < (y)? (x) : (y))
#define ceil(a,b) ((a) % (b) == 0 ? (a) / (b) : ((a) / (b)) + 1)
void check_error (const char* message) {
cudaError_t error = cudaGetLastError ();
if (error != cudaSuccess) {
printf ("CUDA error :... |
22,035 | #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( "Comp... |
22,036 | // #ifdef __cplusplus
// extern "C" {
// #endif
#include <float.h>
#include <math.h>
#include <stdio.h>
#include <vector>
#define DIVUP(m, n) ((m) / (m) + ((m) % (n) > 0))
#define CUDA_1D_KERNEL_LOOP(i, n) \
for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < n; \
i += blockDi... |
22,037 |
#ifdef D_CUDA
#include "ParticleKernel.cuh"
#include "Dot/Core.h"
#include <GL/glew.h>
#include <cuda_gl_interop.h>
#include <iostream>
namespace Dot {
__global__ void _Init(float3* pos, float3* vel, int count,curandState * state)
{
int id = blockDim.x * blockIdx.x + threadIdx.x;
if (id < count)
{
... |
22,038 | #include <fstream>
#include <string>
#include <iostream>
#include <stdint.h>
#include <math.h>
#include <utility>
#include <sys/time.h>
#include <limits>
#include <stdlib.h>
#include <unistd.h>
#include <sstream>
#include <map>
#include <bitset>
using namespace std;
#define STEPSIZE 1 // step size in pixels, e.g. 2 =... |
22,039 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <cuda_runtime.h>
#include <fstream>
#include <chrono>
#include <iostream>
__global__ void vectorAdd(const double *A, const double *B, double *C, int numElements) {
int i = blockDim.x * blockIdx.x + threadIdx.x;
if (i < numEleme... |
22,040 | #include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/generate.h>
#include <thrust/sort.h>
#include <thrust/copy.h>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <math.h>
#include <assert.h>
struct LU
{
LU() = default;
std::vector<double> L;
std:... |
22,041 | #include <thrust/host_vector.h>
#include <thrust/fill.h>
#include <thrust/device_vector.h>
#include <thrust/reduce.h>
#include <thrust/functional.h>
#include <iostream>
template <typename T>
double funcao_que_recebe_device_ou_host(T v) {
thrust::fill(v.begin(), v.end(), 0.4);
double s = thrust::reduce(v.beg... |
22,042 | __global__
void advectVelocities(const float dt,
const float * d_levelset,
const float * d_velIn_x,
const float * d_velIn_y,
float * d_velOut_x,
float * d_velOut_y)
{
}
void advectVelocities(dim3 blocks, dim3... |
22,043 | //
// 【normalize_vector】
//
// 概要: ベクトルの正規化関数サンプル
// 参考:
// CUDA for Engineers: An Introduction to High-Performance Parallel Computing
//
#include <thrust/device_vector.h>
#include <thrust/inner_product.h>
#include <thrust/transform.h>
#include <thrust/functional.h>
#include <cmath>
#include <iostream>
u... |
22,044 | #include<stdio.h>
#include<cuda.h>
|
22,045 | #include "includes.h"
__global__ void Round(float * A, float *out, int size) {
int id = blockDim.x*blockIdx.y*gridDim.x + blockDim.x*blockIdx.x + threadIdx.x;
if (id < size) {
int t = (int)(out[id] + 0.5); // can it be speeded up??
out[id] = (float)t;
}
} |
22,046 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
using namespace std;
#include <cuda_runtime.h>
#include <curand_kernel.h>
#define NUM_THREADS 1024
cudaStream_t stream;
int features = 1024;
int sampels = 10000;
int classes = 10;
float ** training_x; //3500 * 784
float ** training_y; //3... |
22,047 | #include <stdio.h>
void initWith(float num, float *a, int N)
{
for(int i = 0; i < N; ++i)
{
a[i] = num;
}
}
__global__
void addVectorsInto(float *result, float *a, float *b, int N)
{
int index = threadIdx.x + blockIdx.x * blockDim.x;
int stride = blockDim.x * gridDim.x;
for(int i = index; i < N; i +=... |
22,048 | /*
* Copyright 2011-2015 NVIDIA Corporation. All rights reserved
*
* Sample app to demonstrate use of CUPTI library to obtain metric values
* using callbacks for CUDA runtime APIs
*
*/
#include <stdio.h>
#include <cuda.h>
#define DRIVER_API_CALL(apiFuncCall) \
do { ... |
22,049 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <errno.h>
#include <limits.h>
#include <string.h>
#include <time.h>
#include <cuda.h>
#define GIG 1000000000
#define CPG 2.4 // Cycles per GHz -- Adjust to your computer
#define GPU_BLOCK_SIZE 128
typedef float pr_type_t;
typedef struct ad_v... |
22,050 | // incrementArray.cu
#include <stdio.h>
#include <assert.h>
#include <cuda.h>
void incrementArrayOnHost(float *a, int N)
{
int i;
for (i=0; i < N; i++) a[i] = a[i]+1.f;
}
__global__ void incrementArrayOnDevice(float *a, int N)
{
int idx = blockIdx.x*blockDim.x + threadIdx.x;
if (idx<N) a[idx] = a[idx]+1.f;
}
__... |
22,051 | #include <iostream>
#include <stdio.h>
#include <assert.h>
#include <sys/time.h>
#include <memory>
#include <fstream>
#include <queue>
class Graph{
public:
Graph(const int verticeNum){
this->verticeNum = verticeNum;
graphMatrix = new int*[verticeNum];
for(int i = 0; i < vertic... |
22,052 | #include "includes.h"
extern "C" {
}
#define TB 256
#define EPS 0.1
#undef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#undef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b))
__global__ void hist_remap2_kernel( float *I, int nI, float *mI, float *histJ, float *cumJ, float *_minJ, float *_maxJ, int nbins, float *_... |
22,053 | #include "includes.h"
__global__ void SumSymbolsKernel( float *symbolOne, float *symbolTwo, float *result, int symbolSize )
{
int threadId = blockDim.x*blockIdx.y*gridDim.x //rows preceeding current row in grid
+ blockDim.x*blockIdx.x //blocks preceeding current block
+ threadIdx.x;
if(threadId < symbolSize)
{
resu... |
22,054 | #include "includes.h"
__global__ void ConditionCFLKernel2D2 (double *newDT, double *DT2D, double *DT1D, double *Vmoy, double *invRmed, int *CFL, int nsec, int nrad, double DeltaT)
{
int i = threadIdx.x + blockDim.x*blockIdx.x;
int k;
double dt;
double newdt = 1e30;
if (i>0 && i<nrad){
newDT[i] = newdt;
for (k = 0; k <... |
22,055 | #include <stdio.h>
void __global__ kernel_add_one(int* a, int length) {
int gid = threadIdx.x + blockDim.x*blockIdx.x;
while(gid < length) {
a[gid] += 1;
gid += blockDim.x*gridDim.x;
}
}
|
22,056 | /* fragment gpu RAM by allocating a bunch of blocks and then releasing some in between, creating holes
then try to allocate more than the size of the largest hole, but less than total free memory
it appears that CUDA succeeds
conclusiong: cudaMalloc it's not allocating contiguous memory
*/
#include <stdio.h>
#... |
22,057 | #include "includes.h"
__global__ void second_calculation( char* dev_a, char* dev_b, char* dev_c, int k, int num_matrices, int matrix_size ) {
// Each thread handles a matrix
int j = (blockIdx.x*blockDim.x) + threadIdx.x; // this thread handles the data at its thread id
if (j >= matrix_size) return;
//If first valu... |
22,058 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <math.h>
#define MASK_WIDTH 5
#define COMMENT "Histogram_GPU"
#define RGB_COMPONENT_COLOR 255
#define TILE_WIDTH 32
#define SHARED_WIDTH TILE_WIDTH+(MASK_WIDTH-1)/2
typedef struct {
unsigned char red, green, blue;
} PPMPixel;
typedef struct {
... |
22,059 | /*
* purpose: CUDA managed unified memory for >= pascal architectures;
* this version just uses the variant of globally managed
* memory hopefully set aside on the device, but for the rest
* everything remains pretty similar to previous attempts;
* result: fr... |
22,060 | #include "includes.h"
__global__ void inefficient_prefixSum(float* in, int in_length, float* out ){
//shared memory declaration
extern __shared__ float DSM[];
//compute index
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if(idx < in_length){
//load on shared memory
DSM[threadIdx.x] = in[idx];
//compute prefix_su... |
22,061 | /* compile with: nvcc -O3 hw1.cu -o hw1 */
#include <stdio.h>
#include <sys/time.h>
#include <assert.h>
#define INF (1<<16 - 1)
////////////////////////////// DO NOT CHANGE //////////////////////////////////
#define IMG_HEIGHT 256
#define IMG_WIDTH 256
#define N_IMAGES 10000
typedef unsigned char uchar;
#define CU... |
22,062 | __global__ void applyFilter(const unsigned char *input, unsigned char *output, const unsigned int width, const unsigned int height, const float *kernel, const unsigned int kernelWidth) {
const unsigned int col = threadIdx.x + blockIdx.x * blockDim.x;
const unsigned int row = threadIdx.y + blockIdx.y * blockDim... |
22,063 | #include "ising.cuh"
#include <cmath>
// pre-calculated exp(dE / (kB * T))
__constant__ float exp_dE_beta[10];
void set_expdE(const float beta, const float J, const float H, const bool verbose) noexcept
{
// up == true, down == false;
// cash exp(dE) to constant memory
const float exp_dE[10] = { /... |
22,064 | #include <iostream>
#include <stdio.h>
#define N 64
#define TPB 32
float scale(int i, int n)
{
return ((float) i)/((float) (n-1));
}
__device__ float distance(float x1, float x2)
{
float x = (x1-x2)*(x1-x2);
return sqrt(x);
}
__global__ void distanceKernel(float *d_out, float *d_in, float ref)
{
const int i = b... |
22,065 | #include <curand_kernel.h>
#include <curand.h>
#include <chrono>
#include <iostream>
#include <string.h>
#include <math.h>
#include <time.h>
#include <stdio.h>
__global__ void setup_gpu_rng(long long n, curandState *rng_states, long long seed) {
long long i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < n) cura... |
22,066 | #include "io.cuh"
void load_data()
{
FILE *f_images=fopen("../data/train-images.idx3-ubyte","rb");
FILE *f_labels=fopen("../data/train-labels.idx1-ubyte","rb");
int tmp;
int magic_num;
fread(&magic_num,sizeof(int),1,f_images);
fread(&magic_num,sizeof(int),1,f_labels);
// printf("debug:%d... |
22,067 | #include "includes.h"
static __device__ float E = 2.718281828;
__global__ void transformBboxSQDKernel(float *delta, float *anchor, float *res, int block_size)
{
int di = (blockIdx.x * block_size + threadIdx.x) * 4;
float d[4] = {delta[di], delta[di+1], delta[di+2], delta[di+3]};
float a[4] = {anchor[di], anchor[di... |
22,068 |
__global__ void multiplyArray(const int* matches, const int* counts, const int N, const int M, int* counts_out){
/*
Embarrassingly simple parallel multiply where output and first matrix are 1D
Inputs:
matches: N length array of matches (ideally ones and zeros)
counts: N*M length array of coun... |
22,069 | #include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <chrono>
#include <fstream>
using namespace std::chrono;
#define nBins 2024
__global__ void
hist_device(const int *input, int *bins, int N)
{
int index = threadIdx.x + blockIdx.x * blockDim.x;
int stride = blockDim.x * gridDim.x;... |
22,070 | /* NiuTrans.Tensor - an open-source tensor library
* Copyright (C) 2017, Natural Language Processing Lab, Northeastern University.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the ... |
22,071 | /*
@autor José Arcos Aneas
Codigo de suma de dos vectores contenidos en archivos donde la
primera linea sea el numero de elemento a leer.
Los archivos son pasados como argumento a la hora de ejecutar.
*/
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdli... |
22,072 | #include "cuda.h"
#include "stdio.h"
__global__ void hello() { printf("Hello world from GPU\n"); }
int main() {
// will print 5 hello world.
hello<<<1, 5>>>();
// reset all the resources in GPU for this process.
// If no cudaDeviceReset(), no output will print, the program in CPU will just
// quit without ... |
22,073 | // includes
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <cuda_runtime.h>
//-------------Funcion sumar velocidad
__global__ void sumarvelocidad(float * pdist,int * pvec,float * psum, int node) {
int nvec=9; //numero de vecinos
int ndist=9; //numero de funcion de distribucion
int k=0;
int x = t... |
22,074 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
using uchar = unsigned char;
__global__ void kernel(uchar* data, uchar* new_data, unsigned height, unsigned width) {
float matr[3][3] =
{
{0.11111f, 0.11111f, 0.11111f}... |
22,075 | // fermi
/*
* Copyright 2018 Vrije Universiteit Amsterdam, The Netherlands
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* Unles... |
22,076 | #include<iostream>
#include<math.h>
#include<cooperative_groups.h>
using namespace cooperative_groups;
int numBlocks = 40;
int blockSize = 256;
__device__ int reduce_sum(thread_group g, int *temp, int val){
for (int i = g.size()/2; i>0; i /=2){
// make a val variable for each thread and take the value from the ... |
22,077 | #include "includes.h"
__global__ void Compute_weightdata_Kernel(float* weightdata, const float* I, const float* input, int nPixels, int nChannels, int c, float norm_for_data_term, float eps)
{
int bx = blockIdx.x;
int tx = threadIdx.x;
int x = bx*blockDim.x + tx;
if (x >= nPixels)
return;
if (norm_for_data_term == 2)... |
22,078 | #include<stdio.h>
#include<stdlib.h>
#include<sys/time.h>
#include<cuda.h>
#include<cuda_runtime.h>
#define GLOBAL_N 10
const int M = (1 << GLOBAL_N), N = (1 << GLOBAL_N), K = (1 << GLOBAL_N); /* matrix size */
#define BLOCK_SIZE (1 << 3) /* thread block size */
// Matrices are stored in row-major order:
// M(row, co... |
22,079 | #include <cuda.h>
#include <stdio.h>
__global__ void arrayMult(float *a, float *b, float *result, int N){
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < N){
result[idx] = a[idx] * b[idx];
}
}
int main(){
float *vector_a, *vector_b;
float *dev_a, *dev_b, *dev_result;
float... |
22,080 | #include <stdio.h>
__global__ void compute_grid_h_kernel( double *gridh, double *xm1, double *ym1, double *zm1, int nelt, int lx1, int ly1, int lz1, int if3d, int nnel,int lxy, int lxyz ){
int id = blockIdx.x*blockDim.x+threadIdx.x;
if(id<nnel){
int ix= id % lx1;
int iy= (id/lx1)%ly1;
int iz = (id / (lxy... |
22,081 | /*
* hello.cu:
*
*
*/
#include <stdio.h>
__global__ void mykernel()
{
}
int main()
{
mykernel<<<1,1>>>();
printf("Hello, CUDA World!\n");
return 0;
}
|
22,082 | #include "includes.h"
__global__ void transposeSmemDyn(float *out, float *in, int nx, int ny)
{
// dynamic shared memory
extern __shared__ float tile[];
// coordinate in original matrix
unsigned int ix, iy, ti, to;
ix = blockDim.x * blockIdx.x + threadIdx.x;
iy = blockDim.y * blockIdx.y + threadIdx.y;
// linear glob... |
22,083 | #include <stdio.h>
/* The old-fashioned CPU-only way to add two vectors */
void add_vectors_host(int *result, int *a, int *b, int n) {
for (int i=0; i<n; i++)
result[i] = a[i] + b[i];
}
/* The kernel that will execute on the GPU */
__global__ void add_vectors_kernel(int *result, int *a, int *b, int n) {
... |
22,084 | #include <math.h>
#include <stdlib.h>
#include <stdio.h>
__global__ void mul_array(int n, float *a, float *b, float *c) {
int i = blockIdx.x*blockDim.x + threadIdx.x;
if(i<n) c[i] = a[i]*b[i];
}
int main() {
int i, n=1000;
float x;
int bytes=n*sizeof(float);
float *a = (float*)malloc(bytes);
float *b = (float*... |
22,085 | /************************************************************************************\
* *
* Copyright � 2014 Advanced Micro Devices, Inc. *
* Copyright (c) 2015 Mark D. Hill and David A. Wood ... |
22,086 | #include<stdio.h>
#include<iostream>
using namespace std;
__global__ void sum(int* input1,int* input2, int *Out,int size) //kernel
{
int i = threadIdx.x + blockDim.x * blockIdx.x;
printf("\nThread id%d",threadIdx.x);
if(i<size)
Out[i]= input1[i] + input2[i];
__syncthreads();
}
int main()... |
22,087 |
#include <iostream>
#include <cuda.h>
#include <cstdlib>
class Unified {
public:
void *operator new(size_t len) {
void *ptr;
cudaMallocManaged(&ptr, len);
return ptr;
}
void operator delete(void *ptr) {
cudaFree(ptr);
}
void* operator new[] (std::size_t size) {
void *ptr;
cudaMallocManaged(&ptr,s... |
22,088 | /*
This program demonstrates the basics of working with cuda. We use
the GPU to add two arrays. We also introduce cuda's approach to
error handling and timing using cuda Events.
This is the main program. You should also look at the header add.h
for the important declarations, and then look at add.cu to see h... |
22,089 | /*
autor fredy m
uaem
desonses@gmail.com para mas comentarios
*/
#ifdef __CUDACC__
#define cuda_SYNCTHREADS() __syncthreads();
#else
#define cuda_SYNCTHREADS()
#endif
#include <stdlib.h>
#include <stdio.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <math.h>
#define N 32
/*
calcula el v... |
22,090 |
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <cuda_runtime_api.h>
//Copied from NVidia
__device__ void sum_reduction(int *data, int *out) {
unsigned int id = threadIdx.x;
for (unsigned int s=blockDim.x/2; s>0; s>>=1) {
if (id < s) {
data... |
22,091 | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef std::vector<double> vi;
typedef vector<vector<double> > matrix;
vi A;
vi IA = { 0 };
vi JA;
vi DA;
int length;
__global__ void multi(double *a, double *b, double *c, int n){
int id = blockIdx.x*blockDim.x+threadId... |
22,092 | #include <cuComplex.h>
#include <cuda.h>
#include <cuda_runtime.h>
__global__ void bpsk_decision_maker(cuFloatComplex *in, uint8_t *out,
int n) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < n) {
out[i] = in[i].x > 0;
}
}
void exec_bpsk_decision_maker(cuFloatCo... |
22,093 | #include "includes.h"
__global__ void kReadRows(float* data, float* target, int num_images, int num_modules, int num_modules_batch, int module_id_offset) {
int c = blockIdx.y;
int src_module_id = module_id_offset + blockIdx.x;
int dst_module_id = blockIdx.x;
data += num_images * (src_module_id + c * num_modules);
targ... |
22,094 | #include "includes.h"
const int N = 32;
__global__ void mul(int* A, int* B, int* C){
int col = blockIdx.x * blockDim.x + threadIdx.x;
int lig = blockIdx.y * blockDim.y + threadIdx.y;
int index = lig * N + col;
if (col < N && lig < N){
int inter = 0;
for (int i = 0; i<N; ++i){
inter += A[lig*N + i] * B[i*N + col];
}... |
22,095 | // A tiled matrix multiplication program
#include "stdio.h"
#include "stdlib.h"
#define SIZE 512
#define TILE_WIDTH 16
// kernel definition
__global__ void MatrixMulKernel(float * A,float * B,float * C,int len)
{
int row = blockIdx.y * blockDim.y + threadIdx.y;
int col = blockIdx.x * blockDim.x + threadIdx.... |
22,096 | #include <stdio.h>
int main() {
int nDevices;
//All CUDA C Runtime API functions have a return value which can be used to check for errors that occurr during their execution
//cudaPeekAtLastError(): cuda maintain a single variable for error, which is updated everytime. This method will return the value of th... |
22,097 | #include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <cstdlib>
#include <chrono>
int n;
__global__ void vecAdd(double *A, double *B, double *C){
int idx = blockIdx.x * blockDim.x + threadIdx.x;
C[idx] = A[idx] + B[idx];
}
bool checkResults(double *A, double *B, double *res_gpu){
double *res_cpu =... |
22,098 | #pragma kernel tune(threads_per_block=32, 64, 128, 256, 512, 1024)
#pragma kernel tune(items_per_thread=1, 2, 4, 8)
#pragma kernel set(items_per_block=threads_per_block * items_per_thread)
#pragma kernel problem_size(n)
#pragma kernel block_size(threads_per_block)
#pragma kernel grid_divisor(items_per_block)
#pragma ke... |
22,099 | #include <cuda.h>
#include <stdio.h>
#include <stdlib.h>
__global__ void mandelKernel() {
// To avoid error caused by the floating number, use the following pseudo code
//
// float x = lowerX + thisX * stepX;
// float y = lowerY + thisY * stepY;
}
// Host front-end function that allocates the memory a... |
22,100 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <cuda.h>
//Parallel (GPU) function for mean filter
__global__ void meanFilter(int* imageArray, int* filteredArray, int img_height, int img_width, int window_width){
int x = blockIdx.x*blockDim.x + threadIdx.x;
int y = blockId... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.