serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
401 |
__global__ void CuKnlSetField(
double xCells,
double yCells,
double* energy0,
double* energy1)
{
const int gid = threadIdx.x+blockIdx.x*blockDim.x;
energy1[gid] = energy0[gid];
}
|
402 | #include "probe.cuh"
Probe::Probe(ProbeConfig cfg)
: chan_indices_(cfg.n_active()),
site_labels(cfg.n_active()),
chan_grps(cfg.n_active()),
x_coords(cfg.n_active()),
y_coords(cfg.n_active()),
is_active_(cfg.n_total),
site_dists(cfg.n_active()) {
n_total_ = cfg.n_total;
if (n... |
403 | #include "includes.h"
__global__ void cudaComputeSignature(double* hyperplanes, double* v, int* dimensions, bool* sig, long* hyperp_length) {
long tid = threadIdx.x + blockDim.x * blockIdx.x;
if (tid < *hyperp_length) {
int d_dimensions = *dimensions;
long pos = tid * d_dimensions;
double sum = 0.0;
for (int i = 0; i... |
404 | #include "stdio.h"
// printf() is only supported
// for devices of compute capability 2.0 and higher
#if defined(__CUDA_ARCH__) && (__CUDA_ARCH__ < 200)
#define printf(f, ...) ((void)(f, __VA_ARGS__),0)
#endif
__global__ void helloCUDA(float f)
{
printf("Hello thread %d, f=%f\n", threadIdx.x, f);
}
int main(... |
405 | #include <cuda.h>
#include <cuda_runtime.h>
#include <stdio.h>
#define N 1000000
__global__ void gpuAdd(int *d_a, int *d_b, int *d_c){
//总线程id = 当前块线程id.x + 块id*块维度x
int tid = threadIdx.x + blockIdx.x * blockDim.x;
while (tid < N)
{
d_c[tid] = d_a[tid] + d_b[tid];// 加法
tid += blockDim.x * gridDim.x; // 一次执... |
406 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <climits>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <chrono>
#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, const char *file, int line, bool abor... |
407 | #include <stdio.h>
__global__ void add(int a, int b, int *c){
*c = a + b;
}
int main(){
int c;
int *dev_c;
cudaMalloc( (void**) &dev_c, sizeof(int) );
add<<<1, 1>>> (2, 7, dev_c);
cudaMemcpy(&c,
dev_c, sizeof(int),
cudaMemcpyDeviceToHost);
printf("2 + 7 ... |
408 | #include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <stdio.h>
// __global__ indicates a function or "kernel" that runs on the device and is called from host code
__global__ void hello_kernel(void)
{
// greet from the device : the GPU and its memory
printf("Hello, world from the device!\n... |
409 | #include <stdlib.h>
#include <stdio.h>
#include <time.h>
/* Every thread gets exactly one value in the unsorted array. */
#define THREADS 128 // 2^7
#define BLOCKS 1024 // 2^10
#define NUM_VALS THREADS*BLOCKS
#define MAX_VALUE 8196
void print_elapsed(clock_t start, clock_t stop)
{
double elapsed = ((double) (stop -... |
410 | #include <iostream>
using std::endl;
__global__ void sum_kernel(double *A, double *B, double *C, int N) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx >= N) { return; }
double a = A[idx];
double b = B[idx];
C[idx] = a + b;
}
int main(int argc, char **argv) {
// Size of vectors
... |
411 | /**
* 3mm.cu: This file is part of the PolyBench/GPU 1.0 test suite.
*
*
* Contact: Scott Grauer-Gray <sgrauerg@gmail.com>
* Louis-Noel Pouchet <pouchet@cse.ohio-state.edu>
* Web address: http://www.cse.ohio-state.edu/~pouchet/software/polybench/GPU
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#i... |
412 | #include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <cuda.h>
#include <device_functions.h>
#include <cuda_runtime_api.h>
#include<iostream>
#define imin(a,b) (a<b?a:b)
#define sum_squares(x) (x*(x+1)*(2*x+1)/6)
const int N = 33 * 1024;
const int threadsPerBlock = 256;
const int blocksPerGrid = i... |
413 | // RUN: %run_test hipify "%s" "%t" %hipify_args %clang_args "-Xclang" "-fcuda-allow-variadic-functions"
/*
Copyright (c) 2015-present Advanced Micro Devices, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "... |
414 | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <cuda.h>
__global__ void _slowKernel(char* ptr, int sz) {
int idx = blockIdx.x * blockD... |
415 | #include "math.h"
__constant__ int sobelV[] = {1, 0, -1, 2, 0, -2, 1, 0, -1};
__constant__ int sobelH[] = {1, 2, 1, 0, 0, 0, -1, -2, -1};
extern "C"
__global__ void grayEdgeDetection(int * output, int width, int thresh) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
int idy = blockIdx.y * blockDim.y + threadI... |
416 | #include<stdio.h>
#include<stdlib.h>
#include<time.h>
float random_number(int min, int max){
/*
* Function: random_number
* -----------------------
* return a random number between min and max as a float
*/
float num = rand() % (max + 1 - min) + min;
ret... |
417 | /*
* ising_cuda_v1.cu
*
* Created on: Dec 26, 2019
* Author: Charalampos Eleftheriadis
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define N 512
#define threadsNum 64
#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, const char *file, ... |
418 | #include "includes.h"
__device__ void generate2DGaussian(double * output, double sigma, int sz, bool normalize) {
/*x and y coordinates of thread in kernel. The gaussian filters are
*small enough for the kernel to fit into a single thread block of sz*sz*/
const int colIdx = threadIdx.x;
const int rowIdx = threadIdx.y;... |
419 | #include <algorithm>
#include <cassert>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <vector>
#include <chrono>
using namespace std;
constexpr int M = 1 << 3 ; //M =8
constexpr int N = 1 << 3;
constexpr int K = 1 << 3;
constexpr int THREADS = 1 << 2;
constexpr int M_padded = M + TH... |
420 | #include <cuda.h>
#include <stdlib.h>
#include <stdio.h>
#include <cuda_profiler_api.h>
#include <tuple>
#include <iostream>
#include <string.h>
double time_host = 0;
double time_device = 0;
int sample_rounds = 10;
void meanFilter_host(unsigned char* image_matrix,unsigned char* filtered_image_data,int image_width, i... |
421 | // pi2.cu
/*
* A simple CUDA-enabled program that approximates \pi using monte-carlo
* sampling. This version generates random numbers on-the-fly within each
* kernel.
*/
#include <iostream>
#include <curand.h>
#include <curand_kernel.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdbool.h>
using namespace ... |
422 | #include <iostream>
#include <cuda.h>
#define DATA_TYPE float
#define NX 1024*8 // A = NX * NY
#define NY 1024*32 // B = NY * NZ
#define NZ 1024
#define GPU_DEVICE 0
using namespace std;
__global__ void MatMul(DATA_TYPE* A, DATA_TYPE* B, DATA_TYPE* Out){
int idx = blockIdx.x * blockDim.x + threadIdx.x;
int idy = b... |
423 | //This is a matrix multiplication program in CUDA without any optimizations
//like tiling, using shared memory etc
#include<stdio.h>
#include<stdlib.h>
#include<cuda_runtime.h>
#include<assert.h>
__global__ void MatrixMulKernel(float* Md, float* Nd, float* Pd, int width)
{
//2D thread ID
int bx=blockIdx.x;
int ... |
424 | #define TILE_DIM 32
template<typename T>
__device__ void vectorDotVector(const T* A, const T* B, T* result, const int length) {
__shared__ T a_tile[TILE_DIM];
__shared__ T b_tile[TILE_DIM];
__shared__ T result_tile[TILE_DIM];
for (int i = 0; i < TILE_DIM; i++) {
result_tile[i] = 0;
}
int tx = threadI... |
425 | #include <stdio.h>
#include <cuda.h>
int *a, *b; // host data
int *c, *c2; // results
//Cuda error checking - non mandatory
void cudaCheckError() {
cudaError_t e=cudaGetLastError();
if(e!=cudaSuccess) {
printf("Cuda failure %s:%d: '%s'\n",__FILE__,__LINE__,cudaGetErrorString(e));
exit(0);
}
}
//GPU kernel... |
426 | #include <algorithm>
#include <fstream>
#include <iostream>
#include <sstream>
#include <vector>
#define THREADS 64
// Error check-----
#define gpuErrchk(ans) \
{ gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, const char *file, i... |
427 | #include "includes.h"
/*
Vector addition with a single thread for each addition
*/
/*
Vector addition with thread mapping and thread accessing its neighbor parallely
*/
//slower than simpler
/*
Matrix Matrix multiplication with a single thread for each row
*/
/*
Matrix Matrix multiplication with a single thread... |
428 | #include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#define N 1024
#define BLOCK_SIZE 16
typedef struct
{
float *elements;
int width;
int height;
} Matrix;
void cpu_gj(Matrix A, float *x, ... |
429 | /*
* EyLeftUpdater.cpp
*
* Created on: 01 февр. 2016 г.
* Author: aleksandr
*/
#include "EyLeftUpdater.h"
#include "SmartIndex.h"
/*
* indx должен пренадлежать участку от [0, sizeY-1]
*/
__device__
void EyLeftUpdater::operator() (const int indx) {
int n = indx;
Ey(0, n) = coeff[0]*(Ey(2, n) + EyLeft(0,... |
430 | /* Histogram generation on the GPU.
Host-side code.
Author: Naga Kandasamy
Date modified: 3/11/2017
*/
// includes, system
#include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>
#include <string.h>
#include <math.h>
#include <float.h>
#define THREAD_BLOCK_SIZE 256
#define NUM_BLOCKS 60 // Define the size o... |
431 | #include "includes.h"
__global__ void unaccumulatedPartSizesKernel(int size, int *accumulatedSize, int *sizes)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if(idx == 0)
sizes[idx] = accumulatedSize[0];
else if(idx < size)
{
sizes[idx] = accumulatedSize[idx] - accumulatedSize[idx - 1];
}
} |
432 | #include <stdio.h>
#include <sys/time.h>
__global__
void log1p(double p, double q, double * y)
{
y[0] = q + log1p(exp(p - q));
}
__global__
void log_1p(double p, double q, double * y)
{
y[0] = q + log(1 + exp(p - q));
}
int main(void)
{
double a, b;
double * y;
cudaMallocManaged(&y, sizeof(*y));
y[0] = ... |
433 | /*
This is the function you need to implement. Quick reference:
- input rows: 0 <= y < ny
- input columns: 0 <= x < nx
- element at row y and column x is stored in data[x + y*nx]
- correlation between rows i and row j has to be stored in result[i + j*ny]
- only parts with 0 <= j <= i < ny need to be filled
*/
#include ... |
434 | #include<stdio.h>
#include<cuda.h>
# define M 1000
# define N 1000
__global__ void mult( int * a, int * b, int * c)
{
unsigned int i= blockDim.x *blockIdx.x + threadIdx.x;
unsigned int j= blockDim.y *blockIdx.y + threadIdx.y;
int sum=0;
if(i<M && j<N)
{
for(int k=0;k<N;k++)
{
sum+=(a[i*N+k]* b[k*N+j]); ... |
435 | #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[N];
temp[threadIdx.x] = a[threadIdx.x] * b[threadIdx.x];
__syncthreads(); // Evita condición de carr... |
436 | __global__ void
convolution2D(float *A,float *B,const int numRows,const int numCols)
{
int i = blockDim.x*blockIdx.x + threadIdx.x;
int j = blockDim.y*blockIdx.y + threadIdx.y;
if (i<numRows && j<numRows)
{
float pos1=0,pos2=0,pos3=0,pos4=0,pos5=0,pos6=0,pos7=0,pos8=0;
if((i-1)>=0 &... |
437 | /* Write GPU code to perform the step(s) involved in counting sort.
Add additional kernels and device functions as needed. */
__global__ void counting_sort_kernel(int *input_array, int *sorted_array, int *histogram, int *scan, int num_elements, int range)
{
extern __shared__ int temp[];
int threadID = block... |
438 | #include "includes.h"
__global__ void BoxReciprocalGPU(double *gpu_prefact, double *gpu_sumRnew, double *gpu_sumInew, double *gpu_energyRecip, int imageSize)
{
int threadID = blockIdx.x * blockDim.x + threadIdx.x;
if(threadID >= imageSize)
return;
gpu_energyRecip[threadID] = ((gpu_sumRnew[threadID] * gpu_sumRnew[threa... |
439 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <cuda.h>
#include <stdio.h>
#include <device_functions.h>
//#include "device_launch_parameters.h"
#include <cuda_runtime_api.h>
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <string>
#include <cmath>
#include <time.h>
usi... |
440 | #include <iostream>
#include <math.h>
#include<cuda_profiler_api.h>
//function to add the elements of two arrays
__global__
void add(int n, float *x, float *y)
{
for (int i = 0; i < n; i++)
y[i] = x[i] + y[i];
}
int main(void)
{
//cudaProfilerStart();
int N = 1<<20; //1M elements
//int N = 100; //100 elements
... |
441 | //
// Created by Peter Rigole on 2019-04-17.
//
#include "NeuronProperties.cuh"
NeuronProperties::NeuronProperties() : long_time_lambda(0.5),
medium_time_lambda(0.5) {}
// Copy constructor
NeuronProperties::NeuronProperties(const NeuronProperties &neuronProperties) :
lo... |
442 | /*
* BackpropagationCUDA.cu
*
* Created on: Jan 30, 2012
* Author: wchan
*/
/**
* This file is needed because nvcc doesn't support C++0x yet... we can merge it back in later when nvcc adds support for the C++11 standard
*/
#include <thrust/device_ptr.h>
#include <thrust/transform.h>
void mult(double* x,... |
443 | #include "includes.h"
__global__ void copy_sort_int( const float *orig, const unsigned int *sort_idx, const unsigned int nitems, float *sorted ) {
for( int i = 0; i < nitems; ++ i ) {
sorted[sort_idx[i]] = orig[i];
}
} |
444 | #include "includes.h"
__global__ void LeftRightBound2D(double *Hs, double *Ztopo, double *K2e, double *K2w, int BC2D, int M, int N) {
int tid = threadIdx.x + blockIdx.x * blockDim.x;
while (tid < M) {
// no-flow BCs
if (BC2D == 0) {
Hs[tid*N] = Hs[tid*N+1];
Hs[(tid+1)*N-1] = Hs[(tid+1)*N-2];
} else { // Critical de... |
445 | #include "includes.h"
__global__ void imgGray(unsigned char * d_image, unsigned char* d_imagegray, int width, int height){
int row = blockIdx.y*blockDim.y+threadIdx.y;
int col = blockIdx.x*blockDim.x+threadIdx.x;
if ((width > col) && (height > row)){
d_imagegray[row*width+col]=d_image[(row*width+col)*3+2]*0.299+d_ima... |
446 | #include <iostream>
#include "../include/lglist.h"
#include <thrust/device_vector.h>
#define def_dvec(t) thrust::device_vector<t>
#define to_ptr(x) thrust::raw_pointer_cast(&x[0])
using namespace std;
const int MAX_LENGTH = 170;
__device__ void printList(gpu_linearized_stl::list<float, MAX_LENGTH> &l){
if(l.empty... |
447 | #include <stdio.h>
#include <stdlib.h>
#define MAXPOINTS 1000000
#define MAXSTEPS 1000000
#define MINPOINTS 20
#define PI 3.14159265
const int kThreadsPerBlock = 256;
int nsteps, // Number of time steps
tpoints; // Total points along string
float values[MAXPOINTS + 2]; // Values at time t
void check_p... |
448 | #include "includes.h"
__global__ void bcnn_backward_upsample_cuda_kernel(size_t dst_sz, float *src, int w, int h, int c, int n, int size, float *dst) {
size_t i = (blockIdx.x + blockIdx.y * gridDim.x) * blockDim.x + threadIdx.x;
if (i >= dst_sz) {
return;
}
int dst_idx = i;
int dst_w = i % (w * size);
i = i / (w * size... |
449 | /*
* reduce an array of 1's by the sum
*/
#include <stdio.h>
#include <stdlib.h>
void nonCudaReduce(float* out, float *in, int size);
void startClock(char*);
void stopClock(char*);
void printClock(char*);
int main(int argc, char** argv) {
if (argc < 2) {
printf("Usage: %s #-of-floats\n",argv[0]);
exit(1);
}... |
450 | #include "includes.h"
__global__ void repack_input_kernel(float *input, float *re_packed_input, int w, int h, int c)
{
int index = blockIdx.x*blockDim.x + threadIdx.x;
const int items_per_channel = w * h;
int c_pack = index % 32;
int chan_index = index / 32;
int chan = (chan_index * 32) % c;
int i = (chan_index * 32)... |
451 | #include<stdio.h>
void cpu()
{
printf("cpu\n");
}
__global__ void gpu()
{
printf("gpu\n");
}
int main()
{
cpu();
gpu<<<1,1>>>();
cudaDeviceSynchronize();
}
|
452 | #include "includes.h"
__global__ void reduceSmemDyn(int *g_idata, int *g_odata, unsigned int n)
{
extern __shared__ int smem[];
// set thread ID
unsigned int tid = threadIdx.x;
int *idata = g_idata + blockIdx.x * blockDim.x;
// set to smem by each threads
smem[tid] = idata[tid];
__syncthreads();
// in-place reductio... |
453 | #include<stdio.h>
#include<iostream>
#include<fstream>
#include<cuda.h>
#include<time.h>
#include<sys/time.h>
#define IMAGE_LENGTH 2000
#define KERNEL_LENGTH 5
#define MAX_NUMBER 12
#define NumOfBlocks IMAGE_LENGTH/16
#define NumOfThreads 16
using namespace std;
ofstream fs("convolucion.txt");
void print_Matrix(int*... |
454 | #include "includes.h"
__global__ void ReturnFloat( float *sum, float *out, const float *pIn )
{
out[threadIdx.x] = atomicAdd( &out[threadIdx.x], pIn[threadIdx.x] );
} |
455 | // https://devblogs.nvidia.com/even-easier-introduction-cuda
// https://devblogs.nvidia.com/unified-memory-cuda-beginners
#include <iostream>
#include <math.h>
// cuda kernel
__global__
void add(size_t num_elements, const float* x, float* result)
{
size_t index = blockIdx.x * blockDim.x + threadIdx.x;
size_t str... |
456 | __global__ void
reduction_sum(float *A,int num_elements){
int i = blockIdx.x*blockDim.x + threadIdx.x;
if(i<num_elements){
for(int stride = 1;stride<num_elements;stride*=2){
__syncthreads();
if(i%(2*stride) == 0){
float temp = 0;
if(i+st... |
457 | #include <cuda.h>
#include <iostream>
using namespace std;
/**
* C = A + B (one element per thread)
*/
__global__
void addMatricesElt(float* C, const float* A, const float* B, int dim)
{
int col = blockIdx.x * blockDim.x + threadIdx.x;
int row = blockIdx.y * blockDim.y + threadIdx.y;
if(col < dim && row < dim... |
458 | extern "C" __global__ void
shift(float2* arr, int resx, int resy, int resz, int size)
{
int i = blockDim.x * blockIdx.x + threadIdx.x;
int idx = resx / 2;
int idy = resy / 2;
int idz = resz / 2;
float2 tmp;
if (i / resy / resz < idx) {
if (i / resz % resy < idy) {
i... |
459 | #include "includes.h"
__global__ void breadth_first_search_csr_gpu(unsigned int* cum_row_indexes, unsigned int* column_indexes, int* matrix_data, unsigned int* in_infections, unsigned int* out_infections, unsigned int rows) {
unsigned int row = blockDim.x * blockIdx.x + threadIdx.x;
if (row < rows) {
if (in_infections... |
460 | #include "includes.h"
__global__ void ForwardLinear(float *A, float *W, float *b, int nRowsW, int nColsW, int nColsA, float *Z)
{
int row = blockIdx.y * blockDim.y + threadIdx.y;
int col = blockIdx.x * blockDim.x + threadIdx.x;
float ZValue = 0;
if (row < nRowsW && col < nColsA)
{
for (int i = 0; i < nColsW; i++)
{
Z... |
461 | #include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <math.h>
#include <time.h>
// Maximum value of the matrix element
#define MAX 100
#define MAX_ITER 100
#define TOL 0.000001
// Generate a random float number with the maximum value of max
float rand_float(int max) {
return ... |
462 | //nvcc -ptx EM5.cu -ccbin "F:Visual Studio\VC\Tools\MSVC\14.12.25827\bin\Hostx64\x64"
__device__ void EM1( double *r,
double *z,
double * ar0,
double * br0,
double * az0,
double * bz0,
const int... |
463 |
/************************************************************************
C-DAC Tech Workshop : hyPACK-2013
October 15-18, 2013
Example : multiple-cuda-streams.cu
Objective : Objective is to demonstrate multiple streams for
addition of two... |
464 | #include <stdio.h>
int main() {
int nDevices;
cudaGetDeviceCount(&nDevices);
for (int i = 0; i < nDevices; i++) {
cudaDeviceProp prop;
cudaGetDeviceProperties(&prop, i);
printf("Device Number: %d\n", i);
printf(" Device name: %s\n", prop.name);
printf(" Memory Clock Rate (KHz): %d\n",
... |
465 |
#include <stdio.h>
#include <math.h>
#include <cuda_runtime_api.h>
#include <time.h>
#include <errno.h>
/******************************************************************************
* This program takes an initial estimate of m and c and finds the associated
* rms error. It is then as a base to generate and eval... |
466 | #include <iostream>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <random>
#include <chrono>
#include <stdio.h>
#define NB_THREADS 1024
#define NB_NUMBERS 200
#define NB_EXPERIMENTS 100
void print_vector(int* array, int k) {
for(size_t i=0; i < k; i++) {
printf("%d ", arra... |
467 |
#include <stdio.h>
#include <stdlib.h>
// For the CUDA runtime routines (prefixed with "cuda_")
#include <cuda_runtime.h>
#include <sys/time.h>
#include <cooperative_groups.h>
//#include <helper_cuda.h>
#define N_INPUTS 32
#define N_ARITH 74
__global__ void
ac(float *A, const int *B, const int *C, const int *op_sel,... |
468 | // includes, system
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
__global__ void notDivergent(int n)
//The threads should perform the same work as
//in divergent(), but the threads within a warp
//should not diverge
{
}
__global__ void divergent(int n)
//The threads should perform the same work as
... |
469 |
/**
* Copyright 1993-2012 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 use, reproduction, disclosure, or distribution of
* this software and relat... |
470 | // This example introduces CUDA's heterogeneous model of memory
// by demonstrating the difference between the "host" and "device"
// memory spaces.
// #include stdlib.h for malloc/free
#include <stdlib.h>
// #include stdio.h for printf
#include <stdio.h>
// nvcc automatically #includes headers needed for cudaMalloc... |
471 | //合并 访存
#include<stdio.h>
#include<math.h>
#include<time.h>
#include <stdlib.h>
int Max=16384;
int width=32;
typedef struct {
double A1;
double A2;
double A3;
double A4;
}stru;
__global__ void multi(stru *A,stru *b,double *C,const int Max){
int idx = blockIdx.x * blockDim.x + threadIdx.x;
int... |
472 | #include<math.h>
#include<time.h>
#include<stdexcept>
#include<iostream>
#include<cstdlib> //for abs(x)
#include<stdio.h>
using namespace std;
__global__ void kernel_multiplication( int* A, int* B, int* C,int N,int M);
int main()
{
int NUMBER_OF_ELEMENTS;
int VECTOR_SIZE;
cout<<"Enter the vector size:";
cin>... |
473 | #include <cuda.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#define STOP 0
#define START 1
/* Play with the following two values */
#define NB 1000000L //Size of array (long integer)
#define MANY 200L //Number of transfers
/* (over-)Simple chronometer function */
void chrono (int kind, float *time) ... |
474 | #include "includes.h"
__global__ void _segmentedScanBackKer(float *maxdist, int *maxdistidx, int *label, float *blockmaxdist, int *blocklabel, int *blockmaxdistidx, int numelements)
{
// 声明共享内存。用来存放中间结果小数组中的元素,也就是输入的原数组的每块最
// 后一个元素。共包含三个信息。
__shared__ float shdcurmaxdist[1];
__shared__ int shdcurlabel[1];
__shared__ i... |
475 | #include "includes.h"
__global__ void TemporalConvolutionTBC_bp_bias( float* matrix, float* target, int rows, int stride, float scale) {
int i = blockIdx.x * 32 + threadIdx.x;
float t = 0;
for (int j = blockIdx.y; j < rows; j += gridDim.y)
t += matrix[j * stride + i];
atomicAdd(&target[i], t * scale);
} |
476 | #include <complex>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cuComplex.h>
// Kernel Definitions
/******************************************************************************
* Function: CUDAisInMandelbrotSet
*
* Authors: Elliott Rarden & Katie Macmillan
*
* Description... |
477 | #include <cuda.h>
#include <stdio.h>
#include <stdlib.h>
#define BLOCK_SIZE 32
#define GROUP_OF_PIXELS 1
__global__ void mandelKernel(float upperX, float upperY, float lowerX, float lowerY, int* img, int resX, int resY, int maxIterations) {
int row = blockIdx.y * blockDim.y + threadIdx.y;
int col = (blockIdx.x... |
478 | #include "plane.cuh"
#include <stdio.h>
__host__ __device__ Plane3::Plane3() {
a = Vec3();
b = Vec3();
c = Vec3();
}
__host__ __device__ Plane3::Plane3(Vec3 a, Vec3 b, Vec3 c) {
this->a = a;
this->b = b;
this->c = c;
}
__host__ __device__ float determinant(Vec3 a, Vec3 b, Vec3 c) {
retur... |
479 | #include "cuda_runtime.h"
#include <stdio.h>
#include <time.h>
//#define SIZE 1000
using namespace std;
__global__ void Convolution1(int *a,int *filter,int *result,int size_a,int size_filter,int size_result)
{
int i=blockIdx.x;
int j=blockIdx.y;
if(i<size_result||j<size_result)
{
... |
480 | #include <stdio.h>
template <unsigned int blockSize>
__device__ void warpReduce(volatile int* sdata, int tid) {
if (blockSize >= 64) sdata[tid] += sdata[tid + 32];
if (blockSize >= 32) sdata[tid] += sdata[tid + 16];
if (blockSize >= 16) sdata[tid] += sdata[tid + 8];
if (blockSize >= 8) sdata[ti... |
481 | /****
File: findRedsDriver.cu
By: Ilya Nemtsov
Compile: nvcc findRedsDriver.cu -o frgpu
Run: ./frgpu
****/
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <cuda.h>
#define NUMPARTICLES 32768
#define NEIG... |
482 | #include <cuda.h>
#include <stdio.h>
__global__ void K1() {
unsigned num = 0;
unsigned id = blockIdx.x * blockDim.x + threadIdx.x;
for (unsigned ii = 0; ii < id; ++ii)
num += ii;
printf("K1: %d\n", threadIdx.x);
}
__global__ void K2() {
unsigned num = 0;
unsigned id = blockIdx.x * blockDim.x + threadIdx.x;
fo... |
483 | #include <stdio.h>
#include <cuda.h>
#include <cuda_runtime.h>
//#include <cutil_inline.h>
extern "C"
void runCudaPart(float a[], float b[], float c[], int n);
__global__ void myKernel(float *a, float *b, float *c, int n)
{
int idx = blockIdx.x*blockDim.x + threadIdx.x;
//return;
if (idx < n)
{
... |
484 | #include "includes.h"
float * g_outputs_d, *g_sweepers_d_2;
__global__ void update_positions(float max_speed, float * outputs_d, float * sweepers_d)
{
int my_index = blockIdx.x * blockDim.x + threadIdx.x;
sweepers_d[my_index] += (2 * outputs_d[my_index] * max_speed) - max_speed;
} |
485 | //=============================================================================================
// Name : thread3dStl.cu
// Author : Jose Refojo
// Version :
// Creation date : 26-02-2014
// Copyright : Copyright belongs to Trinity Centre for High Performance Computing
// Description : This prog... |
486 | #include <stdio.h>
#include <cuda.h>
int main() {
// get the range of stream priorities for this device
int priority_high, priority_low;
cudaDeviceGetStreamPriorityRange(&priority_low, &priority_high);
// create streams with highest and lowest available priorities
cudaStream_t st_high, st_low;
cudaStreamCreateWithPrio... |
487 | extern __device__ __constant__ int constNumber[4];
|
488 | #define TILE_DIM 128
//template<typename T>
//__device__ void sumColumns(const T* matrix, T* result,
// const int rows, const int cols) {
//
// __shared__ T tile[TILE_DIM][TILE_DIM];
//
// int by = blockIdx.y;
// int ty = threadIdx.y;
// int row = by * blockDim.y + ty;
// T sum = 0;
//
/... |
489 |
/* 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,int var_4,int 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 var_14... |
490 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <assert.h>
#ifndef THREADS_PER_BLOCK
#define THREADS_PER_BLOCK 1024
#endif
#define CUDA_ERROR_CHECK
#define CudaSafeCall( err ) __cudaSafeCall( err, __FILE__, __LINE__ )
#define CudaCheckError() __cudaCheckError( __FILE__, __LINE__ )
inline voi... |
491 | #include "includes.h"
__global__ void copy_kernel_frombuf(char *dest, char *src, int rx_s, int rx_e, int ry_s, int ry_e, int rz_s, int rz_e, int x_step, int y_step, int z_step, int size_x, int size_y, int size_z, int buf_strides_x, int buf_strides_y, int buf_strides_z, int type_size, int dim, int OPS_soa) {
int idx_z ... |
492 | #include<stdio.h>
__global__ void kernel (float *out)
{
// shared memory
// the size is determined by the host application
extern __shared__ float sdata[];
// access thread id
const unsigned int tid = threadIdx.x;
// access number of threads in this block
const unsigned int num_threads ... |
493 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <zlib.h>
int hNumberOfReads = 0; // holds number of reads that are processed
int hReadsWritten = 0; // number of reads written to output file
char input_filename[400]="/home/linux/cuda-workspace/Prep... |
494 | /*
============================================================================
Name : review_chp4_2.cu
Author : freshield
Version :
Copyright : Your copyright notice
Description : CUDA compute reciprocals
============================================================================
*/
#include... |
495 | #include "includes.h"
__global__ void empty_kernel()
{
} |
496 | #include<stdio.h>
#include<stdlib.h>
#include "cuda.h"
__global__ void addVectors(int N, double *a, double *b, double *c) {
int thread = threadIdx.x;
int block = blockIdx.x;
int blockSize = blockDim.x;
int id = block*blockSize + thread;
__shared__ double s_a[32];
__shared__ double s_b[32];
__shared__ ... |
497 | #define N 16
#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("%d blockIdx=%d\n", c[blockIdx.x], blockIdx.x);
}
void random_ints(int *array, int size){
int i;
for(i = 0; i < size; i++)
array[i] = rand() % 10;
}
int main(... |
498 | #include "includes.h"
__global__ void cudaAcc_GPS_kernel_mod3( int NumDataPoints, float2* FreqData, float* PowerSpectrum)
{
const int sidx = (blockIdx.x * blockDim.x + threadIdx.x);
float ax,ay;
if ( sidx < NumDataPoints )
{
ax = FreqData[sidx].x;
ay = FreqData[sidx].y;
PowerSpectrum[sidx] = __fadd_rn( __fmul_rn(ax,... |
499 | #include "includes.h"
__device__ unsigned char value( float n1, float n2, int hue ) {
if (hue > 360) hue -= 360;
else if (hue < 0) hue += 360;
if (hue < 60)
return (unsigned char)(255 * (n1 + (n2-n1)*hue/60));
if (hue < 180)
return (unsigned char)(255 * n2);
if (hue < 240)
return (unsigned char)(255 * (n1 + (n2... |
500 | #include "3d-test.cuh"
#include<iostream>
#include<stdio.h>
__host__ __device__
void scalingFunction(int array[]) {
for(int i=0; i<8; i++) {
array[i] = array[i] * 2.0;
}
}
__host__ __device__
void distributeFunction(pencilComputation& p1,int x,int y){
for(int z=0; z<8; z++) {
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.