serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
2,901 | #include "includes.h"
__global__ void unpack_bottom( const int x, const int y, const int halo_depth, double* field, double* buffer, const int depth)
{
const int x_inner = x - 2*halo_depth;
const int gid = threadIdx.x+blockDim.x*blockIdx.x;
if(gid >= x_inner*depth) return;
const int lines = gid / x_inner;
const int of... |
2,902 | #include "includes.h"
__global__ void callOperationSharedDynamic(int *a, int *res, int x, int n)
{
int tidx = blockDim.x * blockIdx.x + threadIdx.x;
int tidy = blockDim.y * blockIdx.y + threadIdx.y;
if (tidx >= n || tidy >= n) {
return;
}
int tid = tidx * n + tidy;
extern __shared__ int data[];
int *s_a = data;
int... |
2,903 | /* Code for COMP 605 HW5, problem 1
Code will calculate pi from the integral of
4/(1+x^2) on the bounds 0 - 1
using CUDA methodology.
Author: Jon Parsons
compile using
nvcc -o CudaPI.x cudapi.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
const int threadsPerBlock = 10;
const int blocksP... |
2,904 | /*************************************************************************
/* ECE 277: GPU Programmming 2021 Winter
/* Author and Instructer: Cheolhong An
/* Copyright 2020
/* University of California, San Diego
/*************************************************************************/
#define COLS 4
#define ROWS ... |
2,905 | #include <stdio.h>
#include <cuda.h>
__global__ void hello() {
int id = blockIdx.x * blockDim.x + threadIdx.x;
//if (id == 2047)
printf("my id is %d.\n", id);
}
int main() {
dim3 block(1024, 1, 1);
hello<<<2, block>>>();
cudaDeviceSynchronize();
return 0;
}
|
2,906 | #include "includes.h"
__global__ void matrixMult (int *a, int *b, int *c, int width)
{
int i, sum = 0;
int col = threadIdx.x + blockDim.x * blockIdx.x;
int row = threadIdx.y + blockDim.y * blockIdx.y;
if(col < width && row < width)
for (i = 0; i< width; i++)
{
sum += a[row * width + i] * b[i * width + col];
}
c[row * w... |
2,907 | #include "triangle.cuh"
#include <iostream>
#include <fstream>
using namespace std;
// point class
// This constructor will help us create an instance of v3 from binary data found in the STL file.
v3::v3(char* facet)
{
float xx = *((float*)facet);
float yy = *((float*)facet + 1);
float zz = *((float*)face... |
2,908 | __global__ void BilinearInterpolationForward(const float* bottom_data,
const int* bs, const float* pos_data, float* top_data, const int* ts) {
// bs = bottom_data size, ps = pos_data size, ts = top_data size
// input position = -1~1
// pos_data[:,:,1,:] = x, pos_data[:,:,2,:] = y
// top_data size =... |
2,909 | #include<stdio.h>
#include<stdlib.h>
#include<sys/time.h>
#define NUM 10000000
#define CUDA_ERROR_EXIT(str) do{\
cudaError err = cudaGetLastError();\
if( err != cudaSuccess){\
printf("Cuda Error: '%s' ... |
2,910 | // a cuda app. we will convert this to opencl, and run it :-)
#include <iostream>
#include <memory>
#include <cassert>
using namespace std;
#include <cuda_runtime.h>
__global__ void setValue(float *data, int idx, float value) {
if(threadIdx.x == 0) {
data[idx] = value;
}
}
// int main(int argc, ch... |
2,911 | #include "cuda_MP7.cuh"
void cuda_MP7(int argc, char* argv[])
{
/* Case of 0 arguments: Default seed is used */
if (argc < 2) {
srand(0);
}
/* Case of 1 argument: Seed is specified as first command line argument */
else {
int seed = atoi(argv[1]);
srand(seed);
}
uint8_t *gold_bins = (uint8_t*)malloc(... |
2,912 | extern "C" __global__ void
mul_each(float2* x, float2* y)
{
int i = blockDim.x * blockIdx.x + threadIdx.x;
x[i] = make_float2(x[i].x * y[i].x - x[i].y * y[i].y, x[i].x * y[i].y + x[i].y * y[i].x);
} |
2,913 | #include "includes.h"
__global__ void matrix_transpose_k1(float* input,float* output,const int nx, const int ny)
{
int gid = blockDim.x * blockIdx.x + threadIdx.x;
int offset = threadIdx.x*blockDim.x;
//printf("gid : %d , offset : %d , index : %d ,value : %f \n", gid, offset, offset + blockIdx.x,input[offset + blockIdx... |
2,914 | __global__ void kernelFunc() {
}
|
2,915 | #include <stdio.h>
/*
* Currently, `initializeElementsTo`, if executed in a thread whose
* `i` is calculated to be greater than `N`, will try to access a value
* outside the range of `a`.
*
* Refactor the kernel defintition to prevent our of range accesses.
*/
__global__ void initializeElementsTo(int initialVal... |
2,916 | #include "kernels.cuh"
__global__
void dot_product_kernel(float *x, float *y, float *dot, unsigned int n){
unsigned int index = threadIdx.x + blockIdx.x * blockDim.x;
unsigned int stride = blockDim.x * gridDim.x;
__shared__ float cache[256];
double temp = 0.0;
while(index < n){
temp +... |
2,917 | # include <math.h>
# include <time.h>
# include <stdio.h>
# include <stdlib.h>
# include <iostream>
# include <sys/time.h>
# include "cuda_runtime.h"
using namespace std;
const int DIM = 1024, AS = 32, BS = 32;
const float sigma = 1.0;
const bool PRINT_RESULT = false;
/*
RBF Kernel Implementation on CPU.
Param @ si... |
2,918 | #include <cuda_runtime_api.h>
#define OFFSET_BANK(idx) ({ __typeof__ (idx) _idx = idx; ((_idx) + ((_idx) / 32)); })
__global__ void conv_diag_affine_white_var_fwd_batch_kernel(
const float *in_act,
int spatial_dim,
int num_channels,
int batch_size,
const float *mean,
const float *var,
floa... |
2,919 | #include "cuda.h"
#include <stdio.h>
__global__ void ScatterNdOps_forward_kernel(double *out, const long long*ii, const double *update, int n){
int p = blockIdx.x *blockDim.x + threadIdx.x;
if (p<n){
out[ii[p]-1] = update[p];
}
}
__global__ void setzero_kernel(double *out, int n){
int p = blo... |
2,920 | #include<stdio.h>
#include <curand.h>
#include <curand_kernel.h>
#include<stdlib.h>
/* Thread structure: 1, m*n
This function initializes random values into an array according to the above thread structure
*/
__global__ void init(double *W){
int mx = threadIdx.x;
int nx = threadIdx.y;
int m = blockDi... |
2,921 | #include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#define N 20480
// declare the kernel
__global__ void daxpy(double a, double *x, double *y) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < N) {
y[i] += a*x[i];
}
}
int main(void) {
double *x, *y, a;
double... |
2,922 | #include<iostream>
#include<cstdlib>
#include<cmath>
#include<time.h>
using namespace std;
__global__ void matrixVectorMultiplication(int *a, int *b, int *c, int n)
{
int row=threadIdx.x+blockDim.x*blockIdx.x;
int sum=0;
if(row<n){
for(int j=0;j<n;j++)
{
sum=sum+a[(j*n)+row... |
2,923 | // Copyright 2016 Massachusetts Institute of Technology. See LICENSE file for details.
// http://docs.nvidia.com/cuda/samples/6_Advanced/reduction/doc/reduction.pdf
template <unsigned int blockSize, typename T, typename R>
__device__ void cuda_reduce(R reduce, size_t n, T *g_idata, T *g_odata, off_t incx, off_t incy, ... |
2,924 | #include <stdio.h>
#include <time.h>
int main(void) {
time_t t;
time(&t);
printf("%ld\n", t);
printf(ctime(&t));
} |
2,925 | #include <cuda_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define __DEBUG
#define VSQR 0.1
#define TSCALE 1.0
#define CUDA_CALL(err) __cudaSafeCall(err, __FILE__, __LINE__)
#define CUDA_CHK_ERR() __cudaCheckError(__FILE__, __LINE__)
/**************************************
* void __cudaSafe... |
2,926 |
/* This is a automatically generated test. Do not modify */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
__global__
void compute(float comp, float var_1,float var_2,float var_3,float var_4,float var_5,float var_6,float var_7,int var_8,float var_9,float var_10,float var_11,float var_12,float var_13,float ... |
2,927 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cuda.h>
__device__ unsigned long long int gcd(unsigned long long int a, unsigned long long int b){
unsigned long long int r=0;
while(b!=0){
r = a%b;
a = b;
b = r;
}
return a;
}
__global__ void MonteCarlo(unsigned long long int n, unsigned lo... |
2,928 | #include "includes.h"
__global__ void quickSort(int *x, int *dfirst, int *dlast, int *list)
{
int idx = threadIdx.x;
int first = dfirst[idx];
int last = dlast[idx];
list[idx] = 0;
if(first<last)
{
int pivot, j, temp, i;
pivot = first;
i = first;
j = last;
while(i<j)
{
while(x[i]<=x[pivot] && i<last)
i++;
while(x[j] ... |
2,929 | #include "includes.h"
__global__ void batch_crop_kernel(float* input, const int nCropRows, const int nCropCols, const int iH, const int iW, const int nPlanes){
const int plane = blockIdx.x;
if (plane >= nPlanes)
return;
input += plane * iH * iW;
const int tx = threadIdx.x;
const int ty = threadIdx.y;
if (ty < iH && (... |
2,930 | #include <stdio.h>
#include <assert.h>
#include <cuda.h>
int main(int argc, char* argv[])
{
int* p = NULL;
int4* q = NULL;
int i = 0;
cudaError_t iRet;
p = (int*) malloc(sizeof(int4)*8*64*sizeof(int));
assert(p != NULL);
q = (int4*) malloc(2*64*sizeof(int4));
assert(q != NULL);
fo... |
2,931 | #ifndef THREADED_H
#define THREADED_H
#include<vector>
#include<thread>
#define THREADED(class,function, num_of_threads) \
void class::function##Threaded(){ \
std::vector< std::thread > threads; \
for(int i=0; i<num_of_threads; i++){ \
threads.push_back( std::thread([this](){this->function##Single();}))... |
2,932 | #include "stdio.h"
__global__
void testKernel(float* d_data)
{
int myId = threadIdx.x;
d_data[myId] = 10;
}
void CallKernel()
{
int threads = 32;
dim3 gridSize(1, 1, 1);
dim3 blockSize(threads, 1, 1);
float* h_data;
float* d_data;
int dataLen = threads;
h_data = (float *)malloc(... |
2,933 | #include "includes.h"
__global__ void Mask_Intersect_Kernel( int* A, int* B, int* devOut)
{
const int idx = blockDim.x*blockIdx.x + threadIdx.x;
devOut[idx] = A[idx] * B[idx];
} |
2,934 | #ifdef __cplusplus
extern "C" {
#endif
struct point{
float x;
float y;
};
__global__ void pi(const struct point* A, float* res, const int nbPoint, const float ray){
const int idx = 32*blockDim.x * blockIdx.x + threadIdx.x;
if (idx < nbPoint-32*blockDim.x)
{//blockDim.x * blockIdx.x + threadIdx.x;
const int ... |
2,935 | #include <cstdio>
int main(int argc, char **argv) {
const int N = 1024;
char *tmpPtr;
char tmpBuffer[N];
cudaMalloc(&tmpPtr, N);
cudaMemcpy(tmpPtr, tmpBuffer, N, cudaMemcpyHostToDevice);
while(getchar() != EOF);
}
|
2,936 | /* This program sorts an input array by bucket sort.
* Each bucket in turn is sorted using Parallel Bubble sort.
* The array consists of float numbers, all less than 1. To find the destination bucket,
* the float number is multiplied by 10 to get the first digit, which determines the bucket number.
* For eg., 0.123... |
2,937 | #include <thrust/device_vector.h>
#include <thrust/transform.h>
#include <thrust/copy.h>
#include <iostream>
struct functor{
functor(float (*g)(const float&)) : _g{g} {}
__host__ __device__ float operator()(const float& x) const {
return _g(x);
}
private:
float (*_g)(const float&);
};
__host__ __device_... |
2,938 | #include <iostream>
#include <math.h>
#include <stdio.h>
#include <cuda.h>
using namespace std;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++!
// Divergence of a Vector with variable coefficient- term in momentum eqn !
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++... |
2,939 | #include "includes.h"
const int Nthreads = 1024, NrankMax = 3, nt0max = 71, NchanMax = 1024;
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////... |
2,940 | #include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/inner_product.h>
#include <thrust/sequence.h>
#include <bits/stdc++.h>
using namespace std;
int main(){
thrust::device_vector<int> d_B(5), d_A(5,15);
cout<<"begin\n\n";
for(auto b:d_B) cout<<b<<' ';
cout<<endl;
for(auto a:d_A) co... |
2,941 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;
__global__ void global_get_flags(int* d_in, int* flags, int mask, int size) {
//indices
int myId = threadIdx.x + blockDim.x * block... |
2,942 | /* 2dadvec_kernels.cu
*
* This file contains the kernels for the 2D advection DG method.
* We use K = number of elements
* and H = number of sides
*/
#define PI 3.14159
/***********************
*
* DEVICE VARIABLES
*
***********************/
/* These are always prefixed with d_ for "device" */
double *d_c... |
2,943 | //#include "xfasttrie-k-parallel.cuh"
//#include "Catch2/catch.hpp"
//#include "cuda/api_wrappers.h"
//
//#include "allocators/default_allocator.cuh"
//#include <cassert>
//#include <cooperative_groups.h>
//
//using XTrie = XFastTrieKParallel<unsigned char, int>;
//using XTrieKey = typename XTrie::key_type;
//using XTr... |
2,944 | #include <stdio.h>
__global__ void multi_thread(void)
{
printf("Hello, world from the device!\n");
}
int main(void)
{
// greet from the host
printf("Hello, world from the host!\n");
// launch a kernel with a single thread to greet from the device
multi_thread<<<1,1>>>();
cudaDeviceSynchronize();
retur... |
2,945 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
int main()
{
int devcount;
cudaGetDeviceCount(&devcount);
printf("%i device(s) found...", devcount);
return 0;
}
|
2,946 | ////////////////////////////////////////////////////////////////////////////////
//
// FILE: one_dim_convolution.cu
// DESCRIPTION: implements one-dimensional convolution in 3 ways
// AUTHOR: Dan Fabian
// DATE: 3/15/2020
#include <cuda.h>
#include <cuda_runtime.h>
#include <iostream>
#include <stdi... |
2,947 | /******************************
* Tisma Miroslav 2006/0395
* Multiprocesorski sistemi
* domaci zadatak 6 - 1. zadatak
*******************************/
/**
* 1. Sastaviti program koji kvadrira elemente dvodimenzionalne matrice.
*/
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <cuda.h>
... |
2,948 | #include <random>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <assert.h>
#include "cuda_runtime.h"
__global__ void bankConflictTest(float* fake_result) {
__shared__ float sm[128];
int i = threadIdx.x / 4;
fake_result[i] = sm[i];
}
int main(int argc, char *argv[]) {
float *fake_res... |
2,949 | /**
* Yuri Gorokhov
* lab 5 - Modulus power of two
*/
#include <stdio.h>
#include <cuda.h>
#include <math.h>
#define ITERATIONS 100000
#define THREADS 32
#define POW 30
__global__ void kernel_mod(int);
int main (void) {
cudaEvent_t start, stop;
int input[POW];
float output[POW];
cudaEventCreate(&start);
... |
2,950 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#define THREADSPERBLOCK 4
int checkArray(int [], int [], int);
// CUDA example: finds row sums of an integer matrix m
// find1elt() finds the rowsum of one row of the nxn matrix m, storing the
// result in the corresponding position in the rowsum array rs; m... |
2,951 | #include "includes.h"
__device__ float rowcol_dot(float *matrix_a, float *matrix_b, int row, int col, int N)
{
float val = 0;
for (int k=0; k < N; k++)
{
val += matrix_a[ row*N + k ] * matrix_b[ col + k*N];
}
return(val);
}
__global__ void matrix_mult_ker(float * matrix_a, float * matrix_b, float * output_matrix, int... |
2,952 | //THRUST
#include <thrust/tuple.h>
#include <thrust/device_vector.h>
#include <thrust/host_vector.h>
//STL
#include <iostream>
#include <vector>
int N = 10;
thrust::tuple< int, const char * > tString( N, "thrust" );
int main( void )
{
std::cout << "The 1st value of tString is " << thrust::get< 0 >( tString ) << s... |
2,953 |
/* 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,int 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,float var_12,float var_13,float va... |
2,954 | #include <stdio.h>
#include <unistd.h>
struct IntSandwich {
int beginning;
int middle[1];
int end;
};
__global__ void access_offset_kernel(struct IntSandwich *hostMem, int offset) {
#ifdef R
volatile int i = hostMem->middle[offset];
#elif W
hostMem->middle[offset] = 42;
#endif
}
int main(int argc, ch... |
2,955 | #include <iostream>
#include <algorithm>
#include <ctime>
#include <cuda_runtime.h>
#include <cuda_runtime_api.h>
#include <device_launch_parameters.h>
#include <cuda.h>
using namespace std;
__global__ void binomial_kernel(double *S, double *kvpq, double *prices, int size, int nsteps, bool am_b, bool put_b);
double *... |
2,956 |
// #include <iostream>
#include <cuda_runtime.h>
// #include <string>
#include <stdio.h>
using namespace std;
__global__ void test(/*string name*/) {
printf("test_gpu\n");
}
int main(){
test<<<1,1>>>(/*"Test"*/);
cudaDeviceSynchronize();
}
|
2,957 | #include <stdlib.h>
#include <stdio.h>
#define CUDA_DEVICE (0)
#define NUM_THREADS (1<<13)
#define BLOCK_DIM (64)
#define GRID_DIM (NUM_THREADS/BLOCK_DIM)
#define NUM_BYTES (NUM_THREADS*4*sizeof(float))
// Compile and run with the commands:
// nvcc float4_test.cu
// ./a.out
//
// Failure occurs on my Tesla C870 c... |
2,958 | #include<stdio.h>
__global__ void device_greetings()
{
printf("Hello, world from the GPU!\n");
}
int main()
{
printf("Hello, world form the host!\n");
dim3 threadBlocks(8, 16);
dim3 gridBlocks(2, 4);
device_greetings<<<gridBlocks, threadBlocks>>>();
cudaDeviceSynchronize();
return 0;
} |
2,959 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <fstream>
#include <cstdlib>
#include <math.h>
#define BLOCK_SIZE 16
#define FEATURE_LEN 128
using namespace std;
void calMeanVar(double* v, double& mean, double& var){
double sum = 0;
for(int i=0;i<FEATURE_LEN;i++)
... |
2,960 | #include <stdio.h>
#include <stdlib.h>
#include "gpu_functions.cuh"
__host__ void helloGPU(void) {
__helloGPU<<< 1, 1 >>>();
cudaDeviceSynchronize();
}
__global__ void __helloGPU(void) {
printf("[gpu]> Hello world! (global)\n");
__helloGPUDevice();
}
__device__ void __helloGPUDevice(void) {
printf("[gpu... |
2,961 | __global__ void count_up() {
//@ ensures x == 11
int x = 0;
//@ loop invariant x <= 11
while (x <= 10) {
x++;
}
}
|
2,962 | #include <iostream>
__global__ void kernel( void ) {
}
int main( void ) {
kernel<<<1,1>>>();
std::cout<< "Hello, World!" << std::endl;
return 0;
}
|
2,963 | #include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <cuda_runtime.h>
#define BLOCK_SIZE 32
#define WA (10 * BLOCK_SIZE) // Matrix A width
#define HA (10 * BLOCK_SIZE) // Matrix A height
#define WB (20 * BLOCK_SIZE) // Matrix B width
#define HB WA // Matrix B heigh... |
2,964 | #include <cuda.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#define rows 1000
#define cols 1000
#define Y 32
#define X 32
__host__ void fill(double* M1, double* M2){
for(int k=0; k<rows*cols; k++){
M1[k] = sin(k);
M2[k] = cos(k);
}
}
__host__ void checkStatus(cudaError_t& status,const char ... |
2,965 | /**
* 获取GPU属性
*/
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
cudaDeviceProp prop;
int count;
// 获取有所少快GPU设备
cudaGetDeviceCount(&count);
for(unsigned i = 0; i < count; ++i)
{
// 获取GPU属性信息
cudaGetDeviceProperties(&prop, i);
... |
2,966 |
// CUDA version of vector add example
#include <stdio.h>
#define RealType float
__global__ void vector_add(const RealType *a, const RealType *b, RealType *c, const int N)
{
int idx = blockDim.x * blockIdx.x + threadIdx.x;
if (idx < N) {
c[idx] = a[idx] + b[idx];
}
}
void check_status(cudaError_t status, ... |
2,967 | #include <iostream>
__global__ void sharedMemoryKernel(const int* x, int* y, const int N) {
__shared__ int sharedMemory[7][256];
int sum = 0;
int maxSum = 0;
int sqrSum = 0;
int maxMod = 0;
int min = x[0];
int max = 0;
int zeros = 0;
for (int tid = blockDim.x * blockIdx.... |
2,968 | #include "includes.h"
__global__ void Subsample_Bilinear_uchar(cudaTextureObject_t uchar_tex, unsigned char *dst, int dst_width, int dst_height, int dst_pitch, int src_width, int src_height)
{
int xo = blockIdx.x * blockDim.x + threadIdx.x;
int yo = blockIdx.y * blockDim.y + threadIdx.y;
if (yo < dst_height && xo < ds... |
2,969 | /**
* Assignment 06 Program - moving_average.cu
* Sarah Helble
* 10/06/17
*
* Calculates the average of each index and its neighbors
*
* Usage ./aout
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
// Execution Notes
// 512, 512 gives about equivalent times
// 512, 256 register is 2x faster
... |
2,970 | #define N 4000
#define DIV_UP(a, b) ( ((a) + (b) - 1) / (b) )
#include <stdio.h>
__global__ void matrixMult (float *a, float *b, float *c, int width) {
int k = 0;
float sum = 0.0;
int col = threadIdx.x + blockDim.x * blockIdx.x;
int row = threadIdx.y + blockDim.y * blockIdx.y;
if(col < width && row < width) {
... |
2,971 | __global__ void update_core(double *f, double *g, double *c, int nx, int ny) {
int tid = blockIdx.x * blockDim.x + threadIdx.x;
int i = tid / ny;
int j = tid % ny;
if (i > 0 && j > 0 && i < nx-1 && j < ny-1) {
f[tid] = c[tid] * (g[tid-ny] + g[tid+ny] + g[tid-1] + g[tid+1]
- 4*g... |
2,972 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <curand_kernel.h>
#define KERNEL_SIZE 20
__constant__ int kernel[KERNEL_SIZE];
__global__ void conv1d(int *input, int *output, int l) {
int tid = blockIdx.x * blockDim.x + threadIdx.x;
in... |
2,973 | __global__ void clock_block(clock_t* d_o, long clock_count)
{
clock_t start_clock = clock64();
volatile long clock_offset = 0;
volatile int i = 0;
for (i = 0; i < 10000000; i++)
while (clock_offset < clock_count)
{
clock_offset = clock_count--;
}
d_o[0] = clock_offset;
}
|
2,974 | #include "includes.h"
__global__ void sobelFilterShared(unsigned char *data, unsigned char *result, int width, int height){
// Data cache: threadIdx.x , threadIdx.y
const int n = Mask_size / 2;
__shared__ int s_data[BLOCKSIZE + Mask_size * 2 ][BLOCKSIZE + Mask_size * 2];
// global mem address of the current thread in ... |
2,975 | #include <stdio.h>
__global__ void vector_add(int *a, int *b, int *c)
{
/* insert code to calculate the index properly using blockIdx.x, blockDim.x, threadIdx.x */
int index = threadIdx.x;
c[index] = a[index] + b[index];
}
#define dim 3
int main()
{
int *a, *b, *c;
int *d_a, *d_b, *d_c;
//since we will b... |
2,976 | /*
**********************************************
* CS314 Principles of Programming Languages *
* Spring 2020 *
**********************************************
*/
#include <stdio.h>
#include <stdlib.h>
__global__ void strongestNeighborScan_gpu(int * src, int * oldDst, int * newDst, ... |
2,977 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cuda.h>
#include <cuda_runtime.h>
#define dT 0.2f
#define G 0.6f
#define BLOCK_SIZE 64
// Global variables
int num_planets;
int num_timesteps;
// Host arrays
float2* velocities;
float4* planets;
// Device arrays
float2* velocities_d;
float4* planet... |
2,978 | //pass
//--blockDim=1024 --gridDim=1
__device__ void bar(char **in, char **out) {
char tmp = (*in)[threadIdx.x];
out[0][threadIdx.x] = tmp;
*out = *in;
}
__global__ void foo(char *A, char *B, char c)
{
char *choice1 = c ? A : B;
char *choice2 = c ? B : A;
bar(&choice1, &choice2);
bar(&choice1, &choice2)... |
2,979 | #include<stdio.h>
__global__ void kernel(int *d_o,int*d_i)
{
int index=threadIdx.x+blockIdx.x*blockDim.x;
if(index<10)
{
int temp=d_i[index+1];
__syncthreads();
d_o[index]=temp;
__syncthreads();
}
}
int main()
{
const int N=10;
int h_i[N];
int h_o[N];
... |
2,980 | /////////////////////////////////////////////////////////////////////////
// Parallel Computing Assignment 3
// Chris Jimenez
// 5/1/14
// This CUDA program finds the max integer in an array of random integers.
// This program DOES use shared meemory and DOES take thread
// divergaence in to consideration. The n... |
2,981 | __global__ void DotProd_kernel(float *result, const float* vec1, const float* vec2, int N)
{
// YOUR TASKS:
// - Write kernel body to compute element-wise product between elements of vec1 and vec2 and return result in
// new vec.
// - Make sure that arbitrary sizes of N can be used.
// Insert code below ... |
2,982 | /***
* Ashutosh Dhar
* Department of Electrical and Computer Engineeing
* University of Illinois, Urbana-Champaign
*
*/
#include <cuda.h>
#include <iostream>
#include <cstdio>
#define THREADS_PER_SM 1
#define BLOCKS_PER_SM 1
int ITERATIONS;
int L2_CACHE_SIZE = 512*1024;
int DATA_SIZE;// (L2_CACHE_SIZE * ITERATIONS)
... |
2,983 | #include <math.h>
#define SIGN(x) ((x) > 0.0 ? 1 : -1)
__global__ void init_image_kernel(float *img) {
size_t xi = blockIdx.x;
size_t yi = blockIdx.y;
size_t zi = threadIdx.x;
size_t imgIdx = zi + yi*blockDim.x + xi*blockDim.x*gridDim.y;
img[imgIdx] = 0.0;
}
__global__ void calculate_cos_alpha_and_tempc
(f... |
2,984 | #include <cmath>
__global__ void call_min(double* first, const double* second)
{
first[threadIdx.x] = std::fmin(first[threadIdx.x], second[threadIdx.x]);
}
|
2,985 | #include <stdio.h>
int main ( int argc, char *argv[ ] ) {
int x, y, *z;
if ( argc != 2 ) /* argc should be 4 for correct execution */
{
/* We print argv[0] assuming it is the program name */
printf( "\nusage: %s filenametoread \n\n", argv[0] );
}
else
{ //assumes space separate integer values e.g. -... |
2,986 | #include "includes.h"
__global__ void Prepare_1_MeansForJoin(float* input, int c_src1, int c_src2, int c_n, float* delta, int imageWidth, int imageHeight)
{
int id = blockDim.x * blockIdx.y * gridDim.x
+ blockDim.x * blockIdx.x
+ threadIdx.x;
int size = imageWidth * imageHeight;
if (id < size)
{
int px = id % imageWi... |
2,987 | #include "includes.h"
__global__ void findRadixOffsets(uint2* keys, uint* counters, uint* blockOffsets, uint startbit, uint numElements, uint totalBlocks)
{
__shared__ uint sStartPointers[16];
extern __shared__ uint sRadix1[];
uint groupId = blockIdx.x;
uint localId = threadIdx.x;
uint groupSize = blockDim.x;
uint2 ... |
2,988 | #include "system.cuh"
#include <assert.h>
#include <string>
__device__ __host__ void job::job_release(int time) {
assert(_state == Created);
_release_time = time;
_state = Ready;
}
__device__ __host__ void job::activate() {
assert(_state == Ready);
_state = Running;
}
__device__ __host__ void job::preempt() {
... |
2,989 | #include <stdlib.h>
#include <stdio.h>
__global__ void vector_add(const float *a, const float *b, float *c, const size_t n){
unsigned int i = threadIdx.x + blockDim.x*blockIdx.x;
if(i<n)
c[i] = a[i] + b[i];
}
int main(){
const int num_elements = 1<<20;
const int num_bytes = num_elements*sizeof(float);
float *de... |
2,990 | #include <fstream>
#include "native_kernel.h"
int main(int argc, char **argv)
{
std::ifstream values;
values.open("./values.txt");
int D,N;
int niter = atoi(argv[1]);
float learn = atof(argv[2]);
float *xvalues,*y_actual,*real_weights,*weights;
values>>D>>N;
printf("N = %d D = %d",N,D);
xvalues = ... |
2,991 | // This example introduces CUDA's abstraction of data parallel computational
// "kernels", or __global__ functions. A __global__ function acts like the
// main() function of a GPU program, and is allowed to manipulate device
// memory directly.
#include <stdlib.h>
#include <stdio.h>
// "kernels" or __global__ funct... |
2,992 | #include<stdlib.h>
#include<stdio.h>
/* The purpose of these microkernels is to
offer the user a sanity check. These microkernels
take the exact same parameters as their "real"
implementations and perform simple modifications
so the user can be sure the kernel is unpacking
and modifying the parameters the correct... |
2,993 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#define SIZE 1024
__global__ void VectoAdd(int *a, int *b, int *c, int n)
{
int i = threadIdx.x;
if (i<n)
{
c[i] = a[i] + b[i];
}
}
__global__ void square(float *dout, float* din)
{
int idx = threadIdx.x;
float f = din[idx];
... |
2,994 | #include "includes.h"
__global__ void EmptyKernel() {
//extern __shared__ thrust::complex<float> filter_products[];
} |
2,995 | #include "includes.h"
__global__ void UpdateParamsLinear(float *dZ, float *A, int nRowsdZ, int nColsdZ, int nRowsA, float lr, float *W, float *b)
{
int row = blockIdx.y * blockDim.y + threadIdx.y;
int col = blockIdx.x * blockDim.x + threadIdx.x;
float dWValue = 0, dbValue = 0;
if (row < nRowsdZ && col < nRowsA)
{
for... |
2,996 | #include "includes.h"
__global__ void VecAdd(const float *xs, const float *ys, float *out, const unsigned int N)
{
unsigned int idx = blockDim.x * blockIdx.x + threadIdx.x;
if (idx < N)
out[idx] = xs[idx] + ys[idx];
} |
2,997 | #include <stdio.h>
void handle_error( cudaError_t error, const char* message)
{
if(error!=cudaSuccess) {
fprintf(stderr,"ERROR: %s : %s\n",message,cudaGetErrorString(error));
exit(-1);
}
}
__global__ void reduce_add (int * array, int * result){
// Here's how to do an O(ln N) reduce in pure
// low-level CUD... |
2,998 | #include <stdio.h>
#include <math.h>
__global__ void heat_step(float * d_out, float * d_in)
{
// int block_x = blockIdx.x;
// int block_y = blockIdx.y;
int x_glob;
int y_glob;
int x_total_dim = blockDim.x * gridDim.x;
int y_total_dim = blockDim.y * gridDim.y;
int location;
x_glob = blo... |
2,999 | #include<iostream>
__global__ void transKernel(int *A, int *A_t, int N){
int x_index = threadIdx.x + blockIdx.x*blockDim.x;
int y_index = threadIdx.y + blockIdx.y*blockDim.y;
if(x_index < N && y_index < N){
A_t[x_index*N+y_index] = A[y_index*N+x_index];
}
}
int main(){
int N = 256;
int size = N*N*sizeof(int... |
3,000 | #include "includes.h"
__global__ void update_mean(double* pressure_mean_d, double* pressure_d, double* Rho_mean_d, double* Rho_d, double* Mh_mean_d, double* Mh_d, double* Wh_mean_d, double* Wh_d, int n_since_out, int num) {
int id = blockIdx.x * blockDim.x + threadIdx.x;
int nv = gridDim.y;
int lev = blockId... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.