serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
17,001 | //--blockDim=4 --gridDim=1
/*
* This kernel suffers from barrier divergence.
* Can you see why?
*/
__global__ void inloop(/* no inputs or outputs
in this illustrative
example */) {
__shared__ int A[2][4];
int buf, i, j;
int tid = threadIdx.x;
int x = tid ==... |
17,002 | #define IDT(i,j) (i)*((i)+1)/2+(j)
typedef struct{
double *v;
int dim;
int size;
} Grid;
__global__ void cero(Grid m){
int i = blockIdx.x * blockDim.x + threadIdx.x;
int j = blockIdx.y * blockDim.y + threadIdx.y;
if(i<=m.dim-1 && j<=i){
if(j==0 || i==m.dim-1 || i==j)
m.v[IDT(i,j)]=0.0;
else
m.v[IDT(i,... |
17,003 | #include "includes.h"
__global__ void refine_fuseThreeDepthSimMaps_kernel(float* osim, int osim_p, float* odpt, int odpt_p, float* isimLst, int isimLst_p, float* idptLst, int idptLst_p, float* isimAct, int isimAct_p, float* idptAct, int idptAct_p, int width, int height, float simThr)
{
int x = blockIdx.x * blockDim.x +... |
17,004 | #include <stdio.h>
#define SIZE 10
#define BLOCKS 1
#define THREADS_PER_BLOCK 5
__global__ void OddEvensort(int *array, int size) {
bool odd = true;
__shared__ bool swappedodd;
__shared__ bool swappedeven;
int temp;
swappedodd = true;
swappedeven = true;
while (true) {
if (odd == true) {
//Swapping ... |
17,005 | #include <iostream>
#define RADIUS 3
#define BLOCK_SIZE 1024
__global__ void stencil_1d(int *in, int *out, int n) {
__shared__ int temp[BLOCK_SIZE + 2 * RADIUS];
int gindex = threadIdx.x + blockIdx.x * blockDim.x;
int lindex = threadIdx.x + RADIUS;
// check boundary
if (gindex >= n) {
return;
}
/... |
17,006 | #include <cuda.h>
#include <cuda_runtime_api.h>
#include <device_launch_parameters.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define TILE_SIZE 4
__global__ void meanFilter(float *deviceinputimage, float *deviceOutputImage, int dim)
{
int row = blockIdx.y * blockDim.y + threadIdx.y;
int col = bl... |
17,007 | #include "includes.h"
__global__ void calculation( char *a, char *b, int *c, int constant, int vector_size ) {
int tid = (blockIdx.x*blockDim.x) + threadIdx.x; // this thread handles the data at its thread id
if (tid < vector_size){
// Read in inputs
char prev_a = a[tid>0?tid-1:(vector_size-1)];
char curr_a = ... |
17,008 | #include <cstdio>
#include <cuda_runtime.h>
// GPU Ŀ α(NVCC )
__global__ void addKernel(int* c, const int * a, const int * b)
{
int i = threadIdx.x;
c[i] = a[i] + b[i];
}
__host__ int main(void){
const int SIZE = 5;
const int a[SIZE] = { 1,2,3,4,5 };
const int b[SIZE] = { 10,20,30,40,50 };
int c[SIZE] = { 0 }... |
17,009 | #include "includes.h"
__global__ void STREAM_Copy_double(double *a, double *b, size_t len)
{
size_t idx = threadIdx.x + blockIdx.x * blockDim.x;
while (idx < len) {
b[idx] = a[idx];
idx += blockDim.x * gridDim.x;
}
} |
17,010 | #include "includes.h"
using namespace std;
/* Utility function, use to do error checking.
Use this function like this:
checkCudaCall(cudaMalloc((void **) &deviceRGB, imgS * sizeof(color_t)));
And to check the result of a kernel invocation:
checkCudaCall(cudaGetLastError());
*/
__global__ void vectorTransformKerne... |
17,011 | #include <cuda.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>
/*
reduction.cu
A demonstration of array reduction using CUDA
Created for GPU Architecture and Programming
Spring 2012, New York University
Copyright 2012 Guy Dickinson <guy.dickinson@nyu.edu>
*/
// Vanilla, sequential reduction on host
... |
17,012 | /*******************************************************************************
*
* probe a comuter for basic info about processing cores and GPU
*
* compile with:
*
* nvcc probe2.cu -L/usr/local/cuda/lib64 -I/usr/local/cuda-10.2/targets/x86_64-linux/include -lcuda -lcudart
*
* (in .tcshrc, please have:)
* s... |
17,013 | #include <cuda.h>
#include <stdio.h>
#include <math.h>
#define N 6
__global__ void add( float *a, float *b, float *c) {
int tid = blockIdx.x; //Handle the data at the index
c[tid] = a[tid] + b[tid];
}
__global__ void scale(float *a, int size, int index){
int i;
int start=(index*size+index);
int end=(index*s... |
17,014 | #include <iostream>
#include <cstdio>
using std::cout;
using std::endl;
__global__
void print_a(int* a, const int n) {
for (int i=0; i<n; i++) {
printf("a[%d] = %d\n",i,a[i]);
}
}
int main() {
// allocate a
const int lena = 6;
int* a;
cudaMallocManaged(&a,lena*sizeof(*a));
// allocate b
const i... |
17,015 | __device__ char solve(float, float);
// Global function, visible from the CPU code
__global__ void mandelbrot(char *result, float *x, float *y, int size) {
// Getting the thread ID
const int tx = threadIdx.x + (blockIdx.x * blockDim.x);
// Calculating the X and Y pixel coordinates, wouldn't need to do this if the... |
17,016 | #include <stdio.h>
#include <stdlib.h>
#define PI 3.14159265
#define PADDING_SIZE 1
#define FILTER_SIZE 3
// declaring constant memory for kernel
__device__ __constant__ float d_filterKernel[FILTER_SIZE] = { -1, 0, 1};
__global__ void convolution( float *image, int paddedX, int paddedY,
int blockX, int bloc... |
17,017 | /*
Author: Azali Saudi
Email : azali@ums.edu.my
Date Created : 3 March 2018
Last Modified: 4 March 2018
Task: The Kernal to solve Laplace's equation.
*/
#include <stdio.h>
#include <cuda_runtime.h>
extern "C"
__global__ void kjacobi(int Nx, int Ny, double *a, double *b)
{
int c=blockIdx.x * blockD... |
17,018 | #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
int iRow = blockIdx.y*blockDim.y+threadIdx.y;
int iCol = blockIdx.x*blockDim.x+thr... |
17,019 | /*
* Find BLANK and replace your own code.
* And submit report why do you replace the blank that way.
*/
#include<stdlib.h>
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#define TILE_WIDTH 2 /* set TILE_WIDTH 16 for the evaluation! */
#define MAXPOOL_INPUT_FILENAME "input.txt"
#define A_... |
17,020 | #include "sum.hh"
#include "../runtime/node.hh"
namespace gpu
{
namespace
{
constexpr std::size_t BLOCK_SIZE = 512;
__global__
void mse(const dbl_t* a, const dbl_t* b, dbl_t* out,
std::size_t len)
{
__shared__ float partial[2 * BLOCK_SIZE];
... |
17,021 | #include <cuda_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/time.h>
__device__ float test1[1000];
__device__ float test2[1000];
__global__ void kernel(){
test1[0] = 0.0f;
test2[0] = 0.0f;
}
int main(int argc,char* argv[]){
return 0;
}
|
17,022 | #include <stdio.h>
// Número de elementos em cada vetor
#define N 2048 * 2048
__global__ void my_kernel(float scalar, float * x, float * y)
{
// Determina a identificação de thread global exclusiva, por isso sabemos qual elemento processar
int tid = blockIdx.x * blockDim.x + threadIdx.x;
// Certifiqu... |
17,023 | #include "includes.h"
__global__ void leapstep(int n, double *x, double *y, double *z, double *vx, double *vy, double *vz, double dt){
const unsigned int serial = blockIdx.x * BLOCKSIZE + threadIdx.x;
if(serial < n){
x[serial] += dt * vx[serial];
y[serial] += dt * vy[serial];
z[serial] += dt * vz[serial];
}
} |
17,024 | #include <stdio.h>
typedef char mytype;
int main() {
int rows=10,cols=10;
mytype **hMat=new mytype*[rows];
hMat[0]=new mytype[rows*cols];
for(int i=1;i<rows;i++)
hMat[i]=hMat[i-1]+cols;
//initialize 2D arrays
for(int i=0;i<rows;i++)
for(int j=0;j<cols;j++)
hMat[i][j]=i+j;
mytype *dArr;
cudaMalloc((... |
17,025 | #include "includes.h"
__global__ void gpu_saxpy(int n, float a, float *x, float *y, float *s)
{
int i = blockIdx.x*blockDim.x + threadIdx.x;
if (i < n) s[i] = a*x[i] + y[i];
} |
17,026 | #include <stdio.h>
#include <stdlib.h>
#include <string.h> /* memcpy */
#include <math.h>
#include <stdint.h>
void *cuda_upload_var(void *host_var, int size)
{
void *cuda_var;
cudaMalloc(&cuda_var, 4);
cudaMemcpy(cuda_var, host_var, size, cudaMemcpyHostToDevice);
return cuda_var;
}
void cuda_download_var(void *cud... |
17,027 | #include <stdio.h>
#include <stdlib.h>
#include <string.h> /* memcpy */
#include <math.h>
#include <stdint.h>
void *cuda_upload_var(void *host_var, int size)
{
void *cuda_var;
cudaMalloc(&cuda_var, 4);
cudaMemcpy(cuda_var, host_var, size, cudaMemcpyHostToDevice);
return cuda_var;
}
void cuda_download_var(void *cud... |
17,028 | #include <iomanip>
#include <iostream>
#include <cuda.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <thrust/device_vector.h>
#include <thrust/reduce.h>
#include <thrust/functional.h>
#include <thrust/transform_reduce.h>
#include <thrust/host_vector.h>
#include <fstream>
using namespace std;
stru... |
17,029 | #include <iostream>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
// kernel menambahkan vector
__global__
void tambahVector(
const float *cVectorA,
const float *cVectorB,
float *cVectorC,
const int cJumlahElemen)
{
// cari indeks saya
int idx_ = 0;
}
// fungsi main untuk panggil kernel
int... |
17,030 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/time.h>
#define MAX_CHAR_PER_LINE 128
#define FLT_MAX 3.40282347e+38
#define malloc2D(name, xDim, yDim, type) do { \
name = (type **)malloc(xDi... |
17,031 | /***************************************************************************
*
* (C) Copyright 2010 The Board of Trustees of the
* University of Illinois
* All Rights Reserved
*
***************************************************************************/
... |
17,032 | ////////////////////////////////////////////////////////////////////////////
//
// Copyright 1993-2015 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 u... |
17,033 | #include "includes.h"
__global__ void sub_calculation( char* dev_a, char* dev_b, char* dev_c, int k, int j, int num_matrices, int matrix_size ) {
// Each thread handles a matrix
int i = (blockIdx.x*blockDim.x) + threadIdx.x;
if (i >= matrix_size) return;
int index = k*matrix_size*matrix_size+j*matrix_size+i;
dev_c... |
17,034 | #include "includes.h"
__global__ void extracunn_MSSECriterion_updateGradInput_kernel(float *gradInput, float *input, float *target, float norm, int nframe, int dim)
{
int k = blockIdx.x;
float *gradInput_k = gradInput + k*dim;
float *input_k = input + k*dim;
float *target_k = target + k*dim;
__shared__ float buffer[MS... |
17,035 | //#include <algorithm>
//#include <cassert>
//#include <cstdlib>
//#include <functional>
//#include <iostream>
//#include <vector>
//#include <cuda_runtime.h>
//#include "device_launch_parameters.h"
//#include <random>
//
//using std::cout;
//using std::generate;
//using std::vector;
//
//using namespace std;
//
//#def... |
17,036 | #include "real.h"
#include "math.h"
#define SECTION_SIZE 512
//ACTUALLY THIS SEEMS WRONG: WE DO NOT KNOW THE ORDER OF OPERATIONS OF THE ADDING. NEED TO DOUBLE BUUFER THE ARRAY XY TO GUARATEE THAT THIS WORKS.
__global__ void ksscan_kernel(real* X, real* Y, int inputsize){
__shared__ real XY[SECTION_SIZE];
int i =blo... |
17,037 | #include "includes.h"
__global__ void kMultScalar(float* mat, float alpha, float* dest, unsigned int len, float scale_targets) {
const unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x;
const unsigned int numThreads = blockDim.x * gridDim.x;
if (scale_targets == 0) {
for (unsigned int i = idx; i < len; i += numT... |
17,038 | /*
* @Program: hello_world.cu
* @Description: The classic Hello World.
*
* @Author: Giacomo Marciani <gmarciani@acm.org>
* @Institution: University of Rome Tor Vergata
*/
#include <stdlib.h>
#include <stdio.h>
__device__ void helloGPUDevice(void) {
printf("[gpu]> Hello world! (device)\n");
}
__global__ void ... |
17,039 | #pragma once
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <iostream>
#define pn(x) printf("%6.3f ", (double)x)
using namespace std;
template <typename T>
class gpuMat
{
bool blank = true;
public:
T* h_elems = nullptr;
T* d_elems = nullptr;
int rows, cols;
int2 *d_size;
gpuMat();
... |
17,040 | #include <stdio.h>
#include <stdlib.h>
int main(void)
{
int driverVersion, runtimeVersion;
cudaDriverGetVersion(&driverVersion);
cudaRuntimeGetVersion(&runtimeVersion);
printf("driver version %d runtime version %d\n",
driverVersion, runtimeVersion);
return 0;
}
|
17,041 | extern "C"
__global__ void sparse2dense_float(float *densevec, float *data, int *indices, int nnz) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i >= nnz) return;
densevec[indices[i]] = data[i];
}
extern "C"
__global__ void sparse2dense_double(double *densevec, double *data, int *indices, int nnz) ... |
17,042 | #include <iostream>
constexpr size_t N = 1 << 20;
constexpr int NUM_THREADS = 256;
constexpr int NUM_BLOCKS = (N + NUM_THREADS-1) / NUM_THREADS;
__global__
void add(size_t n, float *x, float *y){
const int start_index = blockIdx.x * blockDim.x + threadIdx.x;
const int stride = blockDim.x * gridDim.x;
for(size_t... |
17,043 | #ifndef _REPEAT_KERNEL_
#define _REPEAT_KERNEL_
#include <cuda.h>
#include <cuda_runtime.h>
#include <stdio.h>
#include <stdlib.h>
/*
* The actual kernel
*/
template <class T>
__global__ void repeatRowsKernel(T * in, T * out, int M, int N, int r)
{
int row = blockDim.y * blockIdx.y + threadIdx.y;
int column ... |
17,044 | #include<iostream>
#include<cuda.h>
using namespace std;
__global__ void get_block(int *c){
c[0]=blockDim.x;
c[1]=gridDim.x;
}
int main(){
int c[2];
int *dev_c;
cudaMalloc(&dev_c,2*sizeof(int));
get_block<<<10,10>>>(dev_c);
cudaMemcpy(c,dev_c,2*sizeof(int),cudaMemcpyDeviceToHost);
for(in... |
17,045 | #include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
__global__ void add(int *d_a, int *d_b, int *d_c){
*d_c = *d_a + *d_b;
}
int main(){
int a, b, c;
int *d_a, *d_b, *d_c;
cudaMalloc((void**)&d_a, sizeof(int));
cudaMalloc((void**)&d_b, sizeof(int));
cudaMalloc((void**)&d_c, sizeof(int));
a = 7... |
17,046 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include <assert.h>
#define BLOCK_SIZE 16
#define STR_SIZE 256
#define ITER 5000
#ifndef SIZE
#define SIZE 1024
#endif
/* maximum power density possible (say 300W for a 10mm x 10mm chip) */
#define MAX_PD 3000000.0f
/* required prec... |
17,047 | #include <iostream>
#include <fstream>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <queue>
#define maxIter 3500
#define BLOCK_SIZE 32
// Learning rate policy
__device__ float step_fn(int t){
float alpha = 0.012, beta = 0.01;
return alpha/(1.0+beta*powf(t,1.5));
}
__glob... |
17,048 | #include "includes.h"
__global__ void CalculateFixed( const float *background, const float *target, const float *mask, float *fixed, const int wb, const int hb, const int wt, const int ht, const int oy, const int ox )
{
const int yt = blockIdx.y * blockDim.y + threadIdx.y;
const int xt = blockIdx.x * blockDim.x + threa... |
17,049 | #include <stdio.h>
#include <cuda.h>
__global__ void my_kernel(long long *clocks)
{
// 開始時間を記録
long long start = clock64();
printf("Start Clock : %ld\n", start);
// 終了時間を記録
clocks[0] = clock64() - start;
}
int main()
{
int clock_rate = 0;
int device = 0;
long long *clock_data;
lon... |
17,050 | extern "C" {
__global__ void calc_divv(int shift_gid, int np, int nlev, int nelem, double *ru) {
int idx = blockDim.x * blockIdx.x + threadIdx.x + shift_gid;
if (idx >= np*np*(nlev+1)*nelem) return;
ru[idx] = 1.2;
}
} // extern "C"
|
17,051 | #include <cstdio>
#define cudaCheckError() { \
cudaError_t e=cudaGetLastError(); \
if(e!=cudaSuccess) { \
... |
17,052 | #include "includes.h"
#define HISTOGRAM_LENGTH 256
__global__ void convertToChar(float * input, unsigned char * ucharInput, int width, int height)
{
int bx = blockIdx.x; int by = blockIdx.y;
int tx = threadIdx.x; int ty = threadIdx.y;
int row = by*blockDim.y+ty;
int col = bx*blockDim.x+tx;
int index = ro... |
17,053 | #include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/scan.h>
#include <stdint.h>
#include <stdio.h>
void performExperiment(int size ) {
thrust::host_vector<float> values(size);
//can I fread directly into values ?
for (int i = 0; i < size; ++i) {
values[i] = 1.0;
}
... |
17,054 |
#include <cuda.h>
#include <cuda_runtime.h>
// Possible weight coefficients for tracking cost evaluation :
// Gaussian discretisation
/*
* 1 4 6 4 1
* 4 16 24 16 4
* 6 24 36 24 6
* 4 16 24 16 4
* 1 4 6 4 1
*/
// Compute spatial derivatives using Scharr operator - Naiv... |
17,055 | extern "C" __device__ double computeInteraction(
const unsigned int atom1,
const unsigned int atom2,
const double4* __restrict__ posq,
double3 * forces) {
// CUDA COMPUTATIONAL KERNEL
return 0;
}
__global__ void evaluate_2b(
const double4* __restrict__ posq,
... |
17,056 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#define DEFAULT_ROW 16384
#define DEFAULT_COL 16384
// time stamp function in seconds
double getTimeStamp() {
struct timeval tv ;
gettimeofday( &tv, NULL ) ;
return (double) tv.tv_usec/1000000 + tv.tv_sec ;
}
// host side matrix addition
void h_addmat(fl... |
17,057 | #include "SubscaleTable.cuh"
// Constructor
__host__ SubscaleTable::SubscaleTable(int idsSize, int dimensionsSize, int tableSize)
{
this->idsSize = idsSize;
this->dimensionsSize = dimensionsSize;
this->tableSize = tableSize;
}
// Copy constructor
__host__ SubscaleTable::SubscaleTable(SubscaleTable* table)
{
this-... |
17,058 | /**
* @file compare.cu
* @brief cuda arrayの比較の実装
* @author HIKARU KONDO
* @date 2021/09/10
*/
#include "transpose.cuh"
#include <stdio.h>
#include "cuda.h"
#define BLOCKDIM 256
/**
* TODO Doc
**/
template<typename T>
__global__ void transpose_kernel(T *x, T *y, int size, const int *index_array) {
unsign... |
17,059 | #include "includes.h"
#define B 2
/*
*/
__global__ void cudaAcc_GetPowerSpectrum_kernel( int NumDataPoints, float2* FreqData, float* PowerSpectrum) {
const int i = blockIdx.x * blockDim.x + threadIdx.x;
// if (i < NumDataPoints) {
float ax = FreqData[i].x;
float ay = FreqData[i].y;
// PowerSpectrum[i] = freqData.x... |
17,060 | #include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <math.h>
#include <cassert>
#include <stdio.h>
#include <stdlib.h>
using std::vector;
/* Dynamic random-access memory (DRAM) is a type of random-access semiconductor memory that stores each bit of data in a memory cell consisting... |
17,061 | #include "pixel.cuh"
// constants for converting rgb to grayscale
const double RED_LUMINANCE = 0.2126;
const double GREEN_LUMINANCE = 0.7152;
const double BLUE_LUMINANCE = 0.0722;
// get luminance of an rgb value by standard transformation
int getLuminance(int r, int g, int b) {
return round(r * RED_LUMINANCE + g * ... |
17,062 | //: nvcc add2.cu -o add2
#include <stdlib.h>
#include <stdio.h>
#define N 1000000
#define BLOCKS 1000
#define THREADS 512
/*
* Syntaxe : <<<BLOCKS,THREADS>>>
* Pour chaque block, creation de copies distinctes avec un threadIdx.n
* BLOCK : petit bout de memoire de 14 bytes qui peuvent etre partages dans... |
17,063 | #include "includes.h"
// CUDA runtime
// Helper functions and utilities to work with CUDA
//Standard C library
#define subCOL 5248
#define COL 5248
#define ROW 358
#define WARPABLEROW 512
#define blocksize 256
#define subMatDim subCOL*WARPABLEROW
#define targetMatDim ROW * COL
__global__ void reduce4(int *g_idata, ... |
17,064 | //pass
//--blockDim=[64,64] --gridDim=[4,4]
#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 ME... |
17,065 | #include <stdio.h>
//cudaGetDeviceCount(addr): assigns count to addr, returns status value cudaSuccess, cudaErrorNoDevice, cudaErrorInsufficientDriver
//cudaDeviceProp: struct for device props
//cudaGetDeviceProperties(addr, index): assigns device properties to addr, returns status value cudaSuccess, cudaErrorInvali... |
17,066 |
/* This is a automatically generated test. Do not modify */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
__global__
void compute(float comp, float var_1,float var_2,float var_3,float var_4) {
if (comp > var_1 + log10f(-1.4101E36f)) {
float tmp_1 = (-1.7403E-43f * -1.3132E-41f + sinhf(+1.9582E19f - var_... |
17,067 | #include "includes.h"
__global__ void find_boundaries(const int num_keys, const int num_bucket, const int *which_bucket, int *bucket_start){
int index = threadIdx.x + blockIdx.x*blockDim.x +blockIdx.y*blockDim.x*gridDim.x;
// Each thread looks at one entry in the sorted bucket index list
if (index >= num_keys){
return... |
17,068 | #include "includes.h"
__global__ void computeSquare(int *d_in, int *d_out) {
int index = threadIdx.x;
d_out[index] = d_in[index] * d_in[index];
} |
17,069 | #include <iostream>
#include <stdio.h>
#include <cuda_runtime.h>
__global__ void
setArray(int *d_arr, int arrSize)
{
int t_id = blockIdx.x * blockDim.x + threadIdx.x;
for (int idx = t_id; idx < arrSize; idx += gridDim.x * blockDim.x)
d_arr[idx] = idx;
}
__global__ void
search(int *d_arr, int arrSize,... |
17,070 | #include "includes.h"
__global__ void get_dists_kernel(const int * beg_pos, const int* adj_list, const int * weights, bool * mask, int* dists, int * update_dists, const int num_vtx) {
int tid = blockIdx.x*blockDim.x + threadIdx.x;
if (tid < num_vtx) {
if (mask[tid] == true) {
mask[tid] = false;
for (int edge = beg_po... |
17,071 | #include <stdio.h>
#define BLOCKSIZE 32
//Sigmoid function for logistic regression
float sigmoid(float in){
return 1.0 / (1 + exp(-1 * in));
}
//Tiled version of matrix multiply
__global__ void MatrixMultiplyKernel(float *devA, float *devB, float *devC, int rows, int cols, int k, float alpha, float beta)
{
//Get t... |
17,072 | #include <iostream>
#include <math.h>
// Kernel function to color the buffer according to the gradient
__global__ void insideCircle(bool *buffer)
{
int nx = blockDim.x;
int ny = gridDim.x;
float r = 1.0f;
float dx = 2.0f / nx;
float dy = 2.0f / ny;
float x = (threadIdx.x - nx/2.0f + 0.5f) * d... |
17,073 | #include "matrix-multiplication.cuh"
#include "handle-error.cuh"
__global__
void multiplyMatricesKernel(Matrix resultMatrix, Matrix matrixOne, Matrix matrixTwo) {
size_t row = blockIdx.y * blockDim.y + threadIdx.y;
size_t column = blockIdx.x * blockDim.x + threadIdx.x;
size_t resultIndex = (row * resultMat... |
17,074 | #include "includes.h"
__global__ void back_prop_kernel_batch(float *device_output, float *inP, float *m_hidden, float* weights_2, float* o_errG, int nInput, int nHidden, int nOutput, float l_R, int batchSize)
{
int linearThreadIndex = threadIdx.x;
int unit = blockIdx.x%nHidden;
int batch = blockIdx.x/nHidden;
__shar... |
17,075 |
#include <stdio.h>
#include <stdlib.h>
#define ARRAY_SIZE 256
#define N 10
#define NUM_BLOCKS 6
#define THREADS_PER_BLOCK 256
/* Kernel para sumar dos vectores en un sólo bloque de hilos */
__global__ void matrix_mult(int *d_A, int *d_B, int *d_C)
{
__shared__ int temp[N];
int index = threadIdx.x + bl... |
17,076 | /*
============================================================================
Name : ThrustPrime.cu
Author : Stephen Mathews
Version :
Copyright : Your copyright notice
Description : Compute sum of reciprocals using STL on CPU and Thrust on GPU
================================================... |
17,077 | #include "includes.h"
#define IMUL(a, b) __mul24(a, b)
#define iDivUp(a,b) ((a)+(b)-1)/(b)
#define CONV1_THREAD_SIZE 256
#define CONVN_THREAD_SIZE1 16
#define CONVN_THREAD_SIZE2 31 //31 is faster than 32 because shared memory is too full
// 28 space-time orientations of V1 simple cells
#define nrFilters 28
// 8 d... |
17,078 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include "curand.h" // CUDA PRNG library!
#include <ctime>
#include <cstdio>
__global__ void addTen(float* d, int count) {
int threadsPerBlock = blockDim.x * blockDim.y * blockDim.z; // 512
// int blocksPerGrid = gridDim.x * gridDim.y * gridDim.z... |
17,079 | #include <curand_kernel.h>
//
//mettre devant le kernel pour que ce kernel puisse etre vu comme C et recuperé par Pycuda
// il faut le no_extern_c=true dans l'option compilation, pour que curand_kernel qui est C++ puisse être compilé
//
//
extern "C" {
__global__ void counthits(int n, uint *hitsp, unsigned decalage... |
17,080 | #include <stdlib.h>
#include <stdio.h>
#include <cuda_runtime.h>
#define DATATYPE int
#define SMEMSIZE 1024
#define REP 128
//#define conflictnum 32
__global__ void global_broadcast(double *time,const DATATYPE *in1,const DATATYPE *in2,DATATYPE *out,int its, int conflictnum)
{
DATATYPE p,q=(threadIdx.x/conflictnum*con... |
17,081 | /*
* Filter.cpp
*
* Created on: 6 gru 2015
* Author: pSolT
*/
#include "Filter.cuh"
|
17,082 | #include <stdio.h>
#define CUDAERROR 6
int main(int argc, char** argv) {
cudaError_t i;
printf("cudaSuccess = %d\n", cudaSuccess);
printf("cudaErrorMemoryAllocation = %d\n", cudaErrorMemoryAllocation);
printf("cudaErrorLaunchTimeout = %d\n", cudaErrorLaunchTimeout);
return 0;
}
|
17,083 | #include <stdio.h>
#include <cuda_runtime.h>
#define block_size 8
#define N (1<<9)
#define tile_size 64
float* fillArray(float* arr)
{
//Seed rand()
srand(42);
for (int i = 0; i < N*N; i++)
{
arr[i] = rand() % 100;
}
return arr;
}
void printArray(float* arr)
{
for (int i = 0; i < N... |
17,084 | //
// Created by David Matthews on 5/21/20.
//
#include "../include/BoundingBox.cuh"
#include <iomanip>
std::ostream &operator<<(std::ostream &out, const BoundingBox &bb) {
return out << "((" << std::setprecision(3) << std::setw(8) << bb.x_min << " <-> " << std::setprecision(3)
<< std::setw(8) << b... |
17,085 | #include "includes.h"
__global__ void precalculateABC(float4* ABCm, float* M, float timestep, float alpha, unsigned int numPoints)
{
int me_idx = blockIdx.x * blockDim.x + threadIdx.x;
if (me_idx>=numPoints)
return;
float twodelta = timestep*2.0f;
float deltasqr = timestep*timestep;
float Mii = M[me_idx];
float Dii... |
17,086 | #include "includes.h"
__device__ float sigmoid(float x) {
return 1.0f / (1 + __expf(-x));
}
__global__ void sigmoidActivationBackprop(float* Z, float* dA, float* dZ, int Z_x_dim, int Z_y_dim) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
if (index < Z_x_dim * Z_y_dim){
dZ[index] = dA[index] * sigmoid(Z[index])... |
17,087 | // Berat Postalcioglu
/*OUTPUT
blocksPerGrid threadsPerBlock time to generate
------------- --------------- ----------------
157 256 0.04400000 ms.
79 512 0.05434880 ms.
40 1024 0.09233920 ms.
40000 1 ... |
17,088 | #include <stdio.h>
#include <stdlib.h>
#include "cuda_runtime.h"
#define THREADS_PER_BLOCK 32
#ifndef N
#define N 10
#endif
__global__ void matmul_two(float *A, float *B, float *C);
__global__ void matmul_one(float *A, float *B, float *C, int row);
void matmul_caller_two(float *A_dev, float *B_dev, float*C_dev, floa... |
17,089 | // Vector addition: C = A + B.
#include <stdio.h>
#include <cuda.h>
// CUDA Kernel Device code
// Computes the vector addition of A and B into C. The 3 vectors have the same
// number of elements numElements.
__global__ void
vectorAdd(const float *A, const float *B, float *C, int numElements)
{
// INSERT KERNEL CO... |
17,090 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <iostream>
struct GpuTimer
{
cudaEvent_t start;
cudaEvent_t stop;
GpuTimer()
{
cudaEventCreate(&start);
cudaEventCreate(&stop);
}
~GpuTimer()
{
cudaEventDestroy(start);
cudaEventDestroy(stop);
}
void Start(... |
17,091 | #include "includes.h"
__global__ void standard_kernel(float a, float *out, int iters)
{
int i;
int tid = (blockDim.x * blockIdx.x) + threadIdx.x;
if(tid == 0)
{
float tmp;
for (i = 0; i < iters; i++)
{
tmp = powf(a, 2.0f);
}
*out = tmp;
}
} |
17,092 | #include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <chrono>
#include <random>
#include <atomic>
#include <stdio.h>
#define NUM_STREAMS 2
using namespace std;
mt19937 rng;
random_device rd;
__managed__ int n, l, r, s;
class Particle
{
public:
operator string() const {
cha... |
17,093 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#define _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
__global__ void sum(float a, float b) {
int id = threadIdx.x;
//__shared__ float sdata[16];
}
int main()
{
float a[16];
for (int i = 0; i < 16; i++)
{
a[i] = i ... |
17,094 | #include "includes.h"
__global__ void zupdate2(float *z, float *f, float tau, int nx, int ny)
{
int px = blockIdx.x * blockDim.x + threadIdx.x;
int py = blockIdx.y * blockDim.y + threadIdx.y;
int idx = px + py*nx;
float a, b, t;
if (px<nx && py<ny)
{
// compute the gradient
a = 0;
b = 0;
float fc = f[idx];
if (!(px ==... |
17,095 | #include <iostream>
#include <stdlib.h>
#include <cmath>
#include <stdio.h>
int main (int argc, char* argv[]){
//variables
int matDim;
// get inputs
if (argc < 2){
std::cout << "Not enough arguments. <<matrix dimension>>" << std::endl;
return 1;
}
else{
matDim = atoi (argv [1]);
}
//create arra... |
17,096 | // Edge Version: Input Edge Stream
// 3 Kernels: Process only active edges in every iteration
#include<string.h>
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<fstream>
#include<sys/time.h>
#include<cuda.h>
//#include"common.h"
#define INF INT_MAX;
#define MAX_THREADS_PER_BLOCK 1024
#define PRINTFLAG... |
17,097 | #include<stdio.h>
__global__ void suma(int a, int b, int *c){
*c = a+b;
}
int main(void){
int c;
int *device_c;
cudaMalloc((void **)&device_c,sizeof(int));
suma<<<1,1>>>(2,7,device_c);
cudaMemcpy(&c, device_c, sizeof(int), cudaMemcpyDeviceToHost);
printf("2+7 = %d\n", c);
cudaFree(device... |
17,098 | #include "includes.h"
__global__ void conv_vertical_naive_gradInput(const int n, float *dx, const float *dy, const float *w, const int oH, const int oW, const int kL)
{
for (int i = blockIdx.x*blockDim.x+threadIdx.x; i < n; i += blockDim.x*gridDim.x) {
int iH = oH + kL - 1;
int iC = i/(iH*oW);
int row = (i%(iH*oW))/oW;... |
17,099 | #include <assert.h>
#include "cuda.h"
#include "cuda_runtime.h"
#include <stdio.h>
/*****************************************************/
/* CS149: ALL OF YOUR CODE SHOULD GO IN THIS FILE */
/*****************************************************/
// You can modify these parameters to match the image input size
#d... |
17,100 | //
// nvcc Blur.cu
// ./a.out Clown.256.ppm - original imge
// other Clown images are blurred with 2 different kenrel values
#include <stdio.h>
#define CHANNEL 3
#define N 1000
struct PPMImage {
int width;
int height;
unsigned int bytes; //amount if bytes, as each pixel in 3 colors
unsigned char *ima... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.