serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
4,001 | #include <stdlib.h>
#include <stdio.h>
#include <time.h>
#define THREADS 256 // 2^9
#define BLOCKS 32 // 2^15
#define NUM THREADS*BLOCKS
int seed_var =1239;
int random_int()
{
return (int)rand()%(int)9 +1;
}
void array_fill(int *arr, int length)
{
srand(++seed_var);
int i;
for (i = 0; i < length; ++i) {
... |
4,002 | #pragma once
__global__ void
OmgSin_kernel(int numElement, const float *bufferin, float *bufferout)
{
// TODO make it u24
int blockId = blockIdx.y * gridDim.x + blockIdx.x;
int tid = threadIdx.x + blockId * blockDim.x;
int step = gridDim.x * blockDim.x;
//blockIdx.y * step + blockIdx.x * gridDim.x * bloc... |
4,003 | #include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <stdio.h>
#include <curand.h>
#include <curand_kernel.h>
#define BLOCK_SIZE 16
#define MAX_TRIANGLE 100
#define MAX_LIGHT 10
#define eps 0.0001
#define MAX_RAY_DEPTH 20
#define AAKERNEL_SIZE 6
using namespace std;
__device_... |
4,004 | #include<stdio.h>
#include <time.h>
#include <cuda.h>
// Forward Declarations
#define BLOCKSIZE 1024
#ifndef Nsize
#define Nsize 1024
#endif
void printArray(int k);
__global__ void add(int d_a[], int *d_answer);
int* a;
int answer;
int main(){
cudaError_t err;
int deviceCount;
err = cudaGetDeviceCount(&... |
4,005 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
// CUDA example: illustration of shared memory allocation at run time;
// finds primes using classical Sieve of Erathosthenes: make list of
// numbers 2 to n, then cross out all multiples of 2 (but not 2 itself),
// then all multiples of 3, etc.; whatever is l... |
4,006 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include "device_functions.h"
// #include <cufft.h>
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <time.h>
#include <cstdio>
using namespace std;
__global__ void countW(float * W)
{
float pi = 3.1415926535897932384626433832795;
int i... |
4,007 | __global__ void xT(float *a, float *b, const unsigned int X, const unsigned int Y)
{
int col = blockDim.x * blockIdx.x + threadIdx.x;
int row = blockDim.y * blockIdx.y + threadIdx.y;
if(row < Y && col < X) {
b[row * X + col] = a[col * Y + row];
}
}
|
4,008 | #include <cuda_runtime.h>
#include <cstdio>
#include <utility>
#include <cmath>
#include <vector>
#include <cstdio>
#include <utility>
enum class HeapType {
kMinHeap, kMaxHeap
};
enum class PreferIndices {
kLower, kHigher
};
struct Img {
float dist;
int imgid;
__device__ bool operator==(const Img& r) const {
... |
4,009 |
//Needs Header Files for the functions; The header file should have both C and CUDA functions
//This file uses 6 hourly data. Each day is 6 hours long and skipping a day means to add 6
//to the counter that counts the timesteps (l).
//The birds start at 00:00 UTC which is 6pm in central time examplewhen there is n... |
4,010 | /*
The programmer can not influence the order in which the blocks are run
Therefore this program has 16! different possible outputs
*/
#include <stdio.h>
#define NUM_BLOCKS 16
#define BLOCK_WIDTH 1
__global__ void hello() {
printf("Hello world! I'm a thread in block %d\n", blockIdx.x);
}
int main() {
// la... |
4,011 | /* Authors: Cameron Rutherford and Jude Battista
*
*
*/
#include <iomanip>
#include <iostream>
#include <random>
//CUDA Kernel
//Maps one thread to each output space
//Reduces the array once by a factor of reductionFactor
//Assumption: we have enough threads to span the output array for our given reductionFactor
... |
4,012 | #include <stdio.h>
static void HandleError(cudaError_t err,
const char *file,
int line) {
if (err != cudaSuccess) {
printf("%s in %s at line %d\n",
cudaGetErrorString(err),
file, line);
exit(EXIT_FAILURE);
}
... |
4,013 | __device__ static unsigned long xors_x = 123456789;
__device__ static unsigned long xors_y = 362436069;
__device__ static unsigned long xors_z = 521288629;
__device__ static unsigned long xors_w = 88675123;
__device__
unsigned long Xorshift128()
{
unsigned long t;
t = (xors_x^(xors_x<<11));
xors_x = xor... |
4,014 |
/* simple-device-query.cu */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <sys/time.h>
#include <cuda_runtime.h>
#define CHECK_CUDA_CALL(call) \
{ \
const cudaError_t error = call; \
\
if (error != cudaSuccess) { \
fprintf(stderr, "Error (%s:%d), code: %d,... |
4,015 | //xfail:BOOGIE_ERROR
//--blockDim=2 --gridDim=1 --no-inline
//Write by thread .+kernel.cu:8:4:
// to threadIdx.x != 0 we have 'data race'.
#include <cuda.h>
#include <curand.h>
#include <curand_kernel.h>
#include <stdio.h>
#define N 8 //2
__global__ void init_test(curandState *state, unsigned int *A) {
curand_ini... |
4,016 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <functional>
#include <curand_kernel.h>
#define threadsPerBlock 256
typedef double(*test_func_t)(double*, int, double);
__device__ double rastrigin_cuda(double *input, int size, double val) {
if (size == 0 && input == NULL) {
ret... |
4,017 | // Copyright (c) 2020 Saurabh Yadav
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <math.h>
#include <cuda_runtime.h>
#define MAT_A_TOTAL_ROWS 4U
#define MAT_A_TOTAL_COLS 5U
#define MAT_B_TOTAL... |
4,018 | #include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define N 33 * 1024
__global__ void add(int *a, int *b, int *c) {
int tid = threadIdx.x + blockIdx.x * blockDim.x;
while(tid < N) {
c[tid] = a[tid] + b[tid];
tid += blockDim.x * gridDim.x;
}
}
void handleError(cudaError_t error, int lineNo) {
... |
4,019 | #define COALESCED_NUM 16
#define blockDimX 128
#define blockDimY 1
#define gridDimX (gridDim.x)
#define gridDimY (gridDim.y)
#define idx (blockIdx.x*blockDimX+threadIdx.x)
#define idy (blockIdx.y*blockDimY+threadIdx.y)
#define bidy (blockIdx.y)
#define bidx (blockIdx.x)
#define tidx (threadIdx.x)
#define tidy (threadId... |
4,020 | #include "includes.h"
//!!nvcc -c test.cu --compiler-options -fPIC
//!g++ -o program -L/usr/local/cuda/lib64 main.cpp test.o -lcuda -lcudart
__global__ void sub(float *a,float *b,float *c)
{
*c = *a -*b;
} |
4,021 | //Alfred Shaker
//November 13th 2015
//Tiled matrix multiplication
#include <stdlib.h>
#include <stdio.h>
//tile dimention
#define TILE_DIM 32
//kernel function
__global__ void tileMatMul(float* matA, float* matB, float* matC, int aRows, int aCols,
int bRows, int bCols, int cRows, int cCols)
{
//define row an... |
4,022 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <math.h>
#include <cuda.h>
#define I 5000
#define J 2
#define BLOCKSIZEx 512
/*-Global variables-*/
struct timeval startwtime, endwtime;
double seq_time;
/**---Host function declarations---**/
int Blocks(int x, int b){ return ((x % b) != 0) ? (x ... |
4,023 | #include <iostream>
#include <string>
#include <fstream>
#include <vector>
int main(){
std::ifstream file("../data/512/img1.txt");
std::string value;
std::vector<unsigned char> ourImage (512*512);
unsigned int i = 0;
while(file.good() && i < 512*512){
std::getline(file, value, ',');
if(i==512*512) s... |
4,024 | #include <iostream>
#include <math.h>
#include <fstream>
#include <cuda.h>
//#define flouble float
#define flouble double
#define MAXITERATIONS 20000
using namespace std;
void aufg13a();
flouble* initMatrixRightHandSide(int n, flouble h );
flouble* jacobiIter(int n, flouble *f, flouble valBoundary, int* numberOf... |
4,025 | #define NODE_TERMINAL -1
#define NODE_TOSPLIT -2
#define NODE_INTERIOR -3
__global__ void predictKernel(const float *x, int n, int mdim, const int *treemap,
const int *nodestatus, const float *xbestsplit,
const int *bestvar, const int *nodeclass,
int nclass,
int ntree, int *countts, int m... |
4,026 | #include <iostream>
#include <cuda.h>
#include <stdlib.h>
#include <ctime>
using namespace std;
__global__ void AddInts(int *a, int *b, int count){
// Create a unique index for each thread
int id = blockIdx.x * blockDim.x + threadIdx.x;
// Check id if within the bounds of count and add only those items
if(id < co... |
4,027 | #include "includes.h"
__global__ void initvectors(double4 *acc3, float4 *apred){
int i = blockIdx.x*blockDim.x + threadIdx.x;
acc3[i].x = acc3[i].y = acc3[i].z = 0.0;
apred[i].x = apred[i].y = apred[i].z = 0.0f;
} |
4,028 | /* *********************************************************************
* DESCRIPTION:
* Serial Concurrent Wave Equation - C Version
* This program implements the concurrent wave equation
*********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <math.... |
4,029 | #include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
int numDevices;
cudaDeviceProp prop;
cudaError_t errorNum = cudaGetDeviceCount(&numDevices);
if(errorNum != cudaSuccess) {
printf("Could not get device count\n");
exit(EXIT_FAILURE);
}
printf("Number of CUDA capable devices ... |
4,030 | // Jin Pyo Jeon
// Lab 07
#include <cuda.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <math.h>
#define T 1024 // Shared needs to be known at compile time??
#define N (1024 * 1024)
// Times for Reduced and non-reduced dot product
// N Reduced Non-reduced Thread Count
// 2^27 8.95 8.91... |
4,031 | // CUDA libraries.
#include <cuda.h>
#include <cuda_runtime.h>
// Include associated header file.
#include "../include/kernels.cuh"
#include <stdio.h>
#include <iostream>
#include <cmath>
/**
* Point to point interaction calculation model. For this example, the interaction is simply adding the two terms.
* Howeve... |
4,032 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
__device__ void histogram(
void *input
)
{
uint * inputIn = (uint *) input;
uint byteCount = inputIn[0];
uint *d_Data = inputIn +1;
uint *d_Histogram = d_Data + byteCount;
//printf("Thread #: %d\n",threadIdx.x);
int i = thr... |
4,033 |
#include "CPreviousStateLookupTable.cuh"
#include "CStateLookupTable.cuh"
CPreviousStateLookupTable::CPreviousStateLookupTable(unsigned int const p_cnK) :
CStateLookupTable(p_cnK
#ifdef _USE_CUDA_
, LookupTableType_Prev // Set table type
#endif
), m_cnMaxState(GetMaxState(m_cnMemory))
{
}
CPreviousStateLo... |
4,034 | #include "includes.h"
/**
* Various matrix utils using cuda
**/
/**
* Kronecker product of two matrices kernel
* input :
* a : first matrix
* nax, nay : matrix a dimensions
* b: second matrix
* nbx, nby : matrix b dimensions
* results : kronecker product of a and b
**/
__global__ void kronecker(double * a, int nax, ... |
4,035 | #include <stdio.h>
int main() {
FILE *outfile;
int nDevices;
//output file pointer
outfile = fopen("ee16b068_1.txt", "w");
cudaGetDeviceCount(&nDevices);
for (int i = 0; i < nDevices; i++) {
cudaDeviceProp prop;
cudaGetDeviceProperties(&prop, i);
//
printf("De... |
4,036 | /**
* Inaki Urruta Sanchez
* Pedro Alexandre Simoes dos Reis
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#define BLOCK_SIZE 16
/**
* Initialize matrix M with dimension dim with n in all matrix's entries
*/
void initWith(float* M, int dim, float n) {
for (int i = 0; i < dim... |
4,037 | /***************************************************************************//**
* \file intermediatePressure.cu
* \author Christopher Minar (minarc@oregonstate.edu)
* \brief kernels to generate the right hand side of the poission equation
*/
#include "intermediatePressure.h"
/**
* \namespace kernels
* \brief C... |
4,038 | #include <cuda.h>
#include <stdio.h>
#include <sys/time.h>
#include <sys/resource.h>
// Tipo de los datos del algoritmo
typedef int data_t;
// Prototipos
data_t add(const data_t a, const data_t b) { return a + b; }
data_t sub(const data_t a, const data_t b) { return a - b; }
void init_matrix(data_t *M, const un... |
4,039 | extern "C"
__global__ void memSetKernel(
int nBatch,int rbs,int nDegree,int nDScale, int dbStopIdx,int dBaseScale, float regularize,
float *data,float *dataRev, // array of data and reverse data
float *R, // array of range
// arrays pointer
float *DA, float *RA,
float *AA, float *BA,
float *IA, float *CA,
float *EA, f... |
4,040 | /**
MIT License
Copyright (c) 2018 NVIDIA CORPORATION. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, co... |
4,041 | #include <time.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
void CPUEuler2(int m, float* y_i, float delta_t,float t_i ){
for (int i=0;i<m+1;i++){
y_i[i]=y_i[i]+delta_t*(4*t_i-y_i[i]+3+i);
}
}
int main(int argc, char const *argv[])
{
printf("seccion 2.a\n");
for (int j=4... |
4,042 | #include <stdio.h>
#include <stdlib.h>
#define ERR(call) \
{ \
cudaError_t err = call; \
\
if (err != cudaSuccess) \
{ \
fprintf(stderr, "ERROR: CUDA failed in %s:%d: %s\n", __FILE__, __LINE__, cudaGetErrorString(err)); \
exit(0); \
} \
}
__global__ void kernel(double* dA, double* dB, double* dC, int n);
in... |
4,043 | #include <vector_types.h>
#include <cuda_runtime.h>
__global__ void kernel_smooth(unsigned char *rgb, int w, int h, unsigned char *rgb_out) {
unsigned int x = blockDim.x * blockIdx.x + threadIdx.x;
unsigned int y = blockDim.y * blockIdx.y + threadIdx.y;
if (x < 1 || x > w-1 || y < 1 || y > h-3){
r... |
4,044 | /*!
\file global.cu
\author Andrew Kerr <arkerr@gatech.edu>
\brief verifies a CUDA application's ability to use global symbols
\date Feburary 12, 2010
*/
#include <stdio.h>
__device__ float Pi;
extern "C" __global__ void copyFromGlobal(float *result) {
int i = threadIdx.x + blockDim.x * blockIdx.x;
result[i] ... |
4,045 | #include <cuda.h>
#include <stdio.h>
__global__ void fact_kernel()
{
int n = threadIdx.x;
if (n != 0)
{
int fact = 1;
for (int i = 1; i <= n; i++)
{
fact *= i;
}
printf("%d!=%d\n", n, fact);
}
}
int main()
{
const int num_threads = 9;
fact_ke... |
4,046 | /* Host side code that calls a GPU kernel to perform vector addition on the GPU using a single thread block.
We restrict the size of the vector to be up to 512 elements which is the maximum thread block size on this
GPU.
Author: Naga Kandasamy, 02/14/2017
*/
#include <stdlib.h>
#include <stdio.h>
#include <strin... |
4,047 | // GPU Kernel
__global__ void big_add(int *a, int *b, int *c, unsigned int N){
// init thread id
int tid;
tid = blockIdx.x * blockDim.x + threadIdx.x;
// stride is for big arrays, i.e. bigger than threads we have
int stride = blockDim.x * gridDim.x;
// do the operations
while(tid < N){
... |
4,048 | #include "includes.h"
__global__ void vecAdd(float * in1, float * in2, float * out, int len) {
//@@ Insert code to implement vector addition here
} |
4,049 | /*
* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use... |
4,050 | #include <stdio.h>
#include <cuda.h>
#include <cuda_runtime_api.h>
int main() {
int nDevices, i;
cudaGetDeviceCount(&nDevices);
printf("There are %d CUDA devices. \n", nDevices);
for (i = 0; i < nDevices; i++) {
cudaDeviceProp prop;
cudaGetDeviceProperties(&prop, i);
printf("D... |
4,051 | /*
* SPDX-FileCopyrightText: Copyright (c) 1993-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the Lic... |
4,052 | #include "includes.h"
__global__ void rgb2grayKernel(unsigned char *imgr,unsigned char *imgg,unsigned char *imgb,unsigned char *img_gray, int n) {
int r, g, b;
int index = threadIdx.x + blockIdx.x * blockDim.x;
if (index < n){
r = imgr[index];
g = imgg[index];
b = imgb[index];
img_gray[index] = (unsigned char)( 0.29... |
4,053 | // matrix multiplication between square matrices using bidimensional indexes.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/time.h>
#define SIZE 4 //2048
#define NUM_THREADS 2 //512
#define NUM_BLOCKS SIZE / NUM_THREADS
double cclock()
/* Returns ... |
4,054 | #include <cuda_runtime.h>
#include <iostream>
#include <ctime>
#include "device_launch_parameters.h"
#include <limits.h>
#define PRINT_MATRIX true
#define CHECK(value) {\
cudaError_t _m_cudaStat = value;\
if (_m_cudaStat != cudaSuccess) {\
cout<< "Error:" << cudaGetErrorString(_m_cudaStat) \
... |
4,055 | #include "material.cuh"
namespace crt {
Material::Material(float3 _color,
float _diffuse,
float _reflection,
float _refraction,
float _refractionIndex,
float _emission)
: color(_color)
, diffuse(_diffuse)
, reflection(... |
4,056 | #include <iostream>
__device__ int memr[2048];
__device__ int memg[2048];
__device__ int memb[2048];
__shared__ int mem_out[2048];
__global__ void func() {
int i = blockIdx.x * 256 + threadIdx.x;
// This line is different from the line in our presentation,
// but it works similarly and yields similar results.
mem... |
4,057 | #include <bits/stdc++.h>
#include <cuda.h>
#include <curand.h>
#include <curand_kernel.h>
using namespace std;
using namespace std::chrono;
int *edge_array,*edge_array_parent,*vertex_array,*vertex_array_parent,*start_interval,*end_interval;
bool *is_leaf;
int counter=0;
__global__ void BFS(int* off,int* edge,int* cur... |
4,058 | #include "includes.h"
__global__ void CalculateFixed( const float *background, const float *target, const float *mask, float *fixed, const int wb, const int hb, const int wt, const int ht, const int oy, const int ox ){
const int dir[4][2] = { {0, -1}, {1, 0}, {0, 1}, {-1, 0}};
int num = 4;
const int yt = blockIdx.y * b... |
4,059 | #include "transform.cuh"
#include <cuda_runtime.h>
#define CHECK(res) { if(res != cudaSuccess){printf("Error :%s:%d , ", __FILE__,__LINE__); \
printf("code : %d , reason : %s \n", res,cudaGetErrorString(res));exit(-1);}}
__global__ void cudaVectorAdd(const int *A,const int *B,int * C,int numElements)
{
int i =... |
4,060 | #include "includes.h"
using namespace std;
void showMatriz(int *matriz, int anchura, int altura);
void generateSeeds(int *matriz, int ancho, int alto, int cantidad, char modo);
void gestionSemillas(int *matriz, int ancho, int numeroSemillas, int alto, char modo);
int checkFull(int *matriz, int tamano);
bool checkMov... |
4,061 | #include "includes.h"
__global__ void CalcInput(float* screen, float* weight, float* d_Votes, int stride){
//Current implementation, idk if it works. Probably doesn't, but it is worth a try, I think.
int id = threadIdx.x + blockDim.x * blockIdx.x;
d_Votes[id] = 0;
d_Votes[id] += screen[id] * weight[id];
d_Votes[id] ... |
4,062 | #include "includes.h"
extern "C" {
#ifndef REAL
#define REAL float
#endif
#ifndef CAST
#define CAST(fun) fun ## f
#endif
#ifndef REAL2o3
#define REAL2o3 (REAL)0.6666666666666667
#endif
#ifndef REAL3o2
#define REAL3o2 (REAL)1.5
#endif
... |
4,063 |
extern "C" __global__
void histgramMakerKernel_SharedMemAtomics2(int *d_histgram,
const uchar4* d_text4, int textLength4) {
__shared__ int sh_histgram[256];
for (int shPos = threadIdx.x; shPos < 256; shPos += blockDim.x)
sh_histgram[shPos] = 0;
__syncthreads();
int stride = gridDim.x * blockDim.x;... |
4,064 | #include <cuda.h>
#include <cuda_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define CHECK(call) \
{ \
cudaError_t err = call; \
if (err != cudaSuccess) \
{ \
fprintf(stderr, "Failed with error code %s\n", cudaGetErrorString(err)); \
exit(EXIT_FAILURE); \
} \
}
... |
4,065 | #include "includes.h"
__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 = threadIdx.x;
int ty = threadIdx.y;
int Row = by * TILE_WIDTH + ty;
int... |
4,066 | #include <stdio.h>
__global__ void helloGPU(void)
{
printf(" From thread %d : Sugan Nalla - GPU ! \n ", threadIdx.x);
}
int main(void)
{
// From CPU
printf(" Sugan Nalla - CPU ! \n ");
helloGPU <<< 1, 10 >>>();
cudaDeviceReset();
return 0;
}
|
4,067 | #include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#define TILED 16
__global__ void matrix_mult(int *a,int *b, int *c, int m, int n, int k)
{
int row = blockIdx.y * blockDim.y + threadIdx.y;
int col = blockIdx.x * blockDim.x + threadIdx.x;
int sum = 0;
if( col < k && row < m)
{
fo... |
4,068 | #include <stdio.h>
int main()
{
int nDevices;
// Gets properties of all installed NVIDIA GPUs.
cudaGetDeviceCount(&nDevices);
for (int i = 0; i < nDevices; i++)
{
cudaDeviceProp prop;
cudaGetDeviceProperties(&prop, i);
printf("Device Number: %d\n", i);
printf(" Device name: %s\n", prop.name);
printf... |
4,069 | #include "cuda_vec_do.h"
int main(int argc, const char *argv[]) {
return cuda_vec_do(argc,argv);
}
|
4,070 | // Check that -fsanitize=foo doesn't get passed down to device-side
// compilation.
//
// REQUIRES: clang-driver
//
// RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 -fsanitize=address %s 2>&1 | \
// RUN: FileCheck %s
// CHECK-DAG: "-fcuda-is-device"
// CHECK-NOT: "-fsanitize=address"
// CHECK-DA... |
4,071 | #include <stdio.h>
int main() {
int nDevices;
cudaGetDeviceCount(&nDevices);
for (int i = 0; i < nDevices; i++) {
cudaDeviceProp prop;
cudaGetDeviceProperties(&prop, i);
printf("Device Number: %d\n", i);
printf(" Device name: %s\n", prop.name);
printf(" Memory Clock Rate (KHz): %d\n",
... |
4,072 | #include<cuda_runtime.h>
#include<cstdio>
#include<iostream>
int main(){
cudaStream_t cpu2gpu, gpu2cpu;
cudaStreamCreate(&cpu2gpu);
cudaStreamCreate(&gpu2cpu);
cudaEvent_t cpu2gpu_event, gpu2cpu_event;
cudaEventCreate(&cpu2gpu_event);
cudaEventCreate(&gpu2cpu_event);
int size = 1000 * 100... |
4,073 | #include <iostream>
#include <math.h>
#define BLOCK_SIZE 32
__global__ void add(int n, float **x, float **y) {
int i = BLOCK_SIZE * blockIdx.x + threadIdx.x;
int j = BLOCK_SIZE * blockIdx.y + threadIdx.y;
if (i < n && j < n){
y[i][j] += x[i][j];
}
}
int main(void) {
int N = 1 << 10... |
4,074 | #include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <bits/stdc++.h>
#define cudaErrCheck(call) { \
cudaError_t err = call; \
if( cudaSuccess != err) { ... |
4,075 | /*
This follows the guide provided on https://developer.nvidia.com/blog/even-easier-introduction-cuda/
Any clarifications needed pls refer to the guide
*/
#include <iostream>
#include <math.h>
#include <time.h>
#include "cuda_runtime.h" //headers for the cuda methods
#include "device_launch_parameters.... |
4,076 | #include <new>
struct Foo
{
int value = 0x1234;
};
__global__ void kernel_simple(Foo* storage, Foo** initialized)
{
Foo* start = storage + threadIdx.x * 2;
start[0].value = 0x1234;
start[1].value = 0x1234;
initialized[threadIdx.x] = start;
}
|
4,077 | #include "includes.h"
__device__ float in1[ 1000 ]; __device__ __constant__ float in2[ 1000 ]; __global__ void vecadd( float *out, int N ) {
int idx= blockDim.x * blockIdx.x + threadIdx.x;
if( idx < N ) {
out[idx] =in1[idx] + in2[idx];
}
}
__global__ void vecadd( float *in1, float *in2, float *out, int N ) {
int idx= ... |
4,078 | /*******************************************************************************
Project
This project showcases how to use CUDA signal processing library to perform
stpectrum analysis.
This code read in In phase and Quadrature data from the file, performs spectrum
analysis on the data and extracts the range and spee... |
4,079 | #include "includes.h"
__global__ void saxpy_float4s_shmem ( float* y, float* x, float a, clock_t * timer_vals)
{
volatile __shared__ float sdata_x0 [COMPUTE_THREADS_PER_CTA];
volatile __shared__ float sdata_x1 [COMPUTE_THREADS_PER_CTA];
volatile __shared__ float sdata_x2 [COMPUTE_THREADS_PER_CTA];
volatile __shared__ f... |
4,080 | // INCLUDES
#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <iostream>
#include <time.h>
// FUNCTION DEFINITIONS
__global__ void nn_diff(double* input,double* weight, double* output, int column_size);
// DEFINES
#define SIZE 8
#define C... |
4,081 | /**
* @file : cg_eg.cu
* @brief : Examples of using cooperative groups
* @details : cooperative groups for CUDA examples
*
* @author : Ernest Yeung <ernestyalumni@gmail.com>
* @date : 20170104
* @ref : https://devblogs.nvidia.com/parallelforall/cooperative-groups/
*
* https://www.paypal.com/cg... |
4,082 | #include "includes.h"
__global__ void grayscale(unsigned char * data_rgb, unsigned char * data_gray, std::size_t rows, std::size_t cols)
{
auto i = blockIdx.x * blockDim.x + threadIdx.x;
auto j = blockIdx.y * blockDim.y + threadIdx.y;
if( i < cols && j < rows )
{
data_gray[ j * cols + i ] = (
307 * data_rgb[ 3 * (j * ... |
4,083 | // fircu_cu.txt template file, version: 01_01_01
// GENERATED FILE! MODIFY THIS FILE ONLY AT YOUR OWN RESPONSIBLITY!
// An identical behaviour to the simulation results can be assured only if this file remains unchanged!
// Code file of a general CUDA (R) FIR filter implementation
#include "fircu.cuh"
template<typena... |
4,084 | //xfail:REPAIR_ERROR
//--blockDim=32 --gridDim=1
#include <cuda.h>
__global__ void race (int* A)
{
int tid = threadIdx.x;
int bid = blockIdx.x;
int idx = blockDim.x * bid + tid;
if (idx % 2 == 0)
{
int temp = A[idx + 2];
A[idx] = temp;
}
} |
4,085 | #include "includes.h"
__global__ void vecAdd(float *in1, float *in2, float *out, int len) {
int i = threadIdx.x + (blockDim.x * blockIdx.x);
//@@checking boundary condition and adding vectors
if (i < len)
out[i] = in1[i] + in2[i];
} |
4,086 | #include <stdio.h>
#include <unistd.h>
#include "cuda.h"
void checkCUDAError(const char *msg)
{
cudaError_t err = cudaGetLastError();
if( cudaSuccess != err){
fprintf(stderr, "Cuda error: %s: %s.\n", msg, cudaGetErrorString(err));
exit(-1);
}
}
__global__ void myFi... |
4,087 | #include <stdio.h>
inline __host__ __device__ float dot(float3 a, float3 b)
{
return a.x * b.x + a.y * b.y + a.z * b.z;
}
inline __host__ __device__ float length(float3 v)
{
return sqrtf(dot(v, v));
}
const float G = 6.6742867e-5f;
__global__ void simGlobalStep(float3* pos, float3* vel, int total) {
int i... |
4,088 | /*
* Please write your name and net ID below
*
* Last name: Adam
* First name: Steven
* Net ID: sna219
*
*/
/*
* Compile with:
* nvcc -o genprimes genprimes.cu
*/
#include <cuda.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <string>
#include <math... |
4,089 | #include<cstdio>
#include<cassert>
__global__ void doit() {
auto nt = blockDim.x;
__shared__ int x[2048];
x[threadIdx.x]=1;
x[threadIdx.x+nt]=1;
__syncthreads();
int nl=0;
while (__syncthreads_and(nt)) {
if(threadIdx.x>=nt) continue;
++nl;
x[threadIdx.x]+=x[threadIdx.x+nt];
nt = nt/2;
}
... |
4,090 | //Parallelization - several blocks - several threads + balance
#include<stdio.h>
#include<time.h>
#include<sys/time.h>
#define N 100000
#define M 8 //Threads per block
__global__ void add(int *a, int *b, int *c, int n)
{
int index = threadIdx.x + blockIdx.x * blockDim.x;
if(index<n)
c[i... |
4,091 | // The pentanomial to be used as an irreducible.
__constant__ unsigned int pentanomialCoefficients[5];
|
4,092 | __global__ void wave1Dmac2(double * f_next, double * f_tmp1,
double * f_in, double u, double dt,
double dx, 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;
double ft1_tmp = f_tmp1[tid];
f_next[tid]=0.5*(f_in[tid]+ft1_tmp - u*(dt/dx)*(ft... |
4,093 | //
// Created by jgibson37 on 2/10/20.
//
#include "../Generic-Library/include/A.cuh"
#include "../Generic-Library/include/B.cuh"
#include "../Generic-Library/include/C.cuh"
//#include "../Generic-Library/include/BB.cuh"
//#include "../Generic-Library/include/CC.cuh"
#include <iostream>
int main() {
//std::cout << ... |
4,094 | #include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
//#include <cutil.h>
#define CUDA_SAFE_CALL(x) (x);
#define CUT_CHECK_ERROR(x) ;
#define D2F_AND_COPY(n,host_mem,device_mem,float_mem) \
for(int i=0;i<(n);i++) ((float *)(float_mem))[i]=(host_mem)[i];\
CUDA_SAFE_CALL(cudaMalloc((void **)&... |
4,095 | //errorcheck_soln.cu: This program is designed to produce output
//'data = 7'. Error checking has been added and all errors have
//been removed.
#include <stdio.h>
#include <stdlib.h>
#define CUDA_ERROR_EXIT_CODE 1
__global__ void setData(int *ptr)
{
*ptr = 7;
}
static void checkCUDAError(cudaError_t error, const... |
4,096 | #include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
//handle when there millions of elements for vectors to be processed
__global__ void sum_array_gpu_long(int *a,int *b,int *c,int size)
{
int tid = threadIdx.x + blockIdx.x * blockDim.x;
w... |
4,097 |
#include <cstdio>
#include "../include/kernel.cuh"
__global__ void cuda_element_add (const float *A, const float *B, float *C, int length) {
int i = blockDim.x * blockIdx.x + threadIdx.x;
if (i < length) {
C[i] = A[i] + B[i];
}
}
__global__ void cuda_element_add_patch (const float *A, const... |
4,098 | float h_A[]= {
0.9857256709211897, 0.7478611782748985, 0.8448693389656563, 0.6129309395192508, 0.941933539703407, 0.9205863183795332, 0.7174586806278428, 0.5750123409946755, 0.8123382165246953, 0.8380199834599251, 0.8497058722729396, 0.5995508061235055, 0.9817894907268603, 0.6705828034531081, 0.9606496034803618, 0.9294... |
4,099 | #include <stdio.h>
#include <stdlib.h>
__global__ void colonel(int *d_a) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
printf("Before %d, %d, %d, index = %d, *d_a = %d\n", blockIdx.x, blockDim.x,
threadIdx.x, index, *d_a);
atomicAdd(d_a, index);
printf("After %d, %d, %d, index = %d, *d_a = %d\n... |
4,100 | #include "includes.h"
__global__ void matrix_multiply_simple(float *a, float *b, float *ab, size_t width)
{
//TODO: write the kernel to perform matrix a times b, store results into ab.
// width is the size of the square matrix along one dimension.
int row = blockIdx.y*blockDim.y + threadIdx.y;
int col = blockIdx.x * bl... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.