serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
20,201 | #include <stdlib.h>
#include <string.h>
#include <time.h>
void sumArraysOnHost(float *A, float *B, float *C, const int N) {
for (int idx = 0; idx < N; idx++) {
C[idx] = A[idx] + B[idx];
}
}
void initialData(float *ip, int size) {
// generate different seed for random number
time_t t;
srand((unsigned int)time(&t)... |
20,202 | #define NUM_DIFF_EQUATIONS 2 // number of differential equations
#define NUM_ITERATIONS 10000
#define TIME_STEP 0.001
#define cuda_get(matrix, row, column, width) (matrix[(row)*(width) + (column)])
#include <stdio.h>
#include <time.h>
#include <assert.h>
#include <cuda_runtime.h>
#include <iostream>
using namespace ... |
20,203 | #include <cuda.h>
#include <iostream>
#include <sys/time.h>
#include <stdio.h>
using namespace std;
/* Concurrent kernel execution
* - compare concurrent execution performance with serial execution
* - effect of (number of blocks) and (number of multiprocessors)
*/
#define TILE_DIM 16
#define BLOCK_ROWS 16
_... |
20,204 | #include "includes.h"
#define DEBUG false
#define DEBUG_OUTPUT false
#define DEBUG_DELTA_K false
#define DEBUGNET false
#define DEBUG_TIMEING true
#define index(i,j,ld) (((j)*(ld))+(i))
int numBlocks = 1;
int blockSize = 256;
using namespace std;
/*
* Print Matrix on host
*/
__global__ void addConstant(float* in... |
20,205 | #include "includes.h"
__global__ void accumulateRowsKernel( float *input, float *output, int channels, int h, int w) {
// view multichannel image as a multiline single-channel image
int globalRowIdx = BLOCK_SIZE * BLOCK_SIZE * blockIdx.x + threadIdx.x;
if (globalRowIdx < channels * h) {
float *outputRow = output + (gl... |
20,206 | #include<curand_kernel.h>
extern "C" __global__ void integrate(curandState * states,
unsigned long long * seed,
unsigned long long * numSamples,
unsigned long long * inCount,
... |
20,207 | #include<cuda.h>
#include<iostream>
#include<stdio.h>
__global__ void factorialKernel()
{
//this adds a value to a variable stored in global memory
int factorial = 1;
int n = threadIdx.x+1;
for(int i = 1; i <= n; ++i) {
factorial *= i;
}
printf("%d!=%d\n", n, factorial);
}
int main()... |
20,208 | #include<stdio.h>
__global__ void hello_from_gpu(){
const int bid = blockIdx.x;
const int tid = threadIdx.x;
printf("hello world from block %d and thread %d\n", bid, tid);
}
int main() {
hello_from_gpu<<<2, 4>>>();
cudaDeviceSynchronize();
return 0;
} |
20,209 | #include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include <curand_kernel.h>
#include <stdlib.h>
#include <cuda.h>
#include <sys/time.h>
#include "cuSearchDoublet.cu"
#include<chrono>
#include<iostream>
using namespace std;
using namespace std::chrono;
int blocks_[20][2] = {{8,8},{16,16},{... |
20,210 | #include <thrust/device_vector.h>
#include <thrust/remove.h>
#include <thrust/unique.h>
#include <thrust/binary_search.h>
#include <thrust/sort.h>
#include <iostream>
/*
* This example "welds" triangle vertices together by taking as
* input "triangle soup" and eliminating redundant vertex positions
* and shared ed... |
20,211 | #include <cuda.h>
#include <stdlib.h>
#include <stdio.h>
#define TILE_WIDTH 512
#define index(i, j, N) ((i)*(N+1)) + (j)
int maximum(int a, int b) {
return (a > b)? a : b;
}
__global__ void knapsackKernel(int *profits, int *weights, int *input_f, int *output_f, int capacity, int c_min, int k){
int c = blockIdx... |
20,212 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include <cuda.h>
#define LINE 100000
void readfile(int num[LINE]){
int temp;
int i;
FILE *fp;
fp = fopen("number.txt", "r");
i = 0;
if(fp == NULL){
printf("Error loading file!!\n");
exit(1);
}else{
while(!feof(fp)){
fscanf(... |
20,213 | // 16CO234 Prajval M
// 16CO145 Sumukha PK
#include<stdio.h>
#include<cuda.h>
__global__ void add_vec(float *d_a, int n){ //7.CUDA Kernel that computes sum
int i = threadIdx.x;
if((n-i-1)!=i) {
d_a[i]+=d_a[n-i-1];
}
}
int main(){
int i, n, deviceCount;
cudaGetDeviceCount(&de... |
20,214 | #include <memory>
#include <iostream>
#include <cuda_runtime.h>
// Main Program
int main(void)
{
int device_Count = 0;
cudaGetDeviceCount(&device_Count);
// This function returns count of number of CUDA enable devices and 0 if there are no CUDA capable devices.
if (device_Count == 0)
{
prin... |
20,215 | #include <math.h>
#include <stdio.h>
#include <cuda_runtime.h>
// Array access macros
#define im(i,j) A[(i) + (j)*(m)]
#define f(i,j) f[(i) + (j)*(m)]
#define Z(i,j) Z[(i) + (j)*m]
__global__ void Zev(float const * const A, float *Z,float const * const H, int m, int n,int patch,float patchSigma,float filtsigma){
in... |
20,216 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <fstream>
#include <time.h>
using namespace std;
__global__ void blur(int* flat, int* result, int lines, int cols, int channels, int scale) {
int tid = blockIdx.x * blockDim.x + thre... |
20,217 | #include "includes.h"
__global__ void mcfauto_kernal(const float* data1, float* data2, const int totaltc)
{
int idx = 2*(threadIdx.x + (blockIdx.x + blockIdx.y*gridDim.x)*MAX_THREADS);
if(idx < totaltc){
data2[idx] = sqrt(data1[idx] * data2[idx] + data1[idx + 1] * data2[idx + 1]);
data2[idx + 1] = 0;
}
} |
20,218 | // Hilos y Bloques
#include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
#define COLUMNAS 10 // Nro de columnas -> eje x
#define FILAS 6 // Nro de filas -> eje y
// Kernel Bidimensional (x, y)
__global__
void MathFinal(int *entrada, int *salida)
{
// indice de la columna: eje x
int colu... |
20,219 | // Computes adjacencies matrix in parallel
__global__ void compute_adjacent_nodes(int *indptr, int *indices, float *in_component, float *update_values, float *adjacencies, int n)
{
const int i = threadIdx.x;
if(update_values[i] == 0)
return;
int offset = i*n;
for(int j = indptr[i]; j < indptr[i+... |
20,220 | #define CUDA_KERNEL_LOOP(i, n) \
for (int i = blockIdx.x * blockDim.x + threadIdx.x; \
i < (n); \
i += blockDim.x * gridDim.x)
#define INDEX(b,c,h,w,channels,height,width) ((b * channels + c) * height + h) * width+ w
extern "C" __global__ ... |
20,221 | #include "Vector3.cuh"
#include <cuda_runtime.h>
#ifdef __INTELLISENSE__
//#define __CUDACC__
#include <math_functions.h>
#endif // __INTELLISENSE__
Vector3* addVector3(Vector3* dst, Vector3* src) {
dst->x = dst->x + src->x;
dst->y = dst->y + src->y;
dst->z = dst->z + src->z;
return dst;
}
Vector3* scaleVector... |
20,222 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <cuda_profiler_api.h>
#include <assert.h>
// Convenience function for checking CUDA runtime API results
// can be wrapped around any runtime API call. No-op in release builds.
inline
cudaError_t checkCuda(cudaError_t result)
{
#if defined(DEBUG) || ... |
20,223 | #include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include "tree23_array_help.cu"
int offsetTotal_h = 0;
int numNodes = 0;
__host__ int createNode_arr(int *arr, int offset, int data)
{
arr[offset] = offset;
arr[offset+1] = data;
arr[offset+2] = -1;
arr[offset+3] = -2;
arr[offset+4] = -2;
arr[o... |
20,224 | #include "includes.h"
__global__ void kernel(int* arr,int offset_min,int n){
int bx = blockIdx.x;
int tx = threadIdx.x;
int BX = blockDim.x;
int i = bx*BX+tx;
if (i>= n|| i < 0) return;
//printf("%d %d - %d %d\n",offset_min,offset_max,i+offset_min,i);
arr[i+offset_min] += 1;
} |
20,225 | // RUN: %clang_cc1 -Wno-cuda-compat -Werror %s
// RUN: %clang_cc1 -Wcuda-compat -verify %s
// RUN: %clang_cc1 -x c++ -Wcuda-compat -Werror %s
// Note that this puts the expected lines before the directives to work around
// limitations in the -verify mode.
void test(int *List, int Length) {
/* expected-warning {{argu... |
20,226 | #include <iostream>
#include <fstream>
#include <cmath>
#define IMAGE_DIMENSION 1000
#define G 9.81
#define PI 3.14159265358979323846
#define ARRAY_LENGTH 4000
#define MAX_TIME 40
void writeImgArrToFile(int *arr, std::string fileName)
{
std::ofstream arrayFile(fileName);
for (int i = 0; i < IMAGE_DIMENSION ... |
20,227 | #include "includes.h"
__global__ void kernel_push_stochastic1(int *g_push_reser, int *s_push_reser, int *g_count_blocks, bool *g_finish, int *g_block_num, int width1)
{
int x = __umul24(blockIdx.x, blockDim.x) + threadIdx.x;
int y = __umul24(blockIdx.y, blockDim.y) + threadIdx.y;
int thid = __umul24(y, width1) + x;
s_... |
20,228 | #include "includes.h"
__global__ void pfbFilter(float *filtered, float *unfiltered, float *taps, const int ntaps) {
const int nfft = blockDim.x;
const int i = threadIdx.x + threadIdx.y*blockDim.x + blockIdx.x * blockDim.x * blockDim.y;
filtered[i] = unfiltered[i] * taps[threadIdx.x];
for (int j=1; j<ntaps; j++) {
fil... |
20,229 | #include <stdlib.h>
#include <stdio.h>
double3* r; //array of displacement vectors
double3* rc; //array of displacement vectors in cylindrical coords, used in initcond() only
double3* r1; //array of displacement vectors of one end of particles
double3* r2; //array of displacement vectors of the other end of particles
... |
20,230 |
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/sort.h>
#include <curand.h>
#include <curand_kernel.h>
#include <cuda.h>
/*
#include "cuPrintf.cu"`
*/
using namespace std;
inline void __cudaSafeCall( cud... |
20,231 | #include "includes.h"
// Possible weight coefficients for tracking cost evaluation :
// Gaussian discretisation
/*
* 1 4 6 4 1
* 4 16 24 16 4
* 6 24 36 24 6
* 4 16 24 16 4
* 1 4 6 4 1
*/
// Compute spatial derivatives using Scharr operator - Naive implementation..
// Compu... |
20,232 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cuda_runtime.h>
#define MAX_ARRAY_SIZE 1000000
/* -------------------------------------------------------------------------
Algorithm description:
array_in {1, 5, 3, 2, 6, 7, 9, 5, 3, 6}
|
| parallel check odd/even: O(1)
... |
20,233 | #define SizeT int
#define VertexId int
__global__ void Collect(
const SizeT edges,
const SizeT iter,
const SizeT* const flag,
const VertexId* const froms_data,
const VertexId* const tos_data,
VertexId* froms,
VertexId* tos,
SizeT* ... |
20,234 | #include "MemoryManagement.cuh"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
ComputationEnvironment glob_Env = ComputationEnvironment::GPU;
ComputationEnvironment trellis_3D_Env = ComputationEnvironment::GPU;
MemoryMovementDuplication glob_Dup = MemoryMovementDuplication::NO;
__host__ cudaError_t all... |
20,235 | //Calculate prime numbers within a certain range provided by the user, or use default
//values of 0-1000
#include <iostream>
#include <cstdint> //required for uint64_t
#include <sstream> //convert runtime params into uint64 using istringstream
#include <ctime>
#include <chrono>
#include <cstdlib>
#include <cuda_runtim... |
20,236 | #include <iostream>
using namespace std;
const int N = 16;
const int blocksize = 16;
__global__
void add_matrix_gpu( float* a, float *b, float *c, int N )
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
int j = blockIdx.y * blockDim.y + threadIdx.y;
int index = i + j*N;
if ( i < N && j < N )
... |
20,237 | #include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
#define n 1024
__global__ void sc(char *a, char c[n]) {
int i = threadIdx.x;
c[i] = (char)((int)a[i] - 32);
// printf("%s\n", c[i]);
}
int main() {
char a[n], c[n], *pa, *pc;
for (int i = 0; i < n; i++) {
a[i] = 'a';
}
... |
20,238 | //pass
//--gridDim=[64,1,1] --blockDim=[128,1,1]
__global__ void kernelAddConstant(int *g_a, const int b)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
g_a[idx] += b;
}
|
20,239 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#define PI 3.14159265359
#define grid(i,k,nr) k*nr+i
#define omega 1.5
#define RelativeError 1e-3
#define epsilon 1e-12
#define nMax 256
#define zEvalsPerBlock 16
#define rEvalsPerBlock 16
double Besseli0(double x){
//returns modified be... |
20,240 | /*
#include <iostream>
using namespace std;
__global__
void kernelFunction()
{
return;
}
//extern "C"
void CudaMain()
{
int threads = 32;
dim3 gridSize(1, 1, 1);
dim3 blockSize(threads, 1, 1);
kernelFunction<<<gridSize, blockSize>>>();
}
*/
|
20,241 | #include <stdio.h>
#include<stdlib.h>
#include "device_launch_parameters.h"
#include "cuda_runtime.h"
#define BLOCK_SIZE 64
__global__ void
totalKernel(float * input, float * output, int len)
{
__shared__ float partialSum[2*BLOCK_SIZE];
unsigned int t = threadIdx.x;
unsigned int start = blockIdx.x*blockDim.x*2;
... |
20,242 | #include "includes.h"
__global__ void matrixMultiplicationKernel(float* A, float* B, float* C, int N) {
int ROW = blockIdx.y*blockDim.y+threadIdx.y;
int COL = blockIdx.x*blockDim.x+threadIdx.x;
float tmpSum = 0;
if (ROW < N && COL < N) {
// each thread computes one element of the block sub-matrix
for (int i = 0; i <... |
20,243 | #include <stdio.h>
#include <time.h>
#define LEN 256
#define TILESZ 16
// Uncomment this line if you want to display //
// the result of the computation. //
// #define DISPLAY 1
static double CLOCK();
__global__ void matInit(float*);
__global__ void stencil(float*, float*)... |
20,244 | /*
Game Interface for Tic-Tac-Toe
Rahul Kejriwal
CS14B023
*/
#include <stdio.h>
#include "GameState.cu"
#define BOARD_SIZE 9
#define WIN_SIZE 8
#define ROW_SIZE 3
#define NUM_ROWS 3
#define NUM_COLS 3
#define OFFSET(i,j) ((i)*NUM_COLS + (j))
__device__
int GPU_winning_patterns[WIN_SIZE][ROW_SIZE] = {
{0, 1, 2... |
20,245 | // In this assignment you will write a basic kernel where every thread
// will write out to console string "Hello world!".
// You will also initialize GPU using cudaSetDevice() and also launch
// your "Hello world" kernel.
#include <stdio.h>
#include <stdlib.h>
// we have to include few more things
#include <cuda.h>
... |
20,246 | #include "includes.h"
__global__ void PrepareDerivativesKernel(float* input, float* lastInput, float* derivatives, int inputWidth, int inputHeight)
{
int id = blockDim.x * blockIdx.y * gridDim.x
+ blockDim.x * blockIdx.x
+ threadIdx.x;
int size = inputWidth * inputHeight;
if (id < size)
{
float mul = 100000;
//I_x, I... |
20,247 | #include "includes.h"
#define ARRAY_SIZE 200
#define ARRAY_BYTES ARRAY_SIZE * sizeof(float)
__global__ void CalculateSquare(float* p_out, float* p_in)
{
int index = threadIdx.x;
float valueToSuqare = p_in[index];
p_out[index] = valueToSuqare * valueToSuqare;
} |
20,248 | #include "includes.h"
__global__ void computeSphereVertexDistancesKernel(float4 *V, float *dist, unsigned int *NEIGHBOR, unsigned int *NBOFFSETS, unsigned int *nNeighbors, unsigned int nVertices, float circumference)
{
int n,N;
int offset,soffset;
// since we are using multiple threads per blocks as well as multiple b... |
20,249 | // hello_world.cu
|
20,250 | #include <stdio.h>
// #include <cuda.h>
__global__
void foo (float *farr) {
farr[0] = farr[1];
}
int main (void) {
float *d_farr;
cudaMalloc(&d_farr, sizeof(float)*2);
foo<<<1, 1>>>(d_farr);
return 0;
}
|
20,251 | #include "includes.h"
extern "C" {
#ifndef NUMBER
#define NUMBER float
#endif
}
__global__ void vector_copy (const int n, const NUMBER* x, const int offset_x, const int stride_x, NUMBER* y, const int offset_y, const int stride_y) {
const int gid = blockIdx.x * blockDim.x + threadIdx.x;
if (gid < n) {
const int i... |
20,252 | #include<iostream>
#include<vector>
__global__
void vecadd(float *a, float *b, float *c, int num)
{
c[threadIdx.x] = a[threadIdx.x] + b[threadIdx.x];
}
int main(int argc, char *argv[])
{
const int num = 16;
std::vector<float> a(num, 1);
std::vector<float> b(num, 1);
std::vector<float> c(num, 0);
float... |
20,253 | #include "includes.h"
__global__ void ChannelBoxKernelB(const float* p_Input, float* p_Output, int p_Width, int p_Height, int p_Display) {
const int x = blockIdx.x * blockDim.x + threadIdx.x;
const int y = blockIdx.y * blockDim.y + threadIdx.y;
if ((x < p_Width) && (y < p_Height))
{
const int index = (y * p_Width + x) ... |
20,254 | #include "includes.h"
__global__ void OutputDeltaKernel(float *outputDeltas, float *target, float *outputActivations, float *outputActivationDerivatives)
{
int unitId = blockDim.x*blockIdx.y*gridDim.x //rows preceeding current row in grid
+ blockDim.x*blockIdx.x //blocks preceeding current block
+ threadIdx.x;
if (u... |
20,255 | // g++ -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_OMP -I../../../thrust/ -fopenmp -x c++ exemplo1.cu -o exemplo1 && ./exemplo1 < ../17-intro-gpu/stocks2.csv
// nvcc -arch=sm_70 -std=c++14 exemplo1.cu -o exemplo1 && ./exemplo1 < ../17-intro-gpu/stocks2.csv
#include <thrust/device_vector.h>
#include <thrust/host_vector... |
20,256 | #include <stdio.h>
#include <curand.h>
#include <curand_kernel.h>
static const unsigned int NUM_BUYERS = 1 << 10;
static const unsigned int MAX_BUYER_VALUE = 20;
static const unsigned int MAX_SELLER_VALUE = MAX_BUYER_VALUE;
// static const unsigned int MAX_TRADES = 1 << 10;
unsigned int *buyerValues;
unsigned int *s... |
20,257 | #include <stdio.h>
//__device__ __managed__ int x, y = 2;
int main() {
int nDevices;
double *a;
cudaMallocManaged(&a, 10 * sizeof(double));
cudaGetDeviceCount(&nDevices);
for (int i = 0; i < nDevices; i++) {
cudaDeviceProp prop;
cudaGetDeviceProperties(&prop, i);
printf("Device Number: %d\n",... |
20,258 | #include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
using namespace std;
//**************************************************************************
__global__ void transformacion_global(float * A, float * B, float * C, float * D, float * mx)
{
int tid = threadIdx.x;
int i = tid + b... |
20,259 |
#ifndef block_size_x
#define block_size_x 128
#endif
/*
* This kernel removes nodes with degree less than or equal to minimum.
* For the remaining nodes this kernel removes edges to nodes that have been removed.
*
* To remove a node we need to set its degree to zero
* To remove an edge we need to set its col... |
20,260 | // iircu_cu.txt template file, version: 01_01_01
// GENERATED FILE! MODIFY THIS FILE ONLY AT YOUR OWN RESPONSIBLITY!
// An identical behaviour to the simulation results can be assured only if this file remains unchanged!
// Code file of a general CUDA (R) IIR filter implementation
#include "iircu.cuh"
template<typena... |
20,261 | #define W 500
#define H 500
#define TX 32 // number of threads per block along x-axis
#define TY 32 // number of threads per block along y-axis
__global__
void distanceKernel(float *d_out, int w, int h, float2 pos) {
const int c = blockIdx.x * blockDim.x + threadIdx.x;
const int r = blockIdx.y * blockDim.y + t... |
20,262 | /*#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include<opencv2\imgproc.hpp>
#include <iostream>
#define DIM 1024
#define totalThreads 16
#define totalBlocks DIM/16
#define PI 3.1415
__glo... |
20,263 | #include <cuda.h>
#include <stdio.h>
__global__ void K1() {
unsigned sum = 0;
if (blockIdx.x == 0 && threadIdx.x == 0)
printf("K1 before\n");
for (unsigned ii = 0; ii < 1000; ++ii) {
sum += ii;
}
if (blockIdx.x == 0 && threadIdx.x == 0)
printf("K1 after\n");
}
__global__ void K2() {
printf("in K2\n");
}
in... |
20,264 | __device__ float spoc_fadd ( float a, float b ) { return (a + b);}
__device__ float spoc_fminus ( float a, float b ) { return (a - b);}
__device__ float spoc_fmul ( float a, float b ) { return (a * b);}
__device__ float spoc_fdiv ( float a, float b ) { return (a / b);}
#ifdef __cplusplus
extern "C" {
#endif
__global__... |
20,265 | #define TILE_DIM 32
template<typename T, typename R>
__device__ void common_mean(const T* matrix, R* result,
const int numRows, const int numColumns) {
__shared__ T tile[TILE_DIM][TILE_DIM];
int tx = threadIdx.x;
int ty = threadIdx.y;
tile[ty][tx] = 0;
#pragma unroll
for (int tr = 0... |
20,266 |
# include <stdio.h>
# include <stdlib.h>
# include <cuda.h>
# define N (2048)
# define THREADS_PER_BLOCK 512
__global__ void add(int *a, int *b, int *c)
{
int index = threadIdx.x + blockIdx.x * blockDim.x;
c[index] = a[index] + b[index];
}
int main(void)
{
int *a, *b, *c; // host copies of a, b, c
int... |
20,267 | #include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
//__constant__ int datos[1024];
__global__ void kernel(int *d_dst, int *d_src) {
int tId = threadIdx.x + blockIdx.x * blockDim.x;
d_dst[tId] = d_src[tId];
}
int main(int argc, char **argv) {
int *d_datos, *... |
20,268 | #include<stdlib.h>
#include<stdio.h>
#include<time.h>
#include<iostream>
#include <curand.h>
#include <curand_kernel.h>
#include <math.h>
using namespace std;
// CUDA settings
#define WARP_SIZE 32
#define WARP_COUNT 16
#define BLOCK_COUNT 13
class Rectangle {
public:
int top;
int bottom;
in... |
20,269 | #include "cuda.h"
#include "limits.h"
#include "math.h"
#include "stdio.h"
#include "stdlib.h"
#define BLOCK_SIZE 512
#define ELEMS_PER_THREAD 32
template <unsigned int blockSize>
__device__ void warpReduce(volatile double* s_data, unsigned int t) {
if (blockSize >= 64) s_data[t] += s_data[t + 32];
if (blockSize ... |
20,270 | #include "includes.h"
__global__ void cuda_filter2D(float *dst, float *src, float *kernel, int src_width, int src_height, int kernel_rows, int kernel_cols)
{
int row = threadIdx.y + blockIdx.y * blockDim.y;
int col = threadIdx.x + blockIdx.x * blockDim.x;
if(row < src_height && col < src_width)
{
float sum = 0;
for(int... |
20,271 | // Library imports.
#include <iostream>
using namespace std;
// Main method.
int main() {
cout << "Hello world!!";
return 0;
} |
20,272 | #include "Game.cuh"
#include "Screen.cuh"
Game::Game(Screen& initialScreen)
{
currentScreen = &initialScreen;
}
void
Game::onCreate()
{
currentScreen->onCreate();
currentScreen->isCreated = true;
currentScreen->onResume();
isCreated = true;
}
void
Game::update(int delta)
{
currentScreen->onUpdate(delta);
}... |
20,273 | #include "includes.h"
__global__ void substractWalkers ( const int dim, const int nwl, const float *xx0, const float *xxCP, float *xx1 ) {
int i = threadIdx.x + blockDim.x * blockIdx.x;
int j = threadIdx.y + blockDim.y * blockIdx.y;
int t = i + j * dim;
if ( i < dim && j < nwl ) {
xx1[t] = xx0[t] - xxCP[t];
}
} |
20,274 | #include <iostream>
using namespace std;
#define CHECK(value) { \
cudaError_t _m_cudaStat = value; \
if (_m_cudaStat != cudaSuccess) { \
cout<< "Error:" << cudaGetErrorString(_m_cudaSt... |
20,275 | #include "includes.h"
__global__ void advectParticles_OGL(float2 *part, float2 *v, int dx, int dy, float dt, int lb, size_t pitch) {
int gtidx = blockIdx.x * blockDim.x + threadIdx.x;
int gtidy = blockIdx.y * (lb * blockDim.y) + threadIdx.y * lb;
int p;
// gtidx is the domain location in x for this thread
float2 pter... |
20,276 | #include <stdlib.h>
#include <stdio.h>
#include <string.h>
// Tamanho do filtro, como definido na especificação: 5x5.
#define TAM_FILTRO 5
#define GRID 1
#define BLOCK 1024
#define TILE_WIDTH 28
#define BLOCK_WIDTH (TILE_WIDTH + (TAM_FILTRO - 1))
// Kernel de convolução
__global__ void convolucao(int *output, int *i... |
20,277 | #include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
#include <time.h>
#define NUM_THREADS 256
bool InitCUDA()
{
int count;
cudaGetDeviceCount(&count);
if(count == 0) {
fprintf(stderr, "There is no device.\n");
return false;
}
int i;
for(i = 0; i < count; i++) {
... |
20,278 | #include <stdio.h>
#include "cuda.h"
#define max(x,y) ((x) > (y)? (x) : (y))
#define min(x,y) ((x) < (y)? (x) : (y))
#define ceil(a,b) ((a) % (b) == 0 ? (a) / (b) : ((a) / (b)) + 1)
void check_error (const char* message) {
cudaError_t error = cudaGetLastError ();
if (error != cudaSuccess) {
printf ("CUDA error :... |
20,279 | /* Copyright (C) 2007-2012 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
* Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY... |
20,280 | // HelloWorldCUDA.cpp : 이 파일에는 'main' 함수가 포함됩니다. 거기서 프로그램 실행이 시작되고 종료됩니다.
//
#include <iostream>
// CUDA runtime
#include <cuda_runtime.h>
void printHelloWorld()
{
printf("Hello World!\n");
}
__global__ void printHelloWorldCUDA()
{
printf("Hello World from CUDA!\n");
}
int main()
{
printHelloWorld();
... |
20,281 | /*
Created based off of Cuda intro tutorial: https://devblogs.nvidia.com/even-easier-introduction-cuda/
Compile with g++: g++ add.cpp -o add
Complie with Cuda nvcc: nvcc add.cu -o add_cuda
* Must rename file to *.cu in order to compile with Cuda
*/
#include <iostream>
#include <string>
#include <math.... |
20,282 | #include "includes.h"
__global__ void cuda_gray(unsigned char *input, int offset, int streamSize, unsigned char* gray, int size) {
int gray_idx = (offset/3) + (blockIdx.x * blockDim.x + threadIdx.x);
int rgb_idx = (offset) + ((blockIdx.x * blockDim.x + threadIdx.x) * 3);
if (((blockIdx.x * blockDim.x + threadIdx.x)*... |
20,283 | /*
* This sample implements a separable convolution
* of a 2D image with an arbitrary filter.
*/
#include <stdio.h>
#include <stdlib.h>
//#include <cuda.h>
//#include <cuda_runtime_api.h>
unsigned int filter_radius;
#define FILTER_LENGTH (2 * filter_radius + 1)
#define ABS(val) ((val)<0.0 ? (-(val)) : (val))
#de... |
20,284 | #include <iostream>
#include <stdio.h>
#include <time.h>
//#define LENGTH 100
//#define rowA 4
//#define colA 1
//#define rowB 1
//#define colB 4
#define w 100
#define tw 10
//#define TILE_BLOCKS 10
//#define TILE_WIDTH 100
using namespace std;
__global__ void mat_mult_simple(int (*a)[w], int (*b)[w], int (*c)[w]){... |
20,285 | //////////////////////////////
//MultiDimKernelLaunch.cpp
//This program is an example posted online concerning the
//launch of multiple processes in a 2D format. The hope
//is that this program also contains incormation concerning
//the passing and use of 2D arrays using CUDA. This program
//is probably written in ... |
20,286 | #include "rgb2yuv.cuh"
#include <stdio.h>
#include <stdint.h>
__global__ void convert_rgb_to_yu12_kernel(uint8_t *rgb_input, uint8_t *yu12_output)
{
int y_idx = threadIdx.y + blockIdx.y * blockDim.y;
int x_idx = threadIdx.x + blockIdx.x * blockDim.x;
int idx = x_idx + y_idx * gridDim.x * blockDim.x;
in... |
20,287 | #include <cuda.h>
#include <stdlib.h>
#include <stdio.h>
#include <random>
#include <chrono>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/reduce.h>
void randomize_vector_float(thrust::host_vector<float> &h_vec, float start, float stop)
{
// randomize the seed, create distribu... |
20,288 | #include "includes.h"
__global__ void alpha_calculation(float * r_squared ,float * p_sum,float* alpha)
{
alpha[0] = r_squared[0]/p_sum[0] ;
} |
20,289 | #include <iostream>
using namespace std;
__global__ void square(int *d_out, int *d_in){
int idx = blockDim.x*blockIdx.x + threadIdx.x;
int i = d_in[idx];
d_out[idx] = i*i;
}
int main(){
const int ARRAY_SIZE = 1000;
const int ARRAY_BYTES = ARRAY_SIZE * sizeof(int);
int id = cudaGetDevice(&id);
... |
20,290 | #include<stdio.h>
#include<cuda.h>
#define row1 2 /* Number of rows of first matrix */
#define col1 3 /* Number of columns of first matrix */
#define row2 3 /* Number of rows of second matrix */
#define col2 2 /* Number of columns of second matrix */
__global__ void matproduct(int *l,int *m, int *n)
{
int x=blockI... |
20,291 | #include "includes.h"
// customDllFunctions.cu
//////////////////////////
// Template to write .dlls
//////////////////////////
/* Include the following directories for the program to run appropriately:
///////////////////////
in the VC++ directories:
$(VC_IncludePath);
$(WindowsSDK_IncludePath);
C:\ProgramData\NVID... |
20,292 | // kmrocki 1/15/19
__global__ void cudainit(unsigned int *canvas, int imgw) {
unsigned int x = blockIdx.x*blockDim.x + threadIdx.x;
unsigned int y = blockIdx.y*blockDim.y + threadIdx.y;
canvas[y*imgw+x] = (threadIdx.x + threadIdx.y + blockDim.x + blockDim.y ) % 7 == 0 ? 0xffffffff : 0x00000000;
}
__glob... |
20,293 | #include "includes.h"
#define DIMENSIONS 2
#define GPU_DEVICE_ZERO 0
__global__ void minimumClusterDistance(int threads, double *pointToClusterDistance, int *minimumPointToCluster, int pointsCounter, int clusterCounter)
{
/**
This function puts the point in the right cluster after computing smallest distances.
**... |
20,294 | #include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
__host__ __device__ int getKey0 (int *arr, int index){
return arr[ index + 1 ];
}
__host__ __device__ int getKey1 (int *arr, int index){
return arr[ index + 2 ];
}
__host__ __device__ int getParent (int *arr, int index){
return arr[ index + 3 ];
}
__ho... |
20,295 | #include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
__global__ void VecAdd(float* A, float* B, float*
C, int N_op,int op_loop){
// N_op : no of total ops
// op_loop: no of ops to do in a loop
// Host code
int j;
int i = blockDim.x * blockIdx.x + threadIdx.x;
if (i < ... |
20,296 | #include "cudamat_kernels.cuh"
#include "float.h"
const int NUM_THREADS = 32;
__device__ void reduceToMax(float* sdata, unsigned int tid){
//Synchronize threads to share shared memory data
__syncthreads();
float mySum = sdata[tid];
// do reduction in shared mem
if (NUM_THREADS >= 512) { if (tid < 256) { s... |
20,297 | #include "rwalk.cuh"
#include <stdio.h>
#include <assert.h>
int64_t * d_p_scan_list = NULL;
int64_t * d_v_list = NULL;
float * d_w_list = NULL;
int64_t *d_global_walk = NULL;
int tblocksize = 512;
int nblock;
void __global__ device_rwalk(
int m_walk_length,
int n_walks_per_node,
int total_num_nodes,
unsigned lo... |
20,298 | __global__ void addSubArray0 (int *A, int *B, int w, int h) {
for (int i = 0; i < w; i++) {
int j = blockIdx.x * blockDim.x + threadIdx.x;
if (j % 2 == 0) {
B[j * w + i] += A[i];
} else {
B[j * w + i] -= A[i];
}
}
} |
20,299 |
#include <stdio.h>
#include <stdlib.h>
#define N 30
//typedef long long int ll;
__global__ void align(char *key , char *s , int *scores , int n , int num)
{
int GP = -1 , MR = 1;
int index = threadIdx.x + blockIdx.x * blockDim.x;
if(index < num)
{
int i , j , k , tmp;
int nm[N + 1][N + 1];
char r1[2*N+... |
20,300 | #include <stdio.h>
#include <cuda_runtime_api.h>
#include <time.h>
/****************************************************************************
This program gives an example of a poor way to implement a password cracker
in CUDA C. It is poor because it acheives this with just one thread, which
is obviously not ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.