serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
16,801 | /*
__global__ void calcHistogramGlobal(unsigned int const d_dataVals[], unsigned int d_histogram[], const unsigned int iteration, const size_t numElems)
{
int myId = threadIdx.x + blockDim.x * blockIdx.x;
if(myId<numElems)
{
bool isOne=isBitByRight(d_dataVals[myId], iteration);
atomicAdd(&(d_histogram[isOne?1... |
16,802 | #include <iostream>
#include <stdio.h>
#include <vector>
#define MAX_THREADS 256
#define SIZE 524288
#define __START__ cudaEventCreate(&start); cudaEventCreate(&stop); cudaEventRecord(start, 0);
#define __STOP__(_V) cudaEventRecord(stop, 0); cudaEventSynchronize(stop); cudaEventElapsedTime(&time, start, stop); _V.pus... |
16,803 | #include <stdio.h>
#include <cuda_runtime.h>
#include <time.h>
__global__ void add_vec(int *a, int *b, int *c){
int k = blockIdx.x * blockDim.x + threadIdx.x;
c[k] = a[k] + b[k];
}
int repeat(int size){
int i, a_host[size], b_host[size], c_host[size], c_fromgpu[size];
for(i=0;i<size;i++){
a_ho... |
16,804 | #include <stdio.h>
__global__ void square(float *d_out, float *d_in)
{
int idx = threadIdx.x;
float f = d_in[idx];
d_out[idx] = f*f;
}
int main(int argc, char *argv[])
{
const int ARRAY_SIZE = 64;
const int ARRAY_BYTES = ARRAY_SIZE * sizeof(float);
// inicializando o array de input no host (p... |
16,805 | // #include <Dolphin>
int main(){} |
16,806 | #include <iostream>
#include <cstdlib>
using namespace std;
__global__ void add(int *a, int *b, int n){
int index = threadIdx.x + blockIdx.x * blockDim.x;
if(index<n){
a[index] += b[index];
}
}
__global__ void rad(int *a, int n){
int index = threadIdx.x + blockIdx.x * blockDim.x;
if(index... |
16,807 | #include <stdlib.h>
#include <stdio.h>
__global__ void helloWorld()
{
int thread = threadIdx.x;
printf("Hello World! My threadId is %d \n", thread);
}
int main()
{
helloWorld<<<1, 256>>>();
cudaDeviceSynchronize();
} |
16,808 | #include "includes.h"
__global__ void kernel2(int* D, int* q, int b){
int i, j;
if(blockIdx.y == 0)
{
j = b * blockDim.y + threadIdx.y;
if(blockIdx.x >= b)
{
i = (blockIdx.x + 1) * blockDim.x + threadIdx.x;
}
else
{
i = blockIdx.x * blockDim.x + threadIdx.x;
}
}
else
{
i = b * blockDim.y + threadIdx.y;
if(blockIdx.x >... |
16,809 | #include "includes.h"
__global__ void addMatrix(int *c, int *a, int *b){
int j = blockIdx.x*blockDim.x + threadIdx.x;
int i = blockIdx.y*blockDim.y + threadIdx.y;
*(c + blockDim.y*i + j) = *(a + blockDim.y*i + j) + *(b + blockDim.y*i + j);
} |
16,810 | #include "includes.h"
__global__ void KernelNormalVec(double *g_idata,double *g_odata,int l){ // Sequential Addressing technique
__shared__ double sdata[BLOCK_SIZE];
// each thread loads one element from global to shared mem
unsigned int tid = threadIdx.x;
unsigned int i = blockIdx.x*blockDim.x + threadIdx.x;
if(i<l){... |
16,811 | /*
* Noopur Maheshwari : 111464061
* Rahul Rane : 111465246
*/
#include <pthread.h>
#include <iostream>
using namespace std;
extern pthread_mutex_t lock;
int get_shared_var_value(int *ptr) {
int ret;
pthread_mutex_lock(&lock);
ret = *ptr;
pthread_mutex_unlock(&lock);
return ret;
}
void set_shar... |
16,812 | #define CONV_SOBEL_SIZE 3
#define CONV_GAUSSIAN_SIZE 5
__constant__ char SOBELX[CONV_SOBEL_SIZE*CONV_SOBEL_SIZE] = {-1,0,1,-2,0,2,-1,0,1};
__constant__ char SOBELY[CONV_SOBEL_SIZE*CONV_SOBEL_SIZE] = {1,2,1,0,0,0,-1,-2,-1};
__constant__ char GAUSSIAN[CONV_GAUSSIAN_SIZE*CONV_GAUSSIAN_SIZE] = {1,4,6,4,1,4,16,24,16,4,6,2... |
16,813 | #include <stdio.h>
/* experiment with N */
/* how large can it be? */
//#define N (2048*2048)
#define N 10240
#define THREADS_PER_BLOCK 4
__global__ void add(int *a, int *b, int *c)
{
/* insert code to calculate the index properly using blockIdx.x, blockDim.x, threadIdx.x */
int index = blockIdx.x * blockDim.x +... |
16,814 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
__global__ void parallel_for_loop() {
int index = blockIdx.x * blockDim.x + threadIdx.x;
printf("Current Iteration Number: %d\n", index);
}
class ParallelizedForLoopProgramMultipleBlocks {
public:
int nBlocks, nThreads;... |
16,815 | #include <iostream>
#include <random>
#include <algorithm>
#include <chrono>
void sumArraysOnHost(float *A, float *B, float *C, const int N)
{
int idx;
for (idx=0; idx<N; ++idx)
{
C[idx] = A[idx] + B[idx];
}
}
__global__ void sumArraysOnGPU(float *A, float *B, float *C, const int N)
{
... |
16,816 | /**
* GA Approximate: Try to approximate a simple function using Genetic Algorithm
*
**/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cfloat>
// For the CUDA runtime routines (prefixed with "cuda_")
#include <cuda_runtime.h>
/**
* Macros to configure experiment
*/
#define POPULATION_SIZE 3... |
16,817 | #include "reduce.cuh"
#include "real.h"
#include "assert.h"
#include <iostream>
void sumTest(){
real summands[1024];
for (int i=0; i!=1024; ++i)
summands[i]=1;
assert(reducev1(summands,1024) == 1024);
assert(reducev2(summands,1024) == 1024);
}
int main(){
sumTest();
std::cout << "Success!!!\n" << std::flush; ... |
16,818 | #include<cuda.h>
#include<cuda_runtime.h>
#include <stdio.h>
#define Mask_width 3
#define Mask_width_half (Mask_width/2)
//Tiles are smaller than blocks, so we can pad the input image while burst reading it into local memory.
#define BLOCK_WIDTH 16
#define TILE_WIDTH (BLOCK_WIDTH - (Mask_width -1))
__global__ vo... |
16,819 | #include<stdio.h>
#include<stdlib.h>
// Macro for checking errors in CUDA API calls
#define cudaErrorCheck(call) \
do{ \
cudaError_t cuErr = call; ... |
16,820 | #include <stdio.h>
#include <cuda_runtime.h>
#include <cuda.h>
#define BDIMX 32
#define BDIMY 16
void matricMul(int *A, int *B, int *C, int size) {
for (int col = 0; col < size; col++) {
for (int row = 0; row < size; row++){
int outidx = col * size + row;
for (int idx = 0; idx < size; idx++)
C[outidx] +=... |
16,821 | #include <thrust/iterator/counting_iterator.h>
#include <thrust/iterator/transform_iterator.h>
#include <thrust/iterator/permutation_iterator.h>
#include <thrust/functional.h>
#include <thrust/fill.h>
#include <thrust/device_vector.h>
#include <thrust/host_vector.h>
// for printing
#include <thrust/copy.h>
#include <... |
16,822 | #include "includes.h"
__global__ void simple_saxpy_kernel(float *y, const float* x, const float alpha, const float beta)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
y[idx] = alpha * x[idx] + beta;
} |
16,823 | #include "includes.h"
__global__ void ComputePressureFieldKernel (double *SoundSpeed, double *Dens, double *Pressure, int Adiabatic, int nrad, int nsec, double ADIABATICINDEX, double *Energy) /* LISTO */
{
int j = threadIdx.x + blockDim.x*blockIdx.x;
int i = threadIdx.y + blockDim.y*blockIdx.y;
if (i<nrad && j<nsec){
... |
16,824 | #include <stdio.h>
void deviceQuery() {
cudaDeviceProp prop;
int nDevices = 0, i;
cudaError_t ierr;
ierr = cudaGetDeviceCount(&nDevices);
if (ierr != cudaSuccess) {
printf("Sync error: %s\n", cudaGetErrorString(ierr));
}
for (i = 0; i < nDevices; ++i) {
ierr = cudaGetDeviceProper... |
16,825 | #include "includes.h"
__global__ void fast_variance_delta_kernel(float *x, float *delta, float *mean, float *variance, int batch, int filters, int spatial, float *variance_delta)
{
const int threads = BLOCK;
__shared__ float local[threads];
int id = threadIdx.x;
local[id] = 0;
int filter = blockIdx.x;
int i, j;
for... |
16,826 | #include <stdio.h>
#include <cuda.h>
void MatrixAddC(float* A, float* B, float* S, int Width, int Height, int offset) {
int col = 0;
int row = 0;
int DestIndex = 0;
int N = Width * Height;
for (col = 0; col < Width; col++) {
for (row = 0; row < Height; row++) {
DestIndex = col * Width + row;
S[DestIndex] ... |
16,827 | #include <cstdio>
#include <cstdlib>
#include <vector>
__global__ void initialize(int *bucket){
int i = threadIdx.x;
bucket[i] = 0;
}
__global__ void bucket_add(int *key, int *bucket) {
int i = threadIdx.x;
int content = key[i];
atomicAdd(&bucket[content],1);
}
__global__ void bucket_return(int *key, int n... |
16,828 |
__global__ void saxpy(int n, float a, float *x, float *y)
{
int i = blockIdx.x*blockDim.x + threadIdx.x;
if (i < n) y[i] = a * x[i] + y[i];
}
__host__ void hsaxpy(int n, float a, float *x, float *y)
{
float* d_x;
float* d_y;
cudaMalloc(&d_x, n * sizeof(float));
cudaMalloc(&d_y, n * sizeof(float));
cudaMemcpy(d... |
16,829 | #include "gpuVector4D.cu"
#include <iosfwd>
class gpuMatrix4x4 {
public:
// The default constructor.
__device__ __host__ gpuMatrix4x4(void) { }
// Constructor for row major form data.
// Transposes to the internal column major form.
// REQUIRES: data should be of size 16.
__device__ __ho... |
16,830 | #include <cuda.h>
#include <cufft.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define FFTSIZE 8
#define BATCH 2
/********************/
/* CUDA ERROR CHECK */
/********************/
#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, const char *file... |
16,831 | #include <stdio.h>
#include <cstdlib>
#include <time.h>
#include <stdlib.h>
#include <math.h>
/*
Authors: Eric Sheeder, Gokul Natesan, Jacob Hollister
Parallel Computing Final Project
This code generates 2 large matrices and multiplies them, once on the GPU and once on the CPU
It expects 3 variables on the comma... |
16,832 | #include <math.h>
#include <cstdlib>
#include <iostream>
using namespace std;
#define N 512
__global__ void add(int *a, int *b, int *c) {
c[blockIdx.x] = a[blockIdx.x] + b[blockIdx.x];
}
int main(void) {
int a[N], b[N], c[N]; // host copies of a, b, c
int *d_a, *d_b, *d_c; // device copies of a, b, c
int size =... |
16,833 | #include "includes.h"
__global__ void convolution_kernel(unsigned char *input_img, unsigned char *output_img, int height, int width)
{
__shared__ unsigned char input_shared[W][W]; //Shared Memory required for a tile and its halo elements(3 channels)
int chan;
for(chan=0;chan<3;chan++) //3 Channel Image
{
int tx = ... |
16,834 | #include "includes.h"
/* Vector addition deom on GPU
To compile: nvcc -o testprog1 testprog1.cu
*/
using namespace std;
#define FIRST_RUN 0
// Boundaries in physical units on the lens plane
const float WL = 10.0;
const float XL1 = -WL;
const float XL2 = WL;
const float YL1 = -WL;
const float YL2 = WL;
// Sourc... |
16,835 | #include "kernels.hh"
#include "runner.hh"
#include "../runtime/node.hh"
#include "../runtime/nodes-list.hh"
#include <stdexcept>
namespace gpu
{
void run(rt::NodesList& tasks)
{
for (auto x : tasks.nodes())
{
kernels_list[x->type](x);
cudaDeviceSynchronize();
... |
16,836 | #include "includes.h"
__global__ void BackwardCrossEntropy(float *output, float *labels, int nColsOutput, float *dOutput)
{
int col = blockIdx.x;
dOutput[col] = (labels[col] / output[col] - (1 - labels[col]) /
(1 - output[col])) * -1;
} |
16,837 | #include "includes.h"
__global__ void colMul(float* a, float* b, float* c, int M, int N){
int i = blockIdx.x*blockDim.x + threadIdx.x;
if(i<M){
int ind = i + blockIdx.y*M;
c[ind] = a[ind]*b[i];
}
} |
16,838 | #include "includes.h"
__global__ void stencil_1d(int n, double *in, double *out)
{
/* allocate shared memory */
__shared__ double temp[THREADS_PER_BLOCK + 2*(RADIUS)];
/* calculate global index in the array */
int globalIndex = blockIdx.x * blockDim.x + threadIdx.x;
int localIndex = threadIdx.x + RADIUS;
/* return if... |
16,839 | #include <float.h>
extern "C"
__global__ void getClusterCentroids(int n, double *xs, int *cluster_index, double *c, int k, int d){
//xs indicates datapoints, c indicates initial centroids, k indicates no. of clusters; d - dimensions
int index = blockIdx.x * blockDim.x + threadIdx.x;
if (index... |
16,840 | #include<stdio.h>
#include<cuda.h>
#define BLOCK_SIZE 16
// CUDA code to add matrix. It linearizes the 2D matrix and adds them on different threads.
__global__ static void AddMatrix(float *dev_buf1, float *dev_buf2, float *dev_buf_s, size_t pitch, int row_size, int col_size)
{
const int tidx = blockDim.x * blockIdx.... |
16,841 | #include <stdio.h>
#include <time.h>
int blockSize;
int gridSize;
__global__ void gameOfLife(int *indata, int *outdata, int width, int height)
{
__shared__ int sdata[256];
int tSize=width*height;
int x, y, x0,x1,y0,y1, n;
int bid, cid, tid;
tid = threadIdx.x;
bid = blockIdx.x;
for(cid = blockIdx.x*blockDim.x... |
16,842 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define N 4096
#define N_2 N*N
#define BLOCK_SIZE 32
float a[N_2], b[N_2];
float c[N_2];
__global__ void mm_kernel(float* A, float* B, float* C) {
int col = blockIdx.x * blockDim.x + threadIdx.x;
int row = blockIdx.y * blockDim.y + threadIdx.y;
if ... |
16,843 | #include "kernels.cuh"
__device__ void warpReduce(volatile int* sdata, int tid)
{
sdata[tid] += sdata[tid + 32];
sdata[tid] += sdata[tid + 16];
sdata[tid] += sdata[tid + 8];
sdata[tid] += sdata[tid + 4];
sdata[tid] += sdata[tid + 2];
sdata[tid] += sdata[tid + 1];
}
#ifdef IN_ARRAY
__global__ void add_kernel_in_... |
16,844 | #include <stdlib.h>
#include <stdio.h>
#include <jpeglib.h>
#include <jerror.h>
#include "image.cuh"
// load and save functions from https://www.tspi.at/2020/03/20/libjpegexample.html
struct imgRawImage* loadJpegImageFile(char* lpFilename) {
struct jpeg_decompress_struct info;
struct jpeg_error_mgr err;
struct img... |
16,845 | /////////////////////////
// freqAnalyzer_old.cu //
// Andrew Krepps //
// Module 9 Assignment //
// 4/9/2018 //
/////////////////////////
#include <chrono>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <cufft.h>
//////////////////////////////////////////////////////////////////... |
16,846 | #include "includes.h"
__global__ void SetForcesToZeroKernel( float *force, int maxCells )
{
int threadId = blockDim.x*blockIdx.y*gridDim.x //rows preceeding current row in grid
+ blockDim.x*blockIdx.x //blocks preceeding current block
+ threadIdx.x;
if(threadId < maxCells * 3)
{
force[threadId] = 0.00f;
}
} |
16,847 | /*
******************************************************
This file is the single GPU version of 2D Heat Equation
using CUDA programming model. This implementation is based
on the CPU version from
http://www.many-core.group.cam.ac.uk/archive/CUDAcourse09/
Permission to use, copy, distribute and modify this software f... |
16,848 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
__device__ double dot_prod_3_d_gpu(double * v1, double * v2)
{
double tmp = 0.0;
for (int i = 0; i < 3; ++i) tmp += v1[i] * v2[i];
return tmp;
}
__device__ float dot_prod_3_f_gpu(float * v1, float * v2)
{
float tmp = 0.0;
for (int i = 0; i < 3; ++i)... |
16,849 | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#define LIST_SIZE 100000
__device__ unsigned long long zeroList[LIST_SIZE];
__device__ unsigned long long oneList[LIST_SIZE];
__device__ unsigned long long record_flag = 0;
extern "C" __device__ void profileCmp(int cmpResult, long index){... |
16,850 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/generate.h>
#include <thrust/sort.h>
#include <thrust/copy.h>
#include <algorithm>
#include <cstdlib>
#include <chrono>
#include <stdio.h>
cudaError_t addWithCuda(int* c, ... |
16,851 | #include <stdio.h>
__global__ void vecAdd(int *X, int *Y, int a, int *F){
int id = threadIdx.x;
F[id] = a*X[id] + Y[id];
}
int main(){
int i,n,a,X[100],Y[100],F[100],*dx,*dy,*df;
printf("Enter value for a: ");
scanf("%d",&a);
printf("Enter value for n: ");
scanf("%d",&n);
printf("Enter the values for vect... |
16,852 | #include <stdio.h>
#include <stdint.h>
#define CHECK(call)\
{\
const cudaError_t error = call;\
if (error != cudaSuccess)\
{\
fprintf(stderr, "Error: %s:%d, ", __FILE__, __LINE__);\
fprintf(stderr, "code: %d, reason: %s\n", error,\
cudaGetErrorString(error));\
exit(EXIT_FAILURE);\
}\
}
struct GpuTimer
{... |
16,853 | /**
* @file vectorAdd.cu
*/
#include <stdio.h>
#include <time.h>
#include <cuda_runtime.h>
#define VECTOR_SIZE 100000
__global__ void
kernelVecAdd ( const double *a, const double *b, double *c, size_t size ) {
/* get position of thread */
unsigned i = blockDim.x * blockIdx.x + threadIdx.x;
/**
... |
16,854 | #include <thrust/device_vector.h>
#include <thrust/transform.h>
#include <thrust/copy.h>
#include <iostream>
typedef float(*fptr_t)(const float&);
template <fptr_t F>
struct functor{
__host__ __device__ float operator()(const float& x) const {
return F(x);
}
};
__host__ __device__ float... |
16,855 | #include <stdio.h>
#include <stdlib.h>
#include <float.h>
#include <math.h>
#include <cuda.h>
#include <curand.h>
// Type for points
typedef struct{
float x; // x coordinate
float y; // y coordinate
int cluster; // cluster this point belongs to
} Point;
// Type for centroids
typedef struct{
floa... |
16,856 | #include<stdio.h>
// nvcc separate source code into device and host components
__global__ void mykernel(void) {
// Device code is compiled by Nvidia compiler
// This function is called from host code
}
int main(void) {
// Host code goes here which is processed by standard host compiler
// e.g. gcc
// <<< ... |
16,857 | #include <cuda.h>
#include <stdio.h>
#include <stdlib.h>
__global__ void mandelKernel(float lowerX, float lowerY, float stepX, float stepY, int maxIterations, int* result) {
// To avoid error caused by the floating number, use the following pseudo code
//
// float x = lowerX + thisX * stepX;
// float y... |
16,858 | // $ nvcc -std=c++11 -I../.. basic_daxpy.cu -o basic_daxpy
#include <cassert>
#include <iostream>
#include <chrono>
#include <thrust/device_vector.h>
__global__ void daxpy_kernel(int n, double a, const double* x, double* y)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
if(i < n)
{
y[i] = a * x[i] + y[i];
... |
16,859 | #include <stdio.h>
#include <stdlib.h>
//#define N 16384
__global__ void addCincoVec(int *a, int N)
{
int tid=threadIdx.x+blockIdx.x*blockDim.x;
if(tid<N)
{
a[tid]=a[tid]+5;
}
}
int main (void)
{
int *dev_a,*a;
int N,num_blocs,num_hilos;
float elapsedTime;
printf("Ingrese el tamano del vector\n");
... |
16,860 | #include "includes.h"
__global__ void cunn_CriterionFilter_updateOutput_kernel( float *target, float *ignored_label, int bound, int batch_size, int map_nelem, int blocks_per_sample)
{
int i;
int sample = blockIdx.x / blocks_per_sample;
int step = blockDim.x * blocks_per_sample;
int toffset = sample * map_nelem;
int ign... |
16,861 | __global__ void PatchedSumImageKernel(double *A,
double *summed_Arr,
uint A_width,
uint A_height,
uint n_color,
uint width,
... |
16,862 | // the GPU code can be found in power_gpu.cu
// jiabing jin, sept 2017
////////////////////////////////////////////
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "cuda.h"
const int BLOCK_SIZE =256;
// #include "power_gpu.cu"
// Input Array Variables
float... |
16,863 | #include <iostream>
int main(int argc, char* argv[]){
cudaError_t error;
cudaDeviceProp prop;
int count; //stores the number of CUDA compatible devices
error = cudaGetDeviceCount(&count); //get the number of devices with compute capability < 1.0
if(error != cudaSuccess){ //if... |
16,864 | /*
Copyright 2021 Fixstars Corporation
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 License at
http ://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
... |
16,865 | /*
* File: mandel.c
* Author: Antonio Lechuga
*
* Created on Día 9999 de la cuarentena COVID19
*/
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
//PP#include <cuda.h>
# define POINTS_PER_DIM 1024
# define MAX_ITER 2000
// Defining complex type
typedef struct complex_ {
double real;... |
16,866 | #include "mse-grad.hh"
#include "graph.hh"
#include "../runtime/node.hh"
#include "../memory/alloc.hh"
namespace ops
{
MSEGrad::MSEGrad(Op* y, Op* y_hat)
: Op("mse_grad", y->shape_get(), {y, y_hat})
{}
void MSEGrad::compile()
{
auto& g = Graph::instance();
auto& cy = g.compil... |
16,867 | #include <cuda.h>
#include <stdio.h>
#include <stdlib.h>
#define BLOCK_SIZE 16
__global__ void mandelKernel(
int *d_out, size_t pitch,
float lowerX, float lowerY,
float stepX, float stepY,
int maxIters
) {
// To avoid error caused by the floating number, use the following pseudo code
//
//... |
16,868 | #include "includes.h"
__global__ void CudaKernelHelloWorld(char *a, int *b)
{
a[threadIdx.x] += b[threadIdx.x];
} |
16,869 | __global__ void kh(double * dtr, const double * __restrict__ dt,
const double * __restrict__ du, const double * __restrict__ de,
double q) {
unsigned int ip = threadIdx.x + blockIdx.x * blockDim.x
+ blockIdx.y * blockDim.x * gridDim.x;
double earg = - du[ip] - de[ip] * q + dt[ip];
if (earg >= 0.0... |
16,870 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
/*
__global__ void add(int a, int b, int *c)
{
*c=a+b;
}
*/
int main(void)
{
/*
int c;
int *dev_c;
cudaMalloc((void**)&dev_c, sizeof(int));
add<<<1,1>>>(20,7,dev_c);
cudaMemcpy(&c,dev_c,sizeof(int),cudaMemcpyDeviceToHost);... |
16,871 | #include <iostream>
#include <cuda.h>
#include <cuda_runtime.h>
#include <cstdlib>
#define BLOCK_SIZE 128
#define CHECK(call) \
{ \
const cudaError_t error = call; ... |
16,872 | float h_A[]= {
0.8771927313561361, 0.7288518259250378, 0.6327764185154686, 0.8648889439116967, 0.803148998719112, 0.9442271326823778, 0.7676756309988559, 0.6300141093775545, 0.9005316101199058, 0.7422706591611263, 0.7195208827294151, 0.6200547443649685, 0.7120178372059457, 0.9914102194138241, 0.6998713741565193, 0.9995... |
16,873 | // incrementArray.cu
#include <stdio.h>
#include <assert.h>
#include <cuda.h>
#include <math.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 ... |
16,874 | #define ABS(x) ((x) > 0 ? (x) : -(x))
__global__ void kernel_division(float *img1, float *img, int nx, int ny, int nz)
{
int ix = 16 * blockIdx.x + threadIdx.x;
int iy = 16 * blockIdx.y + threadIdx.y;
int iz = 4 * blockIdx.z + threadIdx.z;
if (ix >= nx || iy >= ny || iz >= nz)
return;
int i... |
16,875 | #include <stdio.h>
void printDeviceProperties(cudaDeviceProp prop) {
printf("Device name: %s\n", prop.name);
printf("Clock rate (KHz): %d\n", prop.clockRate);
printf("Compute: %d.%d\n", prop.major, prop.minor);
printf("Total number of SMs: %d\n", prop.multiProcessorCount);
printf("Device shares CPU ram dire... |
16,876 | #include "includes.h"
__global__ void findAllMins(int* adjMat, int* outVec, size_t gSize) {
int globalThreadId = blockIdx.x * blockDim.x + threadIdx.x;
int ind = globalThreadId * gSize;
int min = INT_MAX;
if(globalThreadId < gSize) {
for(int i = 0; i < gSize; i++) {
if(adjMat[ind + i] < min && adjMat[ind + i] > 0) {
m... |
16,877 | #include <iostream>
#include <stdlib.h>
#include <string>
#include <vector>
#include <sstream>
#include <cuda.h>
#include <iterator>
using namespace std;
__global__ void multiply(int *A, int *B, int *C, int N) {
int idx = blockDim.x * blockIdx.x + threadIdx.x;
int i = idx / N, j = idx % N;
int sum = 0;
for (i... |
16,878 | #include "includes.h"
__global__ void rowMin(float* input, int* output, size_t rowS, size_t rowNum){
size_t id = blockIdx.x*blockDim.x + threadIdx.x;
if(id < rowNum){
float temp[MAX_K/2][2];
size_t inId = id * rowS;
for(int i = 0; i< rowS;i++){
temp[i][0] = input[inId + i];
temp[i][1] = (float)i;
}
for(int i = 0; i<... |
16,879 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include<stdio.h>
// input: radius (1), nsample (1), xyz1 (b,n,3)
// output: idx (b,n,nsample)
__global__ void query_ball_point_gpu(int b, int n, float radius, int nsample, const float *xyz1, int *idx) {
int batch_idx = blockIdx.x;
xyz1 +=batch_idx*n... |
16,880 | #include "includes.h"
__global__ void kmeans4 (short int *input, short int*centroids, int*newcentroids, int *counter, const int n)
{
int Dim = 4;
int i = (blockIdx.x * blockDim.x + threadIdx.x)*Dim;
if ( i < n ) {
// map
int point_d0 = input[i+0];
int point_d1 = input[i+1];
int point_d2 = input[i+2];
int point_d3 = inp... |
16,881 | #include "includes.h"
/*CUDA 2-D Matrix Multiplication*/
#define TILE_WIDTH 2
#define WIDTH 100
// main routine
__global__ void MatrixMul( float *A_d , float *B_d , float *C_d)
{
// calculate thread id
unsigned int col = TILE_WIDTH*blockIdx.x + threadIdx.x ;
unsigned int row = TILE_WIDTH*blockIdx.y + threadIdx.y ;... |
16,882 | #include <cuComplex.h>
#include <cuda.h>
#include <cuda_runtime.h>
__global__ void
corr_abs_kernel(cuFloatComplex* in, cuFloatComplex* out, float* mag, int n)
{
int d = 16;
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < n) {
cuFloatComplex m = cuCmulf((in[i + d]),cuConjf(in[i]));
... |
16,883 | #include "includes.h"
#define BUFSIZE 64
#define BLOCK_SIZE 16
// Perdiodicty Preservation retains our periodicity
// Runs on CPU
__global__ void periodicityPreservationGPU(int N, char *cells)
{
int i;
//rows
for (i = 1; i <= N; ++i)
{
//Copy first real row to bottom extra row
cells[(N+2)*(N+1)+i] = cells[(N+2)+i];
/... |
16,884 | #include <stdio.h>
#include <iostream>
#include <fstream>
#include <cuda_runtime.h>
#include <cmath>
#include <string>
#include <cstdio>
using namespace std;
__global__ void p2_calc_gpu(float* d_x, float* d_y, float* d_z, float* d_ans, int* d_count, int* d_status, unsigned long long int numatm,float* d_xbox,float*... |
16,885 | #include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
#define MAX 1000000 //10 e 6
ull LnRnBlocks[17*2]; // from l0r0 to l16r16
ull CnDnBlocks[17*2]; //from c0d0 to c16d16
ull keysBlocks[16]; //from key[1] = k0 to key[16] = k15
ull allCipherDES[MAX];
ull Rotations[16] = {
1, 1, 2, 2, ... |
16,886 | #include <cstdio>
#include <cstdlib>
#include <vector>
std::vector< cudaDeviceProp > get_cuda_device() {
std::vector< cudaDeviceProp > devices;
int count = -1;
cudaGetDeviceCount( & count);
for ( int i = 0; i < count; ++i) {
cudaDeviceProp prop;
cudaGetDeviceProperties( & prop, i);
... |
16,887 | #include<iostream>
#include<cuda_runtime_api.h>
#include<time.h>
#include<stdlib.h>
#define SAFE_CALL(CallInstruction){ \
cudaError_t cuerr=CallInstruction; \
if(cuerr!=cudaSuccess){ \
printf("CUDA error:%s at call \"" #CallInstruction"\"\n",cudaGetErrorString(cuerr));\
throw "error in CUDA API function,abortin... |
16,888 | #include "includes.h"
__device__ float digamma_fl(float x) {
float result = 0.0f, xx, xx2, xx4;
for ( ; x < 7.0f; ++x) { /* reduce x till x<7 */
result -= 1.0f/x;
}
x -= 1.0f/2.0f;
xx = 1.0f/x;
xx2 = xx*xx;
xx4 = xx2*xx2;
result += logf(x)+(1.0f/24.0f)*xx2-(7.0f/960.0f)*xx4+(31.0f/8064.0f)*xx4*xx2-(127.0f/30720.0f)*xx4... |
16,889 | // ##########################################################
// By Eugene Ch'ng | www.complexity.io
// Email: genechng@gmail.com
// ----------------------------------------------------------
// The ERC 'Lost Frontiers' Project
// Development for the Parallelisation of ABM Simulation
// ------------------------------... |
16,890 | #include <stdio.h>
#include <stdlib.h>
#define SZ 8
__global__ void AplusB(int *ret, int a, int b) {
ret[threadIdx.x] = a + b + threadIdx.x;
}
int main() {
int *ret;
cudaMallocManaged(&ret, SZ * sizeof(int));
AplusB<<<1, SZ>>>(ret, 10, 100);
cudaDeviceSynchronize();
for (int i = 0; i < SZ; i++)
printf... |
16,891 | /*
* errorCheck.cu
*
* Created on: Jul 24, 2015
* Author: vital
*/
#ifndef ERRORCHECK_H_
#define ERRORCHECK_H_
#include <cuda_runtime_api.h>
#include <cuda.h>
#include <iostream>
#include <fstream>
#define CUDA_ERROR_CHECK
#define CudaSafeCall( err ) __cudaSafeCall( err, __FILE__, __LINE__ )
#define Cuda... |
16,892 | #include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
//Fast integer multiplication
#define MUL(a, b) __umul24(a, b)
////////////////////////////////////////////////////////////////////////////////
// Park-Miller quasirandom number generation kernel
/////////////////////////////////////////////... |
16,893 | #include <stdio.h>
#include <fstream>
#include <iostream>
#define CHANNELS 3 // we have 3 channels corresponding to RGB
using namespace std;
#define CHANNELS 3 // we have 3 channels corresponding to RGB
// The input image is encoded as unsigned characters [0, 255]
__global__ void colorConvert(float * Pout, float * Pin... |
16,894 | #include <stdio.h>
__global__ void kernel() {
printf("Hello World!\n");
}
int main () {
kernel<<<1,2>>>();
kernel<<<3,1>>>();
printf("Hello from CPU!\n");
cudaDeviceSynchronize();
return 0;
} |
16,895 | /*
Simulation of flow inside a 2D square cavity
using the lattice Boltzmann method (LBM)
Written by: Abhijit Joshi (abhijit@accelereyes.com)
Last modified on: Thursday, July 18 2013 @12:08 pm
Build instructions: make (uses Makefile present in this folder)
Run instructions: optirun ./gpu_lbm
*/
#include<ios... |
16,896 |
// #include "linalg.cu"
/*!
* Compute the initial labels for a gene pair in an expression matrix. Samples
* with missing values and samples that fall below the expression threshold are
* labeled as such, all other samples are labeled as cluster 0. The number of
* clean samples is returned.
*
* @param globa... |
16,897 | //////////////////////////////////////////////////////////////////////
//Name: CombineCost.cu
//Created date: 4-2-2012
//Modified date: 4-2-2012
//Author: Gorkem Saygili, Jianbin Fang and Jie Shen
//Discription: combine initial cost with state-of-the-art (cuda kernel)
//////////////////////////////////////////////////... |
16,898 | #include "includes.h"
/***********************************************************
By Huahua Wang, the University of Minnesota, twin cities
***********************************************************/
__global__ void colNorm_b( float* X, float* v, float* b, unsigned int size, unsigned int n)
{
const unsigne... |
16,899 | #include "cuda.h"
#include <stdio.h>
//#include "mex.h"
/* Kernel to square elements of the array on the GPU */
__global__ void norm_elements(float* in, float* out, unsigned int N)
{
__shared__ float vOut[16];
int idx = blockIdx.x*blockDim.x+threadIdx.x;
if ( idx < N)vOut[idx] = in[idx]*in[idx];
__syncthreads();
i... |
16,900 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <fstream>
cudaError_t addWithCuda(unsigned char* p_red, unsigned char* p_green, unsigned char* p_blue, unsigned int size);
int checkSize(char* filename);
void appendHeader(char* filename, char* origin);
void readBMP(char* fil... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.