serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
19,701
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> // Row size const int N = 3; // Column Size const int M = 4; const int SIZE = M * N; __global__ void matrixAdd(int *c, const int *a, const int *b, int cols, int rows) { int row...
19,702
/* 3D IoU Calculation and Rotated NMS(modified from 2D NMS written by others) Written by Shaoshuai Shi All Rights Reserved 2018. */ #include <stdio.h> #define THREADS_PER_BLOCK 16 #define DIVUP(m, n) ((m) / (n) + ((m) % (n) > 0)) #define DEBUG const int THREADS_PER_BLOCK_NMS = sizeof(unsigned long long) * 8; const...
19,703
#include "includes.h" __device__ float gamma_correction(float f_stop, float gamma, float val) { return powf((val*powf(2,f_stop)),(1.0/gamma)); } __global__ void tonemap_gamma(float* imageIn, float* imageOut, int width, int height, int channels, int depth, float f_stop, float gamma) { int Row = blockDim.y * blockIdx.y +...
19,704
/* For DIRECTED GRAPH */ #include <cuda.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX_NODE 100000000 #define DEBUG 0 #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true) { if (code != ...
19,705
#include "graph.hh" #include "node.hh" #include <algorithm> #include <cassert> #include <map> #include <set> #include <string> #include <iostream> namespace rt { Graph::~Graph() { for (auto n : nodes_) delete n; } void Graph::add(Node* node) { assert(node); no...
19,706
#include<stdlib.h> #include<stdio.h> #include<iostream> #include<string> #include<math.h> #include<fstream> #include<sstream> #include<cuda.h> #include<time.h> #define SIZE 82000 using namespace std; size_t threadsPerBlock; size_t numberOfBlocks; int deviceId; enum color { white, black, grew }; type...
19,707
#include <iostream> #include <getopt.h> #define no_argument 0 #define required_argument 1 #define optional_argument 2 int main(int argc, char * argv[]) { std::cout << "Hello" << std::endl; const struct option long_opts[] = { {"version", no_argument, 0, 'v'}, {"help", no_argument, ...
19,708
#include <stdio.h> #include <algorithm> #include <cmath> __global__ void mish(int n, float* tx, float* aten_mul) { for (int i = (threadIdx.x + blockDim.x * blockIdx.x) * 4; i < n; i += gridDim.x * blockDim.x * 4) { float4 tx4 = __ldg(reinterpret_cast<float4*>(tx + i)); tx4.x = tx4.x * tanh(log1p(exp(tx4.x))...
19,709
#include <iostream> #include <string> #include <vector> #include <fstream> #include <sstream> #include <cuda.h> #define THREAD_COUNT 1024 // Max device memory : 4 GB #define MAX_MEMORY ((long long)4e9) void read_graph(std::string fname, int *&row_ptr, int *&col_ind, int &num_nodes, int &num_edges, bool zero_based = ...
19,710
#include "includes.h" __global__ void RemoveEdgesKernel( int *connection, int *age, int maxAge, int *activityFlag, float *winningFraction, int *winningCount, float *utility, float *localError, int *neuronAge, int maxCells ) { int threadId = blockDim.x*blockIdx.y*gridDim.x //rows preceeding current row in grid + block...
19,711
# include <bits/stdc++.h> # include <cuda.h> #define SIZE 60000000// Global Size #define BLOCK_SIZE 1024 using namespace std; //::::::::::::::::::::::::::::::::::::::::::GPU:::::::::::::::::::::::::::::::: // :::: Kernel __global__ void KernelNormalVec(double *g_idata,double *g_odata,int l){ // Sequential Addressin...
19,712
/* To compile: nvcc --arch=sm_60 -O3 -o mandelbrot mandelbrot.c -lm To create an image with 4096 x 4096 pixels ./mandelbrot 4096 4096 */ #include <math.h> #include <stdio.h> #include <stdlib.h> #include <time.h> int writeMandelbrot(const char *fileName, int width, int height, float *img, int minI, int ...
19,713
#include "includes.h" __device__ void convolution(int conv_col, int conv_row, float *d_kernel, int k_size, float *d_matrix, int size_x, int size_y, float *d_conv, int max_row, int max_col){ int conv_index = conv_col+ conv_row*max_col; d_conv[conv_index] = 0; for(int k_row = 0; k_row < k_size; k_row ++){ for(int k_col ...
19,714
/* * Connected Components in the GPU * Paper Source: An Optimized Union-Find Algorithm for Connected * Components Labeling Using GPUs * Adapted from: https://github.com/victormatheus/CCL-GPU * Modified by: Imanol Luengo <imaluengo@gmail.com> */ typedef unsigned int uint32; #define MAX_UINT32 0xFFF...
19,715
#include <iostream> #include <cstdio> #include <cstdlib> // #include <helper_cuda.h> // #include <helper_string.h> /* Run with only HOST code *\ // Say goodbye to the universe int main(void) { printf("Heat death boogaloo!\n"); return 0; } */ /* Run with DEVICEEEEEEE code */ __global__ void mykernel(void) { } ...
19,716
/* Program to add 2 matrics of size M * N in CUDA C++ Using grid of one block Block contains M*N threads arranged in M rows and N columns */ #include<iostream> #include "cuda.h" #include "cuda_runtime.h" #define M 2 #define N 9 __global__ void matAdd(int* a, int* b, int* c) { int idx = threadIdx.x * blockDim.y + t...
19,717
#include <thrust/device_vector.h> #include <thrust/host_vector.h> #include <thrust/sequence.h> #include <thrust/transform.h> #include <math.h> #include <stdio.h> #define N 64 using namespace thrust::placeholders; // Define transformation SqrtOf()(x) -> sqrt(x) struct SqrtOf { __host__ __device__ float operato...
19,718
#include <stdio.h> __global__ void cuda_hello_world() { printf("Hello World from GPU! [ThreadID = %d, BlockID = %d]\n", threadIdx.x, blockIdx.x); } int main() { cuda_hello_world<<<1, 256>>>(); cudaDeviceSynchronize(); return 0; }
19,719
#include "includes.h" __global__ void naive_backward_cross_entropy(float *in, int *one_hot_classes, float batches, int size, float *out) { int bid = blockIdx.x * blockDim.x + threadIdx.x; if (!(bid < size)) return; out[bid] = (in[bid] - one_hot_classes[bid]) / batches; }
19,720
#include "includes.h" /* Program Parameters */ #define MAXN 8000 /* Max value of N */ int N; /* Matrix size */ // Thread block size #define BLOCK_SIZE 16 /* Matrices */ float A[MAXN][MAXN], B[MAXN][MAXN]; /* junk */ #define randm() 4|2[uid]&3 /* Prototype */ /* ------------------ Cuda Code --------------------- ...
19,721
//Alfred Shaker //10/23/2015 //Homework 2 #include <stdio.h> //function to get and print device properties void printDeviceProperties(cudaDeviceProp devProp) { //get the cuda driver version int driverVersion = 0; cudaDriverGetVersion(&driverVersion); printf("Version Number: %d\n",driverVersion/1000 ); //get the...
19,722
#include <stdlib.h> #include <stdio.h> #include <vector> #include <numeric> #include <iostream> #include<chrono> // Here you can set the device ID that was assigned to you #define MYDEVICE 0 constexpr bool DEBUG = false; constexpr size_t BLOCK_SIZE = 512; constexpr size_t SHARE_BLOCK_SIZE = 2*512; double random_dou...
19,723
#include <iostream> __global__ void vectorAdd(int *a, int *b, int *c, int n){ int i = blockIdx.x*blockDim.x+threadIdx.x; if(i<n) for(int j=0;j<100;j++) c[i] = a[i] + b[i]; } int main(void){ int * a, * b, * c; int * d_a, * d_b, * d_c; int * temp; int n = 1<<24; a = new int[n*sizeof(int)]; b = new int[n*s...
19,724
#include <iostream> using namespace std; #include <thrust/reduce.h> #include <thrust/sequence.h> #include <thrust/host_vector.h> #include <thrust/device_vector.h> __global__ void fillKernel(int *a, int n) { int tid = blockIdx.x * blockDim.x + threadIdx.x; if (tid < n) a[tid] = tid; } void fill(int *d_a, int n) {...
19,725
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <math.h> #include <complex.h> #include <cuda_runtime.h> #include <utility> #include <sys/time.h> #define K 3 #define BLCH 8 #define BLCW 32 __constant__ float filter[K*K]; int compute_tiled_naive(float *img, float *f, float * out, int bh, int bw, in...
19,726
// 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...
19,727
/* * The MIT License (MIT) * This file is part of waifu2x-converter-cpp * * 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 us...
19,728
/* * 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 related...
19,729
#define LOG_2_PI 1.83787706640935f #define LOG_PI 1.144729885849400f __device__ int d_next_multiple(int k, int mult) { if (k % mult) return k + (mult - k % mult); else return k; } __device__ void copy_chunks(float* in_buf, float* out_buf, unsigned int tid, unsigned int total) ...
19,730
// ---------------------------------------------------------------------------- // CUDA code to compute minimun distance between n points // #include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> #include<limits> #include<float.h> #define MAX_POINTS 1048576 #define block_size 1024 // -------------...
19,731
#include<stdio.h> extern "C" void GPUDeviceInfo(const int gpu_device) { int deviceCount; cudaGetDeviceCount(&deviceCount); int device; if (deviceCount>0) { printf("#########\n"); for (device = 0; device < deviceCount; ++device) { cudaDeviceProp deviceProp; cudaGetDevicePrope...
19,732
//#include "scale.h" #include <iostream> #include <fstream> #include <vector> #include <algorithm> #include <math.h> /* fabs */ #include <string.h> #include <stdlib.h> #include <sstream> #include <unordered_map> using namespace std; #define THREADS_PER_BLOCK 256 #define STREAM_COUNT 4 #define gpuErrchk(ans) { gpuAsser...
19,733
#include "includes.h" __global__ void Mask_Difference_Kernel( int* A, int* B, int* devOut) { const int idx = blockDim.x*blockIdx.x + threadIdx.x; if(A[idx] == B[idx]) devOut[idx] = 0; else devOut[idx] = 1; // Should test if the extra algebra ops are worth removing the if-statement // Convert to {-1, +1} //int aval =...
19,734
#include <iostream> #include <cuda.h> #include <cuda_runtime.h> #include <stdlib.h> #include <ctime> using namespace std; __global__ void AddInts(int * a, int* b, int count) { int id = blockIdx.x * blockDim.x * threadIdx.x; if (id < count) { a[id]+=b[id]; } } int main(int argc, char const *ar...
19,735
#include "cuda_runtime.h" //#include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> #include <math.h> // CUDA kernel __global__ void vecCompare(int *R, int *G, int *B, int *result, int n) //A is for the green array { int i = blockIdx.x * blockDim.x + threadIdx.x; if(i < n) { ...
19,736
#include <cstdio> #include <iostream> #include <vector> #include <cmath> #include <thrust/device_vector.h> #include <thrust/extrema.h> using namespace std; #define CSC(call) do { cudaError_t res = call; if (res != cudaSuccess) { fprintf(stderr, "CUDA Error in %s:%d: %s\n", __FILE__, __LINE__, cudaGetErrorString(re...
19,737
#include <stdio.h> #include <stdlib.h> #include <time.h> //CUDA RunTime API #include <cuda_runtime.h> #include <device_launch_parameters.h> #include "device_functions.h" #define THREAD_NUM 256 #define raw_row 512*680 #define raw_column 224 #define MATRIX_SIZE raw_row*raw_column const int blocks_num = 16; //// __...
19,738
/* * * Copyright 1993-2012 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 relat...
19,739
#include "includes.h" __global__ void MarkSplits(int size, bool force, int minPartSize, int maxPartSize, int* partSizes, int* splitsToMake) { int idx = blockIdx.x * blockDim.x + threadIdx.x; if (idx < size) { int currentSize = partSizes[idx]; bool shouldSplit = currentSize > maxPartSize && (force || currentSize > minPa...
19,740
#include <cuda.h> #include <iostream> #include <cstdlib> using namespace std; #define THREADSPERBLOCK 1024 // __global__ void mandel(char *d_vet, int MAX_N, int MAX_COL, int MAX_ROW) { __global__ void mandel(char *d_vet, int MAX_ROW, int MAX_COL, int MAX_NUM) { int i = blockIdx.x * blockDim.x + threadIdx.x; if (...
19,741
#include <stdio.h> __global__ void report(){ int i = blockIdx.x; int j = threadIdx.x; printf("My group id is %d, and my thread id is %d\n",i,j); } __global__ void report_in_detail(){ int ix = blockIdx.x; int iy = blockIdx.y; int iz = blockIdx.z; int jx = threadIdx.x; int jy = thread...
19,742
#include "includes.h" __global__ void gpu_transpose(const float* src, float* dst, int colssrc, int colsdst, int n) { int tid = threadIdx.x + blockIdx.x * blockDim.x; int stride = blockDim.x * gridDim.x; while (tid < n) { int cdst = tid % colsdst; int rdst = tid / colsdst; int rsrc = cdst; int csrc = rdst; dst[tid] = sr...
19,743
#include <cuda_runtime.h> int main() { int* a; cudaMalloc(&a, 100); cudaFree(a); return 0; }
19,744
#include "includes.h" __global__ void poli_warp(float* poli, const int N) { int idx = blockIdx.x * blockDim.x + threadIdx.x; float x; if (idx < N) { x = poli[idx]; poli[idx] = 5 + x * ( 7 - x * (9 + x * (5 + x * (5 + x))))- 1.0f/x + 3.0f/(x*x) + x/5.0f; } poli[idx] = x; }
19,745
__global__ void vecAdd(float * in1, float * in2, float * out, int len) { //@@ Insert code to implement vector addition here int i = blockDim.x*blockIdx.x+threadIdx.x; if( i < len ) out[i] = in1[i] + in2[i]; }
19,746
#include <thrust/device_vector.h> #include <thrust/sort.h> #include <thrust/functional.h> int main(void) { thrust::device_vector<int> data(8); data[0] = 6; data[1] = 3; data[2] = 7; data[3] = 5; data[4] = 9; data[5] = 0; data[6] = 8; data[7] = 1; thrust::sort(data.begin(), dat...
19,747
#include <stdio.h> #include <stdlib.h> #include <math.h> #define BLOCKSIZE 4 // Number of threads in each thread block // CUDA kernel. Each thread takes care of one element of a __global__ void diffKernel( float *in, float *out, int n ) { int i = blockIdx.x * blockDim.x + threadIdx.x; if(i < n - 1) out[i]...
19,748
#include <iostream> using namespace std; int main() { int ver; cudaDriverGetVersion(&ver); cout << "DRIVER VERSION: " << ver << "\n"; cudaRuntimeGetVersion (&ver); cout << "RUNTIME VERSION: " << ver << "\n"; cout << "\n"; size_t total_mem, free_mem; cudaMemGetInfo(&free_mem, &total_m...
19,749
#include <thrust/device_vector.h> #include <thrust/host_vector.h> #include <iostream> #include <chrono> #include <thrust/extrema.h> #include <thrust/execution_policy.h> #include <thrust/functional.h> int main() { double stocks; std::cin >> stocks; thrust::host_vector<double> host; for(int i =0; i < 25...
19,750
#define t_max 1 #define t 1 /* (u[0][0][0][1][0]=(a*((((u[-3][0][0][0][0]+(u[0][-3][0][0][0]+u[0][0][-3][0][0]))*-2.0)+(((u[-2][0][0][0][0]+(u[0][-2][0][0][0]+u[0][0][-2][0][0]))*15.0)+((u[-1][0][0][0][0]+(u[0][-1][0][0][0]+u[0][0][-1][0][0]))*-60.0)))+((u[0][0][0][0][0]*20.0)+(((u[1][0][0][0][0]+(u[0][1][0][0][0]+u[0...
19,751
#include "cuda_runtime.h" int main(){ }
19,752
#include <stdio.h> #define N 64 #define TPB 32 // A scaling function to convert integers 0,1,...,N-1 to evenly spaced floats __device__ float scale(int i, int n) { return ((float)i) / (n - 1); } // Compute the distance between 2 points on a line. __device__ float distance(float x1, float x2) { return sqrt((x...
19,753
#include "includes.h" __global__ void divideByCSCColSums(const float *values, const int *colPointers, float *pixels, const size_t n) { const size_t idx = blockIdx.x * blockDim.x + threadIdx.x; if (idx >= n) return; float weight = 0.0f; for (size_t ridx = colPointers[idx]; ridx < colPointers[idx+1]; ++ridx) { weight ...
19,754
#include "includes.h" __global__ void sobelEdgeDetectionSharedMem2(int *input, int *output, int width, int height, int thresh) { int regArr[4][4]; int i = (blockIdx.x * blockDim.x + threadIdx.x) * 2; int j = (blockIdx.y * blockDim.y + threadIdx.y) * 2; if ( i > 0 && j > 0 && i < width - 1 && j < height - 1) { regAr...
19,755
#include <stdio.h> #include <stdlib.h> #include <iostream> __global__ void add_vec(int *a,int *b, int offset,int N) { int i = offset + threadIdx.x + blockIdx.x*blockDim.x; if(i < N){ a[i] = a[i] + b[i]; } } template <typename T> void fill_arr(T *data,T val,int N){ for(int i=0;i<N;++i){ data[i] = val; } } ...
19,756
//#include <data_types/timeseries.hpp> //#include <data_types/fourierseries.hpp> //#include <data_types/candidates.hpp> //#include <data_types/filterbank.hpp> //#include <transforms/dedisperser.hpp> //#include <transforms/resampler.hpp> //#include <transforms/folder.hpp> //#include <transforms/ffter.hpp> //#include <tr...
19,757
#include<stdio.h> #include<stdlib.h> #include<cuda.h> #define N 3 #define BLOCK_DIM 3 __global__ void matrixAdd(int *a,int *b,int *c) { int col=blockIdx.x*blockDim.x+threadIdx.x; int row=blockIdx.y*blockDim.y+threadIdx.y; int index=col+row*N; printf("\n%d\t%d",threadIdx.x,threadIdx.y); printf("\nIndex val:%d\n",i...
19,758
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <inttypes.h> #include <math.h> #define gettime(t) clock_gettime(CLOCK_MONOTONIC_RAW, t) #define get_sub_seconde(t) (1e-9*(double)t.tv_nsec) /** return time in second */ __host__ double get_elapsedtime(void) { struct timespec st; int err = gettime(&s...
19,759
#include "includes.h" __global__ void differenceImg_gpu() { }
19,760
#include <stdio.h> __global__ void kernel0(void) { printf("kernel0\n"); } int main() { kernel0 <<<1,1>>> (); return 0; }
19,761
#include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include <math.h> #include <cuda.h> // function to integrate #define F(x) (x*x) #define CUDA_CALL(F) if( (F) != cudaSuccess ) \ {printf("Error %s at %s:%d\n", cudaGetErrorString(cudaGetLastError()), __FILE__,__LINE__); exit(-1);} const long blocks_per_gr...
19,762
#include <stdio.h> #include <cuda.h> __device__ int sumg = 0; __global__ void K(int num) { num += num; ++num; atomicAdd(&sumg, num); __shared__ int sum; sum = 0; __syncthreads(); sum += num; } int main() { for (unsigned ii = 0; ii < 100; ++ii) { K<<<5, 32>>>(ii); cudaDeviceSynchronize(); } return 0; }
19,763
#include <stdio.h> #include <stdlib.h> /** * =============== Comparação entre os tempos de execução: =============== * Sequencial: 1m18.116s * Paralelo: 0m25.027s * Paralelo (GPU - OpenMP): 0m15.604s * Paralelo (GPU - CUDA): 0m1.534s * * =============== Métricas relacionas as versões em GPU =============== ...
19,764
#include "includes.h" __global__ void exclusive_scan(unsigned int *in,unsigned int *out, int n) { unsigned int i = blockIdx.x * blockDim.x + threadIdx.x; if (i < n) { out[i] -= in[i]; } }
19,765
__global__ void mat_dot(float *a, float *b, float *c, int a_rows, int a_columns, int b_rows, int b_columns) { const int i = blockDim.y * blockIdx.y + threadIdx.y, j = blockDim.x * blockIdx.x + threadIdx.x; if (i < a_rows && j < b_columns) { float c_at_ij = 0; for (int ...
19,766
#include <stdio.h> #include <stdlib.h> #include <cuda_runtime_api.h> #define BASE_TYPE float __global__ void mult(const BASE_TYPE *a, const BASE_TYPE *b, BASE_TYPE *c, const int N, const int M) { int i = N * (blockDim.y * blockIdx.y + threadIdx.y); int j = blockDim.x * blockIdx.x + threadIdx.x; BASE_...
19,767
# include <stdlib.h> # include <cuda.h> #include<stdio.h> const int N = 1024; __global__ void f(long long int *dev_a) { unsigned int tid = threadIdx.x; long long int temp = dev_a[(tid+1)%N]; __syncthreads(); dev_a[tid] = temp; } int main(void) { long long int host_a[N]; long long in...
19,768
/* Daniel Parker * University of Reading * 215 Parallel algorithms for Bioinformatics * * random.cu - generate some random strings for testing */ #include <stdlib.h> #include <time.h> void generate(char string[], int len) { int i; for (i = 0; i < len; i++) { string[i] = 'a' + (rand() % 4 + 1); } }
19,769
// nnCount: B*M // nnDist: B*M*nnSample // Weight: B*M*nnSample __global__ void cal_weight(int B, int M, int nnSample, int weightType, float radius, const int* nnCount, const float* nnDist, float* Weight) { // get the neighbor indices for(int i=blockIdx.x;i<B;i+=gridDim.x) ...
19,770
#include "includes.h" __global__ void combineSourceAndBackground ( const int nwl, const int n, const float scale, float *src, const float *bkg ) { int i = threadIdx.x + blockDim.x * blockIdx.x; int j = threadIdx.y + blockDim.y * blockIdx.y; if ( i < n && j < nwl ) { src[i+j*n] = src[i+j*n] + scale * bkg[i+j*n]; } }
19,771
#include <cuda.h> #include <stdio.h> #include <time.h> #include <iostream> #include <fstream> #include <string> #include <vector> //#define BLOCK_WIDTH 512 __global__ void printMatrix(float **d_matrix, int size) { int i = (blockIdx.x * blockDim.x) + threadIdx.x; int j = (blockIdx.y * blockDim.y) + threadIdx.y...
19,772
#include <stdio.h> #include <stdlib.h> #define DEBUG __global__ void convol2D (float *a, float *h, float *c, int a_rows, int a_cols, int h_rows, int h_cols) { //Calculating indices along x and y directions int index_x = blockIdx.x * blockDim.x + threadIdx.x; int index_y = blockIdx.y * blockDim.y + threadI...
19,773
/* CPU Based Wallsolver nvcc wallsolverCPU.cu -o testCPU */ #include <stdio.h> #include <stdbool.h> #include <stdlib.h> #include <math.h> #include <sys/time.h> #define SPACE_LENGTH 5 // Spaces Size of rows / columns #define SPACE_WIDTH 5 #define NUM_SPACES 25 #define WALL_LENGTH 4 // Walls size of rows/...
19,774
#include "includes.h" #define DOUBLE #ifdef DOUBLE #define Complex cufftDoubleComplex #define Real double #define Transform CUFFT_Z2Z #define TransformExec cufftExecZ2Z #else #define Complex cufftComplex #define Real float #define Transform CUFFT_C2C #define TransformExec cufftExecC2C #endif #define TILE_DIM 8 /...
19,775
#ifdef _WIN32 # define EXPORT __declspec(dllexport) #else # define EXPORT #endif void __global__ file1_kernel(int x, int& r) { r = -x; } EXPORT int file1_launch_kernel(int x) { int r = 0; file1_kernel<<<1, 1>>>(x, r); return r; }
19,776
#include <cuda_runtime_api.h> #include <cuda.h> #include <stdio.h> #include <stdlib.h> #include <iostream> using namespace std; cudaStream_t createStreamWithFlags(){ cudaStream_t stream; cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking); return stream; }
19,777
#include<stdio.h> #include<stdlib.h> #include<math.h> #include "answer.cuh" // Compute vector sum C = A+B //CUDA kernel. Each thread performes one pair-wise addition __global__ void vector_add(float *a, float *b, float *c, int N) { /* insert code to calculate the index properly using blockIdx.x, blockDim.x, thre...
19,778
#include<stdio.h> #include<stdlib.h> #include<ctype.h> #include<math.h> #include<time.h> __global__ void euler_method(float *y, float *sum, float delta_t, int N) { int y0 = 4; int tId = threadIdx.x + blockIdx.x*blockDim.x; if(tId < N){ y[tId] = y0 + delta_t * sum[tId]; } } float edo_resuelta(float t); float ed...
19,779
/********************************************************************************** This code performs a calculation of pi using the monte carlo method using cuda GPU parallelisation. Created by: George Tall Email: george.tall@seh.ox.ac.uk /**********************************************...
19,780
#include <stdio.h> #include <vector> #include <algorithm> #include <functional> #include <cuda_runtime.h> #include <cstdlib> #include <string> #include <map> #include <vector> #include <math.h> #include <cuda.h> #include <float.h> #include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <thrust/trans...
19,781
#include <stdio.h> #include <iostream> #include <cuda.h> #include <vector> #include "demo.cuh" __global__ void add_kernel(float* A, float* B, float* C) { const unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x; C[idx] = A[idx] + B[idx]; //printf("%d\n", C[idx]); } int testCUDA() { int num = 100...
19,782
/* autor fredy m uaem desonses@gmail.com para mas comentarios */ #include <device_functions.h> #include <stdio.h> #include <stdlib.h> #include <vector_types.h> #include <cuda.h> #include <math.h> #include "cuda_runtime.h" #include "device_launch_parameters.h" #define N 33 /* realiza la transpuesta de una matriz */...
19,783
/* NiuTrans.Tensor - an open-source tensor library * Copyright (C) 2017, Natural Language Processing Lab, Northeastern University. * All rights reserved. * * 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 ...
19,784
#include <cuda.h> #include <assert.h> #include <stdio.h> template <int input_per_thread, int filter_per_thread, int input_per_block, int filter_per_block> __global__ static void _cwc_kern_convolutional_forward_propagate(const int strides, const int border, const int batch, float* input, const int rows, const int col...
19,785
__global__ void KNNSearch( float * result, const int * args, const float * pc1, const float * pc2) { int cudaNumBlocks = args[0]; int cudaNumThreads = args[1]; int pc1NumPts = args[2]; int pc2NumPts = args[3]; int pc2Idx = blockIdx.x * cudaNumThreads + threadIdx.x; float currPtX = pc2[pc2...
19,786
#include "includes.h" // Author: Jose F. Martinez Rivera // Course: ICOM4036 - 040 // Professor: Wilson Rivera Gallego // Assignment 2 - CUDA Implementation #define V 8 #define E 11 #define MAX_WEIGHT 1000000 #define TRUE 1 #define FALSE 0 typedef int boolean; // //Represents an edge or path between Vertice...
19,787
#include<stdio.h> #include<stdlib.h> #include<stdbool.h> #include<string.h> #include<cuda.h> #include<time.h> #include<cuda_runtime_api.h> #include<device_launch_parameters.h> #include <device_functions.h> #define MASK_WIDTH 3 //Here MASK_WIDTH = MASK_HEIGHT = 2*N + 1 where N is half-width of the chosen square mask...
19,788
/* This is a automatically generated test. Do not modify */ #include <stdio.h> #include <stdlib.h> #include <math.h> __global__ void compute(float comp, int var_1,int var_2,float var_3,float var_4,float var_5,float var_6,int var_7,float var_8,float var_9,float var_10,float var_11,float var_12,float* var_13,float var...
19,789
#include "includes.h" __global__ void matmul_double(double* A, double* B , double* C, int M, int N, int K) { int bx = blockIdx.x ; int by = blockIdx.y ; int tx = threadIdx.x ; int ty = threadIdx.y ; int row = by * TILE_WIDTH + ty ; int col = bx * TILE_WIDTH + tx ; __shared__ double SA[TILE_WIDTH][TILE_WIDTH+1] ;...
19,790
#include "includes.h" __global__ void matrixAddKernel(float* A, float* B, float* C, int n) { int Row = blockIdx.y * blockDim.y + threadIdx.y; int Col = blockIdx.x * blockDim.x + threadIdx.x; if((Row < n) && (Col < n)) C[Row * n + Col] = A[Row * n + Col] + B[Row * n + Col]; }
19,791
#include"stdio.h" #include<cuda_runtime.h> #include <sys/time.h> #define N 1024 // Kernel definition __global__ void VecAdd(float* A, float* B, float* C) { int i = threadIdx.x; for(int j=0;j<1000;j++) C[i] = (A[i] * B[i]); } long getCurrentTime() { struct timeval tv; gettimeofday(&tv,NULL); return ...
19,792
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> // 1 block of threads --> 8 values, grid = 1 __global__ void unique_idx_calc_threadIdx(int * input) { int tid = threadIdx.x; printf("threadIdx : %d, value : %d \n", tid, input[tid]); } // 4 blocks, each block - 4 threads. __g...
19,793
// // Created by hina on 2021-03-13. // #include "activation.cuh" __device__ float activation::func_relu(float input_num) { return input_num > 0 ? input_num : 0.0f; } __device__ float activation::deriv_relu(float input_num) { return input_num > 0 ? 1.0f : 0.0f; }
19,794
#include "includes.h" __global__ void bias_grad(float *pre_grad, float *output, int rows, int cols) { int i = blockIdx.x * blockDim.x + threadIdx.x; if (i >= rows) return; output[i] = 0; for (int k = 0; k < cols; k++) { output[i] += pre_grad[i * cols + k]; } }
19,795
#include <stdio.h> #include <stdlib.h> #include "cuda.h" #include <curand.h> #include <curand_kernel.h> #include <math.h> #include <time.h> #include <sys/time.h> #include <unistd.h> #define HASH_STEP 720 #define WARP_SIZE 32 #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } inline void gpuAssert(cudaE...
19,796
__host__ __device__ int get_raw(int idx, int K_k) { return idx / K_k; } __host__ __device__ int get_col(int idx, int K_k) { return idx % K_k; } __host__ __device__ void get_mul(double* res, double* a, double* b, int idx, int K_m, int K_n, int K_k ) { int m = get_raw(idx, K_k); int k = get_col(idx, K_k); for (in...
19,797
#include <stdio.h> #include <cuda.h> #define n 10 __global__ void add(int*a, int*max) { int i = blockIdx.x * blockDim.x + threadIdx.x; if(i < n) { for(i=0;i<n;i++) { if(a[i]>*max) *max=a[i]; } } } int main() { int a[n]; int i; int max; int* dev_a; int* dev_max; cud...
19,798
#include<bits/stdc++.h> int main (void) { printf("Hello World!\n"); return 0; }
19,799
#include "includes.h" __global__ void bcnn_op_cuda_tanh_grad_kernel(int n, float *x, float *dx) { int i = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x; if (i < n) { dx[i] *= (1 - x[i] * x[i]); } return; }
19,800
// Copyright (c) 2012-2017 VideoStitch SAS // Copyright (c) 2018 stitchEm #include <cstdio> int main() { int devices; cudaError_t err = cudaGetDeviceCount(&devices); if (err != cudaSuccess) { fprintf(stderr, "cudaGetDeviceCount failed: %s\n", cudaGetErrorString(err)); return 1; } if (devices == 0) ...