serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
24,001 | #include "includes.h"
__global__ void poli1(float* poli, const int N) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
float x = poli[idx];
if (idx < N) {
poli[idx] = 3 * x * x - 7 * x + 5;
}
} |
24,002 | #include <cstdio>
void VecAdd( const float* pA, const float* pB, float* pC, int vectorSize)
{
for( int i = 0 ; i < vectorSize; ++i)
{
pC[i] = pA[i] + pB[i];
}
}
void VecFill( float * pVector, int vectorSize, float firstValue, float increment )
{
for( int i = 0 ; i < vectorSize; ++i)
{
pVector[i] = firstValue... |
24,003 | #include "includes.h"
__global__ void marks(float * media, int * final){
int thread = blockIdx.x*blockDim.x + threadIdx.x;
final[thread] = (media[thread] == (int)media[thread]) * (int)media[thread] +
(media[thread] != (int)media[thread] && media[thread] > 4 && media[thread] < 5)* 4 +
(media[thread] != (int)media[thread... |
24,004 | #include <stdio.h>
#include <stdlib.h>
#include <algorithm>
// Change the code here:
// This should be changed to GPU kernel definition
void matAdd(int width, int height, const float* A, const float* B, float* C)
{
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
... |
24,005 | #include "includes.h"
__global__ static void ZCalcBrightness(float* DataArray, float* BrightArray, int size, int rows, int cols, int startIndex)
{
int id = blockIdx.x * blockDim.x + threadIdx.x;
if (id >= size * rows) // 超出範圍
return;
// 算 Index
int sizeIndex = id / rows;
int rowIndex = id % rows;
BrightArray[id]... |
24,006 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <set>
#include <utility>
using namespace std;
__global__ void factorAKernel ( int *T_i, float *T_d ,float *A, float *B, float *C, float *A_n, int l_i, int l_t, int l_q, int l_d, int k,fl... |
24,007 | #ifndef __CUDACC__
#define __CUDACC__
#endif
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <cuda.h>
#include <device_functions.h>
#include <cuda_runtime_api.h>
#include <curand.h>
#include <curand_kernel.h>
#include <math.h>
#include <stdio.h>
#include <random>
#include <iomanip>
#include <i... |
24,008 | #include "matrix.cuh"
#define PRINT_MAX 10
#define TRUNC(A) ((A) < PRINT_MAX ? (A) : PRINT_MAX)
void Matrix::print(int sz) const // prints the entire matrix
{
if (sz)
{
}
else
{
// print everything
if (gpu_enabled)
{
float* a = new float[dim1*dim2];
... |
24,009 | #include <stdlib.h>
#include <string.h>
#include <time.h>
#include <stdio.h>
#include <math.h>
#include <cuda_runtime.h>
__global__ void sumArraysOnGpu(float *A, float *B, float *C, int fatorUnroll) {
unsigned int idx = blockIdx.x * blockDim.x * fatorUnroll + threadIdx.x;
for (int i = 1; i <= fatorUnroll; i++) {
... |
24,010 | // Date March 28 2029
//Programer: Hemanta Bhattarai
// Progarm : To add two arrays and compare computation time in host and device
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h> //for random numbers
#include <time.h>
#include <sys/time.h>
#define gpuErrchk(a... |
24,011 | #include "includes.h"
__global__ void hierarchical_scan_kernel_phase1(int *X, int *Y, int *S) {
__shared__ int XY[SECTION_SIZE];
__shared__ int AUS[BLOCK_DIM];
int tx = threadIdx.x, bx = blockIdx.x;
int i = bx * SECTION_SIZE + tx;
if (i < INPUT_SIZE) {
// collaborative load in a coalesced manner
for (int j = 0; j < S... |
24,012 | #include <stdio.h>
#include <cuda.h>
#include <cuda_runtime.h>
#define THREADS_PER_BLOCK 256
#define MULTIPLICATIONS 4096
/**
* Multiply square matrix (n x n) by the vector of size n.
*
*
* @param mat Input matrix.
* @param vec Input vector.
* @param out Output vector.
* @param n Dimension.
*/
__global_... |
24,013 | #include "includes.h"
__global__ void kernel_fill_nn_cuda(unsigned int *d_nn, int *nearest_neighbour_indexes, unsigned int number_nearest_neighbour_indexes)
{
int ind=blockIdx.x*blockDim.x+threadIdx.x;
if(ind < number_nearest_neighbour_indexes)
{
if(nearest_neighbour_indexes[ind] < 0)
{
d_nn[ind] = 0;
}else
{
d_nn[in... |
24,014 | #include <stdio.h>
__global__ void doGPUWork(int numData, int *data) {
if (threadIdx.x < numData) {
data[threadIdx.x] = threadIdx.x;
}
}
void sayHello(int *numDevices) {
int numData = 2;
int data[numData];
int dev_data[numData];
int i;
cudaGetDeviceCount(numDevices);
cudaMalloc((void**)&dev_dat... |
24,015 | #include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <cuda_runtime.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <sstream>
#include<random>
using namespace std;
#define X_trn(x, y) X_trn[x * size_train + y] // 196 *... |
24,016 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include "stdio.h"
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
__global__ void isinblock_kernel(float *xy, float x_low, float y_low, float ... |
24,017 | #include <stdio.h>
#include <math.h>
#include <png.h>
#include <string.h>
#include <stdlib.h>
#define MAX_ITERATION 100
#define CEIL(a, b) (((a) + (b) - 1)/(b))
__global__ void kernel(int width, int height, float min_real, float min_imag, float max_real, float max_imag, int iteration, float *buffer);
int writeImage(... |
24,018 |
__global__ void self_initialization(){
}
|
24,019 | __global__
void iterateKernel(int w, int h, int maxIterations, double xOrigin, double yOrigin, double zoomFactor, int* result) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
int stride = blockDim.x * gridDim.x;
for(int p = index; p < w * h; p += stride) {
// deliniarize
int i = p / w;... |
24,020 | #include <stdio.h>
#define N 10000000000
__global__ void add_gpu(float *a, float *b, float *c) {
long long tid = blockIdx.x;
if (tid < N)
c[tid] = a[tid] + b[tid];
}
int main(void) {
float a[N], b[N], c[N];
float *dev_a, *dev_b, *dev_c;
cudaMalloc((void**)&dev_a, N * sizeof(float));
cudaMalloc((void**)&dev... |
24,021 | #include <stdio.h>
#include <cuda.h>
#define CUDA_CHECK(value, label) { \
cudaError_t c = (value); \
if (c != cudaSuccess) { \
fprintf(stderr, \
"Error: '%s' at line %d in %s\n", \
cudaGetErrorString(c),__LIN... |
24,022 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <float.h>
#include <string.h> /* needed library to use strcmp function */
#include <cuda.h>
typedef struct {
float posx;
float posy;
float range;
float temp;
} heatsrc_t;
typedef struct {
unsigned maxiter; /* maximum number of itera... |
24,023 | #include <stdio.h>
int main()
{
int NbDevice = 0;
if (cudaSuccess != cudaGetDeviceCount(&NbDevice))
return -1;
if (!NbDevice)
return -1;
for (int device = 0; device < NbDevice; ++device)
{
cudaDeviceProp propri;
if (cudaSuccess != cudaGetDeviceProperties(&pr... |
24,024 | __global__ void fillOneFloatArrayKernel(
int numberRows,
int numberEntries,
float* array,
float constant) {
int index = blockIdx.x * numberEntries + blockIdx.y * numberRows + threadIdx.x;
array[index] = constant;
} |
24,025 | #define BLOCK_DIM 4
#define TILE_DIM BLOCK_DIM
#include <stdio.h>
#include <stdlib.h>
#include<time.h>
void Print_Matrix( int* mtxArray , int n, int m );
void PrintMatrixToText(int* mtxArray, int height, int width, const char* fileName);
// Matrix Mult Kernel
__global__ void matrixMult(int* A, int* B, int* C, int AR... |
24,026 | //#include<stdio.h>
#include <iostream>
#include <vector>
__global__ void gaxpy(double *y, double *a, double *x, int m, int n){
int bid = blockIdx.x;
int tid = threadIdx.x;
extern __shared__ double dots_s[];
if(bid<m)
if(tid<n){
dots_s[bid*n+tid] = a[bid*n+tid] * *(x+tid);
__syncthreads();
if(tid ==... |
24,027 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
#define WIDTH 10
#define HEIGHT 10
#define channels 3
#define Mask_width 5
#define Mask_radius Mask_width/2
#define O_TILE_WIDTH 12
#define BLOCK_WIDTH (O_TILE_WIDTH+Mask_width-1)
#define min(x,y) ((x)<(y)?(x):(y)... |
24,028 |
/*
Kernel to do temperature update in explicit finite difference
solution to 3-D heat equation. Works for a block size of 16 x 16.
Make copies for other block sizes. Can be easily extended to
arbitrary sized stencils.
*/
# include <stdio.h>
# include <cuda.h>
__global__ void temperature_update16x16... |
24,029 | /*
* This sample implements a separable convolution
* of a 2D image with an arbitrary filter.
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
unsigned int filter_radius;
#define FILTER_LENGTH (2 * filter_radius + 1)
#define ABS(val) ((val)<0.0 ? (-(val)) : (val))
#define accuracy 0.05
typedef f... |
24,030 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <errno.h>
#include <error.h>
#include <unistd.h>
const long BOX_SIZE = 23000; /* size of the data box on one dimension */
#define BLOCK_SIZE 512
#define EXITERROR() error_at_line(errno, errno, __FILE__, __LINE__, "pid %llu", (long l... |
24,031 | // ****
// Implement the phasor method using complex data rather than two times reconstruction
// ****
#define NPOINT 1
#define STRIDE 1
/*__global__ void ThreeD_NLOS_Phasor_General( float* p_xyz, float* p_xyt_real, float* p_xyt_imag,
float* sensor_pos, float* origin, float* laser_pos, float dx, float dz, i... |
24,032 | #define CU1DBLOCK 256
__global__
void _copy_low_upp(float* A, int rows, int stride) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
int j = blockIdx.y * blockDim.y + threadIdx.y;
if (i <= j || i >= rows)
return;
int index_1 = i * stride + j;
int index_2 = j * stride + i;
A[index_2] = A[index_1];
}
// ... |
24,033 | //Strided convolution output stationary
//In this program , INQ weight sharing property is used weights are quatized
//each thread computes one output element. so the matrix elements with common
//weights are added up then just multiplied once.
#include<stdio.h>
#include<cuda.h>
#include<math.h>
#define CUDA_CALL... |
24,034 | #include <stdlib.h>
#include <stdio.h>
#define ARRAY_LENGTH (100)
#define ARRAY_ELEMENT_SIZE (sizeof(long))
#define ARRAY_SIZE (ARRAY_ELEMENT_SIZE * ARRAY_LENGTH)
#define SAMPLE_LENGTH (5)
#define SAMPLE_SIZE (ARRAY_ELEMENT_SIZE * SAMPLE_LENGTH)
#define QUERY_LENGTH (10)
#define QUERY_SIZE (ARRAY_ELEMENT_SIZE * QUERY_... |
24,035 | #include "includes.h"
__global__ void back(double *h_out_d, double *weights_out_d, double *weights_h_d, double *weights_in_d, double *outputs_d, double *deltas_h_d, double *deltas_h_new_d, double *deltas_o_d, double *weights_in_delta_d, double *weights_out_delta_d, double *weights_h_delta_d, int height, int inputs, int... |
24,036 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <cuda.h>
#include <cuda_runtime.h>
#define N 10000000
/*
void vectorAddition(int n, float *vec1, float *vec2, float *out) {
for (int i=0; i<n; i++)
out[i] = vec1[i] + vec2[i];
}
*/
__global__ void vectorAddition(int n, float *vec1, float *... |
24,037 | #define OFFSET(row, col, ncols) (row * ncols + col)
#define NO_BOUND -1
#define EPSILON 0.000001
#define NONBASIC_FLAG 0
#define BASIC_FLAG 1
extern "C"
__global__ void check_bounds(
const int n,
const int offset,
const float* const lower,
const float* const upper,
const float* const assigns,
const unsigned char... |
24,038 | #include "compaction.cuh"
#include <iostream>
int maxThreadsPerBlock = 128;
cudaEvent_t beginEvent;
cudaEvent_t endEvent;
// global calls
void initCuda (int N) {
cudaEventCreate(&beginEvent);
cudaEventCreate(&endEvent);
}
__global__ void naive_scan (float* in_arr, float* scan_arr, int size, int depth) {
int index... |
24,039 | __global__ void bgr2gray(float *g_odata, float *g_idata, int width, int height) {
// printf("%d, %d\\n", width, height);
int des_x = blockIdx.x * blockDim.x + threadIdx.x;
int des_y = blockIdx.y * blockDim.y + threadIdx.y;
if (des_x >= width || des_y >= height)
return;
int des_id = des_y * w... |
24,040 | #include <stdio.h>
#include <iostream>
#include <cuda.h>
#include <math.h>
#include <chrono>
#include <random>
#include <bits/stdc++.h>
using namespace std;
int random_in_range( int minimum, int maximum )
{
thread_local std::ranlux48 rng(
std::chrono::system_clock::now().time_since_epoch().count() );
return s... |
24,041 | #include "stdio.h"
#include "cuda_runtime.h"
// output given cudaDeviceProp
void OutputSpec( const cudaDeviceProp sDevProp )
{
printf( "Device name: %s\n", sDevProp.name );
printf( "Device memory: %d\n", sDevProp.totalGlobalMem );
printf( " Memory per-block: %d\n", sDevProp.sharedMemPerBlock );
printf( " Regis... |
24,042 | #include <iostream>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
#define SIZE 1000
#define TILE 16
__global__ void matMultiplyOnDevice(int* a, int* b, int* c, int m, int n, int k) {
int row = blockIdx.y * blockDim.y + threadIdx.y;
int col = blockIdx.x ... |
24,043 | /* NiuTrans.Tensor - an open-source tensor library
* Copyright (C) 2017, Natural Language Processing Lab, Northeastern University.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the ... |
24,044 | #include "includes.h"
__global__ void bestFilter(const double *Params, const bool *iW, const float *cmax, int *id){
int tid,tind,bid, ind, Nspikes, Nfilters, Nthreads, Nblocks;
float max_running = 0.0f, Th;
Nspikes = (int) Params[0];
Nfilters = (int) Params[2];
Nthreads = block... |
24,045 | #include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <math.h>
#include <cuda.h>
#include <cuComplex.h>
#include <cufft.h>
extern "C" int fftshift(cuComplex *target, unsigned int width, unsigned int height){
unsigned int halfw, halfh;
unsigned int x,y, offset, tmpoffset;
cuComplex tmp13, tmp24;
... |
24,046 | // double indirection, ie float **, in kernel parameter
// this test cuts all gpu buffers from one single gpu buffer
#include <iostream>
#include <memory>
#include <cassert>
using namespace std;
#include <cuda.h>
struct BoundedArray {
float *bounded_array[8];
};
__global__ void wipe(int *buffer, int length) {... |
24,047 | #include <stdio.h>
__global__ void holaCUDA(float e){
printf("Hola, soy el hilo %d del bloque %d con valor pi -> %f\n", threadIdx.x, blockIdx.x,e);
}
int main (int argc, char **argv)
{
holaCUDA<<<3,4>>>(3.1416);
cudaDeviceReset(); //Reinicializa el device
return 0;
}
|
24,048 | #include "includes.h"
__global__ void set_with_value_util_kernel( double2 * __restrict buf, double v, int elem_count)
{
int elem_id = blockDim.x * blockIdx.x + threadIdx.x;
if (elem_id < elem_count)
{
double2 val;
val.x = v;
val.y = v;
buf[elem_id] = val;
}
} |
24,049 | #include <cuda.h>
#include <float.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
typedef struct Data {
float* x;
float* y;
int num_node;
} data;
data* read_data(const char* file) {
data* d = NULL;
FILE* f = fopen (file, "r");
int num_node;
if (fscanf(f, "%5d\n", &num_no... |
24,050 | #include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <stdlib.h>
#include <math.h>
using namespace std;
__device__ void _3Dstencil_(float *d_e,float *d_r,int X,int Y,int Z,int k, int x, int y,int z)
{
int h_r_i = x + ( y * (X) ) + ( z* (X*Y) );
int h_e_i = h_r_i;
d_r[h_r_i] = d_e[h_e_i];
... |
24,051 | #include "includes.h"
__global__ void reset_nan_and_inf_kernel(float *input, size_t size)
{
const int index = blockIdx.x*blockDim.x + threadIdx.x;
if (index < size) {
float val = input[index];
if (isnan(val) || isinf(val)) {
input[index] = 0;
}
}
} |
24,052 | //xfail:REPAIR_ERROR
//--blockDim=2 --gridDim=1 --no-inline
#include <cuda.h>
__global__ void race_test (unsigned int* i, int* A)
{
int tid = threadIdx.x;
int j = atomicAdd(i,0);
A[j] = tid;
}
|
24,053 |
#include <cuda.h>
#include <iostream>
int main() {
CUdevice dev;
cuDeviceGet(&dev, 0);
cudaDeviceProp deviceProp;
cudaGetDeviceProperties(&deviceProp, dev);
printf("%d%d\n", deviceProp.major, deviceProp.minor);
} |
24,054 | #include <stdio.h>
int main(void)
{
int deviceCoint;
cudaDeviceProp devProp;
cudaGetDeviceCount(&deviceCoint);
printf("Found %d devices\n", deviceCoint);
for (int device = 0; device < deviceCoint; ++device)
{
cudaGetDeviceProperties(&devProp, device);
printf("Device: %d\n", device);
printf("Compute cap... |
24,055 | /**
* Author:易培淮
* Mail:yiph@ihep.ac.cn
* Function:Accelerate simulation with Single GPU
* 2018/11/27
*/
#include <cuda.h>
#include <cuda_runtime_api.h>
#include <curand.h>
#include <curand_kernel.h>
#include <stdio.h>
#include <math_constants.h>
#include <assert.h>
typedef struct res_arr
{
double *arr;
int *... |
24,056 | #include "includes.h"
__global__ void mykernel(void)
{
} |
24,057 | #include "includes.h"
__device__ float* deconcatenate(unsigned int x)
{
float * array = new float[32];
for (int i = 0; i < 32; i++)
{
array[i] = (x & ( 1 << i )) >> i;
}
return array;
}
__device__ unsigned int concatenate(float* array)
{
unsigned int rvalue=0;
unsigned int sign;
for (int i = 0; i < 32; i++)
{
sign =... |
24,058 | //STL
#include <iostream>
#include <string>
#include <vector>
#include <time.h>
using namespace std;
///*OCTAVE M-script*/ xfp=single(0.0:0.1:6.3);Xfp=single(dct(xfp));clc;length(Xfp);Xfp(1:5)
unsigned i;
const unsigned N = 2048;
unsigned gpuThr = 256;
unsigned gpuBl = N / gpuThr;
vector < float > inputVec( N );
str... |
24,059 | #include <iostream>
#include <cstdio>
using namespace std;
extern "C" __global__ void helloFromGPU() {
printf("Hello World from GPU thread %d!\n", threadIdx.x);
}
/*int __declspec(dllexport) test(const unsigned int n) {
for (unsigned int i=0; i<n; i++) {
cout << "Hello World from CPU!\n";
helloFromGPU <<<... |
24,060 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <iostream>
// Just for testing
// code from https://stackoverflow.com/questions/13320321/printf-in-my-cuda-kernel-doesnt-result-produce-any-output
__global__
void set1(int *t) {
t[threadIdx.x] = 1;
}
inline bool failed(cudaError_t error) {
... |
24,061 | #include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <stdlib.h>
#include <math.h>
using namespace std;
__global__ void _3Dstencil_global(float *d_e,float *d_r,int X,int Y,int Z,int k){
//int thread_id = threadIdx.x + blockIdx.x * blockDim.x;
//printf("sou id %d || threadIdx.x %d || blockIdx.x %d ... |
24,062 | #include <stdlib.h>
#include <stdio.h>
#include <cstdlib>
#include <math.h>
#include <random>
#include <iostream>
#include <curand_kernel.h>
#include <ctime>
class Particle
{
public:
float3 pos = make_float3(0,0,0);
float3 vel = make_float3(1,1,1);
Particle() {}
Particle(float3 ... |
24,063 | #include<iostream>
#include<algorithm>
#include<iomanip>
#include<time.h>
#include<thrust/host_vector.h>
#include<thrust/device_vector.h>
#include<thrust/sort.h>
#include <thrust/iterator/permutation_iterator.h>
#define N (8<<27)
#define M N/10
template<class T>
class plusOne{
public:
__device__ __host__ T operat... |
24,064 | //device code
__global__ void VecAdd(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];
}
}
//host code
int main()
{
int N = 1024;
size_t size = N*sizeof(float);
//allocate input vectors in host memory
float* h_A = (float*)malloc(size);
f... |
24,065 | #include "includes.h"
__global__ void kernelBackprop1(float *delta_nabla_w,int w_off,float *activations,float *delta_nabla_b,int b_off) {
delta_nabla_w[w_off+(blockIdx.x*blockDim.x)+threadIdx.x]=activations[threadIdx.x]*delta_nabla_b[b_off+blockIdx.x];
//delta_nabla_w[w_off+(threadIdx.x*gridDim.x)+blockIdx.x]=activatio... |
24,066 | // https://www.jianshu.com/p/a0184e73a460
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <math.h>
#define w 2000
struct Matrix
{
int width;
int height;
float *elements;
};
__device__ float getElement(Matrix *A, int ro... |
24,067 | extern "C" __device__ void kernel(int* result) { *result = 1; }
|
24,068 | /* Utility program. Convert input into a format that the spiking-visualizer can
* easily use. */
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
int format(void)
{
char line[LINE_MAX];
int time = 0;
float value;
while (fgets(line, LINE_MAX, stdin) != NULL) {
value = strtof(line, NULL);
p... |
24,069 |
/* Implementation of a XOR neural network in CUDA */
#include <stdio.h>
// weights for the hidden layer
float weights_h[] = { 0.5f, -1.0f, -1.0f,
-1.5f, 1.0f, 1.0f };
// weights for the output layer
float weights_o[] = { 0.5f, -1.0f, -1.0f };
// weight arrays for the device
float *dev_hw;
fl... |
24,070 | #include <thrust/set_operations.h>
#include <thrust/host_vector.h>
#include <stdio.h>
int main()
{
int A1[7] = {13, 1, 5, 3, 1, 1, 0};
int A2[7] = {13, 8, 5, 3, 2, 1, 1};
thrust::host_vector<int> result(7);
thrust::host_vector<int>::iterator result_end;
result_end = thrust::set_intersection(A1, A1 + 7, A2, A2... |
24,071 | #include "sample.cuh"
__device__ double
generateRandom(curandState *state)
{
double result = abs(curand_uniform_double(state));
return result;
}
__device__ int
generateRandomInt(curandState *state,int begin,int end)
{
int result = begin+int(ceil(abs(curand_uniform_double(state))*(end-begin)));
return... |
24,072 | #include<stdio.h>
#define CHECK(res) if(res!=cudaSuccess){exit(-1);}
const int width=5;
const int height=22;
const int size=width*height*sizeof(int );
//const int size=sizeof(int)*width;
/*__global__ void kerneltest(int **b,size_t pitch)
{
printf("(%d,%d)\n",threadIdx.x,threadIdx.y);
int *c=(int *)((char *)b+threadI... |
24,073 | #include "includes.h"
__global__ void entrySearch_max_int_kernel(int *g_iarr, int *g_maxarr, int size)
{
// create shared memory
extern __shared__ int sarr_int[];
// load shared mem
unsigned int tid = threadIdx.x;
unsigned int i = blockIdx.x * blockDim.x * 2 + threadIdx.x;
if(i + blockDim.x < size) {
if(g_iarr[i] > g... |
24,074 | #include <iostream>
#include <math.h>
int I = 500;
int J = 500;
int K = 500;
__global__
void mul(int I, int J, int K, float *x, float *y, float *z)
{
int index = blockIdx.x * blockDim.x + threadIdx.x;
int stride = blockDim.x * gridDim.x;
for(int q=index; q<I*K; q+=stride) {
int i = q / K;
int k = q % ... |
24,075 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
// Step 1: Query Device for maximum block sizes and thread sizes
// (not really sure what we care about)
// Step 2: Take in user input to specify data dimensions
// Step 3: Check to make sure user inputs match with specified program device que... |
24,076 | #include "includes.h"
__global__ void KerInOutUpdateVelrhopM1(unsigned n,const int *inoutpart ,const float4 *velrhop,float4 *velrhopm1)
{
const unsigned cp=blockIdx.x*blockDim.x + threadIdx.x; //-Number of particle.
if(cp<n){
const unsigned p=inoutpart[cp];
velrhopm1[p]=velrhop[p];
}
} |
24,077 | /*-----------
*
* matrixMulGlobal.cu
*
* This is the source file for matrix multiplication with global memory only.
*
* This kernel is from NVIDIA CUDA samples. reduction_kernel.cu.
*
* streamsOptBenchmark/reduction_kernel.cu
*
* By Hao Li
*
*------------
*/
/*
Parallel reduction kernels
*/
#include ... |
24,078 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <math.h>
__global__ void adicionarKernel(double* resultado, const double* n) {
int i = threadIdx.x;
double a = 1, b = 0;
double delta = pow(b, 2) - (4 * a * (n[i] * -1));
resultado[i] = ((b * -1) + sqrt(delta)) / 2 * a;
}
... |
24,079 | /*#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
#define TILE_SIZE 4
#define INPUT_SIZE 12
#define MASK_WIDTH 5
__constant__ float M[MASK_WIDTH];
__global__ void convolution_shared_memory(float* N, float* P) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
_... |
24,080 | #include<stdio.h>
#include<stdlib.h>
#include<curand_kernel.h>
#include<curand.h>
#include<sys/time.h>
unsigned int NUM_PARTICLES = 1000;
unsigned int NUM_ITERATIONS = 100;
unsigned int BLOCK_SIZE = 512;
unsigned int GRID_SIZE = ((NUM_PARTICLES)/BLOCK_SIZE);
typedef struct {
float posX;
float posY;
float posZ;
}po... |
24,081 | extern "C"
__global__ void compute_probs(double* alphas, double* rands, double* probs, int n, int K, int M) {
// assign overall id/index of the thread = id of row
int i = blockIdx.x * blockDim.x + threadIdx.x;
if(i < n) {
double maxval;
int m, k;
int maxind;
double M_d = (doubl... |
24,082 | #include <stdio.h>
#include <iostream>
#include <iomanip>
#include <cuda.h>
#include <cuda_runtime.h>
#include <cuda_runtime_api.h>
#include <cassert>
#include <algorithm>
#define checkCudaErrors(val) check( (val), #val, __FILE__, __LINE__)
template<typename T>
void check(T err, const char* const func, const char* co... |
24,083 | #include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include <curand_kernel.h>
#include <stdlib.h>
#include <cuda.h>
#include <sys/time.h>
#include "g_updatePrimalVar.cu"
#include<chrono>
#include<iostream>
using namespace std;
using namespace std::chrono;
int blocks_[20][2] = {{8,8},{16,16}... |
24,084 | #include "includes.h"
__global__ void BaseNeuronSetFloatPtArray(float *arr, int *pos, int n_elem, int step, float val)
{
int array_idx = threadIdx.x + blockIdx.x * blockDim.x;
if (array_idx<n_elem) {
arr[pos[array_idx]*step] = val;
}
} |
24,085 | #include <cmath>
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <random>
#include <chrono>
#include <stdio.h>
#include <fstream>
#define SQRT2PI 2.50662827463100050241
#define BLOCK_SIZE 512
#define SHARED_MEM_SIZE 2048
__device__ float gauss_kernel(float x){
return exp(... |
24,086 | #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) )
#... |
24,087 |
#include <iostream>
using namespace std;
__global__ void kernel( int* b, int* t)
{
b[blockIdx.x] = blockIdx.x; // Blocks in the grid
*t = blockDim.x; // Treads per block
}
int main()
{
int* b;
int* d_b;
int t;
int* d_t;
int numblocks = 4;
b = new int[numblocks];
// store in d_b the address of a... |
24,088 | #include "includes.h"
__global__ void transpose_v1(float* a,float* b, int n){
int i = blockIdx.x*blockDim.x + threadIdx.x;
int j = blockIdx.y*blockDim.y + threadIdx.y;
if(i >= n || j >= n) return;
b[n*j+i] = a[n*i+j];
} |
24,089 | #include "includes.h"
__global__ void orthogonalize23( float *Qi_gdof, int *blocksizes, int numblocks, int largestblock ) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
for( int j = 4; j < 6; j++ ) {
for( int k = 3; k < j; k++ ) { // <-- vectors we're orthognalizing against
float dot_prod = 0.0;
for( int l = 0; l < b... |
24,090 | #include<stdio.h>
__global__ void kernel(int *array,int goal,bool *flag,int size)
{
int index = blockIdx.x * blockDim.x + threadIdx.x;
int first = index * size ;
int last = first + size;
int middle = (first+last)/2;
while (first <= last) {
if (array[middle] < goal)
first = middl... |
24,091 | #include "includes.h"
__global__ void vecAdd(float *in1, float *in2, float *out, int len) {
//@@ Insert code to implement vector addition here
} |
24,092 | // This example demonstrates parallel floating point vector
// addition with a simple __global__ function.
#include <stdlib.h>
#include <stdio.h>
// this kernel computes the vector sum c = a + b
// each thread performs one pair-wise addition
__global__ void vector_add(const float *a,
const... |
24,093 | extern "C" {
__global__ void Vector_Addition(int *a, int *b, int *c)
{
int tid = blockIdx.x;
if (tid < 100)
c[tid] = a[tid] + b[tid];
}
}
|
24,094 | #include <math.h>
#include <iostream>
#include "device_launch_parameters.h"
#include "cuda_runtime.h"
#include "chebyshev.cuh"
#include "kernel.cu"
#include <string>
#include <stdlib.h>
#include <math.h>
#define Im1 0 // i - 1
#define I 1 // i
#define Ip1 2 // i + 1
using n... |
24,095 | #include "includes.h"
__global__ void normalize_N(float* N, float* norm, int npix_per_component) {
int i = blockIdx.x*blockDim.x + threadIdx.x;
int c = blockIdx.y*blockDim.y + threadIdx.y;
if (i < npix_per_component) {
N[c*npix_per_component + i] = N[c*npix_per_component + i] / norm[i];
}
} |
24,096 | #include "vector.cuh"
__device__ void
append_res_arr(Res_Arr *p, double val)//追加,可能成功,可能失败
{
p->arr[p->index+p->pmt_list[p->id]] = val;
p->pmt_list[p->id] += 1;
return;
}
__device__ void
init_res_arr(Res_Arr *p,double *result,int *pmt_res_list,int pmtid,int size){
p->arr = result;//存储的内存空间
p->pmt... |
24,097 | #include "stdio.h"
#include "cuda_runtime.h"
#include <cuda_runtime_api.h>
#include "device_launch_parameters.h"
#define THREADS 1024
#define gpu_error_check(ans) { gpu_assert((ans), __FILE__, __LINE__); }
inline void gpu_assert(cudaError_t code, const char *file, int line, bool abort=true)
{
if (code != cudaSucce... |
24,098 | /******************************************************************************
*cr
*cr (C) Copyright 2010-2013 The Board of Trustees of the
*cr University of Illinois
*cr All Rights Reserved
*cr
***************************************************************... |
24,099 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <cstdio>
void query_device()
{
int deviceCount = 0;
cudaGetDeviceCount(&deviceCount);
if (deviceCount == 0) {
printf("No CUDA Support device found!");
}
int devNo = 0;
cudaDeviceProp iProp;
cudaGetDeviceProp... |
24,100 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <cstring>
#include <stdio.h>
#include <string>
__global__ void checkPointer(const int* c, const size_t pitch, const size_t num, const size_t nrows, const size_t ncols);
__global__ void checkPointer(const int *c, const size_t pitch, const size... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.