serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
16,201 | /*
BGR0 to YUV converter
I have artifacts and changing md5sum now.
*/
// System includes
#include <stdio.h>
#include <time.h>
#include <assert.h>
#include <stdint.h>
// CUDA runtime
#include <cuda_runtime.h>
// helper functions and utilities to work with CUDA
//#include <helper_functions.h>
//#include <helper_cuda... |
16,202 | // ##########################################################
// By Eugene Ch'ng | www.complexity.io
// Email: genechng@gmail.com
// ----------------------------------------------------------
// The ERC 'Lost Frontiers' Project
// Development for the Parallelisation of ABM Simulation
// ------------------------------... |
16,203 | /* file : bitonic_merge_sort.cu
* author : Tiane Zhu
* date : Mar 29, 2017
*
* this program is an implementation of the parallel search algorithm
* ALGORITHM 4.5 in
* "An Introduction to Parallel Algorithms" - by Joseph Jaja
* p146 - ISBN 9-789201-548563
*/
////
// Input:
// Bitonic Sequence X = (x0, ... ... |
16,204 | #include "includes.h"
__global__ void vector_add(double const *A, double const *B, double *C, int const N)
{
int i = blockDim.x * blockIdx.x + threadIdx.x;
// if(i%512==0)
// printf("index %d\n",i);
if (i < N)
C[i] = A[i] + B[i];
} |
16,205 | #include "includes.h"
__global__ void multiplyDet(double *matrix, double *determinant,int* n){
int i;
int nn=*n;
for(i=0;i<nn;i++){
*determinant=(*determinant)*matrix[i*(nn)+i];
}
} |
16,206 | #include "includes.h"
/**
* C file for parallel QR factorization program usign CUDA
* See header for more infos.
*
* 2016 Marco Tieghi - marco01.tieghi@student.unife.it
*
*/
#define THREADS_PER_BLOCK 512 //I'll use 512 threads for each block (as required in the assignment)
__global__ void r1_update(double *A, int... |
16,207 | #include <cub/cub.cuh>
#ifndef block_size_x
#define block_size_x 128
#endif
#ifndef tile_size_x
#define tile_size_x 1
#endif
#ifndef use_shared_mem
#define use_shared_mem 0
#endif
template <int tile_size, int stride, typename T>
__device__ __forceinline__ void fill_shared_mem_tiled_1D(T (&sh_mem)[tile_... |
16,208 | #include "includes.h"
__global__ void sum4M(float *A, float *B, float *C, const int N)
{
int j;
int i = blockIdx.x * blockDim.x + threadIdx.x;
float x[4];
#pragma unroll
for (j=0; j < 4; j++)
if (i < N) {
x[j] = A[i]/7.0*A[i];
C[i] += A[i]/3 + 17*B[i] + 3*B[i] - A[i]*x[j] + x[j]*B[i]*7;
i += blockDim.x * gridDim.x;
}... |
16,209 | // CUDA programming: factorial problem
#include <iostream>
#include <cmath>
// kernel function in GPU
__global__ void findFac( int* a,int* idx ,int n)
{
int id = blockIdx.x*blockDim.x + threadIdx.x;
if(id < n){
//printf("id=%d %d mod %d == %d\n",id,(*a),b[id],(*a)%b[id]);
int b;
id == ... |
16,210 | #include "cuda.h"
extern "C" {
__device__ double sobely_kernel[3][3] = {{-1, -2, -1}, {0, 0, 0}, {1, 2, 1}};
__device__ double sobelx_kernel[3][3] = {{-1, 0, 1}, {-2, 0, 2}, {-1, 0, 1}};
__device__ double sharpen_kernel[3][3] = {{0, -1, 0}, {-1, 5, -1}, {0, -1, 0}};
__device__ double blur_kernel[3][3] =
{{0, 0.2, ... |
16,211 | #include "includes.h"
__global__ void computeDotProducts(float3* pDotProducts, size_t pSize, int* pCandidates, size_t* pJumpLength, size_t* pCandidateSize, size_t pNumberOfCandidates, int* pFeatureIdsNeighbor, float* pValuesNeighbor, size_t pMaxNnzNeighbor, size_t* pSizeNeighbor, int* pFeatureIdsInstance, float* pValue... |
16,212 | #include "includes.h"
__global__ void _bcnn_add_scalar_kernel(int n, float a, float *y) {
int i = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x;
if (i < n) y[i] += a;
} |
16,213 | #include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <cmath>
#include <climits>
#include <fstream>
//const int N = 512;
using namespace::std;
const int BLOCKS = 19000;
const int DIMENSIONS = 16;
const int TESTLINES = 1000;
unsigned short int testLines[TESTLINES*DIMENSIONS];
unsigned... |
16,214 | /*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty o... |
16,215 | #include "includes.h"
__global__ void group_point_gpu(int b, int n, int c, int m, int nsample, const float *points, const int *idx, float *out) {
for (int i=0;i<b;++i) {
for (int j=0;j<m;++j) {
for (int k=0;k<nsample;++k) {
int ii = idx[j*nsample+k];
for (int l=0;l<c;++l) {
out[j*nsample*c+k*c+l] = points[ii*c+l];
}
}
... |
16,216 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/scan.h>
#include <thrust/reduce.h>
#include <thrust/sort.h>
#include <thrust/functional.h>
#include <thrust/copy.h>
#include <thrust/device_ptr.h>
#include <thrust/iterator... |
16,217 | #include <stdio.h>
#include <stdlib.h>
#define N 2
__global__ void MatAdd(int A[][N], int B[][N], int C[][N]){
int i = threadIdx.x;
int j = threadIdx.y;
C[i][j] = A[i][j] + B[i][j];
}
int main(){
int A[N][N] = {{1,2},{3,4}};
int B[N][N] = {{5,6},{7,8}};
int C[N][N] = {{0,0}... |
16,218 | #include "includes.h"
__global__ void callOperationSharedDynamic(int *a, int *b, int *res, int x, int n)
{
int tid = blockDim.x * blockIdx.x + threadIdx.x;
if (tid >= n)
{
return;
}
extern __shared__ int arrays[];
__shared__ int s_x;
int *s_a = arrays;
int *s_b = &s_a[n];
int *s_res = &s_b[n];
s_x = x;
s_a[tid] = a... |
16,219 | #include "includes.h"
__global__ void pw_copy_rc_cu_z(const double *din, double *zout, const int n) {
const int igpt =
(gridDim.x * blockIdx.y + blockIdx.x) * blockDim.x + threadIdx.x;
if (igpt < n) {
zout[2 * igpt] = din[igpt];
zout[2 * igpt + 1] = 0.0e0;
}
} |
16,220 | #include <iostream>
#include <math.h>
// CUDA Kernel function to add the elements of two arrays
__global__
void GPU_add(long n, float *x, float *y)
{
/**
for (int i = 0; i < n; i++)
y[i] = x[i] + y[i];
**/
/**
int index = threadIdx.x;
int stride = blockDim.x;
for (int i = index; i < n; i += stride)
... |
16,221 | #include <stdio.h>
extern "C" {
__global__ void helloWorldKernel(int x);
}
__global__ void helloWorldKernel(int x) {
printf("Hello World %d\n",x);
return;
}
|
16,222 | /* File: mat_add.cu
* Purpose: Implement matrix addition on a gpu using cuda
*
* Output: Result of matrix addition.
*
* Notes:
* 1. There are m blocks with n threads each.
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
//#include "cuPrintf.cuh"
//#include "cuPrintf.cu"
//#include "utils/c... |
16,223 | #include<iostream>
#include <cuda.h>
int main(){
std::cout << "Hello World from CUDA\n";
cudaDeviceProp iProp;
int nDevices;
cudaGetDeviceCount(&nDevices);
std::cout << "Number of CUDA devices : " << nDevices << "\n";
std::cout << "Properties of device : " << nDevices - 1 << "\n";
cudaGetDeviceProper... |
16,224 | #include <iostream>
#include <vector>
#include <math.h>
#include <assert.h>
#include <memory>
#include <random>
#include "gMat.cuh"
#include "gpuerrchk.cuh"
__global__ void matMulKernel(float* A, float* B, float* P, int m, int n, int s, int tile_size){
//each thread in the block will be responsible for a different el... |
16,225 | //pass
//--blockDim=64 --gridDim=64 --equality-abstraction --no-inline
#include "cuda.h"
__global__ void foo(int* p) {
__shared__ int A[10];
int* x;
x = p;
x[0] = 0;
x = A;
x[0] = 0;
}
|
16,226 | #include <stdio.h>
#include <stdlib.h>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#define DEV 0
#define DGS_Check_Call( Statement , MsgString ) \
\
{ ... |
16,227 | #include "includes.h"
__global__ void gpu_stencil2D_4pt_hack5_cp_rows(double * dst, double * shared_cols, double *shared_rows,int tile_y,int M, int N){
#ifdef CUDA_CUDA_DEBUG
if((blockIdx.x==0)&&(blockIdx.y==0)&&(threadIdx.x==0)){
printf("copy rows begin!\n");
}
#endif
int base_global_row = (tile_y * blockIdx.y );
... |
16,228 | #include <iostream>
#define DATA_ELEM 75
#define DB_ELEM 20
#define DB_SIZE 100
using namespace std;
struct Data {
unsigned int d1;
unsigned int d2;
};
union Item {
Data data;
unsigned long long int raw;
};
// TODO, changes only in kernel_write
// database has empty(0) and non-empty(!=0) positio... |
16,229 | #include<stdio.h>
#include<cuda.h>
__global__ void HeatEq(float* d_a, float* d_b, double s)
{
int i = threadIdx.x;
d_b[i+1] = d_a[i+1]+s*(d_a[i+2]+d_a[i]-2*d_a[i+1]);
}
int main(int argc, char** argv)
{
const int n = 16;
const int BYTES = n * sizeof(float);
float h_a[n];
float h_b[n];
double s = 0.25;
for (in... |
16,230 | #include <stdio.h>
#include <cstdlib>
__global__
/* Kernel to square array on GPU */
void squareArray(float *input, float *result, unsigned int n) {
unsigned int idx = (blockIdx.x * blockDim.x) + threadIdx.x;
if (idx < n) {
result[idx] = input[idx] * input[idx];
}
}
unsigned int nIter; // number of iterations
u... |
16,231 | #include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include <curand_kernel.h>
#include <stdlib.h>
#include <cuda.h>
#include <sys/time.h>
#include "cudaS_ssdToOutput_kernels.cu"
#include<chrono>
#include<iostream>
using namespace std;
using namespace std::chrono;
int blocks_[20][2] = {{8,8}... |
16,232 | #include "includes.h"
__global__ void MyKernel(float* devPtr, size_t pitch, int width, int height)
{
for(int r=0; r<height; ++r){
float* row = (float*)((char*)devPtr + r * pitch);
for (int c = 0; c < width; ++c){
row[c] = 17.3;
}
}
} |
16,233 | #include "includes.h"
__global__ void add(int *a, int *b,int * c)
{
int col=10;
int i= blockIdx.y*blockDim.y+threadIdx.y;
int j=blockIdx.x*blockDim.x+threadIdx.x;
*(c + i * col +j)= *(a + i * col + j) + *(b + i * col + j);
} |
16,234 | #include<bits/stdc++.h>
using namespace std;
#define pi (2.0*acos(0.0))
#define eps 1e-6
#define ll long long
#define inf (1<<29)
#define vi vector<int>
#define vll vector<ll>
#define sc(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define all(v) v.begin() , v.end()
#define me(a,val) memset( a , val ,sizeof(a) )
#... |
16,235 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define CHECK(e) { int res = (e); if (res) printf("CUDA ERROR %d\n", res); }
#define CHANNEL 3
// Struct for measuring performance
struct GpuTimer{
cudaEvent_t start;
cudaEvent_t stop;
GpuTimer(){
cudaEventCreate(&start);
cudaEventCreate(&stop);
}
~G... |
16,236 | #include <math.h>
#include <stdio.h>
#define SHAREDSIZE 8000 /* Should be changed to dynamically detect shared
memory size if at all possible. */
//Forward declarations
__global__ void GPUMerge(float *d_list, int len, int stepSize,
int eltsPerThread);
/* Merges... |
16,237 |
__global__ void force_aux2(long n, double mx, double my, double *r_gpu, double *f_gpu, float *sinr_gpu, float *cosr_gpu)
{
long tid;
tid=threadIdx.x+blockIdx.x*blockDim.x;
while (tid<n)
{
f_gpu[tid]=cosr_gpu[tid]*my-sinr_gpu[tid]*mx;
tid+=blockDim.x*gridDim.x;
};
return;
}
|
16,238 | /**
* 并行计算
*/
#include <stdio.h>
#include <iostream>
#include<sys/time.h>
using namespace std;
#define N (200)
void add_cpu(int *a, int *b, int *c)
{
int tid = 0;
while(tid < N)
{
c[tid] = a[tid] + b[tid];
tid += 1;
/* code */
}
}
__global__ void add(int *a, int *b, int ... |
16,239 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include<stdio.h>
#include<stdlib.h>
__global__ void matrixop(int *a, int *t)
{
int n= threadIdx.x,m=blockIdx.x, size=blockDim.x,size1=gridDim.x;
t[m*size+n]=powf(a[m*size+n],m+1);
}
int main(void)
{
int *a,*t,m,n,i,j;
int *d_a,*d_t;
printf("Enter t... |
16,240 | #include <cstdlib>
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <fstream>
#include <string.h>
#include <vector>
#include <stdio.h>
#include <float.h>
#include <sstream>
#include <algorithm>
using namespace std;
// helper method which takes a line and parse each number into integer
// and adds ... |
16,241 | #include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
#define DUM_SIZE 4096
__device__ float dum[DUM_SIZE];
__global__ void foo()
{
size_t gid = blockDim.x * blockIdx.x + threadIdx.x;
if (gid < DUM_SIZE)
{
dum[gid] = 15;
}
return;
}
__global__ void print_foo()
{
size_t ... |
16,242 | /**
* classifier_blk.cu
*
* A CUDA kernel for accelerating a fully-connected neural network layer.
*
* This kernel treats the inputs, weights, and outputs of the layer as
* block matrices in order to facilitate better data reuse.
*/
#include <iostream>
#include <string>
using namespace std;
#ifndef Ni
#def... |
16,243 | // To compile - gcc -o 3dFDTD FDTD3D.c -lm
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <cuda_runtime.h>
#define IMAX 100
#define JMAX 100
#define KMAX 100
// This was taken from stackoverflow.com/questions/14038589/what-is-the-canonical-way-to-check-for-errors-using-the-... |
16,244 | #include<iostream>
using namespace std;
__global__ void matrixAdd(int **a,int **b,int **c){
int j = blockIdx.x*blockDim.x+threadIdx.x;
int i = blockIdx.y*blockDim.y+threadIdx.y;
c[i][j] = a[i][j]+b[i][j];
}
int main(){
int N=16;
int A[N][N],B[N][N],C[N][N];
for(int i=0;i<N;i++){
f... |
16,245 | #include <stdio.h>
#define N 256
#define T 256
__global__ void reverseArray(int *A ,int *B){
int i = threadIdx.x;
B[i] = A[(N - 1) - i];
}
int main (int argc, char *argv[]){
int i;
int size = N * sizeof (int);
int a[N], b[N], *devA, *devB;
printf("Original A array\n");
for (i = 0; i < N; i++... |
16,246 | #include "includes.h"
// Possible weight coefficients for tracking cost evaluation :
// Gaussian discretisation
/*
* 1 4 6 4 1
* 4 16 24 16 4
* 6 24 36 24 6
* 4 16 24 16 4
* 1 4 6 4 1
*/
// Compute spatial derivatives using Scharr operator - Naive implementation..
// Compu... |
16,247 | #include <stdio.h>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
static int const A[] = { 1, 2, 3, 4, 5 };
static __device__ int dev_A[5];
__global__ void szorzas_single_threaded() {
for(int i = 0; i < 5; i++) {
dev_A[i] *= 2;
}
}
__global__ void szorzas(int mennyivel) {
int i ... |
16,248 | #include <stdio.h>
__global__ void add(int a, int b, int *c) {
*c = a + b;
}
int main(void) {
int c, *dev_c;
// Allocate memory on the device
cudaMalloc( (void**)&dev_c, sizeof(int) );
add<<<1,1>>>(2, 7, dev_c);
// IMPORTANT:
// Do not dereference pointer returned by cudaMalloc() from code that
// executes... |
16,249 | #include <iostream>
#include <cmath>
#include <chrono>
// Addition of arrays using a stride loop
void checkError(cudaError_t e)
{
if (e != cudaSuccess)
{
std::cerr << "CUDA error: " << int(e) << " : " << cudaGetErrorString(e) << '\n';
abort();
}
}
__global__
void add(int n, double* x, double con... |
16,250 | #include <stdio.h>
int main(void)
{
int dev;
int no_dev;
cudaDeviceProp prop;
cudaGetDevice(&dev);
cudaGetDeviceCount(&no_dev);
cudaGetDeviceProperties(&prop, dev);
printf("number of devices are %d\n", no_dev);
printf("Id of current CUDA device %d\n", dev);
printf("Number of maximum Threads per Block are: %d... |
16,251 | #include "includes.h"
__global__ void TgvThresholdingL1Kernel(float2* Tp, float* u_, float* Iu, float* Iz, float lambda, float tau, float* eta_u, float* u, float* us, int width, int height, int stride)
{
int iy = blockIdx.y * blockDim.y + threadIdx.y; // current row
int ix = blockIdx.x * blockDim.x + threadIdx.x... |
16,252 | #include <algorithm>
#include <cassert>
#include <chrono>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
struct TItem {
int price;
int weight;
ssize_t index;
bool operator<(const TItem& other) const {
return (d... |
16,253 | /******************************************************************************
* 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... |
16,254 | #include <assert.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <stdio.h>
#include <chrono>
#include <cstdlib>
#include <iostream>
__global__ void vectorAddGPU(float* a, float* b, float* c, int N) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < N) {
... |
16,255 | __device__ unsigned int mulhilo32(
unsigned int a,
unsigned int b,
unsigned int* result_high) {
*result_high = __umulhi(a, b);
return a * b;
}
__device__ uint4 single_round(uint4 ctr, uint2 key) {
constexpr unsigned long kPhiloxSA = 0xD2511F53;
constexpr unsigned long kPhiloxSB = 0xCD9E8D57;
unsi... |
16,256 | #include <stdio.h>
#include <cuda.h>
#include <stdlib.h>
#include <time.h>
#include <driver_types.h>
//Performs inner product of vectors on CPU
void multiply_cpu(int *a, int *b, int* c, int N)
{
int d[N];
for (int i = 0; i < N; ++i)
{
d[i] = a[i]*b[i];
}
for (int i = 0; i < N; ++i)
{
*c += d[i];
}
}
//Per... |
16,257 |
#include <cuda.h>
#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;
void inizializzazioneHostArray(int *h_array,int n){
int i;
for(i=0;i<n;i++)
*(h_array+i)=i;
}
int main(int argc,char *argv[]){
int n;
int *h_array, *d_array;
if(argc==1)
... |
16,258 | #include <iostream>
__device__ void WarpReduce(volatile int* shared_data, int tid) {
shared_data[tid] += shared_data[tid + 32];
shared_data[tid] += shared_data[tid + 16];
shared_data[tid] += shared_data[tid + 8];
shared_data[tid] += shared_data[tid + 4];
shared_data[tid] += shared_data[tid + 2];
... |
16,259 | /*
* Copyright 1993-2007 NVIDIA Corporation. All rights reserved.
*
* NOTICE TO USER:
*
* This source code is subject to NVIDIA ownership rights under U.S. and
* international Copyright laws. Users and possessors of this source code
* are hereby granted a nonexclusive, royalty-free license to use this code
* ... |
16,260 | __global__ void square( float *x )
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
x[i]=x[i]*x[i];
}
|
16,261 | #include<stdio.h>
#include "cuda_runtime.h"
__global__ void helloFromGPU(){
printf("Hello World");
}
__global__ void VecAdd(float *A,float *B,float *C){
int i=threadIdx.x+blockIdx.x*blockDim.x;
C[i]=A[i]+B[i];
}
int main(){
helloFromGPU<<<1,10>>>();
cudaDeviceReset();
return 0;
} |
16,262 | #include <iostream>
#include <stdlib.h>
#include <chrono>
#include <stdio.h>
__global__
void triad_kernel(int N, double *x, double *y, double *z) {
for(unsigned i = threadIdx.x + blockIdx.x * blockDim.x; i < N; i+=blockDim.x*gridDim.x)
z[i] = x[i] + y[i];
}
int main() {
int N = 100;
double *x, *y,... |
16,263 | #include<iostream>
using namespace std;
__global__ void maximum(int *a, int*b, int n)
{
int tid=threadIdx.x;
int max=-9999;
for(int i=0;i<n;i++)
{
if(max<a[i])
max=a[i];
}
b[tid]=max;
}
int main()
{
int n=1000;
int *a=(int*)malloc(n*sizeof(int));
cudaEvent_t start, end;
for(int i=0;i<n... |
16,264 | #include <iostream>
__global__ void mykernel(void) {
}
int main(void) {
mykernel<<<1,1>>>();
std::cout << "Hello CUDA!" << std::endl;
return 0;
}
|
16,265 | /* CUDA exercise to convert a simple serial code for a brute force
largest prime number search into CUDA (32-bit, int version). This
initial code is serial, but it is written as CUDA code for your
convenience, so should be compiled with nvcc (see below). Your task
is to convert the serial computation to a k... |
16,266 | /***
* Ashutosh Dhar
* Department of Electrical and Computer Engineeing
* University of Illinois, Urbana-Champaign
*
*/
#include <cuda.h>
#include <iostream>
#include <cstdio>
#define THREADS_PER_SM 1
#define BLOCKS_PER_SM 1
#define ITERATIONS 1024
using namespace std;
__global__ void cache_latency(unsigned int *... |
16,267 | #include <cuda.h>
// Kernel definition
__global__ void VecAdd(int n, float* v1, float* v2, float* v3) {
int i = blockDim.x * blockIdx.x + threadIdx.x;
if (i < n) v3[i] = v1[i] + v2[i];
}
// exported function, usable in the C++ part
extern "C" void RunVecAdd(int n, float* v1, float* v2, float* v3) {
size_t size = n... |
16,268 | #include <stdio.h>
// Cuda supports printf in kernels for
// hardware with compute compatibility >= 2.0
__global__ void helloworld()
{
// CUDA runtime uses device overloading or printf in kernels
printf("Hello world!\n");
}
int main(void)
{
helloworld<<<1,1>>>();
return 0;
}
|
16,269 | /* ------------ TESTING PURPOSE ONLY ------------ */
#include <stdio.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <iostream>
#define SIZE 1024
__global__ void VectorAdd(int *a, int *b, int *c, int n) { //global -> tells the compiler that this function will be executed on the gpu
int i... |
16,270 | #include <cuda_runtime.h>
#include <thrust/device_vector.h>
#include <thrust/sort.h>
#include <thrust/binary_search.h>
#include <iostream>
#include <string>
#include <fstream>
template <typename T>
void load_binary(const T * data,
const size_t length,
const std::string& filename)
{
... |
16,271 | #include <stdio.h>
#include <stdlib.h>
/**
* Computes the log of reaction rate.
* @param a: Pointer to coefficient matrix.
* @param temp: Pointer to temperature array.
* @param lam: Matrix to write the results to.
* @param nsets: Number of sets / number of rows in coefficient matrix.
* @param ncells: Number of cells /... |
16,272 | #include "includes.h"
__global__ void cal_pi_d(double *sum, int nbin, double step, int nthreads, int nBLOCKS) {
int i;
double x;
int idx = blockIdx.x*blockDim.x+threadIdx.x; // Sequential thread index across the BLOCKS
for (i=idx; i< nbin; i+=nthreads*nBLOCKS) {
x = (i+0.5)*step;
sum[idx] += 4.0/(1.0+x*x);
}
} |
16,273 | #include"cuda_runtime.h"
#include"device_launch_parameters.h"
#include<stdio.h>
#include<string.h>
__global__ void copy(char *a, char *b, int n,int m)
{
int tid;
tid = threadIdx.x;
int i=0;
while(i<m)
{
b[i*n+tid]=a[tid];
i++;
}
}
int main()
{
char a[100],b[100];
int i,n,m,size;
char *d_a, *d_b;
prin... |
16,274 | #include "includes.h"
__global__ void LinearCombinationKernel(float *input1, float input1_coeff, int input1_start_index, float *input2, float input2_coeff, int input2_start_index, float *output, int output_start_index, int size)
{
int id = blockDim.x*blockIdx.y*gridDim.x
+ blockDim.x*blockIdx.x
+ threadIdx.x;
if(id < ... |
16,275 | /***********************************************************************************
This work is COMS 4824 Architecture Final Project, advised by Professor Martha Kim.
"A Walk on the Hyperthreaded Side:
an Implementation and Analysis of Translating Virtual Addresses on a GPU"
Copyright (c) 2017 Colum... |
16,276 | #include "includes.h"
__global__ void Final_Iterate_Kernel(int size, int *originIn, int *originOut, int *bestSeenIn, int *bestSeenOut, int *adjIndexes, int *adjacency, int *mis, int *incomplete)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < size)
{
int bestSeen = bestSeenIn[idx];
int origin = originIn[id... |
16,277 |
/* 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,float var_3,float var_4,float var_5,float var_6,float var_7,int var_8,float var_9,float var_10,float var_11,float var_12,float var_13,float ... |
16,278 | /***************************************************
* Module that applay the log to all the elements of the matrix
* Author: Alonso Vidales <alonso.vidales@tras2.es>
*
* To be compiled with nvcc -ptx matrix_log.cu
* Debug: nvcc -arch=sm_20 -ptx matrix_log.cu
*
**************************************************/... |
16,279 | #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define nWorld 2
#define N 24
#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"... |
16,280 | #include "includes.h"
#define N 10
//Sum Arrays
__global__ void add(int *x, int *y, int *z){
int tID = blockIdx.x;
if (tID < N){
z[tID] = x[tID] + y[tID];
}
} |
16,281 | #include <math.h>
#include "stdio.h"
double sourcef(double xval)
{
//source function for exact solution = (1-x)e^(-x^2)
double yval;
yval=-(2*xval-2*(1-2*xval)+4*xval*(xval-pow(xval,2)))*exp(-xval*xval);
return yval;
}
int main(int argc, char **argv)
{
//number of sub... |
16,282 | #include <iostream>
using namespace std;
#include <thrust/reduce.h>
#include <thrust/sequence.h>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
bool summation() {
const int N = 5000000;
// Create the array
thrust::device_vector<int> a(N);
// Fill the array
thrust::sequence( a.begin(), a.end(... |
16,283 | #include <cstdio>
#include <cstdlib>
#include <cuda.h>
#include <cuda_runtime_api.h>
void print_device_props_short() {
const size_t kb = 1024;
const size_t mb = kb * kb;
int devCount;
cudaGetDeviceCount(&devCount);
printf("Found the following GPUs:\n");
for (int i = 0; i < devCount; ++i) {
cudaDevic... |
16,284 |
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <iostream>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#define TILE_WIDTH 16
// an optimized version of matrix_multiplication which eliminates redundant loads
__global__ void matrix_multiply(int *d_M, int *d_N,... |
16,285 | #include<iostream>
#include <cuda.h>
#include <math.h>
#include<stdio.h>
#include<stdlib.h>
#include <sys/types.h>
#include <time.h>
using namespace std;
__device__ int min2(int a, int b)
{
int m = a;
if(m > b)
m=b;
return m;
}
__device__ int min1(int a,int b,int c)
{
int m=a;
if(m>b)
m=b;
if(m>c)
... |
16,286 | #include <stdio.h>
#include <cuda_runtime.h>
#include <cuda.h>
#include <stdlib.h>
#define N 256
__global__ void add(int *a, int *b, int* d) {
int tx = threadIdx.x, ty = threadIdx.y;
int bidx = blockIdx.x, bidy = blockIdx.y;
int bx = blockDim.x, by = blockDim.y;
int gy = gridDim.y;
int bid = bidx*gy + bidy;
i... |
16,287 | #include <iostream>
#include <fstream>
#include <string>
#include <cassert>
#include <random>
#include <algorithm>
#include <vector>
#include <unistd.h>
#include <ctime>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
const int IMAGE_DIM = 28;
const int FCL1_DIM = 1024;
const int FCL2_DIM = 10;
void switc... |
16,288 | #include "includes.h"
__global__ void assembleBinBlockCSRKernel( const unsigned matrix_size, const float* diagonal_blks, const float* nondiagonal_blks, const int* csr_rowptr, const unsigned* blkrow_offset, float* JtJ_data ) {
const auto row_idx = threadIdx.x + blockDim.x * blockIdx.x;
if(row_idx >= matrix_size) return;... |
16,289 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#ifndef NDEBUG
#define CHECK_STATUS(status) \
if (status != cudaSuccess) \
fprintf(stderr, "File: %s\nLine:%d Function:%s>>>%s\n", __FILE__, __LINE__, __FUNCTION__,\... |
16,290 | #include <stdio.h>
#include <assert.h>
#include <cuda.h>
#include <math.h>
__global__ void kernelId(int *a)
{
int idx = blockIdx.x*blockDim.x + threadIdx.x;
a[idx] = idx;
}
__global__ void kernelBlockIdx(int *a)
{
int idx = blockIdx.x*blockDim.x + threadIdx.x;
a[idx] = blockIdx.x;
}
__global__ void kernelTh... |
16,291 | /* --------------------------------------------------------------------
OPTIMIZED CODE MAKING USE OF REGISTERS + SHARED MEMORY
----------------------------------------------------------------------*/
#include <stdio.h>
#include "cuda.h"
#define max(x,y) ((x) > (y)? (x) : (y))
#define min(x,y) ((x) < (y)? (x... |
16,292 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cuda.h>
__global__ void matrixVecMultiply(float* A, float* B, float* C, int M) {
int i = threadIdx.x;
int offset;
float sum = 0;
for (int j=0; j<M; j++) {
offset = i*M + j;
sum += A[offset] * B[j];
}
C[i] = sum;
... |
16,293 | /**
* Vector Addition with CUDA (Fall 2016):
*
* Members:
* Emanuelle Crespi, Tolga Keskinoglu
*
* This test implements a parallel vector addition: C = A + B
* discussed in the methodology section of Optimizing CPU-GPU Interactions.
*
* The following code makes use of the function call vectorAdd( int n, int *... |
16,294 | void __device__ lrg ( unsigned int * seed )
{
for (int i = 0; i < 6; i++) {
/* code */
seed[i] =(1103515245*seed[i]+12345)%4294967296;
}
};
float __device__ fr ( unsigned int * seed, unsigned int i )
{
switch (i)
{
case 0:
return (float)(seed[0])/4294967296;
... |
16,295 | #include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <sys/time.h>
#define NSTREAMS 2
__host__ void init(float *out, int sz)
{
for(int i = 0 ; i < sz ; i++)
{
out[i] = sin(float(i));
}
}
__host__ void verif(float *out, int sz)
{
float err = 0.;
for(int i = 0 ; i < sz ; i++)
{
e... |
16,296 | /*
* segmentation_tools.cu
*
* Created on: Apr 15, 2017
* Author: sara
*/
#include "segmentation_tools.cuh"
#include "segmentator_cuda_kernels.cuh"
/******************************************************************************
* compute_organ_mask_bounds: estimate left, right, front, back, top and bottom... |
16,297 | #include <stdio.h>
#include <stdint.h>
#define CHECK(call) \
{ \
const cudaError_t error = call; \
if (error != cudaSuccess) ... |
16,298 | #include <stdio.h>
__global__ void glob(){
// int i = threadIdx.x;
// int j = blockIdx.x;
printf("Hello World!\n");
// printf("%d %d \n", i,j);
}
int main(void)
{
// double b[10][10];
// double *a;
// cudaMalloc((void **)&a, sizeof(b));
// cudaMemcpy(a,b,sizeof(b), cudaMemcpyHostToDevi... |
16,299 | __global__ void calc_grad_x_3d(int nx, int ny, int nz, float dx, float *arr_grad, float *arr){
const int x = threadIdx.x + blockDim.x * blockIdx.x;
const int y = threadIdx.y + blockDim.y * blockIdx.y;
const int z = threadIdx.z + blockDim.z * blockIdx.z;
int ijk = nx * ny * z + nx * y + x;
int ijk_f ... |
16,300 | #include<stdio.h>
#include<cuda.h>
__global__ void shubham(){
printf("shubham");
}
__global__ void dkernel(){
printf("hello ");
}
int main(){
dkernel<<<1,1>>>();
shubham<<<1,1>>>();
cudaDeviceSynchronize();
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.