serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
17,101
#include <cmath> #include "RNG.cuh" using namespace std; // Constructor and destructor __device__ __host__ RNG_Tausworthe::RNG_Tausworthe(){ _Seed = 129; } __device__ __host__ RNG_Tausworthe::RNG_Tausworthe(const unsigned int seed){ _Seed = seed; } // Private functions __device__ __host__ unsigned int RNG_Tauswo...
17,102
#include "includes.h" __global__ void refreshClusters(dim3 *sum, dim3 *cluster, int *counter) { int i = blockIdx.x * blockDim.x + threadIdx.x; if(counter[i] != 0) { cluster[i].x = sum[i].x / counter[i]; cluster[i].y = sum[i].y / counter[i]; cluster[i].z = sum[i].z / counter[i]; } else { cluster[i].z = cluster[i].x = cl...
17,103
#include "includes.h" __global__ void cuAddQNormAndSqrt(float *dist, int width, int pitch, float *q, int k){ unsigned int xIndex = blockIdx.x * blockDim.x + threadIdx.x; unsigned int yIndex = blockIdx.y * blockDim.y + threadIdx.y; if (xIndex<width && yIndex<k) dist[yIndex*pitch + xIndex] = sqrt(dist[yIndex*pitch + xInd...
17,104
#include <stdio.h> #include <stdlib.h> __global__ void print_from_gpu(void) { printf( "Hello World from device!\n\ threadIdx.x: %d\n\ blockIdx.x: %d\n\ blockDim.x: %d\n", threadIdx.x, blockIdx.x, blockDim.x); } int main(void) { printf("Hello World from host!\n"); print_from_gpu<<<2, 3>>>...
17,105
#include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <stdint.h> #include <assert.h> #include <time.h> #include <math.h> /* Author: Andrew DiPrinzio Course: EN605.417.FA Assignment: Module 5 Resources: https://devblogs.nvidia.com/using-shared-memory-cuda-cc/ http://www.nvidia.com/docs/IO/116711/sc11-cu...
17,106
#include "stdio.h" #include "stdlib.h" #include "time.h" #include "math.h" #define BLOCK_SIZE 32 int block_size; void generate_matrix(float *mat, int a, int b) { int i, j, m, n; m = a * block_size; n = b * block_size; for(i = 0; i < m; i++) for(j = 0; j < n; j++) mat[i * n + j] = (float)(rand() % 100) / 10....
17,107
//////////////////////////////////////////////////////////////////////////// // // 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...
17,108
#include <stdio.h> #include <math.h> #include <cuda.h> #include <cuda_runtime.h> #include <time.h> __global__ void calculations_inv(float *d_array, float *ans,int *n, long *iter) { int id = blockIdx.x * blockDim.x + threadIdx.x; float *d_ptr_array = d_array; int i; //obliczanie sumy //ustawienie wskaznika na ...
17,109
#include <stdio.h> #include <assert.h> //const int TILE_DIM = 32; //const int BLOCK_ROWS = 32; const int thread = 32; const int NUM_REPS = 100; const int nx = 2000; const int ny = 2000; //Uni10 Transpose __global__ void transposeUni10(const double *A, size_t M, size_t N, double *AT) { size_t y = blockIdx.y * block...
17,110
//function kernel __device__ float length(float3 r) { return r.x*r.x + r.y*r.y + r.z*r.z; } __device__ float3 mul_float3(float3 r1, float3 r2) { return make_float3(r1.x * r2.x, r1.y * r2.y, r1.z * r2.z); } __device__ float3 add_float3(float3 r1, float3 r2) { return make_float3(r1.x + r2.x, r1.y + r2.y, ...
17,111
/* Copyright 2018 - The OPRECOMP Project Consortium, Alma Mater Studiorum Università di Bologna. 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 of the License at htt...
17,112
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include "cuda.h" #include <stdio.h> #include <stdlib.h> #define THREADS 5 #define BLOCKS 1 __global__ void testFunction(float *dev_a) { int thread = threadIdx.x; if(thread == 0) { printf("dev[%d] = %.2f;\n", thread, dev_a[thread+2]); int ...
17,113
#define __TRANSALIGN_KILLER_CU__ #include <iostream> #include <fstream> #include <string> #include <algorithm> #include <cuda.h> #include <time.h> #include <sys/time.h> #include <thrust/count.h> #include <thrust/device_vector.h> #include <thrust/host_vector.h> #include "transalign_killer_thrust.cuh" int main(int arg...
17,114
#include "includes.h" __global__ void initializeBiasKernel(float* b, int size){ int index = blockIdx.x * blockDim.x + threadIdx.x; if(index < size){ b[index] = 0.0; } }
17,115
#include <stdio.h> #include <stdint.h> #include <math.h> #include <unistd.h> #include <stdlib.h> #include <cuda.h> #include <ctime> #include <iostream> // timing of functions clock_t start,end; /* invert and square every element of the input array in parallel */ __global__ void _innergpu_2_sqr(double *psum, int64_t...
17,116
#include "includes.h" __global__ void FinalizeVelocityKernel(float* velocities, float* globalFlow, int inputWidth, int inputHeight) { int id = blockDim.x * blockIdx.y * gridDim.x + blockDim.x * blockIdx.x + threadIdx.x; int size = inputWidth * inputHeight; if (id < size) { float globalFlowL = sqrtf(globalFlow[0] * gl...
17,117
#include <stdio.h> #include <stdlib.h> #include <time.h> #include "cuda_runtime.h" #include "device_launch_parameters.h" // ref: https://cs.calvin.edu/courses/cs/374/CUDA/CUDA-Thread-Indexing-Cheatsheet.pdf __device__ int getGlobalIdx_3D_3D() { int blockId = blockIdx.x + blockIdx.y * gridDim.x + grid...
17,118
/* This program generates 2 N*N matrices and then multiplies them on a GPU */ #include<stdio.h> #include<stdlib.h> #include<math.h> #include<cuda.h> #include<unistd.h> //#define N 100 __global__ void multiply(float* A, float* B, float* C, int K) { /* The Kernel is a 2D grid. Tried doing the same with a 1D grid but...
17,119
#include <stdio.h> #include <sys/time.h> using namespace std; struct particle { float position[3]; float velocity[3]; }; struct seed { int x; int y; int z; }; __host__ __device__ float gen_random(int seed, int particle_id, int iteration,int num_particles) { float rand_num = (seed * particle_id...
17,120
extern "C" void cuda_add_vector( float* a, float* b, float *c, int size ); __global__ void VectorAdd( float* arrayA, float* arrayB, float* output ) { int idx = threadIdx.x; output[idx] = arrayA[idx] + arrayB[idx]; } void cuda_add_vector( float* a, float* b, float *c, int size ) { int data_size = size * sizeof(flo...
17,121
// *************************************************************************** // Assignment #2 // Name: Yujin Yoshimura // Parallel Programming Date: March 5, 2020 // *************************************************************************** // This sequential program demonstrates Matrix Multiplication. // // For Tur...
17,122
#include <cuda.h> #include <cuda_runtime.h> #include <stdio.h> __global__ void offset_access(float *a, int s, int n) { int tid = blockDim.x * blockIdx.x + threadIdx.x; if (tid + s < n) { a[tid + s] = a[tid + s] + 1; } } __global__ void strided_access(float *a, int s, int n) { int tid = blo...
17,123
#include <iostream> #include <stdlib.h> #include <math.h> #include <complex> #include <string> #include <fstream> #include <time.h> #include <cuda.h> #include <cuda_runtime.h> #define Nblock 16 #define NThreadPerBlock 64 #define NTotal Nblock*NThreadPerBlock #define N_ 200 class RNHQS_ZB { public: __device...
17,124
#include <assert.h> #include <time.h> #include <stdio.h> #include <stdlib.h> #include <cuda_profiler_api.h> // #include <cutil_inline.h> // Convenience function for checking CUDA runtime API results // can be wrapped around any runtime API call. No-op in release builds. inline cudaError_t checkCuda(cudaError_t result...
17,125
#include "includes.h" __global__ void InvertPermutationKernel(float* input, float* output, int size) { int id = blockDim.x*blockIdx.y*gridDim.x + blockDim.x*blockIdx.x + threadIdx.x; if (id >= size) return; int temp = __float2int_rn(input[id]); if (input == output) __syncthreads(); output[temp] = id; }
17,126
#include <stdio.h> #include <cuda.h> //#include "cuPrintf.cu" /* * CUDA parallel factorial computing program by bahramwhh * Note : This program is only tested for n <= 21 * because of my hardware constraints * * comments in the code are for debuggin purpose only ;) * */ __global__ void fact(int *n, int *a, int...
17,127
#include "includes.h" __global__ void apply_weights_kernel(double *g_out, int *g_in, double *g_ttmp) { int val[2], test = 1; double ttp_temp[2]; const int index = (blockIdx.x * blockDim.x + threadIdx.x) << 1; val[0] = g_in[index]; val[1] = g_in[index + 1]; ttp_temp[0] = g_ttmp[index]; ttp_temp[1] = fabs(g_ttmp[index +...
17,128
/********************************************************* * DESCRIPTION: * * Serial Concurrent Wave Equation - C Version * * This program implements the concurrent wave equation* **********************************************************/ #include<stdio.h> #inclu...
17,129
#include <stdio.h> #include <cstdio> #include <cstdlib> #include <iostream> #include <sstream> #include <iomanip> #include <fstream> #include <unistd.h> #include <limits.h> #include <string> #include <vector> #include <ctype.h> #include <inttypes.h> #include <cuda.h> #include <cuda_runtime.h> #include <curand_kernel...
17,130
#include <iostream> #include <math.h> #include <iomanip> #include <stdio.h> #include <math.h> #include <vector> #include <fstream> #include "random" #define space 15 #define dim1 100 //X #define dim2 100 //Y #define dim3 100 //Z #define N ( 100000 ) #define M ( 512 ) #define incr 1 #define rad_circles 1 #def...
17,131
#include "includes.h" __global__ void kernel_D( float * _g_data, int dimx, int dimy ) { float4* g_data = reinterpret_cast<float4 *>(_g_data); int id = blockIdx.x*blockDim.x + threadIdx.x; float4 value = g_data[id]; value.x += sqrtf( cosf(value.x) + 1.f ); value.y += sqrtf( logf(value.y) + 1.f ); value.z += sqr...
17,132
#include <stdio.h> #include <math.h> #include <time.h> #include "cuda_runtime.h" #define PICK_PIVOT 1 #define PIVOT_CANDIDATE 3 #define checkCudaError(e) { checkCudaErrorImpl(e, __FILE__, __LINE__); } inline void checkCudaErrorImpl(cudaError_t e, const char* file, int line, bool abort = true) { if (e != cudaSuc...
17,133
#include <stdlib.h> #include <stdlib.h> #include <stdio.h> #include <cuda_runtime.h> #include <math.h> #include <locale.h> #include <cuda.h> #define BLOCK_SIZE 250 #define GRID_SIZE 4 #define THREAD_SIZE 1000 #define CUDA_FLOAT float __global__ void pi_kern(CUDA_FLOAT *res) { int n = threadIdx.x + blockIdx.x ...
17,134
#include "includes.h" __global__ void DrawMaskedColorKernel2DBlock(float *target, int targetWidth, int targetHeight, int inputX, int inputY, float *textureMask, int textureWidth, int textureHeight, float r, float g, float b) { int id = blockDim.x * blockDim.y * (blockIdx.y * gridDim.x + blockIdx.x) + blockDim.x * threa...
17,135
#include <math.h> #include <stdlib.h> #include <stdio.h> #include "convolution.cuh" // #define USE_SHARED_MEM // Question 2 et 3 // #define USE_PITCH // Question 3 void init_A( /* IN */ noyau_t *noyau, int Ni, int Nj, /* OUT */ float **A ) { const float pasx = 1/float(Ni); const float pasy = 1/float...
17,136
#include <stdlib.h> #include <stdio.h> #define N (2048*2048) #define THREADS_PER_BLOCK 512 __global__ void add(int *a, int *b, int *c, int n) { int index = threadIdx.x + blockIdx.x * blockDim.x; if(index < n) c[index] = a[index] + b[index]; } void random_ints(int* a); int main(void){ int *a, *b, *c; int *d_a, *...
17,137
#include<stdio.h> __global__ void add2(int *a) { *a = *a + 2; } int main( void ) { int *data; cudaMallocManaged(&data, sizeof(int)); *data = 5; add2<<<1,1>>>(data); cudaDeviceSynchronize(); printf("data: %d\n", *data); cudaFree(data); return 0; }
17,138
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <cuda_runtime.h> int main() { const unsigned int N = 1048576*16; const unsigned int bytes = N * sizeof(int); int *h_a; int *d_a; cudaMalloc((int**)&d_a, bytes); cudaError_t status = cudaMallocHost((void**)&h_a, bytes); if (status...
17,139
/* * Copyright 2008, Karen Hains, UWA . All rights reserved. * * NOTICE TO USER: * * This source code is subject to NVIDIA ownership rights under U.S. and * international Copyright laws. Users and possessors of this source code * are hereby granted a nonexclusive, royalty-free license to use this code * in indi...
17,140
#include <cuda.h> #include <cuda_runtime.h> #include "gray_img_CUDA.cuh" __global__ void gray_CUDA(unsigned char* orig, unsigned char* gray, int width, int height, int channels){ int x = threadIdx.x + blockIdx.x * blockDim.x; int y = threadIdx.y + blockIdx.y * blockDim.y; if (x < width && y < height) { ...
17,141
/* Program to add two long integer integer arrays. Hopefully this is a better exploitation of the GPU's parallel computing capabilities. Benchmarking timing to compare execution speeds. */ /* Note that there is a considerable dependency of the ratio of execution times of the CPU and GPU on the hardware which is being...
17,142
#include "includes.h" __global__ void sgemm_kernel_B(const float *A, const float *B, float *C, int N, int M, int K, float alpha, float beta) { int col = blockIdx.x * blockDim.x + threadIdx.x; int row = blockIdx.y * blockDim.y + threadIdx.y; float sum = 0.f; for (int i = 0; i < K; ++i) sum += A[row * K + i] * B[i * K +...
17,143
/* Hello World - CUDA Compile by: nvcc hello_cuda.c -o hello_cuda */ #include <stdio.h> // Global specifier indicates that the function runs on device (GPU). // These functions can be called through the host code (e.g. main()) and also known as "kernels". __global__ void cuda_hello(){ print...
17,144
#include <stdio.h> #include <math.h> #include <time.h> #include <unistd.h> #include <cuda_runtime_api.h> #include <errno.h> #include <unistd.h> /****************************************************************************** * This program takes an initial estimate of m and c and finds the associated * rms error. It...
17,145
#include "includes.h" __global__ void BFS_Bqueue_kernel(int* p_frontier, int* p_frontier_tail, int* c_frontier, int* c_frontier_tail, int* edges, int* dest, int* label, int* visited) { __shared__ int c_frontier_s[BLOCK_QUEUE_SIZE]; __shared__ int c_frontier_tail_s; __shared__ int our_c_frontier_tail; if (threadIdx.x ...
17,146
#include "includes.h" using namespace std; #ifndef MAP_FILE #define MAP_FILE MAP_SHARED #endif __global__ void mask4D(float* in, int* mask, int xstrides0, int xstrides1, int xstrides2, int xstrides3, int scalarCount) { int tid = blockIdx.x * blockDim.x + threadIdx.x; int stride = gridDim.x * blockDim.x; for (; tid < ...
17,147
#include <stdlib.h> #include <math.h> #include "constants.cuh" #include "mesh.cuh" #include "material.cuh" //------------------------------------------------------PROTOTIPES-------------------------------- void stiffness_init(double *ke, struct mesh *mesh, struct material *material); void mass_init(double *me, struct...
17,148
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #define N 5 __global__ void add(int* a, int* b, int* c) { int tid; tid = threadIdx.x; c[tid] = a[tid] + b[tid]; } int main(void) { int a[N],b[N],c[N]; int size=sizeof(int); int i; for(i=0;i<N;i++) { a[i] = i; b[i] = 2*i; ...
17,149
// This program computes the sum of two vectors on the GPU using CUDA // By: Roland Green #include <cassert> #include <cstdlib> #include <iostream> using std::cout; using std::endl; // Vector Addition kernel __global__ void vectorAdd(int *a, int *b, int *c, int N) { // Global threadID calculation int tid = block...
17,150
#include <stdio.h> #include <math.h> #include <stdlib.h> #include <string.h> #include <png.h> #include <cufft.h> #include <cuda_runtime.h> #include <unistd.h> #include <chrono> #include <iomanip> // Convention: Matrix dimension on the front, then input , output on the back // Convention: Scalar arguments always at the...
17,151
#include "includes.h" /* * Alexandre Maros - 2016 * * Cuda Matrix Multiplication with Global Memory. * * nvcc cuda_matrix_global.cu -o cg.o * * Implemented by Alexandre Maros for learning purposes. * A version of this code using Shared Memory is in here: * https://github.com/alepmaros/cuda_matrix_multiplication * * Dis...
17,152
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> #include <cuda_runtime.h> #define NOISE 0.01 #define GET_RAND ((double)rand()/(10.0 * (double)RAND_MAX)) - 0.05 #define SIZE 10000 typedef double VECTOR[SIZE]; __device__ int n; __device__ int count; int BLOCK_SIZE = 16; __device__ struct no...
17,153
/* Furthest point sampling GPU implementation * Author Zhaoyu SU * All Rights Reserved. Sep., 2019. * Happy Mid-Autumn Festival! :) */ #include <stdio.h> #include <iostream> __device__ int get_batch_id(int* accu_list, int batch_size, int id) { for (int b=0; b<batch_size-1; b++) { if (id >= accu_list[b]...
17,154
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <curand.h> #include <curand_kernel.h> #include <algorithm> #include <cmath> #include <iostream> #include <vector> #include <chrono> #include <assert.h> #define N 100 #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } inline v...
17,155
__global__ void muda() { float x; }
17,156
#include <stdio.h> #include <stdlib.h> #include <cuda.h> /* print_array Helper function for printing integer arrays of specified length. */ void print_array(int* array, size_t length) { printf("["); for (size_t i=0; i<length; ++i) printf(" %d,", array[i]); printf("]\n"); } /* vec_add Kernel (devic...
17,157
#include<stdio.h> #include<cuda_runtime.h> #include<device_launch_parameters.h> __global__ void add(int *a, int *b, int *c, int m){ int id=blockIdx.x*blockDim.x+threadIdx.x; int offset = 0; int n = blockDim.x; for (int i = 0; i < m; ++i){ offset = i*n + id; c[offset] = a[offset] + b[offset]; } }...
17,158
#include "includes.h" __global__ void lga_data_backward (const int n, const float *filters, const float *top_diff, const int height, const int width, const int channel, const int radius, float *bottom_diff){ int index = blockIdx.x * blockDim.x + threadIdx.x; if (index >= n) { return; } int step = height * width; int w...
17,159
#include <stdio.h> #include <cuda_runtime.h> #include <time.h> #include <vector> using namespace std; const int GPUs[] = {0,1,2}; // 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, ...
17,160
#include "KernelMath.cuh" #include <stdio.h> __global__ void addKernel(int* c, const int* a, const int* b, const int N) { int tid = blockIdx.x * blockDim.x + threadIdx.x; if (tid < N) { c[tid] = a[tid] + b[tid]; } } __global__ void subKernel(int* c, const int* a, const int* b, const int N) { i...
17,161
#include "includes.h" __global__ void reduce0(float *g_idata, float *g_odata, int N){ extern __shared__ float sdata[]; // each thread loads one element from global to shared mem int tid = threadIdx.x; int i = blockIdx.x*blockDim.x*2 + threadIdx.x; if((i+blockDim.x)<N) sdata[tid] = g_idata[i] + g_idata[i+blockDim.x]; el...
17,162
extern "C" __global__ void find_reduce_point(char *nodes, int node_count, int count, int threads, int blocks, int *out) { char TERMINAL = 0; char NETERMINAL = 1; char NONE = 0xf; int TYPE_INDEX = 0; int MODEL_INDEX = 1; int CHILD_INDEX = 2; int VALUE_INDEX = 3; int NODE_SIZE = 11; int node_offset = coun...
17,163
#include "includes.h" #define TILE_WIDTH 32 #define TILE_HEIGHT 32 #define FSize 256 //void convolution(int *InputImage,int width,int height,int *filter,int filterWidth,,int padding,int *result); using namespace std; __global__ void shareMatrixMultiple(int *InputImage,int width,int height,int *filter,int filterWidth,...
17,164
// http://forums.nvidia.com/index.php?showtopic=52806&pid=287558&mode=threaded&start=#entry287558 #include <stdlib.h> #include <stdio.h> #include <cuda_runtime_api.h> const int num_threads = 64; const int len = 30720 * 128;//2949120; const int stride = 16; int nIters = 500; # define CUDA_SAFE_CALL( call) do { ...
17,165
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> #include <iostream> #define imin(a,b) (a<b?a:b) //Nombre de posicions del vector const int N = 33 * 1024; //Nombre de threads per cada block const int threadsPerBlock = 256; //Escollim el nombre de blocs a la gr...
17,166
#include<stdio.h> #include<math.h> #define abs(x) (x > 0 ? x : -(x)) #define MAX(a,b) (a > b ? a : b) #define MIN(a,b) (a < b ? a : b) #define PI 3.1415926 #define GRIDDIM 32 #define BLOCKDIM 1024 //32*32 extern "C" void TOF_dist_backprojection(float *image_bp, const float *proj_value, const float *tof_value, ...
17,167
extern "C++" { #include "stdlib.h" #include "stdio.h" } #include <cuda.h> #include <cuda_runtime.h> __device__ __constant__ unsigned int d_input_height, d_input_width, d_filter_height, d_filter_width, d_output_height, d_output_width; #define cudaErrorCheck(ans) { cudaAssert((ans), __FILE__, __L...
17,168
#include <iostream> #include <vector> #include <string> #include <fstream> #include <cuda.h> using namespace std; __global__ void odd_count(int *arr, unsigned int *d_count, int length) { int idx = blockDim.x * blockIdx.x + threadIdx.x; if (idx >= length) { return; } if (arr[idx] % 2 != 0) { atomi...
17,169
#include "math.h" #include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <time.h> #define TIMER_CREATE(t) \ cudaEvent_t t##_start, t##_end; \ cudaEventCreate(&t##_start); \ cudaEventCreate(&t##_end); #define TIMER_START(t) \ cudaEventRecord(...
17,170
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> // =========== GLOBALS ========================= const int m = 50; // number of elements in array const int n = 10; // number of elements in array const int k = 10; // number of elements in array const int sizeZ = 64; // number of threads in z ...
17,171
// CMPE297-6 HW2 // CUDA version Rabin-Karp #include<stdio.h> #include<iostream> #define NUM_PATTERN 4 #define PATTERN_MAX_LENGTH 15 /*ADD CODE HERE: Implement the parallel version of the sequential Rabin-Karp*/ __global__ void findIfExistsCu(char* input, int input_length, char* pattern, int *pattern_length, int *pa...
17,172
#include <iostream> #include <iomanip> #include <string> #include <string.h> #include <sys/time.h> #include <stdio.h> int n = 32; void printall(float u[]) { for(int i=0; i<n; i++){ for(int j=0; j<n; j++){ std::cout << std::setw(12) << u[i*n+j]*10; } std::cout << std::endl << st...
17,173
#include <stdio.h> #include <stdlib.h> __global__ void helloKernel(){ int thread = threadIdx.x; int block = blockIdx.x; printf("hello from thread %d in block %d\n", thread, block); } int main(int argc, char **argv){ int B = 3; // number of thread-blocks int T = 4; // number of threads per thread-bloc...
17,174
/* Soma dois vetores Ilustra o uso da memória unificada (managed memory) */ #include <stdio.h> #include <stdlib.h> #include <cuda.h> #define TAM 5000 #define TPB 256 __global__ void soma(int *vetA_glb, int *vetB_glb,int *vetC_glb){ int idx = blockDim.x * blockIdx.x + threadIdx.x; if (idx < TAM) { ...
17,175
#include <stdio.h> #include <cuda.h> //device code __global__ void helloCUDA(float f) { //beliebige Argumente möglich printf("ThreadId: %d\tProzessId: %d\n", threadIdx.x, blockIdx.x); } //host code int main() { helloCUDA<<<15, 32>>>(1.2345f); // 15 Prozesse zu je 32 Threads cudaThreadExit(); return 0; }
17,176
#include <stdio.h> #include <stdlib.h> #include "cuda.h" #include <assert.h> #define N 2//64 __global__ void foo(int *c) { int b, a; a = 2; b = 3; c[threadIdx.x]= a+b; __syncthreads (); }
17,177
/* Submitted By: Sulav Timsina ID: 50502493 Course: CS 6253 Heterogeneous Computing Spring , 2018 Submitted On; 04/16/2018 */ #include <stdio.h> #include <math.h> #include <stdlib.h> /* Array to print an array to Console arr = pointer to array dimen = 1-D size of array */ void printArray(int *arr, int dim...
17,178
#include <cstdio> #include <unistd.h> #include <fstream> #include <string> #include <iostream> #include <cuda.h> #define cudachk(ans) { gpuAssert((ans), __FILE__, __LINE__); } inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true) { if(code != cudaSuccess) { fprintf(stderr, "GPUasse...
17,179
#include "includes.h" extern "C" { } __global__ void stanh(const int lengthA, const double alpha, const double *a, double *b) { int i = threadIdx.x + blockIdx.x * blockDim.x; if (i<lengthA) { b[i] = alpha*tanh(a[i]); } }
17,180
#include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <string.h> #include <math.h> #define TAM 8 #define TAMBLOCK 2 __global__ void sumaVectores(float *c, float *a, float *b){ //Kernel, salto a la GPU. Esta funcion es ejecutada por todos los hilos al mismo tiempo. int ix = blockIdx.x*blockDim.x+threadI...
17,181
#include "includes.h" __global__ void convolution_kernel_naive(float *output, float *input, float *filter) { }
17,182
//CUDE_2d_arraySum.cu //Ben Talotta #include "stdio.h" #define COLUMNS 4 #define ROWS 3 //based off sum2darr.cu example code __global__ void add(int* a,int* c) { int x = threadIdx.x; int sum = 0; for(int i = 0; i < ROWS; i ++){ sum += a[(COLUMNS * i) + x]; } printf("the sum of the %d th...
17,183
/* 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,float var_2,float 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...
17,184
#include <stdio.h> #include <cmath> #include <cuda.h> #include <curand_kernel.h> #include <ctime> #include <chrono> #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true) { if (code != cudaSuccess) { fprintf(std...
17,185
extern "C" __global__ void stochasticGradientDescentKernel (int length, float scalingFactor, float learningRate, float *parameter, float *gradient) { int index = blockDim.x * blockIdx.x + threadIdx.x; if(index < length) { parameter[index] -= scalingFactor * learningRate * gradient[index]; } }
17,186
// Tests the phases generated for a CUDA offloading target for different // combinations of: // - Number of gpu architectures; // - Host/device-only compilation; // - User-requested final phase - binary or assembly. // REQUIRES: clang-driver // REQUIRES: powerpc-registered-target // REQUIRES: nvptx-registered-target ...
17,187
/** * Assignment 03 Program - ceasar_cipher.cu * Sarah Helble * 9/17/17 * * Usage ./out <total_num_threads> <threads_per_block> <input_file> <key_file> * * Creates two arrays of <total_num_threads> length, and reads <total_num_threads> * characters from <input_file> and <key_file> to fill them. * Adds the char...
17,188
#include <stdio.h> #include <cuda_runtime.h> #include "functions.cuh" __global__ void KernelAdd(int n, float * p_sum, float * x, float * y){ int i = blockIdx.x * blockDim.x + threadIdx.x; if ( i < n ) p_sum[i] = x[i] + y[i]; } void DeviceKernel(int numBlocks, int sizeBlock, int n, float * p_sum, float * x, fl...
17,189
#include <limits.h> #include <stdio.h> int main() { int *hostMem; cudaMalloc((void**)&hostMem, ULONG_MAX); cudaFree(hostMem); cudaDeviceReset(); return 0; }
17,190
#include <stdio.h> #include <assert.h> // Simple utility function to check for CUDA runtime errors void checkCUDAError(const char *msg); __global__ void SetMatrixA( float *d_a ) { int idx = blockIdx.x * blockDim.x + threadIdx.x; d_a[idx] = blockIdx.x + 0.1 * threadIdx.x; } __global__ void SetMatrixB( float *d_a ) ...
17,191
#include <iostream> #include <math.h> #include <chrono> __global__ void add(int n, float *x, float *y) { int index = threadIdx.x; int stride = blockDim.x; for (unsigned long i = 0; i < n; i++) { //std::cout << "iter " << i << std::endl; x[i] = (float)(536.0f / 32.23f); ...
17,192
/* The following program is written to add two matrices. Benchmarking the time of execution on the CPU and the GPU is done to compare the sequential and parallel approach to solve this problem. */ /* Note that there is a considerable dependency of the ratio of execution times of the CPU and GPU on the hardware which ...
17,193
#include <math.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <float.h> #include "time.h" #define NUM_THREADS 256 #define NUM_BLOCKS 512 int nsamp = 65536 * 1024 * 4; __global__ void mean_stddev(float *input, float2 *stddev, const int nsamp) { // Declare shared memory to store temporary ...
17,194
#include <stdio.h> //compilar: nvcc matrizMultiplicacao.cu -o matrizMultiplicacao //for i in `seq 1 10`; do ./matrizMultiplicacao; done //#define N 64 #define B 16 extern double *mA, *mB, *mC; extern int N, num; __global__ void matrix_multi(double *a, double *b, double *c, int N) { int y = blockIdx.x * blockDim.x ...
17,195
#include "includes.h" #define max(a, b) a > b ? a : b #define min(a, b) a < b ? a : b struct Edge{ long long int x; }; ///* //*/ __global__ void hook_odd(int* parent, Edge* edge_list, int e, bool* flag, bool* active_edges){ int bid = blockIdx.x; int tid = threadIdx.x; int id = bid*blockDim.x + tid; long ...
17,196
__global__ void kernel(float* dA, float* dB, float* dC, int dim) { unsigned int idx = threadIdx.x + blockIdx.x*blockDim.x; unsigned int idy = threadIdx.y + blockIdx.y*blockDim.y; if(idx<dim && idy<dim) dC[idx+idy*dim]=dA[idx+idy*dim]+dB[idx+idy*dim]; }
17,197
#include <stdlib.h> #include <string.h> #include <math.h> #include <iostream> #include <fstream> #include <cmath> #include <iomanip> using namespace std; using std::cout; using std::endl; /*------------------------------------------------------------------------------------ Written by Gautam Machiraju, Mallick Lab Gl...
17,198
#include "includes.h" __global__ void UpdateScalars(float *WHAT , float *WITH , float AMOUNT , float *MASS) { int idx = threadIdx.x + blockIdx.x * blockDim.x; // this defines the element WHAT[idx] += AMOUNT*WITH[idx]/MASS[idx]; }
17,199
#include <limits> /** * Configuration indexes. */ #define KERNEL_0 conf[0] #define KERNEL_1 conf[1] #define X_IMAGE_SIZE conf[2] #define X_FEATURE_SIZE conf[3] #define X_ROW_SIZE conf[4] #define N conf[5] #define Y_IMAGE_SIZE conf[6] #define Y_FEATURE_SIZE conf[7] #define Y_ROW_SIZE conf[8] /** * Compute the kerne...
17,200
extern "C" { __global__ void distoring_mirror(float3 * src,float3 * dst,int imgWidth,int imgHeight,int x,int y){ float radius = 0.0; float theta = 0.0; float map_x = 0.0; float map_y = 0.0; float map_r = 0.0; int xIndex = threadIdx.x + blockIdx.x * blockDim.x; int yIndex = threadIdx.y ...