serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
3,001 | #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 BLOCK_SIZE 1024
#define MAX_GRID 1024
__g... |
3,002 | #include<stdio.h>
__global__ void add1(int *g_A){
atomicAdd(&g_A[0], 1);
}
int main()
{
int *h_A;
int *d_A;
h_A = (int*)malloc(sizeof(int));
cudaMalloc((void**)&d_A, sizeof(int));
cudaMemset(d_A,0,sizeof(int));
add1<<<1024, 1024>>>(d_A);
cudaMemcpy(h_A,d_A,sizeof(int),cudaMemcpyDeviceToHost);
printf("%d... |
3,003 | #include <stdio.h>
__global__ void firstParallel()
{
printf("This should be running in parallel.\n");
}
int main()
{
firstParallel<<<5,5>>>();
cudaDeviceSynchronize();
}
|
3,004 | #include<stdio.h>
#include<stdlib.h>
typedef struct {
unsigned char red,green,blue;
} PPMPixel;
typedef struct {
int x, y;
PPMPixel *data;
} PPMImage;
#define CREATOR "COMP3231"
#define RGB_COMPONENT_COLOR 255
static PPMImage *readPPM(const char *filename)
{
char buff[16];
PPMImage... |
3,005 | #include <cuda.h>
#include <stdio.h>
#include <sys/time.h>
#define CHECK(call) { \
cudaError_t err; \
if ( (err = (call)) != cudaSuccess) { \
fprintf(stderr, "Got error %s at %s:%d\n", cudaGetErrorString(err), \
__FILE__, __LINE__); \
exit(1); \
} \
}
__global__ void kernel2(int *a, int *b, int c)
{
int t... |
3,006 | #include "Globals.cuh"
#include <device_launch_parameters.h>
__global__ void sum(int* input, int* output, int workSize) {
__shared__ int shared[numberOfThreads + 2 * blurRadius];
int globalIndex = threadIdx.x + blockIdx.x * blockDim.x;
int localIndex = threadIdx.x + blurRadius;
if (globalIndex < workSize) {
a... |
3,007 | #include "includes.h"
//==========================================================================
// Kernels
//==========================================================================
//==========================================================================
//======================================================... |
3,008 | #include <iostream>
#include <chrono>
#define BLOCKSIZE 256
__global__ void polynomial_expansion(float *poly, int degree, int n, float *array)
{
//TODO: Write code to use the GPU here!
//code should write the output back to array
int index = threadIdx.x + blockIdx.x * blockDim.x;
if (index < n)
{
... |
3,009 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <curand.h>
typedef struct group {
// array of pointer of points
int *p;
// how many points in the group
unsigned int length;
}Group;
typedef struct cluster {
// array of pointer of groups
Group** g;
int num_point;
}Cluster... |
3,010 | #include "includes.h"
__global__ void count_spikes(const double *Params, const int *id, int *nsp, const float *x, float *V){
int tid, tind, bid, ind, Nspikes, Nfilters, NthreadsMe, Nblocks;
Nspikes = (int) Params[0];
Nfilters = (int) Params[2];
tid = threadIdx.x;
bid = blockIdx.x;
Nthre... |
3,011 | #include "includes.h"
__global__ void grayScale(uchar3 *input, uchar3 *output) {
int tid = threadIdx.x + blockIdx.x * blockDim.x;
output[tid].x = (input[tid].x + input[tid].y +
input[tid].z) / 3;
output[tid].z = output[tid].y = output[tid].x;
} |
3,012 | #include "includes.h"
__global__ void Initialize_Kernel(int size, unsigned int *randoms, int *bestSeen, int *origin, int *mis, int *incomplete)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < size)
{
// Taustep is performed with S1=13, S2=19, S3=12, and M=UINT_MAX coded into kernel
unsigned int z = randoms... |
3,013 | #include<iostream>
using namespace std;
__global__ void minimum(int *input)
{
int tid = threadIdx.x;
int step_size = 1;
int number_of_threads = blockDim.x;
while(number_of_threads > 0)
{
if(tid < number_of_threads)
{
int first = tid*step_size*2;
int second = first + step_size;
if(... |
3,014 | #include "includes.h"
__global__ void relabelUnrollKernel(int *components, int previousLabel, int newLabel, const int colsComponents, const int idx, const int frameRows, const int factor) {
uint id_i_child = (blockIdx.x * blockDim.x) + threadIdx.x;
id_i_child = id_i_child + (frameRows * idx);
uint id_j_child = (blockId... |
3,015 | #include <iostream>
#include <stdio.h>
__global__ void print(){
printf("KYU NHI CHAL RHAA\n");
}
int main(){
int n = 3;
int x[n];
x[0] = 0;
x[1] = 1;
x[2] = 2;
for(int i=0;i<n;++i){
for(int j=0;j<n;++j){
if(i != j){
std::cout<<i<<" "<<j<<std::endl;
cudaSetDevice(j);
int* d... |
3,016 | #include "includes.h"
__global__ void callOperationSharedStatic(int * a, int *b, int *res, int n)
{
int tid = blockDim.x * blockIdx.x + threadIdx.x;
if (tid >= n)
{
return;
}
__shared__ int s_a[size], s_b[size], s_res[size];
s_a[tid] = a[tid];
s_b[tid] = b[tid];
s_res[tid] = s_a[tid] - s_b[tid];
if (s_res[tid] < 0)... |
3,017 | #include "includes.h"
__global__ void windowKernel(float* idata, float* window, int width, int height)
{
int tidx = threadIdx.x + blockIdx.x*blockDim.x;
int tidy = threadIdx.y + blockIdx.y*blockDim.y;
if(tidx < width && tidy < height)
{
idata[tidy * width + tidx] = window[tidx] * idata[tidy * width + tidx];
}
} |
3,018 | #include "includes.h"
__global__ void updateOutputWeights(float* d_weights, float error, float lr, int keypress, int numHiddenNeurons, float* outputTotals, int numInput){
int id = threadIdx.x + blockDim.x * blockIdx.x;
int index = numHiddenNeurons * keypress + id;
float certainty = 0.0f;
for (int i = 0; i < numInput;... |
3,019 | /*
* EyRightUpdater.cpp
*
* Created on: 01 февр. 2016 г.
* Author: aleksandr
*/
#include "EyRightUpdater.h"
#include "SmartIndex.h"
/*
* indx должен пренадлежать участку от [0, sizeY-1]
*/
__device__
void EyRightUpdater::operator() (const int indx) {
int n = indx;
Ey(sizeX - 1, n) = coeff[0]*(Ey(sizeX ... |
3,020 | #include <stdio.h>
#define CHECK(call) \
{ \
const cudaError_t error = call; \
if (error != cudaSuccess) ... |
3,021 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <sys/time.h>
#define dT 0.2f
#define G 0.6f
#define BLOCK_SIZE 32
// Global variables
int num_planets;
int num_timesteps;
// Host arrays
float2* velocities;
float4* planets;
// Device arrays
float2* veloc... |
3,022 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <math.h>
#define COMMENT "Histogram_GPU"
#define N_BINS 64
#define N_THREADS 128
#define RGB_COMPONENT_COLOR 255
typedef struct {
unsigned char red, green, blue;
} PPMPixel;
typedef struct {
int x, y;
PPMPixel *data;
} PPMImage;
doub... |
3,023 | #include "includes.h"
__global__ void sga_down_data_backward (const int n, const float *filters, float *top_diff, const int height, const int width, const int depth, const int wsize, float *bottom_diff){
int index = blockIdx.x * blockDim.x + threadIdx.x;
if (index >= n)
{
return;
}
int step = height * width;
int base =... |
3,024 | #include "includes.h"
// risky
#define dfloat double
#define p_eps 1e-6
#define p_Nsamples 1
// ratio of importance in sampling primary ray versus random rays
#define p_primaryWeight 2.f
#define p_intersectDelta 0.1f
#define p_shadowDelta 0.15f
#define p_projectDelta 1e-2
#define p_maxLevel 5
#define p_maxNrays (... |
3,025 | #include "scan.h"
__global__ void
scan_v2_kernel(float *d_output, float *d_input, int length)
{
int idx = blockDim.x * blockIdx.x + threadIdx.x;
int tid = threadIdx.x;
extern __shared__ float s_buffer[];
s_buffer[threadIdx.x] = d_input[idx];
s_buffer[threadIdx.x + BLOCK_DIM] = d_input[idx + BLOCK_... |
3,026 | #include <stdio.h>
#include "imageutils.cuh"
// weights of each color channel
#define RED_WEIGHT (0.299f)
#define GREEN_WEIGHT (0.587f)
#define BLUE_WEIGHT (0.114f)
// dimensions of the thread blocks
#define NUM_BLOCKS_X 16
#define NUM_BLOCKS_Y 16
__global__
void rgba_to_negative(
uchar4 *rgbaImage,
unsigned ... |
3,027 | #include "includes.h"
__global__ void compute_distances(float * ref, int ref_width, int ref_pitch, float * query, int query_width, int query_pitch, int height, float * dist) {
// Declaration of the shared memory arrays As and Bs used to store the sub-matrix of A and B
__shared__ float shared_A[BLOC... |
3,028 | #include <stdio.h>
#include <sys/time.h>
#include <stdlib.h>
#include <unistd.h>
//define the check err
#define CHECK_ERR(x) \
if (x != cudaSuccess) { \
fprintf(stderr,"%s in %s at line %d\n", \
cudaGetErrorString(err),__FILE__,_... |
3,029 | #include "includes.h"
__global__ void kernBiasAndLog(double* sumexp, double* bias) {
*sumexp = *bias + log(*sumexp);
} |
3,030 | //Based on the work of Andrew Krepps
#include <stdio.h>
#include <stdlib.h>
#define ARRAY_SIZE N
#define ARRAY_SIZE_IN_BYTES (sizeof(unsigned int) * (ARRAY_SIZE))
#define FIRST_ASCII_SYMBOL 65
//65=A
#define LAST_ASCII_SYMBOL 122
//122 = z
#define SHIFT 4
#define LETTER_RANGE LAST_ASCII_SYMBOL - FIRST_ASCII_SYMBOL
... |
3,031 | #include <stdio.h>
#include <cuda.h>
#include "cuda_runtime_api.h"
#include <stdint.h>
#include <stdlib.h>
//This is the working matrix multiplication code - very basic
/*
Done:
- printing of matrix in a more pleasant manner using printMatrix function
- command line arguments
- opens matrix files and reads the matrix ... |
3,032 | #include <thrust/device_vector.h>
#include <iostream>
int main(void){
int xs[2] = {1,2};
thrust::device_vector<int> d_xs(xs, xs+2);
thrust::device_vector<int> d_ys(xs, xs+2);
std::cout << (d_xs == d_xs) << std::endl;
if(d_xs != d_xs){
std::cout << "FALSE" << std::endl;
}
if(d_xs != d_ys){
std::co... |
3,033 | #include <iostream>
#include <cstdio>
#define BLOCK_SIZE 16
#define SIZE_RATE 200
struct matrix{
int height;
int width;
float *elements;
};
void printMatrix(matrix M){
for(int i = 0; i < M.height; i++){
for(int j = 0; j < M.width; j++){
if(j != 0) std::cout << " ";
std::cout << M.elements[i*M... |
3,034 | #include <stdlib.h>
#include "constants.cuh"
#include "mesh.cuh"
#include "matrix_functions.cuh"
//----------------------------------------------PROTOTIPES--------------------------------------
void create_noderns(int *noderns, struct mesh *mesh);
void create_edofvec(int *edofvec, int *noderns, struct mesh *mesh);
vo... |
3,035 | /*
Author: Su Ming Yi
Date: 11/16/2018
Goal: use CUDA to sum up two numbers
Because we do not have the gpu resource of OSC now,
we cannot get the correct portion from gpu and host.
How to compile it:
qsub -I -l walltime=00:59:00 -l nodes=1:gpus=1,mem=4gb -A PAS0027
module load cuda
nvcc -o example_1 examp... |
3,036 | #include "includes.h"
__global__ void uchar4tofloat4(uchar4 *inputImage, float4 *outputImage, int width, int height)
{
int offsetX = blockIdx.x * blockDim.x + threadIdx.x;
int offsetY = blockIdx.y * blockDim.y + threadIdx.y;
if (offsetX < width && offsetY < height)
{
int offsetBlock = blockIdx.x * blockDim.x + blockId... |
3,037 | #include "includes.h"
__global__ void set_chunk_data_vertices( int x, int y, int halo_depth, double dx, double dy, double x_min, double y_min, double* vertex_x, double* vertex_y, double* vertex_dx, double* vertex_dy)
{
const int gid = blockIdx.x*blockDim.x+threadIdx.x;
if(gid < x+1)
{
vertex_x[gid] = x_min + dx*(gid-h... |
3,038 | //xfail:ASSERTION_ERROR
//--blockDim=1024 --gridDim=1 --no-inline
__constant__ int A[1024];
__global__ void foo(int *B) {
A[threadIdx.x] = B[threadIdx.x];
}
|
3,039 | #include <stdio.h>
#include <stdlib.h>
const int shared_size = 4;
// Square matrix multiplication with dimention that has power of 8
__global__ void kernel(float *a, float *b, float *c, int i, int j, int n){
// const int shared_size = n;
__shared__ float cache[shared_size];
int idx = threadIdx.x;
if(idx < ... |
3,040 | #include <cassert>
#include <chrono>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <random>
constexpr int TILE_DIM = 32;
__global__
void multiplication( int * a, int * b, int * c, int dim) {
// create shared memory
__shared__ int m[TILE_DIM][TILE_DIM];
__shared__ int... |
3,041 | #include <stdio.h>
#include <assert.h>
#include <string.h>
#include <cuda.h>
#define BLOCK_SIZE 4
void checkCudaError(cudaError_t errorCode)
{
if (errorCode != cudaSuccess)
fprintf(stderr, "Error %d\n", errorCode);
}
void incrementArrayOnHost(float *a, int size, int k)
{
int i;
for (i = 0; i < si... |
3,042 | #include "includes.h"
__global__ void pcr_k(float a, float b, float c, float* y, int n) {
// Identifies the thread working within a group
int tidx = threadIdx.x % n;
// Identifies the data concerned by the computations
int Qt = (threadIdx.x - tidx) / n;
// The global memory access index
int gb_index_x = Qt + blockIdx.x... |
3,043 | #include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<iostream>
#define N 256*256
using namespace std;
__global__ void reduce(int *input, int *output) {
__shared__ int shared_data[256];
int i = blockIdx.x * blockDim.x + threadIdx.x;
shared_data[threadIdx.x] = input[i];
__sync... |
3,044 | /*
The shared memory is allocated using the __shared__ memory space specifier.
Shared memory is expected to be much faster than global memory.
The following code sample is a straightforward implementation of matrix multiplication
that does not take advantage of shared memory. Each thread reads one row of A and one
c... |
3,045 | /*
other things we should test:
- struct pointer, with offset
- multiple struct pointers, cut from same buffer
- getting values from various types of structs passed in
*/
#include <iostream>
#include <memory>
#include <cassert>
using namespace std;
#include <cuda.h>
struct Struct_fp_fp_f_f {
float *p1;
floa... |
3,046 | #include "includes.h"
#define FIBER 32
#define MATRIX_SIZE 2048
#define DATA_SIZE MATRIX_SIZE * MATRIX_SIZE * sizeof(int)
#define MAX_MATRIX_SIZE (MATRIX_SIZE * MATRIX_SIZE)
using namespace std;
__global__ void kernel(int *A, int *C, int *B, int *result) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
int j = bl... |
3,047 | #include <stdio.h>
#include <stdlib.h>
/* check for CUDA error */
#define CHECK_ERROR check_cuda_error(__LINE__-1, __FILE__)
/* #bodies */
static int N;
/* #threads/block (leapfrog) */
static int TPB = 128;
/* #tiles (acceleration kernel) */
static int P;
/* #timesteps */
static int TIMESTEPS = 1000;
/* softening ... |
3,048 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <iostream>
#include <chrono>
#include <stdlib.h>
const int m = 14400;
const int n = 14400;
// CUDA Kernel for MatrixAddition
__global__ void MatAdd(float* A, float* B, float* C) {
int i = blockIdx.x * blockDim.x + threadI... |
3,049 | //******************************************************************************
// Final Project
// Name: Andrew McKissick
// GPU Computing Date: 12/5/16
//******************************************************************************
// This program performs a Fast Fourier transform on a set of complex numbers.
// In... |
3,050 | #include <iostream>
#include <fstream>
#include <sstream>
#include <stdlib.h>
#include <cuda_runtime.h>
__global__ void
convolution(const float *A, const float *B, float *C, int a_rows, int a_cols, int b_rows, int b_cols, int c_rows, int c_cols)
{
int m = blockDim.y * blockIdx.y + threadIdx.y;
int n = blockDi... |
3,051 | #include "includes.h"
__global__ void saveTheWhalesX ( const int d0, const int d1, const int i0, const int i2, float *xxx, const int d3, const float *x ) {
int i = threadIdx.x + blockDim.x * blockIdx.x;
if ( i < d3 ) {
xxx[i0+i*d0+i2*d0*d1] = x[i];
}
} |
3,052 | #include <iostream>
#include <math.h>
#include <vector>
#include <iomanip>
#include <sstream>
#include <string>
#include <fstream>
#include <thread>
#include <ctime>
#include <stdio.h>
__device__ static inline void setSeed(int64_t *seed)
{
*seed = (*seed ^ 0x5deece66d) & ((1LL << 48) - 1);
}
__device__ static inli... |
3,053 | extern "C" __global__ void test(
void* arguments,
int arguments_size,
void* result_buffer,
int result_buffer_size,
void* node_local_data,
int node_local_data_size) {
int ii = blockDim.x * blockIdx.x + threadIdx.x;
int elements = arguments_size / sizeof(float) / 2;
if (ii >= elements)
return;
flo... |
3,054 | #include "cuda_runtime.h"
#include <stdio.h>
int main(void) {
cudaDeviceProp prop;
int count;
cudaGetDeviceCount(&count);
printf("Device count: %d\n", count);
for(int i = 0; i < count; ++i) {
cudaGetDeviceProperties(&prop, i);
printf("Device's name(%d): %s\n", i, prop.name);
printf(" Tota... |
3,055 | // -1/target probability if target = 1.0, 0.0 otherwise
__global__ void backwardLogisticLossKernel (float *predictions, float *targets, float *result)
{
int globalId = blockIdx.x * blockDim.x + threadIdx.x;
result[globalId] = targets[globalId] * -(1.0/predictions[globalId]);
} |
3,056 | /*
* TopBottomUpdaterTE.cpp
*
* Created on: 05 февр. 2016 г.
* Author: aleksandr
*/
#include "TopBottomUpdaterTE.h"
#define Ex(M, N) Ex[(M) * (sizeY) + (N)]
#define Ey(M, N) Ey[(M) * (sizeY-1) + (N)]
#define Hz(M, N) Hz[(M) * (sizeY-1) + (N)]
#define epsilon(M, N) epsilon[(M) * (sizeY) + (N)]
__device__
v... |
3,057 | #include <cstdio>
#include <cstdlib>
#include <vector>
// Update bucket in parallel.
// Each thread represents a key and will increment the corresponding bucket.
__global__ void putBucket(int *key, int *bucket, int n) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
if(i >= n) return;
atomicAdd(&bucket[key[i]], ... |
3,058 | #include "shape.hh"
#include <cassert>
namespace ops
{
Shape::Shape(const std::vector<int>& dims)
: dims_(dims)
{}
const std::vector<int>& Shape::dims() const
{
return dims_;
}
std::size_t Shape::ndims() const
{
return dims_.size();
}
int Shape::opera... |
3,059 | #include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <thrust/random/linear_congruential_engine.h>
#include <thrust/random/uniform_real_distribution.h>
#include <iostream>
// nvcc -std=c++14 -O3 tarefa1.cu -o t1 && ./t1
int main()
{
int seed;
std::cin >> seed;
// default_random_engine... |
3,060 | #include "includes.h"
__global__ void add(int *a, int *b, int *c)
{
// each block handles a different element of the array
// on the device, each block can execute in parallel
// use blockIdx.x to access block index
c[blockIdx.x] = a[blockIdx.x] + b[blockIdx.x];
} |
3,061 | #include <stdlib.h>
#include <string.h>
#include <time.h>
#include <iostream>
void sumArraysOnHost(float *A, float *B, float *C, const int N) {
for (int idx=0; idx<N; idx++) {
C[idx] = A[idx]+B[idx];
}
}
void initialData(float *ip, int size) {
// generate different seed for random number
time_t t;
srand... |
3,062 | #define MATRIX_SIZE 1024
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <chrono>
// Kernel Function Definition
// Pass the matrices as arrays
__global__ void SqMatrixMul(float* A, float* B, float* C, int N) {
int ROW = blockIdx.y * blockDim.y + threadIdx.y;
int COL = blockIdx.x * blockDim.x + ... |
3,063 | /***************************************************************************//**
* \file weight.cu
* \author Christopher Minar (minarc@oregonstate.edu)
*/
#include "weight.h"
namespace kernels
{
__global__
void alpha_u(double *alpha, int *ghostTagsUV, int *hybridTagsUV, double *yu, double *xu,
double *body_int... |
3,064 | /*
**********************************************
* CS314 Principles of Programming Languages *
* Spring 2020 *
**********************************************
*/
#include <stdio.h>
#include <stdlib.h>
/**
* Performs segment scan to find strongest neighbor for each src node
* @param ... |
3,065 |
#include <stdio.h>
__global__ void use_local_memory_GPU(float in)
{
float f;
f = in;
}
__global__ void use_global_memory_GPU(float *array)
{
array[threadIdx.x] = 2.0f * (float) threadIdx.x;
}
__global__ void use_shared_memory_GPU(float *array)
{
int i, index = threadIdx.x;
... |
3,066 | #include <iostream>
#include <math.h>
//function to add the elements of two arrays
__global__
void add(int n, float *x, float *y)
{
int index = threadIdx.x;
int stride = blockDim.x;
for (int i = index; i < n; i+= stride)
y[i] = x[i] + y[i];
}
int main(void)
{
int N = 1<<20; //1M elements
//int N = 100; //100 e... |
3,067 | #include <cstdio>
#include <cstdlib>
#include <vector>
//----------Change Begin----------------
__global__ void for_1(int *bucket_cu) {
int i=blockIdx.x * blockDim.x + threadIdx.x;
bucket_cu[i]=0;
//printf("%d\n",i);
}
__global__ void for_2(int n,int *bucket_cu,int *key){
int i=blockIdx.x * blockDim.x + threadIdx.... |
3,068 | #include "includes.h"
__global__ void cudaSRectifier_backPropagate_kernel(float* x, float* dx, unsigned int size, float leakSlope, float clipping)
{
const unsigned int index = blockIdx.x * blockDim.x + threadIdx.x;
const unsigned int stride = blockDim.x * gridDim.x;
for (unsigned int i = index; i < size; i += stride) ... |
3,069 | /* jacobi.c - Poisson problem in 3d
*
*/
#include <math.h>
#include <stdio.h>
__device__ void print_matrix2(double*** A, int N){
int i,j,k;
for (i=0; i<N; i++){
printf("\n %d -th Layer \n", i);
for(j=0; j<N; j++){
for(k=0; k<N; k++){
printf("%lf \t", A[i][j][k]);
}
printf("\n");
}
}
}
__globa... |
3,070 | #include <bits/stdc++.h>
#include <cuda.h>
#define M 64
#define N 64
#define TILE_WIDTH 16
__global__ void tiled_matrix_multiplication(int *A, int *B, int *C) {
__shared__ int As[TILE_WIDTH][TILE_WIDTH];
__shared__ int Bs[TILE_WIDTH][TILE_WIDTH];
int bx = blockIdx.x;
int by = blockIdx.y;
int tx = threadIdx.x;... |
3,071 | #include "includes.h"
__global__ void KerSortDataParticles(unsigned n,unsigned pini,const unsigned *sortpart,const double2 *a,const double *b,const float4 *c,double2 *a2,double *b2,float4 *c2)
{
const unsigned p=blockIdx.x*blockDim.x + threadIdx.x; //-Particle number.
if(p<n){
const unsigned oldpos=(p<pini? p: sortpart... |
3,072 | #include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define BLOCKDIM 1024
/*
#include <thrust/device_vector.h>
#include <thrust/reduce.h>
#include <thrust/functional.h>
#include <thrust/inner_product.h>
using namespace thrust;
using namespace thrust::placeholders;
*/
#defin... |
3,073 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <math.h>
//Problem Size 2^25
#define N 33554432
#define THREADS_PER_BLOCK 128
//This kernel is responsible for the following tasks
//Compute distance between each data point and the cluster centroids
//Based on distance assign the point to the closest c... |
3,074 | #include "includes.h"
__global__ void cudaDclamp_kernel(double* x, unsigned int size, double minVal, double maxVal)
{
const unsigned int index = blockIdx.x * blockDim.x + threadIdx.x;
const unsigned int stride = blockDim.x * gridDim.x;
for (unsigned int i = index; i < size; i += stride) {
x[i] = (x[i] < minVal) ? minV... |
3,075 | #include <stdio.h>
using namespace std;
__global__ void hello(){
printf("hello world from GPU!\n");
return;
}
int main(){
hello<<<1,1>>>();
cudaError_t err = cudaDeviceSynchronize();
if(err != cudaSuccess){
printf("kernel launch failed with error %s\n", cudaGetErrorString(err));
}
return 0;
}
|
3,076 | #include <iostream>
#include <math.h>
using namespace std;
__global__ void min1(int *a,int *b,int n)
{
int index=256*blockIdx.x;
int mini=999999;
for(int i=index;i<min(256+index,n);i++)
{
if(a[i]<mini)
{
mini=a[i];
}
}
b[blockIdx.x]=mini;
}
int main()
{
int n=0;
cout<<"Enter n:";
cin>>n;
int *a=(i... |
3,077 | #include <time.h>
#include <stdio.h>
#define N (48*1024)
#define M (48*1024)
#define P 256
#define SIZE 4
float rand_unit_box() {
return (rand() + 0.5) / (RAND_MAX + 1.0) - 0.5;
}
template<class T>
struct SharedMemory {
__device__ inline operator T *() {
extern __shared__ int __smem[];
return (... |
3,078 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <assert.h>
#ifndef THREADS_PER_BLOCK
#define THREADS_PER_BLOCK 1024
#endif
#define CUDA_ERROR_CHECK
#define CudaSafeCall( err ) __cudaSafeCall( err, __FILE__, __LINE__ )
inline void __cudaSafeCall( cudaError err, const char *file, const int line )... |
3,079 | extern "C"
{
__global__ void Dstanh_32(const int lengthX, const float sf, const float *gradc, const float *fc, float *gradn)
{
int i = threadIdx.x + blockIdx.x * blockDim.x;
if (i<lengthX)
{
gradn[i] += sf*gradc[i]*(1.0-(fc[i]/sf)*(fc[i]/sf));
}
}
} |
3,080 |
#include <iostream>
#include <ctime>
#include <stdlib.h>
#include <math.h>
#include <cstdio>
using namespace std;
//Set tolerance for the check
#define TOLERANCE 0.001
#define BLOCK_SIZE 1024
__global__ void scan (int * arr, int * arr_gpu, int n){
__shared__ float temp[BLOCK_SIZE];
int i = blockIdx.x * blockDim... |
3,081 | #include "includes.h"
__global__ void check_collisions( float x1_robot, float y1_robot, float x2_robot, float y2_robot, float *x1_obs, float *y1_obs, float *x2_obs, float *y2_obs, bool *collisions, int *indexes)
{
int obstacleId = threadIdx.x;
bool xcol = ((x1_obs[obstacleId] <= x1_robot && x1_robot <= x2_obs[obstacle... |
3,082 | #include <stdio.h>
#include <cuda.h>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#define BLOCKSIZE_X 16
#define BLOCKSIZE_Y 18
#define FILTER_LENGTH 9
#define FILTER_RADIUS 1
__constant__ unsigned char c_Filter[FILTER_LENGTH];
extern "C" void setFilter(unsigned char *h_Filter)
{
cudaMemcpyT... |
3,083 | #include <iostream>
__global__ void scan(int* v, const int n);
int main(int argc, char** argv) {
const int size = 10;
int h_v[size] = { 3, 7, 1, 10, 6, 9, 5, 2, 8, 4 };
int *d_v = 0;
cudaMalloc((void**)&d_v, size * sizeof(int));
cudaMemcpy(d_v, h_v, size * sizeof(int), cudaMemcpyHostToDevice);
dim3 grdDim... |
3,084 | /***************************************************************************//**
* \file LHS2.cu
* \author Christopher Minar (minarc@oregonstate.edu)
* \brief kernels to generate the left hand side for the poission solve
*/
#include "LHS2.h"
namespace kernels
{
__global__
void LHS2_mid_luo(int *row, int *col, dou... |
3,085 | /*
Copyright (c) 2016, David lu
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following di... |
3,086 | #pragma once
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <iostream>
#define pn(x) printf("%5.2f ", (double)x)
using namespace std;
template <typename T>
class gpuMat
{
public:
T* h_elems = nullptr;
T* d_elems = nullptr;
int rows, cols;
gpuMat();
gpuMat(int rows, int cols);
~gpuM... |
3,087 | #include <stdio.h>
#include "cuda.h"
#define max(x,y) ((x) > (y)? (x) : (y))
#define min(x,y) ((x) < (y)? (x) : (y))
#define ceil(a,b) ((a) % (b) == 0 ? (a) / (b) : ((a) / (b)) + 1)
void check_error (const char* message) {
cudaError_t error = cudaGetLastError ();
if (error != cudaSuccess) {
printf ("CUDA error :... |
3,088 | #include "includes.h"
__global__ void kernel_array_beam_slave_sincos_original(int N, float r1, float r2, float r3, float *x, float *y, float *z, float *sum, int blockDim_2) {
unsigned int n=threadIdx.x; //+blockDim.x*blockIdx.x;
__shared__ float tmpsum[1000]; /* assumed to be size 2*Nx1 */
if (n<N) {
float ss,cc;
sinco... |
3,089 | extern "C"
__global__ void __launch_bounds__(256) sgemm_tt_128x128
(
const float* param_A,
const float* param_B,
float* param_C,
float param_alpha,
float param_beta,
int param_lda,
int param_ldb8,
int param_ldc,
int param_m,
int param_n,
int ... |
3,090 | #include "includes.h"
__global__ void gpu_Filter_peaks_kernel(unsigned int *d_new_peak_list_DM, unsigned int *d_new_peak_list_TS, unsigned int *d_new_peak_list_BW, float *d_new_peak_list_SNR, unsigned int *d_peak_list_DM, unsigned int *d_peak_list_TS, unsigned int *d_peak_list_BW, float *d_peak_list_SNR, unsigned int n... |
3,091 | #include <stdint.h>
#include <stdio.h>
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <stdint.h>
#include <vector>
#define long int64_t
// TODO: Fix speed calculation when these are different numbers.
#define INPUT_BLOCK_SIZE (2 << 20)
#define WORK_UNIT_SIZE (2 << 20)
#define CHECK... |
3,092 | #include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/generate.h>
#include <thrust/sort.h>
#include <thrust/copy.h>
#include <thrust/random.h>
#include <iostream>
#include <time.h>
int main(int argc, char **argv) {
double timer, timer_alloc;
clock_t start, start_a... |
3,093 | #include "includes.h"
__global__ void kernel_diagmu_fl(int M, float *A,float mu){
unsigned int tid = blockIdx.x*blockDim.x + threadIdx.x;
/* make sure to use only M threads */
if (tid<M) {
A[tid*(M+1)]=A[tid*(M+1)]+mu;
}
} |
3,094 | #include <stdio.h>
#include <errno.h>
#include "cs_header.h"
#include "cs_dbg.h"
#define CUDA_DBG
#ifdef CUDA_DBG
#define DBG_BUF_SIZE (1024 * 1024)
int *dbg_bufp, dbg_size ;
void dbg_pdata_ll( char *s, long long *dp, int size ) ;
int
dbg_init( int size )
{
if (!( dbg_bufp = ( int * ) malloc ( size )))
{
fp... |
3,095 | /*
Submitted By: Sulav Timsina
ID: 50502493
Course: CS 6253 Heterogeneous Computing
Spring , 2018
Submitted On; 04/16/2018
*/
/*
The device property can also be found from command line using the command:
lshw -C display
*/
#include <stdio.h>
int main() {
int nDevices;
cudaGetDeviceCount(&nDevices);
print... |
3,096 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
//function definition
__global__ void Fun1(int *a, int *b, int *c)
{
int i = blockIdx.x;
c[i] = a[i] + b[i];
}
__global__ void Fun2(int *a, int *b, int *c)
{
int i = threadIdx.x;
c[i] = a[i] + b[i];
}
__global_... |
3,097 | #include "frustrum.cuh"
#include <stdio.h>
#include <new>
__host__ __device__ Frustrum::Frustrum()
{
orig_a = Vec3();
orig_b = Vec3();
orig_c = Vec3();
orig_d = Vec3();
a = Vec3();
b = Vec3();
c = Vec3();
d = Vec3();
}
__host__ __device__ Frustrum::Frustrum(Vec3 position, Vec3 forwa... |
3,098 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <cstdio>
__global__ void print_threadIds() {
printf("blockIdx.x : %d, blockIdx.y : %d, blockIdx.z : %d , blockDim.x : %d, blockDim.y : %d, gridDim.x : %d, gridDim.y : %d \n",
blockIdx.x, blockIdx.y, blockIdx.z, blockDim.x, block... |
3,099 | /*
Sample Implementation of
Yamazaki and Tanaka (2005).
Neural Modeling of an Internal Clock.
Neural Computation 17:1032--1058.
using only global memory of CUDA.
Licensed under Creative Commons Attribution License (CC-BY)
http://creativecommons.org/licenses/by/3.0/
*/
#include<stdio.h>
#include... |
3,100 | #include "includes.h"
__global__ void self_dots(int n, int d, double* data, double* dots) {
double accumulator = 0;
int global_id = blockDim.x * blockIdx.x + threadIdx.x;
if (global_id < n) {
for (int i = 0; i < d; i++) {
double value = data[i + global_id * d];
accumulator += value * value;
}
dots[global_id] = accumul... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.