serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
3,901 | /*
Generic Parent Class for all game interfaces
Rahul Kejriwal
CS14B023
*/
/*
Abstract Class for abstracting actual game interface from game-playing algorithms
*/
class GameState {
public:
/*
Array to hold moves from current GameState
Can be used to generate children
*/
bool *moves;
int moves_length;
... |
3,902 | #include "includes.h"
#define max(a, b) a > b ? a : b
#define min(a, b) a < b ? a : b
struct Edge{
long long int x;
};
///*
//*/
__global__ void accumulate(Edge* edge_list, bool* cross_edges, int* indices, int e){
int bid = blockIdx.x;
int id = bid*blockDim.x + threadIdx.x;
Edge temp;
temp.x = 0;
if(id <... |
3,903 | #include <stdio.h>
#include <stdlib.h>
#include <assert.h>
__global__ void gpu_matrix_mult(float *a,float *b, float *c,
int m, int n, int k)
{
int row = blockIdx.y * blockDim.y + threadIdx.y;
int col = blockIdx.x * blockDim.x + threadIdx.x;
float sum = 0;
if( col < k && row < m)
{
... |
3,904 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <cstdio>
#include <cstdlib>
#include <ctime>
__global__ void code_without_divergence()
{
int gid = blockIdx.x * blockDim.x + threadIdx.x;
float a, b;
a = b = 0;
int warp_id = gid / 32;
if (warp_id % 2 == 0) {
a = 10... |
3,905 | #include "includes.h"
__global__ void mergeLocation(const short2* loc_, float* x, float* y, const int npoints, float scale)
{
const int ptidx = blockIdx.x * blockDim.x + threadIdx.x;
if (ptidx < npoints)
{
short2 loc = loc_[ptidx];
x[ptidx] = loc.x * scale;
y[ptidx] = loc.y * scale;
}
} |
3,906 | #include <cuda.h>
#include <iostream>
#include <math.h>
#include <ctime>
#include <cmath>
#include <stdlib.h>
#include <fstream>
#include <sstream>
double* three_dim_index(double* matrix, int i, int j, int k, double m, int b, int num_assets);
double* two_dim_index(double* vector, int i, int j, double m, int b);
_... |
3,907 | #include "includes.h"
__global__ void reduction(const int N, float *a, float *result) {
int thread = threadIdx.x;
int block = blockIdx.x;
int blockSize = blockDim.x;
int gridSize = gridDim.x;
//unique global thread ID
int id = thread + block*blockSize;
__volatile__ __shared__ float s_sum[256];
float sum = 0;
for ... |
3,908 | #include <cuda.h>
#include <iostream>
#include <time.h>
__global__
void addKernel(int* A_d, int* B_d, int*C_d); //vector addition(device code)
void arrayAdd(int* A, int* B, int* C, int n); //vector addition(serial code)
void vecAdd(int* A, int* B, int* C, int n); //loading, transfer, execution(host code)
void printArra... |
3,909 | /*
Implement your CUDA kernel in this file
*/
#define TILE_DIM 32
__global__ void mirror_boundaries(double *E_prev, const int n, const int m)
{
int row = blockIdx.y*blockDim.y + threadIdx.y + 1;
int col = blockIdx.x*blockDim.x + threadIdx.x + 1;
if (col == 1) {
E_prev[row*(n+2)] = E_prev[row*(n+2) + 2];... |
3,910 | //#include "cuda_runtime.h"
//#include "device_launch_parameters.h"
//
//#include <stdio.h>
//#include <random>
//#include <conio.h>
//
//
//#define N 2048
//#define NB_THREADS 1024
//
//__global__ void multVect(int* result, int* a, int* b) {
// int idx = threadIdx.x + blockIdx.x * blockDim.x;
// if(idx < N)
// result[... |
3,911 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <cuda.h>
void printBoard(unsigned char *board, int rows, int cols)
{
int counter = 0;
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
if(board[counter] == 0)
printf("-");
else
printf("0");
... |
3,912 | #include "includes.h"
__global__ void int_copy(int *vec_to, int *vec_from, const int n)
{
unsigned int xIndex = blockDim.x * blockIdx.x + threadIdx.x;
if ( xIndex < n )
vec_to[xIndex] = vec_from[xIndex];
} |
3,913 | #include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
const char* getfield(char* line, int num){
const char* tok;
for (tok = strtok(line, ",");
tok && *tok;
tok = strtok(NULL, ",\n"))
{
if (!--num)
return tok;
}
return NULL;
}
__global__ void calcPot(doub... |
3,914 | #include "includes.h"
__global__ void crossFade(float* out1, float* out2, int numFrames){
const int threadID = blockIdx.x * blockDim.x + threadIdx.x;
float fn = float(threadID) / (numFrames - 1.0f);
out1[threadID * 2] = out1[threadID * 2] * (1.0f - fn) + out2[threadID * 2] * fn;
out1[threadID * 2 + 1] = out1[threadID *... |
3,915 | #include <stdio.h>
#include <cuda_runtime.h>
int main( ) {
int dev = 0;
cudaDeviceProp prop;
cudaGetDeviceProperties(&prop, dev);
printf("device id %d, name %s\n", dev, prop.name);
printf("number of multi-processors = %d\n",
prop.multiProcessorCount);
printf("Total constant memory: %4.2... |
3,916 | #include <stdio.h>
#include <stdlib.h>
#define N 256
__global__ void bitreverse(void *data){
unsigned int *idata = (unsigned int *)data;
extern __shared__ int array[];
array[threadIdx.x] = idata[threadIdx.x];
array[threadIdx.x] = ((0xf0f0f0f0 & array[threadIdx.x]) >> 4) | ((0x0f0f0f0f & array[th... |
3,917 | #include "includes.h"
/*
Autor: Munesh Singh
Date: 08 March 2010
Vector addition using cudaMallocPitch
*/
const int width = 567;
const int height = 985;
__global__ void testKernel2D(float* M, float* N, float* P, size_t pitch) {
int col = threadIdx.x + blockIdx.x * blockDim.x;
int row = threadIdx.y + blockIdx.y * blo... |
3,918 | #include <stdio.h>
#include <cuda_runtime.h>
#define N 10
#ifndef checkCudaErrors
#define checkCudaErrors(err) __checkCudaErrors(err, __FILE__, __LINE__)
void __checkCudaErrors(cudaError_t err, const char *file, const int line)
{
if(cudaSuccess != err)
{
fprintf(stderr, "checkCudaErrors() Driver API error =... |
3,919 | #include <stdio.h>
#include <stdlib.h>
// Define this to turn on error checking
#define CUDA_ERROR_CHECK
#define CUDASAFECALL( err ) __cudaSafeCall( err, __FILE__, __LINE__ )
#define CUDACHECKERROR() __cudaCheckError( __FILE__, __LINE__ )
inline void __cudaSafeCall(cudaError err, const char* file, const int line)... |
3,920 | #include <stdio.h>
// Variables
float* h_A;
float* h_B;
float* h_C;
float* d_A;
float* d_B;
float* d_C;
// Functions
void Cleanup(bool);
void RandomInit(float*, int);
void ParseArguments(int, char**);
// Device code
__global__ void VecAdd(const float* A, const float* B, float* C, int N)
{
int i = blockDim.x * bl... |
3,921 | #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/time.h>
/* Problem size */
#define NI 8192 // height
#define NJ 8192 // width
__global__ void convolutionKernel(double *A_d, double *B_d, int width, int height)
{
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y +... |
3,922 | #include <cstdio>
#include <iostream>
#include <chrono>
#include <algorithm>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
__global__ void add_gpu(float *dx, float *dy)
{
int id = blockIdx.x * blockDim.x + threadIdx.x;
//int temp = dx[id] > 0 ? dx[id]: (-1)*dx[id];
//dy[id] += temp;
dy[id] +... |
3,923 | /*
Copyright (C) Muaaz Gul Awan and Fahad Saeed
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in... |
3,924 |
template<typename Destination, typename Data>
__global__ void floorArrays(size_t elements, Destination *dst, Data *src) {
const size_t kernelIndex = blockDim.x * blockIdx.x + threadIdx.x;
if (kernelIndex < elements) { dst[kernelIndex] = floor(src[kernelIndex]); }
}
template<typename Destination, typename Data>
__gl... |
3,925 | #include <cuda_runtime.h>
#include <iostream>
#include <string>
// Define this to turn on error checking
#define CUDA_ERROR_CHECK
#define CudaSafeCall(err) __cudaSafeCall(err, __FILE__, __LINE__, deviceID)
#define CudaSyncAndCheckError() __cudaSyncAndCheckError(__FILE__, __LINE__, deviceID)
__host__ inline std::str... |
3,926 | #include <math.h>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#define GIG 1000000000
#define NANO_TO_MILLI 1000000
#define CPG 2.8 // Cycles per GHz -- Adjust to your computer
// Assertion to check for errors
#define CUDA_SAFE_CALL(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAsser... |
3,927 | //
// main.cpp
//
//
// Created by Elijah Afanasiev on 25.09.2018.
//
//
// System includes
#include <assert.h>
#include <stdio.h>
#include <chrono>
#include <cstdlib>
#include <iostream>
// CUDA runtime
#include <cuda.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#ifndef MAX
#define MAX(a, b)... |
3,928 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
__global__ void transpose(int *a,int *t)
{
int v = threadIdx.y;
int n = v*blockDim.x+threadIdx.x;
int ta = (int)powf(a[n],v+1);
t[n] = ta;
}
int main(void)
{
int *a,*t,n,i,j;
int *d_a,*d_t;
... |
3,929 | #include "shared.cuh"
__global__ void memset_zero(int* all_thread_ids) {
int i = thread_id();
all_thread_ids[i] = 0;
}
|
3,930 | /**
* 2DConvolution.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 <unistd.h>
#include <stdio.h>
#include <... |
3,931 | /// Convolution 1D Parallel.
///
/// Implementation of a 1-dimensional convolution in CUDA, with a placeholding
/// mask and shared memory usage.
///
/// Authors:
/// Lucas Oliveira David.
/// Paulo Finardi.
///
/// Note (in Brazilian Portuguese):
/// Como nosso trabalho final e' relacionado `a redes convolucio... |
3,932 | #include <iostream>
#include <complex>
#include <math.h>
#include <thrust/complex.h>
#include <sys/time.h>
#include <cassert>
using namespace std;
__constant__ const int block_1 = 16;
__constant__ const int block_2 = 8;
void checkError(){
cudaError_t errSync = cudaGetLastError();
cudaError_t errAsync = cudaDevic... |
3,933 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#define N 2048
#define THREADS_PER_BLOCK 50
__global__ void add(int *a, int *b, int *c)
{
printf("threadid No : %d\n",threadIdx.x);
printf("blockid No : %d\n",blockIdx.x);
printf("blockdim No : %d\n",blockDim.x);
int index = thr... |
3,934 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define N 100000000
float hArray[N];
float *dArray;
int blocks;
clock_t begin1,begin2,begin3,begin4,end1,end2,end3,end4;
void prologue(void)
{
memset(hArray, 0, sizeof(hArray));
for(int i = 0; i < N; i++)
{
hArray[i] = i... |
3,935 | #include <stdio.h>
__global__ void helloFromGPU() {
if (threadIdx.x < 20 && blockIdx.x < 20)
printf("Hello World from GPU! %d %d\n", threadIdx.x, blockIdx.x);
}
int main(int argc, char**argv) {
printf("Hello World from CPU!\n");
// 2 milhões blocos de 1024 threads
long long int blocks = 2 * 1e6;
long l... |
3,936 | #include "particleSolver.cuh"
void SolverFunctions::forwardEulerCPU(vector<float> v, vector<float> vp, float dt){
} |
3,937 | #include <cuda_runtime.h>
#include <stdexcept>
#include <algorithm>
constexpr int CUDA_NUM_THREADS = 128;
constexpr int MAXIMUM_NUM_BLOCKS = 4096;
inline int GET_BLOCKS(const int N) {
return std::max(std::min((N + CUDA_NUM_THREADS - 1) / CUDA_NUM_THREADS,
MAXIMUM_NUM_BLOCKS), 1);
}
// define the kernel... |
3,938 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <math.h>
#include <time.h>
#define TAM 5
void llenarVector(int *A) {
//srand(time(NULL));
for(int i=0; i<TAM; i++) {
A[i]=rand();
}
}
__global__ void sumaVectores(int *A, int *B, int *C) {
int i = threadIdx.x+blockDim.x * blockIdx.x;
if(i<TAM)
... |
3,939 | #include<stdio.h>
int main()
{
int num_devices,i;
cudaGetDeviceCount(&num_devices);
for(i=0;i<num_devices;i++)
{
cudaDeviceProp prop;
cudaGetDeviceProperties(&prop,i);
printf("Device Number: %d\n",i);
printf("Device Name: %s\n",prop.name);
printf("Compute Ca... |
3,940 | //nvcc -ptx cuda_kernel.cu --gpu-architecture=compute_30 --gpu-code=compute_30 --optimize 2
#include "cuComplex.h"
// CUDA runtime
#include "cuda_runtime.h"
#include "stdint.h"
#define IDX2F(i,j,ld) ((((j)-1)*(ld))+((i)-1))
#define IDX2C(i,j,ld) (((j)*(ld))+(i))
// #define IDX3(k1,k2,k3,kcut) (((((k1)-1)*(kcut))+((k2)... |
3,941 | //Генерация псевдослучайных чисел с использованием CuRand
#include <iostream>
#include <curand.h>
#include <curand_kernel.h>
#define MAX 100
/* эта функция ядра GPU вычисляет случайное число и сохраняет его в памяти*/
__global__ void random(unsigned int seed, int* result) {
/* Библиотека случайных чисел CUDA исполь... |
3,942 | #include <stdio.h>
#include <cuda.h>
#include <time.h>
#include <math.h>
#include <unistd.h>
/* we need these includes for CUDA's random number stuff */
#include <curand.h>
#include <curand_kernel.h>
#define ISLAND 10
#define POPULATION 50
#define FACILITY 20
#define GENERATION 8
#define CROSSOVER 0.6
#define MUTAT... |
3,943 | //
// Created by igor on 28.03.2021.
//
#include "Camera.cuh"
Camera::Camera(float fov, const unsigned int x, const unsigned int y) : fov(fov), x(x), y(y) {
position = Matrix4::IDENTITY;
origin = Vector3{0, 0, 0};
float pixelDxLen = tan(fov/2)/x*2;
pixelDx = {pixelDxLen, 0, 0};
pixelDy = {0, -pix... |
3,944 | #include <cuda.h>
#include <vector>
#include <cstdio>
#include <cstdlib>
template <typename T, std::size_t capacity>
struct queue {
int size = 0;
T data[capacity];
__device__ bool insert(const T& value) {
// TODO: insert an element into the queue.
// This will involve:
// 1) An atomic i... |
3,945 | #include <stdio.h>
const int max_threads_per_block = 512;
#define HANDLE_CUDA_ERROR(err) if (err) { printf("%s", cudaGetErrorString(err)); return; }
__device__ int cyclic_reduction_forward_reduction(float *lower, float *diagonal, float *upper, float *equal, const int dim, int step, const int to)
{
/* Forward redu... |
3,946 | #include "includes.h"
__global__ void pow_kerneld(double *v, int n, double e) {
int x(threadIdx.x + blockDim.x * blockIdx.x);
if (x >= n) return;
v[x] = ::pow(v[x], e);
} |
3,947 | __global__ void kernel_task1_cuda(int n, int *A1, int *A2, int *A3) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
int stride = blockDim.x * gridDim.x;
for(int i = index; i < n; i += stride) {
A1[i] += 1;
A3[i] = A2[i];
}
}
__global__ void kernel_task2_cuda(int n, int *A1, int *A2) {
int index ... |
3,948 | #include "includes.h"
__global__ void reduceUnrolling (double *g_idata, double *g_odata, unsigned int n, unsigned int q) //added int q
{
// set thread ID
unsigned int tid = threadIdx.x;
unsigned int idx = blockIdx.x * blockDim.x * q + threadIdx.x; // q adapted idx
// unroll analogous q
if (idx + blockDim.x*(q-1) < n)
... |
3,949 | #include "stdio.h"
#define COLUMNS 3
#define ROWS 2
__global__ void add(int *a, int *b, int *c)
{
int x = blockIdx.x;
int y = blockIdx.y;
int i = (COLUMNS * y) + x;
c[i] = a[i] + b[i];
}
int main()
{
int a[ROWS][COLUMNS], b[ROWS][COLUMNS], c[ROWS][COLUMNS];
int *dev_a, *dev_b, *dev_c;
cudaMalloc((void **... |
3,950 | #include "includes.h"
/*
Vector addition with a single thread for each addition
*/
/*
Vector addition with thread mapping and thread accessing its neighbor parallely
*/
//slower than simpler
/*
Matrix Matrix multiplication with a single thread for each row
*/
/*
Matrix Matrix multiplication with a single thread... |
3,951 | /*
initialize all parameter for System model and cost function
*/
#include "../include/init.cuh"
void init_params( float *a )
{
// params for simple nonlinear systems
// for Simple Nonlinear System
/*a[0] = 1.0f;
a[1] = 1.0f;*/
// FOR CART AND POLE
a[0] = 0.1f;
a[1] = 0.024f;
a[2] = ... |
3,952 | #include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <ctime>
#include <cstdint>
#include <thrust/reduce.h>
#include <cuda.h>
using namespace std;
__device__ int binarySearch(int* arr, int l, int r, int x)
{
while (l <= r)
{
int m = (l+r)/2;
... |
3,953 | //pass
//--gridDim=64 --blockDim=256
template <class T> __global__ void reduce3(T *g_idata, T *g_odata, unsigned int n);
template __global__ void reduce3<int>(int *g_idata, int *g_odata, unsigned int n);
#include "common.h"
template <class T>
__global__ void
reduce3(T *g_idata, T *g_odata, unsigned int n)
{
T *s... |
3,954 | #include <stdio.h>
__global__ void vecMatSum(int *a, int *b, int *c, int width, int length){
int row = blockIdx.x*blockDim.x + threadIdx.x;
int col = blockIdx.y*blockDim.y + threadIdx.y;
int tid = row*width+col;
if(tid < length)
c[tid] = a[tid] + b[tid];
}
int main(int argc, char* argv[]){
//initialization ... |
3,955 | #include "includes.h"
// this is how cuda knows that this code is a kernel by calling __global__
__global__ void cube(float * d_out, float * d_in) {
int idx = threadIdx.x ;
float f = d_in[idx];
d_out[idx] = f * f * f;
} |
3,956 | /*
Parallel Tile Coding Software version 3.0beta translated to C
by Jaden Travnik based on Rich Sutton's Python implementation
*/
// PARALLEL TILECODING
// A gpu kernal function which completes the hashing function started in calCoordAndHashFloat and stores it in d_hashArray on the gpu
__global__ void shiftHash(unsig... |
3,957 | #include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;
__global__ void maximum(int *a, int *b, int n)
{
int max=0;
int index = 256 * blockIdx.x;
for(int i=index;i<min(256+index,n);i++)
{
if(a[i]>max)
{
max=a[i];
}
}
b[blockIdx.x]=max;
}
__global__ void minimum(int *a, int *b, in... |
3,958 | #include "includes.h"
__device__ int greatest_row; __device__ void swap(float* arr, int ind_a, int ind_b)
{
float tmp = arr[ind_a];
arr[ind_a] = arr[ind_b];
arr[ind_b] = tmp;
}
__global__ void swapRow(float* mat, float* b, float* column_k, int rows, int cols, int k)
{
int row_i = greatest_row;
int i = blockIdx.x*bloc... |
3,959 | // Copyright 2013
#include <cmath>
#include <cstdlib>
#include <cstring>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
__global__ void im2col(const int n, const float * data_im,
const int height, const int width, const int imagenum,
float * data_col) {
int index = threadI... |
3,960 | #include "relu-grad.hh"
#include "graph.hh"
#include "../runtime/node.hh"
#include "../memory/alloc.hh"
namespace ops
{
ReluGrad::ReluGrad(Op* z, Op* dout)
: Op("relu_grad", z->shape_get(), {z, dout})
{}
void ReluGrad::compile()
{
auto& g = Graph::instance();
auto& cz_out = g... |
3,961 | #include "includes.h"
__global__ void reluActivationBackprop(float* Z, float* dA, float* dZ, int Z_x_dim, int Z_y_dim) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
if (index < Z_x_dim * Z_y_dim) {
if (Z[index] > 0) {
dZ[index] = dA[index];
}
else {
dZ[index] = 0;
}
}
} |
3,962 | #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... |
3,963 |
__device__
float divergence(const float* pz, const float* py, const float* px,
long idx, const int3& p, long size2d, const int3& shape)
{
float _div = 0.0f;
long _idx;
if ( p.z - 1 >= 0 ) {
_idx = (p.z - 1) * size2d + p.y * shape.x + p.x;
_div += (pz[idx] - pz[_idx]);
... |
3,964 | #include "includes.h"
/**********************************************************************
* DESCRIPTION:
* Serial Concurrent Wave Equation - C Version
* This program implements the concurrent wave equation
*********************************************************************/
#define MAXPOINTS 1000000
#define ... |
3,965 | #include <thrust/device_vector.h>
#include <thrust/transform.h>
#include <thrust/sequence.h>
#include <thrust/copy.h>
#include <thrust/fill.h>
#include <thrust/replace.h>
#include <thrust/functional.h>
#include <iostream>
int main(void)
{
// allocate three device_vectors with 10 elements
thrust::device_vector<... |
3,966 | #define ELEMENT_SIZE 64
#define BLOCK_SIZE 16
extern "C"
__global__ void int8pack_kernel(long *ret, const unsigned char *input, const int ret0, const int ret1, const int input1) {
const int y = blockIdx.x * blockDim.x + threadIdx.x;
const int x = blockIdx.y * blockDim.y + threadIdx.y;
const int tid = threa... |
3,967 | #include<iostream>
#include<thrust/reduce.h>
#include<thrust/sequence.h>
#include<thrust/host_vector.h>
#include<thrust/device_vector.h>
using namespace std;
int main(){
const int N=5000;
thrust::device_vector<int> a(N);
//填充数组
thrust::sequence(a.begin(),a.end(),0);
//计算数组各个元素之和
int SUM=thrust:... |
3,968 | // *----------------------------------------------
// Author Contact Information:
// Hao Gao
// hao.gao@emory.edu || hao.gao.2012@gmail.com
// Department of Mathematics and Computer Science, Emory University
// Department of Radiology and Imaging Sciences, Emory University
//
// Copyright (c) Hao Gao 2012
// ----... |
3,969 |
__device__ void HSV2RGB(float h, float s, float v, float &r, float &g, float &b) {
if(h < 0) {
r=v;
g=v;
b=v;
return;
}
h *= .0166666666666667; // convert from 360 to 0-6;
int i = (int) floor(h);
float f = h - i;
f = (!(i&1)) ? 1-f : f; // if even
float m = v * (1-s);
float n = v * (1-s... |
3,970 | /*
Author: Vedanta Pawar
NetID: vp273
Class: M.Eng ECE, Cornell University
Email: vp273@cornell.edu
Instructions for Compiling and Executing Code:
Compile: /usr/local/cuda-10.1/bin/nvcc -o vp273_hw5_2.out vp273_hw5_2.cu
Run: ./vp273_hw5_2.out "Enter the dimension of the matrix:" "Enter the Block Size:"
Example: ./vp27... |
3,971 | #include <algorithm>
#include <cassert>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <chrono>
using namespace std;
__global__ void convolution_1d(int *array, int *mask, int *result, int n,int m);
void verify_result(int *array, int *mask, int *result, int n, int m);
auto get_time() { return chrono... |
3,972 |
#include <cuda.h>
#ifdef _WIN32
# define IMPORT __declspec(dllimport)
#else
# define IMPORT
#endif
IMPORT int simplelib();
int main(void)
{
return simplelib();
}
|
3,973 | #include "includes.h"
__global__ void get_iou_cuda_(int nInstance, int nProposal, int *proposals_idx, int *proposals_offset, long *instance_labels, int *instance_pointnum, float *proposals_iou){
for(int proposal_id = blockIdx.x; proposal_id < nProposal; proposal_id += gridDim.x){
int start = proposals_offset[proposal_i... |
3,974 | #include "includes.h"
/* https://zxi.mytechroad.com/blog/dynamic-programming/leetcode-730-count-different-palindromic-subsequences/ */
long kMod = 1000000007;
__global__ void helperKernel(char *S, int *dp, int n, long kMod, int len) {
for(int i = blockIdx.x * blockDim.x + threadIdx.x; i < n - len; i += blockDim.x *... |
3,975 | #include <stdio.h>
#include <cuda.h>
#include <string>
//using namespace std;
__global__ void myKernel(int* c,int N )
{ if(threadIdx.x <N){
c[threadIdx.x] = 2;
printf("Hello, world from the device! \n");
//__syncthreads();
}
}
int main()
{
//int dayName[] = {1, 1,1,1,1,1,1,1,2,2};
int* dayName = (int*)malloc(1... |
3,976 | #include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <thrust/functional.h>
#include <thrust/transform.h>
#include <iostream>
#include <math.h>
int main() {
thrust::device_vector<double> AAPL;
thrust::device_vector<double> MSFT;
thrust::device_vector<double> MEAN_DIF(2518,0);
doub... |
3,977 | #include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <sys/time.h>
// Necessary for random numbers in CUDA
#include <curand_kernel.h>
#include <curand.h>
#define NUM_ITER 1000000000
#define TPB 128 // Threads PER block
#define NUM_THREADS 10000 ... |
3,978 | #include <cuda.h>
#include <assert.h>
#define N 2//(64*64)//(2048*2048)
#define THREADS_PER_BLOCK 2//512
__global__ void Asum(int *a, int *b, int *c){
int index = threadIdx.x + blockIdx.x*blockDim.x;
c[index] = a[index] + b[index];
}
|
3,979 | #include "includes.h"
__global__ void topBoundaryKernel(double* temperature, int block_size) {
int i = blockDim.x * blockIdx.x + threadIdx.x;
if (i < block_size) {
temperature[1 + i] = 1.0;
}
} |
3,980 | #include "includes.h"
__global__ void swap(unsigned short *d_input, float *d_output, int nchans, int nsamp) {
size_t t = blockIdx.x * blockDim.x + threadIdx.x;
size_t c = blockIdx.y * blockDim.y + threadIdx.y;
d_input[(size_t)(c * nsamp) + t] = (unsigned short) __ldg(&d_output[(size_t)(c * nsamp) + t]);
} |
3,981 | /*
152096 - William Matheus
Friendly Numbers
Programacao Paralela e Distribuida
CUDA - 2019/2 - UPF
Programa 2
*/
#include <stdio.h>
#include <cuda.h>
__device__ void gcd ( int a, int b, int *result){
int c, resto;
while ( a != 0 ) {
c = a;
a = b % a;
b = c;
}
*result = b;
}
__global__ void... |
3,982 | #include "includes.h"
__global__ void ComputeDistanceKernel( float *symbolVectors, float *inputVector, float *distance, int symbolSize, int symbols )
{
int symbolId = blockDim.x*blockIdx.y*gridDim.x //rows preceeding current row in grid
+ blockDim.x*blockIdx.x //blocks preceeding current block
+ threadIdx.x;
if(sym... |
3,983 | /***************************************************************************
*cr
*cr (C) Copyright 2007 The Board of Trustees of the
*cr University of Illinois
*cr All Rights Reserved
*cr
********************************************************************... |
3,984 | #include <cassert>
#include <cstdlib>
#include <iostream>
#include <chrono>
using namespace std;
#define MASK_DIM 7
#define MASK_OFFSET (MASK_DIM / 2)
// allocation in constant memory
__constant__ int mask[7 * 7];
__global__ void convolution_2d(int *matrix, int *result, int N);
void verify_result(int *m, int *mask, ... |
3,985 | #include "includes.h"
__global__ void host_api_kernel(float *randomValues, float *out, int N)
{
int i;
int tid = blockIdx.x * blockDim.x + threadIdx.x;
int nthreads = gridDim.x * blockDim.x;
for (i = tid; i < N; i += nthreads)
{
float rand = randomValues[i];
rand = rand * 2;
out[i] = rand;
}
} |
3,986 | /*
*
* Accessing out of bound memory from GPU
* Vector addition
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "cuda_runtime.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)... |
3,987 | // Copyright (c) Meta Platforms, Inc. and its affiliates.
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
#include "RedwoodNoiseModel.cuh"
#include <algorithm>
#include <cmath>
#include <cuda_runtime.h>
#include <curand_kernel.h>
namespac... |
3,988 | /*
compile
$ nvcc -o matrix_transpose_dot_product matrix_transpose_dot_product.cu
elementwise multiplication and subtraction
numpy version
import numpy as np
m1 = np.array(((0, 1, 2), (3, 4, 5), (6, 7, 8)))
m2 = np.array(((8, 7, 6), (5, 4, 3), (2, 1, 0)))
m1.dot(m2.T) # m1 dot m2_transpose (m1_m2T)
m1.T.dot(m2) ... |
3,989 | #include "includes.h"
__device__ inline unsigned int RM_Index(unsigned int row, unsigned int col, unsigned int width) {
return (row * width + col);
}
__global__ void GaussianNBVarKernel(const float *d_data, const int *d_labels, const float *feature_means_, float *feature_vars_, const int *class_count_, const unsigned i... |
3,990 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define M 32
void desplegar(int *matriz, int m, int n);
__global__ void calcularGPU2D(int *mask, int *imagen, int *res, int p, int m, int n)
{
int i = blockIdx.x*blockDim.x + threadIdx.x;
int j = blockIdx.y*blockDim.y + threadIdx.y;
res[i*n+j] = 0;
... |
3,991 | #include <cstdio>
__global__ void kernel()
{
}
int main()
{
kernel<<<1, 1>>>();
printf ("Hello, CUDA!\n");
return 0;
} |
3,992 | #include <iostream>
#include <vector>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include "Graph.cuh"
#include "Solver.cuh"
using namespace std;
namespace atspSolver
{
void fullCycle::display()
{
std::stringstream stream;
int pathSize = path.size();
for (int i = 0; i < pathSize; i++)
{... |
3,993 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <ctime>
//Function that verify cuda calls and return cuda error if any
#define gpuCheck(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true)
{
if (code != cudaSuccess)
... |
3,994 | #include "includes.h"
__global__ void set_cl(int *nnz_num, int *cl, int chunk, int pad_M)
{
int c_size = pad_M / chunk;
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i >= c_size) {
return;
}
int offset = chunk * i;
int max = 0;
int j, length;
for (j = 0; j < chunk; j++) {
length = nnz_num[offset + j];
if (length ... |
3,995 | #include <stdio.h>
#include <iostream>
#define NB_COLS 1000 // Nombre de colonnes de la matrice.
#define NB_ROWS 500 // Nombre de lignes de la matrice.
#define NB_THREADS 16 // Nombre de threads par bloc dans 1 dimension
void matrixInit(int *mat); // Initialisation d'une matrice.
void checkRes(int *mat); // V... |
3,996 |
// listPrimes - shows the prime numbers between a fixed range.
// this is a CUDA version that uses 1 thread in 1 block just using
// a simple serial approach
// Eric McCreath 2019 - GPL
// based on https://en.wikipedia.org/wiki/Integer_square_root
// assumes a positive number
#include<stdio.h>
#include<... |
3,997 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include<iostream>
using namespace std;
__global__ void multiply(int *a, int *b, int *c, int m, int n, int q)
{
int id_x = threadIdx.x;
int id_y = threadIdx.y;
int i,d=0;
for(i=0;i<n;i++)
{
d = d + (a[(id_y * n) + i] * b[(i * q) +... |
3,998 | /*
* 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... |
3,999 | #include "includes.h"
__global__ void simpleKernel(float *dst, float *src)
{
const int idx = blockIdx.x * blockDim.x + threadIdx.x;
float temp = src[idx];
dst[idx] = temp * temp;
} |
4,000 | /*
STEPS
1. Allocate host memory and initialized host data e.g. malloc
2. Allocate device memory e.g cudaMalloc
3. Transfer input data from host to device memory e.g cudaMemcpy
4. Execute kernels
5. Transfer output from device memory to host
6. Free Host & CUDA memory e.g. free & cudaFree
*/
#include <stdio.h>
#inclu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.