serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
3,201
#include <cuda_runtime.h> #include <iostream> #include <memory> #include <string> #include <cuda.h> #include <stdio.h> #ifndef BLOCK_SIZE # define BLOCK_SIZE 16 #endif #ifndef _M # define _M 10000 #endif #ifndef _N # define _N 10000 #endif #if !defined(CUDA) && !defined(CPU) && !defined(CHECK) # define CUDA #e...
3,202
extern "C" __global__ void applyKernels( float* kernels_hat, float* kernels_hat_sum_2, float* inimg, float* pos2zncc, float* pos2sigma, float* pos2vx, ...
3,203
// CUDA kernels for embedding shortest path metric into normed vector space // Calculate all pairs shortest path. // after Okuyama, Ino, and Hagihara 2008. __global__ void scatter (int nv, int *vertex, int *edge, int *weight, int *cost, int *modify) { // Note: the kernel does not need to know the origin vertices -...
3,204
extern "C" __global__ void saxpy(float* Z, float A, float* X, float* Y, size_t blockOff_x) { size_t id = (blockOff_x + blockIdx.x) * blockDim.x + threadIdx.x; Z[id] = A * X[id] + Y[id]; }
3,205
#include <stdio.h> #include <stdlib.h> #include <cuda_runtime.h> #include <unistd.h> #define THREADS 1024 __global__ void kernel(float* d_1,float* d_2){ int id; id = blockDim.x*blockIdx.x + threadIdx.x; d_1[id] += 1.0f; d_2[id] += d_1[id]; } int main(){ cudaError_t res; float *d_1,*d_2,*h; size_t p...
3,206
#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 :...
3,207
#include "includes.h" static unsigned int GRID_SIZE_N; static unsigned int GRID_SIZE_4N; static unsigned int MAX_STATE_VALUE; __global__ static void cudaEvaluateRightGammaKernel(int *wptr, double *x1, double *x2, double *diagptable, double *output, const int limit) { const int i = blockIdx.x * blockDim.x + threadIdx....
3,208
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> __global__ void add (int *A, int *B,int *a) { int idx = blockIdx.x; printf("idx = %d\n", idx); A[idx] = (*a)*A[idx] + B[idx]; } int main () { int M; int i, j; printf("Enter the size : "); scanf("%d",&M); ...
3,209
#include "includes.h" __global__ void sortKernelMulti(int *arr, int arr_len, int num_elem, int oddEven) { int i = 2 * (blockIdx.x * blockDim.x * num_elem) + oddEven; int iterEnd = min(arr_len - 1, i + 2 * blockDim.x *num_elem); // Increment to thread start index: i += 2 * threadIdx.x; // Every thread in block (warp) st...
3,210
#include <stdio.h> #include <stdlib.h> __global__ void dot_prod(int n, int *a, int *b, int *c) { int index = threadIdx.x; int stride = blockDim.x; for (int i = index; i < n; i += stride){ // T threads per iteration c[i] = a[i] * b[i]; } } int main(int argc, char **argv){ int sum = 0; ...
3,211
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <thrust/scan.h> #include <thrust/reduce.h> #include <thrust/sort.h> #include <thrust/functional.h> #include <thrust/copy.h> #include <thrust/device_ptr.h> str...
3,212
extern "C" { __global__ void fullgrow_kernel(double* d_image, double* d_region, double* d_conv, int h, int w) { int j = blockDim.x * blockIdx.x + threadIdx.x; int i = blockDim.y * blockIdx.y + threadIdx.y; int index = i*w + j; if ((0 < i) && (i < (h - 1)) && (0 < j) && (j < (w -...
3,213
// RUN: %clang_cc1 %s -emit-llvm -o - -triple=amdgcn-amd-amdhsa \ // RUN: -fcuda-is-device -target-cpu gfx906 -fsanitize=address \ // RUN: -x hip | FileCheck -check-prefix=ASAN %s // RUN: %clang_cc1 %s -emit-llvm -o - -triple=amdgcn-amd-amdhsa \ // RUN: -fcuda-is-device -target-cpu gfx906 -x hip \ // RUN: | Fi...
3,214
#include <stdio.h> __global__ void reverse (int* in, int* out){ out[blockDim.x-threadIdx.x-1]=in[threadIdx.x]; } int main() { int d_in[]={100,110,200,220,300}; int size = 5* sizeof( int ); int* d_out=(int*)malloc(size); int *dev_in, *dev_out; // device copies int i; // allocate dev...
3,215
// Device code typedef struct BUFFERDIMS_t { unsigned int X; unsigned int Y; unsigned int Z; unsigned int stride; unsigned int pitch; } BUFFERDIMS; extern "C" __global__ void scale( float * A, float * B, float scalar, BUFFERDIMS dims ) { int i = blockDim.x * blockIdx.x +...
3,216
/* A simple CUDA test program that adds two vectors */ #include <iostream> __global__ void vAdd(int* a, int* b, int* c, int N) { int gIdx = (blockDim.x * blockIdx.x) + threadIdx.x; if(gIdx < N) { c[gIdx] = a[gIdx] + b[gIdx]; } } int main(int argc, char** argv) { if(argc != 2) { std::cout << "Usa...
3,217
/* module load cudatoolkit qsub -q gpu -l nodes=1:ppn=1,walltime=00:20:00 -I nvcc matrixTranspose.cu */ #include <stdio.h> #define DIM 32 __global__ void transposeNaive(double *odata, const double *idata,int BLOCK_ROWS) { int x = blockIdx.x * DIM + threadIdx.x; int y = blockIdx.y * DIM + threadIdx.y; int wi...
3,218
#include <stdio.h> // #include <cuda.h> #include <iostream> #include <random> #include <chrono> #define DIM 2048 #define N (DIM*DIM) #define THREAD_PER_BLOCK 512 __global__ void add(int* a, int* b, int* c) { int index = threadIdx.x + blockIdx.x * blockDim.x; c[index] = a[index] + b[index]; } void randomInts...
3,219
#include<stdio.h> #include<stdlib.h> #include<math.h> // Compute vector sum C = A+B //CUDA kernel. Each thread performes one pair-wise addition __global__ void vecAddKernel(float *A, float *B, float *C, int n) { //Get our global thread ID int i = threadIdx.x; if (i<n) C[i] = A[i] + B[i]; } int main(int argc, char* ...
3,220
#include "includes.h" __global__ void matmulKernel(float *A, float *B, float *C, int rA, int cA, int cB){ int i = blockIdx.y*gridDim.x + blockIdx.x, j = threadIdx.y*blockDim.x + threadIdx.x; if(i < rA && j < cB){ C[i*cB + j] = 0.; for(int k=0;k<cA;++k) C[i*cB + j] += A[i*cA + k] * B[k*cB + j]; } return; }
3,221
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <cuda_runtime.h> extern "C" void saxpy(int,float,float*,float*); extern "C" void set(int,float,float*); extern "C" void map(float*, float*, int); int main(int argc, char **argv) { float *x, *y, *dx, *dy, tmp; int n = 1<<20; x = (float*) malloc...
3,222
#define __rose_lt(x,y) ((x)<(y)?(x):(y)) #define __rose_gt(x,y) ((x)>(y)?(x):(y)) //this is only used for cuda-chill //heavy simplification #define NsolventMolecules_ 1024 #define NsolventAtoms_ 1024 struct MolDist { ///< Original solvent molecule number (starts from 1). int mol; ///< Closest distance of solvent m...
3,223
/** * Author: Kapil Gupta <kpgupta98@gmail.com> * Organization: XantheLabs * Created: January 2017 */ #pragma once #ifndef HOUGH_LINES_DRAW_H_ #define HOUGH_LINES_DRAW_H_ #endif // HOUGH_LINES_DRAW_H_
3,224
#include "includes.h" __global__ void cunnx_WindowSparse_accGradParameters_kernel( float *gradWeight, float* gradBias, float *gradOutput, float *input, float *inputIndice, float *outputIndice, int inputWindowSize, int outputWindowSize, int inputSize, int outputSize, float scale) { __shared__ float buffer[WINDOWSPARSE_T...
3,225
#include "includes.h" __global__ void GetSpikes(double *spike_array, int array_size, int n_port, int n_var, float *port_weight_arr, int port_weight_arr_step, int port_weight_port_step, float *port_input_arr, int port_input_arr_step, int port_input_port_step) { int i_target = blockIdx.x*blockDim.x+threadIdx.x; int port ...
3,226
#include "includes.h" __global__ void callOperationSharedStatic(int *a, int *b, int x, int *res, int n) { int tid = blockDim.x * blockIdx.x + threadIdx.x; if (tid >= n) { return; } __shared__ int s_a[size], s_b[size], s_res[size]; __shared__ int s_x; s_x = x; s_a[tid] = a[tid]; s_b[tid] = b[tid]; s_res[tid] = ((s_a...
3,227
#include "includes.h" __global__ void transposeCoalesced(float *odata, const float *idata) { __shared__ float tile[TILE_DIM][TILE_DIM]; int x = blockIdx.x * TILE_DIM + threadIdx.x; int y = blockIdx.y * TILE_DIM + threadIdx.y; int width = gridDim.x * TILE_DIM; for (int j = 0; j < TILE_DIM; j += BLOCK_ROWS) tile[thread...
3,228
#include <cuda_runtime.h> __device__ unsigned int buildSum(int *s_data) { unsigned int thid = threadIdx.x; unsigned int stride = 1; // build the sum in place up the tree for (int d = blockDim.x; d > 0; d >>= 1) { __syncthreads(); if (thid < d) { int i...
3,229
#include <iostream> #define N 10 // __global__ qualifier indicates that // this function is a kernel function of CUDA. __global__ void reverse(int *da){ int tid = blockIdx.x; // which block handling the data if (tid < N){ int cross = N - 1 - tid; int temp = da[tid]; da[tid] = da[cross]; da[cross] = temp;...
3,230
#include <stdio.h> #include "cs_motion_report.h" void ma_report_header ( FILE *ofd, int y, int x, int t, int vr, int hr, int tr ) { fprintf( ofd, "****==== video info (1) ====****\n") ; fprintf( ofd, "vid_size_v,vid_size_h,vid_size_t,uv_ratio_v,uv_ratio_h,uv_ratio_t\n") ; fprintf( ofd, "I,I,I,I,I,I\n") ; fprintf(...
3,231
#include<stdio.h> #include<cuda.h> __global__ void oddeven(int* x,int I,int n) { int id=blockIdx.x; if(I==0 && ((id*2+1)< n)){ if(x[id*2]>x[id*2+1]){ int X=x[id*2]; x[id*2]=x[id*2+1]; x[id*2+1]=X; } } if(I==1 && ((id*2+2)< n)){ if(x[id*2+1]>x[id*2+2]){ int X=x[id*2+1]; x[id*2+1]=x[id*2+2]; ...
3,232
extern "C" { //灰度直方图统计 __global__ void histogram(unsigned char *dataIn, int *hist) { int threadIndex = threadIdx.x + threadIdx.y * blockDim.x; int blockIndex = blockIdx.x + blockIdx.y * gridDim.x; int index = threadIndex + blockIndex * blockDim.x * blockDim.y; atomicAdd(&his...
3,233
/*__global__ void Rotate3D(float* Destination, float* Source, int sizeX, int sizeY, float deg) { int i = blockIdx.x * blockDim.x + threadIdx.x;// Kernel definition int j = blockIdx.y * blockDim.y + threadIdx.y; int k = blockIdx.z * blockDim.z + threadIdx.z; int xc = sizeX - sizeX/2; int yc = sizeY ...
3,234
#include<stdio.h> #include<iostream> #include<stdlib.h> #include<string.h> #define NUM_THREADS 256 #define IMG_SIZE 1048576 // Coefficients with Structure of Array struct Coefficients_SOA { int* r; int* b; int* g; int* hue; int* saturation; int* maxVal; int* minVal; int* finalVal; }; __global__ v...
3,235
#include <curand.h> #include <curand_kernel.h> #define DIM 1600 #define PI 3.14159265 __global__ void grayscale(unsigned char *R_input, unsigned char *G_input, unsigned char *B_input, size_t i_size, unsigned int *hist) { int x = threadIdx.x + (blockIdx.x * blockDim.x...
3,236
#include "cuda_runtime_api.h" #include <vector> namespace CudaHelpers { template<typename T> bool copy_vector_to_gpu(T* gpu_mem, const std::vector<T>& vec){ cudaError_t err; err = cudaMalloc((void**)&gpu_mem, vec.size() * (size_t)sizeof(T)); cudaMemcpy((void*)gpu_mem, (void*)vec.data(), vec.size() * (size_t)s...
3,237
#include <chrono> #include <iostream> //Kernel Definition __global__ void emptyKernel() { } int main () { using namespace std::chrono; //Call emptyKernel to get the starting cost out of the measurement emptyKernel<<<1,1>>>(); for (int n = 0; n <= 6; n++){ //Time Measururement Point 1 high_resolution_cl...
3,238
#include "includes.h" __device__ void sumByReduction( volatile double* sdata, double mySum, const unsigned int tid ) { sdata[tid] = mySum; __syncthreads(); // do reduction in shared mem if (tid < 128) { sdata[tid] = mySum = mySum + sdata[tid + 128]; } __syncthreads(); if (tid < 64) { sdata[tid] = mySum = mySum + sdat...
3,239
/* 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,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) { if (co...
3,240
/* * sgemm.cu: * */ #include <stdio.h> #include <sys/time.h> #include <cuda_runtime.h> enum { BLOCK_SIZE = 32, N = 1024 }; __global__ void sgemm_naive(const float *a, const float *b, float *c, int n) { int row = blockIdx.y * blockDim.y + threadIdx.y; int col = blockIdx.x * blockDim.x + threadIdx.x...
3,241
#include "includes.h" __global__ void kernel(const uint *__restrict__ a, const uint *__restrict__ b, const uint length, uint *c) { uint tid = (blockIdx.x * blockDim.x) + threadIdx.x; const uint stride = blockDim.x * gridDim.x; while (tid < length) { c[tid] = a[tid] + b[tid]; tid += stride; } }
3,242
#include <stdio.h> #include <future> #include <thread> #include <chrono> #include <iostream> #include <iterator> #include <cstring> #define N 1000000 #define SIZE 100 __constant__ int factor = 1; // // NOTE: while loop is for the case when number of elements in the array exceeds the // number of blocks possible tot...
3,243
#include "includes.h" __global__ void squared_difference(float *x, float *y, int len) { int i = blockIdx.x*blockDim.x + threadIdx.x; if (i < len) { x[i] = (x[i] - y[i])*(x[i] - y[i]); } }
3,244
#include <cuda.h> #include <stdio.h> #include <stdlib.h> __global__ void what_is_my_id(unsigned int * const block, unsigned int * const thread, unsigned int * const warp, unsigned int * const calc_thread) { // Thread_ID is b...
3,245
using namespace std; #include <iostream> #include <fstream> #include <string> #include <cstdlib> #include <vector> #include <stdio.h> #include <stdlib.h> #include <cuda_runtime.h> __global__ void is_odd( int * d_in){ int idx = threadIdx.x + blockIdx.x * blockDim.x; printf("hello from thread %d, data is %d\n", idx, ...
3,246
#include <stdio.h> #include <stdlib.h> #include "mesh.cuh" #include "material.cuh" void print_mesh_details(struct mesh *m); void print_material_details(struct material *mat); void mesh_material_print(struct mesh *me, struct material *ma) { printf("MESH PROPERTIES: \n"); print_mesh_details(me); printf("MATERIAL PR...
3,247
#include "cuda_runtime.h" #include "cudafile2.cuh" #include <stdio.h> #include <iostream> #include "device_launch_parameters.h" using namespace std; #define N 10 void fillalldata(int ** data[N][N]) { for (int i = 0; i < N;i++) { for (int j = 0; j < N; j++) { **data[i][j] = j * 4; } } } __global__ void ...
3,248
#include <stdio.h> #include <cufft.h> cufftHandle plan; cufftResult result; // 1D FFT single precision ==================================================== void sPlan1dCUFFT(int n, void *stream) { result = cufftPlan1d(&plan, n, CUFFT_C2C, 1); if (result!=CUFFT_SUCCESS) { printf ("Error: cufftPlan1d failed:...
3,249
#include <stdio.h> __global__ void myKernel(int64_t *dA) { int id = blockIdx.x * blockDim.x + threadIdx.x; dA[id] = dA[id] + 1; } extern "C" { void kernel(int64_t *ptr) { myKernel<<<1,128>>>(ptr); cudaDeviceSynchronize(); } }
3,250
#include "includes.h" __global__ void cudaDSaturation_propagate_kernel(double* x, double* y, unsigned int size, double threshold) { const unsigned int index = blockIdx.x * blockDim.x + threadIdx.x; const unsigned int stride = blockDim.x * gridDim.x; for (unsigned int i = index; i < size; i += stride) { double value = ...
3,251
/* * CUDA program to multiply matrices (fills in matrices itself) * * compile with: * nvcc -o matrix_multiply matrix_multiply.cu * * run with: * ./matrix_multiply */ #include <stdio.h> #include <cassert> #include <cstdlib> //constants to control the program: #define NTESTS 1 /* # of tests...
3,252
/***************************************************** * This file tests cuda memory management APIs. *****************************************************/ #include <cuda_runtime.h> #include <stdio.h> __global__ void vecAdd(float* A, float* B, float* C) { unsigned int i = blockIdx.x * blockDim.x + threadIdx.x; C[...
3,253
#include "includes.h" __global__ void cuConvertHSVToRGBKernel(const float4* src, float4* dst, size_t stride, int width, int height, bool denormalize) { const int x = blockIdx.x*blockDim.x + threadIdx.x; const int y = blockIdx.y*blockDim.y + threadIdx.y; int c = y*stride + x; if (x<width && y<height) { // Read float4 i...
3,254
#include "includes.h" __global__ void cu_kron(const float *a, const float* b, float* dst, const int rowsa, const int colsa, const int rowsdst, const int colsdst, const int n){ int tid = threadIdx.x + blockIdx.x * blockDim.x; int stride = blockDim.x * gridDim.x; int colsb = colsdst / colsa; int rowsb = rowsdst / rowsa; ...
3,255
// /usr/local/cuda/bin/nvcc task1.cu -o task1 // nvcc task1.cu -o task1 //./task1 #include <stdio.h> #include <stdlib.h> #include <math.h> __global__ void solver(double *T_new, const double *T_old, int cols, int rows) { int col = blockIdx.x * blockDim.x + threadIdx.x; int row = blockIdx.y * blockDim.y + thr...
3,256
#include <stdio.h> typedef struct NET_T { int nb_layers; int* size0;//size of output int* size1;//size of input double** layers; double** biases; } net_t; typedef struct IMG_T{ int l; int ll; double* pixels; } img_t; net_t load_coeffs(char* file_address){ FILE* f = fopen(file_address, "r"); //pri...
3,257
// Invocar como: './practico_sol nombre_archivo, ejercicio'. En donde ejercicio es 1, 2 o 3. #include <stdio.h> #include <stdlib.h> #include "cuda_runtime.h" #include "device_launch_parameters.h" // Macro para wrappear funciones de cuda e interceptar errores #define CUDA_CHK(ans) { gpuAssert((ans), __FILE__, __LINE__...
3,258
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <iostream> #include <stdio.h> #include <cstdlib> #include <ctime> #define max 20 #define min 0 #define dato 10 using namespace std; __global__ void busqueda_bin(int* x, int *a, int* flag) { int i = threadIdx.x; if (*(a + i) == *x) *(fla...
3,259
#include <stdio.h> #include <stdlib.h> #include<algorithm> using namespace std; #define BLOCKSIZE 256 #define DATASIZE 101 //INSERT CODE HERE--------------------------------- //Counting Sort __global__ void countingData(int * pSource_d,int *offsetArray,int input_size){ //Shared memory for saving data counts __shared...
3,260
#include "includes.h" /** Modifed version of knn-CUDA from https://github.com/vincentfpgarcia/kNN-CUDA * The modifications are * removed texture memory usage * removed split query KNN computation * added feature extraction with bilinear interpolation * * Last modified by Christopher B. Choy <chrischoy@ai...
3,261
#include <cuda.h> #include <cuda_profiler_api.h> #include <iostream> #define N 1024 using namespace std; __global__ void transpose(int A[][N])//,int B[][N],int C[][N]) { int id = threadIdx.x; for(int j=0;j<id;j++) { int t = A[id][j] ^ A[j][id]; A[id][j] = t ^ A[id][j]; A[j][id] = t ^...
3,262
/** * The memory shared between the threads of each block. */ extern __shared__ float sdata[]; /** * Arg max function along a row. * @param n the number of column. * @param i the row index. * @param a the array (data). * @param r the output buffer. * @return nothing. */ extern "C" __global__ void arg_max_row(...
3,263
/* Authors: Erkin Verbeek, Prabhat Bhootra Date: 12/2/2019 * *** with 3 x 3 patch *** * M = 10000 N = 10000 The elapsed time: 71.6 ms M = 30000 N = 10000 The elapsed time: 215.1 ms M = 20000 N = 20000 The elapsed time: 227.6 ms * *** with 7 x 7 patch *** M = 10000 N = 10000 The...
3,264
#include <stdio.h> __device__ int geti() { int i = blockIdx.z; i = i*gridDim.y + blockIdx.y; i = i*gridDim.x + blockIdx.x; i = i*blockDim.z + threadIdx.z; i = i*blockDim.y + threadIdx.y; i = i*blockDim.x + threadIdx.x; return i; } __global__ void process_kernel1(const float *A, const float *B, float *C,...
3,265
/* * Copyright (c) 2020 Yaroslav Pogrebnyak <yyyaroslav@gmail.com> * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License...
3,266
#include "includes.h" __global__ void sum(int *a, int *b, int *c, int N) { int tid = blockIdx.x * blockDim.x + threadIdx.x; if (tid<N) { c[tid] = a[tid] + b[tid]; } }
3,267
#include "includes.h" __global__ void BuildColorFieldDev(float* data, uchar4* colors, float* minmax, uint xx, uint yy) { float mn = minmax[0]; float mx = minmax[1]; float median = (mx - mn)/2.0f; const uint idx = threadIdx.x*gridDim.x/yy/yy + blockIdx.x/xx; float val = data[idx]; uchar4 col; #if 1 if(val < median...
3,268
__global__ void invert(double * I, double * A, const int * n){ for (int i = 0; i<n[0]; i++){ int x = blockIdx.x * blockDim.x + threadIdx.x; int y = blockIdx.y * blockDim.y + threadIdx.y; //Non diagonal normalization if (x < n[0] && y < n[0]) if (x == i && x!=y){ ...
3,269
//matrix_mult.cu //template provided by Prof. Andrew Grimshaw //implementation by Jerry Sun(ys7va) 2017.05.08 //the program will take 4 parameters to specify the size of two matrices //if only provided 1 value N, it will calculate the multiplication of two N * N matrices #include<stdio.h> #include<sys/time.h> #include<...
3,270
#include <cuda.h> #include <limits.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <time.h> #define max(x, y) x > y ? x : y #define TIME(f, msg) \ _begin = clock(); \ (f); \ _end = clock(); \ printf("%s done in %f\n", (msg), (float)(_end - _begin) / CLOCKS_PER_SEC); void testRand(int *a, i...
3,271
#include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <thrust/execution_policy.h> #include <thrust/transform.h> struct TenX { __host__ __device__ int operator() (int x) const { return x*10; } } myFunctor; void hostVectors() { thrust::host_vector<int> vec1(4), vec2(4); printf("Host\n"...
3,272
#include <stdio.h> __global__ void saxpy(uint n, float a, float *x, float *y) { uint i = blockIdx.x*blockDim.x + threadIdx.x; // nvcc built-ins if(i < n) y[i] = a*x[i] + y[i]; } void misc(void) { int ndev; cudaDeviceProp prop; cudaGetDeviceCount(&ndev); printf("This machine has %d CUDA devices.\n", ...
3,273
#include <iostream> #include <math.h> #include <ctime> #include <cmath> #include <stdlib.h> #include <fstream> #include <sstream> #define PI 3.14159265358979323846 //this function returns the transition densities between nodes __device__ double densityW(double Xold, double Xnew, double sigma, double r, double delta,...
3,274
// clang-format off #include <cstdio> #include <cassert> __global__ void init_random_numbers(unsigned int seed) { printf("seed = %d\n", seed); atomicAdd((int *)(12312433432), 123); atomicAdd((float *)(12312433432), 123.0f); __threadfence_block(); // membar.cta __threadfence(); // membar.gl __threadfence_sy...
3,275
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <stdio.h> cudaError_t addWithCuda(int *c, const int *a, const int *b, unsigned int size); __global__ void addKernel(int *c, const int *a, const int *b) { } int main() { s...
3,276
#include <iostream> #include <cuda.h> #include <cstdlib> #include <stdlib.h> #include <stdio.h> #include <time.h> const int BLOCK = 256; __global__ void ScanListK(float *I, float *O, int l) { int b = blockIdx.x; int t = threadIdx.x; __shared__ float tSum[BLOCK*2]; int start = 2*blockDim.x*b; ...
3,277
#include <cuda_runtime.h> #include <device_launch_parameters.h> #include <stdlib.h> #include <stdio.h> #include <math.h> #include <assert.h> __global__ void vectorAdd(int* a, int* b, int* c, int n){ int tid = (blockIdx.x * blockDim.x) + threadIdx.x; if (tid < n){ c[tid] = a[tid] + b[tid]; } } voi...
3,278
#include "includes.h" __global__ void multi_scale_kernel(const float *data_in, const float *scale, float *data_out, int width, int height) { const int x = blockDim.x * blockIdx.x + threadIdx.x; const int y = blockDim.y * blockIdx.y + threadIdx.y; if (x < width && y < height) { int index = y * width + x; data_out[index...
3,279
// // Created by yevhen on 8/1/21. // #include "iostream" #include "cassert" #include "../mmul.cuh" __global__ void mmul_bl(const int* a, const size_t Arows, const size_t Acols, const int* b, const size_t Bcols, int* c, const size_t ID) { // get thread ids const...
3,280
#include "includes.h" __global__ void IntDataPointIdentity(int *size, const int *inputX, const int *inputY, int *outputX, int *outputY, int *length) { const long ix = threadIdx.x + blockIdx.x * (long)blockDim.x; if (ix < *size) { // copy int array const int *inArrayBody = &inputX[ix* *length]; int *outArrayBody = &outp...
3,281
#include "includes.h" __global__ void mm_tiled(float *dA, float *dB, float *dC, int DIM, int N, int GPUN) { int it, jt, kt, i, j, k; __shared__ float sA[32][32], sB[32][32]; // (it, jt) => the first element of a specific tile it = blockIdx.y * 32; jt = blockIdx.x * 32; // (i, j) => specific element i = it + threadIdx...
3,282
#include <stdio.h> #include <stdlib.h> #include "cuda.h" void serialAddVectors(int N, double *a, double *b, double *c){ int n; for(n=0;n<N;++n){ c[n] = a[n] + b[n]; } } // code to be executed by each CUDA "thread" __global__ void addVectorsKernel(int N, double *a, double *b, double *c){ int threadRank...
3,283
#include <stdio.h> #include <stdlib.h> #define BLOCK_SIZE 64 #define N 1024 __global__ void doubleValues(int* numbers, int length) { numbers[BLOCK_SIZE*blockIdx.x + threadIdx.x] *= 2; } int main() { int* cpu_arr = (int*)malloc(N * sizeof(int)); if(!cpu_arr) { perror("malloc"); exit(1); } for(...
3,284
#include "includes.h" __global__ void multiply_device (double *d_a, double *d_b,int dim) { //Declaration of required variables. double a, b, sum; //Retrive the thread and block specific information. int i = threadIdx.x,j,k; // Begine Matrix Computation. for (j = blockIdx.x; j < dim; j += gridDim.x) { sum = 0; for(k=...
3,285
extern "C" __global__ void mmkernel( float* a, float* b, float* c, int pitch_a, int pitch_b, int pitch_c, int n, int m, int p ) { int tx = threadIdx.x; int bx = blockDim.x; int i = blockIdx.x * bx * 2 + tx; int j = blockIdx.y; __shared__ float cb[512]; float sum0 = 0.0, sum1 = 0.0; for(...
3,286
#include <cuda_runtime.h> #include "device_launch_parameters.h" #include <iostream> template <typename T, typename C> __global__ void awkward_listarray_compact_offsets(T* tooffsets, const C* fromstarts, const C* fromstops, int64_t startsoffset, int64_t stopsoffset, int64_t length) { int thid = threadIdx.x + (blockIdx...
3,287
#include <stdio.h> #include <limits.h> /* GPU */ __global__ void find_odd(int n, int *A, int *B) { int index = blockIdx.x * blockDim.x + threadIdx.x; int stride = blockDim.x * gridDim.x; for (int i = index; i < n; i += stride) { if (A[i] % 2 > 0) { B[i] = A[i]; } else { B[i] = 0; } } } ...
3,288
/****************************** * Tisma Miroslav 2006/0395 * Multiprocesorski sistemi * domaci zadatak 6 - 4. zadatak *******************************/ /** * 4. Sastaviti program koji menja znak svim elementima niza celih brojeva. Po zavrsenoj obradi niza, treba * ispisati izmenjeni niz, ukupan broj pozitivnih i...
3,289
#if GOOGLE_CUDA #define EIGEN_USE_GPU extern "C" __global__ void default_function_kernel0(const float* __restrict__ Data, const float* __restrict__ K0, const float* __restrict__ K1, const float* __restrict__ K2, float* __restrict__ Output) { float Output_local[16]; __shared__ float pad_temp_share...
3,290
/* Single Author info: hmajety Hari Krishna Majety Group info: hmajety Hari Krishna Majety srout Sweta Rout mreddy2 Harshavardhan Reddy Muppidi */ #include<stdio.h> #include<cuda_runtime.h> #include<math.h> #include<curand_kernel.h> #define SEED 35791246 __global__ void setup_kernel(curandState *state, int numEleme...
3,291
#include <cuda_runtime.h> #include <vector> #include <iostream> __global__ void vector_add(const float *a, const float *b, float *c, int num_elements) { int i = blockDim.x * blockIdx.x + threadIdx.x; if (i < num_elements) { c[i] = a[i] + b[i]; } } int main(void) { size_t const num_eleme...
3,292
#include <iostream> #include <string> #include "program/program.cuh" #include "program/image_program.cuh" #include "program/video_program.cuh" using namespace std; void usage() { ImageProgram().usage(); VideoProgram().usage(); } int main(int argc, char *argv[]) { if (argc < 2) { cout << "This program should ...
3,293
#include <stdio.h> #include<cuda.h> #include<cuda_runtime.h> #include<time.h> #include<stdlib.h> #define BLOCK_NUM 32 //块数量 #define THREAD_NUM 32 // 每个块中的线程数 #define R_SIZE 1024//BLOCK_NUM * THREAD_NUM #define M_SIZE R_SIZE * R_SIZE __global__ void mat_mul(int *mat1, int *mat2, int *result) { const int bid = bl...
3,294
#include <cmath> #include <cstdio> #include <cuda_runtime.h> #include <device_launch_parameters.h> #include <device_atomic_functions.h> #include "CudaSudoku_cuda.cuh" /** * This function takes in a bitmap and clears them all to false. */ __device__ void clearBitmap(bool *map, int size) { for (int i = 0; i < s...
3,295
//pass //--blockDim=64 --gridDim=64 --no-inline #include "cuda.h" __global__ void foo() { int a, b, c; a = 2; b = 3; c = a + b; }
3,296
// System includes #include <stdio.h> #include <cuda_runtime.h> #include<device_launch_parameters.h> #include<curand.h> #define _USE_MATH_DEFINES #include<math.h> __global__ void sumSingleBlock(int *d) { int tid = threadIdx.x; int myIdx = tid * 2; int diff = 1; while(myIdx + diff < 2 * blockDim.x) { d[myIdx] +=...
3,297
#include <iostream> #include <cuda.h> #include <chrono> #include <stdlib.h> #include <ctime> #include <cmath> #include <limits> #define BLOCK_SIZE 1024 __global__ void gpu_transposition(double *a, double *b, int m, int n) { int idx = blockIdx.x * blockDim.x + threadIdx.x; if (idx < m * n) { b[(idx / n...
3,298
__global__ void matmultvec(int m, double *A, double *b, double *c){ int i, j; i = threadIdx.x+blockIdx.x*blockDim.x; for (j=0; j<m; j++){ c[i] += A[i+j] * b[j]; } }
3,299
#include <iostream> #include <cmath> #include <vector> #include <fstream> #include <curand.h> #include <curand_kernel.h> #define Ndmsq 1000 #define Nssq2th 1000 #define Ngrid Ndmsq*Nssq2th #define Nfexp 500 #define Bkgd 100 __global__ void fakeexps(unsigned int, double*, double*, double*); __device__ doubl...
3,300
#include "includes.h" __global__ void cuMult(int *a, int *b, int *c, int wA, int wB, int hA) { // global index int gidx = blockDim.x * blockIdx.x + threadIdx.x; // col int gidy = blockDim.y * blockIdx.y + threadIdx.y; // row if(gidx < wB && gidy < hA) { int sum = 0; for(int k=0; k<wA; k++) { // Multiply row of A by ...