serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
1,101 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <stdbool.h>
#include <unistd.h>
#include <cuda.h>
#define NUM_THREADs 5
#define BLOCK_SIZE 16
#define PI 3.141592654
#define MEGEXTRA 1000000
typedef struct Matrix
{
int width;
int height;
double* elements;
} Matrix;
__gl... |
1,102 | // System includes
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <math.h>
// CUDA runtime
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <time.h>
#define BLOCK_SIZE 128
#define N 4194304
// #define N 2048
__global__ void reduce0(int *g_idata, int *g_odata , int size)
{... |
1,103 | #include <stdio.h>
#include <math.h>
__global__ void multi(float *a, float *b, float *c, int width) {
int col = threadIdx.x + blockIdx.x * blockDim.x;
int row = threadIdx.y + blockIdx.y * blockDim.y;
float result = 0;
if (col < width && row < width) {
for (int k = 0; k < width; k++) {
result +=... |
1,104 | #include <stdio.h>
__device__ float* hello;
__global__ void TryHello(float* hello) {
// float hi = *hello;
// printf("%f\n", hi);
printf("Hello from block %d, thread %d\n", blockIdx.x, threadIdx.x);
}
__global__ void setHello(float* hello, float num) {
*hello = num;
}
// int main() {
// TryHello<<<1, 5>>>(... |
1,105 | #include <stdio.h>
#include <math.h>
#include <cuda_runtime.h>
const double pi = 3.14159265358979323846;
void X_init(double *a, int numTicks, double delta) {
for (int i = 0; i <= numTicks; ++i)
for (int j = 0; j <= numTicks; ++j)
a[i*(numTicks+1) + j] = (double)j * delta;
}
void Y_init(double *a, int numTicks, d... |
1,106 | #include "includes.h"
__global__ void reset_states_u_after_spikes_kernel(float *d_states_u, float * d_param_d, float* d_last_spike_time_of_each_neuron, float current_time_in_seconds, size_t total_number_of_neurons) {
int idx = threadIdx.x + blockIdx.x * blockDim.x;
while (idx < total_number_of_neurons) {
if (d_last_sp... |
1,107 | #include "includes.h"
__global__ void add_vector(int* a,int* b,int*c)
{
int i = blockIdx.x*blockDim.x+ threadIdx.x;
c[i] = a[i] + b[i];
} |
1,108 | #include "includes.h"
__global__ void OPT_1_HIST(int* lcm, int* hist, int n) {
//
int vertex = blockIdx.x;
int vcomp = threadIdx.x;
bool equal;
//
__shared__ int cval;
//
if(vcomp == 0)
cval = 0;
__syncthreads();
//
if(vertex < n && vcomp < n)
for(int i = vcomp; i < n; i += blockDim.x) {
if(vertex == i) {
atomicAd... |
1,109 | #include "includes.h"
__global__ void boxFilter(unsigned char *srcImage, unsigned char *dstImage, unsigned int width, unsigned int height, int channel)
{
int x = blockIdx.x*blockDim.x + threadIdx.x;
int y = blockIdx.y*blockDim.y + threadIdx.y;
// only threads inside image will write results
if((x>=FILTER_WIDTH/2) && (... |
1,110 | //60070501054
//60070501064
#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <curand.h>
#include <curand_kernel.h>
#define blocksize 1024
#define gridsize 1
#define threadsize 1024
__global__ void piEstimate(long long int *countStore, int *iterations)
{
int rank = (blockIdx.x * blockDim.x) + threadI... |
1,111 | #include "includes.h"
__global__ void init_i32 (int* vector, int value, int len) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < len) {
vector[idx] = value;
}
} |
1,112 | //xfail:TIMEOUT
//--gridDim=64 --blockDim=128 --warp-sync=32
#include "common.h"
template <unsigned int blockSize, bool nIsPow2> __global__ void reduceMultiPass(const float *g_idata, float *g_odata, unsigned int n);
template __global__ void reduceMultiPass<128, true>(const float *g_idata, float *g_odata, unsigned int... |
1,113 |
/**
* 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 relat... |
1,114 |
#define THREAD_BLOCK_SIZE 512
#define NUM_BLOCKS 320 // Define the size of a tile
/* This function uses a compare and swap technique to acquire a mutex/lock. */
__device__ void lock(int *mutex)
{
while(atomicCAS(mutex, 0, 1) != 0);
}
/* This function uses an atomic exchange operation to release the mutex/lock.... |
1,115 | #include <stdio.h>
// __device__ float lerp1d(int a, int b, float w)
// {
// if(b>a){
// return a + w*(b-a);
// }
// else{
// return b + w*(a-b);
// }
// }
__device__ double lerp1d(int a, int b, float w)
{
return fma(w, (float)b, fma(-w,(float)a,(float)a));
}
__device__ double ler... |
1,116 |
/* 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,int var_2,float var_3,float 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 v... |
1,117 | #include<stdio.h>
#include<stdlib.h>
__global__ void arradd(int* md, int* nd, int* pd, int size)
{
int myid = blockIdx.x*blockDim.x + threadIdx.x;
pd[myid] = md[myid] + nd[myid];
}
int main()
{
int size = 2000 * sizeof(int);
int m[2000], n[2000], p[2000],*md, *nd,*pd;
int i=0;
for(i=0; i<2000; i++ )
{
... |
1,118 | //
// Created by root on 2020/12/3.
//
#include "thrust/host_vector.h"
#include "thrust/device_vector.h"
#include "thrust/reduce.h"
#include "thrust/generate.h"
#include "thrust/transform.h"
#include "math.h"
#include "stdio.h"
#define N (1 << 20)
using namespace thrust::placeholders;
int main() {
thrust::host_... |
1,119 | #include "includes.h"
__constant__ float *c_Kernel;
__global__ void subtract(float *d_dst, float*d_src_1, float* d_src_2, int len) {
int baseX = blockIdx.x * blockDim.x + threadIdx.x;
if (baseX < len)
{
d_dst[baseX] = d_src_1[baseX] - d_src_2[baseX];
}
} |
1,120 | #include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>
#include <time.h>
#include <string.h>
#include <math.h>
#include <float.h>
// includes, kernels
#include "vector_dot_product_kernel.cu"
void run_test(unsigned int);
float compute_on_device(float *, float *,int);
void check_for_error(char *);
extern "C" floa... |
1,121 | #include <stdio.h>
#include <vector>
__global__ void add_kernel(int *a, int *b, int *c) {
*c = *a + *b;
}
//template <typename T>
//struct Matrix {
// int width;
// int height;
// std::vector<T> data;
//};
//
//template <>
//struct Matrix {
// int width;
// int height;
// std::vector<float> data... |
1,122 | #include <stdio.h>
#define N 64
#define TPB 32
__device__ 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 ref, int len){
const int i = blockIdx.x*blockDim.x + threadIdx.x;
co... |
1,123 | #include <stdio.h>
#include <sys/time.h>
#include "cuda.h"
#include <string.h>
#define MAX_ARGS 10
#define REC_LENGTH 49 // size of a record in db
#ifndef REC_WINDOW
#define REC_WINDOW 15000 // number of records to take in at a time
#endif
#define LATITUDE_POS 28 // character position of the latitude value in each ... |
1,124 | /**
* Author: Zachariah Bryant
* Description: Pre-generates a thermalized lattice configuration for later use.
*/
// ********************
// * Headers *
// ********************
#include <sys/stat.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <fstream>
#include <string>
#incl... |
1,125 | #include <stdio.h>
#include <stdlib.h>
#include <curand_kernel.h> // CURAND lib header file
#define TRIALS_PER_THREAD 1024 // Set the value for global variables
#define BLOCKS 256
#define THREADS 512
#define PI 3.1415926535 // Known value of pi, to calculate error
__global__ void pi_mc(float *estimate, curandState *s... |
1,126 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
__global__ void matrixMultGPU(int *A,int *B,int *C, int N,int mod){
int k, sum=0;
int col = threadIdx.x + blockDim.x * blockIdx.x;
int fil = threadIdx.y + blockDim.y * blockIdx.y;
if (col < N && fil < N)
{
for (k = 0; k < N; k++)
{
sum += A[fil * N... |
1,127 | #pragma once
#include "Vector3.cuh.cu"
#include "Ray.cuh.cu"
namespace RayTracing
{
class Plane
{
protected:
Point3 m_A, m_B, m_C;
Vector3 m_normal;
float m_D;
public:
Plane(
const Vector3 &A,
const Vector3 &B,
const Vector3 &C,
const Point3 &origin
)
... |
1,128 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <assert.h>
//#include <time.h>
#define N 2
__global__ void MoreSums(int *a, int *b, int *c){
c[blockIdx.x] = a[blockIdx.x] + b[blockIdx.x];
}
|
1,129 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
__global__ void vector_add(float *a, float *b, float *c, int n)
{
int tid = blockIdx.x * blockDim.x + threadIdx.x;
if(tid < n)
c[tid] = a[tid] + b[tid];
}
int main( int argc, char* argv[] )
{
cudaEvent_t start,stop;
float elapsedTime;
cudaEventCreate(&... |
1,130 | #include "includes.h"
__global__ void update_positions( const int size, const double position_step, const double* force_per_atom, const double* position_per_atom, double* position_per_atom_temp)
{
const int n = blockIdx.x * blockDim.x + threadIdx.x;
if (n < size) {
const double position_change = force_per_atom[n] * pos... |
1,131 | #include "includes.h"
__global__ void calc_lut(int *lut, int * hist_in, int img_size, int nbr_bin){
__shared__ int shared_hist[256];
shared_hist[threadIdx.x] = hist_in[threadIdx.x];
__syncthreads();
int i, cdf, min, d;
cdf = 0;
min = 0;
i = 0;
while(min == 0){
min = shared_hist[i++];
}
d = img_size - min;
for(i = 0... |
1,132 | #include "includes.h"
__global__ void zupdate2_dummy(float *z1, float *z2, float *f, float tau, 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;
float a, b, t;
if (px<nx && py<ny)
{
// compute the gradient
a = 0;
b = 0;
float fc = f... |
1,133 | #include <stdio.h>
#include <thrust/extrema.h>
#include <thrust/device_vector.h>
struct type {
int key;
int value;
};
struct comparator {
__host__ __device__ bool operator()(type a, type b) {
return a.key < b.key;
}
};
int main() {
srand(time(NULL));
comparator comp;
int i, i_max = -1, n = 100000;
type *... |
1,134 | /*******************************************************************************
* Copyright (C) 2019 Marvin Löbel <loebel.marvin@gmail.com>
* Copyright (C) 2019 Oliver Magiera <oliver.magiera@tu-dortmund.de>
*
* All rights reserved. Published under the BSD-3 license in the LICENSE file.
**************************... |
1,135 | #include <cuda.h>
//#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <assert.h>
#define N 16
__device__ int index(int col, int row, int ord){
return (row *ord)+col;
}
__global__ void Transpose(int *c, const int *a){
int col = (blockDim.x * blockIdx.x) + threadIdx.x;
... |
1,136 | #include <cuda_runtime_api.h>
__global__ void linear_bias_fwd_kernel(
const float *in_buf,
int dim,
int batch_size,
const float *bias,
float *out_buf)
{
int idx = threadIdx.x + blockIdx.x * blockDim.x;
int k = idx % dim;
int batch_idx = idx / dim;
if (k < dim && batch_idx < batch_size) {
... |
1,137 | __global__ void DTWSSM(float* SSMA, float* SSMB, float* CSM, int M, int N, int diagLen, int diagLenPow2) {
//Have circularly rotating system of 3 buffers
extern __shared__ float x[]; //Circular buffer
int off = 0;
int upoff = 0;
//Other local variables
int i, k;
int i1, i2, j1, j2;
int ... |
1,138 | #include "includes.h"
__global__ void cuda_conv2D_updateDeltas(double* delta, double* biasDelta, const double* upStreamActivation, const double* err, double momentum, size_t kernelCount, size_t kernelRows, size_t kernelCols, size_t outputRows, size_t outputCols, size_t inputChannels, size_t inputRows, size_t inputCols,... |
1,139 | #include <stdio.h>
#include <stdlib.h>
__global__ void kernel(int *d, int n){
__shared__ int s[64];
int t =threadIdx.x;
int tr=n-t-1;
s[t]=d[t];
__syncthreads();
d[t]=s[tr];
}
int main (void)
{
const int n=64;
int a[n],r[n],d[n];
for(int i=0;i<n;i++)
{
a[i]=i;
r[i]=n-i-1;
d[i]=0;
}
int *d_d;
cuda... |
1,140 | #include "includes.h"
__global__ void Interpolate(float* input1, float* input2, float* output, float weight, int inputSize)
{
int threadId = blockDim.x*blockIdx.y*gridDim.x //rows preceeding current row in grid
+ blockDim.x*blockIdx.x //blocks preceeding current block
+ threadIdx.x;
if(threadId < inputSize)
{
if (w... |
1,141 | #include <cuda.h>
#include <cuComplex.h>
// Launch configuration should be as follows:
// 1. blocks of dim3(threads_per_dim, threads_per_dim, 1) size
// where threads_per_dim = min(N, 16)
// 2. grid of dim3((N+threads_per_dim-1)/threads_per_dim, (N-1)/(threads_per_dim * 2)+1, 1) blocks
template <class T>
stat... |
1,142 | #include <math.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <sys/timeb.h>
// Hypercube
// Version: optimisé pour une partagée
// On sépare le gros tableau en multiples sous-tableaux qu'on réduit de la même manière
// Pas limité en taille
#define pow2(x) (1<<(x))
// Nombre de threads par bloc... |
1,143 | /**
* Copyright 1993-2015 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,144 | // ###
// ###
// ### Practical Course: GPU Programming in Computer Vision
// ###
// ###
// ### Technical University Munich, Computer Vision Group
// ### Winter Semester 2015/2016, March 15 - April 15
// ###
// ###
#include <cuda_runtime.h>
#include <iostream>
using namespace std;
// cuda error checking
#define CUDA... |
1,145 | #include <cmath>
#include <cstdio>
#include <cuda_runtime.h>
#include "Sudoku.cuh"
/**
* Takes array and resets all values to false.
*/
__device__
void clearArray(bool *arr, int size) {
for (int i = 0; i < size; i++) {
arr[i] = false;
}
}
/**
* Checks if the state of board is valid.
* board is one-dimensional... |
1,146 | #include "stdio.h"
#define N 10
__global__ void add(int *a,int *b,int *c)
{
int tID = blockIdx.x;
if(tID<N)
{
c[tID] = a[tID] + b[tID];
}
}
int main()
{
int a[N],b[N],c[N];
int *dev_a,*dev_b,*dev_c;
cudaMalloc((void**)&dev_a,N*sizeof(int));
cudaMalloc((void**)&dev_b,N*sizeof(int));
cudaMalloc((void**)&d... |
1,147 | // CUDA by Example
// Ch10: page-locked (pinned) host memory
#include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
static void HandleError(cudaError_t err,
const char *file,
int line) {
if (err != cudaSuccess) {
printf("%s in %s at line %d\n", cudaGetErrorString(err),
file, ... |
1,148 | extern "C"
__global__ void add(int n, float *cRarr, float *cIarr, int *result) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < n) {
float cR = cRarr[i];
float cI = cIarr[i];
int n = 0;
float x = 0;
float y = 0;
for(n = 0; (y*y) < 4 && n < 255; n++) {
... |
1,149 | #include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <iostream>
#include <fstream>
#include <time.h>
#include <thrust/device_vector.h>
#define BLOCK_SIZE 16
__global__ void MV(int *vec, int *mat, int *out, const int N, const int M){
int tid=threadIdx.x+blockIdx.x*blockDim.x;
int sum=0;
if(... |
1,150 | #include <cuda.h>
#include <cuda_runtime.h>
#include <time.h>
#define N 32*1024*1024
#define BLOCK_SIZE 256
__global__ void reduce_v1(float *g_idata,float *g_odata){
__shared__ float sdata[BLOCK_SIZE];
// each thread loads one element from global to shared mem
unsigned int tid = threadIdx.x;
unsigned... |
1,151 | #include "includes.h"
__global__ void cuArraysSetConstant_kernel(float *image, int size, float value)
{
int idx = threadIdx.x + blockDim.x*blockIdx.x;
if(idx < size)
{
image[idx] = value;
}
} |
1,152 | //
// Assignment 1: ParallelSine
// CSCI 415: Networking and Parallel Computation
// Spring 2017
// Name(s):Chengyao Tang,Victoria Kyereme
//
// Sine implementation derived from slides here: http://15418.courses.cs.cmu.edu/spring2016/lecture/basicarch
// standard imports
#include <stdio.h>
#include <math.h>
#includ... |
1,153 | // simple stupid dot product example from chapter 5 of CUDA by Example
// as worked by myself from scratch
#include <stdio.h>
#define N 1000000
#define BPG 16
#define TPB 16
__global__ void dot(float *a, float *b, float *c){
//accumulate thread result on shared mem (per block)
__shared__ float cache[TPB];
... |
1,154 |
/* 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,int var_2,float var_3,float 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 va... |
1,155 | __global__
void broadcast_kernel(int n, const float* x, float *z)
{
int i = blockIdx.x*blockDim.x + threadIdx.x;
if (i < n) z[i] = x[0];
}
void broadcast(int n, const float* x, float *z) {
broadcast_kernel<<<(n+255)/256, 256>>>(n, x, z);
}
|
1,156 | #include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include "unistd.h"
#include "time.h"
#include "string.h"
// Stores temporary shift values
__constant__ float dm_shifts[4096];
// ---------------------- Optimised Dedispersion Loop ------------------------------
__global__ void dedisperse_loop(float *outbuff, ... |
1,157 | #define t_max 1
#define t 1
/*
(u[0][0][0][0][0]=((alpha*(ux[1][0][0][0][1]-ux[-1][0][0][0][1]))+((beta*(uy[0][1][0][0][2]-uy[0][-1][0][0][2]))+(gamma*(uz[0][0][1][0][3]-uz[0][0][-1][0][3])))))
*/
__global__ void divergence(float * * u_0_0_out, float * u_0_0, float * ux_1_0, float * uy_2_0, float * uz_3_0, floa... |
1,158 | #include <stdio.h>
#include <stdlib.h>
#define N 32
//Código device
__global__ void soma_vetor(int *a, int *b, int *c){
int indice = blockIdx.x;
if(indice < N)
c[indice] = a[indice] + b[indice];
}
//Código host
int main(){
int a[N],b[N],c[N];
int* dev_a;
int* dev_b;
int* dev_c;
int tam = N*sizeof(int);
//... |
1,159 | #include <stdio.h>
__global__ void global_scan(float* d_out, float* d_in) {
int idx = threadIdx.x;
float out = 0.00f;
d_out[idx] = d_in[idx];
__syncthreads();
for (int interpre = 1; interpre<sizeof(d_in); interpre *= 2) {
if (idx - interpre >= 0) {
out = d_out[idx] + d_out[idx - interpre];
}
__syncthrea... |
1,160 | ////////////////////////////////////////////////////////////////////////////////
// CUDA LATTICE RELAXATION
// WRITTEN BY: CLAYTON RAYMENT
//
// I wrote this program to help teach myself CUDA. While MATLAB and OCTAVE
// are multithreaded applications, this pro... |
1,161 | #include <stdio.h>
__global__ void mykernel(void)
{
printf("Hello World from GPU!\n");
}
int main(void)
{
mykernel<<<1,1>>>();
cudaDeviceSynchronize;
printf("Hello World from CPU!\n");
return 0;
} |
1,162 | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#define MAX_CHAR 100
#define DATAFILE "data.txt"
#define RESULTSFILE "resultsCudal.txt"
#define G 6.674e-11
#define NUM_ITER 1000
#define NUM_ITER_SHOW 50
__global__ void asteroid(double * gpu_x, double * gpu_y, double * gpu... |
1,163 | #include <stdio.h>
unsigned int N = 1 << 12;
unsigned int N_p = N/4;
__global__
void mul(int n, int *x, int *y)
{
int i = blockIdx.x*blockDim.x + threadIdx.x;
if (i < n) y[i] = x[i] * y[i];
}
int main(void)
{
int *d_x, *d_y;
int *x, *y;
x = (int*)malloc(N*sizeof(int));
y = (int*)malloc(N*sizeof(int));
... |
1,164 | #include <iostream>
#include <cstdlib>
__global__ void setVec (int* array) {
int i=blockIdx.x*blockDim.x+threadIdx.x;
array[i] = 42;
}
int main() {
int* array; //Creates a pointer of int. This will be used on host
int* array_d; //Creates a pointer of int. This will be used on device
int N = 8; //Sets the arr... |
1,165 |
#include <stdio.h>
#include <stdlib.h>
#define BLOCKSIZE 128
#define gpuErrchk(error) __checkCuda(error, __FILE__, __LINE__)
#define iDivUp(x,y) (((x)+(y)-1)/(y)) // define No. of blocks/warps
/*********************************************/
/* A method for checking error in CUDA calls */
/***************************... |
1,166 | /*
* Program to show the COMPUTE CAPABILITY of the current device
*
* Version: Jul 2021
*/
#include <stdio.h>
//#define CURRENT_DEVICE 1
#define EXIT_SUCCESSFULLY 0
#define EXIT_ERROR -1
int main(int argc, char** argv)
{
cudaError_t result;
int device, coresPerSM;
//cudaSetDevice(CURRENT_DEVICE);... |
1,167 |
/******************************************************************************************
Source Code : SOAvsAOS.cu
Objective : Example code to demonstrate the advantage of having Stucture of arrays rather
than array of structures in the application while representing data the
... |
1,168 | #include<stdio.h>
__global__ void helloWorld()
{
printf("Hello World! My threadId is %d\n", threadIdx.x);
}
int main()
{
helloWorld<<<1, 256>>>();
cudaDeviceSynchronize();
return 0;
} |
1,169 | #include <stdio.h>
#include <cuda_runtime.h>
#include <stdlib.h>
#include <iostream>
#include <time.h>
#include <thread>
#include <vector>
using namespace std;
#define DSIZE 20000000
#define BSIZE 512
void initData(int data[]){
for(int i=0; i<DSIZE; i++){
data[i] = rand()%10;
}
}
/*
use shared memory to do r... |
1,170 | #include<stdio.h>
#include<stdio.h>
#include<string.h>
#include <stdlib.h>
#include <stdarg.h>
#include<time.h>
#include <math.h>
#define CHECK(call) \
{ \
const cudaError_t error = call; \
if (error != cudaSuccess) \
{ \
printf("Error: %s:%d, ", __FILE__, __LINE__); \
printf("code:%d, reason: %s\n", error, cuda... |
1,171 | //pass
//--blockDim=2048 --gridDim=64
struct s {
float x, y, z;
};
__global__ void foo(s *q) {
s p = { 0.0f, 0.0f, 0.0f };
q[threadIdx.x + blockIdx.x * blockDim.x] = p;
}
|
1,172 | // To compute histogram with atomic operations */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <cuda_runtime.h>
// Variables
float* data_h; // host vectors
unsigned int* hist_h; // GPU solution back to the CPU
float* data_d; // device vectors
unsigned int* ... |
1,173 | #include "includes.h"
__global__ void AssembleArrayOfNoticedChannels ( const int nmbrOfChnnls, const float lwrNtcdEnrg, const float hghrNtcdEnrg, const float *lwrChnnlBndrs, const float *hghrChnnlBndrs, const float *gdQltChnnls, float *ntcdChnnls ) {
int c = threadIdx.x + blockDim.x * blockIdx.x;
if ( c < nmbrOfChnnls ... |
1,174 | #include "includes.h"
__global__ void MatrixMulKernel(float *M, float *N, float *P, int Width)
{
int Row = blockIdx.y * blockDim.y + threadIdx.y;
int Col = blockIdx.x * blockDim.x + threadIdx.x;
if((Row < Width) && (Col < Width))
{
float Pvalue = 0;
for(int k = 0; k < Width; ++k)
{
Pvalue += M[Row*Width+k]*N[k*Width+... |
1,175 | #include "includes.h"
__global__ void THCudaTensor_kernel_copy(float *dst, long *dst_sz, long *dst_st, int dst_dim, float *src, long *src_sz, long *src_st, int src_dim, long n_elem, long innerdim)
{
long k = (blockIdx.z * gridDim.x * gridDim.y + blockIdx.y * gridDim.x + blockIdx.x)*blockDim.y + threadIdx.y;
long i_sta... |
1,176 |
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
// Note N must be an even multiple of BLOCK_DIM
#define N (BLOCK_DIM*1024)
#define BLOCK_DIM 16
#define RAND_SEED 97
#define NB_OF_THREADS 4
#define PRINT_MATRIX_OUT 0
#if PRINT_MATRIX_OUT
#define PRINT_MATRIX(...) print_matrix(__VA_ARGS__)
#else
#d... |
1,177 | #include "includes.h"
__global__ void gpuMM(float *A, float *B, float *C, int N)
{
// Matrix multiplication for NxN matrices C=A*B
// Each thread computes a single element of C
int row = blockIdx.y*blockDim.y + threadIdx.y;
int col = blockIdx.x*blockDim.x + threadIdx.x;
float sum = 0.0;
for (int n = 0; n < N; ++n)
sum... |
1,178 | #include <stdio.h>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include "string.h"
void printDevice(cudaDeviceProp prop){
printf("\t Name: \t%s\n",prop.name);
printf("\t Capability Major/Minor version number: %d.%d\n", prop.major, prop.minor);
printf("\t Total amount of global memory: \t%.... |
1,179 | #include "includes.h"
__global__ void kArgMinColumnwise(float* mat, float* target, unsigned int width, unsigned int height) {
__shared__ float min_vals[32];
__shared__ unsigned int min_args[32];
float cur_min = 2e38;
unsigned int cur_arg = 0;
float val = 0;
for (unsigned int i = threadIdx.x; i < height; i += 32) {
val... |
1,180 | #include "includes.h"
__device__ void warpReduce(volatile float *sdata, int tid, int bid, int size)
{
if (bid + 32 < size) sdata[tid] += sdata[tid + 32];
if (bid + 16 < size) sdata[tid] += sdata[tid + 16];
if (bid + 8 < size) sdata[tid] += sdata[tid + 8];
if (bid + 4 < size) sdata[tid] += sdata[tid + 4];
if (bid + 2 < ... |
1,181 | __global__ void swap(int *A,int n){
int idi = blockIdx.y*blockDim.y+threadIdx.y;
int idj = blockIdx.x*blockDim.x+threadIdx.x;
if(idi<n && idj<=idi){
if(idj%2==0 && idj<n-1){
int temp=A[idi*n+idj];
A[idi*n+idj]=A[idi*n+idj+1];
A[idi*n+idj+1]=temp;
}
int temp=idi;
idi=idj;
idj=temp;
if(idi!=idj &&... |
1,182 | #include <cuda.h>
#include <ctime>
#include <stdio.h>
#include <iostream>
int K = 256;
int N = 1024 * 32;
int sizeVector = (N * 32 * 20);
#define CUDA_CHECK_RETURN(value) ((cudaError_t)value != cudaSuccess) ? printf("Error %s at line %d in the file %s\n", cudaGetErrorString((cudaError_t)value), __LINE__, __FILE__) : ... |
1,183 | #include <stdio.h>
#include "imageutils.cuh"
// dimensions of the thread blocks
#define NUM_BLOCKS_X 16
#define NUM_BLOCKS_Y 16
__global__
void rgba_to_negative(
uchar4 *rgbaImage,
uchar4 *negativeImage,
int numRows, int numCols
) {
// finding pixel assigned to this thread
int thread_x = blockDim.x * blockIdx.x... |
1,184 | #include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <vector>
#define num 25
__global__ void gpuAdd(int *d_a, int *d_b, int* d_c, int N=num)
{
int tid = blockIdx.x;
if(tid < N)
{
d_c[tid] = d_a[tid] + d_b[tid];
printf("%d + %d = %d\n", d_a[tid], d_b[tid... |
1,185 | #include <stdio.h>
#include<stdlib.h>
#include<string.h>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#define BLOCK_SIZE 1024
#define SECTION_SIZE 2*BLOCK_SIZE
__global__ void
listScanKernel(float * input, float * output, int len)
{
__shared__ float list[SECTION_SIZE];
unsigned int t = thread... |
1,186 | #include <stdio.h>
__global__ void vectorAdd(const float *a, const float *b, float *c, int numElements)
{
int i = blockDim.x * blockIdx.x + threadIdx.x;
if (i < numElements)
{
c[i] = a[i] + b[i];
}
}
int main(int argc, char *argv[])
{
int numElements = 5e+4;
// Allocate vectors a, b and c in host memory.
si... |
1,187 | #include <stdio.h>
#include <time.h>
#include <malloc.h>
#define CUDA_CHECK_RETURN(value) {\
cudaError_t _m_cudaStat = value;\
if (_m_cudaStat != cudaSuccess) {\
fprintf(stderr, "Error \"%s\" at line %d in file %s\n",\
cudaGetErrorString(_m_cudaStat), __LINE__, __FILE__);\
exit(1);\
}\
} //макрос для обработ... |
1,188 | #include <stdio.h>
#include <cuda.h>
void vectorAdd(double* A, double* B,double* C,int n);
__global__ void vecAddKernel(double* A, double* B, double* C, int n);
int main() {
double *h_A, *h_B, *h_C;
int i;
long N=10000;
int size=N*sizeof(double);
h_A=(double*)malloc(size);
h_B=(double*)malloc(size);
h_C=(double*... |
1,189 | #include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <iostream>
#define Shared_Mem_Size 16*16*4
// CUDA kernel for vector addition
__global__ void tile_MatrixMul(int* a, int* b, int* c, int n, int tile_size) {
//statical... |
1,190 | #include <stdio.h>
const int N = 16;
__global__
void hello(char *a, int *b)
{
a[threadIdx.x] += b[threadIdx.x];
}
int cuda_test()
{
char a[N] = "Hello \0\0\0\0\0\0";
int b[N] = {15, 10, 6, 0, -11, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
char* ad = NULL;
int* bd = NULL;
printf("%s", a);
cudaMalloc((void**... |
1,191 | #include <stdio.h>
#include <stdlib.h>
__global__ void add(int *a,int *b)
{
int tid = threadIdx.x;
int n=a[tid];
if(tid+2<*b && tid<(*b)/2)
{
a[tid]=a[tid+2];
a[tid+2]=n;
}
}
int main(void)
{
int n,a[20],c[20];
printf("Enter value of N:");
n=5;
printf("Enter array elements ... |
1,192 | #include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <iostream>
#include <chrono>
int main() {
thrust::host_vector<double> host;
// thrust::sequence(host.begin(), host.end());
while (std::cin.good()) {
double t;
std::cin >> t;
host.push_back(t);
}
... |
1,193 | #define Index3D(_nx,_ny,_i,_j,_k) ((_i)+_nx*((_j)+_ny*(_k)))
__global__ void block2D_hybrid_coarsen_x(float c0,float c1,float *A0,float *Anext, int nx, int ny, int nz)
{
const int i = blockIdx.x*blockDim.x*2+threadIdx.x;
const int i2= blockIdx.x*blockDim.x*2+threadIdx.x+blockDim.x;
const int j = blockIdx.y*blockDim... |
1,194 | #include <stdio.h>
__global__ void dummy()
{
int j = 0;
for(int i = 0; i < 1000000; i++)
j++;
}
int main()
{
cudaStream_t stream1, stream2;
double *A, *B, *C, *D;
cudaSetDevice(1);
cudaMalloc((void **) &C, 100000000 * sizeof(double));
cudaMalloc((void **) &D, 10000000 * sizeof(double));
cudaSetDevice(0);... |
1,195 | /*
* Copyright 1993-2010 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 related... |
1,196 | #include <iostream>
#include <stdio.h>
#include <math.h>
// kernels transpose a tile of TILE_DIM x TILE_DIM elements
// using a TILE_DIM x BLOCK_ROWS thread block, so that each thread
// transposes TILE_DIM/BLOCK_ROWS elements.
// TILE_DIM must be an integral multiple of BLOCK_ROWS
#define SIZE 10016
#define TILE_DIM ... |
1,197 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
__global__ void print_threadIds()
{
printf("threadIdx.x : %d threadIdx.y : %d threadIdx.z : %d\n", threadIdx.x, threadIdx.y, threadIdx.z);
}
int main()
{
int nx=16, ny=16;
dim3 block(8, 8);
dim3 grid(nx/block.x, ny/bl... |
1,198 | #include<iostream>
#include<cstdlib>
#include<fstream>
#include<string>
#include<sys/time.h>
//#define debug
typedef unsigned long long int UINT;
using namespace std;
__device__ int s(int a, int b){
return a==b?3:-3;
}
__global__ void GPU(int *dev_table, int *dev_arr1, int *dev_arr2, int startIdx, int curjobs, con... |
1,199 | #include<cstdio>
#include<cstdlib>
#include<iostream>
#define DFL_LEN 32
#define MAX_THREADS_PER_BLOCK 1024 //supported by hardware, run ./deviceQuery to determine
//cuda error checking
#define check_error(ans) {cudaCheckError((ans),__FILE__,__LINE__);}
inline void cudaCheckError(cudaError_t e,const char *file,int ... |
1,200 | #include "includes.h"
extern "C"
__global__ void bubble(unsigned int length, unsigned int parity, float* tab)
{
int index = 2* (threadIdx.x + blockDim.x * blockIdx.x);
int leftElementID = index + parity;
int rightElementID = index + parity + 1;
float l, r;
if (rightElementID < length)
{
l = tab[ leftElementID ];
r ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.