serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
20,701 | #include <stdio.h>
__device__ void VecAdd ( void* param1)
{
// warp hard coded
int warp_size = 32;
// unbox params
float* mem = (float*)param1;
int size = (int)mem[0];
int As = (int)mem[1];
float *A = mem+2;
float* C = A + As*size;
//C[tid] = A1[tid] + A2[tid] + A3[tid] + ...;
int... |
20,702 | #include "mat-rvect-add.hh"
#include "graph.hh"
#include "../runtime/graph.hh"
#include "../runtime/node.hh"
#include "../memory/alloc.hh"
namespace ops
{
MatRvectAdd::MatRvectAdd(Op* left, Op* right)
: Op("mat_rvect_add", left->shape_get(), {left, right})
{}
void MatRvectAdd::compile()
{
... |
20,703 | //#include <stdio.h>
//#include "Cublas.h"
//
//
//// Allocates a matrix with random float entries.
//void randomInit(float *data, int size)
//{
// for (int i = 0; i < size; ++i)
// data[i] = rand() / (float)RAND_MAX;
//}
//
//
//////////////////////////////////////////////////////////////////////////////////
//// Pro... |
20,704 | #include <stdio.h>
#include <cuda.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
__global__ void mul( float *Ad, float *Bd, float *Cd, int msize, int tile, int task);
int main( int argc, char **argv){
// argv[0]: name, argv[1]: msize, argv[2]: tile_width/ per block, argv[3]: task per thread, argv[4]: ... |
20,705 | #include "distance_matrix.cuh"
/**
* @brief Get the value of the (`i`, `j`) element in the distance matrix.
* @param i The row of the element.
* @param j The column of the element.
* @return The value of the (`i`, `j`) element in the distance matrix.
*/
template<class T>
T DistanceMatrix<T>::at(uint32_t i, uint32... |
20,706 | #include "includes.h"
using namespace std;
void KNearestNeighborsCPU(float3 *dataArray, int *result, int cnt);
// cpu algorithm
__global__ void KNearestNeighborsGPU(float3 *dataArray, int *result, int cnt)
{
int id = blockIdx.x * blockDim.x + threadIdx.x;
if (id >= cnt) return;
float3 point = dataArray[id], current... |
20,707 | #include <stdio.h>
#include<sys/time.h>
#include<math.h>
#define N 8192
#define nth 1024
__global__ void fast_transpose(size_t* A, size_t* B){
__shared__ size_t Ablock[nth];
__shared__ size_t Bblock[nth];
size_t dimx=blockDim.x;
size_t dimy=blockDim.y;
//dimx=linear dimension in x of a subma... |
20,708 | #include "includes.h"
__global__ void k1( float* g_dataA, float* g_dataB, int floatpitch, int width)
{
extern __shared__ float s_data[];
// TODO, implement this kernel below
unsigned int y = blockIdx.y * blockDim.y + threadIdx.y;
y = y + 1; //because the edge of the data is not processed
// global thread(data) column i... |
20,709 | /* ==================================================================
Programmer: Yicheng Tu (ytu@cse.usf.edu)
The basic SDH algorithm implementation for 3D data
To compile: nvcc SDH.c -o SDH in the C4 lab machines
==================================================================
*/
#include <stdio.h>
#in... |
20,710 | #include <stdio.h>
__global__ void hello() {
printf("Hello, CUDA! Thread [%d] in block [%d]\n", threadIdx.x, blockIdx.x);
}
int main( int argc, char** argv ) {
hello<<<1,1>>>(); // asynchronous call!
cudaDeviceSynchronize(); // wait for all operations on the GPU to finish
return 0;
}
|
20,711 | #include <cuda.h>
#include <cuda_runtime.h>
#include "stdio.h"
#define TILE_SIZE 64
#define WARP_SIZE 32
extern "C" void CSR_matvec(int N, int nnz, int* start, int* indices, float* data, float* x, float *y, bool bVectorized);
extern "C" void CSR_create(int N, int nnz, int* start, int * indices, float * data , float *... |
20,712 | #include "includes.h"
__device__ double dnorm(float x, float mu, float sigma)
{
float std = (x - mu)/sigma;
float e = exp( - 0.5 * std * std);
return(e / ( sigma * sqrt(2 * 3.141592653589793)));
}
__global__ void dnorm_kernel(float *vals, int N, float mu, float sigma)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
... |
20,713 | #include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
__global__
void mish_gridstride(int n, float* tx, float* aten_mul) {
for (int i = (threadIdx.x + blockDim.x * blockIdx.x) * 4; i < n; i += gridDim.x * blockDim.x * 4) {
float4 tx4 = __ldg(reinterpret_cast<float4*>(tx + i));
tx4.x =... |
20,714 | /**
* CUDA organizes execution into grids. Each device contains grids. Each grid
* contains blocks. Each block contains threads.
* Device[id]->Grid[id]->Block[id]->Thread[id].
*/
__global__ void OrgKernel(void * in, void * out, int size) {
// block and grid dimensions describe how large the execution grid/block i... |
20,715 | // matrix vector multiplecation
#include <chrono>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std::chrono;
#define NUM_THREADS_PERBLOCK 128
// the macro to check the cudaAPI return code
#define cudaCheck(error) \
if (error != cudaSucc... |
20,716 | /* Andrew Miller <amiller@dappervision.com>
*
* Cuda 512*512*512*4bytes test
*
* According to the KinectFusion UIST 2011 paper, it's possible
* to do a sweep of 512^3 voxels, 32-bits each, in ~2ms on a GTX470.
*
* This code is a simple benchmark accessing 512^3*2 short ints.
* voxel has two 16-bit components... |
20,717 |
inline void fill_host(int *h_v, int value, int m){
for (int i = 0; i < m; i++)
h_v[i] = value;
return;
}
|
20,718 | #include <stdio.h>
#include <stdint.h>
int main(){
int *a = (int *) malloc(sizeof(int));
int b = reinterpret_cast<uintptr_t>(a);
int *c = reinterpret_cast<int *>(b);
printf("%p %x %p\n", a, b, c);
free(a);
return 0;
}
|
20,719 | #include "includes.h"
__global__ void gpu_seqwr_kernel(int *buffer, size_t reps, size_t elements)
{
for(size_t j = 0; j < reps; j++) {
size_t ofs = blockIdx.x * blockDim.x + threadIdx.x;
size_t step = blockDim.x * gridDim.x;
while(ofs < elements) {
buffer[ofs] = 0;
ofs += step;
}
}
} |
20,720 | __device__ float sigmoid (float x)
{
return 1.0 / (1.0 + expf (-x));
}
extern "C"
__global__ void sigmoidKernel (int length, float *source, float *destination)
{
int index = blockDim.x * blockIdx.x + threadIdx.x;
if(index < length) {
destination[index] = sigmoid(source[index]);
}
} |
20,721 | #include <stdio.h>
#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", cudaGetErrorString(code), file, line);
if (abort) exit(code);
... |
20,722 | #include <iostream>
#include <vector>
#include <string.h>
//#include <stdio.h>
//#include <sys/types.h>
//#include <unistd.h>
using namespace std;
/*string* word(string s)
{
string[] word_array = new string[20];
for(auto x: s)
{
if(x == ' ')
{
}
}
}*/
int main()
{
cout << "Hello" ... |
20,723 | #include <cuda.h>
#include <stdio.h>
#include <cuda.h>
#include <curand_kernel.h>
#include <time.h>
__global__ void initPRNG(int seed, curandState *rngState)
{
unsigned int tid = threadIdx.x + blockIdx.x*blockDim.x;
curand_init(seed, tid, 0, &rngState[tid]);
}
__global__ void generate_uniform_int(int n, int *... |
20,724 | #include "cuda.h"
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sys/time.h>
void print_matrix(int* states, int n)
{
std::cout << "matrix:" << std::endl;
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < n; ++j)
{
std::cout << states[i*n+j] << " ";
}
std::cout << std::endl;
}
}
/... |
20,725 | #include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <tiffio.h>
#include <stdint.h>
__global__ void greyscale(uint8_t *d_out, uint8_t *d_in){
int id = blockIdx.x*blockDim.x+threadIdx.x;
if(id%3 == 0)
d_out[id] = 0.299f * d_in[id] + 0.587f * d_in[id+1] + 0.114f * d_in[id+2];
else if(id%3 == 1)
d... |
20,726 | #include "includes.h"
using namespace std;
long long remaining_N2(int , int ,long long );
long long remaining_N(int , int ,int );
__global__ void ker2(float * cormat, float * upper,int n1,int n,long long upper_size,int N,int i_so_far,long long M1)
{
long long idx = blockDim.x;
idx*=blockIdx.x;
idx+=threadIdx.x;
long i... |
20,727 | #include <stdio.h>
#include <stdlib.h>
#define N 16
extern __global__
void cudaMatMul(int C[N][N], int A[N][N], int B[N][N], int n);
int main(int argc, char** argv)
{
int* A[N];
int* B[N];
// result
int* C[N];
// cuda guys
int* A_c[N];
int* B_c[N];
int* C_c[N];
// cuda result placed in this value
int* ... |
20,728 | #include "includes.h"
__global__ void copyBiasToOutputs(float *ptrbias, float *ptroutput, const int size1, const int size2, const int nOutputPlane, const int linestride, const int imstride)
{
// each thread has a value to manage...
//const int blk =blockDim.x;
const int tidx=blockDim.x*blockIdx.x + threadIdx.x;
const i... |
20,729 | #include <stdio.h>
#include <math.h>
#include <time.h>
void add(int n, float* x, float* y) {
for(int i = 0; i < n; ++i)
y[i] += x[i];
}
void add(int x_size, int y_size, int z_size, float*** t1, float*** t2) {
for(int x = 0; x < x_size; ++x)
for(int y = 0; y < y_size; ++y)
for(int z = 0; z < z_size... |
20,730 | #include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <cuda.h>
__host__ void init_vects(int vect_len,float *h_vect1,float *h_vect2);
__global__ void vec_add(int vect_len, float *d_vect1, float *d_vect2, float *d_sum);
int main(int argc,char **argv)
{
cudaEvent_t start=0;
cudaEvent_t stop=0;
float time=0;
... |
20,731 | // (c) Copyright 2013 Lev Barash, Landau Institute for Theoretical Physics, Russian Academy of Sciences
// This is supplement to the paper:
// L.Yu. Barash, L.N. Shchur, "PRAND: GPU accelerated parallel random number generation library: Using most reliable algorithms and applying parallelism of modern GPUs and CPUs".
/... |
20,732 | #include <iostream>
#include <fstream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
__global__ void index_kernel( int* a, int N){
int blockId = blockIdx.x + blockIdx.y * gridDim.x + gridDim.x * gridDim.y * blockIdx.z;
int threadId = blockId * (blockDim.x * blockDim.y * b... |
20,733 | #include "stdio.h"
#include <limits>
#include <iostream>
#include <chrono>
__global__ void GPU_SAXPY(int n, float *x, float a, float* y) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
if (index < n) y[index] = a * x[index] + y[index];
}
void CPU_SAXPY(int n, float *x, float a, float * y) {
for (int i = ... |
20,734 | #include <stdio.h>
#define NUM_THREADS 1000000
#define ARRAY_SIZE 100
#define BLOCK_WIDTH 1000
//------------------------------------------------------------------------------
void print_array(int *array, int size) {
printf("{ ");
for (int i=0; i<size; i++) {
printf("%d ", array[i]);
}
printf(" }");
}
... |
20,735 | #include <random>
#include <cuda.h>
#include <stdio.h>
#include <curand.h>
#include <time.h>
int main()
{
curandGenerator_t gen;
// default (WOWXOR) or Mersenne-Trister pseudo random number generator
curandCreateGenerator(&gen, CURAND_RNG_PSEUDO_DEFAULT);
// curandCreateGenerator(&gen, CURAND_RNG... |
20,736 | #define TILE_DIM 8
template<typename T>
__device__ void matrixDotMatrix(const T* matrixA, const T* matrixB, T* result,
const int rowsA, const int colsA, const int rowsB, const int colsB) {
__shared__ T tileA[TILE_DIM][TILE_DIM];
__shared__ T tileB[TILE_DIM][TILE_DIM];
int bx = b... |
20,737 | #include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
void __global__ kernel0(int64_t Npart,int64_t* totalNpairs, int64_t* npairs){
int64_t i = blockIdx.x * blockDim.x + threadIdx.x;
if(i< Npart) {
for(int64_t j = 0;j < Npart;j++) {
totalNpairs[(i*Npart)+j]+=7;
}
}
__syncthr... |
20,738 | #include <stdio.h>
#include <stdlib.h>
#include <cstdio>
__global__ void input( int *output)
{
__shared__ int s_data[1024];
for(int i= 0 ; i < 1024 ; i++)
{
s_data[i] = 2;
}
__syncthreads();
/*
for(int i=0 ; i < 32; i++)
{
int t = threadIdx.x + i *32;
output[t]=s_data[t];
}*/
for(int i=0; i < 32 ;... |
20,739 | #include<stdio.h>
#include <cuda.h>
#include <sys/time.h>
__global__ void compute(int* x,int* y,int n){
int col=threadIdx.x+blockIdx.x*blockDim.x;
int row=threadIdx.y+blockIdx.y*blockDim.y;
int num=col+row*n;
int neighbor=0;
//cell in the middle has eight neighbors,
//a c... |
20,740 | #include <iostream>
#include <cuda.h>
#include <cuda_runtime.h>
#include <stdio.h>
#include <cmath>
typedef unsigned int histogram_t;
typedef unsigned vector_t;
#define MIL 1000
#define MILLON MIL*MIL
#define N 20*MILLON
#define M 8 //Tamaño histograma
#define P 10 //N... |
20,741 | #include <cuda_runtime.h>
#include <stdio.h>
__global__ void helloKernel() {
}
int main(int argc, char **argv) {
helloKernel<<<1,1>>>();
printf("Host: Hello World!!!\n");
return (0);
}
|
20,742 | // #######################################################
//
// Exemplo (template) de multiplicação de matrizes em CUDA
// Disciplina: OPRP001 - Programação Paralela
// Prof.: Mauricio Pillon
//
// #######################################################
#include <cuda.h>
#include <math.h>
#include <stdio.h>
// Matriz... |
20,743 | #include <cstdio>
#include <cstdlib>
#include <time.h>
#define CUDA_SAFE_CALL(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, char *file, int line, bool abort=true)
{
if (code != cudaSuccess)
{
fprintf(stderr,"CUDA_SAFE_CALL: %s %s %d\n", cudaGetErrorString(code), file, line)... |
20,744 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <math.h>
int iDivUp(const int a, const int b) { return (a % b != 0) ? (a / b + 1) : (a / b); };
__global__ static void KernelRect(unsigned char *imgdst,long *X,long *Y, int imgWidth, int imgHeight)
{
unsigned long index = threadIdx.x + blockIdx... |
20,745 | /*
* Demonstration of 2-dimensional block- and thread-indices
* mostly the same as vec_addition example.
* adds up a square matrix with height and with N (Means N^2 calculations)
* kernel is divided in block with THREADS_PER_BLOCK_X * THREADS_PER_BLOCK_X threads per block
*/
#include <stdio.h>
#include <stdlib.h>... |
20,746 | #include<stdio.h>
#include<cuda.h>
#define N 10
__global__ void vecAdd(int *a, int *b, int *c)
{
int id = blockIdx.x;
if(id < N)
c[id] = a[id] + b[id];
}
void checkError(cudaError_t error, char * function)
{
if(error != cudaSuccess)
{
printf("\"%s\" has a problem with error code %d and desc: %s\n", fun... |
20,747 | #include "includes.h"
__global__ void MedianFilterWithMask3x3_Kernel(float* output, const float* input, const int width, const int height, const int nChannels, const bool* keep_mask)
{
int x = threadIdx.x + blockIdx.x * blockDim.x;
int y = threadIdx.y + blockIdx.y * blockDim.y;
if (x >= width || y >= height)
return;
i... |
20,748 | extern "C" // ensure function name will be left alone rather than mangled like a C++ function
{
// Compute the standard normal density at an array of n points (x) and stores output in y.
__global__ void std_normal_pdf_double(const double *x, double *y, unsigned int n)
{
// assumes a 2-d grid of 1-d bloc... |
20,749 | #include "includes.h"
__global__ void vectorLength(int *size, const double *x, const double *y, double *len) {
const long ix = threadIdx.x + blockIdx.x * (long)blockDim.x;
if (ix < *size) {
len[ix] = sqrt(x[ix] * x[ix] + y[ix] * y[ix]);
}
} |
20,750 | /**************************************************************************
* This file contains implementation of pqp (parallel quadratic programming)
* GPU version optimised with TILE and shared memory for MPC Term Project of HP3 Course.
* Group 7 CSE Dept. IIT KGP
* Objective function: 1/2 U'QpU + Fp'U + 1/2 Mp
* Co... |
20,751 | #include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
void _CheckCudaError(const cudaError_t cudaError, const char* file, const int line)
{
if (cudaError != cudaSuccess) {
std::cout << "[CUDA ERROR] " << cudaGetErrorString(cudaError) <<... |
20,752 | #include <cuda.h>
#include <iostream>
#include <sys/time.h>
using namespace std;
#define nPerThread 32
/* Simple Cuda Program: Shared memory
* - Use dynamic shared memory
* - bank conflicts
* - synchronization
*/
// no bank conflicts
__global__ void addOneShared(const int n, double *data) {
extern __shared__ ... |
20,753 | #include <stdio.h>
int main() {
int num_dev;
cudaGetDeviceCount(&num_dev);
printf("%d\n", num_dev);
return 0;
}
|
20,754 | //nvcc -o lab5_3_1 lab5_3_1.cu
/*Author:
Pedro Silva
*/
/*3. Implemente um programa em CUDA que devolva a transposta de uma matriz*/
/*3.1. Implemente uma versão simples (sem recorrer a optimizações).*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
__global__ void transposta(int *d_matrix, int *d_out, int ... |
20,755 | /* Hello Cuda example */
/* Intro to GPU tutorial */
/* SCV group */
#include <stdio.h>
#define NUM_BLOCKS 4
#define BLOCK_WIDTH 8
/* Function executed on device (GPU */
__global__ void hello( void) {
printf("\tHello from GPU: thread %d and block %d\n", threadIdx.x, blockIdx.x);
}
/* Main function, executed on ... |
20,756 | #include <stdio.h>
__global__ void matrixs_1D_multiplication(int *matrix_a_dev,int *matrix_b_dev,int *matrix_c_dev,int row,int col)//记住这里的row和col直接对应global里面的数值,不能有误
{
int j = threadIdx.x+blockIdx.x * blockDim.x;
int i = threadIdx.y+blockIdx.y * blockDim.y;
if(i< row &&j < row)
{
for(int k = 0... |
20,757 | #include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <iostream>
#include <ctype.h>
#include <cuda.h>
#include <math.h>
#define CEIL(a,b) ((a+b-1)/b)
#define SWAP(a,b,t) t=b; b=a; a=t;
#define DATAMB(bytes) (bytes/102... |
20,758 | #include "includes.h"
__device__ int position; //index of the largest value
__device__ int largest; //value of the largest value
int lenString = 593;
int maxNumStrings = 1000000;
int threshold = 2;
__global__ void compare(char *d_a, int *d_b, int *d_c, int size, int lenString, int threshold) {
int my_id = block... |
20,759 | #include "../image_headers/hough.cuh"
#include <iostream>
#include <cmath>
#include <cstdio>
__global__ void hough_kernel(int* line_matrix, int* image, int width, int height, int diag) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
int i = idx / width;
int j = idx % width;
if (idx < width * height) {
for (i... |
20,760 | #include<iostream>
#include<vector>
const int SHARED_MEM = 256;
__global__ void absoluteKernel(int *a, int *abs_a, int N){
int index = threadIdx.x + blockIdx.x*blockDim.x;
if(index<N){
if(a[index] < 0){
abs_a[index] = -1*a[index];
}
else{
abs_a[index] = a[index];
}
}
}
__global__ void findmaxnorm(... |
20,761 | #include "MurMurHash3.cuh"
__host__ __device__ inline uint64_t rotl64(uint64_t x, int8_t r)
{
return (x << r) | (x >> (64 - r));
}
__host__ __device__ inline uint64_t getblock64(const uint64_t *p, int i)
{
return p[i];
}
__host__ __device__ inline uint64_t fmix64(uint64_t k)
{
k ^= k >> 33;
k *= 0xff51afd7ed... |
20,762 | #include "includes.h"
__global__ void kernel(float *F, double *D)
{
int tid = blockIdx.x * blockDim.x + threadIdx.x;
if (tid == 0)
{
*F = 12.1;
*D = 12.1;
}
} |
20,763 | /*************************************************************************************************
* File: matrixmath.cu
* Date: 11/06/2018
*
* Compiling: Requires a Nvidia CUDA capable graphics card and the Nvidia GPU Computing Toolkit.
* Linux & Windows: nvcc -Wno-deprecated-gpu-targets -O3 -o prog2 ... |
20,764 | #include <stdio.h>
#include <math.h>
#define N 3000000
#define BLOCKSIZE 256
__global__ void moving_average(float *in, float *out) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < N-2) {
out[i] = (in[i] + in[i+1] + in[i+2]) / 3.0;
}
}
int main() {
float *in, *out;
float *d_in, *d_out;
size... |
20,765 | #include <stdio.h>
#include <cuda_runtime.h>
__global__ void Kernel
(
double* u1,
double* v1,
double a,
double b,
double eta,
double d_u1,
double d_v1,
double dt,
double D,
int N
)
{
int tidx = threadIdx.x;
int tidy = threadIdx.y;
int bidx = blockIdx.x;
... |
20,766 | // Taken from the NVIDIA "2_Graphics\simpleGL" sample:
// A kernel that modifies the z-coordinates of a rectangular
// grid of vertices, based on a time value, so that they
// form an animated sine wave
extern "C"
__global__ void simple_vbo_kernel(
float4 *pos, unsigned int width, unsigned int height, float time... |
20,767 | __global__ void process_kernel1(const float *input1,const float *input2, float *output, int datasize)
{
int blockNum = blockIdx.z * (gridDim.x * gridDim.y) + blockIdx.y * gridDim.x+ blockIdx.x;
int threadNum = threadIdx.z * (blockDim.x* blockDim.y) + threadIdx.y * (blockDim.x) + threadIdx.x;
int i = blockNum * (blo... |
20,768 |
/* This is a automatically generated test. Do not modify */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
__global__
void compute(float comp, int var_1,float var_2,float var_3,float var_4,float var_5,float var_6,float var_7,float var_8,float var_9,float var_10,float var_11) {
for (int i=0; i < var_1; ++i)... |
20,769 | /* A toy example that adds two numbers on the device. */
#include <stdio.h>
__global__ void add(int *c, int a, int b) {
*c = a + b;
}
int main(void) {
int result;
int *result_dev;
cudaMalloc(&result_dev, sizeof(int));
// <<<1,1>>> means: run the kernel on a grid of one block, where each block
... |
20,770 | /*
# compile
$ nvcc -o sigmoid sigmoid.cu
# numpy counterpart
import numpy as np
m = np.array(((0, 1, 2), (3, 4, 5), (6, 7, 8), (9, 10, 11)))
s = 1/(1+np.exp(-m))
sd = s*(1-s)
*/
#include <stdio.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <cuda_runtime_api.h>
// kernel of device sigmoid function
__glob... |
20,771 | #include "includes.h"
// cuDEBYE SOURCE CODE VERSION 1.5
// TO DO:
// - REWRITE TO DOUBLE PRECISION DISTANCE CALCULATIONS FOR BENCHMARKING
// - CONSIDER NOT CALLING SQRT (HISTOGRAM OF VALUE UNDER SQUARE -> problem with memory, no solution jet) IN KERNEL TO SAVE COMPUTATION TIME
// - USE INTEGER VALUES INSTEAD OF FLOAT ... |
20,772 | #include<stdio.h>
__global__ void shift(int * g){
int i = threadIdx.x;
__shared__ int array[128];
array[i] = i;
__syncthreads();
if(i<127){
int temp = array[i + 1];
__syncthreads();
array[i] = temp;
__syncthreads();
}
g[i] = array[i];
__sync... |
20,773 | #include <stdio.h>
#include <stdlib.h>
#define NUM_ELEMENTS 8192
#define MAX_THREADS_PER_BLOCK 1024
#define KERNEL_LOOP 100000
__host__ void generate_rand_data(unsigned int * host_data_ptr)
{
for(unsigned int i=0; i < NUM_ELEMENTS; i++)
{
host_data_ptr[i] = (unsigned int) rand();
... |
20,774 | /* Molecular dynamics simulation linear code for binary Lennard-Jones liquid
under NVE ensemble; Author: You-Liang Zhu, Email: youliangzhu@ciac.ac.cn
Copyright: You-Liang Zhu
This code is free: you can redistribute it and/or modify it under the terms
of the GNU General Public License.*/
#include <ctype.h... |
20,775 | #include "utils.cu"
|
20,776 | #include <stdio.h>
template<typename srcT, typename dstT>
__global__
void yuv2rgb_kernel(srcT *src, dstT *dst, int width, int height)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
int j = blockIdx.y * blockDim.y + threadIdx.y;
if (i >= width || j >= height)
return;
int yIdx = j * width + i;... |
20,777 | /*
* usage: nvcc ./stream_test_v3.cu -o ./stream_v3
* nvvp ./stream_v3 ( or as root:
* nvvp -vm /usr/lib64/jvm/jre-1.8.0/bin/java ./stream_v3 )
*
* purpose: just see what commenting out the final call to the default
* stream would cause our concurrency pro... |
20,778 | //***************************************************************************
// Broday Walker
// Dr. Eduardo Colmenares
//
//
//***************************************************************************
#include <cuda.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
using namespace ... |
20,779 | #include <iostream>
#include "vector_summation.cuh"
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cuda.h>
GpuVector::GpuVector(int* vec_cpu,int nbytes){
/* allocate GPU mem */
cudaMallocManaged(&vec_gpu,nbytes);
cudaMemcpy(vec_gpu, vec_cpu, nbytes, cudaMemcpyHostToDevice);
}
void GpuVec... |
20,780 | #include <stdio.h>
#include <cuda.h>
#include <cuda_runtime_api.h>
#include <device_launch_parameters.h>
#include <stdlib.h>
#include <time.h>
#include <cfloat>
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define abs(a) (a > 0 ? a : -1 * a)
#define MAX_BLOCKS 50000
__global__ void kMeansSte... |
20,781 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cuda_runtime.h>
#define PREFIX_LENGTH 4
#define MAX_PASSWORD_LENGTH 6
#define ALPHABET_SIZE 26
/* F, G and H are basic MD5 functions: selection, majority, parity */
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z) (((x) & (z)) | ((y... |
20,782 | /*
* Copyright 1993-2010 NVIDIA Corporation. All rights reserved.
*
* NVIDIA Corporation and its licensors retain all intellectual property and
* proprietary rights in and to this software and related documentation.
* Any use, reproduction, disclosure, or distribution of this software
* and related documentat... |
20,783 | #include <iostream>
__device__ int myAtomicAdd(int *address, int incr)
{
// Create an initial guess for the value stored at *address.
int guess = *address;
int oldValue = atomicCAS(address, guess, guess + incr);
// Loop while the guess is incorrect.
while (oldValue != guess)
{
guess = ... |
20,784 | /**
* bicg.cu: This file is part of the PolyBench/GPU 1.0 test suite.
*
*
* Contact: Scott Grauer-Gray <sgrauerg@gmail.com>
* Louis-Noel Pouchet <pouchet@cse.ohio-state.edu>
* Web address: http://www.cse.ohio-state.edu/~pouchet/software/polybench/GPU
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#... |
20,785 |
__global__ void anisotropy_kernel(float1* imInD, int M,int N, float k, float lambda, short type) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
int j = blockIdx.y * blockDim.y + threadIdx.y;
int index = j+i*M;
int len = N*M;
float deltaN;
float deltaS;
float ... |
20,786 | #include <stdio.h>
__global__ void helloKernel()
{
const int i = blockIdx.x*blockDim.x + threadIdx.x;
printf("Hello World! My threadId is %d \n", i);
}
int main()
{
// Launch kernel to print
helloKernel<<<1, 256>>>();
cudaDeviceSynchronize();
return 0;
}
|
20,787 | #include "includes.h"
__global__ void cuda_int8_to_f32(int8_t* input_int8, size_t size, float *output_f32, float multipler)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < size) output_f32[idx] = input_int8[idx] * multipler; // 7-bit (1-bit sign)
} |
20,788 | #include "includes.h"
__global__ void absDifference(double *dDifference, double *dSup, double *dLow, int dSize){
int tid = threadIdx.x + blockIdx.x * blockDim.x;
while (tid < dSize) {
double a = dSup[tid];
double b = dLow[tid];
dDifference[tid] = (a > b) ? (a - b) : (b - a);
tid += blockDim.x * gridDim.x;
}
} |
20,789 | #include "includes.h"
__global__ void warmUpGPU()
{
// do nothing
} |
20,790 | #include <fstream>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <sys/time.h>
#include <cuda_runtime.h>
#define BLOCK_DIM 8
__device__ double c(const double x, const double y) {
//if ((y > 1.0) && (y <= 1.2)) return 0.8;
//if ((y > 0.5) && (y <= 0.8) && (x > 0.2) && (x <= 0... |
20,791 | #include <cuda.h>
#include <cuda_runtime_api.h>
#include<stdio.h>
__global__ void cuda_gray_kernel(unsigned char *b, unsigned char *g, unsigned char *r, unsigned char *gray, size_t size)
{
size_t idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx >= size) {
return;
}
gray[idx] = (unsigne... |
20,792 | //===- transpose.cu -------------------------------------------*--- C++ -*-===//
//
// Copyright 2022 ByteDance Ltd. and/or its affiliates. All rights reserved.
// 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... |
20,793 | #include <stdio.h>
#include <sys/time.h>
#include <cuda_runtime.h>
const float step = 0.001;
enum {
BLOCK_SIZE = 32,
N = 1024
};
void tabfun_host(float *tab, float step, int n)
{
for (int i = 0; i < n; i++) {
float x = step * i;
tab[i] = sinf(sqrtf(x));
}
}
__global__ void tabfun(flo... |
20,794 | #define N_W 128
#define N_H 128
#define N_D 128
extern "C" // ensure function name to be exactly "vadd"
{
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////... |
20,795 | #include "includes.h"
/*
#define N 512
#define N 2048
#define THREADS_PER_BLOCK 512
*/
const int THREADS_PER_BLOCK = 32;
const int N = 2048;
__global__ void mult(int *a, int *b, int *c)
{
int pos = threadIdx.x + blockDim.x * blockIdx.x;
if (pos >= N) return;
c[pos] = a[pos] * b[pos];
} |
20,796 | #include "includes.h"
// Include files
// Parameters
#define N_ATOMS 343
#define MASS_ATOM 1.0f
#define time_step 0.01f
#define L 10.5f
#define T 0.728f
#define NUM_STEPS 10000
const int BLOCK_SIZE = 1024;
//const int L = ;
const int scheme = 1; // 0 for explicit, 1 for implicit
/**********************************... |
20,797 | /*
* UpdaterEz1D.cpp
*
* Created on: 25 янв. 2016 г.
* Author: aleksandr
*/
#include "UpdaterIntensityTM.h"
__device__
void UpdaterIntensityTM::operator() (const int indx) {
#define Ez(M, N) Ez[(M) * (gridSizeY) + (N)]
const int n = indx % sizeY;
const int m = indx / sizeY;
intensity[indx] = intensity[... |
20,798 | #include "includes.h"
__global__ void add(int *a, int *b, int *c, int n)
{
int index = threadIdx.x + blockIdx.x * blockDim.x;
if (index < n)
c[index] = a[index] + b[index];
} |
20,799 | /**
* @file compare.cu
* @brief cuda arrayの比較の実装
* @author HIKARU KONDO
* @date 2021/07/19
*/
#include "compare.cuh"
#define BLOCKDIM 256
/**
* @def
* Macro to compare against arrays on the GPU
* @fn
* Macro to compare against arrays on the GPU
* @param (comareArrayA) Pointer to the beginning of the array... |
20,800 | //https://devblogs.nvidia.com/easy-introduction-cuda-c-and-c/
#include <stdio.h>
#include <cuda.h>
int main(void)
{
int runtimeVersion = -1;
cudaError_t error_id = cudaRuntimeGetVersion(&runtimeVersion);
printf("Runtime version %d; Cuda error: %x (%s)\n", runtimeVersion, error_id, cudaGetErrorString(erro... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.