serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
22,501 | //pass
//--blockDim=32 --gridDim=1
#include <cuda.h>
__global__ void test_Prog(int *A, int N) {
const int tid = threadIdx.x;
for(int d = N/2; d > 0; d = d / 2) {
if (tid < d) {
A[tid] += A[tid + d];
}
}
}
|
22,502 | #include <stdio.h>
__global__ void holaCUDA(float e) {
printf("Hola, soy el hilo %i del bloque %i con valor pi -> %f \n",threadIdx.x,blockIdx.x,e);
}
int main(int argc, char **argv){
holaCUDA<<<3,4>>>(3.1416);
cudaDeviceReset();
return 0;
} |
22,503 | #include <cmath>
#include <cstdio>
#include <ctime>
#include <iostream>
__global__
void add(float *d_a, float *d_b, float *d_c, long num)
{
int idx = threadIdx.x + blockIdx.x * blockDim.x;
if (idx < num) {
d_c[idx] = d_a[idx] + d_b[idx];
}
}
int main(void)
{
std::clock_t start_time;
double... |
22,504 | #include <math.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <sys/timeb.h>
// Hypercube
// Version: pas de mémoire partagée
// On réduit tout sur une dimension à chaque appel (non optimisé pour une mémoire partagée par block)
// Pas de distinction entre des threads du même block
// Pas limité e... |
22,505 | #include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <iostream>
int main(int argc, char* argv[]) {
// H has storage for 4 integers
thrust::host_vector<int> H(4);
// initialize individual elements
H[0] = 14;
H[1] = 20;
H[2] = 38;
H[3] = 46;
// H.size() returns the size of vector H
std... |
22,506 | #include "includes.h"
__global__ void MatrixMulKernel(int * _matrixA, int * _matrixB, int * _result, int _width)
{
int k = 0, elementA = 0, elementB = 0;
//2D thread ID
int tx = threadIdx.x;
int ty = threadIdx.y;
//valeu store the _result element that is computed by thread
int value = 0;
for (k = 0; k < _width; k++)
{... |
22,507 | #include <stdio.h>
#include <stdlib.h>
__global__ void multiplication(int n, int m, int *a, int *b)
{
int index = threadIdx.x;
int stride = blockDim.x;
for (int i = index, j = index; i < m*n; i += stride){ // T threads per iteration
a[i] = a[i] * b[j%n];
}
}
int main(int argc, char **argv){
... |
22,508 | #include <stdio.h>
#include <math.h>
#include <ctime>
using namespace std;
int transponowanie(){
clock_t begin = clock();
int const size(1000);
static double tablica[size][size];
static double tab[size][size];
for(int i=0; i<size;i++){
for(int j=0; j<size;j++){
tablica[i][j]=i*size+j+1;
}
}
... |
22,509 | #include "includes.h"
__global__ void saxpy(int n, float a, float *x, float *y, char *ad, char *bd)
{
int i = blockIdx.x*blockDim.x + threadIdx.x;
if (i < n){ y[i] = a*x[i] + y[i];
ad[0] = 'C';
}
} |
22,510 | /*
============================================================================
Name : CWLab3.cu
Author : sm01800
Version :
Copyright : Your copyright notice
Description : CUDA compute reciprocals
============================================================================
*/
#include <stdio.... |
22,511 | #include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
#include <cuda_runtime.h>
#define CUDA_CALL(func, name) \
{ \
cudaError_t e = (func); \
if(e != cudaSuccess) \
cout << "CUDA: " << cudaGetErrorString(e) << ": " << name << endl; \
else \
... |
22,512 | #include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cuda_runtime.h>
#include <sys/time.h>
double get_time() {
struct timeval tv;
gettimeofday(&tv, nullptr);
return tv.tv_sec + 1e-6 * tv.tv_usec;
}
constexpr int m = 256;
constexpr int n = m * m * m;
constexpr int block_size = 4;
using grid_type =... |
22,513 | __device__
int rectanglesSum(int** integralImage, int x, int y, int w, int h)
{
int A = x > 0 && y > 0 ? integralImage[x - 1][y - 1] : 0;
int B = x + w > 0 && y > 0 ? integralImage[x + w - 1][y - 1] : 0;
int C = x > 0 && y + h > 0 ? integralImage[x - 1][y + h - 1] : 0;
int D = x + w > 0 && y + h > 0 ? integralImage... |
22,514 | #include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <float.h>
#include <sys/time.h>
// includes, kernels
#include "trap_kernel.cu"
#define LEFT_ENDPOINT 10
#define RIGHT_ENDPOINT 1005
#define NUM_TRAPEZOIDS 100000000
double compute_on_device(float, float, int, float);
extern "C" do... |
22,515 | #include "includes.h"
__device__ void Device_FloodFillZPlane(int zPlane, int L, int M, int N, unsigned char* vol)
{
long idx, idxS, idxN, ts;
bool anyChange = false;
int x, y;
ts = L*M*N;
// set point (0,0) to OUTSIZE_1
idx = zPlane*L*M /* + 0*L + 0 */;
vol[idx] = OUTSIDE_1;
anyChange = true;
while(anyChange) {
anyC... |
22,516 | //#include "cuda_runtime.h"
//#include "device_launch_parameters.h"
//
//#include <stdio.h>
//#include <iostream>
//#include <vector>
//#include <fstream>
//#include <string>
//#include <algorithm>
//#include <chrono>
//#include <random>
//
//using namespace std;
//
//#define IMAGE_PATH "mnist\\train-images.idx3-ubyte"... |
22,517 | #include <cuda_runtime.h>
#include <stdio.h>
__global__ void sumArraysZeroCopy(float *A,float *B,float *C,const int N){
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i<N) C[i] = A[i] + B[i];
}
void sumArraysOnHost(float *A, float *B, float *C,const int N){
for (int idx=0;idx<N;idx++){
C[i... |
22,518 | #include <cmath>
__global__ void mylog2(float* value)
{
value[threadIdx.x] = std::log2(value[threadIdx.x]);
}
|
22,519 | #include <cuda.h>
#include <cuda_runtime.h>
namespace {
__global__ void wait_kernel(long long int cycles) {
const long long int start = clock64();
long long int cur;
do {
cur = clock64();
} while (cur - start < cycles);
}
} // anonymous namespace
/**
* Launch a kernel on stream that waits for length s... |
22,520 | #include "includes.h"
__device__ int position; //index of the largest value
__device__ int largest; //value of the largest value
int lenString = 593;
int maxNumStrings = 1000000;
int threshold = 2;
__global__ void populate (int *d_b, int *copy_db, int *d_c, int size, int *left) {
int n = 0;
*left = 1; // reinita... |
22,521 | /*
#ifndef __CUDACC__
#define __CUDACC__
#endif
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include<stdio.h>
#include "string.h"
__global__ void mofor(char* d_str,int len)
{
for(int i=0;i<len;i++)
if(d_str[i]=='A' ||d_str[i]=='E' ||d_str[i]=='I' ||d_str[i]=='O' ||d_str[i]=='U' ||d_str[i]=='a' ... |
22,522 | #include <stdlib.h>
#include <cuda.h>
#include <stdio.h>
__host__
void llenar(float *d_a, int tam) {
int n = 10;
for (int i = 0; i < tam; i++) {
d_a[i] = n;
}
}
void print(float *V, int tam){
for (int i = 0; i < tam; i++) {
printf("%.2f ", V[i]);
}
printf("\n");
}
__global__
void mult_matKernel(... |
22,523 | /*
* MSU CUDA Course Examples and Exercises.
*
* Copyright (c) 2011 Dmitry Mikushin
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising
* from the use of this software.
* Permission is granted to anyone to use thi... |
22,524 | // CS 87 - Final Project
// Maria-Elena Solano
//
// Radix-2 Cooley-Tukey Fourier Transform on C^n - parallel 'pi' CUDA version
//
#include <stdio.h> // C's standard I/O library
#include <stdlib.h> // C's standard library
#include <stdint.h> // C's exact width ... |
22,525 | #include <math.h>
#include <stdio.h>
__host__ void
mat_swap(double **A, double **B) {
double *temp = *A;
*A = *B;
*B = temp;
}
__global__ void
jacobian(double *OLD, double *NEW, double *f, int size, int max_it, \
double h) {
/* initializing iteration variables */
int i,j;
for (i = 1;... |
22,526 | #include "includes.h"
/*
* Implementations
*/
__global__ void ca_map_backward_kernel_w(const float *dout, const float *weight, const float *g, float *dw, int num, int chn, int height, int width) {
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threadIdx.y;
int sp = height * w... |
22,527 | extern "C"
__global__ void im2col_gpu(float *x,float *out,int N,int C,int H,int W,int kh,int kw,int stride,int oHeight,int oWidth,int ow,int oh,int kSize)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
int n = i / oHeight / oWidth;
int startH = (i - (n * oHeight * oWidth)) / oHeight * stride;
int sta... |
22,528 | #include "includes.h"
__global__ void Match7(float *d_pts1, float *d_pts2, float *d_score, int *d_index)
{
__shared__ float4 buffer1[M7W*NDIM/4]; //%%%%
__shared__ float4 buffer2[M7H*NDIM/4];
int tx = threadIdx.x;
int ty = threadIdx.y;
int bp1 = M7W*blockIdx.x;
for (int d=tx;d<NDIM/4;d+=M7W)
for (int j=ty;j<M7W;j+=M7H/... |
22,529 | #include <bits/stdc++.h>
#include <unistd.h>
#include <curand.h>
#include <curand_kernel.h>
#include <thrust/device_vector.h>
#include <thrust/sequence.h>
#include <thrust/sort.h>
#include <thrust/functional.h>
#include<time.h>
using namespace std;
#define ni 24 // number of neurons in input layer
#... |
22,530 | #include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<stdbool.h>
#include<iostream>
#include<cuda.h>
#include<cuda_runtime.h>
// Convenient Types
typedef unsigned int uint;
typedef unsigned short ushort;
// CUDA external functions
extern "C" {
bool HL_kernelLaunch(ushort threadsCount, int myrank);
... |
22,531 | #include "includes.h"
__global__ void inclusivePrefixAdd(unsigned int* d_in, unsigned int* d_out)
{
//Hillis Steele implementation
//NOTE: right now, this is only set up for 1 block of 1024 threads
int abs_x = threadIdx.x + blockIdx.x * blockDim.x;
int thread_x = threadIdx.x;
extern __shared__ unsigned int segment[];... |
22,532 | #include <cuda.h>
#include <stdio.h>
#include <malloc.h>
void save_matriz(float *Matrix, int row, int col){
FILE *f = fopen("result_mult.csv", "a");
if (f == NULL){
printf("File error\n");
exit(-1);
}
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; ++j){
if(col - 1 == j){
... |
22,533 | #include <cuda_runtime.h>
#include <stdio.h>
int main(int argc, char** argv) {
printf("%s Starting...\n", argv[0]);
int deviceCount = 0;
cudaError_t error_id = cudaGetDeviceCount(&deviceCount);
} |
22,534 |
// Babak Poursartip
// 09/28/2020
// section 2: video 20
#include <iostream>
__global__ void print_details_of_warps() {
int gid = blockIdx.y + gridDim.x * blockDim.x + blockIdx.x * blockDim.x +
threadIdx.x;
int warp_id = threadIdx.x / 32;
int gbid = blockIdx.y * gridDim.x + blockIdx.x;
printf(... |
22,535 | #include "includes.h"
__global__ void xnor_gemm(unsigned int* A, unsigned int* 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-mat... |
22,536 | #include <cuda_runtime.h>
#include <cuda.h>
#include <device_launch_parameters.h>
#include <curand.h>
#include <curand_kernel.h>
#include <iostream>
#include <chrono>
#include <cstdlib>
#include <cmath>
// the max number of (x,y) threads is 1024
// which is 1024 = 32 x 32, so 0 <= threadIdx.x < 32 and 0 <= threadId... |
22,537 | #include <math.h>
#include <float.h>
#include <cuda.h>
__global__ void gpu_Heat (float *h, float *g, int N, float *residual) {
extern __shared__ float v_reduction[]; // Vector to store the reduction values
int block_id = (blockIdx.x + blockIdx.y*gridDim.x);
int t_id = block_id*blockDim.x*blockDim.y + thre... |
22,538 | #include<stdio.h>
#include<stdlib.h>
#include<sys/time.h>
int seed;
#define CUDA_ERROR_EXIT(str) do{\
cudaError err = cudaGetLastError();\
if( err != cudaSuccess){\
printf("Cuda Error: '%s' for %s\n", ... |
22,539 | #include<iostream>
#include<stdlib.h>
#include<math.h>
#define MAX_THREADS 512
typedef struct _matrix {
int xDim;
int yDim;
int *vals;
} matrix;
__global__
void doMultiplications(_matrix *a, _matrix *b, int* resultMatrix,int row, int col){ //Result matrix must be a.xDim * b.xDim * a.yDim length array
... |
22,540 | #include <cuda.h>
#include <stdio.h>
#include <stdlib.h>
__device__ int diverge_gpu(float c_re, float c_im, int max) {
float z_re = c_re, z_im = c_im;
int i;
for (i = 0; i < max; ++i) {
if (z_re * z_re + z_im * z_im > 4.f)
break;
float new_re = z_re * z_re - z_im * z_im;
float new_im = 2.f *... |
22,541 | #include "includes.h"
__global__ void vectorAddition (float *a, float *b, float *c, int n){
int i= blockDim.x * blockIdx.x + threadIdx.x;
if (i<n){
c[i] = a[i]+b[i];
}
} |
22,542 | #include "use_matrix.cuh"
int main()
{
use_matrix();
return 0;
} |
22,543 | #include "includes.h"
__global__ void scan_sum_kernel(unsigned int* input_vals, unsigned int pass, unsigned int * output, unsigned int* output_block, unsigned int size, unsigned int block_num) {
unsigned int tid = threadIdx.x;
unsigned int mid = threadIdx.x + blockIdx.x * blockDim.x;
__shared__ unsigned int shared_inpu... |
22,544 | #include <stdio.h>
#include <cuda_runtime.h>
#include <time.h>
#include <sys/time.h>
void checkResult(float *hostRef, float *gpuRef, const int N){
double epsilon = 1.0E-8;
bool match = 1;
for (int i = 0; i < N; ++i) {
if (abs(hostRef[i] - gpuRef[i]) > epsilon){
match = 0;
pr... |
22,545 | ///
/// Useful Functions and Types
///
typedef float3 pCoor;
typedef float3 pVect;
struct pMatrix3x3 { float3 r0, r1, r2; };
__device__ float3
make_float3(float4 f4){return make_float3(f4.x,f4.y,f4.z);}
__device__ float3 m3(float4 a){ return make_float3(a); }
__device__ float3 xyz(float4 a){ return m3(a); }
__device... |
22,546 | #include <thrust/transform.h>
void test() {
} |
22,547 | #include <iostream>
#include <cuda.h>
int main()
{
cudaError_t err;
double *v;
int c;
cudaGetDeviceCount(&c);
std::cout << c << std::endl;
err = cudaMalloc(&v, 100*sizeof(double));
std::cout << cudaGetErrorString(err) << std::endl;
err = cudaFree(v);
std::cout << cudaGetErrorString(err) << std::endl;
}
|
22,548 | // Include packages and also CUDA packages
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<stdbool.h>
#include <cuda.h>
#include <cuda_runtime.h>
// Result from last compute of world.
unsigned char *g_resultData=NULL;
// Current state of world.
unsigned char *g_data=NULL;
// Current width of world.... |
22,549 | #include "includes.h"
#define BLOCK_SIZE 1024
#ifndef THREADS
# define THREADS 1024
#endif
__global__ void total(float * input, float * output, unsigned int len) {
__shared__ float sum[2*BLOCK_SIZE];
unsigned int i = threadIdx.x;
unsigned int j = blockIdx.x * (blockDim.x * 2) + threadIdx.x;
float localSum = (i < le... |
22,550 | #include "includes.h"
__global__ void transpose_naive(float *odata, float* idata, int width, int height)
{
unsigned int xIndex = blockDim.x * blockIdx.x + threadIdx.x;
unsigned int yIndex = blockDim.y * blockIdx.y + threadIdx.y;
if (xIndex < width && yIndex < height)
{
unsigned int index_in = xIndex + width * yIndex;... |
22,551 | #include "pinnedmem.cuh"
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
cudaError_t mallocHost(void** h_mem ,unsigned int memSize, memoryMode memMode, bool wc)
{
if( PINNED == memMode ) {
#if CUDART_VERSION >= 2020
return cudaHostAlloc( h_mem, memSize, (wc) ? cudaHostAllocWr... |
22,552 | #include "includes.h"
__global__ void dropout_op(size_t sz, float_t* random_nums, float_t* data, float_t drop_rate, float_t scale)
{
size_t index = blockIdx.x*blockDim.x + threadIdx.x;
if(index < sz)
{
if(random_nums[index] <= drop_rate)
{
data[index] = 0;
}
else
{
data[index] *= scale;
}
}
} |
22,553 | //new
/***************** EXAMPLE ***********************
ArrayVals: 9, 31, 4, 18
padded ArrayVals: 09, 31, 04, 18
create histogram of size 10 for buckets 0-9
which each element initialized to 0. Use a thread
on each element of ArrayVals and increment the value
in the bucket it belongs to. This will count how many
val... |
22,554 | #include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <math.h>
#include <tiffio.h>
#include <cuda.h>
#include <cuComplex.h>
__device__ float distcalc(unsigned int bidx, unsigned int bidy, unsigned int width, unsigned int height, float pinholedist, float pixelsize){
float xcon, ycon, Rxy;
xcon = (((... |
22,555 | #include "includes.h"
__global__ void Shrink_DownSampling( float *target, const float *source, const int wt, const int ht, const int ws, const int hs )
{
int y = blockIdx.y * blockDim.y + threadIdx.y;
int x = blockIdx.x * blockDim.x + threadIdx.x;
const int curt = y*wt+x;
const int curs = (y*2)*ws+x*2;
if(y < ht and x ... |
22,556 | //============================================================================
// Name : MF6.cpp
// Author : Sohrab
// Version : 1
// Copyright : Hi!
// Description : Matched Filter in C++, Ansi-style
//============================================================================
#include <iostream>
#... |
22,557 | #include "stdlib.h"
#include <stdio.h>
#include <unistd.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#define BMP_HEADER 14
#define DIB_HEADER 40
#define IMAGE_WIDTH 4608
#define IMAGE_HEIGHT 3456
#define IMAGE_BYTES_PER_PIXEL 3
#define IMAGE_SIZE (IMAGE_WID... |
22,558 |
/* This is a automatically generated test. Do not modify */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
__global__
void compute(float comp, int var_1,int var_2,float var_3,float var_4,float var_5,float var_6,float var_7,float var_8,float var_9,float var_10,float var_11,float var_12,float var_13,float va... |
22,559 | #include <iostream>
#include <vector>
#include <cmath>
#include <chrono>
using namespace std;
using namespace std::chrono;
#define BLOCK_SIZE 16
#define N 1024
__global__ void gpu_matrix_mul(int *a, int *b, int *c){
int row = blockIdx.y * blockDim.y + threadIdx.y;
int col = blockIdx.x * blockDim.x + threa... |
22,560 | //cuda version of test.c
#include <stdio.h>
#define N 256
#define TPB 256
__global__ void helloWorldKernel(){
const int i = blockIdx.x*blockDim.x + threadIdx.x;
printf("Hello World! My threadId is %2d\n", i);
}
int main(){
helloWorldKernel <<<N/TPB, TPB>>>();
return 0;
}
|
22,561 | #include "includes.h"
// GPU constant memory to hold our kernels (extremely fast access time)
__constant__ float convolutionKernelStore[256];
/**
* Convolution function for cuda. Destination is expected to have the same width/height as source, but there will be a border
* of floor(kWidth/2) pixels left and righ... |
22,562 | #include "includes.h"
__global__ void CudaKernel_BatchResize_GRAY2GRAY( int src_width, unsigned char* src_image, int num_rects, int* rects, int dst_width, int dst_height, float* dst_ptr )
{
const int gid = blockIdx.x * blockDim.x + threadIdx.x;
const int dst_image_size = dst_width * dst_height;
if( num_rects*dst_image_... |
22,563 | __global__ void PDH_kernel4(unsigned long long* d_histogram,
double* d_atom_x_list, double* d_atom_y_list, double* d_atom_z_list,
long long acnt, double res, int histSize)
{
extern __shared__ double shmem[];
//for now assume a block count of 157 and 80 (based on 10000 pts, 500.0 resolution, and 64 block... |
22,564 | #include "includes.h"
/*
#define N 512
#define N 2048
#define THREADS_PER_BLOCK 512
*/
const int THREADS_PER_BLOCK = 32;
const int N = 2048;
__global__ void dotProd( int *a, int *b, int *c ) {
__shared__ int temp[THREADS_PER_BLOCK];
int index = threadIdx.x + blockIdx.x * blockDim.x;
temp[threadIdx.x] = a[index] *... |
22,565 | /* Vector reduction example using shared memory.
* Works for small vectors that can be operated upon by a single thread block.
* Build as follows: make clean && make
* Execute as follows: ./vector_reduction
* Author: Naga Kandasamy
* Date modified: May 15, 2020
*/
#include <stdlib.h>
#include <stdio.h>
#inclu... |
22,566 | /*
============================================================================
Name : md5.cu
Author : xdegtyarev
Version :
Copyright : alexander degtyarev
Description : CUDA compute reciprocals
============================================================================
*/
#include <stdio.h>
... |
22,567 | #include <math.h>
#include <cuda.h>
__global__ void apply_f1(double h, int lower_bound, double* destination) {
int thread_id = blockDim.x * blockIdx.x + threadIdx.x;
destination[thread_id] = sin(h * (thread_id + lower_bound));
}
__global__ void apply_f2(double h, int lower_bound, double* destination) {
int thread_... |
22,568 | #include <stdio.h>
// Matrices are stored in row-major order:
// M(row, col) = *(M.elements + row * M.width + col)
typedef struct {
int width;
int height;
float* elements;
} Matrix;
// Thread block size
#define BLOCK_SIZE 16
#define MATRIX_SIZE 1024
// Forward declaration of the matrix multiplication ker... |
22,569 | #include <cuda_runtime_api.h>
#include <iostream>
#include <stdio.h>
#define BLOCK_SIZE 16
using namespace std;
typedef struct {
int width;
int height;
int stride;
int* elements;
} Matrix;
typedef struct {
int width;
int* elements;
} Vector;
__device__ float GetElement(const Matrix ... |
22,570 | /*
Swap the elements of a vector: the first with the last and so on...
*/
#include <stdio.h>
#include <cuda.h>
#include <stdlib.h>
#include <sys/time.h>
void checkCUDAError(const char* msg);
__global__ void rebalta (float *dati, long n)
{
long id;
long t;
id=blockIdx.x*blockDim.x+threadIdx.x;
if (id<n/2)
... |
22,571 | #include "includes.h"
__global__ void cuda_deactivateBend(double* pE, const double* pA, int n)
{
int id = blockIdx.x * blockDim.x + threadIdx.x;
if (id < n) {
double x = pE[id];
pE[id] *= 0.5 * (x / sqrt(x * x + 1)) + 1;
}
} |
22,572 | #include "includes.h"
__global__ void cuda_mat_multiply(const double* A, const double* B, double * C, int rowsa, int colsa, int rowsb, int colsb, int rowsc, int colsc){
__shared__ double sA[32][32]; // Tile size of 32x32
__shared__ double sB[32][32];
int Row = blockDim.y*blockIdx.y + threadIdx.y;
int Col = blockDim.x... |
22,573 | #include "cuda.h"
#include "stdio.h"
int N = 10;
void printi(int i){
printf("%d\n", i);
}
void init_CPU_array(int* array, int n){
for(int i = 0; i < n; i++) {
array[i] = i;
}
}
void print_CPU_array(int array[], int n){
for(int i = 0; i < n; i++) {
printi(array[i]);
}
}
// realiza la suma de determinant... |
22,574 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <cmath>
using namespace std;
__device__ __inline__ float trim(unsigned char value)
{
return fminf((unsigned char)255, fmaxf(value, (unsigned char)0));
}
__device__ __inline__ float poly(float x, float a, float b, float c)
{
return a*x*x*x+b*... |
22,575 | #include <iostream>
#include <vector>
#include <cuda_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
__global__ void addShared(int * v0, std::size_t size){
extern __shared__ int v0tmp[];
auto tid = blockIdx.x * blockDim.x + threadIdx.x;
v0tmp[tid] = v0[tid];
__syncthreads();
if(tid>0 && ... |
22,576 | #include <stdio.h>
__global__ void helloWorld(float f)
{
/*printf("Hello thread %d, f=%f\n", threadIdx.x, f);*/
/* printf("Hello block %i running thread %i, f=%f\n", blockIdx.x, threadIdx.x, f);*/
int idx = threadIdx.x + blockIdx.x * blockDim.x;
printf("Hello block %i running thread %i, f=%f\n", blockIdx.x, idx, ... |
22,577 | #include <iostream>
#include <sstream>
#include <list>
int main()
{
std::ostringstream arch;
std::list<std::string> archs;
int count = 0;
if (cudaSuccess != cudaGetDeviceCount(&count)){ return -1; }
if (count == 0) { return -1; }
for (int device = 0; device < count; ++device)
{
cud... |
22,578 | #include "observer.cuh"
#include <stdio.h>
__device__ bool checkBorder(int x, int y, int minX, int maxX, int minY, int maxY){
if ((minX <= x) && (x <= maxX)){
if ((minY <= y) && (y <= maxY)){
return true;
}
else{
return false;
}
}
else{
return false;
}
}
template <typename T>
_... |
22,579 | // 20181201
// Yuqiong Li
// a basic CUDA function to test working with device constant memory
#include <stdio.h>
#include <cuda.h>
const unsigned int N = 10; // size of vectors
__constant__ float const_d_a[N * sizeof(float)]; // filter in device const memory
// function declarations
__global__ void vecAddConsta... |
22,580 | #include "stdio.h"
#include <cuda.h>
#include <cuda_runtime.h>
#include <iostream>
// Defining two constants
__constant__ int constant_f;
__constant__ int constant_g;
#define N 5
// Kernel function for using constant memory
__global__ void gpu_constant_memory(float *d_in, float *d_out) {
// Getting thread index for... |
22,581 | #include <iostream>
#include <fstream>
#include <vector>
#include <sstream>
extern int solveMatrix(double *A_in, int n, double *b_in, double *x_out);
using namespace std;
int main(int argc, char *argv[]){
ifstream mtx(argv[1]);
ifstream vec(argv[2]);
vector<double> A;
vector<double> b;
string line;
int n=... |
22,582 | #include <cuda.h>
#include <cufft.h>
#include <cuda_profiler_api.h>
#include <stdio.h>
template<typename T>
__device__ __forceinline__ T ldg(const T* ptr) {
#if __CUDA_ARCH__ >= 350
return __ldg(ptr);
#else
return *ptr;
#endif
}
extern "C"
__global__
void zSmooth(
int nz
, int ny
, int nx
, float alpha
, float * da... |
22,583 | #include <iostream>
#include <fstream>
#include <cuda.h>
#include <complex>
#include <thrust/complex.h>
#include <cuComplex.h>
using namespace std;
__global__ void fft(thrust::complex<float> *, thrust::complex<float> *);
int main()
{
const int N = 10;
// An array of complex numbers per the specification... |
22,584 | #include "stdio.h"
__global__ void kernel(void){
}
int main ( void ){
kernel<<<1,1>>>();
printf("Hello, World! \n");
return 0;
}
|
22,585 | //
// 【pw_multiplies】
//
// 概要: thrust のサンプルコード
// vector の同じ要素同士の掛け算を計算する
// pointwise multiplication 計算
//
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/copy.h>
#include <thrust/transform.h>
#include <iostream>
int main(){
// ホスト側のメモリを確保
thrust::host_vector<int... |
22,586 | float h_A[]= {
0.9783785703143878, 0.5590614973341264, 0.6797962714660215, 0.8903910511968696, 0.9341342807933763, 0.6495864827547604, 0.5170069800106131, 0.9390146434783977, 0.7431405249408038, 0.5571549932954716, 0.8789095350337303, 0.8766834337695264, 0.7585463937940116, 0.6509300690459523, 0.6655874028349105, 0.723... |
22,587 | #include "includes.h"
__global__ void kernel(float *a, size_t N)
{
int tid = threadIdx.x;
__shared__ float s[BS];
int blocks = (N+BS-1)/BS;
float sum = 0.0f;
for (int ib=0; ib<blocks; ib++)
{
int off = ib*BS+tid;
s[tid] = a[off];
for (int skip=16; skip>0; skip>>=1)
if (tid+skip < N && tid < skip)
s[tid] += s[tid+skip];... |
22,588 | #include "includes.h"
__device__ inline float stableLogit(float x) {
if(x >= 0) {
float z = expf(-x);
return 1.0 / (1.0 + z);
} else {
float z = expf(x);
return z / (1.0 + z);
}
}
__global__ void gLSTMOutputForward(float* out, const float* cell, const float* xW, const float* sU, const float* b, size_t rows, size_t cols... |
22,589 | #include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <cuda.h>
#define max 999
__global__ void kernel(int n, int size, int * A, int * path, int check)
{
for(int k=0;k<n;k++){
int i = threadIdx.x;
int j = threadIdx.y;
if(A[i*size+j] > ... |
22,590 | #include "includes.h"
__global__ void UniformNormalDistribution(float *from, float *to, int size)
{
int id = blockDim.x * blockIdx.y * gridDim.x
+ blockDim.x * blockIdx.x
+ threadIdx.x;
float tmp;
if (id < size)
{
tmp = normcdf(from[id] * sqrt((float)size));
to[id] = (tmp -0.5)*2;
}
} |
22,591 | #include <iostream>
#include <iomanip>
#include <ctime>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include "cuda_runtime.h"
using namespace std;
#define TPB 1024
#define min(a,b) ((a < b) ? a : b)
__global__
void scat_part_sum(double * array, double * array_psums) {
// Distributes the values fro... |
22,592 | #include <cuda_runtime.h>
#include <cuda_fp16.h>
#include <cstdio>
#include <chrono>
#include <random>
// Flops = num_ops * gpu_loops * iterations * blocks * threads / time_seconds
__global__ void testKernel(float* A, float* B, float* C, long long int gpu_loops, long long int *timers) {
int idx = threadIdx.x + bl... |
22,593 | #include "includes.h"
__global__ void vec_add(int N, int *A, int *B, int *C){
int i = threadIdx.x + blockIdx.x * blockDim.x;
// assert( i<N );
if(i < N) C[i] = A[i] + B[i];
} |
22,594 | #include "includes.h"
//#define NDEBUG
const static float eps = 1e-6;
const static size_t blocSize = 8;
const static size_t size = 1024;
__global__ void matMultiply1D(float* matA, float* matB, float* Dest, int dimensions)
{
int i = threadIdx.x + blockIdx.x*blockDim.x;
if (i < dimensions)
{
float vectA[2048];
for ... |
22,595 | #include "includes.h"
__global__ void eldiv0(float * inA, float * inB, int length)
{
int idx = threadIdx.x + blockDim.x*blockIdx.x;
if (idx<length) inA[idx] /= inB[idx];
} |
22,596 | /*
* CUDA kernel for 2D matrix shift. Ignores borders.
* Sofie Lovdal 18.6.2018
*/
__global__ void shiftPixels(double * output, double * const input,
unsigned int const numRows, unsigned int const numCols,
double const rho, double const phi)
{
/*global thread ID in x, y dimension*/
const in... |
22,597 | #include<stdlib.h>
#include<math.h>
#include<iostream>
#include<time.h>
#define N 512
#define BLOCKS 64
using namespace std;
__global__ void Jacobi(double* u1, double* u2, double* f, double* ut, double h2, double* dmax)
{
dmax[0] = 0; // max error
double dm = 0; // temporary value of error
int i = blockIdx.x*... |
22,598 | #include <stdio.h>
/* cuda kernel declared and defined */
__global__ void add( int a, int b, int *c ){
*c = a + b;
}
int main( void ) {
int c;
int *dev_c;
/* allocates memory on the device */
cudaMalloc( (void**)&dev_c, sizeof(int));
/*call to kernel*/
add<<<1,1>>>(2, 7, dev_c);
/* copies dev_c into c */ ... |
22,599 | extern int MaxThreadsPerBlock;
extern int MaxThreadsX;
extern int MaxThreadsY;
__global__ void Kernel_Rings1(unsigned char *surface1, int width, int height, size_t pitch,
float Amp, float a, float b, float Rt, int x0, int y0, float yref, int Mask )
{
int x = blockIdx.x*block... |
22,600 | #include <stdio.h>
#include <time.h>
using namespace std;
#define PI 3.1415926535897932384
#define mu0 4*PI*1e-7
#define block_i 16
#define block_j 16
//grid will be r driven meaning grid(r,z) = grid[r*zMax + z]
__global__ void init(double *grid, double Il, double dI, double ldr, double rlength, int rseg, int zseg){... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.