serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
5,201 | #include "includes.h"
__global__ void xMinDeltaIntegralFracKernel( const float *intData, float *tmpArray, const int nWindows, const int h, const int w, const float *xMin, const float *yMin, const float *yMax, const float *inData, const int inDataStrideRow) {
int id = BLOCK_SIZE * BLOCK_SIZE * blockIdx.x + threadIdx.x;... |
5,202 | #include <device_functions.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <iostream>
#include <iomanip>
void calculate_cdf(const float* const d_logLuminance,
unsigned int* const d_cdf,
float &min_logLum,
floa... |
5,203 | #include "vector.cuh"
Vec::Vec(double x, double y, double z) {
this->x = x;
this->y = y;
this->z = z;
}
Vec Vec::operator+(const Vec &b) {
return Vec(x+b.x,y+b.y,z+b.z);
}
Vec Vec::operator-(const Vec &b) {
return Vec(x-b.x,y-b.y,z-b.z);
}
Vec Vec::operator*(double b) {
return Vec(x*b,y*b,... |
5,204 | #include <curand_kernel.h>
#define BlkSz 256 //NOTE: This was the best value for our machine even though it supports up to 1204 threads per block. You may try to change it to another value if it works better.
/*********************************/
//kernels for random number generation
/**************************... |
5,205 | #include "includes.h"
__global__ void Add_Im1_weight1_Im2_weight2_Kernel(float* output, const float* Im1, const float weight1, const float* Im2, const float weight2, const int width, const int height, const int nChannels)
{
int x = threadIdx.x + blockIdx.x * blockDim.x;
int y = threadIdx.y + blockIdx.y * blockDim.y;
i... |
5,206 |
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/sort.h>
#include <vector_types.h>
#include <cuda_runtime.h>
#include <cuda.h>
#include <iostream>
#include <vector>
#include <ctime>
#include <cmath>
//#include <QDebug>
#define PI 3.14159265359
using namespace std;
template<class T... |
5,207 | #define PG (4*1024)
#include <stdio.h>
int main(void)
{
int N = 2044*1024;
float *x, *d_x;
x = (float*)malloc(N*sizeof(float));
cudaMalloc(&d_x, N*sizeof(float));
for (int i = 0; i < N; i++) {
x[i] = 0;
}
cudaEvent_t start, end;
float time;
int current = 0;
cudaEventCreate(&start);
cudaEv... |
5,208 | // RunPuzzleParallel.cu
//
//
// Created by Joey Borowicz on 5/7/17.
//
//
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <iostream>
#include <string>
#include <sys/time.h>
#include <unistd.h>
#include <sys/types.h>
#include <cstdio>
#include <iostream>
using namespace std;
//Note: the first part ... |
5,209 | // a simple CUDA kernel to add two vectors
extern "C"
{
__global__ void vadd(const float *a, const float *b, float *c)
{
int i = threadIdx.x + blockIdx.x * blockDim.x;
c[i] = a[i] + b[i];
}
} // extern "C"
|
5,210 | // After accumulation, we need to renormalize the moments.
//
// 1. It shoudl be called with enough threads to cover all
// numChannels in the moments.
//
// 2. The actual number of blocks is determined based on the block
// size to satisfy condition (2).
__global__ void normalize_moments(float * moments,
... |
5,211 | #include "includes.h"
__global__ void kMult(float* a, float* b, float* dest, unsigned int numEls, 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 < numEls; i += numThread... |
5,212 | // C = A * B
const int TILE_SIZE = 16;
__global__
void matrixMultiplication(float* C, float* A, float* B, int rowsC, int colsC, int rowsA, int colsA, int rowsB, int colsB) {
__device__ __shared__ float ds_A[TILE_SIZE][TILE_SIZE];
__device__ __shared__ float ds_B[TILE_SIZE][TILE_SIZE];
const int tx = thr... |
5,213 | #include <stdio.h>
#include <math.h>
#ifdef _WIN64
#include <cufft.h>
#define PI_FLOAT 3.14159265358979323846264338327f
#define OUTPUT
//#define OUTPUT_GF
#define OUTPUT_CHARGE
//#define OUTPUT_CHARGE_FFT
//#define OUTPUT_CHARGE_FFT_GF
//#define OUTPUT_POTENTIAL
void displayDeviceProperties(cudaDeviceProp* pDevicePr... |
5,214 | #include <chrono>
#include <stdio.h>
#define GRID_DIM 8
#define BLOCK_DIM 256
#define ITERATIONS 1000000
using namespace std;
__global__ void kernel()
{
}
int main()
{
// Measure kernel invocation
chrono::high_resolution_clock::time_point start_time = chrono::high_resolution_clock::now();
for (int i =... |
5,215 | #include "includes.h"
__global__ void profileSubphaseFindAggregates_kernel() {} |
5,216 |
#include <stdio.h>
#include <stdlib.h>
__global__ void collateSegments_gpu(int * src, int * scanResult, int * output, int numEdges) {
/*YOUR CODE HERE*/
int i;
int tid = blockIdx.x * blockDim.x + threadIdx.x;
int total_threads = blockDim.x * gridDim.x;
for(i = tid; i < numEdges; i += total_threads){
if (src[i] != ... |
5,217 | #include "includes.h"
__global__ void update_density_rg_1_real_gpu_kernel(int size__, double const* psi_rg__, double wt__, double* density_rg__)
{
int ir = blockIdx.x * blockDim.x + threadIdx.x;
if (ir < size__) {
double p = psi_rg__[ir];
density_rg__[ir] += p * p * wt__;
}
} |
5,218 | #include<stdio.h>
#include<math.h>
#define fg 0.00001
#define fe 0.001
#define damp 0.0001
#define critical_factor 0
#define SCREEN_WIDTH 600
#define SCREEN_HEIGHT 600
#define STRONG_FORCE 0.001
const int BLOCK_SIZE = 1024;
// [self.x,self.y,self.z,self.vx,self.vy,self.vz,self.m,self.charge]
// 0 1 2 ... |
5,219 | #include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <limits>
#include <sys/time.h>
#define NUM_PARTICLES 1000000
#define NUM_ITERATIONS 1000
#define NUM_BATCHES 4 // MUST BE A DIVIDER OF NUM_PARTICLES
#define BLOCK_SIZE 200
#define STREAMS
#define MICROSECONDS(start, end) ((end.tv_sec - start.tv_sec... |
5,220 | #include <cuda_runtime.h>
#include <stdio.h>
/*
* This example demonstrates a simple vector sum on the GPU and on the host.
* sumArraysOnGPU splits the work of the vector sum across CUDA threads on the
* GPU. Only a single thread block is used in this small case, for simplicity.
* sumArraysOnHost sequentially iter... |
5,221 | #include <stdio.h>
#include <cuda_runtime.h>
#include <vector>
#include <iostream>
#define NUM_BANKS 32
#define LOG_NUM_BANKS 5
#define CONFLICT_FREE_OFFSET(n) ((n) >> NUM_BANKS + (n) >> (2 * LOG_NUM_BANKS))
#define NUM_THREADS 256
using namespace std;
// Exclusive prescan
// n - number of elements
__global__ void pr... |
5,222 | //
//#include <helper_math.h>
//#include <nvMatrix.h>
//#include "Constructor.h"
#include "cuda.h"
extern __device__ float4* d_cuda_construct_texture;
|
5,223 |
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <math.h>
using namespace std;
// CUDA KERNEL FUNCTIONS
__global__ void Hello()
{
//int globalidx = threadIdx.z * blockDim.x * blockDim.y + threadIdx.y * blockDim.x + threadIdx.x;
int globalidx = blockIdx... |
5,224 | /*
* UCLA Spring 2011
* CS239
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#define NUM_BANKS 16
#define LOG_NUM_BANKS 4
#define CONFLICT_FREE_OFFSET(n) ((n) >> NUM_BANKS + (n) >> (2 * LOG_NUM_BANKS))
#define NUM_BLOCKS 511
#define BLOCK_SIZE 512
__global__ void cuda_prefixsum... |
5,225 | #include "includes.h"
#define N 50
#define NewN 100
#define LifeN 500
#define numofthreads 512
int numofeles=0,capacity;
struct chromosome
{
long long weight=0, value=0;
bool chromo[100003];
};
chromosome chromoele[N],*cudaChromo,*cudaNewpopulation,newpopulation[NewN],res,x[2];
int weight[100001],value[100001],*devVa... |
5,226 | #include<stdio.h>
#include <curand.h>
#include <curand_kernel.h>
#include<stdlib.h>
__global__ void fxn(double *W, double *X, double *Y, double *b1, double *b2, double *h, double *Z, double *loss){
int N = gridDim.x, m = blockDim.x, n = m/2, T = 10;
int td = threadIdx.x, bd = blockIdx.x;
double lambda = 0.... |
5,227 | #include <iostream>
#include <cuda_runtime_api.h>
#include <chrono>
#define RAIO 10
#define TAMANHO 20
__constant__ float const_stencilWeight[10000];
// base case
__global__ void stencil(float *src, float *dst, int size, int raio, float *stencilWeight)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
idx +... |
5,228 | /*
* matrixop.c
*
* Created on: 201645
* Author: asus
*/
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "matrixop.cuh"
void matrixturn(double matrix[][BB], int height, int width,double turn[][BB]) {
int i = 0, j;
for (i = 0; i < width; i++)
for (j = 0; j < height; j++)
turn[i][j]... |
5,229 | #include <stdlib.h>
#include <stdio.h>
__global__ void makeAdjMat(int *csizes, int *cstarts, int *cases, int *adjMat, int matSize, int dataSize){
int my_case_idx,my_case_size,my_case_start,idx_inner,mat_pos,idx;
my_case_idx = blockIdx.x*blockDim.x + threadIdx.x;
if(my_case_idx < dataSize){
... |
5,230 | /* To run:
nvcc -Xptxas=dlcm=ca l2_peak_bandwidth.cu -o peak
nvprof ./peak
====
nvprof --print-gpu-summary ./peak
nvprof -m l2_read_throughput ./peak
nvprof -m l2_write_throughput ./peak
*/
# include <stdio.h>
# include <stdint.h>
# include "cuda_runtime.h"
__global__
void global_latency (unsigned int* a, uns... |
5,231 | // Ex. 2
// =====
// Remove the call to cudaDeviceReset()
//
// The result is: nothing is printed from the device to the shell.
#include <stdio.h>
__global__
void helloFromGPU() {
printf("Hello World from GPU!\n");
}
int main(int argc, char *argv[]) {
// Hello from CPU
printf("Hello World from CPU!\n");
hel... |
5,232 | /*
* Tanner Hoelzel
*/
#include <cassert>
#include <unistd.h>
#include <fcntl.h>
#include <cstdio>
#include <string>
void
swap(int &i) {
// Some of the & are superfluous.
i =
(0xff&(i >> 24)) |
(0xff00&(i >> 8)) |
(0xff0000&(i << 8)) |
(0xff000000&(i << 24));
}
int
read_int(int fd) {
... |
5,233 | // includes
#include <stdio.h>
#include <stdlib.h>
//-------------Funcion llenar los vecinos
void llenarVecinos(int * pmat, int row, int colum){
FILE *fichero;
int node=row*colum;
int i,j;
int nvec=9;
fichero = fopen("matriz_con_vecinos.txt","r");
if (fichero==NULL)
{
printf( "No se pued... |
5,234 | __global__ void BuildFrameIndex(float *a, float *b, float *c)
{
int index = threadIdx.x;
c[index] = a[index] + b[index];
}
|
5,235 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <iostream>
#include <chrono>
#include <memory>
using namespace std;
using namespace std::chrono;
#define IMUL(a,b) __mul24(a,b)
cudaError_t performJacobi();
struct cuda_deleter
{
void operator() (void * p) { cudaFree(p); }... |
5,236 | #include "includes.h"
/**
*
* Copyright (C) Tyler Hackett 2016
*
* CUDA Triangle Counter
*
* A quickly-written program to determine all possible combinations of
* valid triangles from a grid, allowing for certain coordinates of the
* grid to be marked as unusable.
*
* main.cu
*
* */
__global__ void countTriangles(ui... |
5,237 | #include <iostream>
#include <algorithm>
#include <chrono>
#include <cuda.h>
using namespace std;
__global__
void saxpy(size_t n, float alpha, float *a, float *b)
{
}
int main(int argc, char **argv)
{
size_t N = 1024;
float *a, *b, *res, *da, *db;
float alpha = 2.0f;
// Allocate and initialize vectors a and... |
5,238 | /*!
* \brief Record the basic usage of Transformations in Thrust.
* https://docs.nvidia.com/cuda/thrust/
* \Functor plus: +;
* minus: -;
* multiplies: *;
* equal_to: ==;
* less: <;
*/
#include <iostream>
#include "time.h"
// Thrust related
#include <thrust/device_vector.h>
... |
5,239 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
__global__ void onesc(int *A, int *B){
int ele = threadIdx.x, row=blockIdx.x, no_eles = blockDim.x, no_rows = gridDim.x;
if(row!=0 && ele!=0 && row!=no_rows-1 && ele != no_eles-1){
int cur = A[row*no_eles + ele];... |
5,240 | #include "includes.h"
__global__ void spmv_csr_vector_kernel(unsigned int computation_restriction_factor, const unsigned int* cum_row_indexes, const unsigned int* column_indexes, const float* matrix_data , const float* in_vector, float* out_vector, const unsigned int outerdim) {
__shared__ float vals[32];
int thread_id... |
5,241 | // source: http://cacs.usc.edu/education/cs596/src/cuda/pi.cu
// Using CUDA device to calculate pi
#include <stdio.h>
#include <cuda.h>
#include <getopt.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <curand_kernel.h>
#define TRIALS_PER_THREAD 1118481
#define BLOCKS 30 // Number of thread BLOC... |
5,242 | /*
ZWYKLE:
gcc test.c -o test
./test
CUDA:
test.cu
nvcc test.cu -o test
./test
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <cuda.h>
#include <cuda_runtime_api.h>
__global__
void funkcja_testowa(){
}
int main(){
funkcja_testowa<<<1,1>>>();
printf("CUDA error: %s\n", cudaGetErrorString(... |
5,243 |
/* This is a automatically generated test. Do not modify */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
__global__
void compute(float comp, int var_1,int var_2,float var_3,float var_4,float var_5,float var_6,float var_7,float var_8,float var_9,float var_10,float var_11,float var_12,float var_13,float va... |
5,244 | #define Dx 256
extern "C" {
__global__ void advance_src(int nx, int ny, int tn, double *f) {
int tid0 = nx/3 + (ny/2)*nx;
f[tid0] += sin(0.1*tn);
}
__global__ void advance(int nx, int ny, double *c, double *f, double *g) {
int tid = blockIdx.x*blockDim.x + threadIdx.x;
int i = tid%nx;
int j = tid/nx;
... |
5,245 | #include "includes.h"
__global__ void fupdate(float *f, float *z, float *g, float invlambda, 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 DIVZ;
if (px<nx && py<ny)
{
// compute the divergence
DIVZ = 0;
if (!(px == (nx - 1)... |
5,246 | /**
* @brief Basic addition.
*
* Here we do basic addition of two integers in a kernel for the
* GPU. For doing our first computation, we need to allocate and
* afterwards free memory on the GPU. The syntax to do this is very
* similar to what we use in C or C... |
5,247 | #include <stdlib.h>
#include <stdio.h>
__host__ void matrix_multiply_cpu(int n, float **a, float **b, float **c) {
int i, j, k;
float tc;
for (i=0; i<n; i++) {
for (j=0; j<n; j++) {
tc = 0;
for (k=0; k<n; k++) tc += a[i][k]*b[k][j];
c[i][j] = tc;
}
}
}
__global__ void matrix_multiply_gpu(int n, flo... |
5,248 | __global__ void process_kernel1 (float *input1, float *input2, float *output, int datasize ){
int blockNum = blockIdx.z * (gridDim.x * gridDim.y) + blockIdx.y * gridDim.x + blockIdx.x;
int threadNum = threadIdx.x * (blockIdx.x * blockDim.y) + threadIdx.y * blockDim.x + threadIdx.x;
int i = blockNum * (blockDim.x + b... |
5,249 | #include "includes.h"
__global__ void x6(float* x7, float* x8, float* x9, int x10) {
int x11 = gridDim.x * blockDim.x;
int x12 = threadIdx.x + blockIdx.x * blockDim.x;
while (x12 < x10) {
int x13 = x12;
x9[x13] = x7[x13] + x8[x13];
x12 = x12 + x11;
}
} |
5,250 | #include "includes.h"
__global__ void addtoall(int* a, int b)
{
int i = threadIdx.x;
atomicAdd(&(a[i]), b);
} |
5,251 | /*
* Copyright 2015 Netherlands eScience Center, VU University Amsterdam, and Netherlands Forensic Institute
*
* 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... |
5,252 | #include <iostream>
#define N (500*1024)
__global__ void add(int *a, int *b, int *c){
int tid = threadIdx.x + blockIdx.x * blockDim.x;
while(tid < N){
c[tid] = a[tid] + b[tid];
tid += blockDim.x + gridDim.x;
}
}
int main( void ){
int a[N], b[N], c[N];
int *dev_a, *dev_b, *dev_c;
// allocate memory ... |
5,253 | #include <CL/cl.h>
#include <iostream>
const char* source =
"__kernel void sum( __global float * input) \n"
"{ \n"
" int i = get_global_id(0); \n"
" input[i] = input[i] + i; \n"
"}";
const unsigned int SIZE = 1024;
int main() {
cl_int error = 0;
cl_uint num_platforms = 0;
clGetPlatformIDs(0, NULL, &... |
5,254 | #include<math.h>
#include<stdio.h>
const double EPSILON = 1.0e-15;
const double a = 1.23;
const double b = 2.34;
const double c = 3.57;
void __global__ add(const double *x, const double *y, double *z);
void check(const double *z, const int N);
int main() {
const int N = 100000000;
const int M = sizeof(doubl... |
5,255 | #include <stdio.h>
#include <iostream>
using namespace std;
__global__ void vec_add(float *A, float *B, float *C, int n_array){
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if(idx<n_array){
C[idx] = A[idx] + B[idx];
}
}
int main(){
int ngpus=2;
cudaGetDeviceCount(&ngpus);
print... |
5,256 | #include<stdio.h>
#include<assert.h>
#define N 10 //0000
#define NUM_THREADS 512
__global__ void transpose( double * d_A, double * d_AT )
{
int idx = threadIdx.x + (blockIdx.x * blockDim.x);
int idy = threadIdx.y + (blockIdx.y * blockDim.y);
if (idx<N){
if (idy<N){
d_AT[idx + idy*N] = d_A[idx*N + idy];
}
}
}
void ... |
5,257 | __global__
void sum_kernel(int n, const float *x, float *z) {
extern __shared__ float sdata[];
int offset = threadIdx.x * 256;
float total = 0;
for (int i = 0; i < 256; ++i) {
if (offset + i < n) {
total += x[offset + i];
}
}
sdata[threadIdx.x] = total;
__syncthreads();
if (offset == 0) {
float tt... |
5,258 | #include <stdio.h>
/**
* Kernel routine
*/
__global__
void matrixSync(int* a, int size) {
int id = threadIdx.x;
if(id<size*size/2) {
int i = id%size;
int j = 2*(id/size);
if(j+1!=size) {
int tmp = a[i*size+j+1];
a[i*size+j+1]=a[i*size+j];
a[i*size+... |
5,259 | #include <stdio.h>
const int m=20;
const int n=20;
const int p=5;
//m*n *n*p=m*p
__global__ void MatrixAdd_CUDA(int *A, int *B, int *C) {
int row = blockIdx.y * blockDim.y + threadIdx.y;
int col = blockIdx.x * blockDim.x + threadIdx.x;
int s ;
if(row<m && col<p){
s= 0;
... |
5,260 | __global__ void saveIDs(int *idsOut)
{
const int tid = threadIdx.x;
idsOut[tid] = tid;
}
|
5,261 | #include <stdio.h>
void question1() {
/*
latency of arithmetic instruction = ~10+ ns
GK110 SM (Kepler) has:
2 warp schedulers
4 warp dispatchers
2 * 4 * 10 = 80 arithmetic instructions required
*/
}
void question2() {
/*
block shape = (32, 32, 1)
a)
int idx = threadIdx.y + blockSize.y * thre... |
5,262 | // Simple CUDA example by Ingemar Ragnemalm 2009. Simplest possible?
// Assigns every element in an array with its index.
// nvcc simple.cu -L /usr/local/cuda/lib -lcudart -o simple
#include <stdio.h>
const int N = 16;
const int blocksize = 16;
__global__
void simple(float *c)
{
c[threadIdx.x] = sqrt(c[threadI... |
5,263 | #include "includes.h"
__global__ void cuda_Cal_X_minus_U_W(float *Y, float *U, float *X, int *Weight, int nRows, int nCols) {
unsigned int Tidx = threadIdx.x + blockIdx.x * blockDim.x;
unsigned int Tidy = threadIdx.y + blockIdx.y * blockDim.y, index;
float X_temp, U_temp, Y_temp;
if ((Tidx < nCols) && (Tidy < nRows))... |
5,264 | #include "includes.h"
__global__ void subgradinputAtomic(float *gradInput, float *gradOutput, int input_n, int input_h, int input_w, int kH, int kW, int dH, int dW)
{
// iterators
int xx, yy;
// output size
int output_w = (input_w - kW) / dW + 1;
int output_h = (input_h - kH) / dH + 1;
// compute offsets based on thr... |
5,265 | #include "includes.h"
__global__ void add(int *a, int *b, int *c)
{
c[blockIdx.x] = a[blockIdx.x] + b[blockIdx.x];
} |
5,266 | #if GOOGLE_CUDA
#define EIGEN_USE_GPU
__global__ void default_function_kernel0(const float* __restrict__ U, const float* __restrict__ K0, float* __restrict__ U0) {
float U0_local[1];
__shared__ float U_shared[128];
__shared__ float K0_shared[4];
for (int n_inner_outer = 0; n_inner_outer < 2; ++n_inner_outer) ... |
5,267 | #include <stdio.h>
__global__
void kernel(int *a, int N)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
int stride = blockDim.x * gridDim.x;
for (int i = idx; i < N; i += stride)
{
a[i] = a[i] * 2;
}
}
void init(int *a, int N)
{
for (int i = 0; i < N; ++i)
{
a[i] = 2;
}
}
int main(int a... |
5,268 | #include "includes.h"
__global__ void _kpolymap64(int n, double *k, double c, double d) {
int i = threadIdx.x + blockIdx.x * blockDim.x;
while (i < n) {
k[i] = pow(k[i] + c, d);
i += blockDim.x * gridDim.x;
}
} |
5,269 | #include "includes.h"
#define NUMBER_OF_BLOCKS 256
#define NUMBER_OF_THREADS 64
// ==========
// Macro taken from:
// https://stackoverflow.com/questions/14038589/what-is-the-canonical-way-to-check-for-errors-using-the-cuda-runtime-api
__device__ int getElementsPerUnit(int total, int number_of_units) {
int elements_p... |
5,270 | #include <iostream>
#include <math.h>
#include <stdio.h>
#include<stdlib.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <unistd.h>
#include <assert.h>
// #define GB 8
// #define MB 1
// #define KB 1
int main(int argc, char *argv[])
{
unsigned GB,MB,KB;
char *endptr;
fprintf(stdout, "Input %d arg... |
5,271 | #include<stdio.h>
#include<cuda.h>
#include<cuda_runtime.h>
__global__ void sumRandC(int* A, int* B, int m, int n, int k=1)
{
// m -> number of rows in A
// n-> number of columns in A
int id;
int blockId = blockIdx.x + blockIdx.y * gridDim.x + gridDim.x * gridDim.y * blockIdx.z;
int threadId = bloc... |
5,272 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
typedef unsigned long ulint;
typedef unsigned long long ulint64;
int banyakdata = 256000;
int dimensigrid = 2000;
int dimensiblok = 128;
void modexp(ulint a, ... |
5,273 | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <cuda.h>
#define N 8
// NRUNS should be < N.
#define NRUNS 2
#define NBLOCKS 2
// NTHREADS*NBLOCKS should equal N
#define NTHREADS (N/NBLOCKS)
// Also, NBLOCKS should equal NTHREADS.
// Sums an array.
__global__ void sum(int* g_idata, int* g_odata) {... |
5,274 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
//
__global__ void add(int *a, int *b, int *c) {
*c = *a + *b;
}
//
int main()
{
int a, b, c; // CPU
int *dev_a, *dev_b, *dev_c; // GPU
int size = sizeof(int); //
// GPU
cudaMalloc((void**)&dev_a,... |
5,275 | #include <stdio.h>
#include <assert.h>
#include <iostream>
#include <chrono>
// CUDA runtime
#include <cuda_runtime.h>
#include <curand.h>
template <int BLOCK_SIZE> __global__ void MatrixMulCUDA(float *C, float *A, float *B, int wA, int wB) {
// Block index
int bx = blockIdx.x;
int by = blockIdx.y;
... |
5,276 | #include <cuda.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#define N 5
void fillMatrix(float *h_A, int size);
void mult(float *h_B, float *h_C, float *h_A, int n);
void printVector(float *h_A, int size);
int main(int argc, char const *argv[]) {
// Input matrix h_B and input vector h_C
float *h_B ... |
5,277 | #include <string>
#include <stdio.h>
#include <fstream>
#include <sstream>
#include <iterator>
#include <iostream>
#include <chrono>
#include <ctime>
#include <cmath>
#include <cuda.h>
#include <iomanip>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
static void HandleError(cudaError_t err, const cha... |
5,278 | #include <iostream>
#include <vector>
#include <string>
#include <fstream>
using namespace std;
#define BLOCK_SIZE 1024
__global__ void countEntriesPartA(int *A, int *B, int size)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < size)
{
int range = A[i] / 100;
atomicAdd(&B[range], 1);
}
__syncthre... |
5,279 | #include "includes.h"
__global__ void KerInOutInterpolateTime(unsigned npt,double fxtime ,const float *vel0,const float *vel1,float *vel)
{
const unsigned p=blockIdx.x*blockDim.x + threadIdx.x; //-Number of particle.
if(p<npt){
const float v0=vel0[p];
vel[p]=float(fxtime*(vel1[p]-v0)+v0);
}
} |
5,280 | #include <cuda.h>
#include <stdio.h>
int const TILE_WIDTH = 2;
__global__
void TiledMatrixMulKernel(float *M, float *N, float *P, int Width)
{
__shared__ float Mds[TILE_WIDTH][TILE_WIDTH];
__shared__ float Nds[TILE_WIDTH][TILE_WIDTH];
int bx = blockIdx.x; int by = blockIdx.y;
int tx = threadIdx.x; int ty =... |
5,281 | #include <bits/stdc++.h>
#include <thrust/device_vector.h>
#include <thrust/inner_product.h>
#define cu_dot(x, y) thrust::inner_product((x).begin(), (x).end(), (y).begin(), 0)
using namespace std;
typedef thrust::device_vector<int> dvi;
struct cpu{
const bool nvcc = false;
};
struct gpu{
const bool nvcc = true;
... |
5,282 | #include<stdio.h>
#include<math.h>
#include <fstream>
#include <iostream>
#include <stdlib.h>
#include <cstring>
using namespace std;
// R1 source, R2 destination,R3 weight
void initMSTEdgeList(int *R1 , int *R2 , int *R3, int *indexArray , int *destinationVertexArray, int *weightArray, int vertices)
{
for(int v =... |
5,283 | #include <stdio.h>
#include <cuda_runtime.h>
#define blockSize 32
__global__ void matrixMul (float *A, float *B, float *C, int N) {
float sum = 0.0;
extern __shared__ float shared_A[];
const int tid = threadIdx.x;
const int row = blockIdx.x;
const int column = threadIdx.x;
int i, j;
// 矩阵分... |
5,284 | #include "includes.h"
__global__ void prelu_kernel(const float *input, float *output, int num_elem, int input_size, int fm_size, const float* gamma) {
int idx = threadIdx.x + blockDim.x * blockIdx.x;
if (idx >= num_elem) return;
if (input[idx] >= 0.0f) {
output[idx] = input[idx];
return;
}
int c = (idx % input_size) ... |
5,285 | /*
* Copyright 1993-2010 NVIDIA
* Corporation.
* All rights reserved.
*/
#include <stdio.h>
__global__ void mykernel( void ) {
}
int main( void ) {
mykernel<<<1,1>>>();
printf( "Hello, GPU World!\n" );
return 0;
}
|
5,286 | #include <time.h>
#include <cuda.h>
#include <stdio.h>
#define STOP 0
#define START 1
#define BLOCK_X 16
#define BLOCK_Y 16
extern "C" void chrono (int kind, float *time);
__global__ void kconvol (float *gpu_a, float *gpu_b, int pitch, int n) {
int ig, jg, lg, il, jl, ll;
__shared__ float la[(BLOCK_X+2)*(BLOCK_Y... |
5,287 | #include "includes.h"
__global__ void sum_kernel(float *g_odata, float *g_idata, int n)
{
// the size is determined by the host application
extern __shared__ float sdata[];
// access thread id
const unsigned int tid = threadIdx.x;
// access number of threads in this block
//const unsigned int num_threads = blockDim.... |
5,288 | #include "includes.h"
__global__ void misaligned_read_unrolled4(int* a, int* b, int *c, int size, int offset)
{
int i = blockIdx.x * blockDim.x * 4 + threadIdx.x;
int k = i + offset;
if (k + 3 * blockDim.x < size)
{
c[i] = a[k] + b[k];
c[i + blockDim.x] = a[k + blockDim.x] + b[k + blockDim.x];
c[i + 2* blockDim.x] = a... |
5,289 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <math.h>
#define COMMENT "Histogram_GPU"
#define RGB_COMPONENT_COLOR 255
#define HISTOGRAM_SIZE 64
typedef struct {
unsigned char red, green, blue;
} PPMPixel;
typedef struct {
int x, y;
PPMPixel *data;
} PPMImage;
__global__ void histo_kern... |
5,290 | /*
Name: Paul Talaga
Date: Dec 5, 2017
Desc: Program to add two arrays using the GPU
It uses multiple threads and multiple blocks, so this is
as fast it can go.
To compile this, d... |
5,291 | #include <iostream>
#include <numeric>
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <cooperative_groups.h>
/* INT_MAX < LONG_MAX < ULONG_MAX < LLONG_MAX < ULLONG_MAX*/
typedef unsigned vector_t;
typedef unsigned int histogram_t;
typedef int atomic_t;
... |
5,292 | #include "includes.h"
__global__ void callOperation(int *a, int *b, int x, int *res, int n)
{
int tid = blockDim.x * blockIdx.x + threadIdx.x;
if (tid < n) {
res[tid] = ((a[tid] * x) + b[tid]);
}
} |
5,293 | #include "includes.h"
//Alfred Shaker
//10-13-2015
// CUDA kernel
__global__ void vectorSum(int *a, int *b, int *c, int n)
{
//get the id of global thread
int id = blockIdx.x*blockDim.x+threadIdx.x;
//checks to make sure we're not out of bounds
if(id < n)
c[id] = a[id] + b[id];
} |
5,294 | #include "csr.cuh"
#include "cudaMacros.cuh"
#include <stdio.h>
template<unsigned int blockSize, unsigned int beh>
__device__ void warpReduce_mxn(volatile double *sdata, unsigned int tid_0) {
int i;
if (blockSize >= 64)
SUM_POSITIONS_H(beh, 32)
if (blockSize >= 32)
SUM_POSITIONS_H(beh, 16)
if (blockSize >= 16)
... |
5,295 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <chrono>
__global__ void add_OneBlockOneThread(int n, float *x, float *y)
{
for (int i = 0; i < n; i++)
y[i] = x[i] + y[i];
}
__global__ void add_OneBlockManyThreads(int n, float *x... |
5,296 | #include "includes.h"
__global__ void topp_initialization_kernel(bool* finished, int* sequence_length, int* word_ids, int* topp_id_val_buf, int* topp_offset_buf, const int batch_size, const int vocab_size, const int start_id)
{
int tid = threadIdx.x;
int bid = blockIdx.x;
if(bid == 0)
{
for(int i = tid; i < batch_size... |
5,297 | #ifndef _SUBTRACT_KERNEL_H_
#define _SUBTRACT_KERNEL_H_
#include <cuda_runtime.h>
#include <cuda.h>
#include <stdio.h>
template <typename T>
__global__ void subtractKernel(T * a, T * b, T * c, int n){
int index = threadIdx.x + blockIdx.x * blockDim.x;
if(index < n){
c[index] = a[index] - b[index];
... |
5,298 | //Copyright (c) 2018 ETH Zurich, Lukas Cavigelli
#include <cstdio>
#include <cmath>
extern "C" {
__global__ void changeDetectionFG_kernel(const float* __restrict__ input,
const float* __restrict__ prevInput,
float* __restrict__ ... |
5,299 | /*
CUDA C extends C by allowing the programmer to define C functions, called kernels, that, when called,
are executed N times in parallel by N different CUDA threads, as opposed to only once like regular C functions.
A kernel is defined using the __global__ declaration specifier and the number of CUDA threads that ex... |
5,300 | #include <iostream>
#include <chrono>
#include <inttypes.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include "arithmetic_test.cuh"
#include "cuda_call_checker.cuh"
__global__ void abs1(int* d_forabs){
int x_tid = threadIdx.x;
int y_tid = threadIdx.y;
int my_abs = x_tid - y_tid;
volatil... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.