serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
23,201 | #include <iostream>
using namespace std;
template<class T> void f(T x) {
cout << "generic : " << x << endl;
}
template<> void f(int x){
cout << "int : " << x << endl;
}
int main () {
f(1); f(2.3);
}
|
23,202 | #include "hmac_sha512.cuh"
__device__ void hmac_sha512_init(HmacSha512Context *ctx, const uint8_t password[], size_t password_len) {
uint8_t key[128];
if (password_len <= 128) {
memcpy(key, password, password_len);
memset(key + password_len, 0, 128 - password_len);
} else {
Sha512Context ctx_key{};
... |
23,203 | #include "includes.h"
__global__ void chol_kernel_cudaUFMG_zero(float * U, int elem_per_thr) {
// Get a thread identifier
int tx = blockIdx.x * blockDim.x + threadIdx.x;
int ty = blockIdx.y * blockDim.y + threadIdx.y;
int tn = ty * blockDim.x * gridDim.x + tx;
for(unsigned i=0;i<elem_per_thr;i++){
int iel = tn * elem... |
23,204 | #include "includes.h"
__device__ unsigned int getGid3d3d(){
int blockId = blockIdx.x + blockIdx.y * gridDim.x
+ gridDim.x * gridDim.y * blockIdx.z;
int threadId = blockId * (blockDim.x * blockDim.y * blockDim.z)
+ (threadIdx.y * blockDim.x)
+ (threadIdx.z * (blockDim.x * blockDim.y)) + threadIdx.x;
return threadId;
}
_... |
23,205 | #include "includes.h"
__global__ void sneladd(float * inA, float * inB, int *sub, int Nprj, int snno)
{
int idz = threadIdx.x + blockDim.x*blockIdx.x;
if (blockIdx.y<Nprj && idz<snno)
inA[snno*blockIdx.y + idz] += inB[snno*sub[blockIdx.y] + idz];//sub[blockIdx.y]
} |
23,206 | #include <stdio.h>
#include <stdlib.h>
__global__
void calc_meanshift2(float* y_new, float* y_old, float* meanshift)
{
int i = blockDim.x*blockIdx.x + threadIdx.x;
float tempY_new = y_new[i];
float tempY_old = y_old[i];
meanshift[i] = (tempY_new-tempY_old)*(tempY_new-tempY_old);
}
__device__
float kernel_fun(f... |
23,207 | #include <fstream>
#include <vector>
#include <string>
#include <sstream>
#include <iostream>
#include <cuda.h>
using namespace std;
__global__ void Dim2_Calculation(float * __restrict__ d_tem_res, float * __restrict__ d_tem_meo,
const float * __restrict__ d_tem_fix, const int width, const int height, const floa... |
23,208 | #include <stdio.h>
#include <cuda.h>
#include <time.h>
#include <math.h>
#define ISLAND 10
#define POPULATION 50
#define FACILITY 20
#define GENERATION 10
#define CROSSOVER 0.6
#define MUTATION 0.03
#define MIGRATION 15
#define INDIVIDUAL 5
#define H 15 // BAY height
#define W 10 // BAY width
void shuffle(int* faci... |
23,209 | #include <stdio.h>
#include <time.h>
#define ADIABATIC_GAMMA (5.0 / 3.0)
#define min2(a, b) (a) < (b) ? (a) : (b)
#define max2(a, b) (a) > (b) ? (a) : (b)
typedef double real;
__host__ __device__ void conserved_to_primitive(const real *cons, real *prim)
{
const real newton_iter_max = 50;
const real error_t... |
23,210 | #include <cuda_runtime.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#define CHECK(call) \
{ \
const cudaError_t error = call; \
if(error != cudaSucess) \
{ ... |
23,211 | //
// Created by root on 2020/11/23.
//
#include "stdio.h"
#include "cuda_runtime.h"
#define NSTREAM 4
#define n_repeat 32
__global__ void sumArrays(float *A, float *B, float *C, int n) {
int idx = blockDim.x * blockIdx.x + threadIdx.x;
if (idx < n) {
for (int i = 0; i < n_repeat; i++) {
... |
23,212 | #include "shared.cuh"
struct ParticleRef {
Point pos;
Point dir;
double nextdist;
};
inline __device__ ParticleRef make_ref(const ParticleView &view, int i) {
return {view.get_pos(i), view.get_dir(i), view.get_nextdist(i)};
}
__device__ inline void move_impl(const ParticleRef ref) {
const double x = *ref.p... |
23,213 | #include<stdio.h>
#include<stdlib.h>
#include<cuda_runtime.h>
__global__ void global_scan_kernel(float* d_out, float* d_in)
{
int idx = threadIdx.x;
d_out[idx] = d_in[idx];
float out = 0.00f;
for (int interpre = 1; interpre < sizeof(d_in); interpre *= 2)
{
if (idx - interpre >= 0){
... |
23,214 | #include <cuda.h>
#include <cuda_runtime_api.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <stdlib.h>
#define N 40
#define GAP -2
#define MATCH 1
#define MISMATCH -1
//#include "kernels.h"
using namespace std ;
__device__ volatile int g_mutex;
__dev... |
23,215 | #define _NTHREAD 512
#define _NBLOCK 65535
#include<cuda.h>
__global__ void _AFFINE_KERNEL(int* ,int ,int* ,int ,int ,int ,int ,int ,int );
#include<stdio.h>
#include<stdlib.h>
int main()
{
int block[20],quadrant[20],i,j,k;
for(i=0;i<20;i++)
{
block[i]=2*i;
quadrant[i]=3*i;
}
int _SZ_... |
23,216 | #include<iostream>
#include<time.h>
using namespace std;
__global__ void Matrix_Add(int* d_A, int* d_B, int* d_Sum)
{
int i = blockIdx.y;
int j = threadIdx.x;
int id = (i * blockDim.x) + j;
*(d_Sum + id) = *(d_A + id) + *(d_B + id);
}
int main()
{
const int Rows = 4;
const int Cols = 4;
co... |
23,217 | #include "includes.h"
__global__ void conv_horizontal_naive_output(const int n, float *y, const float *x, const float *w, const int iH, const int iW, const int kL)
{
for (int i = blockIdx.x*blockDim.x+threadIdx.x; i < n; i += blockDim.x*gridDim.x) {
int oW = iW - kL + 1;
int x_offset = (i/oW)*iW + i%oW;
int w_offset = ... |
23,218 | /*--------------------------------------------------------------------*/
/* CUDA special utility Library */
/* written by Viktor K. Decyk, UCLA */
#include <stdlib.h>
#include <stdio.h>
#include "cuda.h"
static cudaError_t crc;
/*--------------------------------------------------------------------*/
extern "C" void ... |
23,219 | #include "includes.h"
__global__ void __transpose(float *in, int instride, float *out, int outstride, int nrows, int ncols) {
int nx = BLOCKDIM * gridDim.x;
int ny = BLOCKDIM * gridDim.y;
int ix = BLOCKDIM * blockIdx.x;
int iy = BLOCKDIM * blockIdx.y;
__shared__ float tile[BLOCKDIM][BLOCKDIM+1];
for (int yb = iy; yb <... |
23,220 | // CUDA programming
// Exercise n. 06
#include <errno.h>
#include <cuda.h>
#include <stdio.h>
#define BLOCKS 4
#define THREADS 4
// Prototype
__global__ void saxpy(float a, float *x, float *y, float *z, int N);
__host__ void ints(float *m, int N);
__host__ void print_saxpy(float a, float *x, float *y, float *z, int... |
23,221 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
/*Kernel*/
__global__ void vectorAdd(float a[], float b[], float c[], int N) {
int index = blockDim.x * blockIdx.x + threadIdx.x;
if (blockIdx.x < N && threadIdx.x < N)
c[index] = a[index] + b[index];
}
void vecAdd(float* A, float* B, float* C, in... |
23,222 | extern "C" {
__global__ void kernel1(
float4* pos, unsigned int width, unsigned int height, float time)
{
unsigned int x = blockIdx.x*blockDim.x + threadIdx.x;
unsigned int y = blockIdx.y*blockDim.y + threadIdx.y;
// calculate uv coordinates
float u = x / (float) width;
float v = y / (float) height... |
23,223 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
__device__ int IP[64];
__device__ int FP[64];
__device__ int E[48];
__device__ int P[32];
__device__ int SBox[8][64];
// Initial Permutation
int host_IP[64] = {
57, 49, 41, 33, 25, 17, 9, 1,
59, 51, 43, 35, 27, 19, 11, 3,
61, 53, 45, 37, 29, 21,... |
23,224 | //Minimal CUDA program
__global__ void foo(int* r) {
if(threadIdx.x == 0) {
r[0] = blockIdx.x;
}
}
int main() {
int* r;
cudaMalloc(&r, sizeof(int));
foo<<<128, 128>>>(r);
}
|
23,225 | /********************************************************************
sequential.cu the sequential version of NN
Input:
/usr/local/cuda-10.1/bin/nvcc -arch=compute_52 -o sequential.out sequential.cu
./sequential.out block_size activationtype // block_size = 0; activationtype=1 means sigomid and 2 means ReLU
Ou... |
23,226 | #include "includes.h"
__global__ void pi_optimized(float* x, float* y, int* global_count) {
__shared__ int counts[nthreads];
//int globalId = blockIdx.x * blockDim.x + nitemsperthread * threadIdx.x;
int globalId = blockIdx.x * blockDim.x + threadIdx.x;
int thread_count=0;
for (int i=0; i<nitemsperthread; i++) {
int i... |
23,227 | //Determinante de una matriz
#include<iostream>
#include<time.h>
using namespace std;
__global__
void Det1_CU(int *M, int filas, int columnas, int &suma){
//int i = blockIdx.y*blockDim.y+threadIdx.y;//filas
int j = blockIdx.x*blockDim.x+threadIdx.x;//columnas
if(j < columnas){
int k = j, aux = columnas, l = 0,... |
23,228 | #include "includes.h"
__global__ void cuda_f32_to_int8_nomax(float* input_f32, size_t size, int8_t *output_int8, float multipler)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < size) output_int8[idx] = input_f32[idx] * multipler; // 7-bit (1-bit sign)
} |
23,229 | #include "includes.h"
cudaError_t addWithCuda(int *c, const int *a, const int *b, unsigned int size);
__global__ void shmem_scan(float* d_out, float* d_in) {
extern __shared__ float sdata[];
int idx = threadIdx.x;
float out = 0.00f;
sdata[idx] = d_in[idx];
__syncthreads();
for (int interpre = 1; interpre < size... |
23,230 | #include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <assert.h>
#include <cuda.h>
__global__ void TournamentKernel ( float* pVector, int stride )
{
unsigned index = 2 * ( blockIdx.x * blockDim.x + threadIdx.x) * stride ;
unsigned offset = threadIdx.x * stride;
float tmpfl... |
23,231 | #include <stdio.h>
#include <cuda.h>
#include <stdlib.h>
#define N 512
__global__ void add(int *a, int *b, int *c){
c[blockIdx.x] = a[blockIdx.x] + b[blockIdx.x]; // Use threadIdx.x for multiple threads
}
// Atribute random values to elements of a[n]
void random_ints(int *a, int n){
for(int i = 0; i < n; +... |
23,232 | #include<cuda_runtime.h>
#include<stdio.h>
__global__ void addSleep(int *v, int *r){
float v1 =(float) *v;
int ret =0;
while(ret <v1){
ret = ret+1;
}
*r=ret;
}
void sleep(int v){
int * d_v, *d_r;
cudaMalloc(&d_v, sizeof(int));
cudaMalloc(&d_r, sizeof(int));
cudaMemcpy(d_v, &v, sizeof(int), cudaM... |
23,233 | /*
* Tiled Matrix Multiplication
* (MP2, Fall 2014, GPU Programming/Auburn University)
*
* Compile with -DTILE_WIDTH=16 (for example) to change the tile size.
* Compile with -DSEED=12 (for example) to seed the random number generator.
*/
#include <assert.h>
#include <cuda.... |
23,234 | #include <iostream>
using namespace std;
//Test
// Device code: Computes Z = aX + Y
__global__
void daxpy(double a, const double* X, const double* Y,
int arraySize, double* Z)
{
int i = blockDim.x * blockIdx.x + threadIdx.x;
if (i < arraySize)
Z[i] = a * X[i] + Y[i];
}
// Host code
void doTheKernelLaunch(doubl... |
23,235 | __global__ void selection_k_radius_gpu(int b, int m, int k, float radius, const int* idx, const float* val, int* idx_out, float* val_out){
int batch_index = blockIdx.x;
int stride = batch_index * m * k;
idx += stride;
val += stride;
idx_out += stride;
val_out += stride;
for(int i = threadIdx... |
23,236 | #include <stdio.h>
#include <sys/time.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <cuda_runtime_api.h>
#include <driver_types.h>
#define M 32
__global__
void Calcu(float **od, float **ev, size_t oddpitch, size_t evenpitch)
{
//pitchの使い道がわからん。詰んだ。
int i=blockIdx.x * blockDim.x + threadIdx.x;
int j=bl... |
23,237 | #include <thrust/device_vector.h>
#include <thrust/tabulate.h>
#include <iostream>
struct Fragment
{
int index[3];
Fragment() = default;
};
struct functor
{
__device__ __host__
Fragment operator() (const int &i) const {
Fragment f;
f.index[0] = i; f.index[1] = i+1; f.index[2] = i+2;
... |
23,238 | #include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
// CUDA runtime
#include <cuda_runtime.h>
#define SIZE 100000000
#define THREADS_PER_BLOCK 1024
// Convert and mod
__global__ void add_kernel(uint32_t *d_c, uint32_t *d_a, uint32_t *d_b) {
// compute index = thread index in a block + block index * num... |
23,239 | #include "includes.h"
__global__ void MNKernel(int count, long * Md, long *Nd, long *Pd, int width) {
// 2D thread ID
int col = blockIdx.x*blockDim.x + threadIdx.x;
int row = blockIdx.y*blockDim.y + threadIdx.y;
// Pvalue stores the Pd element that is computed by the thread
long Pvalue = 0;
for (int k=0; k < width; k++... |
23,240 |
/*
Based off work by Nelson, et al.
Brigham Young University (2010)
Adapted by Kevin Yuh (2015)
*/
#include <stdio.h>
#include <cuda.h>
#include <assert.h>
#include <cuda_runtime.h>
#include <stdio.h>
#include <cufft.h>
#define PI 3.14159265358979
/* Check errors on CUDA runtime functions */
#define gpuErrchk(a... |
23,241 | // 20181010
// Yuqiong Li
// Matrix multiplication with CUDA
#include <stdlib.h>
#include <cuda.h>
#include <time.h>
#include <stdio.h>
#define index(i, j, n) ((i) * (n) + (j))
// declare global kernel function
__global__ void matrixMulKernel(float * a, float * b, float * c, unsigned int m, unsigned int n, unsigned ... |
23,242 | #include "thrust/device_vector.h"
#include "thrust/host_vector.h"
#include "thrust/tuple.h"
#include "thrust/complex.h"
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
using namespace std;
typedef thrust::complex<float> th_complex;
typedef thrust::device_vector<th_complex> th_dev_cplx_vec;
... |
23,243 | //#include "CDebug.cuh"
//#include "CMatrixFunctions.cuh"
//#include "CAABBFunctions.cuh"
//#include "CVoxelFunctions.cuh"
//#include "CSVOTypes.h"
//#include "CSVOFunctions.cuh"
//#include <cassert>
//#include <limits>
//#include <cstdio>
//#include "COpenglTypes.h"
//
//__global__ void DebugCheckNodeId(const CSVONode... |
23,244 | #include <stdio.h>
#define NUM_BLOCKS 1
#define BLOCK_WIDTH 256
__global__ void hello()
{
printf("Hello world! I'm thread %d\n", threadIdx.x );
}
int main(int argc, char **argv)
{
hello<<<NUM_BLOCKS, BLOCK_WIDTH>>>();
cudaDeviceSynchronize();
printf("That is all!\n");
return 0;
} |
23,245 | #pragma once
typedef float c_precision;
#define thread_group_size 64
#define max_nominal 20
// Constant buffer strucs
struct SharedBuffer{
unsigned int cb_numTrees;
unsigned int cb_numFeatures;
unsigned int cb_maxDepth;
unsigned int cb_currentDepth;
unsigned int cb_availableNodes;
unsigned int cb_nodeBufferStart... |
23,246 | #include "includes.h"
//!!nvcc -c test.cu --compiler-options -fPIC
//!g++ -o program -L/usr/local/cuda/lib64 main.cpp test.o -lcuda -lcudart
__global__ void exp(float *a,float *c)
{
*c = expf(*a);
} |
23,247 | /*
* CUDA blur
* Kevin Yuh, 2014
* Revised by Nailen Matschke, 2016
*/
#include <cstdio>
#include <cuda_runtime.h>
#include "blur_device.cuh"
__global__
void cudaBlurKernel(const float *raw_data, const float *blur_v, float *out_data,
int n_frames, int blur_v_size) {
/* GPU-accelerated convolution. */
... |
23,248 | #include <cuda.h>
#define DIVERGENCE_HERE \
if(arr[id] %2 == 0) \
arr[id] = arr[id-1]; \
else \
arr[id] = arr[id+1];
__global__ void kernel_one(int *arr, int N) {
int id = threadIdx.x + blockDim.x * blockIdx.x;
if (id >= N);
DIVERGENCE_HERE;
}
__device__ void aux(int *arr, int id, int N) {
DIVE... |
23,249 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <math.h>
#include <string.h>
int size_n;
unsigned int SEED;
#define CUDA_ERROR_EXIT(str) do{\
cudaError err = cudaGetLastError();\
if( err != cudaSuccess){\
... |
23,250 | #include <fstream>
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/generate.h>
#include <thrust/sort.h>
#include <thrust/copy.h>
#include <thrust/binary_search.h>
#include <thrust/pair.h>
#define IGNORE_FIRS... |
23,251 | #include <cstdio>
#define N 100000
#define blocksPerGrid 256
#define threadsPerBlock 128
__global__ void dot(float* a, float* b, float* partial_c)
{
__shared__ float cache[threadsPerBlock];
int tid = threadIdx.x + blockIdx.x*blockDim.x;
float temp = 0;
while (tid < N)
{
temp += (a[tid] + ... |
23,252 | //imports
#include <iostream>
#include <math.h>
#include <cstdlib>
#include <ctime>
#include <curand.h>
#include <curand_kernel.h>
#include <stdio.h>
#include <math.h>
#include <cuda.h>
//constants for dimensions of matrices
#define A_HEIGHT 8192
#define A_WIDTH 8192
#define THREADSIZEX 32
#define THREADSIZEY 32
#defi... |
23,253 | // compute.cu
//
// driver and kernel call
#include <stdio.h>
#define THREADS_PER_BLOCK 512
__global__ void compute_d (int *a_d, int *b_d, int *c_d, int n)
{
int x = blockIdx.x * blockDim.x + threadIdx.x;
if (x < n) {
a_d[x] = x % 10 + 1;
if (x < (n / 2))
{
b_d[x] = x + 1;
... |
23,254 | #include<stdio.h>
#include<cuda.h>
#include<cuda_runtime.h>
#define SIZE 10
__global__ void min(int *input){
int tid = threadIdx.x;
int step_size=1;
int numberofthreads = blockDim.x;
while(numberofthreads>0){
if(tid<numberofthreads){
int first = tid*step_size*2;
int second = first+step_size;
if(input[s... |
23,255 | #include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <chrono>
#include <type_traits>
#include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <thrust/device_ptr.h>
class GpuTimer
{
cudaEvent_t start;
cudaEvent_t stop;
public:
GpuTimer()
... |
23,256 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include <unistd.h>
#include <cuda.h>
#define RANDOM(x) (rand() % x)
#define MAX 100000
#define BLOCKSIZE 16
__global__ void multiply(const int *a, const int *b, int *c, int n) {
int row = blockIdx.x * blockDim.x + threadIdx.x;
i... |
23,257 | #include <stdio.h>
#include <math.h>
#include <stdlib.h>
__host__ __device__ double2 d2add(double2 a, double2 b) {
/*
* Arguments: two 2d vectors
* Returns: the vector addition of the two vectors
*/
double2 ret;
ret.x=a.x+b.x;
ret.y=a.y+b.y;
return ret;
}
__host__ __device__ double2 d2sub(double2 a, double... |
23,258 | #include <stdio.h>
#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true)
{
if (code != cudaSuccess)
{
fprintf(stderr,"GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line);
if (abort) exit(code);... |
23,259 | /*=========================================================================
*
* Copyright Insight Software Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* h... |
23,260 | //15co154 Yeshwanth R
//15co118 Goutham M
#include<stdio.h>
#include<stdlib.h>
#include<cuda.h>
__global__ void func(float *da_in,float *db_in,float *d_out)
{
int idx = blockIdx.x*100 + threadIdx.x;
d_out[idx] = da_in[idx] + db_in[idx];
}
int main()
{
float t1,t2;
const int array_size = 16000;
const int ar... |
23,261 | // HEADERS
#include <iostream>
#include <iomanip>
#include <limits>
#include <stdlib.h>
#include <fstream>
#include <math.h>
#include <time.h>
using namespace std;
// DEFINITIONS
#define NX 201
#define NY 201
#define NT 401
#define NS 640
__constant__ float hx = 0.001f;
__constant__ float hy = 0.001f;
__cons... |
23,262 | #include <cufft.h>
#include <iostream>
#include <complex>
// #define DATA_LEN 1024
// #define ITERATION 100000
int main(int argc, char **argv)
{
if (argc != 3)
{
std::cout << "Usage: " << argv[0] << " [DATA_LEN] [ITERATION]" << std::endl;
return 1;
}
int DATA_LEN = atoi(argv[1]);
int ITERATION = atoi(argv[2... |
23,263 | #include<stdio.h>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <cstdlib>
const long int INF = 99999999;
const int N = 4;
__global__ void ComputeMinPath(int *d_Matrix) {
int row = blockIdx.x;
int col = threadIdx.x;
for (int j = 0; j < N; j++) {
d_Matrix[row * N + col] = d_Matrix[row ... |
23,264 | /*
Demo for the following:
cudaError_t
cudaGetErrorString
*/
#include <stdio.h>
#include <cuda_runtime.h>
__global__ void helloFromGPU(void){
printf("Hello from GPU! %d\n", threadIdx.x);
}
int main(void){
printf("Hello from CPU!\n");
helloFromGPU <<< 1,10 >>>();
// error handling
cudaError_t res; // enum... |
23,265 | #include <stdio.h>
#include <stdlib.h>
__global__ void devicePrint(){
// Print from GPU.
printf("Hello from device! Thread %d,%d\n", threadIdx.x, blockIdx.x);
}
int main(int argc, char** argv){
printf("Hello from host!\n");
devicePrint<<<1, 1>>>();
cudaDeviceSynchronize();
return 0;
}
|
23,266 | #include "includes.h"
__global__ void fast_mean_kernel(float *x, int batch, int filters, int spatial, float *mean)
{
const int threads = BLOCK;
__shared__ float local[threads];
int id = threadIdx.x;
local[id] = 0;
int filter = blockIdx.x;
int i, j;
for(j = 0; j < batch; ++j){
for(i = 0; i < spatial; i += threads){
... |
23,267 |
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#define BLOCK_SIZE 16
/*
*********************************************************************
function name: inicializarMatrizRandom
descripcion: inicializa aleatoriamente los elementos de una matriz
parametros:
- M: puntero a la matriz a inicializar
- ... |
23,268 | #include "includes.h"
__global__ void histogram_privatized_kernel(unsigned char *input, unsigned int *bins, unsigned int num_elements, unsigned int num_bins) {
const int bx = blockIdx.x;
const int bdx = blockDim.x;
const int tx = threadIdx.x;
const int gdx = gridDim.x;
unsigned int tid = bx * bdx + tx;
extern __shared... |
23,269 | #include <cuda_runtime.h>
#include<iostream>
using namespace std;
#include <device_launch_parameters.h>
#define N (1024 * 1024)
__global__ void add(int *a, int *b, int *c)
{
//blockDim is num threads/block, multiplied by block number to index to one of them, then select thread inside block via thread Id
int threadID... |
23,270 | #include <stdio.h>
__global__ void vec_add(int *a, int *b, int *c) {
int tid = threadIdx.x;
c[tid] = a[tid] + b[tid];
}
int main() {
int n = 8;
int *a_h, *b_h, *c_h;
a_h = (int *) malloc(sizeof(int)*n);
b_h = (int *) malloc(sizeof(int)*n);
c_h = (int *) malloc(sizeof(int)*n);
for (in... |
23,271 | #include<stdlib.h>
#include<stdio.h>
#include<time.h>
using namespace std;
__global__ void mul(int *d_in1,int *d_in2,int *d_out){
int idx = threadIdx.x;
d_out[idx] = d_in1[idx]*d_in2[idx];
}
__global__ void reduce_section(int *d_in,int &d_out,const int start,const int end){
int idx = threadIdx.x;
extern __shared__ ... |
23,272 | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
//#include<cublas.h>
//#include<R.h>
#define NTHREADS 512
//computes u = constant * t(X) %*% v
__device__ void cXtv(float con, int rows, int cols, float * X, int ldX, float * v,
float * u){
int i,k;
float sum;
for(k = 0; k < cols; k++){
sum =... |
23,273 | #include "includes.h"
using namespace std;
// function generate random numbers and assign it to array
__global__ void add(int *a, int *b, int *c) {
int index = threadIdx.x + blockIdx.x * blockDim.x;
c[index] = a[index] + b[index];
} |
23,274 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <cuda_runtime_api.h>
#define N 2
__global__ void foo()
{
__shared__ int A[8];
A[0] = threadIdx.x;
}
int main(){
foo<<<1, N>>>();
//ESBMC_verify_kernel(foo,1, N);
cudaThreadSynchronize();
return 0;
}
|
23,275 | #include "includes.h"
__global__ void vel_step( float4 *__restrict__ deviceVel, float3 *__restrict__ accels, unsigned int numBodies, float dt)
{
int index = blockIdx.x * blockDim.x + threadIdx.x;
if (index > numBodies) {return;};
deviceVel[index].x += accels[index].x * 0.5 * dt;
deviceVel[index].y += accels[index].y * ... |
23,276 | /*written by Cheng Chen
parallel computing second project part 1 12/4/2016*/
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <ctime>
#include "kernels.cuh"
using namespace std;
int randNum() {
double ran = (double)rand();
return ran;
}
// double timeTransfer(struct timeval start, struct time... |
23,277 |
extern __device__ int file1_func(int);
int __device__ file3_func(int x)
{
if (x > 0)
return file1_func(-x);
return x;
}
|
23,278 | #include <stdio.h>
#include <cuda.h>
#include <sys/time.h>
#define K 32
#define N 32
__global__ void fun(int *a) {
int i;
unsigned nthreads = blockDim.x * gridDim.x;
unsigned id = blockIdx.x * blockDim.x + threadIdx.x;
unsigned start = N / nthreads * id;
for (i = 0; i < N/K; ++i)
a[start + i] = threadIdx.x * thr... |
23,279 | #include <stdio.h>
//constant for architecture
int SEED = 12; //seed for rand //old was 15
int DIM_LIM = 300; //max size of a matrix
double INIT_VAL = 0.1; //initial value of matrix
int MAT_COUNT = 10000; //
/* file format
ndicate the size of array A)
n_1 n_2 n_3... n_k (k numbers in a single line indicate the dim... |
23,280 | /*
* 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 related... |
23,281 | #include <stdio.h>
__global__ void emptyKernel()
{
printf("empty kernel call\n");
}
int main()
{
dim3 threadsPerBlock(1);
dim3 blocksPerGrid(1);
emptyKernel<<<blocksPerGrid, threadsPerBlock>>>();
cudaThreadSynchronize();
return 0;
}
|
23,282 | // ***********************************************************************
//
// Demo program for education in subject
// Computer Architectures and Paralel Systems
// Petr Olivka, dep. of Computer Science, FEI, VSB-TU Ostrava
// email:petr.olivka@vsb.cz
//
// Example of CUDA Technology Usage
// Multiplication of eleme... |
23,283 | /*
* 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 related... |
23,284 | #include <cuda_runtime_api.h>
#include <stddef.h>
__global__ void image2d_crop(
const float *in_pixels,
int in_width,
int in_height,
int channels,
int x_offset,
int y_offset,
float *out_pixels,
int crop_width,
int crop_height)
{
int idx = threadIdx.x + blockIdx.x * blockDim.x;
i... |
23,285 | #include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <cuda.h>
#define a 3
#define b 5
#define c 4
void llenarMatriz(double *w, int li, int lj){
double count = 0;
for(int i=0; i<li; i++){
for(int j=0; j<lj; j++){
w[i*lj+j] = count;
count++;
}
}
}
void print(double *w, int li, in... |
23,286 | /*
** Originally copied from
** https://github.com/CodedK/CUDA-by-Example-source-code-for-the-book-s-examples-/blob/master/chapter06/ray_noconst.cu
** With a few bugs fixed
*/
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <fstream>
#include <iostream>
using namespace std;
#define INF 2e10f
#... |
23,287 | #include <cuda_runtime.h>
static __device__ float E = 2.718281828;
__global__ void sliceTensorKernel(float *src, float *dst, int sdim, int ddim, int start, int block_size)
{
int di = blockIdx.x * block_size + threadIdx.x;
int si = (blockIdx.x / ddim * sdim + blockIdx.x % ddim + start) * block_size + threadI... |
23,288 | #include <iostream>
#include <cuda.h>
#include <cmath>
#include <ctime>
// #include "common/book.h"
#define mycout cout<<"["<<__FILE__<<":"<<__LINE__<<"] "
/* 全局线程id get thread id: 1D block and 2D grid <<<(32,32),32>>>*/
#define get_tid() (blockDim.x * (blockIdx.x + blockIdx.y * gridDim.x) + threadIdx.x) // 2D grid... |
23,289 | #include <iostream>
#include <math.h>
#include<stdio.h>
#include <algorithm>
#define BLOCK_SIZE 16
//int const Nx = 30, Nz = 20;
__global__
void laplacian_GPU (int ordem, int Nz, int Nx,int dz, int dx, float *P, float *Lapla)
{
int col = blockIdx.x * blockDim.x + threadIdx.x;
int colStride = blockDim.x * grid... |
23,290 | #include <iostream>
#include <math.h>
#include <algorithm>
#include <stdio.h>
#include<float.h>
#define THREADS_PER_BLOCK 1024 //max of the threads in one block is 1024
// Kernel function to add the elements of two arrays
__global__
void iteration(double *d_A,double *d_B,int n)
{
int i=blockIdx.x*bloc... |
23,291 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#define N (33 * 1024)
__global__ void add(int *a, int *b, int * c)
{
//threadIdx.x:当前线程的Index. blockIdx:当前线程块的index. blockDim.x:每个线程块中线程的数量.
int tid = threadIdx.x + blockIdx.x * blockDim.x;
while(tid < N)
{
c[tid] = a[tid] + b[ti... |
23,292 | #include "includes.h"
__global__ void updateGradInputLSM(const float* target, const float* mapping, const float* n_class_in_cluster, float* class_score, float* class_logsum, float* cluster_score, float* cluster_logsum, const long class_score_stride0, const long cluster_score_stride0, int n_clusters) {
const int tidx = ... |
23,293 | // compute.cu
//
// driver and kernel call
#include <stdio.h>
#define THREADS_PER_BLOCK 128
// __global__ void compute_2d (int secondArrSize, float *arr[])
__global__ void compute_2d ( int firstArrSize, int secondArrSize, float **arr)
{
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blo... |
23,294 | #include <iostream>
#include <string>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
using namespace std;
void print_matrix(float* matrix, int rows, int cols) {
for (int i = 0; i < rows; ++i) {
for (int j = 0; j < cols; ++j)
cout<<matrix[i*cols+j]<<" ";
cout<<endl;
}
}
v... |
23,295 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
__global__ void add3(float *val1, float *val2, int *num_elem)
{
int i = threadIdx.x;
val1[i] += val2[i];
}
__global__ void sub3(float *val1, float *val2, int *num_elem)
{
int i = threadIdx.x;
val1[i] += val2[i]+1;
}
int main()... |
23,296 |
/* This is a automatically generated test. Do not modify */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
__global__
void compute(float comp, float var_1,float var_2,int 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 ... |
23,297 | #include <thrust/device_vector.h>
#include <thrust/iterator/counting_iterator.h>
#include <iostream>
struct raw_access {
double *ptr;
raw_access (double *ptr) : ptr(ptr) {};
__device__ __host__
double operator()(const int &i) {
return ptr[i] + 1;
}
};
int main() {
thrust::device_... |
23,298 | #include <iostream>
#include <chrono>
//Host Code
__global__ void polynomial_expansion (float* poly, int degree, int n, float* array) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
if( index < n ){
float polynomial = 0.0;
float power = 1.0;
for ( int i = 0; i < degree+1; ++i)... |
23,299 | #include "includes.h"
__global__ void update2(float *alphaMinusBeta_out, const float *rho, const float *yDotZ, const float *alpha)
{
const float beta = *rho * *yDotZ;
*alphaMinusBeta_out = *alpha - beta;
} |
23,300 | //3x3 mask
__constant__
double mask0[3][3] = { {0.1036,0.1464,0.1036},
{0.1464,0,0.1464},
{0.1036,0.1464,0.1036}};
//horizontal 5x5 mask
__constant__
double mask1[5][5] = { {0,0,0,0,0},
{0.0465,0.0735,0.1040,0.0735,0.0465},
{0.0520,0.1040,0,0.1040,0.0520},
{0.0465,0.0735,0.1040,0... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.