serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
21,101 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <unistd.h>
#include <assert.h>
#include <string.h>
#ifdef CPUGPU_CU_
#define IMG_DIMENSION 32
#define N_IMG_PAIRS 10000
#define NREQUESTS 100000
#define N_STREMS 64
#define HIST_SIZE 256
typedef unsigned char uchar;
#define OUT
#define CUDA_CHECK... |
21,102 | #include "includes.h"
__global__ void gaussjordan(double *A, double *I, int nn, int i)
{
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threadIdx.y;
if ( x< nn && y < nn){
if (x < nn && y < nn){
if (x != i){
I[x*nn + y] -= I[i*nn + y] * A[x*nn + i];
if (y != i){
A[x*nn + y] -= A[i*nn ... |
21,103 | #include "includes.h"
/// Tile size used by the OptimizedMMKernel
#define TILE_SIZE 32
/// Naive matrix multiplication CUDA Kernel
/// Tiled 1D Shared Memory No Unrolling
/// Tiled 2D Shared Memory No Unrolling
/// Tiled 2D Shared Memory With Unrolling (4x4 Tile Size)
/// Tiled 2D Shared Memory With Unrolling (8x... |
21,104 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
cudaError_t addWithCuda(int *c, const int *a, const int *b, unsigned int size);
void doCudaComputation(int* input, int* output);
int doComputationOutput2(int input);
void rea... |
21,105 | extern "C" __global__ void vector_add(float* A, float* B, float* C)
{
int i = blockIdx.x;
C[i] = A[i] + B[i];
}
|
21,106 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cuda.h>
#include <cuda_runtime.h>
#define dT 0.2f
#define G 0.6f
#define BLOCK_SIZE 64
// Global variables
int num_planets;
int num_timesteps;
// Host arrays
float2* velocities;
float4* planets;
// Device arrays
float2* velocities_d;
float4* planet... |
21,107 | // #include <pycuda-helpers.hpp>
__global__ void copyDensity( double *cnsv, double *rho ){
int t_j = blockIdx.x*blockDim.x + threadIdx.x;
int t_i = blockIdx.y*blockDim.y + threadIdx.y;
int t_k = blockIdx.z*blockDim.z + threadIdx.z;
int tid = t_j + t_i*blockDim.x*gridDim.x + t_k*blockDim.x*gridDim.x*blockDim.y*gr... |
21,108 | #include <iostream>
#include <cuda_runtime.h>
#include <chrono>
#include <string>
#define N 13
//#define TRANSPOSED
typedef std::chrono::high_resolution_clock Clock;
int32_t matrixCGlobal[N][N];
int32_t matrixAGlobal[N * N] = {
14, 39, 117, 89, 111, 73, 79, 102, 52, 81, 123, 70, 39,
82, 29, 125, 85,... |
21,109 | //15co154 Yeshwanth R
//15co118 Goutham M
#include<stdio.h>
#include<cuda.h>
__global__ void addition(int *da_in ,int *db_in ,int *d_out){
int idx = blockIdx.x*5 + threadIdx.x;
int idy = blockIdx.y*5 + threadIdx.y;
int in = idx + idy*5;
d_out[in] = da_in[in] + db_in[in];
}
int main()
{
int ... |
21,110 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <random>
#include <sys/timeb.h>
#define BLOCK_SIZE 16
__global__ void Evolve(bool* field, float* scores, double b, int size, bool* next_field)
{
int row = blockIdx.y * blockDim.y + threadIdx.y;
int col = blockIdx.x * bloc... |
21,111 | #include "dev_ptr.cuh"
#include "device_error.cuh"
#include "cuda_runtime.h"
//template<class T>
//DevPtr<T>::DevPtr()
//{
//
//}
//template<class T>
//DevPtr<T>::DevPtr(const DevPtr& devPtr)
//{
// cudaFree(_data);
// _data = devPtr.Get();
// _size = devPtr.Size();
//}
//
//template<class T>
//DevPtr<T>& Dev... |
21,112 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <cuda.h>
#include <cuda_runtime.h>
// CUDA kernel, Each thread takes care of one element of c
__global__ void vecAdd(double *a, double *b, double *c, int n)
{
// Get global thread ID
int idx = blockIdx.x * blockDim.x + threadIdx.x;
... |
21,113 | //--------------------------------------------------------------------------
// Project:
// Select the least utilized GPU on a CUDA-enabled system.
// Insert into your code as desired.
//
// Prerequisites:
// Must have installed the CUDA toolkit.
// Must be running on a UNIX machine
//
// Independent testing info:
/... |
21,114 | #include "includes.h"
__global__ void Split(int * xi, bool * xb, size_t idxi, size_t idxb, size_t N, float threshold)
{
for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < N; i += blockDim.x * gridDim.x)
{
xb[(idxb)*N+i] = (((float)xi[(idxi-1)*N+i]) == threshold);
}
return;
} |
21,115 | // File: cudaGetDeviceProperties.cu
//
// Compiler Command:
// $ nvcc cudaGetDeviceProperties.cu -o cudaGetDeviceProperties
// Head files
#include <stdio.h>
#include <cuda_runtime.h>
// main function
int main(int argc, char **argv) {
printf("%s Starting...\n", argv[0]);
int deviceCount = 0;
cudaError_t ... |
21,116 | #include "includes.h"
__global__ void kern_ConvertBuffer(short* agreement, float* output, int size )
{
int idx = CUDASTDOFFSET;
float locAgreement = (float) agreement[idx];
if( idx < size )
{
output[idx] = locAgreement;
}
} |
21,117 | #include <stdlib.h>
#include <stdio.h>
#include <cuda.h>
#include <time.h>
#include <curand_kernel.h>
#define NUMBER float
#define precision "float"
#define Kernel_cycles 10000
#define Cycles 512
#define Cycles2 512
#define BLOCKS 8
#define THREA... |
21,118 | #include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <iostream>
#include <chrono>
int main() {
double stocks;
std::cin >> stocks;
thrust::host_vector<double> host;
for(int i =0; i < 2517; i++){
std::cin >> stocks;
host.push_back(stocks);
}
/* na linha aba... |
21,119 | #include "includes.h"
__global__ void cudaclaw5_update_q_cuda2(int mbc, int mx, int my, int meqn, double dtdx, double dtdy, double* qold, double* fm, double* fp, double* gm, double* gp)
{
int ix = threadIdx.x + blockIdx.x*blockDim.x;
int iy = threadIdx.y + blockIdx.y*blockDim.y;
if (ix < mx && iy < my)
{
int x_stride ... |
21,120 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define DIM 2 /* Two-dimensional system */
#define X 0 /* x-coordinate subscript */
#define Y 1 /* y-coordinate subscript */
#define START_TIMER \
cudaEvent_t start = cudaEvent_t(); \
cudaEvent_t stop = cudaEvent_t(); \
cudaEvent... |
21,121 | #include <iostream>
#include <cuda.h>
#include <cuda_runtime.h>
//#include <time.h>
//#include <cutil.h>
using namespace std;
# define r 40
# define M 1000 // number of items
# define N 90 // number of transactions
# define alpha 1 // represents the weight of the support in the first fitness function
# define Beta... |
21,122 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <math.h> // for pow()
#define NUM_THREADS 8
#define NUM_BLOCKS 1
__host__ void generate_rand_data(unsigned int * data, unsigned int num_elements)
{
for(unsigned int i=0; i < num_elements; i++)
{
data[i] = rand() % 4; //PLACE YOUR CODE HERE
}
}
_... |
21,123 | /**
* 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 use, reproduction, disclosure, or distribution of
* this software and relate... |
21,124 | #include <cuda.h>
#include <stdio.h>
#include <stdlib.h>
#define BLOCK_WIDTH 2
void fillMatrix(float *A, int A_height, int A_width);
void printMatrix(float *A, int A_height, int A_width);
void tiledMat(float *A, float *result, int A_width, int A_height);
int main(int argc, char const *argv[])
{
// Create mat... |
21,125 | #include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#include <sys/time.h>
#include <time.h>
#include <cuda.h>
#include <math.h>
#include <curand.h>
#include <curand_kernel.h>
#include <cuda_runtime.h>
#include <thrust/host_vector.h>
#include <iostream>
#include <thrust/device_vector.h>
using ... |
21,126 | #include <stdio.h>
#include <stdlib.h>
#define THREADSIZE 100
#define BLOCKSIZE 65536
__global__ void demo(int * p){
int tx=threadIdx.x;
int bx=blockIdx.x;
int thid = tx+bx*blockDim.x;
p[thid]=thid;
if(thid<10){
printf("%d elements is %d\n",thid,p[thid]);
}
}
int main(int argc , char **argv){
int * p;
cuda... |
21,127 | #include <cuda.h>
#include <stdio.h>
#define N (32)
#define BLOCK (8)
__global__
void
matrixFill(float *matrix) {
const int x = threadIdx.x + blockDim.x*blockIdx.x;
const int y = threadIdx.y + blockDim.y*blockIdx.y;
const int i = N*y + x;
matrix[i] = blockIdx.y;
}
int
main(void) {
float h_matrix[N][N];
... |
21,128 | #include <cuda.h>
#include <stdio.h>
#include <stdint.h>
// For comparisons
//#include "seqScan.c"
__device__ int sklansky(int i, float* input0, float *output0, uint8_t *sbase,float *maxs) {
uint32_t t2 = ((blockIdx.x*32)+((threadIdx.x&4294967294)|(threadIdx.x&1)));
uint32_t t9 = ((threadIdx.x&4294967292)|... |
21,129 | #include <stdio.h>
__global__ void myKernelThatAdds(int *a, int *b, int*c, int n) {
/* global keyword is called from host (CPU) and
is executed on device (GPU).
We use pointers for the variable inputs
since the kernel runs on the device, and so the
variables must point to memory.*/
printf("adding...\n");
// ... |
21,130 | // Tiled dense matrix multiplication routine using shared memory
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <cuda.h>
#include <cuda_runtime.h>
#define TILE_WIDTH 16
void checkCUDAError(const char *msg);
// Matrix multiplication
__global__ void matrix_multiply(float *a, flo... |
21,131 | #include "includes.h"
__device__ int GetVecIndex(int vecNumber, int dimCount, int *dimSizes, int measCount, int vecCount, int *dims)
{
unsigned long int index = 0;
for (int i = 0; i < dimCount; ++i)
index += (unsigned long int)dimSizes[i] * (unsigned long int)dims[i * vecCount + vecNumber];
return index;
}
__global__... |
21,132 | #include "includes.h"
__global__ void pow_array_gpu(float *a, int power, int array_size)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
float result=1;
if (idx<array_size)
{
for(int i=0; i<power; ++i)
result*=a[idx];
a[idx] = result;
}
} |
21,133 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
// CUDA kernel. Each thread takes care of one element of c
__global__ void vecAdd(double *a, double *b, double *c, int n)
{
// Get our global thread ID
int id = blockIdx.x*blockDim.x+threadIdx.x;
// get global index
// Make sure we do not go out of bounds
if (id ... |
21,134 | // Source: http://docs.nvidia.com/cuda/curand/index.html
#include <thrust/iterator/counting_iterator.h>
#include <thrust/functional.h>
#include <thrust/transform_reduce.h>
#include <curand_kernel.h>
#include <iostream>
#include <iomanip>
// we could vary M & N to find the perf sweet spot
struct estimate_pi :
p... |
21,135 | #include <iostream>
#include <cmath>
#include <chrono>
#define N 256
using namespace std;
using namespace std::chrono;
__global__ void ArraySum(float *array, float *sum){
int index = threadIdx.x + blockIdx.x * blockDim.x;
if(index < N){
atomicAdd(sum, array[index]);
}
}
__global__ void revisedArra... |
21,136 | __global__ void sum_kernel(float *g_odata, float *g_idata, int N)
// Naive kernel
{
// YOUR TASKS:
// - Write a naive kernel where parallel sum reduction is done on a per block basis
// and reduction sum is returned in g_odata.
// - For simplicity, assume kernel only considers a dataset within each block of size... |
21,137 | //#include "cuda_runtime.h"
//#include "device_launch_parameters.h"
//#include "device_functions.h"
//
//#include <opencv2/core/core.hpp>
//#include <opencv2/highgui/highgui.hpp>
//#include <opencv2/core/cuda.hpp>
//
//
//#include <stdio.h>
//#include <iostream>
//#include <math.h>
//#include <vector>
//
//using namesp... |
21,138 | /*
* Hello world cuda
*
* compile: nvcc hello_cuda.cu -o hello
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <cuda.h>
__global__
void cuda_hello(){
// thread id of current block (on x axis)
int tid = threadIdx.x;
// block id (on x axis)
int bid = blockIdx.x;
prin... |
21,139 | //note: please do not modify this file manually!
// this file has been generated automatically by BOAST version 0.99996
// by: make boast_kernels
/*
!=====================================================================
!
! S p e c f e m 3 D G l o b e V e r s i o n 7 . 0
! --------------... |
21,140 | /******************************************************************************
* File: gpgpuPrimes.cu
*
* Authors: Savoy Schuler
*
* Date: November 2, 2016
*
* Functions Included:
*
* gpuProperties
* countPrimes <kernel>
* isPrime <kernal>
* gpgpuSearch
*
* Description:
*
* This files contains all functions need... |
21,141 | /* Daniel Willen, 2019
*
* Solve the transient heat conduction problem with homogeneous Dirichlet
* boundary conditions:
*
* u(x={0,L}) = u(y={0,L}) = 0
*
* and initial condition:
*
* u(x,y,0) = sin(x) * sin(y)
*
* on the domain 0 <= x,y <= L, with L = pi.
*
* This program solves the above problem... |
21,142 | #include "includes.h"
__global__ void FilmGradeKernelD( float* p_Input, float* p_Output, int p_Width, int p_Height, float p_Pivot, int p_Display) {
const int x = blockIdx.x * blockDim.x + threadIdx.x;
const int y = blockIdx.y * blockDim.y + threadIdx.y;
float height = p_Height;
float width = p_Width;
float X = x;
float... |
21,143 | /*
hello world : add two vectors
*/
#include <stdio.h>
/* ceiling `m' to `n' (returns the smallest `A' such n*A is not less
than `m') */
#define ceiln(m, n) ( ((m) + (n) - 1)/(n) )
/* a common kernel execution configuration */
#define k_cnf(n) ceiln((n), 128), 128
#define n 5 /* number of elements */
flo... |
21,144 |
/* 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* ... |
21,145 | #include <stdio.h>
#include <sys/time.h>
#include <cuda.h>
const int THREADS = 512;
static void CudaTest(const char *msg)
{
cudaError_t e;
cudaDeviceSynchronize();
if (cudaSuccess != (e = cudaGetLastError())) {
fprintf(stderr, "%s: %d\n", msg, e);
fprintf(stderr, "%s\n", cudaGetErrorString(e));
exit... |
21,146 | #include <cuda.h>
#include <cuda_runtime.h>
#include <time.h>
#include <algorithm>
#include <iostream>
#include <cuda_fp16.h>
using namespace std;
#define N 32 * 1024 * 1024
// elementwise implementation copyed from https://github.com/Oneflow-Inc/oneflow/blob/master/oneflow/core/cuda/elementwise.cuh
constexpr int kBlo... |
21,147 | // Output of "python3 circuit2.py prefix_sum.crc" is pasted in as the kernel
// along with some boilerplate code to test this out.
// Expected output: "0 1 3 6 10 15 21 28\n".
#include <iostream>
__global__ void kogge_stone(int *x0, int *x1){
int tid = threadIdx.x;
x1[tid] = x0[tid];
switch(tid){
... |
21,148 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <cuda.h>
// Thread block size
#define BLOCK_SIZE 64
// Size of Array
#define SOA 512
// Allocates an array with random integer entries.
void randomInit(int* data, int size)
{
for (int i = 0; i < size; ++i)
data[i] = rand()%size;
... |
21,149 | //#include "opencv2/highgui/highgui.hpp"
//#include <cstdio>
//#include <time.h>
//#include <sstream>
//#include <iostream>
//
//using namespace cv;
//using namespace std;
//
//#define MAX_THREADS_BY_BLOCK 1024
//#define DIM_BLOCK_X 32
//#define DIM_BLOCK_Y 32
//
//__device__ int cuGPos(int y, int x, int cuCols) {
// r... |
21,150 | #include "matrix.cuh"
__device__ matrix_t* device_matrix_constructor(buffer_t* buffer, unsigned int rows, unsigned int cols)
{
//assert(rows > 0 && cols > 0);
matrix_t* m = (matrix_t*)buffer_malloc(buffer, sizeof(matrix_t) + sizeof(float) * rows * cols);
m->rows = rows;
m->cols = cols;
device_set_matrix(m, 0.0... |
21,151 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
//#include "cuda_common.cuh"
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstring>
__global__ void sum_array_gpu(int* a, int* b, int* c, int size)
{
int gid = blockIdx.x * blockDim.x + threadIdx.x;
if (gid < size) {
c[... |
21,152 | #include <iostream>
#include <stdio.h>
#include <ctime>
#define BLOCK_SIZE 256
#define MAX_FLOAT 1.0e+127
#define WARP_SIZE 32
#define DEBUG
#ifdef DEBUG
#define cudaCheckError(ans) { cudaAssert((ans), __FILE__, __LINE__); }
inline void cudaAssert(cudaError_t code, const char *file, int line, bool abort=true)
{
if... |
21,153 | #include "includes.h"
__global__ void weight_update( int* postsyn_neuron, bool* neuron_in_plasticity_set, float* current_weight, float* weight_divisor, int* d_plastic_synapse_indices, size_t total_number_of_plastic_synapses){
// Global Index
int indx = threadIdx.x + blockIdx.x * blockDim.x;
while (indx < total_number... |
21,154 | #include "includes.h"
__global__ void mat_transpose_regular_kernel(int *mat, int *res) {
// Square tile
int tile_dim = 32;
// 32 Blocks across for 1024 mat
int blocks_per_row = 32;
int rows_per_block_iter = 64;
// Each iter has 2 "block-rows"
for (int block_iter = 0; block_iter < 16; block_iter++) {
int tile_row = blo... |
21,155 | extern "C"
__global__
void saxpy2(float a, float *x, float *y, float* r, unsigned int n)
{
for (int i = blockIdx.x * blockDim.x + threadIdx.x;
i < n;
i += blockDim.x * gridDim.x)
{
r[i] = a * x[i] + y[i];
}
} |
21,156 | #include "includes.h"
using namespace std;
/*** Definitions ***/
// Block width for CUDA kernels
#define BW 128
#define RANDOM_SEED -1
#ifdef USE_GFLAGS
#ifndef _WIN32
#define gflags google
#endif
#else
// Constant versions of gflags
#define DEFINE_int32(flag, default_value, description) const int FLAGS_##flag ... |
21,157 | extern "C"
__global__ void setValue_kernel()
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
}
|
21,158 | #include <stdio.h>
#include <time.h>
#define N 100000000
#define THREADS_PER_BLOCK 512
__global__ void gpu_block_add(int *a, int *b, int *c)
{
c[blockIdx.x] = a[blockIdx.x] + b[blockIdx.x];
}
__global__ void gpu_thread_add(int *a, int *b, int *c)
{
c[threadIdx.x] = a[threadIdx.x] + b[threadIdx.x];
}
__global__ ... |
21,159 | #include "3d-test.cuh"
#include<iostream>
#include<stdio.h>
__host__ __device__
void scalingFunction(int array[]) {
for(int i=0; i<8; i++) {
array[i] = array[i] * 2;
}
}
__host__ __device__
void distributeFunction(int array[],int x,int y){
pencilComputation p2;
for(int z=0... |
21,160 | //#pragma comment (lib, "cublas.lib")
//#include "stdio.h"
//#include <cuda.h>
//using namespace std;
//#include <ctime>
//#include "cuda_runtime.h"
//#include "curand_kernel.h"
//#include "device_launch_parameters.h"
//#include <stdio.h>
//#include <stdlib.h>
//
//#include <string>
//#include <iomanip>
//#include <tim... |
21,161 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
extern "C" {
void * alloc_gpu_mem( size_t N)
{
void*d;
int size = N *sizeof(float);
int err;
err = cudaMalloc(&d, size);
if (err != 0) printf("cuda malloc error: %d\n", err);
return d;
}}
// see kernels.cu for launch_kernel functions
extern "C" {
vo... |
21,162 | #include "includes.h"
__device__ unsigned int shared_reduce(unsigned int p, volatile unsigned int * s) {
// Assumes values in 'p' are either 1 or 0
// Assumes s[0:31] are allocated
// Sums p across warp, returning the result. Suggest you put
// result in s[0] and return it
// You may change any value in s
// You should... |
21,163 | /*
Matthew Dempsky
Public domain.
Derived from public domain code by D. J. Bernstein.
*/
// Modified very slightly for ZeroTier One by Adam Ierymenko
// This code remains in the public domain.
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
//#include "Constants.hpp"
#include "C25519.cuh"
#include "sha5.... |
21,164 | __global__ void kGauss( double * Y, const double * x, const double * w, const int K )
{
int idx = threadIdx.x + blockIdx.x * blockDim.x;
double y = Y[idx];
Y[idx]=0;
for(int i=0; i<K; ++i)
Y[idx] += w[i]*exp(-(y-x[i])*(y-x[i]));
}
|
21,165 | #include "includes.h"
/*
sergeim19
April 27, 2015
Burgers equation - GPU CUDA version
*/
#define NADVANCE (4000)
#define nu (5.0e-2)
__global__ void kernel_rescale_u(double *u_dev, int N)
{
int j;
j = blockIdx.x * blockDim.x + threadIdx.x;
u_dev[j] = u_dev[j] / (double)N;
} |
21,166 | void __global__ loadee(int *output)
{
int tid = threadIdx.x + blockIdx.x * blockDim.x;
output[tid]=tid;
}
|
21,167 | #include<cuda.h>
#include<cuda_runtime.h>
#include <stdio.h>
#define CONFIG_MASK_SIZE 32
#define CONFIG_IMAGE_WIDTH 640
#define CONFIG_IMAGE_HEIGHT 480
#define CONFIG_IMAGE_CHANNEL 3
#define CONFIG_COMPUTE_COUNT 10000
template <int BLOCK_SIZE, int MASK_SIZE, int CHANNELS>
__global__ void WatermarkKernel(
con... |
21,168 | #include "includes.h"
__global__ void addTwoArrays(int *v1, int *v2, int *r, int n)
{
int tid = blockIdx.x * blockDim.x + threadIdx.x;
if (tid >= n) {
return;
}
r[tid] = v1[tid] + v2[tid];
} |
21,169 | #include <iostream>
// Virtual grid dimensions :
//
// 20 000 * 20 000
// 20 blocks, 20 threads
// 2 000 cells/thread
//
// Matrix dimensions :
//
// 20*20 Matrix
// Virtualized as a 400 cells array (20 * 20)
// Each cell of the matrix has 2 000 virtual cells
//
// Algorithm used to get a position into the thread gri... |
21,170 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#define B 64
#define threadNum 32
const int INF = 1000000000;
void input(char *inFileName);
void output(char *outFileName);
void block_FW();
int ceil(int a, int b);
__global__ void phase1(int* dist, int Round, int n, size_t pitch);
__global__ void phase2(int* ... |
21,171 | #define X_BLOCK 1024
#define PITCH 1024
extern "C"
__global__ void MRDWT(float *constant,float *input4,float *result0){
result0[(((blockIdx.y*PITCH)+(blockIdx.x*X_BLOCK))+threadIdx.x)] = ((((((((((((((((((((((((input4[(threadIdx.x+(blockIdx.x*X_BLOCK))]*9.0)+(input4[(((threadIdx.x+(blockIdx.x*X_BLOCK))+1)%1024)... |
21,172 | __global__ void init_i32 (int* vector, int vector_ld, int value, int rows, int cols) {
int row = blockIdx.x * blockDim.x + threadIdx.x;
int col = blockIdx.y * blockDim.y + threadIdx.y;
if (row < rows && col < cols) {
vector[row+col*vector_ld] = value;
}
}
extern "C" {
void VectorFragment_init_i32 (int* vector, int... |
21,173 | #include "includes.h"
#define BLOCK_SIZE 512
#define BLOCK_SIZE_HOUGH 360
#define STEP_SIZE 5
#define NUMBER_OF_STEPS 360/STEP_SIZE
// Circ mask kernel storage
__constant__ int maskKernelX[NUMBER_OF_STEPS];
__constant__ int maskKernelY[NUMBER_OF_STEPS];
// Function to set precalculated relative coordinates for circl... |
21,174 | //
// Created by pierfied on 10/5/20.
//
#include "wigner.cuh"
// Compute the log factorial via the gamma function.
__device__ double lnfac(double x) {
return lgamma(x + 1);
}
// Compute the recursion seed for the case d(j, -j, m, beta).
__device__ double emmRecursionSeed(double j, double m, double beta) {
d... |
21,175 | #include "includes.h"
__global__ void sharedSum(int N, float *input, float *output){
int i = blockIdx.x * blockDim.x + threadIdx.x;
if(i >= N) return;
__shared__ float tmp[BLOCK_SIZE];
memset(tmp, 0, sizeof(tmp));
float a = input[i];
for(int j=0;j<BLOCK_SIZE;++j){
atomicAdd(tmp + j, a);
}
__syncthreads();
output[blockD... |
21,176 | #include <cuda.h> //required for CUDA
#include <curand_kernel.h>
#include <time.h>
#include <limits.h>
#include <iostream>
#include <fstream>
#include <math.h>
#include <cassert>
#include <stdlib.h>
#include <string>
#include <sstream>
#include <vector>
using namespace std;
#define MAX_N_TERMS 10
__global__ void MC... |
21,177 | /* Matrix Multiplication AX+Y in Cuda
*******************************************************************
* Description:
* Populate a float array of size N^2 with each index
* generated M times using mulitplication.
*******************************************************************
* Source:
* https://stack... |
21,178 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <unistd.h>
#include <sys/time.h>
/* Problem size. */
#define NX 4096
#define NY 4096
#ifndef M_PI
#define M_PI 3.14159
#endif
void init_array(double *x, double *A)
{
int i, j;
for (i = 0; i < NX; i++) {
// x[i] = i * M_PI; <--... |
21,179 | #include "includes.h"
__global__ void rotate_weights_kernel(const float *src_weight_gpu, float *weight_deform_gpu, int nweights, int n, int kernel_size, int reverse)
{
const int index = blockIdx.x*blockDim.x + threadIdx.x;
const int kernel_area = kernel_size * kernel_size;
const int i = index * kernel_area;
const int... |
21,180 | //N-Body Physics Simulation
//Randomly generates and displays an N-Body system
//Code from Nvidia's GPU Gems 3 Chapter 31
#ifndef __CUDACC__
#define __CUDACC__
#endif
#include "cuda_runtime_api.h"
#include "cuda_runtime.h"
#include "cuda.h"
#include "device_functions.h"
#include "device_launch_parameters.h"
#include ... |
21,181 | // @file main.cu
#include <stdio.h>
__global__ void hello_world(){
unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x;
printf("[ %d ] Hello world from GPU\n", idx);
}
int main() {
printf("Hello world from CPU\n");
hello_world<<< 1, 10 >>>();
cudaDeviceSynchronize();
return 0;
}
|
21,182 | #include "use_GMRES.cuh"
int main()
{
useGMRES();
useGMRES2();
useGMRES3();
useGMRES_n256();
return 0;
}
|
21,183 | /*
@Author: 3sne ( Mukur Panchani )
@FileName: q4MatrixTranspose.cu
@Task: CUDA program compute transpose of a matrix parallely.
*/
#include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
__global__ void transpose(int *a, int *b, int m, int n) {
/*
Generates b: transpose of... |
21,184 | #include "includes.h"
#define N 512
__global__ void calculate(int *a, int *b, int *c){
c[threadIdx.x] = ((a[threadIdx.x]+2)+b[threadIdx.x])*3;
} |
21,185 | #include <stdio.h>
#include <stdlib.h>
#define N 128 // 2^7
#define THREAD_PER_BLOCK 32 // 2^5
// GPU function for adding two vectors 'a' and 'b'
__global__ void add (int *a, int *b, int *c)
{
// Calculate the index of the current thread
// of the current block
int index = threadI... |
21,186 | #include <stdio.h>
#include <cuda.h>
#include <cuda_runtime.h>
const int N= 1024; // matrix size is NxN
const int K= 32; // tile size is KxK
struct GpuTimer
{
cudaEvent_t start;
cudaEvent_t stop;
GpuTimer ()
{
cudaEventCreate(&start);
cudaEventCreate(&stop);
}
~GpuTimer ()
{
cudaEventDestroy(start... |
21,187 | #include "includes.h"
__global__ void transposeDiagonal(float *odata, float *idata, int width, int height)
{
__shared__ float tile[TILE_DIM][TILE_DIM+1];
int blockIdx_x, blockIdx_y;
// do diagonal reordering
if (width == height)
{
blockIdx_y = blockIdx.x;
blockIdx_x = (blockIdx.x+blockIdx.y)%gridDim.x;
}
else
{
int b... |
21,188 | #include <stdio.h>
#include "reduction.h"
/*
Parallel sum reduction using shared memory
- takes log(n) steps for n input elements
- uses n threads
- only works for power-of-2 arrays
*/
// cuda thread synchronization
__global__ void
reduction_kernel_1(float* g_out, float* g_in, unsigned int size)
{
... |
21,189 | #include "includes.h"
__global__ void calculateBodyForce(float4 *p, float4 *v, float dt, int n) {
int i = blockDim.x * blockIdx.x + threadIdx.x;
if (i < n) {
float Fx = 0.0f; float Fy = 0.0f; float Fz = 0.0f;
for (int tile = 0; tile < gridDim.x; tile++) {
__shared__ float3 shared_position[BLOCK_SIZE];
float4 temp_posi... |
21,190 | //pass
//--blockDim=32 --gridDim=1
#include <cuda.h>
__global__ void test_Prog(int *A, int N) {
const int tid = threadIdx.x;
int alpha=0;
if(tid%2==0)
{
alpha=A[tid+2];
}
if(tid%6==0)
{
A[tid]=A[tid]+alpha;
}
} |
21,191 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
//nvcc shortestPath.cu
struct node
{
int nodeID, ancestor;
char label[20]; //max size of label is 20
};//node
void setNode(node &phy, int numNodes, int id, int aID, char * label)
{
phy.nodeID = id;
phy.ancestor = aID;
memset(phy.label, '\0', sizeof(label)... |
21,192 | #include <cuda.h>
#include <stdio.h>
#include <math.h>
#include <sys/time.h>
double wtime() {
struct timeval t;
gettimeofday(&t, NULL);
return (double)t.tv_sec + (double)t.tv_usec * 1E-6;
}
__global__ void gpuSum(float *a, float *b, float *c) {
int i = threadIdx.x + blockDim.x * blockIdx.x;
c[i] =... |
21,193 | #include <stdio.h>
#include <time.h>
#include <cstring>
#include "cuda.h"
#include "cuda_runtime.h"
#define gpuErrchk(ans) { gpu_assert((ans), __FILE__, __LINE__); }
inline void gpu_assert(cudaError_t code, const char *file, int line, bool abort = true)
{
if(code != cudaSuccess)
{
fprintf(stderr, "GP... |
21,194 | #include "vscale.cuh"
__global__ void vscale(const float *a, float *b, unsigned int n) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < n) {
b[i] *= a[i];
}
}
|
21,195 | #include <cuda.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
//max value for element in array
#define MAX 100000
//defined threads per block for cims machines
#define THREADS_PER_BLOCK 1024
//defined warp number
#define WARP 32
void generate(int *a, const int sie);
__global__ void get_max(int *array, co... |
21,196 | #include "includes.h"
__global__ void cpy(int *a, int *b, int n) {
unsigned int i = blockIdx.x * blockDim.x + threadIdx.x;
int sum = 0;
while (i < n) {
int val = b[i];
sum += val;
i += blockDim.x * gridDim.x;
}
atomicAdd(a, sum);
} |
21,197 |
/*
* Function: best_shuffle
* --------------------
* Shuffles given string (char array) with the use of a deterministic function
*
* s: pointer of the char array (constant)
* r: pointer of a copy of char array (will contain final string)
* diff: pointer of int array, which will contain the difference betwe... |
21,198 | #include <stdio.h>
#include <stdlib.h>
int main( void )
{
int deviceCount;
cudaGetDeviceCount( &deviceCount );
printf("Hello, Physics 244 Class! You have %d devices\n", deviceCount );
return 0;
}
|
21,199 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define NUM_ELEMENTS 1<<30
#define BLOCK_SIZE 1024
#define CUDA_ERROR_CHECK(func) { gpuAssert((func), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true){
if (code != cudaSuccess) {
fprintf(stderr... |
21,200 | #include "includes.h"
__global__ void MatrixCopy(float* in, float *out, int size)
{
int id = blockDim.x*blockIdx.y*gridDim.x + blockDim.x*blockIdx.x + threadIdx.x;
if (id < size)
out[id] = in[id];
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.