serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
5,501 | #include "stdio.h"
// Kernel addition on GPU
__global__ void add(int a, int* b)
{
*b += a * 100;
}
// Main function on the host
int main()
{
int b, *dev_b;
cudaMalloc((void **) &dev_b, sizeof(int));
add <<< 1, 1 >>> (2, dev_b);
cudaMemcpy(&b, dev_b, sizeof(int), cudaMemcpyDeviceToHost);
cudaFree(dev_b);
printf... |
5,502 | /*
* SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* 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 ... |
5,503 | #include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <sys/time.h>
#include <cuda_runtime.h>
#define IND(i, j) ((i) * (N + 2) + (j))
enum {
N = 1024,
ITERS_MAX = 1 << 10,
BLOCK_SIZE = 16
};
typedef uint8_t cell_t;
double wtime()
{
struct timeval t;
gettimeofday(&t, NULL);
ret... |
5,504 | #include "includes.h"
__global__ void pointwise_add(float *d_res, const float *d_op1, const float *d_op2, const int len)
{
const int pos = blockIdx.x*blockDim.x + threadIdx.x;
if(pos >= len) return;
d_res[pos] = d_op1[pos] + d_op2[pos];
} |
5,505 | #include<stdio.h>
#include<stdlib.h>
#include<cuda.h>
#include <sys/time.h>
#include <thrust/sort.h>
#include <thrust/execution_policy.h>
#include <algorithm>
using namespace std;
#define BLOCKSIZE 1024
__global__ void initialize(pair<float, int> * gputimes, unsigned n){
unsigned id = blockIdx.x * blockDim.x + th... |
5,506 | #include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
#include <time.h>
#include <math.h>
//add this if compiled by visual studio
#include <device_launch_parameters.h>
#define G 6.67e-2f
#define BLOCK_DIM 1024
#define MAX_RANGE 100.0f
#define MASS 10000.0f
#define EPS 1.0f
extern __shared__ float3 shared_... |
5,507 | #include "includes.h"
__global__ void copyFromOpenMM( float *target, float *source, int N ) {
const int elementNum = blockIdx.x * blockDim.x + threadIdx.x;
if( elementNum > N ) {
return;
}
const int atom = elementNum / 3;
target[elementNum] = source[4 * atom + elementNum % 3];
} |
5,508 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdlib.h>
#include <stdio.h>
#define NUM_SIZE 1024
template <unsigned int blockSize>
__global__ void reduce5(int *g_idata, int *g_odata) {
__shared__ volatile int sdata[512];
unsigned int tid = threadIdx.x;
unsigned int i = blockIdx.x... |
5,509 | #include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include <curand_kernel.h>
#include <stdlib.h>
#include <cuda.h>
#include <sys/time.h>
#include "computePointHessian0.cu"
#include<chrono>
#include<iostream>
using namespace std;
using namespace std::chrono;
int blocks_[20][2] = {{8,8},{16,... |
5,510 | extern "C" {
//#define Mask_width 5
//#define Mask_radius Mask_width/2
#define O_TILE_WIDTH 12
#define BLOCK_WIDTH (O_TILE_WIDTH+4)
#define clamp(x, start, end) min(max(x, start), end)
__global__ void convolution_2D_kernel(float*P,float*N,int height,int width,int channels,const floa... |
5,511 | #include <stdio.h>
/* 1-98番目までのテキスト。__ の部分を今の数字に、 ## の部分をひとつ減らした数字に置き換える */
__device__ char text[] = "__ bottles of beer on the wall, __ bottles of beer!\n"
"Take one down, and pass it around, ## bottles of beer on the wall!\n\n";
/* 99番目のテキスト。そのまま表示する */
__device__ char end[] =
"01 bottle of beer on the wal... |
5,512 | #include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include <stdlib.h>
#include <sys/time.h>
#include <cuda_runtime.h>
#define N 512
#define I 100000
#define BLOCKS 1
#define ORDER 1
#define cudaErrorCheck(ans) { gpuAssert((ans), __FILE__, __LINE__); }
i... |
5,513 | #include <stdio.h>
#include <stdlib.h>
#define N 4
#define threads_per_block 4
__global__ void simpleKernel(float *out, float *in)
{
int index;
index = blockIdx.x*blockDim.x+threadIdx.x;
if(index<N)
{
out[index]=in[index]*in[index]*in[index];
}
}
extern "C"
void GPU_STUFF(int device)
{
cudaSetDevi... |
5,514 | #include <iostream>
#include <stdlib.h>
#include <sstream>
#include <iomanip>
using namespace std;
#define iceil(num,den) (num+den-1)/den
//Kernel Function
__global__ void imgMulKernel(float* d_img_in, float* d_img_out, int w, int h, float *d_img_fin, int fw, int fh){
//Access the pixel on the image
int c = block... |
5,515 | #include<iostream>
#include <stdio.h>
using namespace std;
int main()
{
FILE* f;
//FILE* f1;
int64_t num;
int64_t k=0;
int64_t sum=0;
int64_t results[1000000];
f=fopen("22.txt","r");
//f1=fopen("18norepeat.txt","w");
for(int64_t i=0;!feof(f);i++)
{
k=0;
fscanf(f, ... |
5,516 | /*#include <iostream>*/
/*#include <ctime>*/
/*#include <stdio.h>*/
/*#include <stdlib.h>*/
/*#include <cuda.h>*/
/*#include <cuda_runtime.h> // Stops underlining of __global__*/
/*#include <device_launch_parameters.h> // Stops underlining of threadIdx etc.*/
/*#include <sys/types.h>*/
/*#include <sys... |
5,517 | // Author: Sudnya Padalikar
// Date: 01/26/2014
// Brief: Tiled (into shared memory) matrix multiplication kernel in cuda
#include <stdio.h>
#include <cassert>
#include <iostream>
#define TILE_SIZE 16
// Kernel that executes on the CUDA device
__device__ void tileMultiplyShared(float * A, float * B, float * C,
... |
5,518 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#ifndef __CUDACC__
#define __CUDACC__
#endif
#include "device_functions.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define DEFAULT_THRESHOLD 8000
#define DEFAULT_FILENAME "BWstop-sign.ppm"
#define MASK_WIDTH 3
#defin... |
5,519 | #include <thrust/scan.h>
#include <thrust/device_vector.h>
#include <iostream>
int main(){
int data[6] = {1, 0, 2, 2, 1, 3};
thrust::inclusive_scan(data, data + 6, data);
/* data[0] = data[0]
* data[1] = data[0] + data[1]
* data[2] = data[0] + data[1] + data[2]
* ...
* data[5] = data[0] + data[1] + ... ... |
5,520 | #include<stdio.h>
#include<stdlib.h>
#include<cuda.h>
#include<time.h>
#define BLOCK_SIZE 25
__global__ void gpu_shared_matrix_mul(float *a, float *b, float *gpu_mul, int n)
{
__shared__ float tile_a[BLOCK_SIZE][BLOCK_SIZE];
__shared__ float tile_b[BLOCK_SIZE][BLOCK_SIZE];
int row=blockIdx.y*blockDim.y+threadIdx.... |
5,521 | //This file is take from caffe/crfasrnn
#define modHash(n) ((n)%(2*table_capacity));
namespace caffe {
template<int kd>
__device__ __host__ static unsigned int hash(signed short *key) {
unsigned int k = 0;
for (int i = 0; i < kd; i++) {
k += key[i];
k = k * 1664525;
}
return k;
}
... |
5,522 |
/* Execution Format : ./<exe> <drug_result_1_dict_compounds.txt> <drug_result_2_dict_compounds.txt> <drug_result_1_dict_proteins.txt> <drug_result_2_dict_proteins.txt> <para.txt> <drug name>
*/
#include <stdio.h>
#include <errno.h>
#include <math.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include... |
5,523 | // fermi
/*
* Copyright 2018 Vrije Universiteit Amsterdam, The Netherlands
*
* 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
* Unles... |
5,524 | #include <cstdio>
#include <cuda_runtime.h>
#include "main.cuh"
#define gpuCheck(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true)
{
if (code != cudaSuccess)
{
fprintf(stderr,"GPUassert: %s %s %d\n", cudaGetErrorString(co... |
5,525 | #include<cuda.h>
#include<stdio.h>
void initializeArray(int*,int);
void stampaArray(int*, int);
void equalArray(int*, int*, int);
void prodottoArrayCompPerCompCPU(int *, int *, int *, int);
//specifica il tipo di funzione kernel
__global__ void prodottoArrayCompPerCompGPU(int*, int*, int*, int );
int main(int argn, c... |
5,526 | #include "includes.h"
#define BLOCK_SIZE 16
#define BLOCKSIZE_X 16
#define BLOCKSIZE_Y 16
// STD includes
// CUDA runtime
// Utilities and system includes
static // Print device properties
__global__ void readChannelKernel(unsigned char * image, unsigned char *channel, int imageW, int imageH, int channelToExtrac... |
5,527 | // zeros out the part of a block above the diagonal
// sets ones on the diagonal (kernel by V.Volkov)
extern "C" {
__global__ void enforceLU( float *matrix, int lda )
{
int i = threadIdx.x;
int j = blockIdx.x;
if( i <= j )
matrix[i + j*lda] = (i == j) ? 1 : 0;
}
}
// zeros out the whole part of ... |
5,528 | #include "includes.h"
__global__ void times_kernel(float *v, float *other, int n) {
int x(threadIdx.x + blockDim.x * blockIdx.x);
if (x >= n) return;
v[x] *= other[x];
} |
5,529 | #include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <cuda.h>
#define CHECK_CUDA_ERR(x) \
if ( (err = x) != cudaSuccess) { \
printf("%d failed with error :%s\n",__LINE__,cudaGetErrorString(err)); \
exit(1); \
}
#define CHECK_LAST_ERR \
if ( (err = cudaGetLastError()) != cudaSucce... |
5,530 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <curand.h>
// thrust library
#include <thrust/device_vector.h>
#include <thrust/tuple.h>
#include <thrust/generate.h>
#include <thrust/random.h>
#include <thrust/sort.h>
#include <thrust/copy.h>
#include <stdio.h>
#include <stdlib.h>
#include <io... |
5,531 | #include <stdlib.h>
#include <sys/time.h>
timeval StartingTime;
void setTime(){
gettimeofday( &StartingTime, NULL );
}
double getTime(){
timeval PausingTime, ElapsedTime;
gettimeofday( &PausingTime, NULL );
timersub(&PausingTime, &StartingTime, &ElapsedTime);
return ElapsedTime.tv_sec*1000.0+ElapsedTime.tv_usec... |
5,532 | #include <stdio.h>
#include <stdint.h>
#define CHECK(call) \
{ \
const cudaError_t error = call; \
if (error != cudaSuccess) ... |
5,533 | #ifdef USE_DOUBLE
#define real_t double
#define fftComplex_t cufftDoubleComplex
#define complex_t cuDoubleComplex
#else
#define real_t double
#define fftComplex_t cufftDoubleComplex
#define complex_t cuDoubleComplex
#endif
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cuda.h>
#include <cuda_runti... |
5,534 | //=====================================================================
// MAIN FUNCTION
//=====================================================================
__device__ void kernel_fin_2(int timeinst, float* d_initvalu, float* d_finavalu, int offset_ecc,
int offset_Dyad, int offset_SL, int offset_Cyt, float* d_p... |
5,535 | /*********************
MIT License
Copyright (c) 2020 Matzoros Christos
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, ... |
5,536 | //=======================================================================================================
// Copyright 2015 Asgeir Bjorgan, Lise Lyngsnes Randeberg, Norwegian University of Science and Technology
// Distributed under the MIT License.
// (See accompanying file LICENSE or copy at
// http://opensource.org/... |
5,537 | ////////////////////////////////////////////////////////////////////////////
//
// Copyright 1993-2015 NVIDIA Corporation. All rights reserved.
//
// Please refer to the NVIDIA end user license agreement (EULA) associated
// with this source code for terms and conditions that govern your use of
// this software. Any u... |
5,538 | #include "includes.h"
__global__ void crate3Dplot(float* plotValues, float patchSize, int itemsX, int itemsY, float maxValue, float* vertexData)
{
int threadId = blockDim.x*blockIdx.y*gridDim.x //rows preceeding current row in grid
+ blockDim.x*blockIdx.x //blocks preceeding current block
+ threadIdx.x;
int size = ... |
5,539 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <math.h>
__global__ void kernel_transpuesta(double *m, int N){
int tid = blockIdx.x * blockDim.x * blockDim.y + threadIdx.y * blockDim.x + threadIdx.x;
int i = int((1 + sqrtf(1 + 8*tid)) / 2);
int j = tid - (i*(i-1)/2); ... |
5,540 | // transform sample
#include <thrust/transform.h>
#include <thrust/functional.h>
#include <thrust/transform_reduce.h>
#include <thrust/device_vector.h>
#include <iostream>
void print_array(int* data, int len){
for(int i=0; i<len; i++){
std::cout << data[i];
}
std::cout << std::endl;
}
// create my functio... |
5,541 | #include <string.h>
#include <stdlib.h>
#include <stdio.h>
//CUDA RunTime API
#include <cuda_runtime.h>
#include <time.h>
#define THREAD_NUM 1024
#define BLOCK_NUM 16
#define DATA_SIZE 1048576
// __global__ 函数(GPU上执行) 计算立方和
__global__ static void sumOfSquares(int *num, int* result, clock_t* time)
{
extern __shared__... |
5,542 | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
#pragma pack (1)
//设置对齐方式
#define GauSize 5
typedef struct{
short type; //文件类型,必须为BM
int size; //整个位图文件的大小,以字节为单位
short reserved1; //保留,全0
short reserved2; //保留,全0
int offset; //位图数据的起始位置,字节为... |
5,543 | #include "includes.h"
__global__ void rayleighHS(double *Mh_d, double *pressure_d, double *Rho_d, double *Altitude_d, double surf_drag, double bl_sigma, double Gravit, double time_step, int num) {
int id = blockIdx.x * blockDim.x + threadIdx.x;
int nv = gridDim.y;
int lev = blockIdx.y;
if (id < num) {
doubl... |
5,544 |
/* Includes, system */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <sys/time.h>
/* Includes, cuda */
#include <cuda.h>
#include <cuda_runtime.h>
#define N 1000000
#define GRID 100000
#define BLOCK 100
#define M 1000
/* Main */
int main(int argc, char** argv)
{
double *... |
5,545 | #include <stdio.h>
#include <cuda.h>
/* Thread block size = number of threads of a block*/
/* Notice: in this example, the input data size = 2*BLOCK_SIZE */
#define BLOCK_SIZE 8
/*The kernel*/
__global__ void Reduction(const float* input, float* output)
{
/*Declare the shared memory*/
__shared__ float partialSum[2*... |
5,546 | #include "includes.h"
__global__ void matrixTrans(float * M,float * MT)
{
int val=0;
int row = blockIdx.x * blockDim.x + threadIdx.x;
int col = blockIdx.y * blockDim.y + threadIdx.y;
MT[row + col*N] = 0;
if (row < N && col < N)
{
val = M[col + row*N];
MT[row + col*N] = val;
}
} |
5,547 | #include "includes.h"
__global__ void cunn_SpatialLogSoftMax_updateOutput_kernel (float *output, float *input, int feature_size, int spatial_size, int data_size, float constant)
{
int idx = (threadIdx.x + blockDim.x*blockIdx.x);
idx = (idx/spatial_size)*feature_size + idx % spatial_size;
if (idx < data_size) {
int nex... |
5,548 |
__global__ void scan_simple(float *out, float *in, int length) {
volatile extern __shared__ float data[];
int tid = threadIdx.x + blockIdx.x * blockDim.x;
int tx = threadIdx.x;
data[tx] = in[tid];
int pout = 0; int pin = 1;
if (tid < length) {
for (int offset = 1; offset < blockDim.x; offset <<= 1) {
... |
5,549 | #include "includes.h"
using namespace std;
// https://stackoverflow.com/questions/26853363/dot-product-for-dummies-with-cuda-c
__global__ void reduce0(float* g_odata, float* g_idata1, float* g_idata2) {
extern __shared__ float sdata[];
// each thread loads one element from global to shared mem
unsigned int tid =... |
5,550 | /*
* compute 0 + 1 + 2 + ... + 1023 using cuda - in a bad way
*/
#include <stdlib.h>
#include <stdio.h>
__global__ void sum(int *result) {
*result = *result + threadIdx.x;
}
int main() {
int h_result = 0;
void *d_result;
cudaMalloc(&d_result,sizeof(int));
cudaMemcpy(d_result,&h_result,sizeof(int),cudaMemcpy... |
5,551 | #include"stdio.h"
#include"time.h"
__global__ void gpu_1(float *da1,float *db1,float *dc1,int n)
{
for(int i=0;i<n;i++)
{
//dc1[i]=db1[i]+da1[i];
dc1[i]=db1[i]*da1[i];
}
}
__global__ void gpu_2(float *da1,float *db1,float *dc1,int n)
{
int tid=threadIdx.x;
const int t_n=blockDim.x;
printf("%d\n",t_n);... |
5,552 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <time.h>
#include <math.h>
#define TILE_WIDTH 16
void printDevProp(cudaDeviceProp devProp) {
// Source: https://stackoverflow.com/questions/32530604/how-can-i-get-number-of-cores-in-cuda-device
printf("%s\n", devProp.name);
printf("Major re... |
5,553 | #include <stdio.h>
#include <cuda_runtime.h>
#include <time.h>
#include <vector>
using namespace std;
const int GPUs[] = {0,1,2,3,4}; // If left blank all available GPUs will be used.
vector<int> g(GPUs, GPUs + sizeof(GPUs)/sizeof(int));
void configure(size_t size, vector<int*> &buffer_s, vector<int*> &buffer_d,
... |
5,554 | //***************************************************************************
// Name: Broday Walker
//
// Links:
// 1. https://devblogs.nvidia.com/how-query-device-properties-and-handle-errors-cuda-cc/
// 2. https://www.cs.cmu.edu/afs/cs/academic/class/15668-s11/www/cuda-doc/html/group__CUDART__DEVICE_g5aa4f479... |
5,555 | #include <iostream>
#include <math.h>
#include <chrono>
__global__ void vecAdd(double *a, double *b, double *c, int n){
// Global Thread ID
int id = blockIdx.x*blockDim.x + threadIdx.x;
// Check to make sure we are in range
if (id < n){
c[id] = a[id] + b[id];
}
}
int main(){
int n =... |
5,556 | #include "includes.h"
__device__ static float rgbaToGray(uchar4 rgba) {
return (0.299f * (float)rgba.x + 0.587f * (float)rgba.y +
0.114f * (float)rgba.z);
}
__global__ void createAnaglyph_kernel(uchar4 *out_image, const uchar4 *left_image, const uchar4 *right_image, int width, int height, int pre_shift) {
const int x =... |
5,557 | #include "includes.h"
__global__ void cunnx_BlockSparse_updateOutput_kernel( float *output, const float *input, const float *outputIndice, const float *outputScale, const float *bias, int outputSize, int nOutputBlock, int inputWindowSize, int outputWindowSize)
{
__shared__ float buffer[BLOCKSPARSE_THREADS];
int tx = th... |
5,558 | #include "includes.h"
__global__ void scale_bias_kernel(float *output, float *scale, int batch, int filters, int spatial, int current_size)
{
const int index = blockIdx.x*blockDim.x + threadIdx.x;
if (index >= current_size) return;
int f = (index / spatial) % filters;
output[index] *= scale[f];
} |
5,559 | #include "seq.hh"
#include <cassert>
#include <stdexcept>
#include "graph.hh"
#include "mse-grad.hh"
#include "ops-builder.hh"
#include "../runtime/node.hh"
#include "../memory/alloc.hh"
namespace ops
{
Seq::Seq(std::vector<Op*> ops)
: Op("seq", ops.back()->shape_get(), ops)
{}
void Seq::compile(... |
5,560 | #include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <ctime>
#include <algorithm>
// Thread block size
#define BLOCK_SIZE 1024
// Size of Array
// #define SOA 67107840
// #define SOA 2147483647
#define SOA 1147483647
// #define SOA 8193
// Alloca... |
5,561 | /* Author: Christopher Mitchell <chrism@lclark.edu>
* Date: 2011-07-15
*
* Compile with `gcc gol.c`.
*/
#include <stdlib.h> // for rand
#include <string.h> // for memcpy
#include <stdio.h> // for printf
#include <time.h> // for nanosleep
#include<curand.h>
#define WIDTH 60
#define HEIGHT 30
// The two boards
in... |
5,562 | #include "includes.h"
__global__ void modified_insertion_sort(float * dist, int dist_pitch, int * index, int index_pitch, int width, int height, int k){
// Column position
unsigned int xIndex = blockIdx.x * blockDim.x + threadIdx.x;
// Do nothing if we are out of bounds
if (xIndex < width) {
//... |
5,563 | #include "includes.h"
__global__ void addPermutations(double *determinant, double *permutations, int *n){
int nn=*n**n-1;
*determinant=0;
for(int i=0;i<nn;i++){
*determinant+=permutations[i];
}
} |
5,564 | #include "includes.h"
__global__ void set_scales_dropblock_kernel(float *drop_blocks_scale, int block_size_w, int block_size_h, int outputs, int batch)
{
const int index = blockIdx.x*blockDim.x + threadIdx.x;
if (index >= batch) return;
//printf(" drop_blocks_scale[index] = %f \n", drop_blocks_scale[index]);
const flo... |
5,565 | // CopyBackAndForth.cu
#include <assert.h>
#include <stdio.h>
__device__ char devarray[16];
extern "C" void runTest()
{
char zerobuf[16];
memset(zerobuf, '@', sizeof(zerobuf));
cudaError_t r = cudaMemcpyToSymbol(devarray, zerobuf, sizeof(zerobuf), 0, cudaMemcpyHostToDevice);
assert(cudaSuccess == r);
... |
5,566 | #include <cuda_runtime.h>
#include <stdio.h>
#include "leaky.cuh"
__global__ void _leakyReluKer(float const *in, float *out, int size) {
int index = threadIdx.x + blockIdx.x * blockDim.x;
if (index >= size)
return ;
if (in[index] < 0)
out[index] = in[index] * 0.1;
else
out[ind... |
5,567 | #include <stdio.h>
#include <time.h>
__global__ void kernel( int* result )
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
result[i] = i;
for(int p = 2; p <= i/2; p++)
{
if(i % p == 0){ result[i] = 0; break; }
}
}
double diff_sec(time_t start, time_t end)
{
return (double)(end - start)/CLOCKS_PER_SEC;
}
int... |
5,568 | #include "includes.h"
__global__ void MatrixMulKernel(float* Md, float* Nd, float* Pd, int Width)
{
// Calculate the row index of the Pd element and M
int Row = blockIdx.y*BLOCK_SIZE + threadIdx.y;
// Calculate the column idenx of Pd and N
int Col = blockIdx.x*BLOCK_SIZE + threadIdx.x;
float Pvalue = 0;
// each thread ... |
5,569 | #include "includes.h"
__global__ void conductance_calculate_postsynaptic_current_injection_kernel( float* decay_term_values, float* reversal_values, int num_decay_terms, int* synapse_decay_values, float* neuron_wise_conductance_traces, float* d_neurons_current_injections, float * d_membrane_potentials_v, float timestep... |
5,570 | #include "includes.h"
__global__ void kernel_getRotMatL(double* devRotm, double* devnR, int nR)
{
extern __shared__ double matS[];
double *mat, *res;
mat = matS + threadIdx.x * 18;
res = mat + 9;
mat[0] = 0; mat[4] = 0; mat[8] = 0;
mat[5] = devnR[threadIdx.x * 4 + 1];
mat[6] = devnR[threadIdx.x * 4 + 2];
mat[1] = de... |
5,571 | #include "includes.h"
__global__ void convolution_backward_kernel(float *y_h, float *filters, float *vbias, float *target, float *y_v, int input_size, int lu_padding, int channel_num, int feature_map_size, int filter_num, int filter_size, float *rnd_array, int rnd_num){
int imgIdx = blockIdx.y / (input_size / 16);
int ... |
5,572 | #include "includes.h"
/*
* This code implements the interleaved Pair approaches to
* parallel reduction in CUDA. For this example, the sum operation is used.
*/
// Recursive Implementation of Interleaved Pair Approach
__global__ void reduceInterleaved (int *g_idata, int *g_odata, unsigned int n)
{
// set thread ID
un... |
5,573 | #include <stdio.h>
#include <math.h>
#define TILE_WIDTH 2
__global__
void MatrixMulKernel(float *d_M , float *d_N , float *d_P , int Width) {
__shared__ float Mds[TILE_WIDTH][TILE_WIDTH];
__shared__ float Nds[TILE_WIDTH][TILE_WIDTH];
int bx = blockIdx.x; int by = blockIdx.y;
int tx = threadIdx.x; int ty = thread... |
5,574 | # include <stdio.h>
# include <stdint.h>
# include "cuda_runtime.h"
# include "cuda_profiler_api.h"
#define ITERATIONS 2
#define DEBUG 1
#define MAX_SHARED_E 2048
#include <time.h>
#include <sys/time.h>
#define USECPSEC 1000000ULL
unsigned long long dtime_usec (unsigned long long start) {
timeval tv;
gettimeof... |
5,575 | #include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/copy.h>
#include <thrust/fill.h>
#include <thrust/sequence.h>
#include <iostream>
//printing device vector
void printDeviceVector(thrust::device_vector<int> v, std::string name) {
for(int i = 0; i < v.size(); i++) {
std::co... |
5,576 | #include <stdio.h>
#include <cuda.h>
#include <cuda_runtime.h>
#define SIZE 400
// two dimension
#define Blocks 20
#define threadPerBlock 20
//For practicing, only consider 16*16 matrix
__global__ void gpuMM_noshared(float* d_a, float* d_b, float* d_res){
//each thread is responsible for one element of re... |
5,577 | //#define REARRANGED_DOMAIN
#ifdef USING_SHARED_MEMORY
#define BLOCK_SIZE 960
#endif
__global__ void gravity_wb(
int N,
double g,
double * stage_vertex_values,
double * stage_edge_values,
double * stage_centroid_values,
double * bed_edge_values,
double * be... |
5,578 | #include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
#define SIZE 1024
__global__ void histo_kernel(int size, unsigned int *histo)
{
int i = threadIdx.x + blockIdx.x * blockDim.x;
if (i < size)
{
//*histo+=i;
atomicAdd(histo, i);
}
}
|
5,579 | /**
* Copyright 1993-2015 NVIDIA Corporation. All rights reserved.
*
* Please refer to the NVIDIA end user license agreement (EULA) associated
* with this source code for terms and conditions that govern your use of
* this software. Any use, reproduction, disclosure, or distribution of
* this software and relate... |
5,580 |
#include <iostream>
using namespace std;
__global__ void kernel() {}
int main()
{
kernel<<<1,1>>>();
cout << "Hello, CUDA!" << endl;
return 0;
}
|
5,581 | /* Matrix normalization.
* Compile with "gcc matrixNorm.c"
*/
/* ****** ADD YOUR CODE AT THE END OF THIS FILE. ******
* You need not submit the provided code.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <sys/types.h>
#include <sys/times.h>
#include <sys/time.h>
#includ... |
5,582 | #include "includes.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_DIM];
int offset... |
5,583 |
#include <stdio.h>
__global__ void add(int *a, int *b, int *c) {
// *c = *a + *b
int id=blockIdx.x;
c[id]=a[id]+b[id];
}
int main(void) {
int a[2], b[2], c[2];
// host copies of variables a, b & c
int *d_a, *d_b, *d_c; // device copies of variables a, b & c
int size = sizeof(int);
// Allocate space for device... |
5,584 | /* This function writes the transformed space (dm,t) out to file in binary format.
*/
#include <stdio.h>
#include <stdlib.h>
void write_output(int i, int t_processed, int ndms, size_t gpu_memory, float *output_buffer, size_t gpu_outputsize, float *dm_low, float *dm_high)
{
FILE *fp_out;
char filename[200];
/*
... |
5,585 | /*
* Noopur Maheshwari : 111464061
* Rahul Rane : 111465246
*/
#include <iostream>
#include <vector>
#include <map>
using namespace std;
extern void *__do_work_cpu(void *data);
extern void *__do_work_gpu(void *data);
extern map<pthread_t, pthread_mutex_t> cpu_lock_map;
extern map<pthread_t, pthread_mutex_t> gpu_loc... |
5,586 | #define TS 32 // Tile size
template<typename Int, typename Alpha, typename TypeA, typename TypeB, typename Beta,
typename TypeC>
__global__ void gemm(bool transA, bool transB, Int m, Int n, Int k, Alpha alpha, TypeA *a, Int lda,
TypeB *b, Int ldb, Beta beta, TypeC *c, Int ldc) {
const Int inx = blockIdx.x * ... |
5,587 | // Date March 26 2029
//Programer: Hemanta Bhattarai
// Progarm : To add two arrays and compare computation time in host and device
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h> //for random numbers
#include <time.h>
#include <sys/time.h>
#define gpuErrchk(a... |
5,588 | // Check that types, widths, __GCC_ATOMIC* macros, etc. match on the host and
// device sides of CUDA compilations. Note that we filter out long double, as
// this is intentionally different on host and device.
//
// FIXME: We really should make __GCC_HAVE_SYNC_COMPARE_AND_SWAP identical on
// host and device, but arc... |
5,589 | /******************************************************************************
*cr
*cr (C) Copyright 2010 The Board of Trustees of the
*cr University of Illinois
*cr All Rights Reserved
*cr
*****************************************************************... |
5,590 | // https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#texture-functions |
5,591 | #include "cuda_runtime.h"
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <cstdio>
#include <chrono>
#define N 32
__global__ void thread_device_multi(int *array)
{
int i = blockDim.x * blockIdx.x + threadIdx.x;
int j = threadIdx.x;
array[i] = j;
}
int main()
{
int *device_array;
int ... |
5,592 | #include <bits/stdc++.h>
#include <curand_kernel.h>
using namespace std;
constexpr int POPULATION_SIZE = 128;
constexpr int GENERATIONS = 100;
constexpr double MUTATION_RATE = 0.1;
//constexpr int MAX_SIZE = 1000;
#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t... |
5,593 | #include "includes.h"
__device__ double2 pow(double2 a, int b){
double r = sqrt(a.x*a.x + a.y*a.y);
double theta = atan(a.y / a.x);
return{pow(r,b)*cos(b*theta),pow(r,b)*sin(b*theta)};
}
__global__ void pow_test(double2 *a, int b, double2 *c){
c[0] = pow(a[0],b);
} |
5,594 | #include "includes.h"
#define ITER 4
#define BANK_OFFSET1(n) (n) + (((n) >> 5))
#define BANK_OFFSET(n) (n) + (((n) >> 5))
#define NUM_BLOCKS(length, dim) nextPow2(length) / (2 * dim)
#define ELEM 4
#define TOTAL_THREADS 512
#define TWO_PWR(n) (1 << (n))
extern float toBW(int bytes, float sec);
__device__ __inline__... |
5,595 | #include <stdlib.h>
#include <stdio.h>
#include <getopt.h>
__global__ void add_vector(int *vOne, int *vTwo, int *vResult, int N) {
int i;
i = blockDim.x * blockIdx.x + threadIdx.x;
while (i < N) {
vResult[i] = vOne[i] + vTwo[i];
i += blockDim.x;
}
}
int main(int argc, char* argv[]) {
int numThreadBlocks, n... |
5,596 | #include "includes.h"
__global__ void Relu(float * x, size_t idx, size_t N, float W0)
{
for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < N; i += blockDim.x * gridDim.x)
x[(idx-1)*N + i] = W0*x[(idx-1)*N + i] > 0 ? W0*x[(idx-1)*N + i] : 0.01;
return;
} |
5,597 | #include <stdio.h>
#include "cuda.h"
static __global__ void testkernel() {
printf("hello from kernel\n");
}
int test() {
printf("hello from cuda\n");
testkernel<<<1, 1>>>();
cudaDeviceSynchronize();
return 0;
}
|
5,598 | #include <cstdio>
#include <cstdlib>
#include <vector>
__global__ void init_bucket(int *bucket) {
bucket[blockIdx.x*blockDim.x+threadIdx.x] = 0;
}
__global__ void add_bucket(int *bucket, int *key) {
int i = blockIdx.x*blockDim.x+threadIdx.x;
atomicAdd(&bucket[key[i]], 1);
}
__global__ void sort_key(int *... |
5,599 | #include "includes.h"
__global__ void calcDenseBackwardGPU( float *dz_in, float *dz, float *in, float *weights, float *biases, float *gradients, float *dW, float *dB, int batch_size, int in_size_x, int in_size_y, int in_size_z, int out_size_x, int out_size_y, int out_size_z, float momentum, float decay )
{
int id = (bl... |
5,600 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define SUBMATRIX_SIZE 10000
#define BLOCK_SIZE 16
float getnum() {
return rand()/((float) RAND_MAX);
}
__global__ void gpu_matrix_multiply(float *a, float *b, float *c, int n)
{
__shared__ float tile_a[BLOCK_SIZE][BLOCK_SIZE];
__shared__ float tile_b... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.