serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
2,801 | // P2P Test by Greg Gutmann
// https://codingbyexample.com/2020/09/14/p2p-memcpy-with-nvlink/
#include "stdio.h"
#include "stdint.h"
int main()
{
// GPUs
int gpuid_0 = 0;
int gpuid_1 = 1;
// Memory Copy Size
uint32_t size = pow(2, 26); // 2^26 = 67MB
// Allocate Memory
uint32_t* dev_... |
2,802 | //Parallel Programming Final Project (CUDA)
//Team: 22
//ver 2.4 2018/12/16 21:15
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <time.h>
#include <cuda.h>
using namespace std;
int NUM_STEPS;
int NUM_DATA;
double *C_gpu,
*P_gpu,
*C_pr... |
2,803 | // Copyright 2018-2019 Tsinghua University, Author: Hongyu Xiang
// Apache 2.0.
// This file contains functions for calculating the denominator gradients in log domain.
#include <cstdio>
#include <cstdlib>
#include <vector>
// for each state
// start_weight
// end_weight
// Transition: float weight, int input_label, ... |
2,804 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include <math.h>
// Matrix dimension
int N;
// Cuda variables
int n_blocks = 16;
int n_threads_per_block = 32;
/* Initialize A and B*/
void initialize_inputs(int argc, char** argv, float*& A, float*& B) {
// User requested specific n... |
2,805 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <pthread.h>
#include <time.h>
#include <sys/time.h>
/*Dados HOST*/
struct data{
double c_x_min;
double c_x_max;
double c_y_min;
double c_y_max;
double pixel_width;
double pixel_height;
int i_x_max;
int i_y_max;
int... |
2,806 | #include <stdio.h>
#define BLOCK_SIZE_X 128
__global__
void warmUp(float* out, float* in, int count) {
float* local_array = in + (blockIdx.x * blockDim.x);
if (threadIdx.x == 0) { out[blockIdx.x] = local_array[0]; }
}
__global__
void sumUnrollGlobal(float* out, float* in, int count) {
if ((blockIdx.x * blockDim.x)... |
2,807 | #include <stdio.h>
#include <cuda_runtime_api.h>
#include <time.h>
__device__ char* is_a_match(char * attempt) {
char password1[] = "OKNXRT3171";
char * newPassword = (char *) malloc(sizeof(char) * 11);
newPassword[0] = password1[0] - 2;
newPassword[1] = password1[0] + 2;
newPassword[2] = password1[0] - 1;... |
2,808 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#define SIZE 8192
#define BLOCKSIZE 32
#define wbCheck(stmt) do { \
cudaError_t err = stmt; \
if (err != cudaSuccess) { \
printf("Failed to run s... |
2,809 | /************************************************
FILENAME: example_paddedpencil.cu
AUTHOR: Anuva K
DESCRIPTION: Test code to perform 3d FFTs on CUDA
according to the proposed pruned framework. FFTs of a small
non-zero subvolume of a larger volume of zeros are to be
computed pencil by pencil without storing the larg... |
2,810 | #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/time.h>
#include <cuda_runtime.h>
__global__ void Convolution(double* A, double* B, int I, int J)
{
int i = blockDim.x * blockIdx.x + threadIdx.x;
double c11, c12, c13, c21, c22, c23, c31, c32, c33;
c11 = +0.2; c21 = +0.5; c31 = -0.8;
c12 ... |
2,811 | // https://stackoverflow.com/questions/57187912/how-to-differentiate-gpu-threads-in-a-single-gpu-for-different-host-cpu-thread
// nvcc cuda_std_thread.cu -o cuda_std_thread -std=c++11
#include <iostream>
#include <math.h>
#include <thread>
#include <vector>
#include <cuda.h>
using namespace std;
const unsigned NUM_... |
2,812 | #include<iostream>
#include<cuda.h>
// Device code
__global__ void VecAdd(float* A, float* B, float* C, int N){
int i = blockDim.x * blockIdx.x + threadIdx.x;
if(i < N){
C[i] = A[i] + B[i];
}
}
// Host code
int main(){
int N = 10;
size_t size = N*sizeof(float);
// Allocate memory for ... |
2,813 | #include "vector.cuh"
|
2,814 | # include <stdio.h>
# include <math.h>
__global__ void Add( int n, float *A, float *B, float *C, float S1, float S2, int steps) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if(idx < n){
for (int i = 0; i < steps; i++){
C[steps*idx+i]=(powf(S1,3.0)- 3*B[steps*idx+i])/(A[steps*idx+i] + S2); //powf(S1,3.0)
... |
2,815 | //Submitted by GAutham M 15co118 and yashwanth 15co154
#include<stdio.h>
#include<stdlib.h>
#include<cuda.h>
#include <time.h>
__global__ void func(float *da_in,float *db_in,float *d_out)
{
int idx = blockIdx.x*100 + threadIdx.x;
d_out[idx] = da_in[idx] + db_in[idx];
}
int main()
{
const int array_size = 16000;
c... |
2,816 | /* Computes quadrature rules (i.e. circumference) for unit circle in 2D */
/* Adapted from: https://people.sc.fsu.edu/~jburkardt/c_src/circle_rule/circle_rule.html */
#include <stdio.h>
#define NUM_ANGLES 100000
#define PI 3.14159265358
#define F(x,y) x*y
#define CUDA_BLOCK_X 128
#define CUDA_BLOCK_Y 1
#define CUDA_BLO... |
2,817 | extern "C"
__global__ void vectorScalarSet(float* A, float alpha, int numElements)
{
int i = blockDim.x * blockIdx.x + threadIdx.x;
if (i < numElements)
{
A[i] = alpha;
}
}
extern "C"
__global__ void vectorScalarAdd(const float* __restrict__ A, float* B, float alpha, int numElements)
{
int i... |
2,818 | /*
simple wrapper to utility cuda routines
*/
#include <stdlib.h>
#include <stdio.h>
#include <cuda.h>
#include <cuda_runtime.h>
extern "C" int CountDevices()
{
int num_gpus = -1;
cudaGetDeviceCount(&num_gpus);
return num_gpus;
}
extern "C" void SetDevice(int gpu_id)
{
cudaSetDevice(gpu_id);
}
extern ... |
2,819 | #include "includes.h"
__device__ double efficientLocalMean_dev (const long x,const long y,const long k, double * input_img, int rowsize, int colsize) {
long k2 = k/2;
long dimx = rowsize;
long dimy = colsize;
//wanting average over area: (y-k2,x-k2) ... (y+k2-1, x+k2-1)
long starty = y-k2;
long startx = x-k2;
long st... |
2,820 | #include <iostream>
#include <math.h>
#include <functional>
#include <stdlib.h> /* srand, rand */
#include <time.h> /* time */
#define ROW_TILE_WIDTH 32
#define COL_TILE_WIDTH 32
template<typename T>
__global__
void naive_matrix_multiply(T *A, T *B, T* C, int width, int C_rows, int C_cols)
{
int row = blo... |
2,821 | #include<stdio.h>
#include<string.h>
#include<stdlib.h>
using namespace std;
#define SUBMATRIX_SIZE 50000
#define NUM_BIN 100
#define HIST_MIN 0.0
#define HIST_MAX 3e9
////////////////////////////////////////////////////////////////////////
__global__ void distance(float *x, float *y, float *z, int xind, int yind, i... |
2,822 | // Copyright (c) 2017 Madhavan Seshadri
// 2018 Patrick Diehl
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
extern "C" { __global__ void kernel(char *out, int *width, int *height, int ... |
2,823 | #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define GRID 1
#define THRDS 256
__global__ void assign(int * buf)
{
int idx = threadIdx.x;
buf[idx] = idx;
}
void print_buf(int * buf,int size)
{
int i = 0;
for (i=0;i<size;i++)
printf("%d\t",buf[i]);
printf("\n");
}
int main()
{
int * buf_h;
int... |
2,824 | #include <stdio.h>
#include <sys/time.h>
#include <time.h>
#define GO_EMPTY 0
#define GO_BLACK 1
#define GO_WHITE 2
#define GO_BORDER 3
const int boardSize = 21;
const int totalSize = boardSize * boardSize;
struct BoardPoint{
int color;
int groupID;
int libertyNumber;
bool isBlackLegal;
bool isWhiteLe... |
2,825 | #define N 16
__global__ void k(int* in)
{
if(threadIdx.x < N)
in[0] = 0;
}
int main()
{
int* din;
cudaMalloc((void**) &din, N*sizeof(int));
k<<<1,N>>>(din);
} |
2,826 | #include "includes.h"
__global__ void matrixMul_kernel(float * A, float * B, float * C, int N)
{
int ROW = blockIdx.y * blockDim.y + threadIdx.y;
int COL = blockIdx.x * blockDim.x + threadIdx.x;
float tmpSum = 0;
if (ROW < N && COL < N)
{
// each thread computes one elem of the block sub-matrix
for (int i = 0; i < N;... |
2,827 | #include<iostream>
#include <cuda.h>
__global__ void stencil_kernel(const float* image, const float* mask, float* output, unsigned int n, unsigned int R)
{
extern __shared__ float shared[];
float opsum=0;
int flag=(int)R;
float* mk = &shared[0];
float* ip = &mk[2*R+1];
float* op = &ip[blo... |
2,828 | #include <cuda.h>
#include <iostream>
#include <math.h>
#include <ctime>
#include <cmath>
#include <unistd.h>
#include <stdio.h>
/* we need these includes for CUDA's random number stuff */
#include <curand.h>
#include <curand_kernel.h>
#define PI 3.14159265358979323846
double* three_dim_index(double* matrix, int... |
2,829 |
#include <stdio.h>
#include <cuda.h>
//#include <cudaMalloc.h>
__global__ void add(int *a, int *b, int *c)
{
*c = *a + *b;
}
int main(void)
{
int a, b, c;
int *pa, *pb, *pc;
int size = sizeof(int);
cudaMalloc((void **)&pa, size);
cudaMalloc((void **)&pb, size);
cudaMalloc((void **)&pc,... |
2,830 | #include "cuda.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#define SIZE 900
#define HIDDINLAYERS 2
#define POINTS 583
#define TEST 100
#define ATTRIBUTES 10
static void HandleError( cudaError_t err,
const char *file,
int line ) {
if... |
2,831 | #include "includes.h"
__global__ void find_closest_mine(float * mine_pos_v, float * distances_v, int * mineIdx_v, int num_sweeprs, int num_mines, float * inputs)
{
#define sweeperIdx blockIdx.y
#define first_item blockIdx.y*num_mines
int my_index = (gridDim.x * blockIdx.x) + threadIdx.x;
//mineIdx_v[sweeperIdx * num_m... |
2,832 | #include <stdio.h>
#include <cuda.h>
#include <time.h>
#define lim 99
#define threads 10
void print(int *w){
for(int i=0; i<lim; i++){
printf("%d\n", w[i]);
}
}
void fillVector(int *w){
for(int i=0; i<lim; i++){
w[i]=i;
}
}
__global__
void add(int *d_x, int *d_y, int *d_z){
int i = blockIdx.x * bl... |
2,833 | #include "includes.h"
__global__ void PictureKernell(unsigned char * d_Pin, unsigned char * d_Pout, int n, int m ){
int Row = blockIdx.y*blockDim.y + threadIdx.y;
int Col = blockIdx.x*blockDim.x + threadIdx.x;
if ((Row < m)&&(Col < n)){
d_Pout[Row*n + Col] = 2*d_Pin[Row*n+Col];
}
} |
2,834 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <iostream>
#include <stdio.h>
void cudaDevicesInfo ()
{
int deviceCount;
cudaDeviceProp deviceProp;
cudaGetDeviceCount (&deviceCount);
for (int device = 0; device < deviceCount; ++device) {
printf ("Device #%d:\n\n", device);
cudaGetDev... |
2,835 | #include <iostream>
int main(){
int dev_count;
cudaGetDeviceCount(&dev_count);
cudaDeviceProp dev_prop;
for (int i=0; i<dev_count; i++){
cudaGetDeviceProperties(&dev_prop,i);
std::cout << "Device number: " << i << "\n";
std::cout << "Shared memory per block:" << dev_prop.sharedMemPerBlock << "bytes \n";
s... |
2,836 | #include "phong_implement.h"
#include "brdf_common.h"
__global__ void
phong_kernel(float3* pos, unsigned int width, float3 V, float3 N, float exposure, int divideByNdotL)
{
unsigned int x = blockIdx.x*blockDim.x + threadIdx.x;
unsigned int y = blockIdx.y*blockDim.y + threadIdx.y;
float3 L = calculateL(p... |
2,837 | #include <stdio.h>
#include <stdlib.h>
__global__ void isExecuted(int *dev_a, int blockid, int threadid){
if(blockIdx.x == blockid && threadIdx.x == threadid)
*dev_a = 1;
else
*dev_a = 0;
}
int main(){
// Declare variables and allocate memory on the GPU.
int a[1], *dev_a;
cudaMalloc((void**) &d... |
2,838 | #include "includes.h"
const int Nthreads = 1024, maxFR = 10000, NrankMax = 3, nt0max=81, NchanMax = 17;
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////... |
2,839 | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sstream>
#include <string>
#include <iostream>
#include <stdlib.h>
#include <time.h>
#define X 40
#define Y 40
#define BLOCK_SIZE_X 16
#define BLOCK_SIZE_Y 8
#define GETCOORDS(row, col) (row) * (Y) + (col)
#define CEIL(x,y) (((x)-1) / (y)) + 1
voi... |
2,840 | #include <cuda_runtime.h>
#include<iostream>
using namespace std;
#include <device_launch_parameters.h>
int main(void) {
//struct containing info such as name, threads/block, etc.
cudaDeviceProp devProp;
int count;
//pass addr of var, get method populates
cudaGetDeviceCount(&count);
for (int i = 0; i < count; i... |
2,841 | /*
Compile using nvcc cuda_heat.cu
Author: Romit Maulik - romit.maulik@okstate.edu
*/
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
const double PI = 3.1415926535;
const double lx = 2.0*PI, ly = 2.0*PI;
const int nx = 254, ny = 254;
const double ALPHA = 0.8, STAB_PARAM = 0.8;
const double... |
2,842 | #include<stdio.h>
#include<stdlib.h>
#include<sys/time.h>
#define CUDA_ERROR_EXIT(str) do{\
cudaError err = cudaGetLastError();\
if( err != cudaSuccess){\
printf("Cuda Error: '%s' for %s\n", cudaGetErro... |
2,843 | #pragma once
#include "Matrix.cuh"
Matrix::Matrix(long width, long height) {
this->width = width;
this->height = height;
}
long Matrix::getWidth() {
return width;
}
long Matrix::getHeight() {
return height;
} |
2,844 | // ###
// ###
// ### Practical Course: GPU Programming in Computer Vision
// ###
// ###
// ### Technical University Munich, Computer Vision Group
// ### Summer Semester 2014, September 8 - October 10
// ###
// ###
// ### Maria Klodt, Jan Stuehmer, Mohamed Souiai, Thomas Moellenhoff
// ###
// ###
// ### Dennis Mack, den... |
2,845 | #include <cuda.h>
#include <iostream>
#include <vector>
void printArray(const float* x, int n)
{
std::cout << "(";
for (int i = 0; i < n; i++)
{
std::cout << x[i] << ", ";
}
std::cout << ")" << std::endl;
}
// My attempt at using shared mem among blocks. Runs slightly slower than my naïve
... |
2,846 | #include <stdio.h>
#include <stdlib.h>
__global__ void gpu_add_two_vectors(void)
{
}
int main()
{
printf("Adding Vectors: \n");
return 0;
} |
2,847 | #include "includes.h"
__global__ void nms_kernel( const int num_per_thread, const float threshold, const int num_detections, const int *indices, float *scores, const float *classes, const float4 *boxes) {
// Go through detections by descending score
for (int m = 0; m < num_detections; m++) {
for (int n = 0; n < num_pe... |
2,848 | /*******************************************************************
* Sparse Auto-Encoder
* by
* David Klaus and Alex Welles
* EC527 Final Project
*
* Serial Implementation With Timing Code
*
* Compile with:
*
* nvcc -Xcompiler -fopenmp -lgomp -o sparseAutoencoder sparseAutoencoder.cu
*
******************... |
2,849 | // David Ramirez A01206423
#include <stdio.h>
#include <stdlib.h>
#include "cuda_runtime.h"
#define RECTS 1e9
#define BLOCKS 1000
#define THREADS 512
// long num_rects = 100000, i;
// double mid, height, width, area;
// sum = 0.0;
// width = 1.0 / (double) num_rects;
// for (i = 0; i < num_rects; i++){
// mid = (i ... |
2,850 | /*
* Alexandre Maros - 2016
*
* Cuda Matrix Multiplication with Global Memory.
*
* nvcc cuda_matrix_global.cu -o cg.o
*
* Implemented by Alexandre Maros for learning purposes.
* A version of this code using Shared Memory is in here:
* https://github.com/alepmaros/cuda_matrix_multiplication
*
* Distributed un... |
2,851 | #include "includes.h"
__global__ void simple_histo(int *d_bins, const int *d_in, const int BIN_COUNT)
{
int myId = threadIdx.x + blockDim.x * blockIdx.x;
int myItem = d_in[myId];
int myBin = myItem % BIN_COUNT;
atomicAdd(&(d_bins[myBin]), 1);
} |
2,852 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <cmath>
#include <cstdio>
#define N 300
#define NSTREAM 4
__global__ void kernel_1()
{
double sum = 0.0;
for (int i = 0; i < N; i++)
{
sum = sum + tan(0.1) * tan(0.1);
}
}
__global__ void kernel_2()
{
double sum = 0.0;
for (int i = 0;... |
2,853 | #include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
#include <unistd.h>
int main(int argc,char* argv[]){
cudaError_t res;
float* d;
int i,j;
size_t pitch,width,height;
for(i = 0 ; i < 1000 ; i ++){
for(j = 0 ; j < 100 ; j ++){
width = 5*i;
height = 100*j;
res = cudaMal... |
2,854 | #include "includes.h"
__global__ void myfirstkernel(void) {
// Code start here
} |
2,855 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <cuda_runtime.h>
//#define DEBUG
#define L1 1024
#define L2 1024
#define L3 1024
/* ========== Multiple block, Multiple threads ========== */
/* ========== Can change different matrix length and width ========== */
/* ========== B matrix doen't tr... |
2,856 | //imports
#include <stdio.h>
#include <math.h>
#include <cuda.h>
#include <stdlib.h>
__global__ void printSome(int i){
printf("%d",i);
}
int main(){
cudaStream_t streams[5];
int i;
for(i=0;i<5;i++){
cudaStreamCreate(&streams[i]);
}
for(i=0;i<5;i++){
printSome<<<1,1,0,streams[i]>>>(i);
}
for(i=0;i<5;i++){
... |
2,857 | #include <stdio.h>
__global__ void spmv_csr_kernel(unsigned int dim, unsigned int *csrRowPtr,
unsigned int *csrColIdx, float *csrData, float *inVector,
float *outVector) {
// INSERT KERNEL CODE HERE
int rowIdx = blockIdx.x*blockDim.x + threadIdx.x;
if(rowIdx<dim){
float dotP = 0.0f;
... |
2,858 | #include <stdint.h>
__global__ void adjust_hue_hwc(const int height, const int width,
uint8_t * const __restrict__ input, uint8_t * const __restrict__ output, const float hue_delta) {
// multiply by 3 since we're dealing with contiguous RGB bytes for each pixel
const int idx = (blockDim.x * blockIdx.x + threadId... |
2,859 | #include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <stdio.h>
#include <stdlib.h>
//implement one grid with 4 blocks and 256 threads in total, 8x8 threads for each block
__global__ void print_threadIds()
{
printf("blockIdx,x : %d, blockIdx.y : %d, blockIdx.z : %d, blockDim.x : %d, blockDim.y : %d... |
2,860 | #include <stdio.h>
#include <cuda_runtime.h>
// #include <helper_cuda.h>
#define N 1000000
__global__ void doubleElements(int *a){
for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < N; i += gridDim.x * blockDim.x)
a[i] *= 2;
}
int main(void){
cudaError_t err = cudaSuccess;
size_t size = N * sizeof(int);
... |
2,861 | #include <stdio.h>
#include <curand_kernel.h>
#include <chrono>
#define host_t float
#define device_t float*
#define t_size sizeof(host_t)
#define size_t unsigned long
#define time_point_t std::chrono::time_point<std::chrono::high_resolution_clock>
template<typename A, typename B>
struct pair_t { A first; B second;... |
2,862 | // Сложение векторов и сравнение с количеством тредов в памяти
#include <iostream>
#include <cuda.h>
using namespace std;
__global__ void add( float *a, float *b, float *c ) {
if(a[ threadIdx.x ] + b[ threadIdx.x ]<10)
c[ threadIdx.x ] = a[ threadIdx.x ] + b[ threadIdx.x ];
else
c[ threadIdx.x... |
2,863 | #include "includes.h"
__device__ __forceinline__ size_t gpu_fieldn_index(unsigned int x, unsigned int y, unsigned int d)
{
return (NX*(NY*(d-1)+y)+x);
}
__global__ void gpu_stream(double *f0, double *f1, double *f2, double *h0, double *h1, double *h2)
{
unsigned int y = blockIdx.y;
unsigned int x = blockIdx.x*blockDim.... |
2,864 | #include "includes.h"
__device__ unsigned int getGid3d3d(){
int blockId = blockIdx.x + blockIdx.y * gridDim.x
+ gridDim.x * gridDim.y * blockIdx.z;
int threadId = blockId * (blockDim.x * blockDim.y * blockDim.z)
+ (threadIdx.y * blockDim.x)
+ (threadIdx.z * (blockDim.x * blockDim.y)) + threadIdx.x;
return threadId;
}
_... |
2,865 | #pragma once
#include <cstdint>
#include <memory>
namespace freeform
{
} |
2,866 | #include <iostream>
#include <cstring>
#include <fstream>
#include "time.h"
using namespace std;
__host__ void preprocesamientoKMP(char* pattern, int m, int f[])
{
int k;
f[0] = -1;
for (int i = 1; i < m; i++){
k = f[i - 1];
while (k >= 0){
if (pattern[k] == pattern[i - 1])
... |
2,867 | #include <device_launch_parameters.h>
#include <cuda_runtime.h>
#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>
#include <math.h>
#include <stdlib.h>
//һκ˺üһCеԪ
void __global__ MVMulCUDA(float *A, float *B, float *C, int rowSize, int columnSize, int wA){
// Block index
int bx = blockIdx.x;
int by = bl... |
2,868 | #include <stdio.h>
#define N 40
__global__ void MatAdd(float *A, float *B, float *C) {
int i = threadIdx.x;
C[i] = A[i] + B[i];
}
size_t ind(int x, int y) {
return y * N + x;
}
int main() {
float A[N * N];
float B[N * N];
float C[N * N];
for (int i = 0; i < N; i++) {
for (int j... |
2,869 | #include "includes.h"
__global__ void gpu_array_2norm2_r4__(size_t arr_size, const float *arr, float *bnorm2)
/** Computes the squared Euclidean (Frobenius) norm of an array arr(0:arr_size-1)
INPUT:
# arr_size - size of the array;
# arr(0:arr_size-1) - array;
OUTPUT:
# bnorm2[0:gridDim.x-1] - squared 2-norm of a sub-ar... |
2,870 | #include <stdlib.h>
#include <stdio.h>
#include <cuda_runtime.h>
#include <math.h>
#include <iostream>
#include<fstream>
#define Pi 3.141516
#define Nthreads 32
using namespace std;
__global__ void Sinodails(double* cosine, double* sine, int tam){
int Id= threadIdx.x + blockDim.x* blockIdx.x;
if(Id<tam){
... |
2,871 | #include <stdlib.h>
#include <stdio.h>
#include <cstdlib>
#include <math.h>
#include <random>
#include <chrono>
#include <iostream>
class Particle
{
public:
float3 pos = make_float3(0,0,0);
float3 vel = make_float3(1,1,1);
Particle() {}
Particle(float3 velocity){
vel... |
2,872 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <cuda.h>
#define ROWS 4096
#define COLS 4096
__global__ void histo(int* d_hist1, int* d_hist2, int* mat) {
int id;
id = blockIdx.x * blockDim.x + threadIdx.x;
switch (d_hist1[id]) {
case 0:
atomicAdd(&mat[0], 1);
break;
case 1:
atomicAdd(&... |
2,873 | #include "includes.h"
__global__ void dot(int *a, int *b, int *c)
{
/* shared memory cache for partial sum results */
__shared__ int cache[THREADS_PER_BLOCK];
int i = blockIdx.x * blockDim.x + threadIdx.x;
int result = 0;
/* multiplication step: write a partial sum into the cache */
while(i < N)
{
result += a[i] * b[... |
2,874 | // fdk-ts-h.cu
#include <stdio.h>
void fdk_ts_help(void)
{
printf("\n\
\n\
image = function('fdk,ts,back', nx,ny,nz, dx,dy,dz, \n\
offset_x, offset_y, offset_z, mask2, \n\
dso, dsd, ds, dt, offset_s, offset_t, proj, beta, nthread)\n\
\n\
image output is single [nz nx ny] <- trick!\n\
nx,ny,nz: (int32) image ... |
2,875 | #include<stdio.h>
#include <cuda.h>
void random_ints(int* a, int N)
{
int i;
for (i = 0; i < N; ++i)
a[i] = rand()%100;
}
__global__ void add_vector(int* a,int* b,int*c)
{
int i = blockIdx.x*blockDim.x+ threadIdx.x;
c[i] = a[i] + b[i];
}
int main()
{
int N = 10000; //size of vector
int M = 10; //Number of th... |
2,876 | #include "includes.h"
__global__ void gPasteRows(float* out, const float* in, size_t cols, const size_t* targetRowIdx, size_t rows) {
for(int bid = 0; bid < rows; bid += gridDim.x) {
int j = bid + blockIdx.x;
if(j < rows) {
size_t dstId = targetRowIdx[j];
size_t srcId = j;
float* rowOut = out + dstId * cols;
const flo... |
2,877 |
extern "C" __global__ void multiply(unsigned int *a, unsigned int *b, unsigned int *c,
int n)
{
unsigned int i;
unsigned int product = 0;
int row = blockIdx.y * blockDim.y + threadIdx.y;
int col = blockIdx.x * blockDim.x + threadIdx.x;
if(row < n && col < n){
for (i = 0; i < n; i++)
product += a[row * ... |
2,878 | /* Histogram generation on the GPU.
* Host-side code.
* Author: Naga Kandasamy
* Date modified: May 17, 2020
*/
#include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>
#include <string.h>
#include <math.h>
#include <float.h>
#define THREAD_BLOCK_SIZE 256
#define NUM_BLOCKS 40
#define HISTOGRAM_SIZE 256 /... |
2,879 | #include<stdio.h>
#include<cuda.h>
#include <string.h>
#include <math.h>
#define MAXNUM 10000000000
#define BNUM 190
#define TNUM 1024
long long MakeNum(int *number,long long size){
int i,j,now=0;
for(i=0;i<size;i++)
number[i]=0;
number[2]=1;number[3]=1;
for(i=5,j=2;i<size;i+=j,j=6-j){
number[i]=1;
now++;
}/... |
2,880 | #include "includes.h"
__global__ void max_pooling_kernel(float *feature_map, float *probs, float *target, int feature_map_size, int feature_map_num, int pooling_rate, float *rnd_array, int rnd_num){
__shared__ float shFm[16*MAX_POOLING_RATE][16*MAX_POOLING_RATE];
int imgIdx = blockIdx.y / (feature_map_size / 16 / pool... |
2,881 | //本质上来说,几维的数组其实都是一维数组,不过是变变表现形式而已,二维数组加法没什么意思,
//就是一维数组加法,还是二维数组乘法有点意思
//这个方法,还不是高并发,高并发,应该是把求和那一块for也并发了。估计要用device,现在的并发度是4
#include<iostream>
#include<cuda.h>
using namespace std;
const int N=2;
__global__ void mul(int *a,int *b,int *c){//并发度为4的矩阵乘法
int row=blockIdx.x;
int col=threadIdx.x;
int temp_sum=0... |
2,882 | #include "stdlib.h"
#include "stdio.h"
#include <math.h>
#include <cuda.h>
const int max_val=100;
void generateArray(float* data, int size);
__global__
void vectAddKernel(float* A, float* B, float* C, int n){
int i = threadIdx.x+blockDim.x*blockIdx.x;
if (i<n){
*(C+i)=*(A+i)+*(B+i);
}
}
void vectorAdd(flo... |
2,883 | #include "includes.h"
#define N 2560
#define M 512
#define BLOCK_SIZE (N/M)
#define RADIUS 5
__global__ void add(double *a, double *b, double *c, int n){
int idx = threadIdx.x + blockIdx.x * blockDim.x;
if(idx < n){
c[idx] = a[idx] + b[idx];
}
} |
2,884 | #include <stdio.h>
#define RADIUS 3
#define BLOCK_SIZE 256
#define NUM_ELEMENTS (4096*2)
__global__ void stencil_1d_simple(int *in, int *out)
{
// compute this thread's global index
unsigned int i = blockDim.x * blockIdx.x + threadIdx.x + RADIUS;
int alpha = 1;
int beta = 1;
if(i < NUM_ELEME... |
2,885 | /*
(c) Matthew Lee
Spring 2019
MIT License
*/
#include <stdio.h>
#include <vector>
#include <math.h>
#include <iostream>
#include <time.h>
#include <curand.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <curand_kernel.h>
#include "barrier_options.cuh"
void down_out(unsigned N_STEPS, u... |
2,886 | #include "includes.h"
__global__ void columnarize_groups(int8_t* columnar_buffer, const int8_t* rowwise_buffer, const size_t row_count, const size_t col_count, const size_t* col_widths, const size_t row_size) {
const auto thread_index =
threadIdx.x + blockIdx.x * blockDim.x + blockIdx.y * blockDim.x * gridDim.x;
if (th... |
2,887 | #include <cuda.h>
#include <stdio.h>
#include <stdlib.h>
#define DataSize 1024
__global__ void Add(unsigned int *Da,int high,int width)
{
int tx = threadIdx.x;
int bx = blockIdx.x;
int bn = blockDim.x;
//int gn = gridDim.x;
int id = bx*bn+tx;
//for(int i=id;i<(high*width);i+=(bn*gn))
//Da[i... |
2,888 | /*#include <cuda_runtime.h>*/
#include <cuda.h>
#include <stdio.h>
__global__ void kernel_vecDotProduct(double* invSigmaMuDev, double* muDev, int fDim, int cbNum, double* resDev) {
int cbIdx = blockDim.x * blockIdx.x + threadIdx.x;
if (cbIdx < cbNum) {
double t = 0;
double* v1 = invSigmaMuDev + cbIdx * fDim;
d... |
2,889 | #include<cuda.h>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
#include <cstdlib>
#include <iostream>
#include <sstream>
__global__ void fillArray(double* array, int size, double value)
{
unsigned int i=threadIdx.x+blockIdx.x*blockDim.x;
if(i<size){
a... |
2,890 | #include "includes.h"
__global__ void backward_zero_nonmax_kernel(int n, int *indexes, float *prev_delta)
{
int id = (blockIdx.x + blockIdx.y*gridDim.x) * blockDim.x + threadIdx.x;
if (id >= n) return;
if (indexes[id] != id) prev_delta[id] = 0;
} |
2,891 | #include <cuda_runtime.h>
#include <cuda_fp16.h>
#include <iostream>
// constants for approximating the normal cdf
// gelu ->gelu_fast
constexpr static float A = 0.5;
constexpr static float B = 0.7978845608028654; // sqrt(2.0/M_PI)
constexpr static float C = 0.035677408136300125; // 0.044715 * sqrt(2.0/M_PI)
templa... |
2,892 | #include "curand_kernel.h"
#define seed 42
__global__ void kernel(double* outdata)
{
// curandStateXORWOW_t state;
curandStateMRG32k3a_t state;
int idx = blockIdx.x * blockDim.x + threadIdx.x;
curand_init(seed, idx, 0, &state);
outdata[idx] = curand_uniform(&state);
}
int main()
{
double* data;
cudaMalloc((vo... |
2,893 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <cuda.h>
#include <cuda_runtime.h>
#define N 10000000
#define MAX_ERR 1e-6
__global__ void vector_add(float* out,float* a,float* b,int n){
int index = threadIdx.x;
int stride = blockDim.x;
for(int i=index ; i<n ;i=i+stride){
ou... |
2,894 | #include <thrust/copy.h>
#include <thrust/remove.h>
#include <thrust/device_ptr.h>
#include <iostream>
#include <iterator>
#include <string>
// this functor returns true if the argument is negative, and false otherwise
struct is_negative
{
__host__ __device__
bool operator()(const int x)
{
return x... |
2,895 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
#define SIZE 128
#define THREADS 32
__global__ void squareWithForLoop(float * d_arr, size_t maxLoop, size_t increment)
{
float value;
size_t index;
size_t i;
index = threadIdx.x;
for (i = 0; i < maxLoop; ... |
2,896 | #include "includes.h"
__global__ void add(int *a, int *b, int *c, int n)
{
//blockDim.x represents threads per block
int index = threadIdx.x + blockIdx.x * blockDim.x;
// as we need to avoid to go beyond the end of the arrays, we need to define the limit
if (index < n)
c[index] = a[index] + b[index];
} |
2,897 | // =================================================================
//
// File: intro3.cu
// Author: Pedro Perez
// Description: This file shows some of the basic CUDA directives.
//
// Copyright (c) 2020 by Tecnologico de Monterrey.
// All Rights Reserved. May be reproduced for any non-commercial
// purpose.
//
// ==... |
2,898 | // Assignment For Module 03:
// Blocks, Warps and Threads
// Author: Justin Renga
#include <stdio.h>
#include <stdlib.h>
/// @brief The Kernel function that will execute on the GPU.
///
/// @param [inout] input1 The first input array (contains integers)
/// @param [inout] input2 The second input array (contain... |
2,899 | #include <math.h> // for abs
#include <stdio.h>
#include <stdint.h> // for uint8_t
#include <string.h>
#include <sys/time.h>
#include <stdlib.h>
// For the CUDA runtime routines (prefixed with "cuda_")
#include <cuda_runtime.h>
//using namespace std;
#define PIXEL uint8_t
#define H 288 // height of each frame
#defi... |
2,900 | #include <cuda_runtime.h>
#include<cassert>
#include<sys/time.h>
#include<time.h>
#include<stdio.h>
#include<string>
#include<sstream>
#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true)
{
if (code != cudaSuccess)
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.