serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
17,301 | #include <stdio.h>
#include <cuda_runtime.h>
#include <cuda.h>
#include <stdlib.h>
#include "device_launch_parameters.h"
#include <thrust/scan.h>
/*
__global__ void dfs_parallel(int *d_frontier1,int *d_vertex,int *d_loc,int *d_edge,int *d_frontier2)
{
int i = blockIdx.x * gridDim.y + blockIdx.y,j=i*blockDim.x*blockDim... |
17,302 | #include<cuda.h>
#include<stdio.h>
#include<math.h>
#include<ctime>
__global__
void vecMulMatrixKernel(float* A, float* B, float* C, int n){
// clock_t start = clock();
int column = threadIdx.x + blockDim.x * blockIdx.x;
int row = threadIdx.y + blockDim.y * blockIdx.y;
//printf("%d ",blockDim.x);
if(row<n && column... |
17,303 | #include "includes.h"
#define NUMBER_OF_BLOCKS 256
#define NUMBER_OF_THREADS 64
// ==========
// Macro taken from:
// https://stackoverflow.com/questions/14038589/what-is-the-canonical-way-to-check-for-errors-using-the-cuda-runtime-api
__device__ double dotProduct(double *a, double *b, int size) {
double result = 0;
... |
17,304 | /*
Now we make the matrix much bigger
g++ -pg seq_matrix_big_mul.c -o seq_matrix_big_mul
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#define N_THREADS 32
int num_rows_A = 2000; int num_rows_B = 2000; int num_rows_C = 2000;
int num_cols_A = 2000; int num_cols_B = 600; int num_co... |
17,305 | // Using different memory spaces in CUDA
#include <stdio.h>
/**********************
* using local memory *
**********************/
// a __device__ or __global__ function runs on the GPU
__global__ void use_local_memory_GPU(float in)
{
float f; // variable "f" is in local memory and private to each thread
... |
17,306 | #include<stdio.h>
#define TBP 256
__global__ void hello_world()
{
printf("Hello World! My threadId is %d\n",threadIdx.x);
__syncthreads();
}
int main()
{
hello_world<<<1,TBP>>>();
cudaDeviceSynchronize();
return 0;
}
|
17,307 | #include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <cuda.h>
#include <math.h>
#define BLOCK_SIZE 1024
// Kernel for the first iteration of parallel scan
__global__ void parallelScan(float *d_out, float *d_in, int length) {
volatile extern __shared__ double sharedData[];
int tid = threadIdx.x + blo... |
17,308 | /*
Swap the elements of a vector: the first with the last and so on...
*/
#include<cuda.h>
#include<stdlib.h>
#include<stdio.h>
#include<sys/time.h>
void checkCUDAError(const char* msg);
__global__ void rebalta (float *dati, int n)
{
int id;
int t;
id=blockIdx.x*blockDim.x+threadIdx.x;
t=dati[n-id-1];
da... |
17,309 | #include "includes.h"
__global__ void cunnx_BlockSparse_updateGradOutput_kernel( float *_gradOutput, float* gradOutputScale, const float *gradOutput, const float *output, const float *outputScale, int outputWindowSize, int outputSize)
{
__shared__ float buffer[BLOCKSPARSE_THREADS];
int tx = threadIdx.x;
int i_step = bl... |
17,310 | /*
* Copyright (c) 2009 Steve Worley < m a t h g e e k@(my last name).com >
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PR... |
17,311 | #include "includes.h"
using namespace std;
// GPU Code
// __global__ indicates that it is a GPU kernel, that can be called from the CPU
// CPU Code
__global__ void Add(float* d_a, float* d_b, float* d_c, int N)
{
int id = blockIdx.x * blockDim.x + threadIdx.x;
if(id < N)
d_c[id] = d_a[id] + d_b[id];
} |
17,312 | #include <stdio.h>
// Matrices are stored in row-major order:
// M(row, col) = *(M.elements + row * M.width + col)
typedef struct {
int width;
int height;
float* elements;
} Matrix;
void print_matrix(const Matrix mat) {
for(int r=0; r<mat.height; ++r) {
for(int c=0; c<mat.width; ++c) {
... |
17,313 | #define COALESCED_NUM 16
#define blockDimX 256
#define blockDimY 1
#define gridDimX (gridDim.x)
#define gridDimY (gridDim.y)
#define idx (blockIdx.x*blockDimX+threadIdx.x)
#define idy (blockIdx.y*blockDimY+threadIdx.y)
#define bidy (blockIdx.y)
#define bidx (blockIdx.x)
#define tidx (threadIdx.x)
#define tidy (threadId... |
17,314 | #include <iostream>
#include <vector>
#include <math.h>
#include <assert.h>
#include <memory>
#include <random>
#include "gMat.cuh"
#include "gpuerrchk.cuh"
#include "real.h"
__global__ void matMulKernel(real* A, real* B, real* P, int m, int n, int s, int tile_size){
//each thread in the block will be responsible for... |
17,315 | #include "includes.h"
__global__ void sobelEdgeDetectionSharedMem(int *input, int *output, int width, int height, int thresh) {
int blockSize = 32;
static __shared__ int shMem[34][34];
int i = blockIdx.x * blockDim.x + threadIdx.x;
int j = blockIdx.y * blockDim.y + threadIdx.y;
int index = j * width + i;
int xind = ... |
17,316 | #include "includes.h"
cudaError_t addWithCuda(int *c, const int *a, const int *b, unsigned int size);
__global__ void global_scan(float* d_out, float* d_in)
{
int index = threadIdx.x;
float out = 0.00f;
d_out[index] = d_in[index];
__syncthreads();
for (int i = 1; i < sizeof(d_in); i*=2)
{
if (index - i >= 0)
{... |
17,317 | #define CHECK(call) \
{ \
const cudaError_t error = call; \
if( error != cudaSuccess ) \
... |
17,318 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <unistd.h>
double get_time()
{
struct timeval tv;
gettimeofday(&tv, NULL);
return (double)tv.tv_sec + (double)1e-6 * tv.tv_usec;
}
__global__ void vec_add(int *x, int *y, int *z, int n) {
int i = blockDim.x * blockIdx.x + threadIdx.... |
17,319 | #include <cuda_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#define ll long long
#define MAX_THREAD_PER_BLOCK 1024
#define MAX_NB_CITIES 50
#define DEBUG 1
__device__ int calc_perm_cost(ll idx, int n, ll nb_perm, int * dist, ll * fact) {
// Test for valid ... |
17,320 | #include <cuda.h>
#include <stdio.h>
#include <iostream>
#include <sys/time.h>
using namespace std;
const int BLOCK_WIDTH = 16;
const int BLOCK_HEIGHT = 16;
const int DEFAULT_ELE = 16;
typedef struct __align__(8) linkNode
{
int edge;
linkNode* next;
} linkNode;
//HACK: This will be incredibly slow on CUDA!
__dev... |
17,321 | #include "includes.h"
/***********************************************************
By Huahua Wang, the University of Minnesota, twin cities
***********************************************************/
__global__ void vecInit(float* X, unsigned int size, float value)
{
const unsigned int idx = blockIdx.x * b... |
17,322 | #include<stdio.h>
#include<math.h>
#define SIZE 1024
__global__ void sum(int * A, int * C)
{
int i=blockIdx.x*blockDim.x+threadIdx.x;
C[i] =A[2*i+1]+A[2*i];
}
/*__global__ void avg(int * A, int * C)
{
int i=blockIdx.x*blockDim.x+threadIdx.x;
A[2*i] < A[2*i+1]?C[i]=A[2*i]:C[i]=A[2*i+1];... |
17,323 | //__global__ void gpuRecursiveReduce(int *g_idata, int *g_odata,
// unsigned int isize)
//{
// int tid = threadIdx.x;
//
// int *idata = g_idata + blockIdx.x*blockDim.x;
// int *odata = &g_odata[blockIdx.x];
//
// // stop condition
// if (isize == 2 && tid == 0)
// {
// g_odata[blockIdx.x] = idata[0] + idata[1];
//... |
17,324 | #include "includes.h"
__global__ void LoadVec(float *vector , float2 *FFT) {
int idx = threadIdx.x + blockIdx.x*blockDim.x; // this should span the full range of the vector
FFT[idx].x = vector[idx]; // The real part is replaced by the vector value
FFT[idx].y = 0.0f; // The imaginary part is zero. The following k... |
17,325 | #include<stdio.h>
__global__ void hellocuda(int* tidx ){
/* *tidx = 100; */
int x = threadIdx.x;
tidx[x]=threadIdx.x;
}
int main(){
int i;
int * d_tidx;
int * h_tidx;
cudaError_t err = cudaMalloc((void**) &d_tidx, 20*sizeof(int));
if (err != cudaSuccess){
printf("%s on ... |
17,326 | #include "includes.h"
__global__ void scan_workefficient(float *g_odata, float *g_idata, int n)
{
// Dynamically allocated shared memory for scan kernels
extern __shared__ float temp[];
int thid = threadIdx.x;
int offset = 1;
// Cache the computational window in shared memory
temp[2*thid] = g_idata[2*thid];
temp... |
17,327 | #include <iostream>
#include <cuda.h>
#include <math.h>
#include <stdio.h>
typedef unsigned int uint;
// O kernel a seguir obtém o índice da thread operante e verifica se ela está apta para manipular o array.
// Assim, por meio dele, executamos em paralelo (CUDA Cores * SMs) operações em paralelo, dado o particioname... |
17,328 | #include <bits/stdc++.h>
#include <curand_kernel.h>
using namespace std;
constexpr int POPULATION_SIZE = 128;
constexpr int GENERATIONS = 100;
constexpr double MUTATION_RATE = 0.1;
//constexpr int MAX_SIZE = 1000;
#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t... |
17,329 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <cuda_runtime.h>
#include <limits.h>
#define nums 200
void kthSmallest(int arr[], int k){
for (int i = 0; i < nums; ++i){
int upper_sum = 0,down_sum = 0,pivot = arr[i];
for (int j = 0; j < nums; ++j){
upper_sum += (pivot>a... |
17,330 | // Dan Rolfe
#define BLOCKSIZE 32
// general structure for version 1 requested by prof
// section 5.3 of the cuda pogramming guide
/**
* first load from device mem to shared mem
* sync threads after read
* do the processing from shared mem
* sync threads after processing
* write the results back to device mem
**/
... |
17,331 | /**
* CUDA implementation of a fully-connected feed forward neural network
*
* Authors: Jevgenija Aksjonova (jevaks@kth.se)
* Beatrice Ionascu (bionascu@kth.se)
*
* Last changed: 04/30/2017
*/
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define TOL ... |
17,332 | #include "includes.h"
__global__ void computeExCovX(float *trans_x, float *trans_y, float *trans_z, int *valid_points, int *starting_voxel_id, int *voxel_id, int valid_points_num, double *centr_x, double *centr_y, double *centr_z, double gauss_d1, double gauss_d2, double *e_x_cov_x, double *icov00, double *icov01, doub... |
17,333 | // kernel definition
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
__global__ void vecAdd(float* A, float* B, float* C)
{
int idx = threadIdx.x;
C[idx] = A[idx] + B[idx];
}
//int main(void)
//{
//
// //vecAdd << <1, N >> > (A, B, C);
//} |
17,334 | #include "../include/commons.cuh"
__host__ void usage()
{
cout << "./main [cpu/gpu] [number_of_spheres]\n";
exit(EXIT_FAILURE);
}
__host__ void controls()
{
cout << "[] Controls:\n";
cout << "|- View Position: A, D, Mouse-Scroll\n";
cout << "|- Light Position: W, S, Q, E\n";
... |
17,335 | #include <iostream>
#include <iomanip>
#include <new>
#include <stdio.h>
#include <cuda_runtime.h>
#include <sys/time.h>
#include <limits.h>
#define imin(a,b) (a<b?a:b)
const int N = 1<<15;
const int threadsPerBlock = 256;
const int blocksPerGrid = imin(32, (N + threadsPerBlock - 1) / threadsPerBlock);
// 计时器函数
doub... |
17,336 | extern "C" {
/*
* Kernel for mirroring the image parallely usng CUDA
*/
__global__
void mirror(const uchar4* const inputChannel, uchar4* outputChannel, int numRows, int numCols, bool vertical)
{
int col = blockIdx.x * blockDim.x + threadIdx.x;
int row = blockIdx.y * blockDim.y + th... |
17,337 | #include "includes.h"
__global__ void sub_mul_kernel(double *g_out, double *a, double *b1, double *b2, double *ct, int n) {
const int j2 = blockIdx.x * blockDim.x + threadIdx.x;
double wkr, wki, xr, xi, yr, yi, ajr, aji, akr, aki, bjr, bji, bkr, bki;
double new_ajr, new_aji, new_akr, new_aki;
const int m = n >> 1;
cons... |
17,338 | #include <cuda.h>
#include <cuda_runtime_api.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <stdlib.h>
//#define N 4
#define BLOCK_SIZE 4
#define GRID_SIZE 2
// threadfence();
using namespace std;
__device__ volatile int Arrayin[100];
__device__ volatile int Arrayout[10... |
17,339 | #include "includes.h"
__device__ inline float3 addCuda(float3 a, float3 b) {
return{ a.x + b.x, a.y + b.y, a.z + b.z };
}
__device__ inline float3 multiplyCuda(float a, float3 b) {
return{ a * b.x, a * b.y, a * b.z };
}
__device__ inline float euclideanLenCuda(float3 a, float3 b, float d) {
float mod = (b.x - a.x) * (b... |
17,340 | // return the cuda compute capabiltiy for device 0 on the current hardware
// this is not just for convenience, but also directly used by the cmake build
#include <stdio.h>
#include <stdlib.h>
int main()
{
cudaDeviceProp prop;
if (cudaGetDeviceProperties(&prop, 0)) {
fprintf(stderr, "Failed to get cuda ... |
17,341 | #include <cuda.h>
#include <stdio.h>
#include <dlfcn.h>
#include <stdlib.h>
CUresult cuDeviceTotalMem(size_t* bytes, CUdevice dev) {
void *handle;
handle = dlopen("/usr/lib/x86_64-linux-gnu/libcuda.so.1", RTLD_LAZY);
printf("%s\n", "I just want to tell you that cuDeviceTotalMem is STILL hijacked!");
... |
17,342 | #include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>
#define initTimer struct timeval tv1, tv2; struct timezone tz
#define startTimer gettimeofday(&tv1, &tz)
#define stopTimer gettimeofday(&tv2, &tz)
#define tpsCalcul (tv2.tv_sec-tv1.tv_sec)*1000000L + (tv2.tv_usec-tv1.tv_usec)
#define MAX_DIM_GRID 65535
#de... |
17,343 | #include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/times.h>
#include <time.h>
#include <cuda_runtime.h>
#define PI 3.14159265358979323846
#define FactorArcosegRad 0.00000484814
clock_t timestart, timeend;
/**
@brief Función que transforma un valor en arco segundo a radianes
@p... |
17,344 |
// Babak Poursartip
// 09/15/2020
// udemy CUDA
// memory management in cude
// start thread in a multiple of 32
#include <cstdio>
#include <cstdlib>
#include <time.h>
// =================================
__global__ void mem_trs_test(int *input) {
// 1d grid, 1d block
int gid = blockDim.x * blockIdx.x + thread... |
17,345 | #include "includes.h"
__global__ void cmin(float *d_in, float *min, int len)
{
extern __shared__ float smin[];
unsigned int tid = threadIdx.x;
unsigned int i = blockIdx.x * blockDim.x + threadIdx.x;
smin[tid] = d_in[i]<d_in[i+len] ? d_in[i] : d_in[i+len];
__syncthreads();
if(blockDim.x > 512 && tid<512) {if(smin[ti... |
17,346 | /**
@brief Compare vector sum calculation functions in CPU vs GPU.
@file 00.cu
@author isquicha
@version 0.1.0
*/
#include <stdio.h>
#include <time.h>
// Cuda headers are on CUDA Toolkit instalation path/VERSION/include
#include "cuda.h"
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
... |
17,347 | #include "includes.h"
__global__ void zupdate_stencil(float *zx, float *zy, float *zoutx, float *zouty, float *g, float tau, float invlambda, int nx, int ny)
{
int px = blockIdx.x * blockDim.x + threadIdx.x;
int py = blockIdx.y * blockDim.y + threadIdx.y;
int idx = px + py*nx;
int tidx, tpx, tpy;
float a, b, t;
float ... |
17,348 | #include <stdlib.h>
//#include <float.h>
#include <stdio.h>
//#include <string.h>
//#include <math.h>
#include <time.h>
typedef struct {
int width;
int height;
float *elements;
} Matrix;
void startSeed()
{
srand(time(NULL));
int seed = rand();
srand(seed);
}
void draw_random(Matrix mat) {
for ... |
17,349 | /*
Single Author info:
arajend4 Ayushi Rajendra Kumar
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
//#include <cuda_runtime.h>
/* first grid point */
#define XI 0.0
/* last grid point */
#define XF M_PI
typedef double FP_PREC;
/* function declarations */
double fn... |
17,350 | typedef double MYFLOAT;
#define PI 3.14159265359
__device__ MYFLOAT gpu_ix2x(int ix, int nx, MYFLOAT lx){
return ((ix) - nx / 2.0)*lx/nx;
}
__device__ MYFLOAT gpu_iy2y(int iy, int ny, MYFLOAT ly){
return ((iy) - ny / 2.0)*ly/ny;
}
__global__ void eff_update_up_down(int nx, int ny, MYFLOAT *temp){
int ix;
... |
17,351 | #include "includes.h"
__global__ void middle_to_right(float* data, const int nx, const int ny)
{
float tmp;
for ( int r = 0; r < ny; ++r ) {
float last_val = data[r*nx+nx/2];
for ( int c = nx-1; c >= nx/2; --c ){
int idx = r*nx+c;
tmp = data[idx];
data[idx] = last_val;
last_val = tmp;
}
}
} |
17,352 | #include <iostream>
using namespace std;
int main()
{
return 0;
}
|
17,353 | #include<iostream>
int main()
{
cudaDeviceProp prop;
int count;
cudaGetDeviceCount(&count);
std::cout<<"GPU num:"<<count<<std::endl;
cudaGetDeviceProperties(&prop,0);
std::cout<<"Max threads/block:"<<prop.maxThreadsPerBlock<<std::endl;
std::cout<<"Max threads/SM:"<<prop.maxThreadsPerMultiP... |
17,354 | /**
* @file : params_kernelf.cu
* @brief : Modified implementation of njuffa's;
* CUDA kernel functions as parameters with CUDA C++14, CUDA Unified Memory Management
* @details : Modified implementation of njuffa's,
* std::function vs. function pointer in C++11, C++14, and now in CUDA
* std::fun... |
17,355 | #include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include "unistd.h"
#include "time.h"
#include "string.h"
#include <cuda_runtime.h>
// ---------------------- Optimised Dedispersion Loop ------------------------------
__global__ void testAtomicCas(int *buffer, int nsamp, int factor)
{
if (blockIdx.x * bl... |
17,356 | #include "includes.h"
__global__ void ComputeOffsetOfMatrixAB(const int32_t* row_sum, const int32_t* col_sum, int32_t* output, int32_t K_A_B, int32_t N) {
for (int32_t i = threadIdx.x; i < N; i += blockDim.x) {
*(output + blockIdx.x * N + i) = K_A_B - row_sum[blockIdx.x] - col_sum[i];
}
} |
17,357 | #include "includes.h"
__global__ void normalise(float* result, unsigned int resultLength, float* amps, unsigned int* hits)
{
int absoluteThreadIdx = blockDim.x * blockIdx.x + threadIdx.x;
if(absoluteThreadIdx > resultLength)
return;
result[absoluteThreadIdx] = amps[absoluteThreadIdx] / hits[absoluteThreadIdx / 4];
} |
17,358 | #include <cuda.h>
#include <stdlib.h>
#include <iomanip>
#include <iostream>
using std::setw;
const int N = 5;
const int threadsPerBlock = N;
int blocksPerGrid = 1;
// device code
__global__ void prefixSum(float* x, float* c) {
__shared__ float
cache[2 * threadsPerBlock]; // declaring a array in shared memor... |
17,359 |
#include <iostream>
#include <stdlib.h>
#include <ctime>
#include <cuda.h>
struct float3_t
{
float x, y, z;
};
__global__
void FindClosetGPU (float3_t* points, int* indices, int count)
{
if (count <= 1)
return;
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < count) {
float3_t thisPoint = points... |
17,360 | #include <iostream>
#include <cstdlib>
#include <math.h>
#include <chrono>
#include <iomanip>
#include <fstream>
using namespace std;
using namespace std::chrono;
typedef unsigned long long ULL;
ofstream primeresult;
ofstream timeresult;
__global__ void cuda_erastothenes_sieve (ULL *marked, ULL *limit, ULL *n, int *to... |
17,361 | #include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <thrust/generate.h>
#include <thrust/random.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/functional.h>
#include <thrust/transform_reduce.h>
#include <cmath>
struct montecarlo : public thrust::unary_function<unsigned int, float>
{
... |
17,362 | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#define LIST_SIZE 100000
__device__ unsigned long long instCountList[LIST_SIZE];
__device__ int init_flag = 0;
extern "C" __device__ void profileCount(long index){
if(init_flag == 0){
int i = 0;
for(i=0;i<LIST_SIZE;i++){
inst... |
17,363 | #include "includes.h"
__global__ void getCrossingTimes(double *results, int *crossTimes, int N, int numSims, int lowerThreshold, int upperThreshold) {
int tid = threadIdx.x + blockIdx.x * blockDim.x;
while (tid < N * numSims) {
if (crossTimes[tid/N] == 0) {
if (results[tid] <= lowerThreshold) {
crossTimes[tid/N] = tid ... |
17,364 | #include "includes.h"
__global__ void InitArrays(float *ip, float *op, float *fp, int *kp, int ncols)
{
int i;
float *fppos, *oppos, *ippos;
int *kppos;
int blockOffset;
int rowStartPos;
int colsPerThread;
// Each block gets a row, each thread will fill part of a row
// Calculate the offset of the row
blockOffset = b... |
17,365 | #include "includes.h"
__global__ void device_add(int *a, int *b, int *c)
{
int blockId = blockIdx.x;
if (blockId < arrSize)
c[blockId] = a[blockId] + b[blockId];
} |
17,366 | #include "includes.h"
__global__ void prime( int *a, int *b, int *c ) {
int tid = (blockIdx.x*blockDim.x) + threadIdx.x; // this thread handles the data at its thread id
if (tid < vector_size){
c[tid] = a[tid] + b[tid]; // add vectors together
}
} |
17,367 | //#include "device_launch_parameters.h"
//#include "cuda_runtime.h"
//#include "Box.h"
//
//#define cudaCheckError() { \
// cudaError_t e=cudaGetLastError(); \
// if(e!=cudaSuccess) { \
// printf("Cuda failure, %s",cudaGetErrorString(e)); \
// exit(0); \
// }\
//}
//
//__global__ void check(int noOfCubes, box* boxes... |
17,368 |
/* Very simple addition kernel */
__global__ void add_kernel(double *in, int N)
{
int tid = blockIdx.x * blockDim.x + threadIdx.x;
if (tid < N)
in[tid]++;
}
/*
Kernel call wrapper, we can not use the <<<>>> syntax in MPI code.
Arguments:
data (double *) -- pointer to the device memory data... |
17,369 | #include "includes.h"
__global__ void cudaKernel(int *n, int limit)
{
} |
17,370 | #ifdef __cplusplus
extern "C" {
#endif
struct point{
float x;
float y;
};
__global__ void pi(const struct point* A, int* res, const int nbPoint, const float ray){
const int idx = 32*blockDim.x * blockIdx.x + threadIdx.x;
if (idx < nbPoint-32*blockDim.x)
#pragma unroll 16
for (... |
17,371 | #include <cstdio>
__device__ __forceinline__ float addf(float* input1, float* input2) {
return input1[blockIdx.x] + input2[blockIdx.x];
}
extern "C" __global__ void add(float c, float* __restrict__ input1, float* __restrict__ input2, float* __restrict__ output) {
output[blockIdx.x] = addf(input1, input2) + c;
}
|
17,372 | #include <stdio.h>
__global__ void compute_data(int *a, int const x, int const n)
{
int idx = threadIdx.x + blockDim.x*blockIdx.x;
if (idx<n) {
int aa = a[idx];
int product = 0.0;
for(int i = 0; i < x; i++) product += aa;
a[idx] = product;
}
}
extern "C"
void ext_compute_data(int grid_size, int ... |
17,373 | #define THETA_N 4
#define SQRT_2 1.4142135623730951f
#define PI 3.141592653589793f
extern "C" {
/**
* Clears out the Gabor Energies Tensor, setting all of its values to zero.
* The Gabor Energies Tensor is the data structure whose [y, x, theta] value contains the average magnitude response to
* the different comple... |
17,374 | #include "includes.h"
__global__ void ComputeSquareDistance(float* dOut, float* dIn, int n, int d)
{
// Load values that will be reused
__shared__ float blockA[KNN_BLOCK_SIZE][KNN_BLOCK_SIZE];
__shared__ float blockB[KNN_BLOCK_SIZE][KNN_BLOCK_SIZE];
// A is responsible for points indexed between aStart and aEnd
auto a... |
17,375 | // ########################################################################
// Practical Course: GPU Programming in Computer Vision
// Technical University of Munich, Computer Vision Group
// ########################################################################
#include <cuda_runtime.h>
#include <iostream>
using na... |
17,376 | #include <stdint.h>
#include <stdio.h>
#define N 32
#define THREADS_PER_BLOCK 32
__global__ void dotproduct(float* x, float* y, float* result) {
// Compute the index this thread should use to access elements
size_t index = threadIdx.x + blockIdx.x * THREADS_PER_BLOCK;
// Create space for a shared array t... |
17,377 | #include "includes.h"
__global__ void linearLayerForward( float* W, float* A, float* Z, float* b, int W_x_dim, int W_y_dim, int A_x_dim, int A_y_dim) {
int row = blockIdx.y * blockDim.y + threadIdx.y;
int col = blockIdx.x * blockDim.x + threadIdx.x;
int Z_x_dim = A_x_dim;
int Z_y_dim = W_y_dim;
float Z_value = 0;
i... |
17,378 | /*
Finds: size of the read only cache
For Maxwell microarchitecture
Source code based on paper https://arxiv.org/pdf/1509.02308.pdf
Compile with nvcc -arch=sm_52 maxwell_readonly.cu -o readonly
(__ldg() intrinsic is only available on compute capability 3.5+ architecture)
*/
#include <stdio.h>
#include <stdin... |
17,379 | #include "includes.h"
//#define array_size 100000000
#define array_size 101
//987459712
cudaError_t addWithCuda(int *total);
__shared__ int temp[array_size];
__global__ void addKernel(int *tid_c, int *tid_total)
{
int tid = blockIdx.x * blockDim.x + threadIdx.x;
tid_c[tid] = tid;
if (tid <= array_size)
{
temp... |
17,380 | /////////////////////////////////////////////////////////////////////////
// //
// CUDA code which calculates PI using Monte-Carlo method //
// It will get random points in the square between (0,0) and (1,1) //
// Find whether it is i... |
17,381 | #include <math.h>
#include <stdio.h>
#include <stdlib.h>
#define THREADS_PER_BLOCK 16
__global__ void set(int *A, int N)
{
int idx = threadIdx.x + blockIdx.x * blockDim.x; //index saved
A[idx] = idx; //A[1] = 1, A[2] = 2, ..., A[N] = N
}
int main(void)
{
const i... |
17,382 | #include "kernels.cuh"
struct node {
char nodeType;
int index;
double vr;
double dr;
int child[2];
bool flag;
};
__global__ void build_circuit(struct node** array, int n, int H, int *num)
{
unsigned int index = threadIdx.x + blockIdx.x*blockDim.x;
unsigned int stride = gridDim.x*blockDim.x;... |
17,383 | #include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <iostream>
#include <chrono>
#include <thrust/count.h>
#include <thrust/functional.h>
#include <thrust/iterator/constant_iterator.h>
#include <thrust/transform_reduce.h>
#include <math.h>
struct var{
double media;
int N;
var(double... |
17,384 | // File name: add.cu
#include <stdio.h>
__global__ void add(int a, int b, int *c){
*c = a+b;
}
int main(void){
int c;
int *device_c;
cudaMalloc((void**)&device_c, sizeof(int));
add<<<1, 1>>>(2, 7, device_c);
cudaMemcpy(&c, device_c, sizeof(int), cudaMemcpyDeviceToHost);
printf("2+7 = %d\n", c);
//cudeFree(devic... |
17,385 | #include "includes.h"
#define BLOCKSIZE 4
#define CELLS_PER_THREAD 4 // Stride length
__global__ void ShortestPath2(float *Arr1,float *Arr2,int N){ //Arr1 input array,Holds weights
//Arr2 output array
unsigned int k;
int row=blockIdx.x;
int col=threadIdx.x;
if(row >= N || col >= N) return;
int index=row*N+col; ... |
17,386 | #include <thrust/device_vector.h>
#include <thrust/iterator/zip_iterator.h>
#include <thrust/tuple.h>
#include <thrust/reduce.h>
int main()
{
// initialize vectors
thrust::device_vector<int> A(3);
thrust::device_vector<char> B(3);
A[0] = 10; A[1] = 20; A[2] = 30;
B[0] = 'x'; B[1] = 'y'; B[2] = 'z';
// crea... |
17,387 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>
#include <curand.h>
using namespace std;
__device__ __host__ __inline__ float N(float x)
{
return 0.5 + 0.5*erf(x*M_SQRT1_2);
}
__device__ __host__ void price(float k, float s, flo... |
17,388 | #pragma once
#include <iostream>
#include "tuple_utility.cu"
namespace nearptd {
template<size_t Dim>
class Cell {
public:
typedef short int Cell_Index_T;
typedef typename ntuple<Cell_Index_T, Dim>::tuple Cell_Tuple;
ntuple<Cell_Index_T, Dim> Cell_Ntuple;
Cell_Index_T c[Dim];
__host_... |
17,389 | #include <cuda.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
//max value for element of array
#define MAX 100000
//defined threads per block for cims machines
#define THREADS_PER_BLOCK 1024
//number of warp
#define WARP 32
void generate(int *a, const int size);
__global__ void get_max(int *array, int *m... |
17,390 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "cuda_runtime.h"
//#include "cuda_profiler_api.h"
#define THREADS 32 //In each block THREADS*THREADS threads
struct matrix {
int ncols;
int nrows;
double* mat;
};
void readMatrix(struct matrix* m, FILE* file);
void printMatrix(s... |
17,391 | #include <stdio.h>
__global__ void add(int a, int b, int *c)
{
*c = a + b;
}
int main()
{
//----------- cuda devices info ---------------
int cuda_count;
cudaDeviceProp prop;
cudaGetDeviceCount(&cuda_count);
printf("Exist %d device with cuda support\n",cuda_count);
for(int device=0;... |
17,392 | #include "includes.h"
__global__ void Predictor (const double TIME, double4 *p_pred, float4 *v_pred, float4 *a_pred, double4 *p_corr, double4 *v_corr, double *loc_time, double4 *acc, double4 *acc1, double4 *acc2, double4 *acc3, int istart, int* nvec, int ppgpus, unsigned int N){
int i = blockIdx.x*blockDim.x + th... |
17,393 | //
// Created by moura on 30/12/2022.
//
#include <iostream>
using namespace std;
#define checkCudaErrors(val) check_cuda( (val), #val, __FILE__, __LINE__ )
void check_cuda(cudaError_t result, char const *const func, const char *const file, int const line) {
if (result != cudaSuccess) {
std::cerr << "CUD... |
17,394 | #include <stdio.h>
#include <cuda.h>
#include <math.h>
#define BLOCK_DIM 16
__global__ void multiply(int *a, int *b, int *c, int wa) {
int t_id = threadIdx.x;
int i;
c[t_id] = 0;
for (i=0; i<wa; i++)
c[t_id] += a[t_id * wa + i] * b[i];
}
int main (int argc, char *argv[]) {
// Initialize host variables
... |
17,395 | #include "Dummy.cuh"
#include <cmath>
__host__ __device__ Dummy::Dummy() : counter(0) { ; }
__device__ void Dummy::incrementCounterDevice()
{
++counter;
magicNumber = counter * 5 * pow((double)3, __double2int_rd(magicNumber) % 100) + counter * magicNumber + counter * 2 * pow((double)2, __double2int_rd(magicNumber) % ... |
17,396 |
__global__ void op1(float *mat, int mat_size)
{
int i=blockIdx.y*blockDim.y+threadIdx.y;
int j=blockIdx.x*blockDim.x+threadIdx.x;
float temp;
if((i<mat_size) && (j<mat_size) && (j<mat_size-1)){
if(j%2==0){
temp = mat[i*mat_size+j];
mat[i*mat_size+j] = mat[i*mat_size+j+1];
mat[i*mat_size+j+1] = t... |
17,397 |
/* 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,int 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 ... |
17,398 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <sys/time.h>
#include <stdint.h>
#define MAX 100
#define MIN 1
__global__ void DUKernel(int *D_Level,int *D_Del,int n, int num);
void IscomponentSame(int *L,int *D, int n,int num);
uint64_t getTime(){
struct timeval t;
gettimeofday(&... |
17,399 | //
// main.cpp
// Parallel Degree of Separation
//
// Created by Cary on 11/16/14.
// Copyright (c) 2014 Cary. All rights reserved.
//
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <set>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <sys/time.h>
#inclu... |
17,400 | /* Write GPU kernels to compete the functionality of estimating the integral via the trapezoidal rule. */
#define BLOCK 64
#define GRID 16384
__global__ void trap_kernel(float a, float b, int n, float h, float *Result_fromGPU)
{
int tx = threadIdx.x;
int bd = blockDim.x;
int bi = blockIdx.x;
int i;
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.