serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
19,901 | #include <fstream>
#include <iostream>
#include <iomanip>
#include <cuda.h>
#include <cuda_runtime.h>
#include <cuda_runtime_api.h>
#include <math.h>
using namespace std;
//Execute 1 thread per pixel of output image.
//Each thread handles all four channels of the output pixels
__global__ void encode_per_pixel_kernel(... |
19,902 | #include <stdio.h>
#include "cuda.h"
#define max(x,y) ((x) > (y)? (x) : (y))
#define min(x,y) ((x) < (y)? (x) : (y))
#define ceil(a,b) ((a) % (b) == 0 ? (a) / (b) : ((a) / (b)) + 1)
void check_error (const char* message) {
cudaError_t error = cudaGetLastError ();
if (error != cudaSuccess) {
printf ("CUDA error :... |
19,903 | #include <cmath>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <fstream>
static void HandleError( cudaError_t err, const char *file, int line) {
if (err != cudaSuccess) {
std::cout << cudaGetErrorString( err ) << " in " << file << " line " << line << std::endl;
exit(EXIT_FAILURE);
}
}
... |
19,904 | #include "includes.h"
__global__ void __fillToInds4D(float A, float *B, int ldb, int rdb, int tdb, int *I, int nrows, int *J, int ncols, int *K, int nk, int *L, int nl) {
int tid = threadIdx.x + blockDim.x * (blockIdx.x + gridDim.x * blockIdx.y);
int step = blockDim.x * gridDim.x * gridDim.y;
int l = tid / (nrows * nco... |
19,905 | //this is a sample CUDA program
#include <stdio.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
__global__ void hello_cuda()
{
printf("hello cuda world \n");
}
int main(){
//kernel_name <<<number_of_blocks, thread_per_block>>>(arguments)
//hello_cuda <<<1,4>>>();
//...<<<grid,block>>>(argument... |
19,906 | #include <iostream>
#include <sys/time.h>
using namespace std;
__global__ void Plus(float A[],float B[],float C[],int n){
int i = threadIdx.x+blockIdx.x*blockDim.x;
C[i]=A[i]+B[i];
}
int main(){
struct timeval start ,end;
gettimeofday(&start,NULL);
float *A,*B,*C,*Ad,*Bd,*Cd;
int n=1024*1024;
int size=n*sizeo... |
19,907 | #include "ward_implement.h"
#include "brdf_common.h"
__global__ void
ward_kernel(float3* pos, unsigned int width, float3 V, float3 N, float3 X, float3 Y, float alpha_x, float alpha_y, bool anisotropic)
{
unsigned int x = blockIdx.x*blockDim.x + threadIdx.x;
unsigned int y = blockIdx.y*blockDim.y + threadIdx.... |
19,908 | #include "includes.h"
__device__ void __gpu_sync(int blocks_to_synch)
{
__syncthreads();
//thread ID in a block
int tid_in_block= threadIdx.x;
// only thread 0 is used for synchronization
if (tid_in_block == 0)
{
atomicAdd((int *)&g_mutex, 1);
//only when all blocks add 1 to g_mutex will
//g_mutex equal to blocks_to_... |
19,909 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <device_functions.h>
#include <stdio.h>
#include <cstdlib>
#include <math.h>
#include<time.h>
#include <cuda.h>
#include <cuda_runtime_api.h>
#define Number 1000
#define Delta_t 0.01
__global__
void Simulate(double* Vortex_p, double* Omega... |
19,910 | #include "includes.h"
// Copyright (c) 2020, Michael Kunz. All rights reserved.
// https://github.com/kunzmi/ImageStackAlignator
//
// This file is part of ImageStackAlignator.
//
// ImageStackAlignator is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public Licens... |
19,911 | #include <stdint.h>
#include <unistd.h>
#include <stdio.h>
#include <assert.h>
#include <sys/time.h>
#include <time.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/syscall.h>
#define gpu_hook(x) syscall(380,x)
static void HandleError( cudaError_t err, const char *file, int line ) {
if (err != cuda... |
19,912 | #include "includes.h"
__global__ void matmul(const float *a, const float *b, float *c, int n, int m){
int i = blockDim.x * blockIdx.x + threadIdx.x;
int j = blockDim.y * blockIdx.y + threadIdx.y;
//printf("%d %d %d %d %d %d\n",blockDim.x,blockDim.y,blockIdx.x,blockIdx.y,threadIdx.x,threadIdx.y);
int idx = j * n + i;
if... |
19,913 | #include <iostream>
#include <math.h>
#include <unistd.h>
#include <memory>
#include <algorithm>
#include <array>
#include <numeric>
// the output incorrectly says that the data mismatches, but it appears to be an issue with doubles
// changing all types to integral types showed 0 issues, which for small N, was also... |
19,914 | #include "includes.h"
__global__ void bpnn_layerforward_CUDA(float *input_cuda, float *output_hidden_cuda, float *input_hidden_cuda, float *hidden_partial_sum, int in, int hid)
{
int by = blockIdx.y;
int tx = threadIdx.x;
int ty = threadIdx.y;
int index = ( hid + 1 ) * HEIGHT * by + ( hid + 1 ) * ty + tx + 1 + ( hid ... |
19,915 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
// CUDA kernel. Each thread takes care of one element of c
__global__ void matAdd(double *a, double *b, double *c, int n)
{
// Get our global thread ID
int id = blockIdx.x*blockDim.x+threadIdx.x;
// Make sure we do not go out of bounds - should be... |
19,916 | #include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <time.h>
#include <iostream>
using namespace std;
__global__ void boyer_moore (int *g){
char s_shared[32768];
for(long j=0;j<10000000;j++){
for(int i=0;i<32;i++){
//s_shared[i*1024+(threadIdx.x*4)+(th... |
19,917 | #include <stdio.h>
#include <stdlib.h>
void CPU_Matrix_Multiply(int m, int n, int k, double *a, double *b, double *c){
for (int x = 0; x < m; x++) { // row number of output
for (int y = 0; y < k; y++) { // column number of output
c[k*x+y] = 0;
for (int z = 0; z < n; z++) { //Add n eleme... |
19,918 | extern "C"
__global__ void calcDir(// Dots props
float* pX,
float* pY,
float* pZ,
//Tree specs
// per Block
//int* dotIndexes,
float* avgPX,
float* avgPY,
float* avgP... |
19,919 | //Author: Ugo Varetto
//Parallel dot product with timing. Link with librt (-lrt)
//#include <cuda_runtime.h> // automatically added by nvcc
#include <vector>
#include <iostream>
#include <numeric>
#include <ctime>
typedef double real_t;
const size_t BLOCK_SIZE = 1024;
//---------------------------------------------... |
19,920 | #include "includes.h"
__global__ void reluBackward(float* dZ, float* top_diff, float* V, int x, int y){
int index = blockDim.x * blockIdx.x + threadIdx.x;
if(index < x*y){
if(V[index] > 0) {
dZ[index] = top_diff[index];
}else{
dZ[index] = 0;
}
}
} |
19,921 | #include <iostream>
#include <thrust/binary_search.h>
#include <thrust/host_vector.h>
#include <thrust/execution_policy.h>
int main(void)
{
thrust::host_vector<int> input(5);
input[0] = 0;
input[1] = 2;
input[2] = 5;
input[3] = 7;
input[4] = 8;
std::cout << thrust::binary_search(thrust::h... |
19,922 | //使用constant memory存放向量
//global memory
#include<stdio.h>
#include<math.h>
#include<time.h>
#include <stdlib.h>
int Max=16384;
int width=32;
double err = 0.1;
__constant__ double con_b[8192];
__global__ void multi(double *A,double *C,const int Max,int i){
int idx=threadIdx.x+blockDim.x*blockIdx.x;
//int idy=thre... |
19,923 | #include <cuda_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#define _EPSILON 0.001
#define _ABS(x) ( x > 0.0f ? x : -x )
__host__ int allclose(float *A, float *B, int len)
{
int returnval = 0;
for (int i = 0; i < len; i++)
{
if ( _ABS(A[i] - B[i]) > _EPSILON )
{
returnval = -1;
break;
}
}
re... |
19,924 | #include <stdio.h>
#include <iostream>
#include <unistd.h>
#include <sys/time.h>
using namespace std;
// Shorthand for formatting and printing usage options to stderr
#define fpe(msg) fprintf(stderr, "\t%s\n", msg);
// Shorthand for handling CUDA errors.
#define HANDLE_ERROR(err) ( HandleError( err, __FILE__, __LIN... |
19,925 | #include "includes.h"
__global__ void add_reference_points_norm(float * array, int width, int pitch, int height, float * norm){
unsigned int tx = threadIdx.x;
unsigned int ty = threadIdx.y;
unsigned int xIndex = blockIdx.x * blockDim.x + tx;
unsigned int yIndex = blockIdx.y * blockDim.y + ty;
__shared__ float shared_ve... |
19,926 | #include "includes.h"
constexpr const int SECTION_SIZE = 2048;
constexpr const int MAX_SECTIONS = 1024;
__device__ void brent_kung_scan_(float *X, float *Y, int InputSize) {
const int bx = blockIdx.x;
const int tx = threadIdx.x;
const int bdx = blockDim.x;
__shared__ float XY[SECTION_SIZE];
int i = 2 * bx * bdx + t... |
19,927 | #include <ctime>
#include <stdio.h>
__global__ void print_3d(int *vector) {
int threads_per_block = blockDim.x * blockDim.y * blockDim.z;
int index = threadIdx.x + (threadIdx.y * (blockDim.z * blockDim.x)) +
(threadIdx.z * blockDim.z) + (blockIdx.x * threads_per_block) +
(blockIdx.z *... |
19,928 | #include<stdio.h>
#define CHECK_FOR_CORRECTNESS 1
#define MIN(a,b) (( (a) < (b) )?(a):(b))
#define GE 1
#define GI 2
/* Following section contains Kernel functions used by prefix sum */
/* Kernel Function1 - Initialize the array */
__global__ void initializeArray(int* A, int* B, int N)
{
int i = threadIdx.x;
if(i<N)... |
19,929 |
// https://www.nvidia.com/docs/IO/116711/sc11-cuda-c-basics.pdf
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <iostream>
#include <iterator>
#include <algorithm>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
cudaError_t addWithCuda(int *c, int *a, int *b, unsigned int size);
... |
19,930 | #include <stdio.h>
#define SIZE 1024
__global__ void VectorAdd(int *a, int *b, int *c, int n) // __global__ Լ GPU ˷
{
int i = threadIdx.x; // read only variable
if (i < n)
c[i] = a[i] * b[i];
//int i; // for ۼϸ ̷ ȴ.
//for (i = 0; i < n; ++i)
// c[i] = a[i] + b[i];
}
int main()
{
int *a, *b, *c;
cuda... |
19,931 | #include <cuda.h>
#include <stdio.h>
#include <string.h>
char* concat(const char *s1, const char *s2)
{
char *result = (char*)malloc(strlen(s1) + strlen(s2) + 1); // +1 for the null-terminator
// in real code you would check for errors in malloc here
strcpy(result, s1);
strcat(result, s2);
return r... |
19,932 | /*
* CPSC 4210
* - High Performance Parallel Computing
*
* Name: Austin Kothig
* ID: 001182645
* Sem: Spring 2018
*
* Purpose:
*
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <unistd.h>
#include <getopt.h>
#include <iostream>
/* Enable / Disable debugging */
#define debug 0
/* ... |
19,933 | #include "includes.h"
__global__ void HydroComputedUx_CUDA3_kernel(float *FluxD, float *FluxS1, float *FluxS2, float *FluxS3, float *FluxTau, float *dUD, float *dUS1, float *dUS2, float *dUS3, float *dUTau, float dtdx, int size)
{
// get thread and block index
const long tx = threadIdx.x;
const long bx = blockIdx.x;
co... |
19,934 | // System includes
#include <stdio.h>
#include<time.h>
// CUDA runtime
#include <cuda_runtime.h>
#include<device_launch_parameters.h>
#include<curand.h>
__global__ void addTen(float* d, int count)
{
int threadsPerBlock = blockDim.x * blockDim.y * blockDim.z;
int threadPosInBlock = threadIdx.x +
blockDim.x * threa... |
19,935 | typedef struct{
int* indices;
float* points;
int* neighbor;
float* k_simplices;
} alpha_complex;
__device__ float calc_sigma(int* indices, float* points)
//circle radius of triangle
{
float d[3];
float s = 0;
for (int i = 0; i<3; i++){
float p1 = points[indices[i]*2] - points[indice... |
19,936 | /*
* mat_prod.cu
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define FALSE 0
#define TRUE 1
#define TxB 4
#define N 4
#define M 4
typedef unsigned char uChar;
const uChar SBOX[256] = {
0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, ... |
19,937 | #include <stdlib.h>
#include <stdio.h>
__global__ void cudaadd(float* cA, float* cB, float* cC);
const int N = 32;
int main()
{
int deviceN = 0; //Number of CUDA-enabled GPUs (graphics cards)
cudaGetDeviceCount(&deviceN);
if (deviceN == 0) {printf("Error! No cuda-enabled devices found!"); return 1;}
cudaSetDevic... |
19,938 | /*----------------------------------------------------------------------------------*
* Copyright (c) 2010-2018 Pauli Parkkinen, Eelis Solala, Wen-Hua Xu, *
* Sergio Losilla, Elias Toivanen, Jonas Juselius *
* ... |
19,939 | #include <stdio.h>
#include <cuda.h>
__global__ void TwoDimHeatEq(float *d_A, float *d_B, double s)
{
// 2-dimensional block, 2-dimensional grid
int blockId = blockIdx.y * gridDim.x + blockIdx.x;
int threadId = (blockId * (blockDim.x * blockDim.y) +
(threadIdx.y * blockDim.x) + threadIdx.x);
int threadAbo... |
19,940 | #include "includes.h"
__global__ void kernel_3(float *d_data_in, float *d_data_out, int data_size)
{
__shared__ float s_data[BLKSIZE];
int tid = threadIdx.x;
int index = tid + blockIdx.x*blockDim.x;
s_data[tid] = 0.0;
if (index < data_size){
s_data[tid] = d_data_in[index];
}
__syncthreads();
for (int s = blockDim.x/2;... |
19,941 | #include "includes.h"
__global__ void pnpoly_cnGPU(const float *px, const float *py, const float *vx, const float *vy, char* cs, int npoint, int nvert)
{
__shared__ float tvx[607];
__shared__ float tvy[607];
int i = blockIdx.x*blockDim.x + threadIdx.x;
if (i < npoint) {
int j, k, c = 0;
for (j = 0, k = nvert-1; j < nv... |
19,942 | #include<cuda.h>
#include<stdio.h>
#include<math.h>
#include<cuda_runtime.h>
#include<stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cuda_runtime.h>
#include <sys/time.h>
__global__ void find_prime(int N,int* a,float* b,int* c)
{
//*p_size = s+1;
//__shared__ cuda_count = 1;
//__share... |
19,943 | /**
* @file compare.cu
* @brief element wise product
* @author HIKARU KONDO
* @date 2021/08/24
*/
#include "element_wise_operator.cuh"
#define BLOCKDIM 256
template<typename T>
__global__ void element_wise_product(T *arrayA, T *arrayB, T *resArray, int size) {
unsigned int idx = threadIdx.x + blockIdx.x * b... |
19,944 | #include "includes.h"
__global__ void shift0(float* in, float* out, int inDim0, int inStride0, int inStride1, int inScalarCount) {
int tid = blockIdx.x * blockDim.x + threadIdx.x;
int stride = gridDim.x * blockDim.x;
for (; tid < inScalarCount; tid += stride) {
int linearIndex = tid;
int inIndex0 = linearIndex / inStri... |
19,945 | #include "includes.h"
__global__ void dotCudaHeapSharedMemory(const float* a, const float* b, float* dest, const size_t length) {
} |
19,946 | /*
The purpose of this program is to compare the performance of calculating
the square root element-wise on an array. The 3 types of executions compared
will be CPU, GPU with only blocks and GPU with only threads.
The size of array <N> is taken as a parameter when the program is executed.
*/
#include <math.h>
#includ... |
19,947 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <time.h>
void printDevProp(cudaDeviceProp devProp) {
printf("%s\n", devProp.name);
printf("Major revision number: %d\n", devProp.major);
printf("Minor revision number: %d\n", devProp.minor);
printf("Total global memory: ... |
19,948 | #include "includes.h"
__global__ void prescan(float* d_in, int nGlobe, int step, int upSweep) {
int tid = blockDim.x * blockIdx.x + threadIdx.x;
int from = 2 * tid * (step + 1) + step;
int to = 2 * tid * (step + 1) + 2 * step + 1;
if (upSweep) {
d_in[to] += d_in[from];
} else {
int temp = d_in[to];
d_in[to] += d_in[fro... |
19,949 | #include "includes.h"
__global__ void TopForcing(double ppt, double *eff_rain, int size) {
int tid = threadIdx.x + blockIdx.x * blockDim.x;
while (tid < size) {
eff_rain[tid] = ppt;
tid += blockDim.x * gridDim.x;
}
} |
19,950 | #include <cstdio>
#include <iostream>
#include <cuda.h>
#include <cuda_runtime.h>
__global__ void scanHillisSteele(int *d_out, int *d_in, int n)
{
int idx = threadIdx.x;
extern __shared__ int tmp[];
int pout = 0, pin = 1;
tmp[idx] = (idx > 0) ? d_in[idx-1] : 0;
__syncthreads();
for (int offset = 1; off... |
19,951 | #include <cuda.h>
#include <iostream>
#define uint unsigned int
#define uchar unsigned char
#define ushort unsigned short
#define int64_t long long
#define uint64_t unsigned long long
extern "C" __global__ void conv3(float* __restrict__ data,
float* __restrict__ kernel,
float* __restrict__ compute) {
floa... |
19,952 | #include "includes.h"
__device__ void warp_reduce(float* S,int tx){
S[tx] += S[tx + 32]; __syncthreads();
S[tx] += S[tx + 16]; __syncthreads();
S[tx] += S[tx + 8]; __syncthreads();
S[tx] += S[tx + 4]; __syncthreads();
S[tx] += S[tx + 2]; __syncthreads();
S[tx] += S[tx + 1]; __syncthreads();
}
__global__ void reduce... |
19,953 | #include "includes.h"
__global__ void clock_block(clock_t *d, clock_t clock_count) {
clock_t start_clock = clock64();
clock_t clock_offset = 0;
while (clock_offset < clock_count) {
clock_offset = clock64() - start_clock;
}
if (d) {
*d = clock_offset;
}
} |
19,954 | /*__global__ void getPointEvals(float* unknowns, float* mPoints, float* outs)
{
int mpidx = i * 3;
int cidx = i * 4;
Vector3f vk((*mPoints)[mpidx], (*mPoints)[mpidx + 1], (*mPoints)[mpidx + 2]);
float alpha = (*unknowns)(cidx);
Vector3f beta((*unknowns)(cidx + 1), (*unknowns)(cidx + 2), (*unknowns)(... |
19,955 | #include <stdlib.h>
#include <stdint.h>
//#include "cuda_utils.h"
#define ALPHABET_SIZE 128
#define MAX_THREADS_PER_BLOCK 1024
#define min(a,b) (((a) < (b)) ? (a) : (b))
__global__ void init_precompute( uint8_t* precompute, uint8_t* pixel_row, int* prop )
{
// pack BLOCK_CHUNK, image_size, current_row_num and MAX... |
19,956 | /*
* Parallel Processing Teaching Toolkit
* CUDA - Example 03
* Vector Multiplication
* https://github.com/javierip/parallel-processing-teaching-toolkit
*/
#include <stdio.h>
// For the CUDA runtime routines (prefixed with "cuda_")
#include <cuda_runtime.h>
#include <time.h>
/**
* CUDA Kernel Device code
* Compu... |
19,957 | #include "includes.h"
__global__ void gpu_floyd_kernel(int k, int* adjacency_mtx, int* paths, int size)
{
int col = blockIdx.x * blockDim.x + threadIdx.x;
if (col >= size)return;
int idx = size * blockIdx.y + col;
__shared__ int best;
if (threadIdx.x == 0)
best = adjacency_mtx[size * blockIdx.y + k];
__syncthreads();
... |
19,958 | #include <cuda_runtime.h>
#include <vector>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
typedef float real_t;
static const int TILE_DIM = 21; //initialized in main
__global__ void transpose( real_t *odata, real_t *idata, int width, int height) {
int xIndex = blockIdx.x * blockDim.x ... |
19,959 | #include<stdio.h>
__global__ void print_kernel(){
printf("Block numarasi %d\t is parcacigi numarasi %d\n",blockIdx.x,threadIdx.x);
}
int main(){
print_kernel<<<5,3>>>();
cudaDeviceSynchronize();
}
|
19,960 |
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
int main() {
int n;
int i, j, k;
printf("Please enter the size of matrix: \n");
scanf("%d", &n);
int *a, *b, *c;
cudaMallocHost((void**)&a, sizeof(int) * n * n);
cudaMallocHost((void**)&b, sizeof(int) * n * n);
cudaMallocHost((void**)... |
19,961 |
/************************************************************************
Source Code : warpDivergence.cu
Objective : To demonstrate the difference in bandwidth achieved when
threads within a warp follow different execution paths ... |
19,962 | /**
* @file : params_kernelf_og.cu
* @brief : Original implementation from njuffa, verbotim;
* CUDA kernel functions as parameters with CUDA C++14, CUDA Unified Memory Management
* @details : Original implementation from njuffa, verbotim
* std::function vs. function pointer in C++11, C++14, and now in... |
19,963 | /*
xor_train.cu
Implementation of a XOR neural network in CUDA, including
network training using backpropagation.
Andrei de A. Formiga, 2012-03-31
*/
#include <stdio.h>
#include <stdlib.h>
#include <curand.h>
// constant for the RNG seed
#define SEED 419217ULL
//#define SEED 419229ULL
//... |
19,964 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cuda.h>
#include <cuda_runtime.h>
#define CHECK(call) { const cudaError_t error = call; if (error != cudaSuccess) { printf("Error: %s:%d, ", __FILE__, __LINE__); printf("code:%d, reason: %s\n", error, cudaGetErrorString(error)); exit(1); }}
__glob... |
19,965 | #define LENGTH_V 1024*1024
#define LENGTH_SHOW 10
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/generate.h>
#include <thrust/scan.h>
#include <thrust/copy.h>
#include <algorithm>
#include <cstdlib>
#include <time.h>
void show_vector(char *myString, int lengthMyString, thrust::host... |
19,966 | #include <fstream>
#include <iostream>
using namespace std;
#define Mask_width 3
#define Mask_radius Mask_width/2
#define TILE_WIDTH 32
#define w (TILE_WIDTH + Mask_width - 1)
#define clamp(x) (min(max((x), 0), 255))
__global__
void convolution(double *I, const int* __restrict__ M, double *P, int channels, int width... |
19,967 | #include <cuda.h>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <chrono>
using namespace std;
/*B*/
__global__
void MatrixAddB(float* A, float* B, float* C, int n) {
int i = threadIdx.x + (blockIdx.x * blockDim.x);
if (i < n*n) {
C[i] = A[i] + B[i];
}
}
/*C=>Row*/
__global__
void MatrixAddC(fl... |
19,968 | #include "includes.h"
__global__ void reduce(float *g_idata, float *g_odata){
extern __shared__ float sdata[];
//each thread loads one element from global to shared mem
unsigned int tid = threadIdx.x;
unsigned int i = blockIdx.x * blockDim.x + threadIdx.x;
sdata[tid] = g_idata[i];
__syncthreads();
// do reduction in ... |
19,969 | /* Copyright 2017 Eric Aubanel
* This file contains code implementing Algorithm 4.14 from
* Elements of Parallel Computing, by Eric Aubanel, 2016, CRC Press.
*
* 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 S... |
19,970 | #include "includes.h"
__global__ void add_bias(float *a, float *bias, float *out, int size_x, int size_y, int size_z)
{
const int i = blockDim.y * blockIdx.y + threadIdx.y,
j = blockDim.x * blockIdx.x + threadIdx.x;
if (i < size_x && j < size_y)
{
int k = (i * size_y + j) * size_z;
for (int c = 0; c < size_z; c++)
ou... |
19,971 | #include "includes.h"
__global__ void CopyPointsCoordinatesKernel( float *pointsCoordinates, int *activityFlag, float xNonValid, float yNonValid, float zNonValid, float *dataVertex, int dataVertexOffset, int maxCells )
{
int threadId = blockDim.x*blockIdx.y*gridDim.x //rows preceeding current row in grid
+ blockDim.x... |
19,972 | #include "add_ghost_cells.cuh"
__global__ void add_ghost_cells
(
BoundaryConditions bcs,
SimulationParameters sim_params,
AssembledSolution d_assem_sol
)
{
int x = blockIdx.x * blockDim.x + threadIdx.x;
if (x == 0)
{
d_assem_sol.q_BC[x] = bcs.q_imposed_up > 0 ? bcs.q_imposed_up : d_assem_sol.q_BC[x + 1];... |
19,973 | #include <fstream>
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/generate.h>
#include <thrust/sort.h>
#include <thrust/copy.h>
#include <thrust/binary_search.h>
#include <thrust/pair.h>
#define GPU_MEM 100... |
19,974 | #include <cstdlib>
#include <ctime>
#include <climits>
#include <algorithm>
#include <functional>
#include <iostream>
using namespace std;
/*========* CudaArray *========*/
template<typename T>
class CudaArray {
public:
CudaArray(int size) :
size_ { size } {
host_data = (T*) malloc(sizeof(T) * size);
cudaMal... |
19,975 | #include<stdio.h>
#include<stdlib.h>
#include<cuda.h>
#include<iostream>
#include <sys/time.h>
#include<bits/stdc++.h>
using namespace std;
struct edgepairs{
int x;
int y;
};
bool compareTwoEdgePairs(edgepairs a, edgepairs b)
{
if (a.x != b.x)
return a.x < b.x;
if (a.y != b.y)
return a.... |
19,976 | //
// CasAES128_CUDA.c
// CasAES128_CUDA
// Created by Carter McCardwell on 11/11/14.
//
#include <stdint.h>
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <cuda_runtime.h>
const int Nb_h = 4;
const int Nr_h = 10;
const int Nk_h = 4;
const uint8_t s_h[256]=
{
0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x... |
19,977 | #include "includes.h"
__global__ void calcularBloques(int *matriz, int *u, int *resultado, int num_bloques, int nc, int m ){
int index1 = threadIdx.x + blockIdx.x*blockDim.x; // 0 - 1
int index2 = threadIdx.y + blockIdx.y*blockDim.y; // 0 - 1
int suma = 0;
for(int i=0 ; i < num_bloques ; i++){
suma = 0;
for(int l=0 ; ... |
19,978 | #define TILE_DIM 32
template<typename T>
__device__ void matrixDotVector(const T* matrix, const T* vector, T* result,
const int matrixRows, const int matrixColumns) {
__shared__ T matrix_tile[TILE_DIM][TILE_DIM];
__shared__ T vector_tile[TILE_DIM];
int bx = blockIdx.x;
int tx ... |
19,979 | /*
============================================================================
Name : sem1.cu
Author : maminov
Version :
Copyright : copyleft
Description : CUDA compute reciprocals
============================================================================
*/
#include <cuda_runtime.h>
#include <dev... |
19,980 | #include<cuda.h>
#include<stdio.h>
#include<math.h>
#include<ctime>
__global__
void vecMulMatrixKernel(float* A, float* B, float* C, int n){
// clock_t start = clock();
int column = threadIdx.x + blockDim.x * blockIdx.x;
int row = threadIdx.y + blockDim.y * blockIdx.y;
//printf("%d ",blockDim.x);
if(row<n && colum... |
19,981 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define MINVAL 1e-7
#define CSC(call) { \
cudaError err = call; \
if(err!=cudaSuccess) ... |
19,982 | #include<cstdio>
using namespace std;
__global__ void add(const int *a, const int *b, int *c)
{
int i = threadIdx.x;
c[i] = a[i] * *b;
}
int main(void)
{
int count = 100;
int size = sizeof(int) * count;
int *cpu_a = (int *)malloc(size); int *gpu_a; cudaMalloc((void**)&gpu_a, size);
int cpu_b = 5; int *gp... |
19,983 | #include "includes.h"
__global__ void sam_kernel(float *in_w_h_c, int size, int channel_size, float *scales_c, float *out)
{
const int index = blockIdx.x*blockDim.x + threadIdx.x;
if (index < size) {
out[index] = in_w_h_c[index] * scales_c[index];
}
} |
19,984 | //nvcc linspace.cu -o linspace -lglut -lGL -lm; ./'linspace'
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
void linspace(float* vec, float start, float stop, int num, int useEndpoint)
{
/* Create 'num' evenly spaced samples, calculated over the interval ['start', 'stop'].
* The endpoint of the interval can... |
19,985 | #include "includes.h"
__global__ void smoothing(float* input, float* output, double alpha, double beta, int length) {
int i = threadIdx.x + blockDim.x*blockIdx.x;
int j = i<<1;
if (j < length) {
output[j] = (float) (input[j] * (1.0 + alpha) - output[j] * alpha);
output[j+1] = (float) (input[j+1] * (1.0 + beta) - output... |
19,986 | __global__ void gpu_Actualizar(float *layer, int posicion, float energia,int layer_size) {
float umbral = 0.001;
int gid = (blockIdx.x + gridDim.x * blockIdx.y) * (blockDim.x * blockDim.y) + (threadIdx.x + blockDim.x * threadIdx.y);
if(gid < layer_size){
int distancia = posicion - gid;
if ( distancia < 0 ) dis... |
19,987 | __device__ float a, b, c;
__global__ void doit1(int start, int end) {
float k;
if (start == 4) {
k = a * b + 2;
} else if (start == 5) {
k = a* b + 3;
} else {
k = a * b + 4;
}
c = k;
}
__global__ void doit2(int start, int end) {
float k;
for (int i = start; i < end; i++) {
if (i == ... |
19,988 | #include<stdio.h>
#define START 32 //first char to make hist ascii code
#define STOP 127 //last char to make hist ascii code
int main(int argc, char** argv){
if(argc <= 2){
fprintf(stderr, "Arguments non valide");
return 1;
}
FILE *f_input;
FILE *f_output;
lon... |
19,989 | #include <stdint.h>
#include <stdio.h>
#define N 34
#define THREADS_PER_BLOCK 32
__global__ void dotproduct(float* x, float* y, float* result) {
// Compute the index this thread should use to access elements
size_t index = threadIdx.x + blockIdx.x * THREADS_PER_BLOCK;
if(index < N) {
// Create space for... |
19,990 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <assert.h>
#define SEED
#define BLOCK_SIZE 16
typedef struct _data {
char * values;
char * next_values;
int width;
int height;
} data;
void input_error() {
fprintf(stderr, "Erro na leitura dos parâmetros");
exit(EXIT_FAILUR... |
19,991 | struct MscData {
float a;
float b;
};
struct UrbanMsc {
const MscData& data;
__device__ decltype(auto) make_calc_thing() const {
return [this](float step) { return this->data.a * step + this->data.b; };
}
};
template <class F>
__device__ void apply_track(F calc_thing, float step, float* result) {
*re... |
19,992 | #include<iostream>
using namespace std;
__global__ void mykernel(void){
}
int main(void){
mykernel<<<1, 1>>>();
cout << "Hello World!\n" << endl;
return 0;
}
|
19,993 |
/*
* compiles on elephanttest using
* nvcc --compiler-options '-fPIC' -o libfpoly.so --shared matrix.cu
*/
#include <cuda_runtime.h>
#define aref(mat, row, col, n) (mat[(col)*(n) + (row)])
/* do the echelon operation */
__device__ int ffge(int *mat, int *vec, int n);
/* launch the threads on the GPU */
__globa... |
19,994 | #include "includes.h"
__global__ void calcSoftmaxBackwardGPU( float *dz_next_layer, float *dz_in, float *dz, unsigned int n )
{
int index = (blockIdx.x + blockIdx.y*gridDim.x) * blockDim.x + threadIdx.x;
// unsigned int index = threadIdx.x + blockIdx.x * blockDim.x;
if ( index < n ){
dz_in[index] += dz_next_layer[inde... |
19,995 | #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);
__global__ void prodottoArrayCompPerCompGPU(int*, int*, int*, int );
int main(int argn, char * argv[]) {
//numero di blocch... |
19,996 | #include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <float.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <sys/time.h>
#include <vector>
#include <chrono>
// #include "Matchcommon.h"
#define Radius 1
// #define NPixel 8
#define Deltat 0.00001
// int NBlocks;
// int Blocks;
// int b... |
19,997 | #include <stdio.h>
#include <stdlib.h>
__global__ void SyncKernel(int iters)
{
int i;
for (i = 0; i < iters; i++) {
__syncthreads();
}
}
void usage(char *program)
{
fprintf(stderr, "usage: %s nblocks nthreads iters\n", program);
fprintf(stderr, "... |
19,998 |
/* This is a automatically generated test. Do not modify */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
__global__
void compute(float comp, float var_1,float var_2,int var_3,float var_4,float var_5,float var_6,float var_7,float var_8,float var_9,float var_10,float var_11,float var_12,float var_13,float ... |
19,999 | template <int N>
__device__ int get_value(){
return N;
}
__global__ void foo_device(int * n){
int i = threadIdx.x;
n[i] = get_value<7>()*i;
//n[i] = 7*i;
} |
20,000 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <vector>
#define real double
#define number float
#define NP 400
#define Q 1.29
#define me 0.511
#define eta 0.0
#define Mk 2.14 // Kamiokande detector mass (kton).
#define Mimb 6.8 // IMB detector mass (kton).
#d... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.