serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
1,301 | #include <iostream>
#include "sys/time.h"
using namespace std;
double timeInSeconds (timeval& starttime, timeval& stopstime) {
return 1e-6*(1e6*(stopstime.tv_sec - starttime.tv_sec) + (stopstime.tv_usec - starttime.tv_usec));
}
//__device__ double* dev_vector1 = 0;
//__device__ double* dev_vector2 = 0;
//__device_... |
1,302 | #include <iostream>
#define N 1024
using namespace std;
__global__ void fun(int* arr) {
int id = threadIdx.x;
arr[id] = id*id*id;
}
int main() {
int ha[N], *a;
cudaMalloc(&a, N*sizeof(N));
fun<<<1,N>>>(a);
cudaMemcpy(ha, a, N*sizeof(int), cudaMemcpyDeviceToHost);
// cudaDeviceSynchronize(... |
1,303 | #include<iostream>
using namespace std;
//test file product on GPU
template<unsigned int blocksize, typename T>
__global__ void prob(T* a, T* b,unsigned int n) {
unsigned int tid = threadIdx.x;
unsigned int idx = threadIdx.x + blockDim.x*blockIdx.x*8;
T *data = a + blockDim.x*blockIdx.x*8;
//ๅขๅ ๅญๅจๆ็
if(idx +... |
1,304 | #include <stdio.h>
#include <stdlib.h>
const int ARR_SIZE = 64;
const int ARR_BYTES = ARR_SIZE*sizeof(float);
__global__
void cuadrado(float* d_out, float* d_in) {
int idx = threadIdx.x;
float f = d_in[idx];
d_out[idx] = f*f;
}
int main(int argc, char **argv){
// Apuntadores a arreglos en host y en device
flo... |
1,305 | // printf("\n\n\nGPU versions:\n");
// printf("\n1.adj_diff_naive:\n");
// printf("Time cost (GPU):%.9lf s\n", adj_diff_naive(data_input, data_output_from_gpu, n));
// if(compare(data_output_from_gpu, data_output_cpu, n)==1){ printf("Passed!\n"); }
// else{ printf("Failed!\n"); }
// memset(data_output_fr... |
1,306 | //parameters: shiftX,Y, scaleX,Y, shearX,Y = 6dimensions
// multiply angle = 7
__global__ void AffineForward(const float* bottom_data,
const int* bottomSize, const float* affine, const int len, float* top_data) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
if (index >= len) return;
... |
1,307 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define DEBUG
#define float double
#define INDEX(fst, snd, n) ((fst) * (n) + (snd))
#define SIZE (5000)
#define TILL (100)
#define N_TILL (SIZE / TILL)
__global__ void multiple(float* matrix, float* vector, float* out) {
/*
* a thread get 100 element ... |
1,308 | // CUDA programming
// Exercise n. 10
#include <errno.h>
#include <cuda.h>
#include <stdio.h>
#define N_ELEMS 16
#define THREADS 4
// Prototype
__global__ void dot_prod(int *a, int *b, int *c);
__host__ void ints(int *m, int N);
__host__ void print_array(int *a, int N);
int main(void)
{
int *a, *b, *c; ... |
1,309 | #include <iostream>
#include <fstream>
#include <cmath>
#include <sys/time.h>
#define BSZ (16)
void checkErrors(char *label) {
// we need to synchronise first to catch errors due to
// asynchroneous operations that would otherwise
// potentially go unnoticed
cudaError_t err;
err = cudaThreadSynchronize();
... |
1,310 |
#include <iostream>
#include <cuda.h>
#include <time.h>
#include <math.h>
using namespace std;
// ํ
์คํธ ์ฉ์ด๋ฏ๋ก ์ผ๋จ ์๋ฃ ํฌ๊ธฐ๋ 1000์ผ๋ก
// 1D์ด๋๊น ๊ทธ๋ฅ ๋ธ๋ญ์ฌ์ด์ฆ๋ 512๋ก
// EP๋ ์ฌ๋ผ์ด์ค์ ์ฌ์ด์ฆ
//10๋ง๊ฐ๋ถํฐ ์๋ฌ๋ฌ์. ์๋ง ๋๋ค ์ซ์ ๋ง๋ค์ด๋ด๋ ๋ฐ, ์๋๋ฉด GPU๋ฉ๋ชจ๋ฆฌ ์์์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ ๊ฒ ๊ฐ์.
// ๋ง์ผ ํ๋ฉด ๋ฐ์ดํฐ๋ฅผ ์ ๋ ฌํ๋ค๊ณ ํ๋ฉด, 2560x1600 = 4,096,000 ํฝ์
์ด๋๊น GPU๋ฉ๋ชจ๋ฆฌ ์์์์ ๋ฌธ์ ๊ฐ
// ์๋๋ผ ๋๋ค ... |
1,311 | #include <stdlib.h>
#include <string.h>
#include <time.h>
#include <stdio.h>
#include <cuda_runtime.h>
__global__ void sumArraysOnGpu(float *A, float *B, float *C){
int idx = threadIdx.x;
C[idx] = A[idx] + B[idx];
}
__global__ void mathOperationsOnGPU(float *A, float *B, float *C, int operations) {
int idx = th... |
1,312 | //#include <iostream>
//#include <fstream>
//#include <iomanip>
//#include <string>
//
//#include <cmath>
//#include <cstdio>
//
//#include <cuda_runtime.h>
//#include <device_launch_parameters.h>
//
////using namespace std;
//using std::ifstream;
//using std::string;
//using std::cout;
//using std::endl;
//using std::... |
1,313 | #include "includes.h"
__global__ void PowerInterleaved(float4 *src, float4 *dest) {
const size_t i = blockDim.x * blockIdx.x + threadIdx.x;
// Cross pols
dest[i].x += src[i].x * src[i].x + src[i].y * src[i].y;
dest[i].y += src[i].z * src[i].z + src[i].w * src[i].w;
// Parallel pols
dest[i].z += src[i].x * src[i].z ... |
1,314 | #include "includes.h"
__global__ void mat_mult_kernel(int *a, int *b, int *c, int mat_rows, int mat_cols) {
int tid = threadIdx.x + blockIdx.x * blockDim.x;
while (tid < mat_rows) {
int res = 0;
for (int i = 0; i < mat_cols; i++) {
res += a[tid * mat_cols + i] * b[i];
}
c[tid] = res;
tid += blockDim.x * gridDim.x;
}
} |
1,315 | // This example is taken from https://devblogs.nvidia.com/even-easier-introduction-cuda/
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <sys/time.h>
// get_walltime function for time measurement
double get_walltime_(double* wcTime) {
struct timeval tp;
gettimeofday(&tp, NULL);
*wcTime = (doubl... |
1,316 | #include <stdio.h>
__global__ void parallel_vector_add(int* d_a, int* d_b, int* d_c, int* d_n)
{
int i = (blockIdx.x*blockDim.x)+threadIdx.x;
//printf("I am thread #%d.", i);
if (i < *d_n)
{
printf("I am thread #%d, and about to compute c[%d].\n", i, i);
d_c[i] = d_a[i]+d_b[i];
}
else
{
printf("I am threa... |
1,317 | #include "includes.h"
__global__ void Sqrt( float * x, size_t idx, size_t N, float W0)
{
for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < N; i += blockDim.x * gridDim.x)
{
x[(idx-1)*N+i] = sqrt(abs(x[(idx-1)*N+i])*W0);
}
return;
} |
1,318 | #include<stdio.h>
#include<cuda.h>
#include<cuda_runtime.h>
#include<time.h>
__global__ void vecAdd(double *a,double *b,double *c,int n)
{
int id=blockIdx.x*blockDim.x+threadIdx.x;
if(id<n)
c[id]=a[id]+b[id];
}
int main()
{
srand(time(NULL));
double *h_a,*h_b,*h_c;
double *d_a,*d_b,*d_c;
int n=50;
int i=0;
clock_t t;
... |
1,319 | extern "C"
__global__
void sigmoid(float *activation, unsigned int length)
{
for (int i = blockIdx.x * blockDim.x + threadIdx.x;
i < length;
i += blockDim.x * gridDim.x)
{
activation[i]=1.0f/(1.0f+__expf(-activation[i]));
//activation[i]=1.0f/(1.... |
1,320 | #include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/time.h>
__global__ void kernel(float* d,float* d1,int size){
int length_per_block;
int length_per_thread;
int start,end;
length_per_block = size/gridDim.x;
length_per_thread = length_... |
1,321 | //#include <hayai/hayai.hpp>
//
//#include "concurrent/containers/hash_tables/chaining.cuh"
//
//#include "hash_map-fixture.cu"
//
//using Chaining = gpu::concurrent::chaining<key_type, mapped_type, gpu::hash<key_type>>;
//using ChainingInsertionFixture = HashMapInsertionFixture<Chaining>;
//using ChainingGetFixture = ... |
1,322 | /// Assignment 06: Local Register Memory
///
/// Author: Justin Renga
/// Two Kernels -- Same Operation
///
/// Operation: Take an integer (randomly generated) from two input arrays,
/// take their modulo (input1 % input2) and store the result.
///
/// Kernel 1: Use the global memory to perform the operatio... |
1,323 | #include "noise_module_base.cuh"
// A table of 256 random normalized vectors. Each row is an (x, y, z, 0)
// coordinate. The 0 is used as padding so we can use bit shifts to index
// any row in the table. These vectors have an even statistical
// distribution, which improves the quality of the coherent noise
// gen... |
1,324 | #include <thrust/copy.h>
#include <thrust/device_vector.h>
#include <thrust/sort.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
/* Every thread gets exactly one value in the unsorted array. */
#define THREADS 128 // 2^7
#define BLOCKS 1024 // 2^10
#define NUM_VALS THREADS*BLOCKS
void print_elapsed(clock_... |
1,325 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <stdbool.h>
static int grid_array[5]={5,9,16,23,30};
static int block_array[5]={2,3,5,10,12};
static FILE *pointerToFile;
__device__
static void calculate(int *readingArray, int* writingArray, double *weights, int n ,int current,int x... |
1,326 | #include <stdio.h>
#define N 64
__global__ void matrixMulGPU( int * a, int * b, int * c )
{
int val = 0;
int row = blockIdx.x * blockDim.x + threadIdx.x;
int col = blockIdx.y * blockDim.y + threadIdx.y;
if (row < N && col < N)
{
for ( int k = 0; k < N; ++k )
val += a[row * N + k] * b[k * N + co... |
1,327 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <iostream>
#include <numeric>
using namespace std;
__global__ void sumSingleBlock(int* d) {
int tid = threadIdx.x;
// number of participating threads halves on each iteration
for (int tc = blockDim.x, stepSize = 1; tc > 0; tc >>= 1... |
1,328 | #include <stdio.h>
#include <cuda.h>
#include <string.h>
#include <time.h>
// Parallel Computing Lab 3
// Author: Andrew Huang
// forward declare
void deviceProperties(void);
long getMax(long * a, long);
#define THREADS_PER_BLOCK 1024 // 3.x
void deviceProperties(void){ // displays device properties
int nDevice... |
1,329 | #include <stdio.h>
template<class T>
__device__ inline int CalcMandelbrot(const T xPos, const T yPos, const int crunch)
{
T y = yPos;
T x = xPos;
T yy = y * y;
T xx = x * x;
int i = crunch;
while (--i && (xx + yy < T(4.0))) {
y = x * y * T(2.0) + yPos;
x = xx - yy + xPos;
... |
1,330 | #include "includes.h"
__global__ void _ele_add(float *m, float *target, float val, int len){
int tid = blockIdx.x * blockDim.x + threadIdx.x;
if(tid < len){
target[tid] = val + m[tid];
}
} |
1,331 | #include <cuda_runtime.h>
#include<stdio.h>
__global__ void add(int *a, int *b, int *c, int N)
{
int idx = threadIdx.x + blockDim.x * blockIdx.x;
if (idx < N)
for(int i=0;i<1000;i++){
c[idx] = a[idx] + b[idx]+1+c[idx];
}
}
__host__
int main(){
const int N=10000;
int *a,*b,*c,... |
1,332 | /*
Ye Wang
CPEG655
lab2 problem 2.a
*/
#include <stdio.h>
#include <assert.h>
#include <cuda_runtime.h>
#include <sys/time.h>
__global__ void
matrixMul_2a(int TILE_SIZE, int BLOCK_SIZE, float *C, float *A, float *B, int N);
void mm(float * C, float * A, float * B, int N);
float GetRand(int seed);
void randomInit(... |
1,333 | #include "includes.h"
__global__ void zupdate(float *z, float *z0, float tau, int nx, int ny)
{
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threadIdx.y;
int idx = x + y*nx;
if (x<nx && y<ny)
{
float a = z[2 * idx + 0];
float b = z[2 * idx + 1];
float t = 1 / (1 + tau*sqrtf(a*a + b*b... |
1,334 | // ๅ ไธบๆ่ชๅทฑ็ฌ่ฎฐๆฌ็ๆพๅก่ฎก็ฎ่ฝๅไธบ2.1๏ผๆไปฅ่ฟๆฎตไปฃ็ ๅ
ถๅฎๆฏๆ ๆณๅทฅไฝ็๏ผๅๅ ๅจไบ cudaMallocManaged ่ฟไธชๅฝๆฐๆฏ็จไธไบ็
#include<stdio.h>
#define N 64
#define TPB 32
float scale(int i,int n){
return ((float)i/(n-1));
}
__device__
float distance(float x1,float x2){
return sqrt((x2-x1)*(x2-x1));
}
__global__
void distanceKernel(float *d_out,float *d_in,float ref)... |
1,335 | #include <stdio.h>
__global__ void helloFromGPU(void){
printf("Hello from GPU!\n");
}
int main(void){
printf("Hello! from CPU\n");
helloFromGPU <<< 1,10 >>>();
cudaDeviceReset();
}
|
1,336 | #include <stdio.h>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <unistd.h>
#include <cuda.h>
#include <cuda_runtime_api.h>
//#include "cutil.h"
using namespace std;
///////////////////////////////////////////////////... |
1,337 | #include "includes.h"
#define UPPERTHRESHOLD 90
#define LOWERTHRESHOLD 30
const float G_x[3 * 3] = {
-1, 0, 1,
-2, 0, 2,
-1, 0, 1
};
const float G_y[3 * 3] = {
1, 2, 1,
0, 0, 0,
-1, -2, -1
};
const float gaussian[5 * 5] = {
2.f/159, 4.f/159, 5.f/159, 4.f/159, 2.f/159,
4.f/159, 9.f/159, 12.f/159, 9.f/159, 4.f/159,
5... |
1,338 |
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/generate.h>
#include <thrust/sort.h>
#include <thrust/functional.h>
#include <cstdlib>
#include <stdint.h>
#include <iostream>
#include <sys/time.h>
int main(int argc, char **argv) {
struct timeval tv1,tv2;
struct time... |
1,339 | /*
CSC691 GPU programming
Project 4: Multi-Pi using multiple streams
Jiajie Xiao
Nov 19, 2017
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define CHUNK 100000
__global__ void partialHist(char *input, int len, int *hist)
{
int i = threadIdx.x + blockDim.x*blockIdx.x;
int number = input[i]-'0... |
1,340 | extern "C" {
__global__ void dummy()
{
}
}
|
1,341 | #include <stdio.h>
#include <math.h>
// Algoritmo Criba de Eratรณstenes
void primos(unsigned long max)
{
unsigned long i, j, c=0;
max++;
char *arr = new char[max];
cudaEvent_t inicio, fin;
float tiempo;
cudaEventCreate( &inicio );
cudaEventCreate( &fin );
cudaEventRecord( inicio, 0 );
if (m... |
1,342 | // sudo nvprof --print-gpu-trace --log-file test.txt ./sum_reduction_simple_opt3
// Prints log in txt file
#include<iostream>
#include<vector>
const int sharedMem = 256*sizeof(double);
__global__ void redSum(double *a, double *out){
__shared__ double red_mat[sharedMem];
auto i = (blockDim.x*2)*blockIdx.x + thread... |
1,343 | /* filename : pipelined_merge_sort.cu
* author : Tiane Zhu
* date : Mar 26, 2017
*
*
*/
/////
// Input : For each node v of a binary tree,
// a sorted list L_s[v] such that
// v is full whenever s >= 3 * alt(v)
////
// Output : For each node v,
// a sorted list L_{s+1}[v] such that
// v is full wh... |
1,344 | #include "includes.h"
__device__ void set_shared(int *buff, int* G,int off1 , int off2,int n)
{
int m = blockIdx.x+off1*gridDim.x;
int l = threadIdx.x+off2*blockDim.x;
int maxx = blockDim.x-1;
if(m<n && l<n)
{
//If we reach the last element check if n is less than the number of threads
//or if it's the last element of... |
1,345 | __global__ void sum_array(const int * array, int * total, unsigned int n) {
unsigned int idx = threadIdx.x + blockIdx.x * blockDim.x;
unsigned int stride = gridDim.x * blockDim.x;
unsigned int input_idx = idx;
__shared__ int partial_res[256];
int partial_sum = 0;
while (input_idx < n) {
... |
1,346 |
#include <iostream>
int crash(int b, int a);
int crash(int b, int a) {
return b / a;
}
int main(int argc, char *argv[]) {
crash(5, 0);
}
|
1,347 | //#include <omp.h>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <sys/mman.h>
#include <sys/stat.h>
#include <iostream>
#include <fcntl.h>
#include <cmath>
using namespace std;
__device__ __managed__ float *x, *y, *z, gpuTotal;
__device__ __managed__ int **indices, *lens;
__device_... |
1,348 | #include <stdio.h>
#include <stdlib.h>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
//The number of character in the encrypted text
#define N 1024
#define A 15
#define B 27
#define M 128
#define INV_MOD 111
void checkCUDAError(const char*);
void read_encrypted_file(int*);
/* Exercise 1.1 */
__dev... |
1,349 | #include "cuda.h"
#include "stdio.h"
__global__
void addSquareMatrix (int *A, int *B, int *result, int n) {
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threadIdx.y;
if(x < n && y < n) {
result[y * n + x] = A[y * n + x] + B[y * n + x];
//The same as: result[y][x] = arr1[y]... |
1,350 | /**
* Copyright 1993-2012 NVIDIA Corporation. All rights reserved.
*
* Please refer to the NVIDIA end user license agreement (EULA) associated
* with this source code for terms and conditions that govern your use of
* this software. Any use, reproduction, disclosure, or distribution of
* this software and relate... |
1,351 | extern "C" __device__ void simple_mul_workgroup(float *lhs, size_t lhs_offset,
float *rhs, size_t rhs_offset,
float *result,
size_t result_offset,
... |
1,352 | /*
* Copyright 2014-2015 NVIDIA Corporation. All rights reserved.
*
* Sample CUPTI app to demonstrate the usage of unified memory counter profiling
*
*/
#include <stdio.h>
#include <cuda.h>
#include <stdlib.h>
#define CUPTI_CALL(call) \
do { ... |
1,353 | #include <cuda.h>
#include <cuda_runtime.h>
__global__ void MatrixMulKernel(float * Md, float * Nd, float * Pd, int Width)
{
// identifiant de thread deux dimensions, comme la matrice
int tx = threadIdx.x;
int ty = threadIdx.y;
// Pvaleur sert au stockage de la valeur calcule par le thread
float P... |
1,354 | /************************************************************
* ECE408 Parallel Programming - Final Project *
* *
* Topic: Terrain Generation *
* Members: Lai,Haoming; Ma,Yunhan; Wang,Bangqi *
* *
************************************************************/
/*
* Terrain Genera... |
1,355 | #include "cuda_runtime.h"
#include "cuda.h"
#include "device_launch_parameters.h"
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>
#define CUDA_CALL(x) do { cudaError_t err = x; if (( err ) != cudaSuccess ){ \
printf ("Error \"%s\" a... |
1,356 | //Darrien Park
#include "cuda_runtime.h"
#include <string.h>
#include <stdio.h>
//no field in cudaDeviceProperties for number of cores. Therefore need to determine based on compute capability
int getCores(cudaDeviceProp dev_prop)
{
int cores = 0;
int sm = dev_prop.multiProcessorCount;
//start switch case based on... |
1,357 | #include <iostream>
#include <curand.h>
using namespace std;
#include <curand.h>
struct random_d_array
{
float *data;
int n;
random_d_array(int n) :n{n}
{
cudaMalloc((void**)&data, n*sizeof(float));
curandGenerator_t gen;
curandCreateGenerator(&gen, CURAND_RNG_PSEUDO_DEFAULT);
curandGenerate... |
1,358 | #include "includes.h"
__global__ void inputKernel2(float *x, int n, int N)
{
int ix = blockIdx.x * blockDim.x + threadIdx.x,i;
int iy = blockIdx.y * blockDim.y + threadIdx.y;
int idx = iy * NUM_OF_X_THREADS + ix;
if (idx < N)
{
if (idx < n)
{
x[idx*N] = ((float)idx * 2) - ((float)idx * (float)idx);
}
else
{
x[idx... |
1,359 | #include "cuda.h"
#include "math.h"
#include "stdio.h"
#include "stdlib.h"
#include "thrust/reduce.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 (bl... |
1,360 | //
// TP: Exploration de la machine
// Complter les TODOs
//
#include<iostream>
int main (int argc, char ** argv) {
// Nombre de GPU sur la machine supporant CUDA
int devices_count = 0;
cudaGetDeviceCount(&devices_count);
std::cout << "Cette machine est รฉquiรฉe de " << devices_count << " GPU(... |
1,361 | __device__ int find_qmin_and_qmax(
double dq0,
double dq1,
double dq2,
double *qmin,
double *qmax)
{
// Considering the centroid of an FV triangle and the vertices of its
// auxiliary triangle, find
// qmin=min(q)-qc and qmax=max(q)-qc,
// where min(q) and ... |
1,362 | #include "includes.h"
__global__ void SidedDistanceKernel(int b,int n,const float * xyz,int m,const float * xyz2,float * result,int * result_i){
const int batch=512;
__shared__ float buf[batch*3];
for (int i=blockIdx.x;i<b;i+=gridDim.x){
for (int k2=0;k2<m;k2+=batch){
int end_k=min(m,k2+batch)-k2;
for (int j=threadIdx... |
1,363 | #include "includes.h"
__global__ void set_zero_kernel(float *src, int size)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < size) src[i] = 0;
} |
1,364 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
//#include "bmp.h"
extern "C" void write_bmp(unsigned char* data, int width, int height);
extern "C" unsigned char* read_bmp(char* filename);
//#include "host_blur.h"
extern "C" void host_blur(unsigned char* inputImage, unsigned char* outputImage, int size);
vo... |
1,365 | #include "includes.h"
__global__ void addKernel(int *c, int *a,int *b)
{
int i = threadIdx.x;
c[i] = a[i] + b[i];
//printf("%d", c[i]);
} |
1,366 | __global__ void spfaKernelForSSSP(int *V, int *E, int *W, int *n, bool *visit,int *dist){
int old=0, u, v;
__shared__ int QuickExit;
const int threadId = threadIdx.z*(blockDim.x * blockDim.y)+ threadIdx.y* blockDim.x+ threadIdx.x;
const int blockSize =blockDim.x * blockDim.y * blockDim.z;
while... |
1,367 | #include <stdio.h>
#include <stdlib.h>
#define SIZE 1024
/* must use .cu otherwise .c and .cpp will send to host compiler and global would have issues */
__global__ void VectorAdd(int *a, int *b, int *c, int n) {
int i = threadIdx.x;
// no loop for (i = 0; i < n; ++i)
if (i < n)
c[i] = a[i] + b[i];
}
int main... |
1,368 | #include "includes.h"
__global__ void negative_prob_multiply_dense_matrix_vector_kernel(float* matrix, float* in_vector, float* out_vector, unsigned int outerdim, unsigned int innerdim) {
// We parallelize at the level of matrix rows,
unsigned int row = blockIdx.x*blockDim.x+threadIdx.x;
float prob = 1.0;
if (row < o... |
1,369 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <cstring>
#include <iostream>
#define checkCudaErrors(err) __checkCudaErrors (err, __FILE__, __LINE__)
inline void __checkCudaErrors(cudaError err, const char* file, const int line)
{
if (cudaSuccess != err)
{
std::cerr << file << "(" << lin... |
1,370 | #include <iostream>
#include <cstdio>
#include <iomanip>
#define CSC(call) do { \
cudaError_t res = call; \
if (res != cudaSuccess) { \
fprintf(stderr, "CUDA Error in %s:%d: %s\n", __FILE__, __LINE__, cudaGetErrorString(res)); \
exit(0); \
} \
} while (0)
using namespace std;
__global__ void kernel(double ... |
1,371 | //====================================================
// GPIO Control
// main.cu : Main Routine
//----------------------------------------------------
// Rev.01 2019.06.08 M.Munetomo
//----------------------------------------------------
// Copyright (C) 2019 Munetomo Maruyama
//===================================... |
1,372 | #include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <iostream>
int main() {
thrust::host_vector<double> host(10, 0);
host[9] = 35;
printf("Host vector: ");
for (thrust::host_vector<double>::iterator i = host.begin(); i != host.end(); i++) {
std::cout << *i << " "; // est... |
1,373 | #include <iostream>
#include <math.h>
#include <cstdio>
using namespace std;
// Thread block size
const int blockSize = 16;
// Matrices are stored in row-major order:
// M(row, clo) = *(M.elements + row*M.width + col);
typedef struct {
int width;
int height;
float* elements;
} Matrix;
// CPU matrix multiplica... |
1,374 | #include "includes.h"
__global__ void kernelA(int n, float *x, float *y) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
int stride = blockDim.x * gridDim.x;
for (int i = index; i < n; i += stride) {
if (x[i] > y[i]) {
for (int j = 0; j < n / CONST; j++)
y[i] = x[j] + y[j];
} else {
for (int j = 0; j < n / CONST; ... |
1,375 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <assert.h>
#include <sys/time.h>
#define THREADS 512
#ifdef __cplusplus
extern "C"
{
#endif
__global__ void bitonicSort(float *d_inputArray, int blockSize, int strideLength, int number_of_elements)
{
int index = blockIdx.x*blockDim.x + threadIdx.x;
... |
1,376 | #include "includes.h"
__global__ void initMemory(size_t position, size_t* array)
{
size_t idx = threadIdx.x + blockIdx.x * blockDim.x;
array[position + idx] = idx;
} |
1,377 | #include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <cuda_runtime.h>
#include "kernel.cuh"
#define N 100000
#define BLOCK_SIZE 256
void compareBuffers(const float *a, const float *b, const uint32_t arr_size)
{
uint32_t total_failed = 0;
for(uint32_t i = 0; i < arr_size; ++i)
{
if(a[i] !=... |
1,378 | #include "includes.h"
extern "C"
extern "C"
extern "C"
extern "C"
extern "C"
extern "C"
//=== Vector arithmetic ======================================================
extern "C"
extern "C"
extern "C"
extern "C"
extern "C"
extern "C"
//=== Vector-and-scalar arithmetic ==... |
1,379 | #include "includes.h"
__global__ void sumArraysOnGPUshared(float *A, float *B, float *C, const int N)
{
__shared__ float smem[512];
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < N) {
smem[threadIdx.x] += i;
C[i] = A[i] + B[i] + smem[threadIdx.x];
}
} |
1,380 | #include <stdio.h>
__global__ void hello_from_gpu()
{
printf("This is hello from GPU\n");
}
int main()
{
printf("This is hello from CPU\n");
hello_from_gpu <<<1,10>>> ();
cudaDeviceReset();
return 0;
}
|
1,381 | #include <iostream>
#include <chrono>
using namespace std;
using namespace std::chrono;
|
1,382 | #include <iostream>
#include <math.h>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
using namespace std;
// Kernel function to add the elements of two arrays
__global__
void add(int n, float *x, float *y)
{
int index = blockIdx.x * blockDim.x + threadIdx.x;
int stride = blockDim.x * gridDim.x;
... |
1,383 | #include "includes.h"
__global__ void cu_depadding(const float* src, float* dst, const int rows1, const int cols1, const int cols2, const int n){
int tid = threadIdx.x + blockIdx.x * blockDim.x;
int stride = blockDim.x * gridDim.x;
while(tid < n){
int pad = (cols1 - cols2) / 2;
int c2 = tid % cols2;
int r2 = tid / cols... |
1,384 | #include "includes.h"
__global__ void matrixAdd_B_Kernel(float* A, float* B, float* C, size_t pitch, int width){
//compute indexes
int row = blockIdx.x * blockDim.x + threadIdx.x;
int rowWidthWithPad = pitch/sizeof(float);
if(row < width){
for (int col = 0; col < width; ++col) {
if(col < width)
C[row * rowWidthWith... |
1,385 | #include <cuda.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
typedef struct {
int width;
int height;
int stride;
float* elements;
} Matrix;
float rand(float a,float b)
{
return(b - a) * ((float)rand() / RAND_MAX) + a;
}
__device__ float GetElement(const Matrix A, int row, int col)... |
1,386 | /* Block size X: 32 */
__global__ void fct_ale_a1(const int maxLevels, const double * __restrict__ fct_low_order, const double * __restrict__ ttf, const int * __restrict__ nLevels, double * __restrict__ fct_ttf_max, double * __restrict__ fct_ttf_min)
{
const int node = (blockIdx.x * maxLevels);
for ( int level = threa... |
1,387 | #include "includes.h"
__global__ void sumArraysOnGPUlocal(float *A, float *B, float *C, const int N)
{
float local[4];
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i +4 < N) {
for (int j=0; j < 4; j++) local[j] = 2*A[i+j];
C[i] = A[i] + B[i] + local[threadIdx.x%4];
}
} |
1,388 | #include <iostream>
#include <cuda.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
#define ARRAY_SIZE_X 32
#define ARRAY_SIZE_Y 16
#define ARRAY_SIZE_IN_BYTES (sizeof(unsigned int) * (ARRAY_SIZE_X * ARRAY_SIZE_Y))
/*ๅฎไน const ๆ้(็ฑไบๆ้ๆฌ่บซ็ๅผไธ่ฝๆนๅๆไปฅๅฟ
้กปๅพๅๅงๅ๏ผ*/
__global__ void what_is_my_id_2d_A(
unsigned int ... |
1,389 | #include <cuda_runtime.h>
#include <stdio.h>
int main(){
int device = 0;
cudaDeviceProp device_property;
cudaGetDeviceProperties(&device_property, device);
printf("\nDevice %d: %s", device, device_property.name);
int driver_version;
int runtime_version;
cudaDriverGetVersion(&driver_versio... |
1,390 | #include <iostream>
#include <chrono>
using namespace std;
using namespace std::chrono;
__global__ void vecAddGPU(double *a, double *b, double *c, double n){
int id = blockIdx.x * blockDim.x + threadIdx.x;
if (id < n){
c[id] = a[id] + b[id];
}
}
void vecAddCPU(double *a, double *b, doubl... |
1,391 | #include "slicer.cuh"
#include "triangle.cuh"
#include <thrust/sort.h>
#include <thrust/count.h>
#include <thrust/functional.h>
#include <thrust/copy.h>
// Declare local helper functions
__device__ __forceinline__ void toNextLayer(layer_t* intersections_large_local,
size_t trunk_length_local, layer_t & curr_layer... |
1,392 | /**
* Group Info:
* rwsnyde2 Richard W Snyder
* kshanka2 Koushik Shankar
*/
#include <stdlib.h>
#include <stdio.h>
#include <cuda_runtime.h>
#include <time.h>
#include <cooperative_groups.h>
#define __DEBUG
#define CUDA_CALL( err ) __cudaSafeCall( err, __FILE__, __LINE__ )
#define CUDA_CHK_ERR() __cudaCheckErro... |
1,393 | /*
A basic CUDA demonstration. Two random vectors are added together
in serial and using a GPU accelerator.
To compile, use:
make
NOTE: CUDA must be installed/loaded before running make. Also, the
Makefile will probably have to be customized for your system.
To run, use for exam... |
1,394 | //
// 3D DCA Driver
//This file invokes all of the necessary function calls to prepare
//and simulate a compound pendulum system through the use of the
//recursive DCA algorithm. The majority of this algorithm is run
//on the gpu. Output is created in a format that is
//readable in python for answer checking and graph... |
1,395 | #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
__device__
unsigned char clip(int n) {
return n > 255 ? 255 : (n < 0 ? 0 : n);
}
__global__
void distanceKernel(uchar4 *d_out, int w, int h, int2 pos) {
const int c =... |
1,396 | #include <cuda.h>
#include <cuda_runtime_api.h>
#include <float.h>
#include <stdio.h>
#include <stdlib.h>
#define RED 0
#define GREEN 1
const char * LABELS[] = {
"Red",
"Green"
};
/**
* Computes the Euclidean distance between the input vector 'Y' and all
* vectors in the array 'X'.
* An array of size 'n' conta... |
1,397 | #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... |
1,398 | #include "includes.h"
__global__ void check_if_unique(const unsigned *keys, unsigned *is_unique, size_t kSize) {
unsigned id = threadIdx.x +
blockIdx.x * blockDim.x +
blockIdx.y * blockDim.x * gridDim.x;
if (id == 0) {
is_unique[0] = 1;
} else if (id < kSize) {
is_unique[id] = (keys[id] != keys[id - 1] ?... |
1,399 | #include "includes.h"
__global__ void RemoveNodeByUtilityKernel( int *connectionMatrix, int *connectionAge, int *activityFlag, float *utility, float utilityConstant, float *localError, int *neuronAge, float *winningFraction, int *winningCount, float maxError, int maxCells )
{
int threadId = blockDim.x*blockIdx.y*grid... |
1,400 | /*
* demo_log_speed.cu
*
* Created on: 07-Apr-2009
* Author: alee
*/
//#include <cutil.h>
#include <stdio.h>
__global__ void logtest(int size, float* d_array, int M) {
const int tid = blockDim.x * blockIdx.x + threadIdx.x;
const int tt = blockDim.x * gridDim.x;
int i, j;
float x;
for (i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.