serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
21,301 | #include <stdio.h>
#include <time.h>
__global__ void matrixMulGPU( int * a, int * b, int * c, int N )
{
int val = 0;
int row = blockIdx.x * blockDim.x + threadIdx.x;
int col = blockIdx.y * blockDim.y + threadIdx.y;
if (row < N && col < N)
{
for ( int k = 0; k < N; ++k )
val +=... |
21,302 |
#include "vectorAdd.cuh"
// ---------------------------------------------------------------------------
// C = A + B
// ---------------------------------------------------------------------------
__global__ void vectorAdd(
const float* A,
const float* B,
float* const C,
int numElements)
{
int i = ... |
21,303 | #include <iostream>
using namespace std;
#define CUDA_CHECK_RETURN(value) {\
cudaError_t _m_cudaStat = value;\
if (_m_cudaStat != cudaSuccess) {\
fprintf(stderr, "Error %s at line %d in file %s\n", cudaGetErrorString(_m_cudaStat), __LINE__, __FILE__);\
exit(1);\
}}
__global__ void Ve... |
21,304 | #include <cuda.h>
#include <cuda_runtime.h>
#include <cuda_runtime_api.h>
#include <iostream>
#include <fstream>
#include <ostream>
#include <istream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
// nvcc ptrs.cu -o ./bin/ptrs -gencode arch=compute_35,code=sm_35 -lm -O3 -s... |
21,305 | #include <stdio.h>
__global__ void sale(int *GPU_arr, int *GPU_price,int *GPU_out){
int i = blockIdx.x*blockDim.x + threadIdx.x;
__shared__ int temp[4];
temp[threadIdx.x] = GPU_arr[i] * GPU_price[threadIdx.x];
__syncthreads();
if(threadIdx.x==0){
float sum = 0;
sum = temp[0]+temp[1]+temp[2]+temp[3];
GPU_out[b... |
21,306 | #if GOOGLE_CUDA
#define EIGEN_USE_GPU
__global__
void NMode32Kernel(const float* A, const int I, const int J, const int S,
const float* B, const int R,
float* C){
int32_t iA = blockIdx.x * blockDim.x + threadIdx.x;
if (iA >= I) {
return;
}
for (int32_t jA = 0; jA < J;... |
21,307 | #include "includes.h"
__global__ void vecAdd(float *in1, float *in2, float *out, int len) {
int i = threadIdx.x + blockDim.x * blockIdx.x;
if (i < len)
out[i] = in1[i] + in2[i];
} |
21,308 | #include <iostream>
#include <string>
#include <cmath>
#include <chrono>
#include <cuda.h>
#define PI 3.141592653589793
const size_t nThreadsPerBlock = 256;
static void HandleError(cudaError_t err, const char *file, int line )
{
if (err != cudaSuccess) {
printf( "%s in %s at line %d\n", cudaGetErrorString(... |
21,309 | #include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime_api.h>
#include <math.h>
#include "link.h"
using namespace std;
__global__ void link(int *bin, int *list, int *bnei, int *bnum,
int *potCon, int *potConSize, int *npcnpt,
int *nsegpt, int *nxbinpt, int *nybinpt, int *nzbinpt){
int npcn = *npcnpt;
int... |
21,310 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
__global__ void increment(float *x, float *y) {
int me = threadIdx.x;
y[me] = x[me] += 1;
__syncthreads();
}
int main(int argc, char** argv) {
int n = 10;
// arrays for host
float *h_input;
float *h_output;
// allocate space on host
h_input = (fl... |
21,311 | #include <stdio.h>
#define B 1
#define TPB 256
__device__ uint whoami() {
return blockIdx.x*blockDim.x+threadIdx.x;
}
__global__ void greetings() {
uint id = whoami();
printf("Hello world! My threadId is %d\n", id);
}
int main() {
greetings<<<B, TPB>>>();
cudaDeviceSynchronize();
} |
21,312 | #include <stdio.h>
#include <math.h>
#include <curand.h>
#include <curand_kernel.h>
#define CUDA_ERROR_CHECK
#define CudaSafeCall( err ) __cudaSafeCall( err, __FILE__, __LINE__ )
#define CudaCheckError() __cudaCheckError( __FILE__, __LINE__ )
inline void __cudaSafeCall( cudaError err, const char *file, const int ... |
21,313 | #include "simple_particle.cuh"
#include "device_launch_parameters.h"
#include "device_functions.h"
#include "math_functions.h"
#include <stdio.h>
__constant__ simpleParticleSystem d_sps[1];
__global__ void generateParticles();
__global__ void renderParticles(uchar4* devPtr, int img_width, int img_height);
__global_... |
21,314 | #include<stdio.h>
#include<math.h>
#include <fstream>
#include <iostream>
using namespace std;
#define THREADS_PER_BLOCK 1024
#define NUMBER_OF_BLOCKS 1024
#define DEBUG 0
//initially, 6 & 9
// number of threads_per_block*blocks should be atleast V-1.
// threads per block should be greater than or equal to number_... |
21,315 | #include "includes.h"
__global__ void square_array() {
} |
21,316 | #include <stdio.h>
#include <time.h>
#include <cuda.h>
__host__ cudaEvent_t get_time(void) {
cudaEvent_t time;
cudaEventCreate(&time);
cudaEventRecord(time);
return time;
}
// Pulled from module 6 assignment
__host__ void generate_rand_data(int * host_data_ptr, const int num_elem)
{
// Generate random values fro... |
21,317 | #include "includes.h"
__global__ void SetMatrixVauleMinMaxX( float* matrix, int cols, int size, int id_min, int id_max, float value)
{
int id = blockDim.x*blockIdx.y*gridDim.x + blockDim.x*blockIdx.x + threadIdx.x;
int id_column = id%cols;
if (id_column >= id_min && id_column <= id_max && id < size)
matrix[id] = value;... |
21,318 | #include "includes.h"
__global__ void convolutionRowGPU(double *h_Dst, double *h_Src, double *h_Filter, int imageW, int imageH, int filterR){
int k;
double sum = 0;
int ix = blockIdx.x * blockDim.x + threadIdx.x;
int iy = blockIdx.y * blockDim.y + threadIdx.y;
for (k = -filterR; k <= filterR; k++) {
int d = ix + k; ... |
21,319 | #include "includes.h"
//Library Definition
//Constant Definition
#define PI 3.141592654
#define blocksize 32
#define Repetitions 8192
//Print matrix into standard output
void print(double * M,int cols,int rows);
void dot(double * a,double * b, double & c, int cols);
void Create_New_Matrix(double * M,double * New,int... |
21,320 | /**
* An introduction to programming with CUDA Thrust
*
* Officially supported library distributed with CUDA since v4.0
* Abstracts the low-level memory and launch dimensions concerns in raw CUDA
* Provides containers and many algorithms for common problems to speed
* development on GPU
* Modeled after C++ ... |
21,321 |
#ifndef CUDACC
#define CUDACC
#endif
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <cuda.h>
#include <device_functions.h>
#include <cuda_runtime_api.h>
#include <stdio.h>
#include <stdlib.h>
typedef unsigned int NUMBER;
const int RADIUS = 3;
const NUMBER N = 2048 * 2048;
const int THREAD... |
21,322 | // Multiple GPU version of cuFFT_check that uses multiple GPU's
// This program creates a real-valued 3D function sin(x)*cos(y)*cos(z) and then
// takes the forward and inverse Fourier Transform, with the necessary scaling included.
// The output of this process should match the input function
// includes, system
#i... |
21,323 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define WIDTH 100
#define HEIGHT 100
#define GRID_SIZE WIDTH * HEIGHT
#define ACTUAL_GRID_SIZE sizeof(char) * GRID_SIZE
#define BLOCK_WIDTH 1
#define BLOCK_HEIGHT 1
#define NO_OF_GENERATIONS_TO_RUN 500
//#define DUMPFULL
//#define DUMPCOUNT
#define CUBE
__glo... |
21,324 | #include "includes.h"
__global__ void DrawRgbaColorKernel(float *target, int targetWidth, int targetHeight, int inputX, int inputY, int areaWidth, int areaHeight, float r, float g, float b)
{
int id = blockDim.x * blockIdx.y * gridDim.x
+ blockDim.x * blockIdx.x
+ threadIdx.x;
int targetPixels = targetWidth * targetHe... |
21,325 | #include <stdio.h>
// by lectures and "CUDA by Example" book
#define ind(i, j, cols) (i * cols + j)
struct dim2 {
int rows;
int cols;
};
// device code: matrices mult calculation
__global__ void mult_matrices_kernel(int* m1, int* m2, int* m3, dim2 m3_dims, int inner_dim) {
int rows = m3_dims.rows;
i... |
21,326 |
/* Includes, system */
#include <stdio.h>
/* Main */
int main(int argc, char** argv)
{
printf("Para ser original -- HOLA MUNDO\n");
}
|
21,327 | #include <stdio.h>
/*
* '__global__' alerts the compiler that a function should be compiled
* to run on a device instead of the host
*/
__global__ void kernel( void ) {
}
int main( void ) {
/*
* <<<?, ?>>> will be run on device, and the '?' in these angle brackets
* are parameters that will influence how the ... |
21,328 | #include <cuda.h>
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#define TILE_WIDTH 32
// kernel
__global__ void tiledMultiplyMatricesKernel(float* d_x, float* d_y, float* d_z, int m, int n, int p)
{
__shared__ float tile_x[TILE_WIDTH][TILE_WIDTH];
__shared__ float tile_y[TILE_WIDTH][TILE_WIDTH];
... |
21,329 | #include <iostream>
using namespace std;
#define L 1e-4
#define N_grid 16
#define dx (L/float(N_grid))
void test(float x)
{
float y = x - floor(x/L)*L;
cout << x << " " << y << endl;
}
int main()
{
cout << "L:" << L << endl;
test(-3*L);
test(-2*L);
test(-L);
test(-0.5*L);
test(0);
t... |
21,330 | //RSQF.cu
/*
* Copyright 2021 Regents of the University of California
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless req... |
21,331 | //
// kernal_add.cu
// XCodeCudaTest
//
// Created by on 2011/11/9.
// Copyright (c) 2011年 takmatsumoto All rights reserved.
//
//__global__ void VecAdd(float* A, float* float* B, float* C)
//{
// int idx = threadIdx.x;
//}
|
21,332 | #include "includes.h"
__global__ void deviceKernel(int *a, int N)
{
int idx = threadIdx.x + blockIdx.x * blockDim.x;
int stride = blockDim.x * gridDim.x;
for (int i = idx; i < N; i += stride)
{
a[i] = 1;
}
} |
21,333 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
__global__ void matrix_mul_gpu(float *A, float * B, float * C, int col_a, int col_b)
{
int i = threadIdx.x + blockDim.x * blockIdx.x;
int j = threadIdx.y + blockDim.y... |
21,334 | #include <cstdlib>
#include <cstdio>
#include <cassert>
typedef float float_t;
#define el(M, I, J) (*((float_t*)((char*)((M).ptr) + (I) * (M).pitch) + (J)))
#define w xsize
#define h ysize
#define eps 1e-4
#ifndef BLOCK_H
#define BLOCK_H 32
#endif
#ifndef BLOCK_W
#define BLOCK_W 32
#endif
cudaPitchedPtr allocHostMa... |
21,335 | /* ENGR-E 517 High Performance Computing
* Original Author : Matt Anderson (Serial Implementation 2D)
* Name : Ninaad Joshi (Serial and Parallel Implementation 1D)
* Project : Demonstration of the 2D Heat Distribution
* Problem using CUDA programming model
*/
#include <stdio.h>
#include <stdlib.h>
#include <mat... |
21,336 | #include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cuda.h>
__global__ void copy_array(float* A, float* B)
{
// int i = threadIdx.x;
int i = blockIdx.x * blockDim.x + threadIdx.x;
B[i] = A[i];
}
__global__ void prefix_sum_extend(float* B, int t, int s)
{
// int i = threadIdx.x;
int i = bl... |
21,337 | #include <stdio.h>
#include <stdlib.h>
#define BLOCK_SIZE 32
#define N 10240
__global__ void doubleValues(int*difference, int* numbers, int length) {
__shared__ int local_values[N];
int index = BLOCK_SIZE * blockIdx.x + threadIdx.x;
local_values[index] = numbers[index];
__syncthreads();
if(index != length ... |
21,338 |
#include "kernel.cuh"
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
|
21,339 | #include<assert.h>
int main(void){
assert(1==2);
return 0;
}
|
21,340 | #ifdef _GLIBCXX_USE_INT128
#undef _GLIBCXX_USE_INT128
#endif
#ifdef _GLIBCXX_ATOMIC_BUILTINS
#undef _GLIBCXX_ATOMIC_BUILTINS
#endif
#include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <thrust/sort.h>
#include <thrust/copy.h>
#include <thrust/binary_search.h>
#include <thrust/iterator/constant_... |
21,341 | #include "includes.h"
__global__ void smooth(float * v_new, const float * v) {
int myIdx = threadIdx.x * gridDim.x + blockIdx.x;
int numThreads = blockDim.x * gridDim.x;
int myLeftIdx = (myIdx == 0) ? 0 : myIdx - 1;
int myRightIdx = (myIdx == (numThreads - 1)) ? numThreads - 1 : myIdx + 1;
float myElt = v[myIdx];
float... |
21,342 | // is reduce in thrust foldl or foldr?
// => it is foldl in Haskell
#include <thrust/reduce.h>
#include <thrust/functional.h>
#include <iostream>
void print_array(int* data, int len){
for(int i=0; i<len; i++){
std::cout << data[i];
}
std::cout << std::endl;
}
struct div_func : public thrust::binary_functio... |
21,343 | // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include <cuda.h>
#include <cuda_runtime.h>
#include <cstdint>
using namespace std;
__global__ void cuda_add_impl(int64_t N, float* O, const float* X, const float* Y) {
auto offset = threadIdx.x;
if (offset < N) {
... |
21,344 | // #include "cublas_v2.h"
// #include "cusparse_v2.h"
// #include "curand.h"
// #include <iostream>
// #include <vector>
// #include <stdexcept>
// #include <cstdio>
// #include <chrono>
// #include "langevin.hpp"
// #include "gpu_utils.cuh"
// template <typename RealType>
// __global__ void update_positions(
// ... |
21,345 | /*Created by Alessandro Bigiotti*/
#include <stdio.h>
#include <stdlib.h>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include "cuda.h"
// A function to show some GPU Information
int main(){
// check the number of devices
int nDevices;
cudaGetDeviceCount(&nDevices);
// for each device print... |
21,346 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>
void initialData( float *ip, int size )
{
// generate different seed for random number
time_t t;
srand( (unsigned int) time (&t) );
for (int i=0; i<size; i++) {
ip[i] = (float)( rand() & 0xFF ) /... |
21,347 | #include <iostream>
#include <assert.h>
// #include <glog/logging.h>
#include <cuda.h>
#include <cuda_runtime.h>
// #include <sys/mman.h>
using namespace std;
int main() {
size_t count = 0;
size_t size = 64 * 1024 * 1024 * sizeof(float);
while (true) {
void *host_array;
cudaError errono = cudaMallocH... |
21,348 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
//TODO : used sharedvar to have (xi - yi)^2 generated in ||lel
__global__ void updateMeans(float *means, float *entries, int *closestMean, int num_entries, int num_means, int num_attribs)
{
int id = threadIdx.y;
int thisMeanCount = 0;
float temp[100];
fo... |
21,349 | //CS-4370 Parallel Programming for many core GPUs
//Name: Gesu Bal
/*
this is a simple cuda program calculating vector add for 2 dimensions on GPU device
I added two two-dimensional matrices A, B on the device GPU.
After the device matrix addition kernel function is invoked, and the addition result is transferred back... |
21,350 | #include <stdio.h>
#include <stdlib.h>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <chrono>
#define TILE_DIM 64
void gpuMemTransfer(int* A_cpu, int* B_cpu, int* C_cpu, int N, int size, bool memCol);
void gpuNoMemTransfer(int* A_cpu, int* B_cpu, int* C_cpu, int N, int size, bool memCol);
// __... |
21,351 | /*#include<iostream>
#include<cuda.h>
#include<cuda_runtime.h>
#include "device_launch_parameters.h"
#include <device_functions.h>
#define imin(a,b)((a<b)?a:b)
const int N =33 * 1024;
const int threadsPerBlock = 256;
const int blocksPerGrid = imin(32, (N+ threadsPerBlock-1) / threadsPerBlock);
__global__ void kerne... |
21,352 | // Author: Rajiur Rahman ( rajiurrahman.bd@gmail.com )
// Department of Computer Science, Wayne State University
// knn implemented for GPU.
// have to provide training data, trianing data label, test data, test data label in separate text files. All the files should be ' ' space separated.
/* Instruction for compi... |
21,353 | #include "includes.h"
__global__ void sum_dWU(const double *Params, const float *bigArray, float *WU) {
int tid,bid, ind, Nfilters, Nthreads, Nfeatures, Nblocks, NfeatW, nWU, nElem;
float sum = 0.0f;
Nfeatures = (int) Params[1]; //NrankPC, number of pcs
NfeatW = (int) Params[4]; //Nchan*n... |
21,354 | #include <stdio.h>
#define BLOCK_SIZE 1024
__global__ void spmv_csr_kernel(unsigned int dim, unsigned int *csrRowPtr,
unsigned int *csrColIdx, float *csrData, float *inVector,
float *outVector) {
// INSERT KERNEL CODE HERE
int row = blockDim.x * blockIdx.x + threadIdx.x;
if(row < dim)
{
... |
21,355 | #include "includes.h"
__device__ float activator_derivative( float x )
{
float sig = 1.0f / (1.0f + exp( -x ));
return sig * (1 - sig);
}
__global__ void calcSigmoidBackwardGPU( float *dz_next_layer, float *dz_in, float *dz, float *in, int elements )
{
int id = (blockIdx.x + blockIdx.y*gridDim.x) * blockDim.x + threadI... |
21,356 |
#include "kernel.cuh"
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
__host__ void callKernel(unsigned int size, int *c, const int *a, const int *b) {
addKernel <<< 1, size >>> (c, a, b);
}
__global__ void addKernel(int *c, const int *a, const int *b)
{
int i = threadIdx.x;... |
21,357 | /*
Center assignments
Written by Jiageng Mao
*/
#include <math.h>
#include <stdio.h>
#define THREADS_PER_BLOCK 256
#define DIVUP(m,n) ((m) / (n) + ((m) % (n) > 0))
__device__ float limit_period(float val, float offset, float period){
float rval = val - floor(val / period + offset) * period;
return rval;
}
_... |
21,358 | #include <stdio.h>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <cuda_runtime_api.h>
#include <errno.h>
#include <unistd.h>
/******************************************************************************
* The variable names and the function names of this program is same as provided by the univers... |
21,359 |
#include "cuda_runtime.h"
#include <iostream>
void error() {
printf("Encountered an error...");
exit(1);
}
int main()
{
cudaDeviceProp prop;
int count = 0;
if (cudaGetDeviceCount(&count))
error();
for (int i = 0; i < count; ++i) {
if (cudaGetDeviceProperties(&prop, i))
error();
std::cout << "\tPropert... |
21,360 | #include "includes.h"
__global__ void windowBartlett(float* idata, int length)
{
int tidx = threadIdx.x + blockIdx.x*blockDim.x;
if (tidx < length)
{
idata[tidx] = 0;
}
} |
21,361 | //---------------------------------------------------------------
// Trabalho Práctico Nº4 - CUDA I - CHAD
// Óscar Ferraz
// 2018/2019
// --------------------------------------------------------------
// nvcc -o vecAdd vecAdd.cu -I /usr/local/cuda-9.1/samples/common/inc
#include <stdio.h>
#include <time.h... |
21,362 | #include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <thrust/functional.h>
#include <thrust/reduce.h>
#include <iostream>
// nvcc -O3 -std=c++14 example1.cu -o t1 && ./t1 < stocks2.csv
int main()
{
thrust::host_vector<double> hostApple;
thrust::host_vector<double> hostMicrosoft;
int... |
21,363 | #include <cuda_runtime_api.h>
#include <cuda.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#define TILE_WIDTH 16
__global__ void gpu_matrix_mult_one(int *a, int *b, int *c, int m, int n, int k)
{
int row = blockIdx.y * blockDim.y + threadIdx.y; // get the row
int col = blockIdx.x * blockDim.x ... |
21,364 | // n should be less than 10000 when k==3
#include <stdio.h>
#include <cuda.h>
__global__ void parallel_max_each_chunk(float *dmaxarr, float * darr, int n, int k);
int main(int argc, char **argv) {
int n = atoi(argv[1]);
int k = atoi(argv[2]);
//generate a 1d array
float *arr = (float*) malloc(n*... |
21,365 | #include <cuda.h>
#include <cuda_runtime.h>
#include <curand.h>
#include <curand_kernel.h>
#include <device_launch_parameters.h>
#include <device_functions.h>
#include <time.h>
#include "curisk.cuh"
__global__ void generate_vector_sample_kernel();
__global__ void setup_gamma_generator(long seed);
__device__ __forceinl... |
21,366 | #include "includes.h"
__global__ void prod( int taille, float * a, float b, float *c ){
int index=threadIdx.x+blockDim.x*blockIdx.x;
if(index>=taille) return;
c[index]=a[index]*b;
} |
21,367 | /******************************************************************************
*cr
*cr (C) Copyright 2010 The Board of Trustees of the
*cr University of Illinois
*cr All Rights Reserved
*cr
*****************************************************************... |
21,368 | #include "includes.h"
__global__ void NmDistanceGradKernel(int b,int n,const float * xyz1,int m,const float * xyz2,const float * grad_dist1,const int * idx1,float * grad_xyz1,float * grad_xyz2){
for (int i=blockIdx.x;i<b;i+=gridDim.x){
for (int j=threadIdx.x+blockIdx.y*blockDim.x;j<n;j+=blockDim.x*gridDim.y){
float x1=... |
21,369 | #define VS
//#define MGPU
#ifdef VS
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#endif
#ifdef MGPU
#include<cuda.h>
#endif
#include <stdio.h>
#include<stdlib.h>
//#define DEBUG_MATRIX
#define DEBUG
//Dal profiler nvida per il kernel vengono usati 13 registri (si deve passare sulla multiGPU... |
21,370 | #include <stdio.h>
#include <fstream>
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(){
// make an undirected and connected graph
// remember n is vertices and m is edges
cout << "hello world";
FILE* pFile = fopen("input.txt", "r");
if(pFile == NULL){
cout << "Fam u can't do that stop";... |
21,371 | #include "includes.h"
__global__ void dyadicAdd(int * counter, const int length, const int shift)
{
if (shift > 0) {
unsigned int xIndex = blockDim.x * blockIdx.x + threadIdx.x;
int adds = 2*shift;
int Index = adds*(xIndex+1)-1;
if (Index < length) {
counter[Index] = counter[Index] + counter[Index-shift];
}
}
} |
21,372 | /*
* This sample implements a separable convolution
* of a 2D image with an arbitrary filter.
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <sys/time.h>
#define FILTER_RADIUS 16
#define FILTER_LENGTH (2 * FILTER_RADIUS + 1)
#define ABS(val) ((val)<0.0 ? (-(val)) : (val))... |
21,373 | #include "includes.h"
__global__ void cal_hist(float *da, int *hist_da, int N, int M){
int bx = blockIdx.x;
int tx = threadIdx.x;
int idx = bx * blockDim.x + tx;
if(idx < N){
// add a lock here to make sure this (read, write) operation atomic.
atomicAdd(&hist_da[(int)da[idx]], 1);
//hist_da[(int)da[idx]] += 1;
}
} |
21,374 | /*
Implementing Radix sort in CUDA.
*/
#include <stdio.h>
#include <stdlib.h>
#define NUM_ELEMENTS 16
__device__ void partition_by_bit(unsigned int* values, unsigned int bit);
__global__ void radix_sort(unsigned int* d_array){
for(int bit = 0; bit < 32; bit++){
partition_by_bit(d_array, bit);
__... |
21,375 | #include <cuda_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#define N 8
#define THREADS 2
double wtime() {
static int sec = -1;
struct timeval tv;
gettimeofday(&tv, NULL);
if (sec < 0) sec = tv.tv_sec;
return (tv.tv_sec - sec) + 1.0e-6 * tv.tv_usec;
}
__global__ void jacobi(float... |
21,376 | //#include <stdlib.h>
//#include <stdio.h>
//#include <curand_kernel.h>
//#include "cuda_runtime.h"
//#include "device_launch_parameters.h"
//
////#include "../../common/book.h"
//#include "../../common/cpu_anim.h"
//#include "../../common/common.h"
//#include "../../common/TexUtils.h"
//#include "../../common/PlyBlock... |
21,377 | #include <cuda.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#define THREADS_PER_BLOCK 32
__global__ void innerProd(float *aa, float *bb, float *cc)
{
__shared__ float temp[THREADS_PER_BLOCK];
int index = threadIdx.x + blockIdx.x* blockDim.x;
temp[threadIdx.x] = aa[index]*bb[index];
*cc ... |
21,378 | //=============================================================================================
// Name : syncThreadsTest.cu
// Author : Jose Refojo
// Version : 08-02-2017
// Creation date : 28-01-2013
// Copyright : Copyright belongs to Trinity Centre for High Performance Computing
// Descripti... |
21,379 | /*
**********************************************
* CS314 Principles of Programming Languages *
* Spring 2020 *
**********************************************
*/
#include <stdio.h>
#include <stdlib.h>
__global__ void check_handshaking_gpu(int * strongNeighbor, int * matches, int nu... |
21,380 | #include "includes.h"
using namespace std;
#define TILE 16
/* LU Decomposition using Shared Memory \
\ CUDA \
\ \
\ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
//Initialize a 2D matrix
__global__ void elim(double *A, int n, int index, int bsize){
extern __shared__ double pivot... |
21,381 | #include "includes.h"
__global__ void lineSpace ( const int d, const int n, const float *l, const float *h, float *b ) {
int i = threadIdx.x + blockDim.x * blockIdx.x;
int j = threadIdx.y + blockDim.y * blockIdx.y;
float delta;
if ( i < d && j < n ) {
delta = ( h[i] - l[i] ) / ( n - 1 );
b[i+j*d] = l[i] + j * delta;
}
... |
21,382 | extern "C" __global__ void vector_add(float *c, float *a, float *b, int n) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < n) {
c[i] = a[i] + b[i];
}
}
|
21,383 | #include "includes.h"
__global__ void cuda_divide(float * dst, float *numerator, float *denominator, int width, int height)
{
int row = threadIdx.y + blockIdx.y * blockDim.y;
int col = threadIdx.x + blockIdx.x * blockDim.x;
if(row < height && col < width)
{
int index = row * width + col;
if(denominator[index] > 0.0000... |
21,384 | #include <stdio.h>
#include <iostream>
#include <limits>
#include <curand.h>
#include<cmath>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <curand_kernel.h>
typedef std::numeric_limits< double > dbl;
// simulation parameters
const double dt = 0.1;
const int N = 100000;
const int T_max = 1... |
21,385 | /*
* FileName: RayTracer_Kernel.cu
*
* Programmer: Jiayin Cao
*/
//the sum for scan
int* g_ScanSum[2];
//some helper functions
__device__ void d_normalize( float4* v )
{
float s = v->x * v->x + v->y * v->y + v->z * v->z;
s = sqrt(s);
v->x /= s;
v->y /= s;
v->z /= s;
}
//cross product
__device__ float4 d_cr... |
21,386 |
/* 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,float var_5,int var_6,int var_7,float var_8,float var_9,float var_10,float var_11,float var_12,float var_13,float va... |
21,387 | /*
**********************************************
* CS314 Principles of Programming Languages *
* Fall 2020 *
**********************************************
*/
#include <stdio.h>
#include <stdlib.h>
//Note: you can place as many kernel functions in this file as are necessary
/**... |
21,388 | #include "includes.h"
/*
* Module to test CUDA module loading and execution.
* To be compiled with:
* nvcc -ptx module_test.cu
*/
#ifdef __cplusplus
extern "C" {
#endif
/// Sets the first N elements of array to value.
#ifdef __cplusplus
}
#endif
__global__ void testMemset(float* array, float value, int N){
int i = ( ... |
21,389 | #include<stdlib.h>
#include<stdio.h>
#include<time.h>
//全局内存
__global__ void global_reduce(float *d_in,float *d_out){
int idx = threadIdx.x + blockIdx.x*blockDim.x;
int idxn = threadIdx.x;
for(int s = blockDim.x/2;s>0;s>>=1){
if(idxn<s){
d_in[idx] += d_in[idx+s];
}
__syncthreads();//同步
}
if(idxn == 0){
... |
21,390 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <cuda_runtime.h>
#define CHECK_STATUS(status) \
if (status != cudaSuccess) \
fprintf(stderr, "File: %s\nLine:%d Function:%s>>>%s\n", __FILE__, __LINE__, __FUNCTION__,\
cudaGetErrorString(status))
////////////////////////////////////... |
21,391 | #include "includes.h"
__global__ void cu_sqrt(const float *A, float *B, const int n){
int tid = threadIdx.x + blockIdx.x * blockDim.x;
int stride = blockDim.x * gridDim.x;
while(tid < n){
B[tid] = sqrtf(A[tid]);
tid += stride;
}
} |
21,392 | #include <iostream>
#include <stdio.h>
#include <time.h>
#define LENGTH 10000
using namespace std;
struct aos{
int a;
int b;
int c;
};
__global__ void vector_add(aos *arr){
int i = threadIdx.x ;
if (i < LENGTH)
arr[i].c = arr[i].a + arr[i].b; // read
}
__host__ void vector_add_cpu(float... |
21,393 | /*!
\brief loopExit.cu
\author Andrew Kerr
\brief simple test of control-flow behavior of kernels
*/
#include <stdio.h>
extern "C" __global__ void kernelLoopExit(int *A, int N) {
int i = threadIdx.x + blockIdx.x * blockDim.x;
__shared__ int S[64];
S[threadIdx.x] = 0;
A[i] = 0;
for (int j = i; j < N; j++) {... |
21,394 | #include <iostream>
#include <vector>
__global__
void scale_kernel(float *const input_image,
const int size,
float* result) {
int index = blockDim.x * blockIdx.x + threadIdx.x;
const int stride = gridDim.x * blockDim.x;
for (;index < size; index += stride) {
re... |
21,395 | #include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/functional.h>
#include <thrust/gather.h>
#include <thrust/scan.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/iterator/transform_iterator.h>
#include <thrust/iterator/permutation_iterator.h>
#include <chrono>
#include... |
21,396 |
extern "C"
__global__
void histgramMakerKernel_naive(int *d_histgram,
const unsigned char* d_text, int textLength) {
int gid = blockDim.x * blockIdx.x + threadIdx.x;
if (gid < textLength) {
unsigned char ch = d_text[gid];
atomicAdd(&d_histgram[(int)ch], 1);
}
}
|
21,397 | #include <iostream>
#include <math.h>
#include <unistd.h>
#include <memory>
const std::size_t N = 1 << 20;
__global__
void vec_add(float* const c, const float* const a, const float* const b, const std::size_t n)
{
// shared memory spaces are block-scoped and for intra-thread communication, 10 was meaningless here... |
21,398 | #include <stdio.h>
__global__ void loop()
{
/*
* This idiomatic expression gives each thread
* a unique index within the entire grid.
*/
int i = blockIdx.x * blockDim.x + threadIdx.x;
printf("%d\n", i);
}
int main()
{
/*
* Additional execution configurations that would
* work and meet the exer... |
21,399 | #include <stdio.h>
#include <cuda.h>
#include <assert.h>
#define N 2//64
__global__ void foo(int* p) {
int* q;
q = p;
q[threadIdx.x] = 0;
}
|
21,400 | #include "includes.h"
__global__ void clearLabel(float *prA, float *prB, unsigned int num_nodes, float base)
{
unsigned int id = blockDim.x * blockIdx.x + threadIdx.x;
if(id < num_nodes)
{
prA[id] = base + prA[id] * 0.85;
prB[id] = 0;
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.