serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
17,501
/****************************************************************************** *cr *cr (C) Copyright 2010 The Board of Trustees of the *cr University of Illinois *cr All Rights Reserved *cr *****************************************************************...
17,502
#include "includes.h" __global__ void cunn_OneVsAllMultiMarginCriterion_updateOutput_kernel(float *output, float *input, float *target, int nframe, int dim, int sizeaverage, float *positiveWeight) { __shared__ float buffer[MULTIMARGIN_THREADS]; int k = blockIdx.x; float *input_k = input + k*dim; float *output_k = outpu...
17,503
#include "includes.h" static const int NTHREADS = 32; __global__ void cunn_ClassNLLCriterion_updateOutput_kernel(float *output, float *total_weight, float *input, float *target, float *weights, int size_average, int nframe, int ndim, int n_classes) { __shared__ float shInputs[NTHREADS], acc_weight[NTHREADS]; int...
17,504
#include <stdlib.h> #include <stdio.h> #define BLOCK_SIZE 512 #define INITIAL_STEPS_SIZE 1024*1024 //assuming everything fits in 1GB of memory #define DELTA_X 64*1024 //Saying the 1 meter bar is going to be divided by 1 million slices __device__ double **t; __device__ long long step = 0; __device__ double K_d; __de...
17,505
#include <cstdlib> #define PI 3.1415926535897932384626433832795029f #define PIx2 6.2831853071795864769252867665590058f #define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) #define K_ELEMS_PER_GRID 2048 #define K_PHIMAG_BLOCK_SIZE 512 #define K_Q_BLOCK_SIZE 256 #define K_Q_K_ELEMS_PER_GRID 1024 struct kValues { float Kx; ...
17,506
#include <stdio.h> #include <iostream> #include <cuda.h> #include <cuda_runtime.h> #include <cmath>
17,507
#include "cuda_runtime.h" #include <stdio.h> const int LZ77windowBits = 11; const int LZ77matchBits = 16 - LZ77windowBits; const int LZ77windowMask = (1 << LZ77windowBits) - 1; const int LZ77matchMask = (1 << LZ77matchBits) - 1; const int LZ77windowSize = 1 << LZ77windowBits; const int LZ77matchSize = 1 << LZ77matchB...
17,508
#include "includes.h" __global__ void resetParticlesKernel(float3* pos, float3* vel, float* age, float* life, int nParts) { unsigned int x = blockIdx.x*blockDim.x + threadIdx.x; int n = x; if (n<nParts) { pos[n] = make_float3(0.0,0.0,0.0); vel[n] = make_float3(0.0,0.0,0.0); age[n] = 1.0; life[n] = 1.0; } }
17,509
#include "includes.h" __global__ void addTwoArraysSharedStatic(int *v1, int *v2, int *r, int n) { int tid = blockDim.x * blockIdx.x + threadIdx.x; if (tid >= n) { return; } __shared__ int s_v1[SIZE], s_v2[SIZE], s_r[SIZE]; s_v1[tid] = v1[tid]; s_v2[tid] = v2[tid]; s_r[tid] = s_v1[tid] + s_v2[tid]; r[tid] = s_r[tid...
17,510
#include <iostream> #include <stdlib.h> #include <thread> #include <time.h> #define BLOCK_SIZE 16 // wrap function for device code __device__ int wrap_d(int N, int idx) { if (idx <= 0) { return N - 1; } else if (idx >= N - 1) { return 0; } return idx; } __global__ void updateUniverseKernel(const int ...
17,511
#include<stdio.h> __global__ void parallel_vector_add(int* d_a, int* d_b, int* d_c,int *d_n ) { int i = (blockIdx.x*blockIdx.x)+threadIdx.x; if(i < *d_n){ printf(" I am thread #%d, and about to compute c[%d]. \n",i,i); d_c[i]=d_a[i]+d_b[i]; } else{ printf("I am thread #%d, and doing nothing.\n" , i); } } ...
17,512
#include "includes.h" using namespace std; #define ITERATIONS 40000 enum pixel_position {INSIDE_MASK, BOUNDRY, OUTSIDE}; __global__ void merge_without_blend_kernel(float *srcimg, float *targetimg, float *outimg, int *boundary_array,int source_nchannel, int source_width, int source_height){ int x = threadIdx.x + bloc...
17,513
#include <stdio.h> #define WIDTH 800 #define HEIGHT WIDTH __global__ void kernel(uchar4 * pbo, double centerX, double centerY, double zoom, unsigned maxIterations) { // Calculate the relative thread identifiers int x = blockIdx.x * blockDim.x + threadIdx.x; int y = blockIdx.y * blockDim.y + threadIdx.y; /...
17,514
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> __global__ void suma_vectores_cubo(int *d_v1, int *d_v2, int *d_vr) { int id_vector = blockIdx.x * 8 + threadIdx.x; printf("Id: %d\n", id_vector); d_vr[id_vector] = d_v1[id_vector] + d_v2[id_vector]; } int main() { // Variables d...
17,515
#define BLOCK_SIZE 16 #define BLOCK_DEPTH 4 __global__ void KeypointLocalization(int* flags, float* DoG, int rows, int cols, float contrastThreshold, float curvateThreshold) { __shared__ float tile[BLOCK_DEPTH][BLOCK_SIZE][BLOCK_SIZE]; int tz = threadIdx.z; int ty = threadIdx.y; int tx = threadIdx.x; ...
17,516
#include "includes.h" __global__ void vecMultiplyReverse(int *A, int *B, int *C) { int i = blockIdx.x * blockDim.x + threadIdx.x; if(i%2 == 0) { C[i] = A[i] + B[i]; } else if(i%2 != 0) { C[i] = A[i] - B[i]; } }
17,517
#include <iostream> #include <stdio.h> #include <memory.h> #include <string.h> #include <math.h> #define VCOUNT 5 #define ECOUNT 12 /* 0 - -- - 1 - - - - 2 - - - - 3 - -- - 4 */ bool frontierNotEmpty(bool* pFrontier, const int size); void print(bool* p, const int size, const int unit);...
17,518
/* Produced by CVXGEN, 2018-04-03 18:09:48 -0400. */ /* CVXGEN is Copyright (C) 2006-2017 Jacob Mattingley, jem@cvxgen.com. */ /* The code in this file is Copyright (C) 2006-2017 Jacob Mattingley. */ /* CVXGEN, or solvers produced by CVXGEN, cannot be used for commercial */ /* applications without prior written permis...
17,519
#include "includes.h" __global__ void countIndices(int *indices, unsigned int *histo, int size) { int id = threadIdx.x + blockIdx.x * blockDim.x; int min = blockIdx.x * blockDim.x; int max = (blockIdx.x + 1) * blockDim.x; extern __shared__ unsigned int tmp[]; tmp[threadIdx.x] = 0; __syncthreads(); for (int i = thr...
17,520
//pass: o caso deve passar por causa do assert que sempre é verdadeiro //--blockDim=16 --gridDim=16 --no-inline //a = 12 //b = 36 //c = 48 #include <stdio.h> #include <cuda.h> #include <cuda_runtime_api.h> #include <assert.h> #define N 2//16 __global__ void example(unsigned a, unsigned b, unsigned c) { //__requi...
17,521
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> __global__ void matAdd(int *A, int *B, int *C, int *n, int *col2) { int i = blockIdx.x; int row1 = gridDim.x; for (int j = 0; j < *col2; j++) { C[i * (*col2) + j] = 0; for (int k = ...
17,522
/* Copyright (c) 1993-2015, NVIDIA CORPORATION. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of ...
17,523
#include <stdio.h> #include <sys/ipc.h> #include <sys/msg.h> #include <string.h> #include <unistd.h> #define TO_SCHEDULER 1 #define KERNEL_REGISTER 1 #define SLICE_CALLED 2 int is_round_robin = 0; #define min(a, b) ((a) < (b)) ? (a) : (b) typedef struct msg_buffer { long type; char content[50]; } msg_buf; t...
17,524
extern "C"{ __global__ void double_chop_pairs_pure_cuda( float* x1, float* y1, float* z1, float* w1, int* cell1, float* x2, float* y2, float* z2, float* w2, int* indx2, float* rbins_squared, float* result, int n1, int nbins) {// array attributes must be explicitly passed in. /* Direct trans...
17,525
#include<stdlib.h> #include<stdio.h> #include<time.h> __global__ void scan(float *d_in,float *d_out,const int size){ int idx = threadIdx.x; d_out[idx] = d_in[idx]; __syncthreads(); float out; for(int step=1;step<size;step*=2){ if(idx-step>=0){ out = d_out[idx]+d_out[idx-step]; /* __syncthreads(); d_...
17,526
#include "output.cuh" void output_time ( const int n_gr, const char *type1, const int n_go, const char *type2, const int n_pkj, const char *type3, const int n_io, const char *type4, const double comp_time, const int sim_time ) { FILE *time_plot; time_plot = fopen ( "compti...
17,527
#include <iostream> #include <stdlib.h> #include <time.h> #include <iomanip> #include <sys/time.h> #include <cuda.h> using namespace std; #define MAX_ARRAY_SIZE 4096 #define RANDOM_MAX 2.0 #define RANDOM_MIN 1.0 float A[MAX_ARRAY_SIZE][MAX_ARRAY_SIZE]; float F[MAX_ARRAY_SIZE][MAX_ARRAY_SIZE]; void serial(); void ...
17,528
#include <stdlib.h> #include <stdint.h> #include <stdio.h> #include <utility> __global__ void add_ballot (uint64_t *T, int *B, int C) { int x = blockIdx.x; int y = blockIdx.y; int cutoff = blockIdx.z; if (B[x] > cutoff && B[y] > cutoff) T[cutoff *C*C + x *C + y]++; } __global__ void calculate_scores (double *S,...
17,529
#include <type_traits> #ifdef _WIN32 # define EXPORT __declspec(dllexport) #else # define EXPORT #endif using tt = std::true_type; using ft = std::false_type; EXPORT int __host__ shared_cuda11_func(int x) { return x * x + std::integral_constant<int, 17>::value; }
17,530
// Solve the Laplace equation on a 2D lattice with boundary conditions. // // compile with the following command: // // (for GTX970) // nvcc -arch=compute_52 -code=sm_52,sm_52 -O3 -m64 -o laplace laplace.cu // // (for GTX1060) // nvcc -arch=compute_61 -code=sm_61,sm_61 -O3 -m64 -o laplace laplace.cu // Includes #incl...
17,531
#include "includes.h" __global__ void ker_sparse_to_dense_block_assign_and_multiply(int n, const unsigned *idx, int bsize, float mult, float* src, float *trg) { // Get our global thread ID int id = blockIdx.x*blockDim.x+threadIdx.x; // Make sure we do not go out of bounds if (id < n*bsize) trg[id] = src[idx[id/bsize]*...
17,532
#include "includes.h" __global__ void x24(float* x25, float* x26, float* x27, int x28) { int x29 = gridDim.x * blockDim.x; int x30 = threadIdx.x + blockIdx.x * blockDim.x; while (x30 < x28) { int x31 = x30; x27[x31] = x25[x31] * x26[x31]; x30 = x30 + x29; } }
17,533
#include <cuda.h> #include <iostream> using namespace std; void load_n_launch(CUmodule& module, int i, int* output, int* output_d){ CUfunction kernel; string kernel_name = "list" + to_string(i); cuModuleGetFunction(&kernel, module, kernel_name.c_str()); void * args[] = {&output_d}; cuLaunchKernel(kernel, 1...
17,534
#include <stdio.h> #include <string.h> #include <stdlib.h> #define MAX_VALUE 5600 #define MAX_STRING_LENGTH 4096 #define CHECK_ERR(x) \ if (x != cudaSuccess) { \ fprintf(stderr,"%s in %s at line %d\n", \ cudaGetErrorString(err),__FILE__...
17,535
#include "includes.h" __global__ void cu_interpolation(const float* src, float* dst, const int colssrc, const int colsdst, const int _stride, const int n){ int tid = threadIdx.x + blockIdx.x * blockDim.x; int stride = blockDim.x * gridDim.x; while(tid < n){ int csrc = tid % colssrc; int rsrc = tid / colssrc; int rdst =...
17,536
#include "includes.h" __global__ static void update_e(int objs,double* e,double* kval,double b_old,double b_new,int i,int j,int yi,int yj,double ai_old,double ai_new,double aj_old,double aj_new){ int id=blockDim.x * blockIdx.x + threadIdx.x; if (id<objs){ double val=e[id]; val+=(b_new-b_old); double ti=yi*kval[i*objs+i...
17,537
#include "includes.h" __global__ void fillKernel(int *a, int n) { int tid = blockIdx.x * blockDim.x + threadIdx.x; if (tid < n) a[tid] = tid; }
17,538
/* Author: Andrew DiPrinzio Course: EN605.417.FA Assignment: Module 5 */ #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <stdint.h> #include <assert.h> #include <time.h> #include <math.h> static const uint32_t DEFAULT_NUM_THREADS = 1024; static const uint32_t DEFAULT_BLOCK_SIZE = 16; #define KER...
17,539
// dimensions layout: // 0-2 target offset_size (flat) // 3-5 source and inclusion size (incremental) // 6-8 filter size (not incremental) // 9 sample_count __global__ void cuda_filter_tips( float *target_image, float const *const source_image, float const *const inclusion_image, ...
17,540
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> __global__ void addArraysGPU(int* a, int* b, int* c) { int i = threadIdx.x; c[i] = a[i] + b[i]; } int main() { // Constante const int count = 5; const int size = count * sizeof(int); // Arrays - Memria RAM ...
17,541
#include "includes.h" __global__ void gpu_square_matrix_mult(int *d_a, int *d_b, int *d_result, int n) { __shared__ int tile_a[BLOCK_SIZE][BLOCK_SIZE]; __shared__ int tile_b[BLOCK_SIZE][BLOCK_SIZE]; int row = blockIdx.y * BLOCK_SIZE + threadIdx.y; int col = blockIdx.x * BLOCK_SIZE + threadIdx.x; int tmp = 0; int idx; ...
17,542
#include <iostream> #include <math.h> #include <cstdlib> #include <ctime> // CUDA kernel to multiply elements of two arrays #define A_HEIGHT 1000 #define B_WIDTH 1000 #define AB_SHARED 1000 //declare global variables float* A; float* B; float* C; float* D; int N; void matrix_mult_nonthreaded(){ int i,j,k; for(i=0;...
17,543
#include "includes.h" // Include files // Parameters #define N_ATOMS 343 #define MASS_ATOM 1.0f #define time_step 0.01f #define L 10.5f #define T 0.728f #define NUM_STEPS 10000 const int BLOCK_SIZE = 1024; //const int L = ; const int scheme = 1; // 0 for explicit, 1 for implicit /**********************************...
17,544
#include "includes.h" __global__ void gemm(float* A, float* B, float* C, int m, int n, int k) { // Block row and column int blockRow = blockIdx.y; int blockCol = blockIdx.x; // Thread row and column within Csub int row = threadIdx.y; int col = threadIdx.x; // Each thread block computes one sub-matrix Csub of C float...
17,545
#include "includes.h" __global__ void elementMulMatrixKernel(double *dev_w, const double *dev_U, const double *dev_V, unsigned int index_row_i, unsigned int index_column_j, unsigned int dim1_U, unsigned int dim1_V) { //-----------------------------------------------------------------------------------------------------...
17,546
#include <stdio.h> //The following trellis functions are written specifically for //g1(D)/g2(D) = (1 + D + D3 )/(1 + D2 + D3 ) //Need to be generalised int next_state(int current_state, int input) { int cpu_beta_state_0[8] = {0, 4, 5, 1, 2, 6, 7, 3}; int cpu_beta_state_1[8] = {4, 0, 1, 5, 6, 2, 3, 7}; int temp=5; i...
17,547
#include "includes.h" __global__ void kernelAdd(float *dvalues, int numOperations, int firstInd, int nextColInd) { int vi = firstInd + blockIdx.x * blockDim.x + threadIdx.x; // "numOperations" is the 2nd input parameter to our executable if (vi < nextColInd) { for (int j=0; j<numOperations; ++j) { // The operation per...
17,548
#include <stdlib.h> #include <math.h> #include <stdio.h> #include <time.h> # define NPOINTS 2000 # define MAXITER 2000 #define SIZE NPOINTS*NPOINTS*sizeof(int) struct complex{ double real; double imag; }; __global__ void mandelbrot(int npoints, int max, int *num){ double ztemp; struct complex z, c; int...
17,549
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <iostream> #include <math.h> #include <fstream> #include <time.h> using namespace std; #define TILE 25 __global__ void CUDAedge( int *a, const int b) { int pos = threadIdx.x; int min[9] = { a[pos], a[pos+1], a[pos-1], a[pos+b], a[pos+b+1], a[pos...
17,550
__global__ void stopKernel(int *color, int *shouldStop, int NodeNum) { for(int i=blockIdx.x*blockDim.x+threadIdx.x; i<NodeNum; i=i+gridDim.x*blockDim.x) { if(color[i] == 0) *shouldStop = 0; } }
17,551
/* Program : To find the run-time of matrix multiplication using tiling for different tile sizes * Author : Anant Shah * Roll Number : EE16B105 * Date : 10-9-2018 */ #include<stdio.h> #define ERROR_HANDLER(error_msg,line) error_handler(error_msg,line) #define T_1 4 #define T_2 8 #define T_3 16 #define T_4 32 #de...
17,552
#include <stdio.h> __global__ void kernel(void) { int bid = blockIdx.x; int tid = threadIdx.x; printf("Hello from block %d, thread %d of the GPU\n", bid, tid); } int main (void) { kernel<<<3,4>>>(); // 3 blocks, 4 threads per block cudaDeviceSynchronize(); printf("Hello, World\n"); return ...
17,553
#include "includes.h" __global__ void max_pooling(unsigned char* original_img, unsigned char* new_img, unsigned int width, unsigned int num_thread, unsigned int size) { unsigned int position; unsigned char max; for (int i = threadIdx.x; i < size/4; i = i + num_thread) { position = i + (4 * (i / 4)) + (width * 4 * (i / ...
17,554
__global__ void kernel() { } int main() { kernel<<<1,1>>>(); return cudaDeviceSynchronize(); }
17,555
#include "includes.h" #define N 33 * 1024 #define threadsPerBlock 256 #define blocksPerGrid (N + threadsPerBlock - 1) / threadsPerBlock #define RADIUS 2 // Signal/image element type typedef int element; // 1D MEDIAN FILTER implementation // signal - input signal // result - output signal // N - leng...
17,556
/** * All threads increments a counter in global memory * by one. The difference is that one uses CUDA's atomic function * to perform an increment. * What to observe/ponder: * - What are the values that are printed out? * - Are they consistent across runs? */ #include <stdio.h> __device__ __managed__ int count...
17,557
#include <stdio.h> #include <stdlib.h> #include <cuda_runtime.h> #include <assert.h> #define BLOCK_SIZE 16 __global__ void gpu_matrix_mult(int *a,int *b, int *c, int m, int n, int k) { int row = blockIdx.y * blockDim.y + threadIdx.y; int col = blockIdx.x * blockDim.x + threadIdx.x; int sum = 0; if( c...
17,558
/* * Copyright (c) 2019 Opticks Team. All Rights Reserved. * * This file is part of Opticks * (see https://bitbucket.org/simoncblyth/opticks). * * 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 ...
17,559
#include <cuda_runtime.h> #include <iostream> using std::cout; using std::endl; #define CUDA_CHECK(x) \ { cudaError_t cuda_error = x; \ if (cuda_error != cudaSuccess) \ cout << "cudaError_t: " << cuda_error << " != 0 " \ << cudaGetErrorString(cuda_error) << endl; \ } #def...
17,560
float h_A[]= { 0.6171344124702118, 0.758653247824508, 0.9239071226893198, 0.6922981676449962, 0.6447658337262208, 0.7414949586971757, 0.8330911176380404, 0.8433334185736439, 0.6071239106681812, 0.6749738189793472, 0.6006782914043483, 0.9868891309858707, 0.801377714315752, 0.7152948999292807, 0.9230394590840756, 0.78769...
17,561
#include <cuda.h> #include <cuda_runtime.h> #include <device_launch_parameters.h> #include "cuda_kernel.cuh" __global__ void mirror_rotate_kernel(uint* src, uint* dst, size_t rows, size_t cols) { // Allocate shared memory for block __shared__ uint smem[32 * 32 * 8]; //...
17,562
char *title = "Erosion and Dilation filter"; char *description = "Erosion and Dilation filter"; /* Фильтр «минимум» – также известный как фильтр эрозии, заменяет значение минимальным в окрестности. Фильтр «максимум» – также известный как фильтр расширения, заменяет значение максимальным в окрестности. */ #include <io...
17,563
// Copyright 2020 Christopher Khan // 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 // Unless required by applicable law or agreed to in w...
17,564
/* Copyright 2009 Colin Percival, 2011 ArtForz, 2011-2013 pooler, * 2013 David G. Andersen * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must reta...
17,565
#include <cuda.h> #include <iostream> #include <math.h> #include <ctime> #include <cmath> #include <stdlib.h> #include <fstream> #include <sstream> #include <curand.h> #include <curand_kernel.h> #define PI 3.14159265358979323846 __device__ double densityMW(double Xold, double Xnew, double sigma, double r, double del...
17,566
#include <stdio.h> #include <cuda_profiler_api.h> __global__ void cuda_hello(){ printf("Hello World from GPU!\n"); } int main() { cudaProfilerStart(); cuda_hello<<<1,1>>>(); cudaDeviceSynchronize(); cudaDeviceReset(); cudaProfilerStop(); return 0; }
17,567
//Based on the work of Andrew Krepps #include <chrono> #include <fstream> #include <random> #include <stdio.h> #include <string> // Uses the GPU to add the block + thread index in array_a to array_b to array_results __global__ void add_arrays( const int* const array_a, const int* const array_b, int* const...
17,568
#include <stdio.h> #include <iostream> #include <fstream> #include <iterator> #include <curand.h> #include <curand_kernel.h> #define N 10 #define CHARS_PER_PASSWORD 30 #define M 11000 #define THREADS_PER_BLOCK 512 using namespace std; __device__ char* findPassword(char *grid, int x, int n); __device__ char* generate...
17,569
#include "includes.h" __global__ void fillImage(int width, int height, int value, int* devOutput) { int x = blockDim.x * blockIdx.x + threadIdx.x; int y = blockDim.y * blockIdx.y + threadIdx.y; int index = y * width + x; if ((y < height) && (x < width)) { devOutput[index] = value; } }
17,570
#include "includes.h" __global__ void kernelReadMotionEnergyAsync(float* gpuConvBufferl1, float* gpuConvBufferl2, int ringBufferIdx, int bsx, int bsy, int n, float* gpuEnergyBuffer) { int bufferPos = threadIdx.x + blockIdx.x * blockDim.x; if(bufferPos < n) { // Offset in ringbuffer int bufferPosConv = bufferPos + ringB...
17,571
#include "includes.h" __global__ void DeviceMultiply(double* left, double* right, double* result, int left_rows, int left_cols, int right_cols) { int i = threadIdx.y; int j = threadIdx.x; int x_stride = blockDim.x; int y_stride = blockDim.y; __shared__ double temp[16][16]; for (int y_offset = 0; i + y_offset < left_row...
17,572
#include "includes.h" __global__ void cudaKernel_estimateSnr(const float* corrSum, const int* corrValidCount, const float* maxval, float* snrValue, const int size) { int idx = threadIdx.x + blockDim.x*blockIdx.x; if (idx >= size) return; float mean = (corrSum[idx] - maxval[idx] * maxval[idx]) / (corrValidCount[idx] ...
17,573
#include "includes.h" const int Nthreads = 1024, maxFR = 100000, NrankMax = 3, nmaxiter = 500, NchanMax = 32; ////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////...
17,574
#include "includes.h" __global__ void TgvMedianFilter3DKernel3(float* X, float* Y, float *Z, int width, int height, int stride, float *X1, float *Y1, float *Z1) { const int ix = threadIdx.x + blockIdx.x * blockDim.x; const int iy = threadIdx.y + blockIdx.y * blockDim.y; const int pos = ix + iy * stride; if (ix >= wid...
17,575
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> //// notes using namespace std; /////////////////////////////////////////////////////////////////////////////// // GPU code to calculate the bin number. // This assumes that you have normalized your data that you want to plot to // lie betwee...
17,576
#define NODE_TERMINAL -1 #define NODE_TOSPLIT -2 #define NODE_INTERIOR -3 __global__ void catUnpack(int *nodestatus, float *xbestsplit, int *bestvar, int *cat, int maxcat, int *cbestsplit, int maxTreeSize) { int threadi = threadIdx.x; int treeOffset = threadi*maxTreeSize; int i, j; unsigned int npa...
17,577
#include "includes.h" __global__ void STREAM_Scale_double(double *a, double *b, double scale, size_t len) { size_t idx = threadIdx.x + blockIdx.x * blockDim.x; while (idx < len) { b[idx] = scale* a[idx]; idx += blockDim.x * gridDim.x; } }
17,578
#include <stdio.h> #include <stdio.h> #include <stdlib.h> // #include "lodepng.h" __global__ void square(int *height, int *width, int *result){ *result = *height * *width; } int main(void){ int width, height, result; int *gpuWidth, *gpuHeight, *gpuResult; cudaMalloc(&gpuWidth, sizeof(int)); cudaMalloc(&gpuHeig...
17,579
//Alfred Shaker //Octtober 30th 2015 //Matrix Multiply #include <stdio.h> #include <stdlib.h> #include <math.h> //CUDA kernel function __global__ void matrixMultiply(float* a, float* b, float* c, int n) { //use block dimentions to calculate column and row int col = blockIdx.x*blockDim.x + threadIdx.x; int row = bl...
17,580
#include <cmath> __global__ void my_copysign(double* v) { int i = threadIdx.x; *v = std::copysign(*v, double(i == 0 ? 1 : -1)); }
17,581
//programma calcolo prod scalare tra 2 vettori #include <cuda.h> #include <stdio.h> #include <iostream> #include <time.h> using namespace std; //input: n size vettori, n blocchi, nthread per blocco (NB: in questo esempio non si mappa 1 cella array input con un thread) //questo esercizio usa il paradigma gather (ogni ...
17,582
// PROJECT: Ultrasonic tomographic imaging source code GPU // Distribution is limited // Date: December 15th, 2013 // University of Maryland Eastern Shore, Salisbury University, Florida International University // // AUTHORS: // Pedro D Bello-Maldonado, pbell005@fiu.edu, (786) 203-9025 // Yuanwei Jin, yjin@umes.edu, (...
17,583
#include "includes.h" #define SIZE 30000 //Length and width of inner grid in threads #define DIM (SIZE + 2) //Length and width of the entire grid in threads #define GRID_SIZE 1500 //Length and width of inner grid in blocks #define BLOCK_SIZE 20 //Length and width of block in threads #define MEM_SIZE (sizeof...
17,584
//g++ -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_OMP -I../../../thrust/ -fopenmp -x c++ stock-apple-micro.cu -o stock-apple-micro-cpu && ./stock-apple-micro-cpu < stocks2.csv #include <thrust/device_vector.h> #include <thrust/host_vector.h> #include <iostream> int main() { int N = 0; thrust::host_vector<doub...
17,585
#include <stdio.h> #include <stdlib.h> #include <stdint.h> __global__ void silly_kernel(int n, int* in, int* out) { if (threadIdx.x == 0){ int acc = 0; for (int i = 0; i < n; ++i){ acc += in[i]; out[i] = acc; } } } #define SIZE 10 int main(int argc, char **argv) { ...
17,586
/* 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,587
#include <cuda_runtime.h> #include <iostream> #include <cstdlib> using namespace std; __global__ void cuda_saxpy(float alpha, float* x, float*y, size_t size) { size_t i = threadIdx.x; if (i < size) y[i] += alpha * x[i]; } __global__ void cuda_sscal(float alpha, float* x, size_t size) { size_t i = threadIdx.x; ...
17,588
#include <iostream> #include <numeric> #include <thrust/sort.h> #define checkCUDA(expression) \ { \ cudaError_t status = (expression); \ if (status != cudaSuccess) { \ std::ce...
17,589
/* objective * c = A*b // A[m][n] is a matrix, b[n] and c[m] are vectors * compile: nvcc --gpu-architecture=compute_60 --gpu-code=sm_60 -O3 matvec.cu -o matvec */ #include <iostream> #include <cstdlib> #define EC(ans) { chkerr((ans), __FILE__, __LINE__); } inline void chkerr(cudaError_t code, const char *file, ...
17,590
#include <cuda.h> #include <iostream> #include <string> using namespace std; void launch_(CUfunction kernel, string name, int* output, int* output_d){ void * args[] = {&output_d}; cuLaunchKernel(kernel, 1, 1, 1, 32, 1, 1, 128, 0, args, 0); cudaDeviceSynchronize(); cudaMemc...
17,591
#include <stdio.h> #include <stdlib.h> #include <cuda.h> #include <cuda_runtime.h> #include <device_launch_parameters.h> #ifndef NDEBUG #define CHECK_STATUS(status) \ if (status != cudaSuccess) \ fprintf(stderr, "File: %s\nLine:%d Function:%s>>>%s\n", __FILE__, __LINE__, __FUNCTION__,\ cudaGetErro...
17,592
extern "C" __global__ void pagerank_kernel(float *d_vertices, const int *d_edge_index, float *d_edges, const int *d_edge_num, int size) { float sum = 0; float pagerank = 0; float pagerankcount = 0; int i = blockDim.x * blockIdx.x + threadIdx.x; if (i >= size) return; int num_in = d_edge_num[i * 2]; int nu...
17,593
// kernel to convert from OpenCV channel representation to channel-first // see: https://docs.opencv.org/2.4/doc/tutorials/core/how_to_scan_images/how_to_scan_images.html#how-the-image-matrix-is-stored-in-the-memory const int BLOCK_SIZE = 1024; #include <cuda_runtime.h> __global__ void channelFirstKernel(unsigned cha...
17,594
/* * JCuda - Java bindings for NVIDIA CUDA driver and runtime API * http://www.jcuda.org * * * This code is based on the NVIDIA 'reduction' CUDA sample, * Copyright 1993-2010 NVIDIA Corporation. */ extern "C" __global__ void sum(float *g_idata,float *g_odata, unsigned int n) { extern __shared__ float sdata[]; ...
17,595
#include <stdio.h> #include <iostream> #include <chrono> #include <cuda.h> #include <cuda_runtime.h> #include <math.h> #include <stdlib.h> #include <time.h> using namespace std; __global__ void saxpy(float x[],float y[],float a,int N){ //printf("Hello World! My threadId is %d\n",threadIdx.x); //printf("I am a...
17,596
#include "includes.h" #define N 100 __global__ void add(int *a, int *c) { int tID = blockIdx.x; if (tID < N) { c[tID] = 3*a[tID]; } }
17,597
#include "includes.h" __global__ void CalculateFixed( const float *subBG, const float *subT, const int *subM, float *fixed, const int wb, const int hb, const int wt, const int ht, const int oy, const int ox ){ const int dir[16][2] = {{-2, -2}, {0, -2}, {2, -2}, {-1, -1}, {0, -1}, {1, -1}, {-2, 0}, {-1, 0}, {1, ...
17,598
// Written by Vasily Volkov. // Copyright (c) 2008, The Regents of the University of California. // All rights reserved. #include <time.h> #include "sgemmN.cuh" #include "cuda_runtime.h" #define BLOCK_SIZE 32 __device__ void saxpy( float a, float *b, float *c ) { c[0] += a*b[0]; c[1] += a*b[1]; c[2] +=...
17,599
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include "sys/time.h" #define DefNumPD 517 // Default Number of Points per Dimension #define DefNumI 10 // Default Number of Iterations #define DefExp 0 // Default Value to Export Data (0 = None, 1 = All, 2 = Last) enum Data_Types { CHAR_T...
17,600
#include "cuda_runtime.h" //#include "device_launch_parameters.h" #include <iostream> #include <stdio.h> // sum array of integers sequentially (using cache) void arraySum(int *arr, int arraySize, int *sumValue) { int tempSum = 0; for (int i = 0; i < arraySize; i++) { tempSum += arr[i]; } *sumValue = tempSum; }...