serial_no
int64
1
24.2k
cuda_source
stringlengths
11
9.01M
21,401
#include "utilities.cuh" cudaError_t arrayMalloc(void*** array, int length, size_t* size) { cudaError_t cudaStatus; for (int i = 0; i < length; i++) { cudaStatus = cudaMalloc(array[i], size[i]); if (cudaStatus != cudaSuccess) { fprintf(stderr, "cudaMalloc failed!\n"); goto Error; } } Error: for (s...
21,402
# include <cuda.h> # include <cuda_runtime.h> # include <vector_types.h> # include <device_launch_parameters.h> # include <cstdio> # ifdef WIN32 # include <time.h> # else # include <sys/time.h> # endif __global__ void iterMandel(int niterMax, int n, int* mandel ) { int t_x, t_y, iter; float step, zr; float2 z...
21,403
/* \file TestExceptions.cu \author Gregory Diamos <gregory.diamos@gatech.edu> \date Tuesday November 9, 2010 \brief A CUDA assembly test for unstructured control flow mimicking exceptions. */ #include <cstdlib> const unsigned int threads = 512; const unsigned int iterations = 100; __device__ unsigned int outp...
21,404
/* * File: Histogram * Author: Roberts Slisans * Date: 03/24/2015 16:00 * Last updated: 03/24/2014 17:32 */ #include <stdio.h> #include <assert.h> /** * KERNEL cuAdd() - Takes 2 input arrays of same size N and adds them into C. * Locations are found by computing the global index of each thread. * @return ...
21,405
#include "includes.h" __global__ void matrixExp(double *a, double *c, int cr, int cc){ int x = blockIdx.x * blockDim.x + threadIdx.x; // col int y = blockIdx.y * blockDim.y + threadIdx.y; // row if(x < cc && y < cr){ c[y * cc + x] = exp(a[y * cc + x]); } }
21,406
#include "includes.h" __global__ void max_gradInput(float *input, float *output, float *indices, long nrows, long ncols) { // output offset: long o = threadIdx.x + blockDim.x * blockIdx.x; if (o >= nrows) return; // input offset: long i = o * ncols; // bprop max gradient: long idx = indices[o]-1; input[i+idx] = outpu...
21,407
#include<iostream> #include<string> #include<malloc.h> #include<fstream> #include<sstream> #include<vector> #include<cmath> #include<cstdio> #include<stdlib.h> #include<cuda.h> #include<cuda_runtime.h> #define MAX_CLUSTER_SIZE 6 #define BLOCK_SIZE 16 using namespace std; typedef vector<double> record_t; typedef vector...
21,408
#include "cuda_runtime.h" #include <stdlib.h> #include <stdio.h> #include <time.h> #define N (4096*4096) #define THREADS_PER_BLOCK 512 __global__ void sumOnGpu(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 sumOnCpu(int ...
21,409
#include <thrust/device_vector.h> #include <thrust/host_vector.h> #include <thrust/random/linear_congruential_engine.h> #include <thrust/random/uniform_real_distribution.h> #include <iostream> // nvcc -std=c++14 -O3 tarefa5.cu -o t5 && ./t5 struct raw_access { __device__ __host__ double operator()(const int &i) ...
21,410
#include "includes.h" using namespace std; // 用宏变长参数来实现 __global__ void merge_sort(int *datas, int n){ int tid=blockDim.x*threadIdx.y+threadIdx.x; extern __shared__ int shared[]; if (tid<n) shared[tid] = datas[tid]; __syncthreads(); int cnt=1; for (int gap=2; gap<n*2; gap<<=1, cnt++){ if (tid%gap==0){ int left=tid+n...
21,411
#include <cuda.h> #include <stdio.h> #include <stdlib.h> __global__ void vecAddKernel(float *A,float * B,float *C,int n){ int i=threadIdx.x+blockDim.x+blockIdx.x; if(i<n){ C[i]=A[i]+B[i]; } } // & address * value; void vecAdd(float *h_A, float *h_B, float *h_C,int n){ int size= n * sizeof(float); float *d_A,*d_...
21,412
#include <stdio.h> #include <cuda.h> __device__ int getnum(char *queryArray, int &i) { int ans=0; while(queryArray[i]==' ' || queryArray[i]=='\t') i++; while(queryArray[i]<=57 && queryArray[i]>=48) { ans = ans*10 + (queryArray[i]-'0'); i++; } while(queryArray[i]==' ' || ...
21,413
__global__ void sinwave_kernal(float4 *pos, unsigned int width, unsigned int hight, float time) { unsigned int x = blockIdx.x * blockDim.x + threadIdx.x; unsigned int y = blockIdx.y * blockDim.y + threadIdx.y; float u = x / (float)width; float v = y / (float)hight; u = u * 2.0f - 1.0f; v = v * 2.0f - 1.0f; float...
21,414
#include "includes.h" __global__ void reverseSort_kernel(unsigned int * d_newArray, unsigned int * d_oldArray, unsigned int numElems) { unsigned int gIdx = blockIdx.x * blockDim.x + threadIdx.x; if (gIdx < numElems) { d_newArray[gIdx] = d_oldArray[(numElems - 1)- gIdx]; } }
21,415
#include <iostream> #include <curand.h> using namespace std; #include <curand.h> struct random_d_array { float *data; int n; random_d_array(int n) :n{n} { cudaMalloc((void**)&data, n*sizeof(float)); curandGenerator_t gen; curandCreateGenerator(&gen, CURAND_RNG_PSEUDO_DEFAULT); curandGenerate...
21,416
#include <cuda.h> #include "cuda_runtime.h" #include <iostream> #include <ctime> #include <stdlib.h> // imported for the random functionality using namespace std; __global__ void AddIntegers(int *arr1, int *arr2, int num_elements) { int id = blockIdx.x * blockDim.x + threadIdx.x; if (id < num_elements) { arr1[id]...
21,417
#include "includes.h" __global__ void block_normalization_kernel(float* histograms, float* descriptor, int histograms_step, int block_grid_width, int block_grid_height, int block_width, int block_height, int num_bins, int cell_grid_width, int block_stride_x, int block_stride_y) { //TODO: make the buffer sizes dependent...
21,418
#include "includes.h" extern "C" { } __global__ void broadcast_backward(float* dx, const float* dy, unsigned int c, unsigned int len) { int tid = blockIdx.x * blockDim.x + threadIdx.x; if (tid < len) { atomicAdd(&dx[tid % c], dy[tid]); } }
21,419
/* * This file is part of cuAutotools. * * cuAutotools is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * cuAutotools is distr...
21,420
/* * Please write your name and net ID below * * Last name: Adam * First name: Steven * Net ID: sna219 * */ /* * This file contains the code for doing the heat distribution problem. * You do not need to modify anything except starting gpu_heat_dist() at the bottom * of this file. * In gpu_heat_di...
21,421
#include "includes.h" __global__ void cube_select_four(int b, int n,float radius, const float* xyz, int* idx_out) { int batch_idx = blockIdx.x; xyz += batch_idx * n * 3; idx_out += batch_idx * n * 32; float temp_dist[32]; float judge_dist = radius * radius; for(int i = threadIdx.x; i < n;i += blockDim.x) { float x = xy...
21,422
#include <iostream> #include <vector> using namespace std; int main() { cerr << "Starting" << endl; int NUM = 100; vector<float> h_vec1(NUM); vector<float> h_vec2(NUM); for (size_t i = 0; i < NUM; ++i) { h_vec1[i] = i * 3; } int *d_vec; cudaMalloc(&d_vec, NUM * sizeof(float)); // copy //...
21,423
#include <iostream> #include <math.h> using namespace std; #define W 500 #define H 500 #define TPB 32 __device__ unsigned char clip(int n) { if (n>255) return n; else if (n<0) return 0; else return n; } __device__ int square(int x) { return (x*x); } __global__ void distKernel(uchar4 *dout, int w, int h, int2 po...
21,424
#include<bits/stdc++.h> using namespace std; #define pi (2.0*acos(0.0)) #define eps 1e-6 #define ll long long #define inf (1<<29) #define vi vector<int> #define vll vector<ll> #define sc(x) scanf("%d",&x) #define scl(x) scanf("%lld",&x) #define all(v) v.begin() , v.end() #define me(a,val) memset( a , val ,sizeof(a) ) #...
21,425
#include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include <math.h> //Dimension of problem grid #define NPROB 240 #define GENERATION 100000 //Size of threads should be multiple of warp's size(32) #define THREAD_NUMBER 64 //Standard inidat void inidat(int nx, bool *u) { int ix, iy; for (ix...
21,426
#include "cuda_includes.cuh" #include <stdlib.h> #include <stdio.h> void HandleError(cudaError_t err, const char* file, int line) { if (err != cudaSuccess) { printf("%s in %s at line %d\n", cudaGetErrorString(err), file, line); exit(EXIT_FAILURE); } } struct Sphere;
21,427
// Device code extern "C" __global__ void scale(float* A, float scalar, int N) { int i = blockDim.x * blockIdx.x + threadIdx.x; if (i < N) A[i] = A[i]*scalar; }
21,428
#include "includes.h" __global__ void cudaSScaleAbs_kernel(unsigned int size, float* input, const float scale, const float beta, float* result) { const unsigned int index = blockIdx.x * blockDim.x + threadIdx.x; const unsigned int stride = blockDim.x * gridDim.x; if (beta != 0.0f) { for (unsigned int i = index; i < si...
21,429
#include "includes.h" __global__ void KerSortDataParticles(unsigned n,unsigned pini,const unsigned *sortpart,const float3 *a,float3 *a2) { const unsigned p=blockIdx.x*blockDim.x + threadIdx.x; //-Particle number. if(p<n){ const unsigned oldpos=(p<pini? p: sortpart[p]); a2[p]=a[oldpos]; } }
21,430
#include "includes.h" __global__ void mask_kernel(int n, float *x, float mask_num, float *mask, float val) { int i = (blockIdx.x + blockIdx.y*gridDim.x) * blockDim.x + threadIdx.x; if(i < n && mask[i] == mask_num) x[i] = val; }
21,431
#include <iostream> #include <iomanip> __global__ void KernelVectorAbs(double *vector, int size){ int i = threadIdx.x + blockIdx.x * blockDim.x; int offset = gridDim.x * blockDim.x; while (i < size) { vector[i] = (vector[i] < 0) ? -vector[i] : vector[i]; i += offset; } } int main(){ std::ios_base::s...
21,432
#include "includes.h" __global__ void cudaDRectifier_propagate_kernel(double* x, double* y, unsigned int size, double leakSlope, int shifting, double clipping) { 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; ...
21,433
#include "includes.h" __global__ void CumulateThroughTimeKernel(float* memoryBlocks, int count, int sequenceLength) { int memoryIdx = blockDim.x * blockIdx.y * gridDim.x + blockDim.x * blockIdx.x + threadIdx.x; if (memoryIdx < count) { for (size_t i = 1; i < sequenceLength; i++) { int memoryBlockOffset = i * count; me...
21,434
/* * * atomic32.cu * * Microdemo for atomic operations on 32-bit integers in global memory. * * NOT INTENDED AS A SAMPLE FOR ANYTHING OTHER THAN CODE GENERATION. * * Build with: * nvcc --gpu-architecture sm_xx --cubin atomic32.cu * cuobjdump --dump-sass atomic32.cubin * (fill in xx with 11, 20, or 3...
21,435
#include "includes.h" __global__ void reduceInterleaved (int *g_idata, int *g_odata, unsigned int n) { // set thread ID unsigned int tid = threadIdx.x; unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x; // boundary check if(idx >= n) return; // in-place reduction in global memory for (int stride = blockDim.x /...
21,436
#include <iostream> #include <stdlib.h> #include <string.h> #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(stderr,"GPUassert: %s %s %d\n", cudaGetErrorString(code), fi...
21,437
#include <cuda.h> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <chrono> #define RGB_COMPONENT_COLOR 255 #define BLUR_SIZE 5 using namespace std; typedef struct { unsigned char red, green, blue; } PPMPixel; typedef struct { int x, y; PPMPixel *data; } PPMImage; unsigned cha...
21,438
#include <stdio.h> #include <sys/time.h> const int N_def (1 << 20); const int threadsPerBlock = 32; //const int blocksPerGrid = (N_def+threadsPerBlock-1) / threadsPerBlock; const int blocksPerGrid = 1; __global__ void cuda_dot(int N, double *a, double *b, double *c) { // __shared__ double localDot[threadsPerBlo...
21,439
/* 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 ...
21,440
#include "includes.h" __global__ void kSoftMaxCrossEntropyRowMajor(float* mat, float* labels, float* target, unsigned int width, unsigned int height, float tiny) { const unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x; const unsigned int numThreads = blockDim.x * gridDim.x; for (unsigned int i = idx; i < heigh...
21,441
// Rishabh Agarwal - 18JE0676 #include <bits/stdc++.h> #include <cuda.h> using namespace std; // kernel functions // compare single point and double point __global__ void CompareKernel(float *da, double *db) { int tid = blockIdx.x * blockDim.x + threadIdx.x; if (tid == 0) { *da = 20.234; *db =...
21,442
#include <stdio.h> #include <stdlib.h> __global__ void add(int *a, int *b, int *c) { c[blockIdx.x] = a[blockIdx.x] + b[blockIdx.x]; printf("hello "); } #define N 512 int main(void) { int *a, *b, *c; int *d_a, *d_b, *d_c; int size = N*sizeof(int); // host copies of a, b, c // device copies of a, b, c // A...
21,443
#include "includes.h" __global__ void addGridThreads(int n, float *x, float *y) { // Let the kernel calculate which part of the input signal to play with, but // now also include the grid information int index = blockIdx.x * blockDim.x + threadIdx.x; int stride = blockDim.x * gridDim.x; for (int i = index; i < n; i += ...
21,444
/* autor fredy m uaem desonses@gmail.com para mas comentarios */ #include <device_functions.h> #include <stdio.h> #include <stdlib.h> #include <cuda_runtime.h> #include <device_launch_parameters.h> #define N 3 /* multiplicacion de matrices con memoria constante */ // definicion de memoria constante CUDA __constant_...
21,445
#include <stdio.h> int main( void ) { cudaDeviceProp prop; int count; cudaGetDeviceCount(&count); for (int i=0; i< count; i++) { cudaGetDeviceProperties(&prop, i); printf( " --- General Information for device %d ---\n", i ); printf( "Device %d: %s\n", i, prop.name ); printf( "CUDA capabi...
21,446
#include "includes.h" __global__ void add(int a, int b, int *c){ *c = a + b; }
21,447
#include <iostream> using namespace std; __global__ void Mat_Mul_Global (float *A, float *B, float *C, int width){ int i = blockIdx.y * blockDim.y + threadIdx.y; //use 2D thread-blocks for convinience, use 1D is also OK. int j = blockIdx.x * blockDim.x + threadIdx.x; if ((i < width) && (j <width)){ // usua...
21,448
#include "includes.h" __global__ void incSumScanB2_kernel(unsigned int* d_outVals, unsigned int* d_inVals, size_t numVals, unsigned int* d_blockOffset) { // unsigned int tIdx = threadIdx.x; unsigned int gIdx = blockIdx.x * blockDim.x + threadIdx.x; extern __shared__ unsigned int s_incScan[]; if (gIdx >= numVals) retur...
21,449
#include <stdio.h> #define N (1024*1024) #define M (1000000) __global__ void cudakernel(float *buf) { /* this line is looking up the address i by taking the thread id (threadIdx.x) adding to block id (blockIdx.x), which is multiplied by the block dimensions This means that each threa...
21,450
__global__ void f1d3(float3 * __restrict__ ptr) { float3 v = ptr[threadIdx.x]; v.x += 1; v.y += 1; v.z += 1; ptr[threadIdx.x] = v; return; } // __global__ void f1(float4 * __restrict__ ptr) { // float4 v = ptr[threadIdx.x]; // v.x += 1; // v.y += 1; // v.z += 1; // v.w += 1; // ptr[...
21,451
#include "includes.h" extern "C" { } __global__ void add(const float* x1, const float* x2, float* y, unsigned int len) { int tid = blockIdx.x * blockDim.x + threadIdx.x; if (tid < len) { y[tid] = x1[tid] + x2[tid]; } }
21,452
#include <float.h> __device__ float euclid2( float* items, float* centers, int itemId, int centerId, int paramsCount) { float sum = 0.0; for(int j = 0; j < paramsCount; j++) { sum = sum + (items[itemId * paramsCount + j] - centers[centerId * paramsCount + j]) * (items[itemId * paramsCount + j] - cent...
21,453
#include <stdio.h> #include <assert.h> #include <curand.h> #include <curand_kernel.h> #include <cuda_runtime.h> #include <unistd.h> #include <math.h> #define SIZE 3 #define BLOCKSIZE 512 #define PI 3.1415926535897932384626433 extern "C" void hello_world(){ printf("oi, fui importada com sucesso. \n"); } extern "C" ...
21,454
// Includes, System #include <iostream> #include <assert.h> #include <chrono> // Here you can set the device ID that was assigned to you #define MYDEVICE 0 // 24%8=0 // Simple utility function to check for CUDA runtime errors void checkCUDAError(const char *msg); /////////////////////////////////////////////////////...
21,455
//3D vector class, floating point precision #include <iostream> #include <cmath> using namespace std; class Vec { public: float x,y,z; __device__ __host__ Vec() { x=0; y=0; z=0; } __device__ __host__ Vec(float x, float y, float z) { this->x = x; this->y = y; this->z = z; } __device__ __host__ Vec add(cons...
21,456
#include "includes.h" const int nblock = 32; ////////////////////////////////////////////////////////////////////////////////////////// __global__ void crossFilter(const double *Params, const float *W1, const float *W2, const float *UtU, float *WtW){ __shared__ float shW1[nblock*81], shW2[nblock*81]; float x; int nt0...
21,457
#include "includes.h" // Second CUDA program // Ping-Che Chen #define BLOCK_SIZE 16 __global__ static void matMultCUDA(const float* a, size_t lda, const float* b, size_t ldb, float* c, size_t ldc, int n) { __shared__ float matA[BLOCK_SIZE][BLOCK_SIZE]; __shared__ float matB[BLOCK_SIZE][BLOCK_SIZE]; const int ti...
21,458
// CUDA code : Add two float vectors together // Device code ( taken form Cuda SDK ) #include <iostream> __global__ void VecAdd(const float* A, const float* B, float* C, int N) { int i = blockDim.x * blockIdx.x + threadIdx.x; if (i < N) C[i] = A[i] + B[i]; } // C interface wrapper - A B C are cudaMall...
21,459
#include <cuda.h> #include <cufft.h> #include <stdio.h> #include <math.h> #define DATASIZE 32768 #define BATCH 16384 /********************/ /* CUDA ERROR CHECK */ /********************/ #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } inline void gpuAssert(cudaError_t code, const char *file, int line,...
21,460
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <sys/time.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> // Location of timetamp file for software watchdog char timestamp_watchdog[200] = "/home/carol/watchdog/timestamp.txt"; // Max errors that can be found fo...
21,461
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <cuda.h> #include "cuda_runtime.h" #include "device_launch_parameters.h" //2015253039 __global__ void helloWorld(char* str) { int idx = blockIdx.x * blockDim.x + threadIdx.x; str[idx] += idx; } int main(int argc, char** argv) { int i; char strin[12] = ...
21,462
#include "includes.h" /****************************************************************************** Displays two grey scale images. On the left is an image that has come from an image processing pipeline, just after colour thresholding. On the right is the result of applying an edge detection convolution operator t...
21,463
#include<iostream> using namespace std; __global__ void print() { printf("hello from gpu thread %d\n",threadIdx.x); } int main() { printf("hello from cpu \n"); print<<<1,10>>>(); }
21,464
#include "includes.h" __global__ void kernel_hadamard_fl(int N, float *wt, float *x){ unsigned int tid = blockIdx.x*blockDim.x + threadIdx.x; /* make sure to use only M threads */ if (tid<N) { x[tid]*=wt[tid]; } }
21,465
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> #include <ctime> // Includes CUDA #include <cuda_runtime.h> #define LINEWIDTH 20 #define NWORDS 32 #define N_STREAMS 8 #define BLOCK_SIZE 32 #define TITLE_SIZE 1 int length; int len; int nwords; int matches[NWORDS]; char *ctext; char keyword...
21,466
/* Authors - Dibyadarshan Hota 16CO154 - Omkar Prabhu 16CO233 */ #include <iostream> #include <stdio.h> #include <sstream> #include <string.h> #include <cuda.h> #define ll long long using namespace std; /** * Kernel for computing Betweenness Centrality * res: Stored in global memory variable bc */ __global__ voi...
21,467
#include <stdio.h> #include <cuda.h> struct node { int data; struct node *next; }; __device__ struct node *head; __device__ struct node *getNewNode() { unsigned id = blockIdx.x * blockDim.x + threadIdx.x; struct node *newnode = (struct node *)malloc(sizeof(struct node)); newnode->data = id; newnode->next = NUL...
21,468
#include <stdio.h> #include <cuda.h> #include <cuda_runtime.h> #include <curand_kernel.h> #include <stdlib.h> #include <math.h> #include <sys/time.h> #include <time.h> #include <string.h> #define PI 3.1415926536 #define e 2.718281828459 #define N 64*64 #define PATCH 3 #define RADIUS (PATCH-1)/2 #define THREADS_PER_BL...
21,469
#include "includes.h" __device__ float sigmoid(float data){ return 1./(1. + expf(-data)); }; __global__ void yoloKernel(const int n,const float * input, float* output, const int* anchors,int anchor_num, int classes,int height,int width,float down_stride,float thresh){ const int idx = blockIdx.x * blockDim.x + threadIdx...
21,470
#include "includes.h" __global__ void add(int *a, int *b, int *c) { //blockDim is num threads/block, multiplied by block number to index to one of them, then select thread inside block via thread Id int threadID = threadIdx.x + blockIdx.x * blockDim.x; //Max 65 535 blocks, with 512 threads each ~ 8 million elements, if...
21,471
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> #include <ctime> // Includes CUDA #include <cuda_runtime.h> #define LINEWIDTH 20 #define NWORDS 32 #define CUDA_STREAMS 1 #define BLOCK_SIZE 32 #define TITLE_SIZE 4 int length; int len; int nwords; int matches[NWORDS]; char *ctext; char keyw...
21,472
#include "includes.h" __global__ void fill(float * w, float val, int size) { const int tid = (blockIdx.x * blockDim.x) + threadIdx.x; if (tid < size) w[tid] = val; }
21,473
// ------------------- // Generic // ------------------- __global__ void indexShiftDown(int *d_rows, const int m){ unsigned int xIndex = blockDim.x * blockIdx.x + threadIdx.x; if (xIndex < m) d_rows[xIndex] = d_rows[xIndex]-1; } __global__ void indexShiftUp(int *d_rows, const int m){ unsigned int xIndex = bloc...
21,474
#include "includes.h" #define BLOCK_SIZE 16 #define HEADER_SIZE 122 #define BLOCK_SIZE_SH 18 typedef unsigned char BYTE; /** * Structure that represents a BMP image. */ typedef struct { int width; int height; float *data; } BMPImage; typedef struct timeval tval; BYTE g_info[HEADER_SIZE]; // Reference header ...
21,475
#include <stdio.h> #include <errno.h> #include <arpa/inet.h> #include <unistd.h> #include <string.h> #include "cs_header.h" int cs_put_header( int fd, char coding, char opt, char m, int x, int y, int xb, int yb, int zb, int xc0, int yc0, int zc0, int xc1, int yc1, int zc1, int xc2, int yc2, int zc2, int xo, int...
21,476
#include "includes.h" __global__ void ComputeInternalEnergy_kernel(float *Rho, float *Vx, float *Vy, float *Vz, float *Etot, float *Eneint, float *Bx, float *By, float *Bz, int size) { // get thread and block index const long tx = threadIdx.x; const long bx = blockIdx.x; const long by = blockIdx.y; int igrid = tx + bx...
21,477
#include <cuda.h> int main(void){ }
21,478
// // Created by root on 2020/11/19. // #include "stdio.h" #include "cuda_runtime.h" #define BDIMX 32 #define BDIMY 32 __global__ void transposeNaiveGem(int *in, int *out, int nx, int ny) { int x = threadIdx.x + blockIdx.x * blockDim.x; int y = threadIdx.y + blockIdx.y * blockDim.y; if (x < nx && y < ny...
21,479
#include <stdio.h> #include <errno.h> #include <unistd.h> #include <string.h> extern int errno; /* Function that saves the Image */ void writeImg(char *in_filename,float *data, int dataRows,int attributes){ FILE *fp; int counter=1; char delim = ','; char *filename; filename = strtok(in_filename,"."); filename = ...
21,480
#include <stdio.h> #include <cuda.h> #include <time.h> #include <stdlib.h> #include <string.h> __global__ void mul( float *Ad, float *Bd, float *Cd, int msize, int tile, int task); int main( int argc, char **argv){ // argv[0]: name, argv[1]: msize, argv[2]: tile_width/ per block, argv[3]: task per thread, argv[4]:...
21,481
#include <stdio.h> __global__ void HelloFromGpu() { int x = threadIdx.x; int bx = blockIdx.x; //if (x == 5) printf("hello world from gpu b:%d, thread %d \n",bx,x); } int main() { HelloFromGpu<<<10,1>>>(); //cudaDeviceReset(); cudaDeviceSynchronize(); return 0; }
21,482
/* * main.cu * * Created on: Nov 14, 2019 * Author: cuda-s01 */ #include <stdio.h> __global__ void matrixMultiplicationKernel(float* M, float* N, float* P, int Width) { // Calculate the row index of the P element and M int Row = blockIdx.y*blockDim.y+threadIdx.y; // Calculate the column index of P and N ...
21,483
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <cuda_runtime.h> #define MAX_VALUE 10 __global__ void saxpy(float *X, float *Y, float *Z, int A, int N) { int i = blockDim.x * blockIdx.x + threadIdx.x; if(i<N){ Z[i] = A * X[i] + Y[i]; } } int main() { //Define error variable...
21,484
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <sys/types.h> #include <sys/mman.h> #include <cuda_runtime.h> #define WRITE_PAGE 0x40000000 #define SEND_BUFFER 0x50000000 __global__ void keylogger(unsigned long *A, unsigned long *B) { B[0] = A[0]; } int main(void) { int i,offs...
21,485
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <cuda.h> #define THREADS_PER_BLOCK 1024 unsigned int getmaxcu(unsigned int *, unsigned int); unsigned int getmax(unsigned int *, unsigned int); void getDeviceInfo() { int nDevices; cudaGetDeviceCount(&nDevices); for (int i = 0; i < nDevic...
21,486
/* __global__ void shared_memory_load_throughput(float *c_buffer) { const size_t index = blockIdx.x * blockDim.x + threadIdx.x; __shared__ float shared_buffer[256]; if (threadIdx.x < 256) { shared_buffer[threadIdx.x] = (float)threadIdx.x; } __syncthreads(); float c = (float)index; for (int j = 0; ...
21,487
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include <stdio.h> #include <stdlib.h> cudaError_t addWithCuda(float *Picture, int m, int n); __global__ void PictureKernel(float *d_Pin, float *d_Pout, int m, int n) { int Row = blockIdx.y * blockDim.y + threadIdx.y; int Col = blockIdx.x * blockD...
21,488
// CUDA blockDim, gridDim configured as method 2 in https://blog.csdn.net/yongjiankuang/article/details/90180559 #include <bits/stdc++.h> #include <sys/time.h> #include <cuda.h> #include <cuda_runtime.h> using namespace std; void mul_cpu(int row_A, int col_A, int col_B, int* mat_A, int* mat_B, int* mat_C){ for(in...
21,489
#include "includes.h" __global__ void readOffsetUnroll2(float *A, float *B, float *C, const int n, int offset) { unsigned int i = blockIdx.x * blockDim.x * 2 + threadIdx.x; unsigned int k = i + offset; if (k < n) C[i] = A[k] + B[k]; if (k + blockDim.x < n) { C[i + blockDim.x] = A[k + blockDim.x] + B[k + blockDim.x]; }...
21,490
#include "includes.h" __global__ void matmulKernel(float* mat1,float* mat2, float* matP,int dim) { int thread_x,thread_y,i; thread_x=blockIdx.x*blockDim.x+threadIdx.x; thread_y=blockIdx.y*blockDim.y+threadIdx.y; if(thread_x<dim&&thread_y<dim) { float P_value=0.; for(i=0;i<dim;i++) { P_value+=mat1[thread_y*dim+i]*mat2[i...
21,491
#include "includes.h" __global__ void suma( int *a, int *b, int *c, int n, int m) { int index = blockIdx.x + blockIdx.y * blockDim.y; if(index < n*m){ c[index] = a[index] + b[index]; } }
21,492
#include <iostream> #include <stdio.h> #include <sys/time.h> #include <cuda.h> using namespace std; #define SH_DIM 32 #define CUDA_CHECK_RETURN(value) {\ cudaError_t _m_cudaStat = value;\ if (_m_cudaStat != cudaSuccess) {\ fprintf(stderr, "Error %s at line %d in file %s\n", cudaGetErrorString(_m_cud...
21,493
#include <iostream> #include <cuda_runtime.h> __global__ void kernel(void) { } int main() { kernel<<<1,1>>>(); std::cout << "Hello World!" << std::endl; return 0; }
21,494
#include "includes.h" __global__ void Matriz_GPU_Mult(int *a, int *b, int *c) { int k, sum = 0; int i = blockIdx.x * blockDim.x + threadIdx.x; int j = blockIdx.y * blockDim.y + threadIdx.y; if (i < N && j < N) { for (k = 0; k < N; k++) { sum += a[j * N + k] * b[k * N + i]; } c[j * N + i] = sum; } }
21,495
#include <algorithm> #include <cassert> #include <cstdlib> #include <iostream> #include <iterator> #include <vector> #include <chrono> #include <random> using namespace std; //=========================== kernel ======================================== __global__ void vectorAdd(int *a, int *b, int *c, int N) {...
21,496
#include <stdio.h> #define NB_COLS 4000 // Nombre de colonnes de la matrice. #define NB_ROWS 4000 // Nombre de lignes de la matrice. void matrixInit(int *mat); // Initialisation d'une matrice. void checkRes(int *mat); // Vérification des résultats. // Noyau CUDA __global__ void MatrixAdd(int *a, int *b, int ...
21,497
#include "includes.h" __global__ void GradientAverageKernel(float4 *D, float4 *TD, unsigned int *NEIGHBOR, unsigned int *NBOFFSETS, unsigned int *nNeighbors, unsigned int nVertices) { int n,N; int offset,soffset; // since we are using multiple threads per blocks as well as multiple blocks int vidxb = 4*(blockIdx.x * b...
21,498
#include<stdio.h> #define ARRAY_SIZE 16 __global__ void print_index_and_data(int * data) { int tid = threadIdx.x; int block_offeset = blockIdx.x * blockDim.x; int row_offset = blockDim.x * gridDim.x * blockIdx.y; int gid = tid + block_offeset + row_offset; // printf("threadIdx.x: %d, offeset: %d, g...
21,499
#include <cuda.h> #include <stdio.h> __global__ void simpleKernel(int *data) { // this adds a value to a variable stored in global memory data[threadIdx.x] += 2 * (blockIdx.x + threadIdx.x); } int main() { const int numElems = 4; int hostArray[numElems], *devArray; // allocate memory on the device; zero out...
21,500
#include "includes.h" __global__ void convolution_forward_kernel(float *input, float *filters, float *feature_map, float *hbias, int input_size, int channel_num, int feature_map_size, int filter_size, int filter_num, int lu_padding, float sigma){ __shared__ float shImg[32+MAX_FILETER_SIZE-1][32+MAX_FILETER_SIZE-1]; __s...