serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
301 | /*
* Copyright 1993-2015 NVIDIA Corporation. All rights reserved.
*
* NOTICE TO USER:
*
* This source code is subject to NVIDIA ownership rights under U.S. and
* international Copyright laws.
*
* This software and the information contained herein is being provided
* under the terms and conditions of a Source ... |
302 | #include<stdio.h>
#include<cuda.h>
__global__ void add(int *a,int *b,int *c)
{
int id = blockIdx.x*blockDim.x+threadIdx.x;
if(id<5)
c[id] = a[id] + b[id];
}
int main()
{
const int arraySize = 5;
float avg,sd;
int d[arraySize];
const int a[arraySize] = { 1, 2, 3, 4, 5 };
const int b[arra... |
303 | #include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include<thrust/transform.h>
#include<thrust/functional.h>
#include <iostream>
struct saxpi{
float k1;
float k2;
saxpi(float k1_, float k2_) :k1(k1_), k2(k2_)
{}
__host__ __device__ float operator()(float &x)const{
return x*k1 + k2;
}
};
i... |
304 | #include "includes.h"
// ERROR CHECKING MACROS //////////////////////////////////////////////////////
__global__ void computePathStates(int noPaths, int noDims, int nYears, int noControls, int year, float unitCost, float unitRevenue, int* controls, int noFuels, float *fuelCosts, float *uResults, float *uComposition, ... |
305 | #include <chrono>
#include <iostream>
//Kernel definition
template<typename T>
__global__
void copyKernel (T* out,
T* in,
const unsigned int N)
{
const unsigned int id = threadIdx.x + blockIdx.x * blockDim.x;
for (unsigned int i= id; i < N; i = i + blockDim.x * gridDim.x)
{
const unsigned el_id = i;
((T*)... |
306 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <time.h>
#define N 289
__global__ void MatMul(float d_A[N][N], float d_B[N][N], float d_C[N][N])
{
int i = threadIdx.x + blockIdx.x * blockDim.x;
int j = threadIdx.y + blockIdx.y * blockDim.y;
if (i < N && j < N)
{
... |
307 | #include <cuda_runtime_api.h>
__global__ void scaleKernel(float *src, float *dst, float scale)
{
const int idx = blockIdx.x * blockDim.x + threadIdx.x;
dst[idx] = src[idx] * scale;
}
int main()
{
float *a_dev;
float *b_dev;
float *a = new float[128*100];
float *b = new float[128*100];
cud... |
308 |
#include <iostream>
int static_cxx11_func(int);
void test_functions()
{
auto x = static_cxx11_func(int(42));
std::cout << x << std::endl;
}
int main(int argc, char** argv)
{
test_functions();
std::cout
<< "this executable doesn't use cuda code, just call methods defined"
<< std::endl;
std::cout <<... |
309 |
/* 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,float var_2,float var_3,float* var_4,int var_5,float var_6,float var_7,float var_8,float var_9,float var_10,float var_11,float var_12) {
if (comp <= (var_... |
310 | #include <stdio.h>
#include <sys/time.h>
#define NUM_BLOCKS 1000
#define NUM_THREADS 1000
#define ALL_THREADS NUM_BLOCKS * NUM_THREADS
__device__ void is_prime(int number, int *output) {
for (int i = 2; i*i < number; i++) {
if (number%i == 0) {
*output = 0;
return;
}
}
... |
311 | __global__ void wave1Drusanov1(double * f_nm, double * f_in,
double nu,int N){
int tid=threadIdx.x+blockIdx.x*blockDim.x;
if(tid<N){
int x_p = tid+1;
if(x_p==N) x_p=0;
double fp = f_in[x_p];
double f = f_in[tid];
f_nm[tid]=0.5*(fp+f)-(nu/3.)*(fp-f);
}
}
|
312 | /*
$ nvcc -o device_prop device_prop.cu
*/
#include <stdio.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <cuda_runtime_api.h>
void getCudaDeviceInfo()
{
int nDevices;
cudaGetDeviceCount(&nDevices);
for (int i = 0; i < nDevices; i++) {
cudaDeviceProp prop;
cudaGetDeviceProperties(... |
313 | #include <stdio.h>
__global__ void task_allocate(){
int i = threadIdx.x;
if(i==0){ // 计算 1+2+3+...+100
int n = 100;
int sum = 0;
while(n>0){
sum+=n;
n--;
}
printf("1+2+...+100 = %d\n",sum);
}else if(i==1){ // 计算 10 的阶乘
int n = 10;
... |
314 | #include <cstdio>
#include <cstdlib>
#include <iostream>
using std::cout;
using std::endl;
#define BLOCKSIZE 50
#define RADIUS 10
#define maxn 2000
#define size maxn*sizeof(int)
__global__ void add(const int *a, const int *b, int *c) {
c[threadIdx.x + blockIdx.x * blockDim.x] =
a[threadIdx.x + blockI... |
315 | #include <thrust/device_vector.h>
#include <thrust/tabulate.h>
#include <stdio.h>
#include <iostream>
#include <time.h>
#include <chrono>
struct generator{
__host__ __device__
int operator() (const int& i) const{
return i % 2 == 0 ? 1 : -1;
}
};
int main(int argc, char** argv){
//If there are no argum... |
316 | #define MODE_MANDEL 1
#define MODE_MANDEL_DISTANCE 2
#define MODE_JULIA 3
#define WIDTH gridDim.x*blockDim.x
#define HEIGHT gridDim.y*blockDim.y
#define X ((blockIdx.x * blockDim.x) + threadIdx.x)
#define Y ((blockIdx.y * blockDim.y) + threadIdx.y)
__device__ inline float2 mul(const float2 pFF1, const float2 pFF2) {
... |
317 | #include<stdio.h>
__global__ void hello_from_gpu(){
int bx = blockIdx.x;
int by = blockIdx.y;
int bz = blockIdx.z;
int gdx = gridDim.x;
int gdy = gridDim.y;
int gdz = gridDim.z;
int tx = threadIdx.x;
int ty = threadIdx.y;
int tz = threadIdx.z;
int bdx = blockDim.x;
int bdy... |
318 | // allocate pitch memory and cudaArray
#include <stdio.h>
#include <memory.h>
#include <cuda.h>
#include <cuda_runtime.h>
#define NX 1003
#define NY 1024
__global__ void PLShift(float* odata, int pitch, int width, int height, int shiftx, int shifty, cudaTextureObject_t texRefPL ){
int global_x_ = threadIdx.x + ... |
319 | #include "includes.h"
// includes, project
#define PI 3.1415926536f
int MaxThreadsPerBlock;
int MaxThreadsX;
int MaxThreadsY;
// Conversion d'un vecteur réel en vecteur complexe
// Conversion d'un vecteur complexe en vecteur réel
// Multiplie point par point un vecteur complex par un vecteur réel
// Applique... |
320 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <cuda.h>
#include <device_functions.h>
#include <cuda_runtime_api.h>
#include <iostream>
template<typename T>
struct ShouldSwap
{
__host__ __device__
virtual bool operator() (const T left, const T right) const;
};
template <typename T>
__host... |
321 | #include <cuda.h>
#include <cufft.h>
#include <cuda_profiler_api.h>
#include <stdio.h>
template<typename T>
__device__ __forceinline__ T ldg(const T* ptr) {
#if __CUDA_ARCH__ >= 350
return __ldg(ptr);
#else
return *ptr;
#endif
}
extern "C"
__global__
void SemblanceDiv(
int nx
, int ny
, int nz
, float * numerator... |
322 | #include "includes.h"
__device__ __forceinline__ int mirror(int index, int len){
int s2 = 2 * len - 2;
if(index < 0){
index = s2 * (-index / s2) + index;
return index <= 1 - len ? index + s2 : -index;
}
if(index >= len){
index -= s2 * (index / s2);
if(index >= len)
index = s2 - index;
return index;
}
if(index < 0 || in... |
323 | #include <stdio.h> //printf
#include <stdlib.h>//srand, rand
#include <time.h> //time
#include <fstream>
#include <string>
#include <iostream>
#include <ctime>
#include <ratio>
#include <chrono>
//globalne ustawienia
const unsigned BLOCKS_PER_GRID = 16;
const unsigned THREADS_PER_BLOCK = 256;
class Matrix{
unsigne... |
324 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <limits.h>
#include <math.h>
#include <cuda.h>
#include <algorithm>
#define BLOCK_SIZE 1024
__device__ unsigned int counter, counter_2;
__constant__ const unsigned int INTMAX = 2147483647;
// structure for dictionary
struct huffm... |
325 | #include "includes.h"
__global__ void rotate2(float*a,float b, float * c, int sx,int sy,int sz, int dx, int dy, int dz)
{
int ids=(blockIdx.x*blockDim.x+threadIdx.x); // id of this processor
int x=(ids + dx)%sx; // advance by the offset steps along the chain
int y=(ids/sx + dy)%sy;
int z=(ids/(sx*sy) + dz)%sz;
int idd... |
326 |
#include <stdio.h>
#include <stdlib.h>
#define ROWS 2
#define COLS 3
// F1
// __global__ void add(int *a, int *b, int *c){
// int idx = blockIdx.x*blockDim.x + threadIdx.x;
// if (idx<ROWS*COLS){
// c[idx] = a[idx] + b[idx];
// }
// }
// F2
__global__ void add(int *a, int *b, int *c){
int col = blockIdx... |
327 | //nvcc -ptx "E:\семестр 7\НИР\kernel.cu" -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64"
//nvcc -ptx "E:\семестр 7\НИР\kernel.cu" -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64" -gencode arc... |
328 | #include <stdio.h>
#include <chrono>
#include <iostream>
#include <cmath>
#define TPB 256
/*
array size 5000: CPU computing time:1.21e-05 GPU computing time:0.167205 The difference is 0.000000
array size 50000: CPU computing time:0.0001292 GPU computing time:0.158399 The difference is 0.000000
array size 500000: CPU ... |
329 | #include "includes.h"
__global__ void big_add(int *a, int *b, int *c, unsigned int N){
int tid;
tid = blockIdx.x * blockDim.x + threadIdx.x;
int stride = blockDim.x * gridDim.x;
while(tid < N){
c[tid] = a[tid] + b[tid];
tid += stride;
}
} |
330 | #include <iostream>
// Kernel detenition
__global__ void MatAdd(int N, float *A, float *B, float *C){
int i = threadIdx.x;
int j = threadIdx.y;
C[N*i + j] = A[N*i + j] + B[N*i + j];
}
int main(){
float *A, *B, *C;
int N = 100;
cudaMalloc((void**)&A, N*N*sizeof(float));
cudaMalloc((void**)&B... |
331 | // *----------------------------------------------
// Author Contact Information:
// Hao Gao
// hao.gao@emory.edu || hao.gao.2012@gmail.com
// Department of Mathematics and Computer Science, Emory University
// Department of Radiology and Imaging Sciences, Emory University
//
// Copyright (c) Hao Gao 2012
// ----... |
332 | #include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/functional.h>
#include <thrust/transform.h>
#include <thrust/iterator/zip_iterator.h>
#include <thrust/random.h>
#include <thrust/inner_product.h>
// This example shows how thrust::zip_iterator can be used to create a
// 'virtual' arra... |
333 | #include <cuda_runtime_api.h>
__global__ void batchmap_add_kernel(
float *xs,
int frame_len,
int batch_size,
float alpha,
const float *scalars)
{
int idx = threadIdx.x + blockIdx.x * blockDim.x;
int i = idx % frame_len;
int batch_idx = idx / frame_len;
if ((i < frame_len) && (batch_idx < ba... |
334 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include "cuda.h"
#include "device_atomic_functions.h"
#include <stdio.h>
#include "Bfs.cuh"
__global__ void bfs_kernel(unsigned int* current_set, unsigned int* new_set,
int current_set_size, int* current_set_size_new,
Node* node_list, Edge* edge_list... |
335 | #include <stdio.h>
__global__ void kernel(unsigned char *p)
{
// int i = blockIdx.x;
// int j = blockIdx.y;
int i = threadIdx.x;
int j = threadIdx.y;
p[i * 9 + j] = (i + 1) * (j + 1);
}
int main( void )
{
unsigned char table[81];
unsigned char *mem;
cudaMalloc((void **)&mem, 81);
// dim3 b(9, 9);
dim3 t(9, 9);... |
336 | #include "Backpropogation.cuh"
#include "NeuralNetwork.cuh"
/**
* Gets the errors associated with each neuron's output
* Parameter nn: the neural network to get the error for
* Parameter errors: the matrix to put the errors in
* Parameter layer: the layer to get the error for
* Return: nothing
*/
__global... |
337 | //add 2 arrays in parallel, often this is faster on CPU than GPU
//reason is computation is not intense, require more data than
//computation
#include <cstdlib>
#include <ctime>
#include <iostream>
#define BSZ 2048
#define TSZ 1024
#define TEST_SIZE BSZ * TSZ
#define TT float
#define EPS 10e-6
using namespace std;
... |
338 | /* Based on code from here: http://devblogs.nvidia.com/parallelforall/easy-introduction-cuda-c-and-c/ */
#include <stdio.h>
#include <stdlib.h>
#define N (1000*1000*8)
/* Calculate SAXPY, single-precision vector math */
/* y[i]=a*x[i]+y[i] */
__global__
void saxpy (int n, float a, float *x, float *y) {
int ... |
339 | #include <emmintrin.h>
#include <sys/time.h>
#include <stdio.h>
//#include <>
int N = 64000000;
int nTrapsPow2 = 2046;
int nSumsPow2 = 10;
int nTraps;
int nSums;
int doPrint = 0;
/... |
340 | /***************************************************
* Module that applay the function sigmoid to all the elements of the matrix
* Author: Alonso Vidales <alonso.vidales@tras2.es>
*
* To be compiled with nvcc -ptx matrix_sum_all.cu
* Debug: nvcc -arch=sm_20 -ptx matrix_sum_all.cu
*
******************************... |
341 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
/*
CUDA C keyword __global__ indicates that a function
- runs on the device
- and is called from host code
*/
// define kernel for add two integers
__global__ void add_kernel(int *dev_c, int const *dev_a, int co... |
342 | #include "LinkTest.cuh"
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
__global__ void addKernel(int* c, const int* a, const int* b)
{
int i = threadIdx.x;
c[i] = a[i] + b[i];
}
void addWithCuda(int* c, const int* a, const int* b, unsigned int size)
{
int* dev_a = 0;
int* dev_b = 0;
int* dev_c ... |
343 | #include "includes.h"
__global__ void device_ll ()
{
__shared__ double partial_ll[REDUC_THREADS] ;
int i, n, ntarg, index ;
double sum_ll ;
index = threadIdx.x ;
n = d_ncases ;
ntarg = d_ntarg ;
sum_ll = 0.0 ;
for (i=blockIdx.x*blockDim.x+index ; i<n ; i+=blockDim.x*gridDim.x)
sum_ll -= log ( d_output[i*ntarg+d_class... |
344 | #include <stdio.h>
#include <stdint.h>
#include <chrono>
// Constant values.
#define TB_SIZE 256
uint64_t ARRAY_SIZE = 300'000'000;
// Check if the given pointer is NULL.
#define PTR_CHECK(cmd) if ((x) == NULL) { \
printf("ERROR: null pointer at line %d\n", __LINE__); abort(); }
// Check if the given command ha... |
345 | #include "includes.h"
__global__ void kernel_test0_global_write(char* _ptr, char* _end_ptr)
{
unsigned int* ptr = (unsigned int*)_ptr;
unsigned int* end_ptr = (unsigned int*)_end_ptr;
unsigned int* orig_ptr = ptr;
unsigned int pattern = 1;
unsigned long mask = 4;
*ptr = pattern;
while(ptr < end_ptr){
ptr = (unsig... |
346 | // This example demonstrates the use of shared per-block arrays
// implement an optimized dense matrix multiplication algorithm.
// Like the shared_variables.cu example, a per-block __shared__
// array acts as a "bandwidth multiplier" by eliminating redundant
// loads issued by neighboring threads.
#include <stdlib.h>... |
347 | /////// /////////////////////////////////////////////////////////////////////
// Calculate scalar products of VectorN vectors of ElementN elements on CPU.
// Straight accumulation in double precision.
////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <cmath>
usin... |
348 | #include "includes.h"
__global__ void Kernel(int* a,int* b,int *c,int n){
int i = blockIdx.x*blockDim.x + threadIdx.x;
__shared__ extern int shared_mem[];
int reg;
if(i>= n) return;
reg = a[i] + b[i];
shared_mem[i] = reg;
c[i] = shared_mem[i];
} |
349 | #include "sha5.cuh"
#include <string.h>
__device__ static const uint64_t rhash_k512[80] = {
I64(0x428a2f98d728ae22), I64(0x7137449123ef65cd), I64(0xb5c0fbcfec4d3b2f),
I64(0xe9b5dba58189dbbc), I64(0x3956c25bf348b538), I64(0x59f111f1b605d019),
I64(0x923f82a4af194f9b), I64(0xab1c5ed5da6d8118), I64(0xd807aa98a3030242)... |
350 | /*
* gapped_extender_gpu_ref.cu
*
* Created on: 2014/08/23
* Author: shu
*/
#ifndef GAPPED_EXTENDER_GPU_REF_CU_
#define GAPPED_EXTENDER_GPU_REF_CU_
/*
#include "gapped_extender_gpu.h"
#include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <thrust/system/cuda/experimental/pinned_allocat... |
351 | #include "includes.h"
__global__ void finishCentroids(int* centroidMass, unsigned int* centroidCount, float* centroids) {
int centroidNumber = blockIdx.y * blockDim.y + threadIdx.y;
int dimensionNumber = blockIdx.x * blockDim.x + threadIdx.x;
if ((centroidNumber < 32) && (dimensionNumber < 34)) {
float totalCount = (fl... |
352 | #include <cuda_runtime.h>
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <sys/time.h>
//Tamaño de matrices (cuadradas)
#define N 1024
//Kernel
__global__ void mul(int * A, int * B, int * C){
int i = blockIdx.x;
int j = threadIdx.x;
//TODO -> Calcular elemento C(i,j)
}
int main(){
struct time... |
353 | #include <cuda.h>
#include <stdio.h>
#include <sys/time.h>
#define BLOCK_SIZE 16
__global__ void lud_diagonal(float *m, int matrix_dim, int offset)
{
int i,j;
__shared__ float shadow[BLOCK_SIZE][BLOCK_SIZE];
/* Each thread block, i.e. 1D 16 threads, loads a
* 2D block, i.e. 16x16, of data from the diagona... |
354 | #include<stdio.h>
#include<stdlib.h>
#include<time.h>
# define FILL_PERCENT 10
# define SIZE 250
# define BLOCK_SIZE 32
__global__ void spmvNormal( int *M, int *V, int *res){
int idx = blockIdx.x * blockDim.x + threadIdx.x;
int temp,i;
if (idx < SIZE) {
temp = 0;
//dot product for one row
... |
355 | //pass
//--blockDim=10 --gridDim=64 --no-inline
#include "cuda.h"
__global__ void foo() {
__shared__ int A[10][10];
A[threadIdx.y][threadIdx.x] = 2;
}
|
356 | #include "includes.h"
__global__ void applyLinearFunction(int size, const short *x, short *y, short a, short b) {
const long ix = threadIdx.x + blockIdx.x * (long)blockDim.x;
if (ix < size) {
y[ix] = a + b * x[ix];
}
} |
357 | #include "includes.h"
__global__ void generateGaussian_kernel(float* og, float delta, int radius)
{
int x = threadIdx.x - radius;
og[threadIdx.x] = __expf(-(x * x) / (2 * delta * delta));
} |
358 | #include <iostream>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <fstream>
#include <sstream>
#include "training_reader.cuh"
using namespace std;
//-----------------------Training Class to load training data-------------------
// class TrainingData
// {
// public:
// __host__ TrainingData(const... |
359 | #include "includes.h"
__device__ float sigmoid(float x) {
return 1.0f / (1 + __expf(-x));
}
__global__ void matrixMultiplyUpdateWeights_sigmoid(float * A, float * B, float * C, int numARows, int numAColumns, int numBRows, int numBColumns, int numCRows, int numCColumns, float learning_rate) {
//@@ Insert code to impleme... |
360 | extern "C"
__global__ void calc_entropy_atomic(float *float_image_in, float *entropy_out, int blk_size) {
//calculate entropy of a block through a single thread
__shared__ float sum;
if (threadIdx.x == 0 && threadIdx.y == 0) {
sum = 0.0;
}
__syncthreads();
int blocksize = blk_size*blk_size;
//vertical offset t... |
361 | __global__ void dummyKernel(){
unsigned int count = 0;
for(unsigned int i = 0; i < 1000; i++){
count += i;
}
}
void dummyKernelWrapper(){
dummyKernel<<<1,1>>>();
} |
362 | #include <cuda.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <time.h>
#include <iostream>
#define DTYPE float
__global__ void kernel(float *a, float *x, float* buff,int Xblocks,int size,bool comp,int toreduce)
{
int i=threadIdx.x+blockIdx.x*blockDim.x;
int j=threadIdx.y+blo... |
363 | #include <iostream>
#include <cstdlib>
#include <ctime>
#include "cuda_runtime.h"
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
using namespace std;
__global__ void action(int *array1, int* array2, int* array_res)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
switch(i % 3)
{
c... |
364 | //#include "shallow.h"
#include <iostream>
#include <time.h>
#include <stdlib.h>
#define RELU(a) ((a > 0) ? a : 0)
#define KERNEL_SIZE(n_C) ((n_C * 2 > 8) ? 8 : n_C * 2)
struct layer_param {
int M; //Ilosc tablic podawanych na wejscie
int pad; //Grubosc warstwy zer na krawedziach (zero-padding)
... |
365 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
//Defining number of elements in Array
#define arraySize 5
//Defining number of thread per block
#define threadPerBlock 5
// 秩排序算法,对于数组中每个元素,统计小于它的元素个数
__global__ void addKernel(int *d_a, int *d_b)
{
// 当前元素在排序后数组中的位置
int count = 0;
... |
366 | /*
*
* Programa de Introducción a los conceptos de CUDA
* Mariana Hernández
* Alan Córdova
*
*
*/
#include <stdio.h>
#include <stdlib.h>
/* Declaración de métodos/
/* Utilidad para checar errores de CUDA */
void checkCUDAError(const char*);
/* Kernel para sumar dos vectores en un sólo bloque de hilos */
__g... |
367 | #include <stdio.h>
#define WIDTH gridDim.x*blockDim.x
#define HEIGHT gridDim.y*blockDim.y
#define X ((blockIdx.x * blockDim.x) + threadIdx.x)
#define Y ((blockIdx.y * blockDim.y) + threadIdx.y)
extern "C"
__global__ void computeFloat(
int *iters,
float4 area,
int maxIterations,
float sqrEscape... |
368 | #include "includes.h"
__global__ void pnpoly_cnGPU1(const float *px, const float *py, const float *vx, const float *vy, char* cs, int npoint, int nvert)
{
int i = blockIdx.x*blockDim.x + threadIdx.x;
if (i < npoint) {
int j, k, c = 0;
for (j = 0, k = nvert-1; j < nvert; k = j++) {
if ( ((vy[j]>py[i]) != (vy[k]>py[i])) ... |
369 | #include <cuda.h>
int main(int argc, char ** argv) {
int deviceCount;
cudaGetDeviceCount(&deviceCount);
for (int dev = 0; dev < deviceCount; dev++) {
cudaDeviceProp deviceProp;
cudaGetDeviceProperties(&deviceProp, dev);
if (dev == 0) {
if (deviceProp.major == 9999 &... |
370 | /**
* Writed By: Huaxia Wang
* hwang122@hawk.iit.edu
**/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define CHECK_ERR(x) \
if (x != cudaSuccess) { \
fprintf(stderr, "%s in %s at line %d\n", \... |
371 | #include <stdio.h>
#include <stdlib.h>
#include <string>
#include <curand.h>
#include <curand_kernel.h>
#define ull unsigned long long
#define ld long double
#define GTX_1060_BLOCKS 1280
#define WARP_SIZE 32 // количество потоков в блоке
/**
* Запуск по всем блокам. После выполнения функции в per_blocks_sum лежат
... |
372 | #include <stdio.h>
#include <stdlib.h>
__device__ int d_value;
__global__ void test_Kernel()
{
int threadID = threadIdx.x;
d_value = 1;
printf("threadID %-3d d_value%3d\n",threadID,d_value);
}
int main()
{
int h_value = 0;
test_Kernel<<<1,2>>>();
cudaMemcpyFromSymbol(&h_value,d_value,
sizeof(int),0,cudaMemcpyD... |
373 | #include "includes.h"
__global__ void Subtract(float *d_Result, float *d_Data1, float *d_Data2, int width, int pitch, int height)
{
const int x = blockIdx.x*SUBTRACT_W + threadIdx.x;
const int y = blockIdx.y*SUBTRACT_H + threadIdx.y;
int p = y*pitch + x;
if (x<width && y<height)
d_Result[p] = d_Data1[p] - d_Data2[p];
_... |
374 | #include <iostream>
#include <time.h>
#include <string>
#include <vector>
#include <sstream>
#include <cuda_runtime.h>
#include <math.h>
#include <fstream> // Libreria para leer archivos
#include <typeinfo> // for 'typeid' to work
#include <tuple>
using namespace std;
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~... |
375 | #include <stdio.h>
#include <curand.h>
#define GRID_SIZE 32
#define BLOCK_SIZE 512
#define NUM_TRY 10000
/**
* 乱数に基づいて(x,y)を生成し、円の中に入る確率を計算し、devResultsに格納する。
*/
__global__
void compute_pi(float* devResults, float* devRandom){
int idx = blockDim.x * blockIdx.x + threadIdx.x;
int step = gridDim.x * blockDim.x * 2... |
376 | #include "includes.h"
__global__ void naiveGmem(float *out, float *in, const int nx, const int ny)
{
// matrix coordinate (ix,iy)
unsigned int ix = blockIdx.x * blockDim.x + threadIdx.x;
unsigned int iy = blockIdx.y * blockDim.y + threadIdx.y;
// transpose with boundary test
if (ix < nx && iy < ny)
{
out[ix * ny + iy]... |
377 | #include "cuda_runtime.h"
namespace gccl {
void GCCLSetCudaDevice(int dev_id) { cudaSetDevice(dev_id); }
} // namespace gccl |
378 | #include "includes.h"
__global__ void bcnn_cuda_add_bias_kernel(float *output, float *bias, int num_channels, int spatial_size)
{
int offset = blockIdx.x * blockDim.x + threadIdx.x;
int channel = blockIdx.y;
int batch_size = blockIdx.z;
if (offset < spatial_size)
output[(batch_size * num_channels + channel) * spatial_... |
379 | #include <stdio.h>
// Luis Miguel García Marín
__global__
void initWith(float num, float *a, int N)
{
int index = threadIdx.x + blockIdx.x * blockDim.x;
int stride = blockDim.x * gridDim.x;
for(int i = index; i < N; i += stride)
{
a[i] = num;
}
}
__global__
void addVectorsInto(float *result, float *a... |
380 | #define CUDA_BLOCK_X 128
#define CUDA_BLOCK_Y 1
#define CUDA_BLOCK_Z 1
__global__ void _auto_kernel_2(int a[5][5],int b[5][5],int i)
{
int thread_x_id;thread_x_id = blockIdx.x * blockDim.x + threadIdx.x;
int thread_y_id;thread_y_id = blockIdx.y * blockDim.y + threadIdx.y;
if (thread_x_id && thread_y_id)
if ... |
381 | #include <cuda.h>
#include <stdio.h>
__device__
int ceilDiv(int num1,int num2)
{
int adder = 0;
if(num1%num2) adder = 1;
return ((int)num1/num2)+adder;
}
__global__
void reduceVec(int* vecA,int* answer,int size)
{
int i = threadIdx.x;
int halfSize = ceilDiv(size,2);
int prevSize = size;
while(halfSize>1)
{... |
382 | //MatrixMult.cu
#include <stdio.h>
#include <cuda.h>
#include <stdlib.h>
__global__ void gpu_sort(int *a,int *b,int *c, int N) {
int tid = threadIdx.x + blockDim.x * blockIdx.x;
int count = 0;
int d;
for(d=0;d<N;d++) {
if(a[d] < a[tid]) {
count++;
}
}
c[count] = a[tid];
}
int main(int argc, cha... |
383 | #include "includes.h"
//#define ITEM_COUNT 2
#define _PI 3.14159265358979323846
#define _PI2 1.57079632679489661923
#define _RAD 6372795
using namespace std;
cudaError_t addWithCuda(int *c, const int *a, const int *b, unsigned int size);
__global__ void d_cudainit(int *a, int *b)
{
int i = threadIdx.x;
if (i=... |
384 | #include <stdio.h>
#include <cuda_runtime.h>
__global__ void hello_world_from_gpu(void)
{
printf("Hello World from GPU\n");
return;
}
int main(void)
{
printf("Hello World from CPU\n");
hello_world_from_gpu <<<1, 1>>> ();
cudaDeviceReset();
return 0;
}
|
385 | #include<stdlib.h>
#include<stdio.h>
#include<time.h>
#define n 1024
#define block_size 32
/*
__global__ void mult_mat(int *a, int *b, int *c) {
int blockRow = blockIdx.y, blockCol = blockIdx.x;
int row = threadIdx.y, col = threadIdx.x;
for (int m = 0; m < (n/block_size); ++m) {
}
}
*/
__global__ void mul_ma... |
386 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cuda_runtime.h>
#define MAX_ARRAY_SIZE 1000000
/*
* Check GPU device
*/
void check_dev(void) {
int deviceCount;
cudaGetDeviceCount(&deviceCount);
if (deviceCount == 0) {
printf("!! Error: no devices supporting CUDA.\n");
... |
387 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define LSIZE 31
#define MIN_LIM 12.0
#define MAX_LIM 30.0
void check_input(int argc,char* argv[]);
__global__ void examine(float *d_coordinates,int *d_coords_within,int d_lines);
long calc_lines(char *filename);
int main(int argc,char * ar... |
388 | /*********************************************************************
*
* © (or copyright) 2020. Triad National Security, LLC.
* All rights reserved.
* This program was produced under U.S. Government contract
* 89233218CNA000001 for Los AlamosNational Laboratory (LANL),
* which is operated by Triad National Sec... |
389 | #include "includes.h"
/*numCirs: num of total circles
*/
__global__ void kernelCompact(float* devSrc, float* devDst, unsigned int* devPredicate, unsigned int* devPos, int numCirs, int offset)
{
int idx = blockDim.x * blockIdx.x + threadIdx.x; //index of the circles
if (idx >= numCirs)
{
return;
}
unsigned int isIn =... |
390 | #include <iostream>
#include <cuda.h>
#include <cuda_runtime.h>
using namespace std;
__global__ void func(int *dev_arr1, int *dev_arr2, int *dev_dot){
__shared__ int temp[3];
int index = threadIdx.x;
if (index < 3){
temp[index] = dev_arr1[index] * dev_arr2[index];
}
__syncthreads();
if (index == 0){
... |
391 | #include <stdio.h>
#include <stdlib.h>
#include <algorithm>
// Change the code here:
// This should be changed to GPU kernel definition
void dot(int numElements, const float3* a, const float3* b, float* c)
{
for (int i = 0; i < numElements; i++)
{
c[i] = a[i].x*b[i].x + a[i].y*b[i].y + a[i].z*b[i].z;
... |
392 | #include <assert.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
/*!
* \brief calculate normalized frequency matrix
*
* Normalized value(x) = \f$ \frac{ X - min }{ max - min }\f$
* \return normalized matrix
*
*/
int normalize(
int *in_mat, /*!< [in] input matrix *... |
393 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
static __device__ __forceinline__ unsigned int bfind32_cuda(unsigned int x)
{
unsigned int ret;
asm volatile("bfind.u32 %0, %1;" : "=r"(ret) : "r"(x));
return 31 - ret;
}
__device__ __host__ unsigned int nlz32_IEEE(unsigned int x... |
394 | #include <thrust/scan.h>
#include <thrust/device_vector.h>
#include <thrust/count.h>
#include <thrust/functional.h>
#include <iostream>
#include <iomanip>
struct not_zero{
__host__ __device__ bool operator()(const float a)
{
return a != 0;
}
};
int main()
{
thrust::device_vector<int> V(10, 0);
V[0] = 1;
V... |
395 | /*
Two Dimensional (2D) Image Convolution : A Basic Approch
Image Convolution is a very basic operation in the field of Image Processing.
It is required in many algorithms in Image Processing. Also it is very compute intensive task as
it involves operation with pixels.
Its a transformation which involves a Mask and a... |
396 | #include<stdio.h>
#include<stdlib.h>
__global__ void matadd(int *d_a,int *d_b,int *d_c, int n){
int idx=threadIdx.x;
if(idx<n)
d_c[idx]=d_a[idx]+d_b[idx];
}
int main(){
int n;
scanf("%d",&n);
cudaEvent_t start,stop;
float escap_time;
cudaEventCreate(&start);
cudaEventCreate(&stop);
cudaEventRecord(start,0);
... |
397 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<getopt.h>
#include <assert.h>
#include <cuda.h>
#include <chrono>
#define RAND_RANGE_MIN -10.0
#define RAND_RANGE_MAX 10.0
#define SEED 123
#define JACOBI_DEBUG 0
enum ERROR_TYPE { MEMCPY,... |
398 | #include<iostream>
#include<cuda.h>
#include<cuda_runtime.h>
#define N 10
using namespace std;
__global__ void mul(int* a_d, int n){
// printf("%d %d %d\n", blockIdx.x,blockDim.x,threadIdx.x);
int index = blockIdx.x * blockDim.x + threadIdx.x;
if(index < n){
a_d[index] *= 5;
}
}
int main(){
cudaEvent_t start... |
399 | /*
* Copyright (c) 2021-2023, NVIDIA CORPORATION.
*
* 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 required by applicable... |
400 | #include <algorithm>
#include <iostream>
#include <vector>
#include <time.h>
typedef unsigned long long data_t;
static inline void check(cudaError_t err, const char* context) {
if (err != cudaSuccess) {
std::cerr << "CUDA error: " << context << ": "
<< cudaGetErrorString(err) << std::endl;
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.