serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
22,601 | // Memoria global
#include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
#define N 16
int main(int argc, char** argv) {
// declaraciones
float *hst_A, *hst_B;
float *dev_A, *dev_B;
// reserva en el host
hst_A = (float*)malloc(N * sizeof(float));
hst_B = (float*)malloc(N * sizeof... |
22,602 | // Vector addition: C = 1/A + 1/B.
// compile with the following command:
//
// (for GTX970)
// nvcc -arch=compute_52 -code=sm_52,sm_52 -O2 -m64 -o vecAdd vecAdd.cu
//
// (for GTX1060)
// nvcc -arch=compute_61 -code=sm_61,sm_61 -O2 -m64 -o vecAdd vecAdd.cu
// Includes
#include <stdio.h>
#include <stdlib.h>
#include <... |
22,603 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* DESCRIPTION :
*
Serial Concurrent Wave Equation - C Version
*
This program implements the concurrent wave equation
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ... |
22,604 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
int main() {
// Get number of GPUs
int deviceCount;
cudaGetDeviceCount(&deviceCount);
printf("Number of GPU devices: %i\n", deviceCount);
// Get CUDA driver and runtime version
int driverVersion;
int runtimeVersion;
cud... |
22,605 | #include "includes.h"
__global__ void ScaleUp(float *d_Result, float *d_Data, int width, int pitch, int height, int newpitch)
{
#define BW (SCALEUP_W/2 + 2)
#define BH (SCALEUP_H/2 + 2)
__shared__ float buffer[BW*BH];
const int tx = threadIdx.x;
const int ty = threadIdx.y;
if (tx<BW && ty<BH) {
int x = min(max(blockIdx... |
22,606 | /**
* Copyright 1993-2012 NVIDIA Corporation. All rights reserved.
*
* Please refer to the NVIDIA end user license agreement (EULA) associated
* with this source code for terms and conditions that govern your use of
* this software. Any use, reproduction, disclosure, or distribution of
* this software and relate... |
22,607 | #include "includes.h"
__global__ void uniformAdd(unsigned int n, unsigned int *data, unsigned int *inter)
{
__shared__ unsigned int uni;
if (threadIdx.x == 0) { uni = inter[blockIdx.x]; }
__syncthreads();
unsigned int g_ai = blockIdx.x*2*blockDim.x + threadIdx.x;
unsigned int g_bi = g_ai + blockDim.x;
if (g_ai < n) ... |
22,608 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <time.h>
#include <stdio.h>
#include <iostream>
#define epsilon 0.000001
using namespace std;
void Gaussian(float* data, int size, FILE* file);
void ForwardElim(float* data, int size);
void BackSub(float* data, int size);
void SwapRows(float* da... |
22,609 | #include <iostream>
#include <cstdlib>
#include <cuda.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
__global__ void vecAdd(double* res, double* inA, double* inB, size_t n) {
int x = blockDim.x * blockIdx.x + threadIdx.x;
if (x >= n) return;
res[x] = inA[x] + inB[x];
}
vo... |
22,610 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
__global__ void reduce(int *g_idata, int *g_odata)
{
}
int main(int argc, char *argv[])
{
// We assume that the element number is the power of 2 for simplification.
const int elemNum = 1 << 22;
int arraySize = elemNum * sizeof(int);
// host memory
int *h_i... |
22,611 | /**
* Add 2 vectors using CUDA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <iostream>
#include <string.h>
/**
* This macro checks return value of the CUDA runtime call and exits
* the application if the call failed.
*/
#define CUDA_CHECK_RETURN( value ) { \
... |
22,612 | struct MyStruct {
float floatvalue;
int intvalue;
};
__device__ __host__ float sumStruct(struct MyStruct **p_structs, int N) {
float sum = 0;
for(int i = 0; i < N; i++) {
struct MyStruct *mystruct = p_structs[i];
sum += mystruct->floatvalue + float(mystruct->intvalue) * 3.5f;
}
... |
22,613 | /* cada hilo copia su parte */
__global__ void gpuCopiarLayer(float *layer, float *layer_copy) {
int idBloque = blockIdx.x + blockIdx.y*gridDim.x;
int idGlobal = (idBloque*blockDim.x*blockDim.y) + (threadIdx.y*blockDim.x) + threadIdx.x;
layer_copy[idGlobal]=layer[idGlobal];
}
/* se actualiza la capa en función de l... |
22,614 | #include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <time.h>
//#define VERIFY
//uncomment above to print difference between CPU and GPU calculations
__global__ void matmul_kernel(
const float* M1,
const float* M2,
float* M3,
const int m,
const int n,
const int p
)
{
/... |
22,615 | float h_A[]= {
0.5497571433874873, 0.8347494050502031, 0.8055736747507383, 0.8446806354421298, 0.9203646031866868, 0.75587394208173, 0.7271795302862971, 0.6541245401546809, 0.6474186907135968, 0.696932168348505, 0.9601942745787786, 0.5481004285262927, 0.7104979842273528, 0.8136085794451676, 0.7747238308303026, 0.940155... |
22,616 | #include "includes.h"
__global__ static void transform_vert_to_fit(const int* src, int* dst, const int nb_vert)
{
const int p = blockIdx.x * blockDim.x + threadIdx.x;
if(p < nb_vert) dst[p] = src[p] < 0 ? 0 : 1;
} |
22,617 | /*************************************************************************
>> File Name: MatrixMultipl.c
>> Author: chenjunjie
>> Mail: 2716705056qq.com
>> Created Time: 2019.06.07
************************************************************************/
#include<stdio.h>
#include<stdlib.h>
#include<cuda.h>
#define W... |
22,618 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
float * multiplicar (float * mat1, float *mat2, int n)
{
float *res; int i=0; int j=0; int k=0;
res = (float*) malloc(n * n * sizeof(float));
for (i = 0; i<n; i++)
{
for (j = 0; j<n; j++)
{
res[i*n+j]=0;
... |
22,619 | extern "C"
/*
Pointer kernelParameters = Pointer.to(
// Dots properties
Pointer.to(gDots.iGA_Float[GPUDots.PX].gpuArray),
Pointer.to(gDots.iGA_Float[GPUDots.PY].gpuArray),
Pointer.to(gDots.iGA_Float[GPUDots.PZ].gpuArray),
... |
22,620 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define TILE_WIDTH 16
__global__ void Matrix_Mul_Kernel(float* d_M, float* d_N, float* d_P, int Width)
{
__shared__ float Mds[TILE_WIDTH][TILE_WIDTH];
__shared__ float Nds[TILE_WIDTH][TILE_WIDTH];
int bx = blockIdx.x;
int by = blockIdx.y;
int tx = threadI... |
22,621 | #ifdef _GLIBCXX_USE_INT128
#undef _GLIBCXX_USE_INT128
#endif
#ifdef _GLIBCXX_ATOMIC_BUILTINS
#undef _GLIBCXX_ATOMIC_BUILTINS
#endif
#include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <thrust/sort.h>
#include <thrust/scan.h>
#include <thrust/iterator/zip_iterator.h>
#include <iostream>
#incl... |
22,622 | #include "includes.h"
__global__ void __fillToIndsLongX(long long A, long long *B, long long len) {
int tid = threadIdx.x + blockDim.x * (blockIdx.x + gridDim.x * blockIdx.y);
int step = blockDim.x * gridDim.x * gridDim.y;
long long i;
for (i = tid; i < len; i += step) {
B[i] = A;
}
} |
22,623 | #include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
/*
__global__ void kernel(float* input0,float* input1,float* output0){
extern __shared__ __attribute__ ((aligned(16))) uint8_t sbase[];
float v3;
v3 = 0.0;
for (int i4 = 0;i4 < 256;i4++){
v3 = (v3+(input0[((blockIdx.x*256)+i4)... |
22,624 | __global__ void forwardReductionKernel(const double *a_d,
const double *b_d,
const double *c_d,
double *d_d,
const double *k1_d,
const double *k2_d,
... |
22,625 | /*
* nn.cu
*
* Created on: Apr 18, 2017
* Author: sara
*/
#include "nn.cuh"
#include "nn_kernels.cuh"
#include <iostream>
#include <fstream>
#include <iomanip>
# define MAX_THREADS 1024
/******************************************************************************
* data_buffer_split: creating data buff... |
22,626 | #include <stdio.h>
#include <cuda_runtime.h>
#include <iostream>
#include <cstdlib>
#include <curand.h>
#include <curand_kernel.h>
#include <ctime>
#include <fstream>
//Función que genera una jewel al azar
int createJewel(int difficulty) {
srand(time(NULL));
switch (difficulty) {
case 1: {
int randomJewel = ran... |
22,627 | #include <stdlib.h>
#include <stdio.h>
#include <time.h>
typedef struct
{
int width;
int height;
float* elements;
} Matrix;
#define BLOCK_SIZE 2
#define MATRIX_SIZE 2
__global__ void MatMulKernel(const Matrix, const Matrix, const Matrix);
void MatMul(const Matrix A, const Matrix B, Matrix C)
{
... |
22,628 | #include "includes.h"
__global__ void kMultDiagonalScalar(float* mat, float val, float* tgtMat, unsigned int width) {
const unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x;
const unsigned int numThreads = blockDim.x * gridDim.x;
for (unsigned int i = idx; i < width; i += numThreads) {
tgtMat[width*i + i] = ma... |
22,629 | #include "includes.h"
__global__ void kernel_bfs_t(int *g_push_reser, int *g_sink_weight, int *g_graph_height, bool *g_pixel_mask, int vertex_num, int width, int height, int vertex_num1, int width1, int height1)
{
int thid = __umul24(blockIdx.x, blockDim.x) + threadIdx.x ;
if(thid < vertex_num && g_pixel_mask[thid] ... |
22,630 | #include "includes.h"
__global__ void copySimilarity(float* similarities, int active_slices, int slices, int* activeMask, int target, int source)
{
int i = threadIdx.x + blockIdx.x * blockDim.x;
if (i >= active_slices)
return;
int slice = activeMask[i];
similarities[target*slices + slice] = similarities[source*slices +... |
22,631 | #include "includes.h"
__global__ void _logploss(int nrows, int ncols, float *y, float *dy) {
/* Similar to softmaxloss, except y is assumed normalized logp and is not overwritten.
y is layer output, i.e. normalized log probabilities.
dy is the label matrix: each column is a one-hot vector indicating the correct label.
... |
22,632 | #if !defined(_VEICULOS_CU_)
#define _VEICULOS_CU_
class Veiculo{
public:
//Metodos
__host__ __device__ Veiculo(){};
__host__ __device__ Veiculo(int id){
ID = id + 11;
x = 0;
y = 0;
vel = 0;
tam = 0;
vMax = 0;
};
//Atributos
int ID, ... |
22,633 | #include <stdio.h>
#include <stdint.h>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
#define CHECK(call)\
{\
const cudaError_t error = call;\
if (error != cudaSuccess)\
{\
fprintf(stderr, "Error: %s:%d, ", __FILE__, __LINE__);\
fprintf(stderr, "code: %d, reas... |
22,634 | // extern __shared__ uchar3 s_inPixels[];
// int idxR = blockIdx.y * blockDim.y + threadIdx.y;
// int idxC = blockIdx.x * blockDim.x + threadIdx.x;
// int filterPadding = filterWidth/2;
// int shareBlockWidth = blockDim.x + filterPadding;
// int inR = idxR - filterPadding;
// int inC = idxC - filterPadding;
/... |
22,635 | /*
CSC501 - Operating System - Spring 2012 - North Carolina State University
HomeWork2 Prob4. See - http://courses.ncsu.edu/csc501/lec/001/hw/hw2/
Author: Salil Kanitkar (sskanitk@ncsu.edu)
For Compiling -
$ make clean ; make a4
For Executing -
$ ./a4 <path-to-log-file> <path-to-process-list-file>
*/
#include<stdio... |
22,636 | #include "includes.h"
__global__ void reductionKernel(float* vec, int width, double* sumUp){
//shared memory instantiation
extern __shared__ float partialSum[];
//index for global memory
int g_idx = blockDim.x * blockIdx.x + threadIdx.x;
//index for shared memory
int b_idx = threadIdx.x;
//load shared memory from gl... |
22,637 | // Vector addition (device code)
// extern C for host program load correct function name
extern "C" __global__ void Sum(int *a, int *b, int *c, int n)
{
int tid = threadIdx.x + blockIdx.x * blockDim.x;
if (tid < n)
c[tid] = a[tid] + b[tid];
}
|
22,638 | #include "includes.h"
extern "C"
__global__ void sumSquareError (int nBatch, int rbs, int rScale, int nCoeff, float *DA, float *CA, float *EA, float *SA)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < nBatch)
{
const int daOffset = i * rbs * rScale * nCoeff;
const int caOffset = i * nCoeff;
const int eaOffse... |
22,639 | #include <iostream>
#include <random>
using namespace std;
// Matrices are stored in row-major order:
// M(row, column) = *(M.elements + row * M.width + col)
typedef struct
{
int width;
int height;
float * elements;
} Matrix;
// Thread block size
#define BLOCK_SIZE 16
// Forward declaration of the matrix mu... |
22,640 | #if GOOGLE_CUDA
#define EIGEN_USE_GPU
#define FLT_MAX 1e35
#include <cassert>
__device__ inline bool isvalidxy(const int h, const int w,const int y,const int x)
{
return (y >= 0) && (x >= 0) && (y < h) && (x < w);
}
__device__ inline void swapf(float & a, float & b)
{
float tmp = a;
a = b;
b = tmp;
}
... |
22,641 | #include <stdio.h>
#include <cuda_runtime.h>
__global__ void sample(int *A)
{
__shared__ int i;
i = 0;
if(threadIdx.x == 0)
{
for(int j = 0; j < 10000000; j++);
A[i] = 1;
atomicAdd(&i, 1);
__syncthreads();
for(int j = 0; j < 1000000; j++);
A[i] = 2;
atomicAdd(&i, 1);
}
else
{
A[i] = 3;
ato... |
22,642 | #include<thrust/reduce.h>
|
22,643 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
__global__ void unique_gid_calculation_2D_2D(int *input){
int tid = threadIdx.x + blockDim.x * threadIdx.y;
int num_threads_per_block = blockDim.x * blockDim.y;
int block_offset = blockIdx.x * num_threads_per_block;
int num_thre... |
22,644 | // nlm algorithm using shared memory
// also uses transpose *cube
// furthermore uses transpose shared array
// if blockSize=16 or 32 then avoids bank conflicts
__global__ void nlmSharedT(float *out, const float *in, const float *cube,
const int N, const int M, const int window,
... |
22,645 | #include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
#define CAFFE_CUDA_NUM_THREADS 196
inline int CAFFE_GET_BLOCKS(const int N) {
return (N + CAFFE_CUDA_NUM_THREADS - 1) / CAFFE_CUDA_NUM_THREADS;
}
template <typename Dtype>
__global__ void ConvFo... |
22,646 | #include <iostream>
#include <stdio.h>
#include <iomanip>
#include <cuda_runtime.h>
using namespace std;
void MatrixRandBin(float *mat, int rows, int cols) {
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
if ((float)rand()/RAND_MAX > 0.5) {
mat[i*cols+j] = 1.0... |
22,647 | #include <stdio.h>
#include <stdlib.h>
#include "device_launch_parameters.h"
#include <cuda_runtime.h>
__global__ void
vecAdd(float *a,float *b, float *c, int len)
{
int i=threadIdx.x+blockDim.x*blockIdx.x;
if(i<len)
c[i] = a[i] + b[i];
}
void vecAdd_CPU(float *a,float *b, float *c, float len)
{
int ... |
22,648 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <cuda_profiler_api.h>
#include <math.h>
#include <curand_kernel.h>
#include <time.h>
#include <string.h>
int sudoku[81];
int state[81];
int len = 81;
__constant__ int mstate_d[81];
#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inli... |
22,649 | #include "includes.h"
__global__ void sino_uncmprss(unsigned int * dsino, unsigned char * p1sino, unsigned char * d1sino, int ifrm, int nele)
{
int idx = blockIdx.x*blockDim.x + threadIdx.x;
if (idx<nele) {
d1sino[2 * idx] = (unsigned char)((dsino[ifrm*nele + idx] >> 8) & 0x000000ff);
d1sino[2 * idx + 1] = (unsigned ch... |
22,650 | #include <iostream>
#define N (2048*2048)
#define THREADS_PER_BLOCK 512
// #define N (8*8)
// #define THREADS_PER_BLOCK 8
__global__ void add(int *a, int *b, int *c) {
int index = threadIdx.x + blockIdx.x * blockDim.x;
c[index] = a[index] + b[index];
}
void random_ints(int *a, int size) {
for (int i = 0... |
22,651 | #include<stdio.h>
#define NUM_BLOCKS 8
#define BLOCK_WIDTH 5
__global__ void hello(){
printf("\nHello from Thread [%d] inside Block [%d]", threadIdx.x, blockIdx.x);
}
int main(){
hello<<<NUM_BLOCKS, BLOCK_WIDTH>>>();
cudaDeviceSynchronize();
printf("\nDONE");
return 0;
} |
22,652 | /*
============================================================================
Filename : algorithm.c
Author : Your name goes here
SCIPER : Your SCIPER number
============================================================================
*/
#include <iostream>
#include <iomanip>
#include <sys/time.h>
#incl... |
22,653 | #include <stdio.h>
#include <cuda_runtime.h>
#include <iostream>
#define N 2048 * 2048 // Number of elements in each vector
/*
* Optimize this already-accelerated codebase. Work iteratively
* and use profiler to check your progress
*
* Aim to profile `saxpy` (without modifying `N`) running under
* 25us.
*
* So... |
22,654 | /*
*
* Carlos Roman Rivera - A01700820
*
* Programming Languages - Cuda Lab 2
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <time.h>
__global__ void matrix_multiplication(int *matrix_1, int *matrix_2, int *matrix_r, int m, int n, int p){
int row = threadIdx.y + blockIdx.y * blockDim.y... |
22,655 | #include <stdlib.h>
#include <math.h>
#include <stdio.h>
#define N 512
#define NTPB 1024
__global__ void mergeSmall_k(int *a, int *b, int *m, int sizeA, int sizeB){
int K[2];
int P[2];
int Q[2];
int i = threadIdx.x;// + blockIdx.x * blockDim.x;
__shared__ int sA[N];
__shared__ int sB[N];
if(i<2*N){
sA[i%N]... |
22,656 | /*
Template code for convolution. CS6023, IITM */
#include<stdio.h>
#include<cuda.h>
#include<math.h>
#define W 1024 // Input DIM
#define OW (W-4) // Output DIM
#define D 8 // Input and Kernel Depth
#define T 5 // Kernel DIM
#define N 128 // Number of kernels
void fillMatrix(unsigned char *matrix){
unsigned char ... |
22,657 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <cuda_runtime.h>
#include <fstream>
#include <chrono>
#include <iostream>
__global__ void matrixMultiplication2D(const double *A, const double *B, double *C, int size) {
int rowIdx = blockIdx.y * blockDim.y + threadIdx.y;
int ... |
22,658 | #include "includes.h"
__global__ void OutputLayer(float* hiddenVotes, float* weight, int d_numHiddenNodes, float* d_votes){
int id = threadIdx.x + blockDim.x * blockIdx.x;
float total = 0.0f;
for (int i = 0; i < d_numHiddenNodes; ++i){
//printf("Hidden Votes: %i\n", hiddenVotes[i]);
//printf("Hidden Votes: %f, Weight... |
22,659 | #include "includes.h"
__global__ void simple_reduction(int *shared_var, int *input_values, int N, int iters)
{
__shared__ int local_mem[256];
int iter, i;
int tid = blockIdx.x * blockDim.x + threadIdx.x;
int local_tid = threadIdx.x;
int local_dim = blockDim.x;
int minThreadInThisBlock = blockIdx.x * blockDim.x;
int max... |
22,660 | // aslp-aslp-cudamatrix/cu-nnet-mpi-sync.cu
// Copyright 2016 ASLP (author: zhangbinbin)
// Created on 2016-02-24
#include "curand.h"
#ifdef CURAND_CHECK
#undef CURAND_CHECK
#endif
#define CURAND_CHECK(status) { curandAssert(status, __FILE__, __LINE__); }
#include "stdio.h"
inline void curandAssert(curandStatus_t ... |
22,661 | #include<cstdio>
#include<stdio.h>
#include<time.h>
#include<string.h>
#include<unistd.h>
#include<stdlib.h>
unsigned char *gpu_input_data_s,*gpu_output_data_s;
unsigned int *gpu_offset;
#define FINGERPRINT_LEN 20
#define MAX_CHUNK_LEN (16384)
#define MJW
#ifdef MJW
typedef struct
{
unsigned long total[2]; ... |
22,662 | #include <stdio.h>
__global__ void kernelA(){
// Giant conditional so that it only prints once, this would not be done in pactice
if (blockIdx.x == 0 & blockIdx.y == 1 & blockIdx.z == 0 & threadIdx.x == 1 & threadIdx.y == 0 & threadIdx.z == 1) {
printf("gridDim (%d, %d, %d)\n", gridDim.x, gridDim.y... |
22,663 | __global__ void wave1Drusanov2(double * f_tmp,double * f_nm,
double * f_in, double nu, int N){
int tid = threadIdx.x+blockIdx.x*blockDim.x;
if(tid<N){
int x_m = tid-1;
if(x_m<0) x_m = (N-1);
f_tmp[tid]=f_in[tid]-(2.*nu/3.)*(f_nm[tid]-f_nm[x_m]);
}
}
|
22,664 | // input: in_data (b,n,c), in_grid (b,n)
// output: out_data (b,g,c), out_pooling_mask (b,g,c)
__global__ void grid_pooling_gpu(int b,int n,int c,int g,const float * in_data,const int * in_grid,float * out_data,int * out_pooling_mask){
//int index = blockIdx.x * blockDim.x + threadIdx.x;
int stride = block... |
22,665 | #include "includes.h"
__global__ void matrixTrans(double * M,double * MT, int rows, int cols)
{
double val=0;
int row = blockIdx.x * blockDim.x + threadIdx.x;
int col = blockIdx.y * blockDim.y + threadIdx.y;
if (row < rows && col < cols){
val = M[col + row*cols];
MT[row + col*rows] = val;
}
} |
22,666 | // Copyright (c) OpenMMLab. All rights reserved.
#include <cstdint>
namespace mmdeploy {
namespace operation {
namespace cuda {
template <typename T>
__global__ void transpose(const T* src, int height, int width, int channels, int src_width_stride,
T* dst, int dst_channel_stride) {
auto x... |
22,667 | #include "includes.h"
__global__ void compute_array_square(float* array, float* outArray, int size)
{
int thread_index = threadIdx.x + blockIdx.x * blockDim.x;
int num_threads = blockDim.x * gridDim.x;
for(int i = 0; i < size; i += num_threads)
{
int index = i + thread_index;
if(index < size)
{
outArray[index] = array... |
22,668 | /*
**********************************************
* CS314 Principles of Programming Languages *
* Spring 2020 *
**********************************************
*/
#include <stdio.h>
#include <stdlib.h>
__global__ void collateSegments_gpu(int * src, int * scanResult, int * output, in... |
22,669 | #include<stdio.h>
#include <curand.h>
#include <curand_kernel.h>
#include<stdlib.h>
__global__ void fxn(double *W1, double *W2, double *X, double *Y, double *b1, double *b2, double *h, double *Z, double *loss){
int m = blockDim.x, n = blockDim.y, T = 10;
int mx = threadIdx.x, Nx = blockIdx.x, nx = threadIdx.y;... |
22,670 | #include<stdio.h>
#include<stdlib.h>
#include<cuda.h>
#define N 4
#define TPB 2
__global__ void matrixMul(int *a, int *b,int *c ,int n)
{
int row = blockIdx.y * blockDim.y + threadIdx.y ;
int col = blockIdx.x * blockDim.x + threadIdx.x ;
int i;
int sum=0;
for( i=0 ;i<N; i++)
{
sum+= a[row * N+... |
22,671 | __global__ void elementwise_add(const int * array1,
const int * array2, int * result, int size) {
unsigned int idx = threadIdx.x + blockIdx.x * blockDim.x;
unsigned int stride = gridDim.x * blockDim.x;
while (idx < size) {
result[idx] = array1[idx] + array2[idx];
idx += stride;
}
}
|
22,672 | #include <stdio.h>
__global__ void bbox_logits_to_attrs_gpu_kernel(int input_npoint, int channels,
const float* input_roi_attrs,
const float* input_logits,
float* output_attrs... |
22,673 |
#define N 100
__constant__ double buffer[N];
|
22,674 | #include "includes.h"
__global__ void VectorAdd(int *a, int *r, int n, double gamma)
{
int i=threadIdx.x;
if(i<n)
r[i] = (int)(255.0*pow((double)a[i]/255.0,1.0/gamma));
} |
22,675 | #include "includes.h"
#define DOUBLE
#ifdef DOUBLE
#define Complex cufftDoubleComplex
#define Real double
#define Transform CUFFT_Z2Z
#define TransformExec cufftExecZ2Z
#else
#define Complex cufftComplex
#define Real float
#define Transform CUFFT_C2C
#define TransformExec cufftExecC2C
#endif
#define TILE_DIM 8
/... |
22,676 | #include <stdio.h>
#include <stdint.h>
#include <cuda.h>
#include <inttypes.h>
#include <iostream>
#include <ctime>
using namespace std;
const long N = 12800;
const int THREADS_PER_BLOCK = 32;
// CPU copies of a, b, c
float *a_cpu, *b_cpu, *c_cpu;
__global__ void matrixMultiplicationKernel(float* A, float* B, float... |
22,677 | #include "includes.h"
__global__ void remove_redness_from_coordinates( const unsigned int* d_coordinates, unsigned char* d_r, unsigned char* d_b, unsigned char* d_g, unsigned char* d_r_output, int num_coordinates, int num_pixels_y, int num_pixels_x, int template_half_height, int template_half_width )
{
... |
22,678 | #include "includes.h"
__global__ void partialScan(unsigned int *d_in, unsigned int *d_out, unsigned int *d_total, size_t n)
{
__shared__ unsigned int temp[BLOCK_WIDTH];
int tx = threadIdx.x;
int bx = blockIdx.x;
int index = BLOCK_WIDTH * bx + tx;
if(index < n) {
temp[tx] = d_in[index];
} else { temp[tx] = 0; }
__synct... |
22,679 | /* jegood Joshua Good */
/**
* @file p3.cu
* Calculates the minimum distance for a set of file-specified points using GPU
* multi-threading. This program requires access to a CUDA-enabled GPU (i.e. NVIDIA
* graphics card).
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#inclu... |
22,680 | #include <iostream>
#include <sys/time.h>
#define TILE_DIM 32
using namespace std;
/* Compile with "-Xptxas -dlcm=cg" flags to disable Fermi L1 cache.
* Code would slow down when L1 cache is disabled.
* Disabling L1 cache would not have any effect on the shared memory
* version of matmul program (see exercise... |
22,681 | #include<stdio.h>
#include<iostream>
__global__
void saxpy(int n, float a, float *x, float *y)
{
int i = blockIdx.x*blockDim.x + threadIdx.x;
if (i < n) y[i] = a*x[i] + y[i];
}
int main(void)
{
using namespace std;
int N=1<<20; //shift 20 bits to the left
int num=100000;
float a=2.0;
float *x; //host arr... |
22,682 | #include <stdio.h>
#include <math.h>
#include <cuda_runtime.h>
__global__ void modular(int *a, int *b, int *c){
// for the small case, we only need thread, no block and grid
int i = threadIdx.x;
c[i] = a[i] % b[i];
// printf is not allowed in kernel function
// printf("%d", c[i])
}
__global__ void... |
22,683 | #include <math.h>
#include <stdio.h>
#include <cuda_runtime.h>
#define f(i,j) f[(i) + (j)*(m)]
#define Z(i,j) Z[(i) + (j)*m]
__global__ void Zev(float const * const Ag,float const * const A, float *Z,float const * const H, int m, int n,int patch,float filtsigma){
int x = blockDim.x * blockIdx.x + threadIdx.x;
in... |
22,684 | #include "includes.h"
__global__ void erosionColumns3DKernel( unsigned short *d_dst, unsigned short *d_src, int w,int h,int d, int kernel_radius )
{
__shared__ unsigned short smem[ER_COLUMNS_BLOCKDIM_Z][ER_COLUMNS_BLOCKDIM_X][(ER_COLUMNS_RESULT_STEPS + 2 * ER_COLUMNS_HALO_STEPS) * ER_COLUMNS_BLOCKDIM_Y + 1];
unsigned s... |
22,685 | /*
Name: Daniyal Manair
Student Number: 20064993
*/
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <vector>
#include <stdio.h>
#include <random>
#include <algorithm>
#include <chrono>
#include <map>
__global__ void sumMatrixGPU(float* A, float* B, float* C, const int N) {
unsigned int col... |
22,686 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define N 1000000
/*
<<<B, T>>>
gridDim.x = B
blockDim.x = T
blockIdx.x = 0 ... B - 1
threadIdx.x = 0 ... T - 1
*/
/*
clP - Cond0tional Likelihood of Parents (1x6)
clC - Conditional Likelihood of Children (1x12)
clPC - Transition Probability of Parent -> Chi... |
22,687 | #include <thrust/sort.h>
#include <thrust/device_vector.h>
#include <thrust/host_vector.h>
using namespace std;
class Point {
public:
Point() = default;
__host__ __device__
Point(double x, double y) : x(x), y(y) {};
double x, y;
};
__device__ Point d_query_point;
template<typename T>
struct device_sor... |
22,688 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
__global__ void sineof(float *X, float *Y){
int idx = blockIdx.x;
Y[idx] = sinf(X[idx]);
}
int main(){
float *X,*Y, N; //program vars
float *d_x, *d_y; //device vars
int size = sizeof(float);... |
22,689 | /*
#ifndef __CUDACC__
#define __CUDACC__
#endif
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>*
#include <conio.h>
const int TILE_WIDTH=2;
__global__ void MatrixMulKernel(float* Md, float* Nd, float* Pd, int Width)
{
__shared__ float Mds[TILE_WIDTH][TILE_WID... |
22,690 | // Assemble.cu
//
//This file contains the function that assembles bodies
#include <iostream>
//Function Prototypes
// Functions found in DCAfuncts.cu
void Mat66Mult(double A[6][6], double B[6][6], double C[6][6]);
void Mat61Mult(double A[6][6], double B[6][6], double C[6][6]);
void get_X(double z1[6][6], double z2[6]... |
22,691 | /*
**********************************************
* CS314 Principles of Programming Languages *
* Spring 2020 *
**********************************************
*/
#include <stdio.h>
#include <stdlib.h>
__global__ void markFilterEdges_gpu(int * src, int * dst, int * matches, int * ke... |
22,692 | /**
* vecAdd: C = A + B.
*
* Partially based on CUDA samples from CUDA 7.5 Toolkit
*
*/
#include <stdio.h>
#include <time.h>
// For the CUDA runtime routines (prefixed with "cuda_")
#include <cuda_runtime.h>
/**
* CUDA Kernel Device code
*
* Computes the vector addition of A and B into C. The 3 vectors ha... |
22,693 | #include <stdio.h>
#define ANGLE_COUNT 360
// declare constant memory
__constant__ float cangle[ANGLE_COUNT];
// declare global memory
__device__ float gangle[ANGLE_COUNT];
// kernel function for constant memory
__global__ void test_kernel(float* darray)
{
int index = blockIdx.x * blockDim.x + threadIdx.x;
... |
22,694 | #include <thrust/device_vector.h>
#include <thrust/copy.h>
#include <thrust/scan.h>
#include <iostream>
#include <iterator>
// BinaryPredicate for the head flag segment representation
// equivalent to thrust::not2(thrust::project2nd<int,int>()));
template <typename HeadFlagType>
struct head_flag_predicate
: publ... |
22,695 | #include <assert.h>
#include <stdio.h>
__global__ void hello_from_gpu(void)
{
printf("Hello world from GPU, thread %d!\n", threadIdx.x);
}
int main(void)
{
printf("Hello world from CPU!\n");
hello_from_gpu<<<1, 10>>>();
int32_t runtime_version;
cudaError_t cudaerr = cudaRuntim... |
22,696 | #include "includes.h"
__global__ void matrixSum(int* a,int* b, int* c, int size)
{
// int max = maxThreadsPerBlock;
// printf("ERROR en global\n");
int pos = threadIdx.x + blockIdx.x * blockDim.x;
// printf("Block: %d\n", blockIdx.x );
// printf("pos= %d\n",pos);
if(pos<size*size){
c[pos] = a[pos] + b[pos];
}
} |
22,697 | // ###
// ###
// ### Practical Course: GPU Programming in Computer Vision
// ###
// ###
// ### Technical University Munich, Computer Vision Group
// ### Summer Semester 2017, September 11 - October 9
// ###
#include <cuda_runtime.h>
#include <iostream>
using namespace std;
// cuda error checking
#define CUDA_CHECK ... |
22,698 | #include "includes.h"
extern "C"
{
}
__global__ void elSq2(int N, int M, float *In, float *Out)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
int j = blockIdx.y * blockDim.y + threadIdx.y;
int index = j*N + i;
if (i < N && j < M)
{
Out[index] = __fmul_rn(In[index], In[index]);
}
} |
22,699 | #include <iostream>
#include <cstdio>
__global__ void helloFromGPU(void)
{
printf("Hello from GPU - block: %d - thread: %d. \n", blockIdx.x, threadIdx.x);
}
int main()
{
std::cout << "Hello from CPU. " << std::endl;
helloFromGPU<<<2, 5>>>();
//cudaDeviceReset();
cudaDeviceSynchronize();
re... |
22,700 | #include "includes.h"
__global__ void sumArraysOnGPU(float *A, float *B, float *C) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
C[idx] = A[idx] + B[idx];
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.