serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
19,201 | #include<stdio.h>
__global__ void hellofromGPU(void)
{
printf("hello world \n");
}
int main(void)
{
//printf("hello world from cpu \n");
hellofromGPU <<<1,10>>>();
cudaDeviceReset();
return 0;
}
|
19,202 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#define N (33*1024)
__global__ void add(int *a, int *b, int *c)
{
int tid = threadIdx.x + blockIdx.x * blockDim.x;
if (tid < N) {
c[tid] = a[tid] + b[tid]; // add as long as it is smaller than input vector.,
tid += gridDi... |
19,203 | #include "includes.h"
__global__ void mapPredicate(unsigned int *d_zeros, unsigned int *d_ones, unsigned int *d_in, unsigned int bit, size_t n)
{
int tx = threadIdx.x;
int bx = blockIdx.x;
int index = BLOCK_WIDTH * bx + tx;
if(index < n) {
unsigned int isOne = (d_in[index] >> bit) & 1;
d_ones[index] = isOne;
d_zeros[i... |
19,204 | #include "includes.h"
extern "C" {
}
/**
* CUDA Kernel Device code
*
* Computes the vector addition of A and B into C. The 3 vectors have the same
* number of elements numElements.
*/
typedef struct {
float *hA, *hB, *hC;
float *dA, *dB, *dC;
int element_count;
size_t vector_bytes;
int v_threadsPerBlock;
int v_block... |
19,205 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include <time.h>
__global__ void mem_transfer_test(int* input)
{
int grid_id = blockIdx.x * blockDim.x + threadIdx.x;
printf("thread ID: %d, grid ID: %d, value: %d\n", threadIdx.x, grid_id, inp... |
19,206 | /* CUDA matrix addition (C = A + B) where each thread is responsilbe for one
* element in matrix C
*/
#include <stdio.h>
#include <cuda.h>
#include <stdlib.h>
#include <math.h>
/* Generate two random matrices of dimension nxn with float precision. */
void matGen(float*, float*, int);
/* Adds two matrices of dimensio... |
19,207 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define TILE_WIDTH 2
__global__ void MatrixMulKernel(float* Md, float* Nd, float* Pd, int Width);
__global__ void sMatrixMulKernel(float* Md, float* Nd, float* Pd, int Width);
int main(void){
int width = 5;
//Allocate and initialize the matrices M, N, P
//I... |
19,208 | #include <stdio.h>
#include <cuda_runtime.h>
int main(int argc,char** argv){
return 0;
} |
19,209 | //
// CasAES_CUDA.c
// CasAES_CUDA
// Created by Carter McCardwell on 11/11/14.
// Modified by Niraj Surati Nov/5/2018
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <cuda_runtime.h>
const int Nb_h = 4;
const int Nr_h = 14;
const int Nk_h = 8;
const uint... |
19,210 | #include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
#define N 1024
__global__ void arraySum (float *d_a, float *d_b, float *d_c){
int tid = blockIdx.x * blockDim.x + threadIdx.x;
if (tid < N){
d_c[tid] = d_a[tid] + d_b[tid];
}
}
int main(){
float *h_a, *h_b, *h_c;
float *d_a, ... |
19,211 | #include "includes.h"
__global__ void ptr2ind_kernel(const int64_t *ptr_data, int64_t *out_data, int64_t E, int64_t numel) {
int64_t thread_idx = blockDim.x * blockIdx.x + threadIdx.x;
if (thread_idx < numel) {
int64_t idx = ptr_data[thread_idx], next_idx = ptr_data[thread_idx + 1];
for (int64_t i = idx; i < next_idx... |
19,212 | #include <stdio.h>
#include <stdlib.h>
__device__ int get_global_index(void) {
return blockIdx.x * blockDim.x + threadIdx.x;
}
__device__ int get_constant(void) { return 7; }
__global__ void kernel1(int *array) {
int index = get_global_index();
array[index] = get_constant();
}
__global__ void kernel2(int *arr... |
19,213 |
#define NUM_THREADS 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <cuda.h>
#include <sys/time.h>
//#include "qx_csbp_GPU.h"
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
//__constant__ int yshift;
//__constant__ i... |
19,214 | extern "C"
{
__global__ void alphaax_32(const int lengthC, const float alpha, const float *a, const float *b, float *c)
{
int i = threadIdx.x + blockIdx.x * blockDim.x;
if (i<lengthC)
{
c[i] = alpha*a[0]*b[i]; // REMEMBER ZERO INDEXING IN C LANGUAGE!!
}
}
} |
19,215 | /******************************************************************************
*cr
*cr (C) Copyright 2010-2013 The Board of Trustees of the
*cr University of Illinois
*cr All Rights Reserved
*cr
***************************************************************... |
19,216 |
#include <ctime>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
class Point
{
public:
float x = 0;
float y = 0;
int group = 1;
};
__device__
float getDistance(const Point& p1, const Point& p2)
{
float s = sqrt( pow( (p1.x - p2.x), 2)
+ pow( (p1.y - p2.y... |
19,217 | #include <cstdio>
#include <stdio.h>
#include <stdlib.h>
#define SIZE 1024*128*512
// int == 4byte
// 1GB 256 1kb
// 256 1024 1mb
// 256 1024 1024 1GB
__global__ void input(int *a, int *b)
{
int i=blockIdx.x*blockDim.x*512 + threadIdx.x*512;
int t=i+2048;
for(;i<t;i++)
{
a[i]=b[i];
}
}
int main(void)
{
... |
19,218 | #include <stdio.h>
////////////
// Notes:
//
// host: CPU + system's memory
// device: GPU + system's memory
/**
* A kernel is a function that executes on the device.
*
* __global__ alerts the compiler that a function should be compiled to run on
* a device instead of the host.
*
*/
__global__ void kernel(voi... |
19,219 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#define MAXPOINTS 1000000
#define MAXSTEPS 1000000
#define MINPOINTS 20
#define PI 3.14159265
void check_param(void);
__global__ void init_line(float*, float*, int);
__global__ void update (float*, float*, int, int);
void printfinal (void);
i... |
19,220 | #include <cstdio>
#include <cassert>
// #include "sixtracklib/sixtracklib.h"
#include <cuda_runtime_api.h>
#include <cuda.h>
// extern void run(double **indata, double **outdata, int npart );
__global__ void test( double* x, int npart )
{
if( npart > 0 )
{
printf( "numbers : %.8f\r\n", x[ 0 ] );
... |
19,221 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
__global__
void MyKernel()
{
printf("threadId[%u]=Hello World\n",threadIdx.x);
return;
}
int main()
{
MyKernel<<<1,1>>>();
printf("****Kernel launched****\n\n");
cudaDeviceSynchronize();
printf("\n****Kernel finished****\n");
return ... |
19,222 | #include "includes.h"
__global__ void scatterKernel( const unsigned int *d_In, const unsigned int *d_FalseKeyAddresses, unsigned int *d_Out, const unsigned int totalFalses, size_t size, unsigned int bitPos)
{
int threadsPerBlock = blockDim.x * blockDim.y;
int blockId = blockIdx.x + (blockIdx.y * gridDim.x);
int threa... |
19,223 | #include <sys/time.h>
#include <cuda.h>
#include <stdio.h>
#include <cuda_runtime_api.h>
// For the CUDA runtime routines (prefixed with "cuda_")
#include <cuda_runtime.h>
//#include <cuda.h>
//#include <helper_cuda.h>
// time stamp function in seconds
double getTimeStamp() {
struct timeval tv ;
gettimeofday( &tv, N... |
19,224 |
// CudafyIntroduction.Program
extern "C" __global__ void kernel();
// CudafyIntroduction.Program
extern "C" __global__ void add(int a, int b, int* c, int cLen0);
// CudafyIntroduction.Program
extern "C" __global__ void WriteHelloWorldOnGPU( unsigned short* c, int cLen0);
// CudafyIntroduction.Program
extern "C" __... |
19,225 | /*
// in is a 3 dimensional array on device such that one slice fits in a grid
// and there are fewer slices than threads per block
// y is a 3 dim output array on device of the same size as x
// adjoint is a boolean
__global__ void TV_Temp(cuDoubleComplex * x, cuDoubleComplex * y, int adjoint) {
if (adjoint == 1) ... |
19,226 | #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 mulM_kernel_cuda(double *d_matA,double *d_matB,double *d_matC, unsig... |
19,227 | /*
*
* Multiplicación de Matrices en CUDA
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <cassert>
#include <time.h>
//PP#include <cuda.h>
#define SHMEM_SIZE 32 * 32 * 4 // guardar en L1 256 float's
/* Utilidad para checar errores de CUDA */
void checkCUDAError(const char*);
// Kernel de multiplicación d... |
19,228 | #include <cuda.h>
#include <cufft.h>
#include <cuda_profiler_api.h>
#include <stdio.h>
template<typename T>
__device__ __forceinline__ T ldg(const T* ptr) {
#if __CUDA_ARCH__ >= 350
return __ldg(ptr);
#else
return *ptr;
#endif
}
#ifndef PI
#define PI 3.14159265359
#endif
extern "C"
__global__
void Shear(
float cen... |
19,229 | #include<stdio.h>
//#include "getAvgAndNorm.cu"
//TODO: Modify for larger dataset. For small dataset, actual no. of rows were greater than what was specified in the MovieLens website
#define ROWS 629
#define COLS 9000
char fileName[] = "./ratings_small.csv";
float ratings[ROWS][COLS];
float avg[ROWS];
float average[... |
19,230 | /* Geometric Convolution
* Original author: Shiyi Lan
* All Rights Reserved. 2019.
*/
#define get_square_euclidean_dist(x,y,z) \
((x)*(x)+(y)*(y)+(z)*(z))
#define _CUDA_NUM_THREADS 512
#define CUDA_KERNEL_LOOP(i, n) \
for (int i = blockIdx.x * blockDim.x + threadIdx.x; \
i < (n); \
i += bloc... |
19,231 | #include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include "bitonic_sorts.cuh"
#define TIME_TESTS 5
#define MAX_RAND 1000000
#define MAX_EXP 25
void generate_arr(int *arr, int n)
{
srand(time(NULL));
for (int i = 0; i < n; i++)
arr[i] = (rand(... |
19,232 | #include <fstream>
#include <iostream>
#include <string>
#include <cuda_runtime.h>
// Charge une matrice disponible dans les repertoires exemples
bool load_matrix(char * filename, float * &matrix, int &nx, int &ny){
std::string line;
std::ifstream infile(filename);
if (!infile.is_open()) {
std::cout << "Fi... |
19,233 | /***************************************************************************//**
* \file intermediateVelocity.cu
* \author Christopher Minar (minarc@oregonstate.edu)
* \brief kernels to generate the right hand side for the initial velocity solve
*/
#include "intermediateVelocity.h"
/**
* \namespace kernels
* \... |
19,234 | #include <iostream>
#include <stdio.h>
#include <stdlib.h>
#define BLOCK_SIZE 1024
#define MAX_MASK_WIDTH 5
#define TILE_SIZE 1024
__constant__ int M[MAX_MASK_WIDTH];
using namespace std;
__global__ void KernelConvolutionTile(int *N, int *P, int Mask_Width,int Width) {
int i = blockIdx.x*blockDim.x + threadIdx.x;
... |
19,235 |
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <iostream>
#define TILE_WIDTH 16
__global__ void sum_matrices(float *ma, float *mb, float *mc, int height, int width)
{
int row = blockIdx.y * blockDim.y + threadIdx.y; // linie
int col = blockIdx.x * blockDim.x + threadIdx.x; // coloana
... |
19,236 | #include <stdio.h>
#include <cuda.h>
__device__ int lockvar;
__global__ void k1() {
while (atomicCAS(&lockvar, 0, 1))
;
printf("Block %d, Thread %d is executing critical section.\n", blockIdx.x, threadIdx.x);
lockvar = 0;
}
int main() {
cudaMemset(&lockvar, 0, sizeof(int)); // lock initialization.
k1<<<64, 1>>>... |
19,237 | #include "includes.h"
__global__ void sumArraysOnGPU(float *A, float *B, float *C)
{
int i=blockIdx.x*COL+threadIdx.x;
//printf("[gpu]:gridDim.x=%u, gridDim.y=%u, gridDim.z=%u, blockDim.x=%u, blockDim.y=%u, blockDim.z=%u, blockIdx.x=%u, blockIdx.y=%u, blockIdx.z=%u,threadIdx.x=%u, threadIdx.y=%u, threadIdx.z=%u\n",
//g... |
19,238 | #include<stdio.h>
#define SIZE 10
#define BLOCKS 1
#define THREADS_PER_BLOCK 10
__global__ void oddevensort(int *in, int *out, int size)
{
bool oddeven=true;
__shared__ bool swappedodd;
__shared__ bool swappedeven;
int temp;
swappedodd=true;
swappedeven=true;
while(true)
{
if(oddeven==true)
{
printf(" ... |
19,239 | extern "C"
__global__ void backwardSquaredLossKernel (int batchSize, int numberInstancePerEntry, float *predictions, float *targets, float *result)
{
int indexInstance = blockIdx.x;
int startInstance = indexInstance * numberInstancePerEntry;
int indexEntryInInstance = threadIdx.x;
int indexEntryInBatc... |
19,240 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
//CUDA
#include <cuda.h>
double wtime(void)
{
static struct timeval tv0;
double time_;
gettimeofday(&tv0,(struct timezone*)0);
time_=(double)((tv0.tv_usec + (tv0.tv_sec)*1000000));
return( time_/1000000);
}
void... |
19,241 | extern "C"
/*
Pointer.to(gDots.iGA_Float[GPUDots.PX].gpuArray),
Pointer.to(gDots.iGA_Float[GPUDots.PY].gpuArray),
Pointer.to(gDots.iGA_Float[GPUDots.PZ].gpuArray),
// Blocks Properties
Pointer.to(iGA_arrayDotsIndexes.g... |
19,242 | // https://github.com/plops/cl-cpp-generator2/blob/2e2080e6e094f5d57ec518d1cc0b9b2d2a57e219/example/24_cuda_graph_launch/source/globals.h
#include <array>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <chrono>
#include <cstdio>
#include <thread>
#include <cuda.h>
#include <cuda_runtime.h>
enum... |
19,243 | #include <stdio.h>
#include <cuda_runtime_api.h>
__global__ void kernel()
{
printf("Hello, world!\n");
}
int main()
{
kernel<<<2,2>>>();
cudaDeviceSynchronize();
return 0;
} |
19,244 | __global__ void
add_bias(float *a, float *bias, float *out,
int size_x, int size_y, int size_z)
{
const int i = blockDim.y * blockIdx.y + threadIdx.y,
j = blockDim.x * blockIdx.x + threadIdx.x;
if (i < size_x && j < size_y)
{
int k = (i * size_y + j) * size_z;
for (i... |
19,245 | #include <stdio.h>
#include <sys/time.h>
__global__ void add(int*a, int*b, int*c)
{
c[blockIdx.x] = a[blockIdx.x] + b[blockIdx.x];
}
__global__ void fatorialAdd(int *a, int *b, int *c)
{
int i;
int maxA = a[blockIdx.x];
int maxB = b[blockIdx.x];
int fatA,fatB;
fatA = fatB = 1;
for(i = 0;i<fatA;i++)
fatA *= (... |
19,246 | #include "includes.h"
__global__ void __cumsumc(int nrows, int ncols, double *A, double *B) {
__shared__ double buff[32];
int i, j, k, lim;
double v, sum;
int icol = threadIdx.y + blockDim.y * blockIdx.x;
__syncthreads();
for (i = icol; i < ncols; i += blockDim.y * gridDim.x) {
sum = 0.0f;
for (j = 0; j < nrows; j += b... |
19,247 | #include "includes.h"
__device__ inline int getTransArrayIndex(unsigned int width, unsigned int height, unsigned int i) {
return height * (i % width) + i / width;
}
__global__ void kCopyToTransDestSlow(float* srcStart, float* destStart, unsigned int srcCopyWidth, unsigned int srcJumpWidth, unsigned int destJumpHeight, ... |
19,248 | //*****************************************************************************
//Projet HPC fusion et trie de tableaux sur GPU
//Auteur: ROBIN Clement et SAULNIER Solene
//Promo: MAIN5
//Date: decembre 2020
//Question 5 en sequentiel
//*****************************************************************************
#inc... |
19,249 | //
// Created by xiezheng on 2020/9/8.
//
#include <iostream>
#include <cuda_runtime.h>
#include "device_launch_parameters.h"
#include <sys/time.h>
#include <math.h>
#define ROWS 1024
#define COLS 1024
//extern "C"
//{
//
//}
using namespace std;
__global__ void Plus(float A[], float B[], float C[],int n)
{
int i ... |
19,250 | #include<cuda_runtime.h>
#include <device_launch_parameters.h>
#include<stdio.h>
#include<iostream>
__global__ void checkIndex(void) {
printf("threadIdx:(%d,%d,%d) blockIdx:(%d,%d,%d) blockDim:(%d,%d,%d) gridDim:(%d,%d,%d)\n",
threadIdx.x, threadIdx.y, threadIdx.z, blockIdx.x, blockIdx.y, blockIdx.z,
blockDim.x,... |
19,251 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
#include <fstream>
using namespace std;
__global__ void applyFilterGPU(int* in, int* out, int lines, int cols, int channels) {
int id = blockDim.x * blockIdx.x + threadIdx.x;
if (id < lines*cols*channels) {
... |
19,252 | #include "includes.h"
__global__ void matadd_1d(const float *a, const float *b, float *c, int n, int m){
int i = blockDim.x * blockIdx.x + threadIdx.x;
//处理m个数据相加
if(i < n){
for(int j = 0; j < m; j++){
int idx = j * n + i;
c[idx] = a[idx] + b[idx];
}
}
} |
19,253 |
#include <cuda_runtime.h>
#include <memory.h>
#include "custring.cuh"
namespace custr
{
// convert string with numerical characters to number
__device__ int stoi( const char* str, size_t bytes )
{
const char* ptr = str;
if( !ptr || !bytes )
return 0; // probably should be an a... |
19,254 | /*
* A simplified example of vector addition in CUDA to illustrate the
* data decomposition pattern using blocks of threads.
*
* To compile:
* nvcc -o va-GPU-simple VA-GPU-simple.cu
*/
#include <stdio.h>
// In this example we use a very small number of blocks
// and threads in those blocks for illustration
/... |
19,255 | #include "kernels.hh"
#include "ops.hh"
#include "../runtime/node.hh"
#include "simd_kernels.hh"
namespace cpu
{
namespace
{
void kernel_conv2d(rt::Node* node)
{
conv2d(node->in1, node->in2, node->out1, node->intconst,
node->int_cons1, node->int_cons2, node->s... |
19,256 | #include "includes.h"
__global__ void correctBounds(double *d_ub, double *d_lb, int nRxns, double *d_prevPoint, double alpha, double beta, double *d_centerPoint, double *points, int pointsPerFile, int pointCount, int index){
int newindex = blockIdx.x * blockDim.x + threadIdx.x;
int stride = blockDim.x * gridDim.x;
for... |
19,257 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <cstdio>
#include <cstdlib>
__global__ void unique_idx_calc_threadIdx(int* input)
{
int tid = threadIdx.x;
printf("threadIdx : %d, value: %d \n", tid, input[tid]);
}
__global__ void unique_gid_calculation(int* input)
{
int tid = threadId... |
19,258 | #include "CUDACOMPLEX.cuh"
#include <math.h>
//#include "cuda_runtime.h"
//#include "device_launch_parameters.h"
__host__ __device__ DataType ata(DataType x, DataType y)
{
if (x == 0.)
{
if (y == 0) return(0.);
else return(1.5707963268);
}
else return(atan2(y, x));
}
// square
__host__ __device__ DataType ... |
19,259 | #include "includes.h"
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
/////////////... |
19,260 | #include <cmath>
#include <cstdio>
#include <ctime>
#include <iostream>
__global__
void add(float *d_a, float *d_b, float *d_c, int num)
{
for (int ii = 0; ii < num; ++ii) {
d_c[ii] = d_a[ii] + d_b[ii];
}
}
int main(void)
{
std::clock_t start_time;
double duration;
const int ARR_SIZE = 1... |
19,261 | #include <cuda.h>
#include "cuda_runtime.h"
#include <iostream>
#include <chrono>
#include <stdio.h>
#include <sstream>
#define arraySize 31 //35 max
//#define W 1741
using namespace std;
__constant__ float coefs[arraySize*2+1];
__global__ void single_thread(float *sh_sum_dev,long int *str_num_dev, float num_of_bl... |
19,262 | #include <stdio.h>
__global__ void helloWorldFromGPU(void)
{
printf("Running on GPU: threadId (%d,%d) - blockId (%d,%d) - blockDim (%d,%d)\n",
threadIdx.x, threadIdx.y,
blockIdx.x, blockIdx.y,
blockDim.x, blockDim.y
);
}
int main(void)
{
printf("Hello World from CPU!\n");
hello... |
19,263 | // CUDA runtime
#include <cuda_runtime.h>
#include <cuda.h>
#include "cuda.h"
int __device__ min3(int a, int b, int c) {
return ((a) < (b) ? ((a) < (c) ? (a) : (c)) : ((b) < (c) ? (b) : (c)));
}
int __device__ levenshtein_cuda(char *s1, char *s2, int len, int *column) {
unsigned int x, y, lastdiag, olddiag;... |
19,264 | /*
This program will numerically compute the integral of
4/(1+x*x)
from 0 to 1. The value of this integral is pi -- which
is great since it gives us an easy way to check the answer.
The is the original sequential program. It uses the timer
from the OpenMP runtime library
History: Written by Tim Matt... |
19,265 | #include<time.h>
#include<chrono>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/sort.h>
#include <iostream>
#include<algorithm>
#include<random>
using namespace std;
using namespace std::chrono;
int Random(){
return rand();
}
float get_random_float()
{
static std::default_ran... |
19,266 | /**
* Configuration indexes.
*/
#define FILTERS_0 conf[0]
#define FILTERS_1 conf[1]
#define FILTERS_2 conf[2]
#define STRIDES_0 conf[3]
#define STRIDES_1 conf[4]
#define X_1 conf[5]
#define X_2 conf[6]
#define X_3 conf[7]
#define N conf[8]
#define Y_0 conf[9]
#define Y_1 conf[10]
#define Y_2 conf[11]
#define Y_3 conf... |
19,267 |
#include <cuda_runtime.h>
#include <iostream>
#include <iomanip>
#include <ctime>
#define N 65535
__global__ void vecadd(int *a, int *b, int *c) {
int id = blockIdx.x;
if (id < N)
c[id] = a[id] * b[id];
}
void add(int *a, int *b, int *c) {
for (int id=0; id < N; id++)
c[id] = a[id] * b[id];
}
/*
int main() ... |
19,268 | #include "includes.h"
__global__ void register_usage_test(int * results, int size)
{
int gid = blockDim.x * blockIdx.x + threadIdx.x;
int x1 = 3465;
int x2 = 1768;
int x3 = 453;
int x7 = 3465;
int x5 = 1768;
int x6 = 453;
int x4 = x1 + x2 + x3 + x7 + x5 + x6;
if (gid < size)
{
results[gid] = x4;
}
} |
19,269 | #include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <cuda.h>
#include <curand_kernel.h>
#include <math.h>
#define SHIFT 50
#define SCALE 5
#define ARRAY_SIZE 1000
#define BLOCK_SIZE 512
#define CUDA_CALL(ans) { GpuAssert((ans), __FILE__, __LINE__); }
inline void GpuAssert(cudaError_t co... |
19,270 | /*---------------------*- C++ 2D Incompressible FLow -*-----------------------*
| Solves the 2D incompressible Fluid Flow in 2D geometry |
| User Input is input.h File |
| This is the main file of the solver |
... |
19,271 | #include <stdio.h>
#include <cuda_runtime.h>
void checkCudaErrors(cudaError_t err, const char *userLabel)
{
if(cudaSuccess != err)
{
fprintf(stderr, "checkCudaErrors() Driver API error = %04d \"%s\" at user label \"%s\".\n", err, cudaGetErrorString(err), userLabel);
exit(EXIT_FAILURE);
}
}
int main(v... |
19,272 | //
// Simple cuda test code
//
__global__ void increment(int *a)
{
a[threadIdx.x] += 1; // b[threadIdx.x];
}
int main()
{
const int dataSize = 16;
int a[dataSize] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11,12,13,14,15,16};
// allocate work buffer
int *ad;
const int bufferSize = dataSize * sizeof(int);
cudaMalloc( ... |
19,273 |
#include<stdio.h>
#define BLOCK_DIM 1
#define N 16
__global__ void matmul(int *a, int *b, int *c, int width)
{
int k, sum=0;
int col=blockIdx.x*blockDim.x+threadIdx.x;
int row=blockIdx.y*blockDim.y+threadIdx.y;
if(col<width && row<width){
for(k=0;k<width;k++){
sum+=a[row*width+k]*b[k*width+col];
c[row*widt... |
19,274 | #include "includes.h"
__global__ void kDot_m1_m2T(const int nThreads, const float *m1, const float *m2, float *output, const int m1_columns, const int m2_rows ){
/* Updates the output matrix with the product of two matrices: m1 and m2 transposed.
Inputs:
m1: array, left matrix of size m1_rows x m1_columns
m2: array, r... |
19,275 | #include <math.h>
#include <iostream>
#include <chrono>
// CUDA kernel to add elements of two arrays
__global__
void add(int n, float *x, float *y)
{
printf("- ");
y[n] = std::sqrt(x[n]);
}
int main(void)
{
cudaError_t error = cudaGetLastError();
if (error != 0) {
std::cout << "ERROR: could not start program C... |
19,276 | #include "includes.h"
__global__ void sumMatrixOnGPU2D(float *A, float *B, float *C, int NX, int NY)
{
unsigned int ix = blockIdx.x * blockDim.x + threadIdx.x;
unsigned int iy = blockIdx.y * blockDim.y + threadIdx.y;
unsigned int idx = iy * NX + ix;
if (ix < NX && iy < NY)
{
C[idx] = A[idx] + B[idx];
}
} |
19,277 | #include<iostream>
#include <sys/time.h>
using namespace std;
const int threadsPerBlock = 512;
const int N = (1 <<20)-3;
const int blocksPerGrid = (N + threadsPerBlock - 1)/threadsPerBlock;
const int iters = 100;
__global__ void kernel1(float* arr, float* out, int N){
__shared__ float s_... |
19,278 | #include "includes.h"
// C++ 17 Includes:
// Project Includes:
// Defines:
__global__ void sum_dynamic_kernel(const int* pIn, int* pOut, size_t numInts)
{
extern __shared__ int ps[]; // Automatically points to our shared memory array
// Load shared memory:
ps[threadIdx.x] = pIn[threadIdx.x];
if (threadIdx.x + blockD... |
19,279 | #include <stdio.h>
// For this to compile U need to use option -arch=sm_20 for nvcc
__global__ void helloCUDA(float f)
{
printf("Hello from thread blockidx.x=%d threadidx.x=%d, f=%f\n", blockIdx.x, threadIdx.x, f);
}
int main()
{
helloCUDA<<<3, 5>>>(1.2345f);
cudaDeviceReset(); // Otherwise you might lose some ... |
19,280 | #include <cstdlib>
#include <iostream>
#include <time.h>
#include <cuda_runtime_api.h>
#include <stdio.h>
#define BLOCK_SIZE 16
#define NROW 1024
#define NCOL NROW
#define TEST_RESULTS
using namespace std;
//Input Array A
int inputArrayA [NROW][NCOL];
//Input Array B
int inputArrayB [NROW][NCOL];
//Output Arra... |
19,281 | /*
* EzRightUpdater.cpp
*
* Created on: 23 янв. 2016 г.
* Author: aleksandr
*/
#include "EzRightUpdater.h"
#include "SmartIndex.h"
/*
* indx должен пренадлежать участку от [0, sizeY-1]
*/
__device__
void EzRightUpdater::operator() (const int indx) {
int n = indx;
Ez(sizeX - 1, n) = coeff[0]*(Ez(sizeX -... |
19,282 |
/* Includes, system */
#include <stdio.h>
#include <cuda.h>
#include <cuda_runtime.h>
/* DEVICE CODE */
__global__ void suma_2_enteros(int *d1, int *d2, int *sum){
*sum = *d1 + *d2;
}
/* HOST CODE*/
int main(int argc, char** argv)
{
int DeviceCount = 0;
int h_d1,h_d2,h_sum;
h_d1 = 2; h_d2 = 3;
/*... |
19,283 | #include<iostream>
#include<cuda_runtime.h>
using namespace std;
bool InitCUDA()
{
int count;
cudaGetDeviceCount(&count);
if(count==0)
{
cout<<"there is no device"<<endl;
return 0;
}
int i;
for(i=0;i<count;i++)
{
cudaDeviceProp prop;
if(cudaGetDeviceProperties(&prop,i)==cudaSuccess)
{
if(prop.maj... |
19,284 |
// This function calculates the flux terms in the x-direction
__device__ void F(float F_vec[3], float U_vec[3], float bottomElevation)
{
float h = U_vec[0] - bottomElevation;
if (h <= 0.0f)
{
F_vec[0] = 0.0f;
F_vec[1] = 0.0f;
F_vec[2] = 0.0f;
} else {
F_vec[0] = U_vec[1];
F_vec[1] = (powf(U_vec[1], 2.0f)... |
19,285 | #include<cuda.h>
__device__ double devDiv(
const double c1,
const double e1,
const double c2,
const double e2,
const double c3,
const double e3,
... |
19,286 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#define N 4
#define thread_num 4
#define block_num 2
__global__ void prescan(float *g_odata, float *g_idata, int n);
void scanCPU(float *f_out, float *f_in, int i_n);
double myDiffTime(struct timeval &start, struct timeval &end)
{
double d_start, d_end;
... |
19,287 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <fstream>
#include <iostream>
class Student
{
public:
Student() {}
Student(std::string _name, int year, float grade, char gender)
: year(year), grade(grade), gender(gender)
{
strcpy(name, _name.c_str());
sprintf(c_year, "%d", year);
sp... |
19,288 |
#include <cuda_runtime.h>
#include <math.h>
static __device__ float sigmoid(float x){
return 1 / (1 + expf(-x));
}
static __global__ void myselu_kernel(const float* x, float* output, int n){
int position = threadIdx.x + blockDim.x * blockIdx.x;
if(position >= n) return;
output[position] = x[positio... |
19,289 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdint>
#include <map>
#include <fstream>
#include <vector>
#include <sstream>
#include <cmath>
#include <functional>
#include <set>
#include <ctime>
#define n 1024
#define T 256
using n... |
19,290 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#define N 1024
#define NUM_BANKS 16
#define LOG_NUM_BANKS 4
#ifdef ZERO_BANK_CONFLICTS
#define CONFLICT_FREE_OFFSET(n) ((n) >> NUM_BANKS + (n) >> (2 * LOG_NUM_BANKS))
#else
#define CONFLICT_FREE_OFFSET(n) ((n) >> LOG_NUM_BANKS)
#endif
__global__ vo... |
19,291 | #include "includes.h"
__global__ void channels_first(float* input, float* rinput, int channels, int height, int width, int pad_size)
{
// n (batch size), c (num of channels), y (height), x (width)
int n = blockIdx.x;
int y = blockIdx.y;
int x = blockIdx.z;
int ch_off = threadIdx.x;
float value;
int dimcyx = channels ... |
19,292 | // Author @ Eric Reinsmidt
// Date @ 2014.11.23
// Version 0.1
/*
Hi Eduardo, I've made an assumption in the code. I don't set the device using cudaSetDevice().
So, on a multi-GPU system this code will default to device 0, which is whatever
device is in the first slot. So please keep that in mind if testing on ... |
19,293 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <time.h>
#include <cuda.h>
#include <assert.h>
/* To save you time, we are including all 6 variants of the loop ordering
as separate functions and then calling them using function pointers.
The reason for having separate functions that are nea... |
19,294 |
#include <stdio.h>
void __global__ mean_pool(float* means, float *words, int *lengths,int *prevLengths, int numdocs, int dims)
{
int bid = blockIdx.x;
__shared__ float local_means[256];
for(int step = bid; step < numdocs; step += gridDim.x )
{
int wordsInDoc = lengths[step];
int blockStarts = pre... |
19,295 | /*
* cuda_utils.cu
*
* Created on: Feb 4, 2017
* Author: Yaison Alcantara
*/
namespace cs {
namespace gpu {
unsigned int BLOCK_SIZE_2D = 16;
unsigned int BLOCK_SIZE_1D = 256;
__global__ void kernel_matrix_mult(float* a, float* b, float* dest, unsigned int m, unsigned int n) {
unsigned int i = blockIdx.... |
19,296 | #include <stdio.h>
#define HANDLE_ERROR( err ) ( HandleError( err, __FILE__, __LINE__ ))
static void HandleError( cudaError_t err, const char *file, int line )
{
if (err != cudaSuccess)
{
printf( "%s in %s at line %d\n", cudaGetErrorString( err ),file, line );
exit( EXIT_FAILURE );
}
}
... |
19,297 | #include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <cuda_runtime.h>
using namespace std;
const int INF = 1000000000;
int n, m;
int* Dist = NULL;
void input(char* infile) {
FILE* file = fopen(infile, "rb");
fread(&n, sizeof(int), 1, file);
fread(&m, sizeof(int), 1, file);
/* hw4 */
... |
19,298 | #include <iostream>
#include <stdio.h>
#include <cuda.h>
#include <math.h>
using namespace std;
#define datafloat float
#define BDIM 1024
__global__ void partialSum(const int N,
datafloat* __restrict__ u,
datafloat* __restrict__ blocksum){
__shared__ datafloat s_blocksum[BDIM];
int t = threadIdx.x... |
19,299 | //advanced cuda system
//sped up algorithms
//dosMott5: like dosMott4 but with reduce instead of scan
/*
Code guide: first matrices are initialized. they are used to keep track of the particles, the probabilities to jump, the substrate, and the general electric potential.
Input parameters are also taken in. Current... |
19,300 | template<typename T>
class DeviceList
{
private:
T* objList;
size_t capacity;
size_t length;
__device__ void expand() {
capacity *= 2;
T* tempObj = new T[capacity];
for (size_t i = 0; i < length; i++) {
tempObj[i] = objList[i];
}
delete[] objList;
objList = tempObj;
}
public:
__device__ explicit ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.