serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
19,301 | #include "cuda_runtime.h"
__global__ void func1(int* a)
{
int idx = threadIdx.x;
int v;
if (idx>32)
v = idx;
else
v = 32;
a[idx] = v;
}
__global__ void func2(int* a)
{
int idx = threadIdx.x;
int v = a[idx]*2;
if (idx>32)
v += 1;
a[idx] = v;
}
__gl... |
19,302 | /* LA-CC-16080
Copyright © 2016 Priscilla Kelly and Los Alamos National Laboratory. All Rights Reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above c... |
19,303 | #include "includes.h"
__global__ void kGenerateTranslationsBigVarOff(float* source, float* target, float* off_x_arr, float* off_y_arr, int source_w, int target_w, int num_channels) {
const unsigned int idx = threadIdx.x;
const unsigned int numThreads = blockDim.x;
int target_x, target_y;
int pad = (source_w - target_w... |
19,304 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#define arraySize 5
#define threadPerBlock 5
__global__ void addKernel(int *d_a, int *d_b)
{
int count = 0;
int tid = threadIdx.x;
int ttid = blockIdx.x * threadPerBlock + tid;
int val = d_a[ttid];
__shared__ int cache[threadPerBl... |
19,305 | #include <chrono>
#include <iostream>
#include <iomanip>
enum { N = 500000, NSTEP = 1000, NKERNEL = 20 };
__global__ void shortKernel(float * out_d, float * in_d){
int idx=blockIdx.x*blockDim.x+threadIdx.x;
if(idx<N) out_d[idx]=1.23*in_d[idx];
}
int main()
{
cudaStream_t stream;
auto blocks = 512;
auto th... |
19,306 | #include<ctime>
#include<iostream>
using namespace std;
#define BLOCK_SIZE 32
__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 + ... |
19,307 | #include "includes.h"
// Lets you use the Cuda FFT library
cudaError_t mathWithCuda(float *output, float *input1, float *input2, unsigned int size, int oper);
// Using __global__ to declare function as device code (GPU)
// Do the math inside here:
// Helper function for using CUDA to add vectors in parallel.
__gl... |
19,308 | #include <iostream>
#include <cuda_runtime.h>
__global__ void GPUAdd( int *a, int *b, int *c, int no_elements)
{
c[threadIdx.x] = a[threadIdx.x] + b[threadIdx.x];
}
int main()
{
int no_elements =32;
int a_host[no_elements];
int b_host[no_elements];
int c_host[no_elements];
for(int i =... |
19,309 | #include <iostream>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <stdlib.h>
#include <locale>
#include <string>
#include <limits>
#include <time.h>
#include <stdio.h>
#include <iomanip>
#include <sys/time.h>
using namespace std;
//------------ Kernel de Processamento
__global__ void Classif(int*... |
19,310 | #include "includes.h"
/*
* Read TODO items below
*/
__global__
__global__ void cacheMatmul(float *a, float *b, float *c, int n)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
int j = blockIdx.y * blockDim.y + threadIdx.y;
float acc = 0;
for(int k1=0;k1<n;k1+=gridDim.x)
{
acc=c[i*n+j];
for(int k=k1;k<k1+gridDim... |
19,311 | #include <stdio.h>
#define CudaSafeCall( err ) __cudaSafeCall( err, __FILE__, __LINE__ )
inline void __cudaSafeCall( cudaError_t err, const char *file, const int line )
{
if ( cudaSuccess != err )
{
fprintf( stderr, "cudaSafeCall() failed at %s:%i : %s\n",
file, line, cudaGetErrorString... |
19,312 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include<cuda.h>
#include<string.h>
#include<ctime>
#define BLOCK_NUM 4 // 块数量
#define THREAD_NUM 2 // 每个块中的线程数
#define R_SIZE (BLOCK_NUM * THREAD_NUM) // 矩阵行列数
#define M_SIZE (R_SIZE * R_SIZE) //矩阵规模
__global__ void mat_mul(int* m... |
19,313 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
// Computes the matrix product using line matrices:
void matMul(float* P, float* M, float* N, unsigned int Width) {
for (unsigned int i = 0; i < Width; ++i) {
for (unsigned int j = 0; j < Width; ++j) {
P[i * Width + j] = 0.0;
for (unsigned... |
19,314 | /*GPUvectorSum.cu*/
#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(void) {
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*size... |
19,315 | #include <stdio.h>
#include <cuda.h>
void checkCudaError(cudaError_t errorCode)
{
if (errorCode != cudaSuccess)
fprintf(stderr, "Error %d\n", errorCode);
}
int main(void)
{
float *ha, *hb; // host data
float *da, *db; // device data
int N = 10, nbytes, i;
nbytes = N * sizeof(float... |
19,316 | #include <stdio.h>
#include <stdlib.h>
#define N 100000
#define THREAD_PER_BLOCK 1
/**
* This macro checks return value of the CUDA runtime call and exits
* the application if the call failed.
*/
#define CUDA_CHECK_RETURN(value) { \
cudaError_t _m_cudaStat = value; \
if (_m_cudaStat != cudaSuc... |
19,317 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <iostream>
#include <time.h>
#include <random>
using namespace std;
__global__ void massSearchKernel(char* buf, char* rows, bool* result, int bufLength, int rowsCount, int rowsLength)
{
int i = blockIdx.x * blockDim.x +... |
19,318 | #include <stdio.h>
// ---------------------------------------------------------------
// General CUDA GPU utility functions that are executed on the host
// ---------------------------------------------------------------
// Routine that Selects between multiple GPU devices
// if GPU device number invalid return -1
in... |
19,319 | #include <stdio.h>
/**
* KERNEL cuAdd() - Takes 2 input arrays of same size N and adds them into C.
* Locations are found by computing the global index of each thread.
* @return
*/
__global__ void cuAdd(int *a,int *b,int *c, int N)
{
// global index
int offset = blockDim.x * blockIdx.x + threadIdx.x;
if(... |
19,320 | #include "includes.h"
__device__ void swap(int &a, int &b){
int t = a;
a = b;
b = t;
}
__global__ void littleBinoticSort(int* arr,int num, int numMax){
unsigned int tid = blockIdx.x * blockDim.x + threadIdx.x;
if(tid >= num) arr[tid] = INT_MAX;
__syncthreads();
for(unsigned int i=2; i<=numMax; i<<=1){
for(unsigned i... |
19,321 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cuda.h>
#include <cuda_runtime.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, cudaGetErrorString(error)); exit(1); }}
__glob... |
19,322 | #include <stdio.h>
// COde to prove float addition is not associative.
int main(int argc,char **argv)
{
printf("(%g + %g) + %g == %g\n%g + (%g + %g) == %g\n",
1.f, 1e99, -1e99, (1.f + 1e99)+ -1e99,
1.f, 1e99, -1e99, 1.f + (1e99 + -1e99));
return 0;
}
|
19,323 | #include <iostream>
#include <cuda.h>
using namespace std;
__global__ void AddInstsCUDA(int *a, int *b)
{
a[0] += b[0];
}
int main()
{
int a =5, b = 9;
int *d_a, *d_b;
cudaMalloc(&d_a, sizeof(int));
cudaMalloc(&d_b, sizeof(int));
cudaMemcpy(d_a, &a, sizeof(int), cudaMemcpyHostToDevice);
... |
19,324 | #include <thrust/device_vector.h>
#include <thrust/copy.h>
#include <list>
#include <vector>
int main(int argc, char *argv[]) {
// create an STL list with 4 values
std::list<int> stl_list;
stl_list.push_back(10);
stl_list.push_back(20);
stl_list.push_back(30);
stl_list.push_back(40);
// initialize a device_v... |
19,325 | #include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include <time.h>
#include<cuda.h>
//kernel
__global__
void vecAddKernel(float *A, float *B, float *C, unsigned int N){
unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x;
if(idx < N){
C[idx] = A[idx] + B[idx];
}
}
int main(){
unsigned int N = 1000... |
19,326 | #ifndef STACK_H
#define STACK_H
#include <cstring>
#include <cuda.h>
#define MAXSTACKSIZE 10
template<class T>
class Stack{
public:
int top;
T ptrToArray[MAXSTACKSIZE];
};
template<class T>
__host__ __device__ void StackInit(Stack<T>* s){
s->top = -1;
}
template<class T>
__host__ __device__ void Stac... |
19,327 |
//Multiplicacion de matriz usando un kernal compartido y usando uno no compartido
#include <stdio.h>
#include <math.h>
#define TILE_WIDTH 2
/*multiplicacion de kernels de matriz*/
//no compartido
__global__ void
MatrixMul( float *Md , float *Nd , float *Pd , const int WIDTH )
{
// calculate thread id
... |
19,328 | #include "includes.h"
__global__ void calcRouteBackwardGPU( float *dz_in, float *dz, int in_size_x, int in_size_y, int in_size_z, int z_offset, int elements )
{
int id = (blockIdx.x + blockIdx.y*gridDim.x) * blockDim.x + threadIdx.x;
if( id < elements ){
int id_out = id;
int x = id % in_size_x;
id /= in_size_x;
int y ... |
19,329 | #include <stdio.h>
#include <iostream>
#include <math.h>
// Kernel function to add the elements of two arrays
__global__
void add(int n, float *x, float *y)
{
int index = threadIdx.x;
int stride = blockDim.x;
for (int i = index; i < n; i += stride)
y[i] = x[i] + y[i];
}
typedef struct {
float x, y, z;
} Vec3;... |
19,330 | // #include "cu_hash_table.h"
// namespace mxnet {
// namespace op {
// namespace permutohedral {
// template<int key_size>
// CuHashTable<key_size>::CuHashTable(int32_t n_keys, int32_t *entries, int16_t *keys)
// : n_keys_(n_keys), entries_(entries), keys_(keys) {
// }
// template<int key_size>
// MSHADOW_FORCE_I... |
19,331 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;
int main(int argc, const char* argv[])
{
ifstream datafile;
datafile.open("data.csv");
string fileline;
int count = 0;
int imagenum... |
19,332 | #include <stdio.h>
#include <stdlib.h>
__global__ void mul1(int *A, int *B, int *C, int n, int q){
int id = threadIdx.x, i,j;
for(i=0;i<q;i++){
C[id*q+i] = 0;
for(j=0;j<n;j++)
C[id*q+i] += A[id*n+j] * B[j*q+i];
}
}
__global__ void mul2(int *A, int *B, int *C, int m, int q){
int id = threadIdx.x, i, j, n = ... |
19,333 | __global__ void sharedMemoryDemo3( )
{
extern __shared__ char shared_data[];
double* data1 = (double*)shared_data;
float* data2 = (float*)&data1[128];
int* data3 = (int*)&data2[64];
// initialization
int id = threadIdx.x;
if (id < 128) {
data1[id] = 0.0f;
}
if (id < 64) {
data2[id] = 0... |
19,334 | // edgebased one thread represent a edge
__global__ void edge(int* src, int* des, int* w, int *n, int* m, int* dist){
const int e0 = threadIdx.z * blockDim.x * blockDim.y + threadIdx.y * blockDim.x + threadIdx.x;
const int offset = blockDim.x * blockDim.y * blockDim.z;
const int blockNum = (const int) gridDim... |
19,335 | #include "includes.h"
__global__ void compute_iteration(char* buffer, char* out_buffer, size_t pitch, size_t pitch_out, int width, int height)
{
const int x = blockDim.x * blockIdx.x + threadIdx.x;
const int y = blockDim.y * blockIdx.y + threadIdx.y;
if (x >= width || y >= height)
return;
int left_x = (x - 1 + width) ... |
19,336 | //xfail:BOOGIE_ERROR
//--gridDim=1 --blockDim=4 --no-inline
//attempt to modify constant memory
#include <stdio.h>
#include <cuda.h>
#define N 2//4
__constant__ int global_constant[N]; //= {0, 1, 2, 3};
__global__ void foo(int *in) {
global_constant[threadIdx.x] = in[threadIdx.x];
__syncthreads();
in[threadI... |
19,337 | #include <stdio.h>
#include <stdlib.h>
#include <curand.h>
#include <curand_kernel.h>
#include <cuda_runtime.h>
#include <time.h>
#include <math.h>
#include <stdbool.h>
// cuda macro for ensuring cuda errors are logged
#define __cuda__(ans) { cudaAssert((ans), __FILE__, __LINE__); }
inline void cudaAssert(cudaError_t... |
19,338 | #include <stdio.h>
__global__ void index_checker(int *gpu)
{
int index = blockIdx.x*blockDim.x+threadIdx.x;
int value = blockIdx.x*10+threadIdx.x;
gpu[index]=value;
printf("%d, %d, blockIdx=%d, blockDim=%d, threadIdx=%d\n", index, value, blockIdx.x, blockDim.x, threadIdx.x);
return;
}
int main(int ... |
19,339 | #include<cuda_runtime.h>
#include<stdio.h>
int main()
{
int dev_count = 0;
cudaError_t error_id = cudaGetDeviceCount(&dev_count);
if(error_id != cudaSuccess)
{
printf("cudaGetDeviceCount returned %d\n->%s\n", int(error_id), cudaGetErrorString(error_id));
printf("Result = FAIL\n");
... |
19,340 | //**********************************************************************
// *
// University Of North Carolina Charlotte *
// *
//Program: Convolution ... |
19,341 | #include <iostream>
#include <random>
#include <sstream>
#include <cassert>
#include <fstream>
#include <cfloat>
#include <cstdlib>
#include <iostream>
#include <string>
#include <ctime>
#include <queue>
#include <pthread.h>
#include <png.h>
#include "tbb/concurrent_queue.h"
#include <chrono>
#include <cuda.h>
#includ... |
19,342 | #include <cuda_runtime.h>
#include <stdio.h>
__device__ float reference(float x)
{
double y = x;
return y * tanh(log1p(exp(y)));
}
__global__ void test()
{
for (float x = -100; x < 100; x += 0.1)
{
// double precision reference
float ref = reference(x);
float e = __expf(x);
... |
19,343 | // Source: http://web.mit.edu/pocky/www/cudaworkshop/MonteCarlo/PiMyRandom.cu
// Written by Barry Wilkinson, UNC-Charlotte. PiMyRandom.cu December 22, 2010.
//Derived somewhat from code developed by Patrick Rogers, UNC-C
#include <stdlib.h>
#include <stdio.h>
#include <cuda.h>
#include <math.h>
#include <time.h>
#d... |
19,344 | /***************************************************
* Module for matrix multiplication
* Author: Alonso Vidales <alonso.vidales@tras2.es>
*
* To be compiled with nvcc -ptx matrix_mult.cu
* Debug: nvcc -arch=sm_20 -ptx matrix_mult.cu
*
**************************************************/
//#include <stdio.h>
#i... |
19,345 | #include "includes.h"
__global__ void kernel_hardswish(const float *input_, float *output_, int n_data_size_)
{
int i = threadIdx.x + blockIdx.x * blockDim.x;
if (i >= n_data_size_)return;
if (input_[i] >= 3.0f)
{
output_[i] = input_[i];
}
else if (input_[i] <= -3.0f)
{
output_[i] = 0.0f;
}
else
{
output_[i] = input_[i... |
19,346 | #include "includes.h"
__global__ void pw_gather_cu_z( double *pwcc, const double *c, const double scale, const int ngpts, const int *ghatmap) {
const int igpt = (gridDim.x * blockIdx.y + blockIdx.x) * blockDim.x + threadIdx.x;
if (igpt < ngpts) {
pwcc[2 * igpt ] = scale * c[2 * ghatmap[igpt] ];
pwc... |
19,347 | #include <stdio.h>
#include <cuda_runtime.h>
#include <time.h>
#define GPUClockRate 823500
template<unsigned int numThreads>
__global__ void reduction(int *answer, const int *in, const int N) {
extern __shared__ int sPartials[];
const int tid = threadIdx.x;
int sum = 0;
// 将该线程应该计算的单元求和
for ... |
19,348 | #include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cuda.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib> // for rand() and srand()
#include <ctime> // for time()
#include <vector>
#include <cuda_runtime.h>
#include <cuda.h>
#include <device_launch_para... |
19,349 | #include "includes.h"
__global__ void generateImg(unsigned char * data, unsigned char * img, unsigned char * tabDepth, int4 * _tabParents, int i, int tailleTab) {
int thx = blockIdx.x * blockDim.x + threadIdx.x;
int thy = blockIdx.y * blockDim.y + threadIdx.y;
int ThId = thy * tailleTab + thx;
int nbPar = 0;
if(data[T... |
19,350 | #include <cuda.h>
#include <stdio.h>
#include <stdlib.h>
#define N 32 // dim of matrix
//Fattened matrix multiplication . Kernel does not support x,y addressing
__global__ void mat_multiply(int* d_mat1, int* d_mat2, int* d_mat3, int width)
{
int k,sum=0;
int col = blockDim.x * blockIdx.x + threadIdx.x;
int row = ... |
19,351 | #include<iostream>
#include "cuda_runtime.h"
__global__ void addone(int *a)
{
*a = *a + 1;
printf("add one \n");
}
int main()
{
int a = 0;
int *d_a;
cudaMalloc(&d_a, sizeof(int));
cudaMemcpy(d_a, &a, sizeof(int), cudaMemcpyHostToDevice);
addone<<<1,32>>>(d_a);
cudaMemcpy(&a, d_a, ... |
19,352 | //xfail:BOOGIE_ERROR
//--blockDim=32 --gridDim=1 --warp-sync=32 --only-warp
__global__ void onlywarp_fail (int* A) {
A[0] = threadIdx.x;
}
|
19,353 | #include<cuda.h>
#include<stdio.h>
#include<math.h>
__global__
void vecMulMatrixKernel(float* A, float* B, float* C, int n){
int column = threadIdx.x + blockDim.x * blockIdx.x;
int row = threadIdx.y + blockDim.y * blockIdx.y;
printf("%d ",blockDim.x);
if(row<n && column <n){
float val = 0.0;
int i;
for(i... |
19,354 | #include <stdio.h>
#include <math.h>
#include <cuda_runtime_api.h>
#include <time.h>
#include <errno.h>
/******************************************************************************
* This program takes an initial estimate of m and c and finds the associated
* rms error. It is then as a base to generate and eval... |
19,355 | /*
* parallelise for dot product and dw calculation.
*/
#define length_of_features 12
#define examples 455
#define TILE_WIDTH 64
__global__ void sgd(float *x, float* y, float* weights,
float reg_strength,
float learning_rate,
int total_examples)
{
int tid = blockIdx.x*blockDim.x + threadIdx.x;
... |
19,356 | ////
//#include "cuda_runtime.h"
//#include "curand_kernel.h"
//#include "device_launch_parameters.h"
//#include <stdio.h>
//#include <stdlib.h>
//
//#include <string>
//#include <iomanip>
//#include <time.h>
//#include <iostream>
//#include <cmath>
//#include <math.h>
//using namespace std;
//
//#define N 10000
//#de... |
19,357 | #include <iostream>
#include<ctime>
#include "kernels.cuh"
int main(){
unsigned int N = 1*1024*1024;
unsigned int M = (unsigned int)sqrt(N);
int *h_primes;
int *d_primes;
//allocate memory
h_primes = (int*)malloc(N*sizeof(int));
cudaMalloc((int **)&d_primes,N*sizeof(int));
//timei... |
19,358 | #include <iostream>
#include <cmath>
#include <random>
#include <ctime>
#include <functional>
#include <cstdio>
typedef struct {
int width;
int height;
float* elements;
} Matrix;
int GetBlockSize() {
cudaDeviceProp deviceProp;
cudaGetDeviceProperties(&deviceProp, 0);
return roundl(sqrtl(devicePro... |
19,359 | #include <stdio.h>
typedef double (*func)(double x);
__device__ double func1(double x)
{
return x+1.0f;
}
__device__ double func2(double x)
{
return x+2.0f;
}
__device__ double func3(double x)
{
return x+3.0f;
}
__device__ func pfunc1 = func1;
__device__ func pfunc2 = func2;
__device__ func pfunc3 = func3;
__glob... |
19,360 |
/* 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... |
19,361 | # define _XOPEN_SOURCE 600
# include <stdio.h>
# include <stdlib.h>
# include <unistd.h>
# include <math.h>
# include <float.h>
# include <string.h>
# include <limits.h>
# include <sys/time.h>
# include <time.h>
//# include "mpi.h"
//# include <omp.h>
//N is Total Mem to be used and the size when only one vector... |
19,362 | #include <iostream>
const int lines = 1024;
const int cols = 1024;
const int block_size = 16;
__global__ void
transpose_matrix(int *input, int *output)
{
int i = blockIdx.x * block_size;
int j = blockIdx.y * block_size;
int x = threadIdx.x;
int y = threadIdx.y;
__shared__ int block_tr[block_siz... |
19,363 | /*
* Name: Nate Steawrt
* Date: 04-04-16
* Description: Serial implementation of Matrix multiplication with transpose
*/
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#define RANDOM_VALUE_MIN 1
#define RANDOM_VALUE_MAX 1000
#define MATRIX_DIM 1024
/*
* Calculate and return a random value between mi... |
19,364 | #include <iostream>
#include "readfile.cuh"
using namespace std;
readfile::readfile()
{
already_open = 0;
buffer = new char [MAX_LINE_LENGTH];
if(!buffer){ cout<< "allocation error in readfile"<<endl; exit(0);}
result = new char [MAX_LINE_LENGTH];
if(!result){ cout<<"allocation error in readfile"<<endl; exit(... |
19,365 | #include "includes.h"
/* https://zxi.mytechroad.com/blog/dynamic-programming/leetcode-730-count-different-palindromic-subsequences/ */
long kMod = 1000000007;
__global__ void setData(int *dp, int n) {
for(int i = blockIdx.x * blockDim.x + threadIdx.x; i < n; i += blockDim.x * gridDim.x) {
dp[i * n + i] = 1;
}
} |
19,366 | #include <stdio.h>
#include <thrust/device_vector.h>
//64
#define N 64
//32 // Threads per block
#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( floa... |
19,367 | #include <stdio.h>
#include <cuda_runtime.h>
#define TILE_SIZE (32)
void fail(const char *message)
{
printf(message);
fflush(stdout);
exit(EXIT_FAILURE);
}
__global__ void useSharedMemory()
{
__shared__ int arrOne[TILE_SIZE][TILE_SIZE];
__shared__ int arrTwo[TILE_SIZE][TILE_SIZE];
// Get rid of comp... |
19,368 | #include <stdio.h>
#include <math.h>
#include <time.h>
#define BLOCK_SIZE 16
#define MAX_DWELL 1024
void setColor(unsigned char* color, int r, int g, int b) {
color[0] =(int) r ;
color[1] =(int) g ;
color[2] =(int) b ;
}
void getColor(unsigned char* color, int index) {
// colors suggested by https://stackover... |
19,369 | #include <curand.h>
#include <curand_kernel.h>
#define DIM 1600
#define PI 3.14159265
__global__ void Pixelado(unsigned char *R_input, unsigned char *G_input,unsigned char *B_input, size_t i_size, unsigned char *R_output, unsigned char *G_output,unsigned char *B_output)
{
int x = threadIdx.x + (blockIdx.x * blockDim... |
19,370 | /*
* Compile: nvcc [-g] [-G] -arch=sm_21 -o mat_add mat_add.cu
* Run: ./mat_add <m> <n>
* m is the number of rows
* n is the number of columns
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define BLOCK_DIM 512
/*
[1 1 1]
[1 1 1] => [1 1 1][1 1 1][1 1 1]
[1 1 1]... |
19,371 | #include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <fstream>
#include "cuda_runtime.h"
using namespace std;
__global__ void fast_radix_sort(int *array, int array_len) {
extern __shared__ int tmp_array[];
int *b_array = tmp_array + array_len;
int *s_array = tmp_array + array... |
19,372 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <stdint.h>
#include <cuda.h>
#include <cuda_runtime.h>
#define TAG_BYTES 10
#define GRID_X 32
#define GRID_Y 32
#define BLOCK_X 32
#define BLOCK_Y 32
#define ALPHABET_LEN 256
#define NOT_FOUND patlen
#define... |
19,373 | #include <unistd.h>
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <errno.h>
#include <math.h>
#include <ctime>
#include <curand.h>
#include <curand_kernel.h>
__global__ void init(float time, curandState_t* states){
int threadID = threadIdx.x + blockDim.x * blockIdx.x;
curand_init ( time, ... |
19,374 | //pass
//--blockDim=[128,128] --gridDim=[4,4]
#include <cuda.h>
//////////////////////////////////////////////////////////////////////////////
//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
//// THE IMPLIED WARRANTIES OF ... |
19,375 | #include "includes.h"
__device__ static void myAtomicAdd(float *address, float value)
{
#if __CUDA_ARCH__ >= 200
atomicAdd(address, value);
#else
// cf. https://www.sharcnet.ca/help/index.php/CUDA_tips_and_tricks
int oldval, newval, readback;
oldval = __float_as_int(*address);
newval = __float_as_int(__int_as_float(ol... |
19,376 | // rellenar
|
19,377 | #include<stdio.h>
#include <malloc.h>
#include <stdlib.h>
#define N 1000
void MatrixMul(int *A, int *B, int *C, int Width) {
int i, j, k;
for(i=0; i<Width; i++)
for(j=0; j<Width; j++){
int s=0;
for(k=0; k<Width; k++)
s+=A[i*Width+k]*B[k*Width+j];
C[i*Width+j]=s;
}
}
#define TILE_WIDTH 16
__... |
19,378 | /******************************************************************************
* PROGRAM: copyStruture
* PURPOSE: This program is a test which test the ability to transfer multilevel
* C++ structured data from host to device, modify them and transfer back.
*
*
* NAME: Vuong Pham-Duy.
* College student.
* Facult... |
19,379 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <cuda.h>
#include <iostream>
using namespace std;
// device memory
float* dev_A;
float* dev_B;
float* dev_out;
// host memory
float* matrix1;
float* matrix2;
float* outBuffer;
inline void CHECKCUDA(cudaError_t e)
{
if (e != cudaSuccess)
{
cerr<<... |
19,380 | #include <iostream>
#include <cstdlib>
#include <cmath>
#include <cstdio>
// alternating harmonic series: https://en.wikipedia.org/wiki/Harmonic_series_(mathematics)#Alternating_harmonic_series
// compute alternating harmonic series member based on index n
__device__ auto ahs(size_t n){ return ((n&1)?1:-1)/(double)n;}... |
19,381 | #include "includes.h"
__global__ static void sum_channels(float *dest, const float *src, uint channels, uint num_channel_elem)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx >= num_channel_elem)
return;
float acc = 0;
for (uint i = 0; i < channels; ++i)
acc += src[idx + i * num_channel_elem];
dest[idx]... |
19,382 | #include "includes.h"
__global__ void to3d_point(float *depth, float *points3d)
{
int x = blockIdx.x * TILE_DIM + threadIdx.x;
int y = blockIdx.y * TILE_DIM + threadIdx.y;
int w = gridDim.x * TILE_DIM;
int h = w / 2;
for (int j = 0; j < TILE_DIM; j+= BLOCK_ROWS)
{
int iw = x;
int ih = y + j;
float depth_point = depth... |
19,383 | #include <cuda_runtime.h>
#include <stdio.h>
__global__ void checkIndex(void) {
printf("threadIdx:(%d, %d, %d) blockIdx:(%d, %d %d)"
"blockDim:(%d, %d, %d) gridDim:(%d, %d, %d)\n",
threadIdx.x, threadIdx.y, threadIdx.z,
blockIdx.x, blockIdx.y, blockIdx.z,
blockDim.x, blockDim.y, blockDim.z,
g... |
19,384 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
__global__
void testKernel(int *s, int dim){
s[400] = 9;
}
int main(int argc, char *argv[]){
if (argc < 2){
printf("Please indicate matrix size.\n");
exit(0);
}
int n = atoi(argv[1]);
int * tm = (int *)calloc((n+1)*(n+1), sizeof(int));
... |
19,385 | #include <iostream>
#include <cstdio>
using namespace std;
#include <cuda_runtime.h>
#define TIMES 24
#ifdef GEM5_FUSION
#include <stdint.h>
extern "C" {
void m5_work_begin(uint64_t workid, uint64_t threadid);
void m5_work_end(uint64_t workid, uint64_t threadid);
}
#endif
/////////////////////////////////////////////... |
19,386 | #include <stdio.h>
#include <cuda.h>
#include <time.h>
#define VARCOUNT 3
__global__ void RecursiveDoublingKernel(int variableSize, int step,int blcokRow, int blockColumn,float* deviceY,float* deviceM,int evenOrOddFlag)
{
//we weill do something like y(i+1)=my(i)+b
int bx=blockIdx.x;
int by=blockIdx.y;
int ... |
19,387 | #include<stdio.h>
#include<stdlib.h>
__global__ void multiply(int *a,int *b,int *c,int n,int m)
{
int row = blockIdx.y*blockDim.y+threadIdx.y;
int col = blockIdx.x*blockDim.x+threadIdx.x;
int result =0;
if(row<n&&col<m)
{
for(int i =0;i<n;i++)
{
result+=a[row*n+i]*b[i*m+col];
}
c[row*m+col]=result;
}
}
int main()
{
... |
19,388 |
#include <stdio.h>
#include <assert.h>
#include <cuda.h>
#define WARP 16
__global__ void incrementArrayOnDevice(int *x, int*y, int*r, int N)
{
int idx = blockIdx.x*blockDim.x + threadIdx.x;
int res = 0;
int warp = idx / WARP;
// the two threads that are going to interract are idx and idx + WARP
if (warp... |
19,389 | #include <cuda_runtime_api.h>
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
// Add your kernel here
__global__ void add(int *a, int *b, int *c) {
int index = threadIdx.x + (blockIdx.x * blockDim.x);
c[index] = a[index] + b[index];
}
// main
#define N (2048*2048)
#define THREADS_PER_BL... |
19,390 | #include <math.h>
#include <stdio.h>
#include <stdlib.h>
#define PI 3.14159265359f
#define MAX(a,b) (((a)>(b))?(a):(b))
#define p_Nthreads 32
__global__ void jacobi(int N, float * u, float *f, float *unew){
const int i = threadIdx.x + blockIdx.x*blockDim.x + 1; // offset by 1
const int j = threadIdx.y + blockI... |
19,391 | #include <stdio.h>
void __global__ kernel_meanSMA(float* array_device, int methodID, int width, int* rowArray, int rowArrayLength, int* colArray, int colArrayLength, int totalCols, int totalRows, float* results) {
// so doing it this way would probably have an advantage for calculating multiple columns at once, b... |
19,392 | /*--
--*/
#include <stdio.h>
#include "../include/MonteCarloMethod.cuh"
int search_best_ID(DataMessanger *hst, SpecGPU info){
int NO1 = 0;
for(int i = 1; i < info.NUM_BLOCKS; i++){
if(hst[i].L < hst[NO1].L){
NO1 = i;
}
}
return NO1;
}
void copy_input_sequences(DataMessange... |
19,393 | //Note:
//======= Cara compile =======
//nvcc nama_file.cu -o nama_file_output -gencode arch=compute_serinya,code=sm_serinya --default-stream per-thread
//======= Cara running program =======
//./nama_file mode besar_matrix besar_grid besar_block
//Ukuran matrix: besar_matrix x besar matrix
// besar_grid max = 655... |
19,394 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <cstring>
#include <ctime>
#include <math.h>
#define N 1024*40000
__device__ int binarySearch1(float *, int , int , int );
int binarySearch(float *, int , int , int );
__global__ void binary (float *Array, float *A2,float key ,int size) //Kernel Co... |
19,395 | #include "includes.h"
__global__ void scale_down_after_fft(float *d_Ex, float *d_Ey, float *d_Ez, int N_grid, int N_grid_all){
int i = blockIdx.x*blockDim.x + threadIdx.x;
int j = blockIdx.y*blockDim.y + threadIdx.y;
int k = blockIdx.z*blockDim.z + threadIdx.z;
int index = k*N_grid*N_grid + j*N_grid + i;
if(i<N_... |
19,396 | /** Thrust Library **/
#include <thrust/random.h>
#include <thrust/device_vector.h>
#include <thrust/transform.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
/** Std library **/
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <mat... |
19,397 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <iostream>
#define N 1536
#define Th 512
using namespace std;
__global__ void reduceVector(int * input, int * output, int * sub_sum){
__shared__ int sh_input[Th];
int thread = threadIdx.x;
int thread_desp = threadIdx.x + blockIdx.x * blockDim.x;
... |
19,398 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <cuda_runtime.h>
/* What is __global__ ?
1. It indicates a function that runs on the device.
2.
*/
/*
FYI,
device function processed by NVIDIA compiler.
will execute on the device. / will be called from the host.
<<<>>> is called from host cod... |
19,399 | //xfail:REPAIR_ERROR
//--blockDim=512 --gridDim=64 --loop-unwind=2 --no-inline
#include <cuda.h>
extern "C" {
__global__ void helloCUDA(float *A)
{
__shared__ float B[256];
for(int i = 0; i < 10; i ++) {
B[i] = A[i];
}
}
}
|
19,400 | extern "C"
#define n (3)
#define qPoints (58)
#define qPolygons (96)
__global__ void obtainPolygonsSteps(int* dev_S,int* dev_polygonToFillX,int* dev_polygonToFillY,int* dev_shipLocationX,
int* dev_shipLocationZ,float* dev_matrixC,int* dev_points,int* dev_polygons,int* dev_normals,const int N)
{
int j = threadIdx.x;
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.