serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
6,201 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
float secuential(const int array[] , int dim){
float mean=0;
for(int i=0; i<dim;i++){
mean+=array[i];
}
mean=mean/dim;
float sum=0;
for(int i=0; i<dim;i++){
sum+=(arr... |
6,202 | #include <stdlib.h>
#include <stdio.h>
__global__ void addVectors(int *a, int *b, int *c, int n) {
int thread = threadIdx.x;
if(thread < n)
c[thread] = a[thread] + b[thread];
}
int main() {
int *a = NULL;
int *b = NULL;
int *c = NULL;
int *dev_a = NULL;
int *dev_b = NULL;
int *dev_c = NULL;
int size = 10;... |
6,203 | #include "includes.h"
__device__ float length(float3 vec)
{
return sqrt(vec.x*vec.x + vec.y*vec.y + vec.z*vec.z);
}
__device__ float length4(float4 vec)
{
return sqrt(vec.x*vec.x + vec.y*vec.y + vec.z*vec.z);
}
__global__ void SampleVelocitiesSlicedDev(float* velocities, const uint slice, const float4* vels_data, const... |
6,204 | #include <stdio.h>
#include <string.h>
#include <cuda.h>
#define THREADS_PER_BLOCK 256
__global__ void best_shuffle(const char *s, char *r, int *diff, int n);
__device__ void update_buf(int *cnt, char *buf);
__device__ int find_max(const char *s, int *cnt, int n);
char * get_input_word(int argc, char *argv[]);
/*
... |
6,205 | #include <stdio.h>
#include <iostream>
#include <cstdlib>
#include<chrono>
int main(void) {
double gammaEulera = 0.;
double N = 1000000;;
auto start = std::chrono::high_resolution_clock::now();
for (int i = 1; i < N; i++)
gammaEulera = gammaEulera + (1. / (double)i);
gammaEule... |
6,206 | #include <math.h>
#include <malloc.h>
#define ABS(a) (a>0?a:-(a))
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define BLOCK_SIZE_x 16
#define BLOCK_SIZE_y 16
const float eps=1e-8;
extern "C" void Atx_cone_mf_gpu_new(float *X,float *y,float *sc,float cos_phi,float sin_phi,float *y_det,float *z_det,
float S... |
6,207 | __global__ void update_e( int Nx, int Ny, int Nz, float *Ex, float *Ey, float *Ez, float *Hx, float *Hy, float *Hz, float *CEx, float *CEy, float *CEz ) {
int idx = blockIdx.x*blockDim.x + threadIdx.x;
int Nyz = Ny*Nz;
int i = idx/Nyz;
int j = ( idx - i*Nyz )/Nz;
int k = idx - i*Nyz - j*Nz;
if ( i > 0 && j > 0 ... |
6,208 | /*
* Copyright 2021 Roman Klassen
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writin... |
6,209 |
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <time.h>
#include <sys/time.h>
#include <curand_kernel.h>
#define D 5
#define BLOCKS 125
#define THREADS 25
#define N 5
__global__ void simpson_int(double *res) {
unsigned int tid = threadIdx.x + blockDim.x*blockIdx.x;
... |
6,210 | #include "includes.h"
__global__ void reduceGmem(int *g_idata, int *g_odata, unsigned int n)
{
// set thread ID
unsigned int tid = threadIdx.x;
int *idata = g_idata + blockIdx.x * blockDim.x;
// boundary check
unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx >= n) return;
// in-place reduction in gl... |
6,211 | __global__ void calculate_inner_grid(double* grid_0, double* grid_1, double* grid_2, int bx, int by, int bz){
int N = (bx + 2) * (by + 2) * (bz * 2);
int idx = blockIdx.x * blockDim.x + threadIdx.x;
int i, j, k;
double uijk = grid_1[idx], laplace = 0.;
i = N % (bx + 2);
if (i < 2 && i >= bx) ret... |
6,212 |
/*
This function takes the set of points (xj,yj) defining a closed curve
and populates the signed distance function Phi.
The time for this should be of order Nx*Ny*points.
Each of the Nx*Ny grid point independently loops through all points to determine
its minDist from curve and if it is located inside or outside ... |
6,213 | /*
compile the program as:
nvcc -arch sm_75 hello.cu -o hello
其中sm_后面的数字随着显卡架构不同而不同
75对应的是Turing架构
*/
#include <stdio.h>
__global__ void helloFromGPU()
{
if(threadIdx.x == 5)
printf("Hello World from GPU !\n");
}
int main()
{
printf("Hello World from CPU !\n");
helloFromGPU <<<1, 10>>>();
cudaDe... |
6,214 | #include <iostream>
#include <chrono>
#include <cuda_profiler_api.h>
__global__ void parallel_for(const int n, double* dax, double* dbx,
const double dt) {
int tid = threadIdx.x + blockIdx.x*blockDim.x;
if (tid < n) {
dax[tid] = dax[tid] + dbx[tid]*dt;
}
}
int main()
{... |
6,215 | #include <iostream>
#include <cuda.h>
#include <stdio.h>
using namespace std;
#define N 20
__global__ void addition(int *a, int *b, int *c)
{
int tid = blockIdx.x;
if (tid < N)
c[tid] = a[tid] + b[tid];
}
int main()
{
int a[N], b[N], c[N];
int *dev_a, *dev_b, *dev_c;
int size = N*sizeof(int);
int i;... |
6,216 | #include "includes.h"
__global__ void sumMatrixOnGPUMix(float *MatA, float *MatB, float *MatC, int nx, int ny)
{
unsigned int nxthreads = gridDim.x * blockDim.x;
unsigned int iy = blockIdx.y;
unsigned int ix = threadIdx.x + blockIdx.x * blockDim.x;
unsigned int ix2 = ix + nxthreads;
unsigned int idx = iy * nx + ix;
un... |
6,217 | #include "includes.h"
__global__ void arrayFill(float* data, float value, int size) {
int stride = gridDim.x * blockDim.x;
int tid = threadIdx.x + blockIdx.x * blockDim.x;
for (int i = tid; i < size; i += stride) data[i] = value;
} |
6,218 | #include <stdio.h>
#include <cmath>
#include "Cuda/PBKDF2.cu"
#define ERRCHECK(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true,bool wait=true) {
if (code != cudaSuccess) {
fprintf(stderr,"GPUassert: %s %s %d\n", cudaGetErrorStr... |
6,219 | #include <cuda.h>
#include <cuda_runtime.h>
#include <cuda_runtime_api.h>
#include <device_launch_parameters.h>
#include <iostream>
template <class scalar_t>
__global__ void axpy (scalar_t a, scalar_t *x, scalar_t *y)
{
y[threadIdx.x] = a * x[threadIdx.x];
}
template <class scalar_t>
void run_it (scalar_t a, scalar... |
6,220 | #include "includes.h"
__global__ void vector_add(double const *A_dev, double const *B_dev, double *C_dev, int const N) {
int i = blockDim.x * blockIdx.x + threadIdx.x;
/* if(i%512==0)
* printf("index %d\n",i); */
if (i < N)
C_dev[i] = A_dev[i] + B_dev[i];
} |
6,221 | #include <cuda.h>
#include <stdio.h>
#define N 16
// Tipo de los datos del algoritmo
typedef int data_t;
// Prototipos
data_t add(const data_t a, const data_t b) { return a + b; }
data_t sub(const data_t a, const data_t b) { return a - b; }
void init_matrix(data_t *M, const unsigned int size, data_t(*init_op)(... |
6,222 | /**
*Developed By Karan Bhagat
*March 2017
**/
#include <stdio.h>
#include <stdlib.h>
//cuda kernel for multiplying two matrices without tiling
__global__ void matrix_mul_kernel(int* a, int* b, int* c, int a_rows, int a_columns, int b_columns)
{
int col = blockIdx.x * blockDim.x + threadIdx.x;
int row = blockIdx.y ... |
6,223 | template<typename T>
__device__ void sumRows(const T* matrix, T* result,
const int rows, const int cols) {
int bx = blockIdx.x;
int tx = threadIdx.x;
int col = bx * blockDim.x + tx;
if (col < cols) {
T sum = 0;
#pragma unroll
for (int i = 0; i < rows; i++) {
int index ... |
6,224 | #include "includes.h"
// filename: vsquare.cu
// a simple CUDA kernel to element multiply vector with itself
extern "C" // ensure function name to be exactly "vsquare"
{
}
__global__ void expkernel(const int lengthA, const double *a, double *b)
{
int i = threadIdx.x + blockIdx.x * blockDim.x;
if (i<lengthA)
{
b[i] ... |
6,225 | #include "includes.h"
#define SIZ 20
#define num_inp 4
using namespace std;
typedef struct edge {
int first, second;
} edges;
__global__ void grads_w1_kernel(double * grads_W1,double * W1,double reg, int size)
{
int i = blockIdx.x;
int j = threadIdx.x;
grads_W1[i*size + j] += W1[i*size + j] * reg;
} |
6,226 | //Example CUDA code, written and commented by Jose Monsalve
//Taken from CUDA C/C++ Basics
//Supercomputing 2011 Tutorial
//by NVIDIA
/**
This code executes c=a+b in a single thread in a GPU device.
It is a really simple code that is intended to show the memory
movement between host and device, but not the division... |
6,227 | #include "user_host.cuh"
__host__
void host_maxValueVector(float *vec, int vector_size, float *p_ret_val) {
float maxVal = FLOAT_MIN_VAL;
for (int i = 0; i < vector_size; i++) {
maxVal = (maxVal < vec[i]) ? vec[i] : maxVal;
}
*p_ret_val = maxVal;
}
|
6,228 | #include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <iostream>
struct COLOR {
uint8_t R;
uint8_t G;
uint8_t B;
};
std::ostream &operator<<(std::ostream &os, COLOR const &m) {
return os << m.R << " " << m.G << " " << m.B;
}
int main(void)
{
const int height = 1;
const i... |
6,229 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
int main( int argc, char* argv[] )
{
// Size of vectors
int n = 10;
// Device input vectors
double *d_a;
// Size, in bytes, of each vector
size_t bytes = n*sizeof(double);
// Allocate memory for each vec... |
6,230 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <cuda_runtime_api.h>
__global__ void add(int *a, int *b, int *c, int tmp) {
*c = *a + *b + tmp;
printf("add\n");
printf("%d %d\n", *a, tmp);
}
int main() {
int a, b, c;
int *d_a, *d_b, *d_c;
int size = sizeof(int);
cudaMalloc((void**)&d_a, si... |
6,231 | #include "includes.h"
__global__ void kernel_setweights(int N, double *wt, double alpha){
unsigned int tid = blockIdx.x*blockDim.x + threadIdx.x;
/* make sure to use only N threads */
if (tid<N) {
wt[tid]=alpha;
}
} |
6,232 | #include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
#define BLOCK_SIZE 16
#define HANDLE_ERROR( err ) (HandleError( err, __FILE__, __LINE__ ))
static void HandleError(cudaError_t err, const char *file, int line)
{
if (err != cudaSuccess) {
printf("%s in %s at line %d\n", cudaG... |
6,233 | #include <thrust/gather.h>
#include <thrust/sort.h>
#include <thrust/binary_search.h>
#include <thrust/device_vector.h>
//#include <cuda.h>
#include <thrust/copy.h>
#include <thrust/device_ptr.h>
#include <thrust/sequence.h>
#include <thrust/scan.h>
#include <thrust/transform.h>
#include <thrust/reduce.h>
#include <thr... |
6,234 | #include "includes.h"
__global__ void multiply(int *result, int *A, int *B)
{
/* OLD logic
We have a 3 by 3 grid and each block has 3 threads.
So rows = block x id, cols = block y id
So Indices will be C[block X id][block Y id] = A[block X id][threads 0, 1, 2] * B[threads 0, 1, 2][block y id]
*/
//__shared__ int result... |
6,235 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <chrono>
__global__ void add_OneBlockOneThread(int n, float *x, float *y, float *z)
{
for (int i = 0; i < n; i++)
z[i] = x[i] + y[i];
}
__global__ void add_OneBlockManyThreads(int n... |
6,236 | #include <stdio.h>
__global__ void kernel_example(int value) {
printf("[GPU] Hello from the GPU!\n");
printf("[GPU] The value is %d\n", value);
printf("[GPU] blockDim = %d, blockId = %d, threadIdx = %d\n", blockDim.x, blockIdx.x, threadIdx.x);
}
int main(void) {
int nDevices;
printf("[HOST] Hell... |
6,237 | #pragma once
#include <iostream>
namespace RayTracing
{
class Vector3
{
public:
float4 d;
public:
__host__ __device__
Vector3() : d({ 0, 0, 0, 0}) {}
__host__ __device__
Vector3(float x, float y, float z, float w=0) : d({ x, y, z, w }) {}
__host__ __device__
Vector3(const float4 &v) : ... |
6,238 | #include "includes.h"
__global__ void getIntYArray_kernel(int2* d_input, int startPos, int rLen, int* d_output)
{
const int by = blockIdx.y;
const int bx = blockIdx.x;
const int tx = threadIdx.x;
const int ty = threadIdx.y;
const int tid=tx+ty*blockDim.x;
const int bid=bx+by*gridDim.x;
const int numThread=blockDim.x;
c... |
6,239 |
/* 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... |
6,240 | #include "includes.h"
__global__ void glcm_calculation_135(int *A,int *glcm, const int nx, const int ny,int max){
int ix = threadIdx.x + blockIdx.x* blockDim.x;
int iy = threadIdx.y + blockIdx.y* blockDim.y;
unsigned int idx =iy*nx+ix;
int i;
int k=0;
for(i=0;i<nx-1;i++){
if(blockIdx.x==i && idx >i*nx){
k=max*A[idx]+A[... |
6,241 | // System includes
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
// CUDA runtime
#include <cuda_runtime.h>
// Helper functions and utilities to work with CUDA
//#include <helper_functions.h>
#define rowOffset(X) ((((X) - 1) * ((X) - 1)) / 4)
__global__ void binom(unsigned long *table, const int n)
{
... |
6,242 | #include "includes.h"
__global__ void decrementalColouringNew (int *vertexArray, int *neighbourArray, int n, int m, int *decrementalArray, int size){
int i = blockDim.x * blockIdx.x + threadIdx.x;
if (i >= size){
return;
}
int startStart, startStop;
int me, you;
// int otheri;
// bool ipercent2 = false;
me = decr... |
6,243 | #include "includes.h"
#define MINVAL 1e-7
__global__ void Gaus(double* Mtr, int Size, int i)
{
int index=blockIdx.x*blockDim.x+threadIdx.x;
if(index>i && index< Size)
{
double particial = -Mtr[i*Size+index]/Mtr[i*Size+i];
for(int z=i; z<Size; z++)
{
Mtr[z*Size+index]=Mtr[z*Size+index]+Mtr[z*Size+i]*particial;
}
}
} |
6,244 | /* 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 ... |
6,245 | #include "includes.h"
__global__ void kernel2( int *a, int dimx, int dimy )
{
int ix = blockIdx.x*blockDim.x + threadIdx.x;
int iy = blockIdx.y*blockDim.y + threadIdx.y;
int idx = iy * dimx + ix;
if(iy < dimy && ix < dimx)
a[idx] = (blockIdx.y * gridDim.x) + blockIdx.x;
} |
6,246 | #include "includes.h"
__global__ void multVector(int *d1_in, int *d2_in, int *d_out, int n, int m){
int ind = blockDim.x*blockIdx.x + threadIdx.x;
if(ind<m){
d_out[ind]=0;
for(int i=0;i<n;i++){
d_out[ind]+= d1_in[i]*d2_in[i*m+ind];
}
}
} |
6,247 | //xfail:REPAIR_ERROR
//--blockDim=8 --gridDim=1 --no-inline
// The statically given values for A are not preserved when we translate CUDA
// since the host is free to change the contents of A.
// cf. testsuite/OpenCL/globalarray/pass2
__constant__ int A[8] = {0,1,2,3,4,5,6,7};
__global__ void globalarray(float* p) {... |
6,248 | extern "C" {
typedef struct {
int e0;
char* e1;
} struct_Buffer_6327;
typedef struct {
struct_Buffer_6327 e0;
struct_Buffer_6327 e1;
int e2;
int e3;
} struct_image_6326;
typedef struct {
struct_Buffer_6327 e0;
int e1;
int e2;
} struct_filter_6332;
__device__ inline int threadIdx_x()... |
6,249 | //
// Created by alex on 7/16/20.
//
#include <cstdio>
#include <arpa/inet.h>
#include <iostream>
#include "udp_transport.cuh"
UdpTransport::UdpTransport(string localAddr, string mcastAddr, eTransportRole role) {
s_localAddr = localAddr;
s_mcastAddr = mcastAddr;
n_mcastPort = 6655; //TODO: does this mat... |
6,250 | #include "includes.h"
__global__ void swap(unsigned int *in, unsigned int *in_pos, unsigned int *out, unsigned int *out_pos, unsigned int n)
{
unsigned int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < n)
{
in[i] = in[i] ^ out[i];
out[i] = in[i] ^ out[i];
in[i] = in[i] ^ out[i];
in_pos[i] = in_pos[i] ^ out_p... |
6,251 | #include "includes.h"
__global__ void mirrorImage_kernel(uint width, uint height, uint border, uint borderWidth, uint borderHeight, float* devInput, float* devOutput) {
int x0 = blockDim.x * blockIdx.x + threadIdx.x;
int y0 = blockDim.y * blockIdx.y + threadIdx.y;
if ((x0 < borderWidth) && (y0 < borderHeight)) {
int x1... |
6,252 | #include "includes.h"
__global__ void GaussianMinMaxField(float* input, int inputCount, float* mins, float* maxes)
{
int i = blockDim.x * blockIdx.y * gridDim.x //rows preceeding current row in grid
+ blockDim.x * blockIdx.x //blocks preceeding current block
+ threadIdx.x;
if (i < inputCount)
{
mins[i] = fminf(mins... |
6,253 | #include "includes.h"
//CUDA reduction algorithm. simple approach
//Tom Dale
//11-20-18
using namespace std;
#define N 100000//number of input values
#define R 100//reduction factor
#define F (1+((N-1)/R))//how many values will be in the final output
//basicRun will F number of threads go through R number of values... |
6,254 | #include <stdio.h>
#include <random>
#include <chrono>
#include <iostream>
__device__
unsigned int floatFlip(unsigned int value)
{
unsigned int mask = (-(value >> 31)) | 0x80000000;
return value ^ mask;
}
__device__
unsigned int floatFlipInverse(unsigned int value)
{
int mask = ((value >> 31) - 1) | 0x80000000;
... |
6,255 | __device__ int evalRamp() {
return 400;
} |
6,256 | #include "includes.h"
#define TILE_WIDTH 40
//-----------------------------------------------
//--------------------------------------------------
// Compute C = A * B
//-------------------------------------------------
__global__ void MatrixMult(int m, int n, int k, double *a, double *b, double *c)
{
int row ... |
6,257 | #include <iostream>
#include <fstream>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <stdlib.h>
#include<sys/time.h>
using namespace std;
//-----------------------DO NOT CHANGE NAMES, ONLY MODIFY VALUES--------------------------------------------
//Final Values that will be compared for correctness... |
6,258 | #include <cuda.h>
#include <iostream>
#define nPerThread 16
using namespace std;
/* Synchronization
* - Synchronize threads in a block
*/
__global__ void myKernel(int n, double *data) {
int t = threadIdx.x;
int nt = blockDim.x;
// initialize values
for (int i=0; i<nPerThread; i++)
data[nt*i+t] = double(n... |
6,259 | #include "includes.h"
__global__ void softmax_linear(float* softmaxP, float* b, int rows, int cols){
int tid = threadIdx.x;
int bid = blockIdx.x;
float _max = -100000000.0;
float sum = 0.0;
extern __shared__ float _share[];
if(tid * cols + bid < rows * cols){
for(int i = 0 ; i < rows ; i++) _share[i] = b[i * cols + ... |
6,260 | //#include "crop_cuda.h"
//
//#include <stdio.h>
//#include <cstdlib>
//#include <math.h>
//#include <iostream>
//
//#include "../common/macro.h"
//
//#define PIXEL_PER_THREAD 128
//
//namespace va_cv {
//
//texture<unsigned char> tex_src;
//__constant__ int rect[5];
//
//
//
//__global__ void kernel_crop_grey(unsigne... |
6,261 |
#include <cuda.h>
#include <stdlib.h>
#include <stdio.h>
//#include <cutil.h>
#define BLOCK_X 16
#define BLOCK_Y 16
__global__ void convolutionKernel( float *pSrcImg)
{
int x,
y;
x = threadIdx.x + blockDim.x * blockIdx.x;
y = threadIdx.y + blockDim.y * blockIdx.y;
pSrcImg[x + y*blockDim.x] = 1;
}
void pce(... |
6,262 | /**
* Copyright 2021 RICOS Co. Ltd.
*
* This file is a part of ricosjp/monolish,
* and distributed under Apache-2.0 License
* https://github.com/ricosjp/monolish
*/
#include "cuda_runtime.h"
#include <iostream>
int main(int argc, char **argv) {
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " [devi... |
6,263 | // The dataset generator generates all the datasets into one single pair of input files.
#include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <thrust/transform.h>
#include <thrust/fill.h>
#include <math.h>
using namespace std;
float tru... |
6,264 | #include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
#include <sys/time.h>
__host__
void printtime(struct timeval *start,struct timeval *stop) {
long time=1000000*(stop->tv_sec-start->tv_sec)+stop->tv_usec-start->tv_usec;
printf("\nCUDA execution time=%ld microseconds\n",time);
}
int main(int argc... |
6,265 | #include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <cuda.h>
#include <device_launch_parameters.h>
#define LIST_SIZE 100000
extern "C" __device__ unsigned long long mulValue1List[LIST_SIZE];
extern "C" __device__ unsigned long long mulValue... |
6,266 | #include <cuda_runtime.h>
#include <cuda.h>
__device__ int ptr=0;
__global__ void a()
{
int b[100];
//atomicAdd(&ptr,1);
b[0]=ptr;
#pragma unroll
for(int i=1; i<200; i++)
{
// for(int j=1;j<90;j++)
{
//b[i][j]=b[i-1][j-1]+1;
b[i] = b[i-1]+1;
}
}
ptr=b[7]+1;
}
int main()
{... |
6,267 | #include <stdio.h>
#include <cuda_runtime.h>
__device__ float fx(float a, float b) {
return a + b;
}
__global__ void kernel(void) {
printf("res = %f\n", fx(1.0, 2.0));
}
int main(int argc, char* argv[]) {
kernel <<<1,1>>>();
cudaDeviceSynchronize();
return 0;
}
|
6,268 | #include "includes.h"
__global__ void initKernel(){
return;
} |
6,269 | #include "includes.h"
__global__ void glcm_calculation_45(int *A,int *glcm, const int nx, const int ny,int max){
int ix = threadIdx.x + blockIdx.x* blockDim.x;
int iy = threadIdx.y + blockIdx.y* blockDim.y;
unsigned int idx =iy*nx+ix;
int i;
int k=0;
for(i=1;i<nx;i++){
if(blockIdx.x==i && idx <((i+1)*nx)-1){
k=max*A[id... |
6,270 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <limits.h>
#include <math.h>
#include <cuda.h>
#include <algorithm>
#define BLOCK_SIZE 1024
__device__ unsigned int counter, counter_2;
//__device__ unsigned int flag;
__constant__ const unsigned int INTMAX = 2147483647;
// struct... |
6,271 | #include <stdio.h>
/* ************************************************** FIRST LAYER START ********************************************************* */
/*
Layer 1: Normal 3D Convolution Layer
Input: 225 * 225 * 3 (Padding of 1)
Weight: 3 * 3 * 3 with a Stride of 2
Output: 112 * 112 * 32
Next Layer... |
6,272 | #define I(d,i,j) (i)*(d)+(j)
typedef struct{
float *v;
int d;
int size;
} Grid;
__global__ void cero(Grid m){
int i = blockIdx.x * blockDim.x + threadIdx.x;
int j = blockIdx.y * blockDim.y + threadIdx.y;
if(1<=m.d && j<=m.d)
m.v[I(m.d,i,j)]=0.0;
}
__global__ void random(Grid m){
int i = blockIdx.x * blockD... |
6,273 | #include <cuda.h>
#include <stdio.h>
#include <math.h>
#define SIZ 1024
__global__ //이게 device에서 실행될 function 각 thread가 일정량실행
void countnum(int* countarr,int* datarr,int n){ //threadIdx.x+blockDim.x*blockIdx.x
int i=threadIdx.x+blockDim.x * blockIdx.x;
if(i<n)
{
int num=datarr[i];
atomicAdd(&countarr[num],1);
}... |
6,274 | // This is a CUDA program that does the following:
//
// 1. On the host, fill the A and B arrays with random numbers
// 2. On the host, print the initial values of the A and B arrays
// 3. Copy the A and B arrays from the host to the device
// 4. On the device, add the A and B vectors and store the result in C
// 5. Co... |
6,275 | extern "C"
__global__ void backwardSquaredLossKernel (int length, float *predictions, float *targets, float *result)
{
int index = blockIdx.x * blockDim.x + threadIdx.x;
if(index < length) {
result[index] = predictions[index] - targets[index];
}
} |
6,276 | #include "includes.h"
__global__ void ComputeConstantResidualKernel (double *VMed, double *invRmed, int *Nshift, int *NoSplitAdvection, int nsec, int nrad, double dt, double *Vtheta, double *VthetaRes, double *Rmed, int FastTransport)
{
int j = threadIdx.x + blockDim.x*blockIdx.x;
int i = threadIdx.y + blockDim.y*block... |
6,277 | #include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
#include <time.h>
#define DATA_SIZE 1048576
bool InitCUDA()
{
int count;
cudaGetDeviceCount(&count);
if(count == 0) {
fprintf(stderr, "There is no device.\n");
return false;
}
int i;
for(i = 0; i < count; i++) {... |
6,278 | #include "includes.h"
__global__ void dwt_per_Y_O(float *d_ip, int rows, int cols, int cA_rows, int filt_len, int Halo_steps, float *d_cL, float *d_cH)
{
extern __shared__ float s_Data[];
//Offset to the upper halo edge
const int baseX = blockIdx.x * Y_BLOCKDIM_X + threadIdx.x;
const int baseY = ((blockIdx.y * 2 * Y_R... |
6,279 | #include <stdio.h>
#include <sys/time.h>
double cpuSecond() {
struct timeval tp;
gettimeofday(&tp,NULL);
return (double) tp.tv_sec + (double)tp.tv_usec*1e-6;
}
__device__ void sleep(float t, clock_t clock_rate) {
clock_t t0 = clock64();
clock_t t1 = t0;
while ((t1 - t0)/(clock_rate*1000.0f... |
6,280 | #include <cuda.h>
#include <iostream>
using namespace std;
__global__ void InitialClusteringKernel_CUDA (float* im_vals, unsigned short* max_response_r, unsigned short* max_response_c, unsigned short* max_response_z , int r, int c, int z, int scale_xy, int scale_z, int offset)
{
int iGID = blockIdx.x * blockDim.x + ... |
6,281 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cuda.h>
#include <curand_kernel.h>
#include <math_constants.h>
extern "C"
{
// Based on example code for random exponential
__device__ float rexpo(curandState *state, float lambda){
float value;
value = -log(curand_uniform(state))/lambda;
ret... |
6,282 | #include <memory>
#include <string>
#include <stdexcept>
#include <vector>
#include <chrono>
#include <iostream>
#include <algorithm>
#include <cuda.h>
#include <cuda_runtime_api.h>
constexpr size_t n_thread = 128;
constexpr size_t n_rep = 10;
constexpr size_t n_element_lo = 512;
constexpr size_t n_element... |
6,283 | #include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <limits.h>
#define TRUE 0
#define FALSE 1
typedef struct {
int src;
int dst;
int cost;
} Edge;
__global__ void bellman_ford_kernel(int *dis_arr, Edge *edges, int *change) {
int my_id;
my_id = blockIdx.x*blockDim.x + threadIdx.x;
Edge my_edg... |
6,284 | /*MIT License
Copyright (c) 2019 Xavier Martinez
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish,... |
6,285 | ////#include<helper_cuda.h>
////#include<cuda_runtime.h>
////#include<device_launch_parameters.h>
////#include<iostream>
////#include<cmath>
////#include<ctime>
////
////
////__global__ void add_cuk(float* x, float* y, float* z, int Num)
////{
//// int index = blockIdx.x * blockDim.x + threadIdx.x;
////
//// if (index ... |
6,286 | #include <stdio.h>
#include <iostream>
#include <cuda_runtime.h>
#include <string>
#define THREADBLOCK_SIZE 128
#define WORKING_SET_SIZE_ELEM_BITS 21
#define WORKING_SET_SIZE_ELEMS (1 << WORKING_SET_SIZE_ELEM_BITS)
#define ITERATION_COUNT 5
// FNV-1a released into public domain
#define INITIAL_HASH 146959810393466560... |
6,287 | #ifdef __cplusplus
extern "C" {
#endif
__global__ void kernel_compute(int* trainingSet, int* data, int* res, int setSize, int dataSize){
int diff, toAdd, computeId;
computeId = blockIdx.x * blockDim.x + threadIdx.x;
//__shared__ int set[784];
if(computeId < setSize){
diff = 0;
for(int i = 0; i < dataSi... |
6,288 | #include <iostream>
#include <iomanip>
#include <cstdio>
using namespace std;
const int d = 8;
const int w = 4;
template <class T>
__global__ void runMaxtrix(T *d_m, T *d_mout, int d){
__shared__ T b_mr[w][w];
__shared__ T b_mc[w][w];
int bdx = blockIdx.x;
int bdy = blockIdx.y;
int tdx = threadIdx.x;
int tdy =... |
6,289 | /*
Copyright 2017 the arraydiff authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, so... |
6,290 | //pass: checka um retorno do tipo "ponteiro pra função"
//--blockDim=1024 --gridDim=1 --no-inline
#include <stdio.h>
#include <cuda.h>
#include <assert.h>
#define N 2//1024
typedef float(*funcType)(float*, unsigned int);
__device__ float multiplyByTwo(float *v, unsigned int tid)
{
return v[tid] * 2.0f;
}
__devi... |
6,291 | #import <cuda_runtime.h>
#include <cuda_runtime_api.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
void error(char const *str)
{
fprintf(stderr, "%s\n", str);
exit(1);
}
void cuda_check(cudaError_t err, char const *str)
{
if (err != cudaSuccess) {
fprintf(stderr, "%s: CUDA error %d... |
6,292 | #include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <iostream>
#define NUM_ELEMENTS 8192
// Non interleaved structure definition
typedef unsigned int ARRAY_MEMBER_T[NUM_ELEMENTS];
typedef struct {
ARRAY_MEMBER_T a;
ARRAY_MEMBER_T b;
ARRAY_MEMBER_T c;
ARRAY_MEMBER_T d;
} NON_INTERLEAVED_T;
// Mu... |
6,293 | #include <stdio.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <curand_kernel.h>
__global__ void multiply(float* Md, float* Nd, float* Pd, int Width){
//int Row = blockIdx.y * blockDim.y + threadIdx.y;
//int Col = blockIdx.x * blockDim.x + threadIdx.x;
float Pvalue = 0;
for (... |
6,294 | #include <cuda.h>
#include <cuda_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#define ThreadSize 16
__global__ void MatMulKernel( int *dD, int *dE, int *dF, int N ) {
int Fvalue = 0;
int row = blockIdx.y * blockDim.y + threadIdx.y;
int col = blockIdx.x * blockDim.x + threadIdx.x;
if ( row < (N/2) && col < (N/... |
6,295 | __global__
void vecAdd(float *l, float *r, float *result, size_t N) {
size_t i = threadIdx.x;
if (l[i] > i) {
goto LABEL1;
} else {
goto LABEL2;
}
LABEL1:
result[i] = exp(l[i]);
goto END;
LABEL2:
result[i] = l[i] + r[i];
goto END;
END:
return;
}
|
6,296 | #include <iostream>
/// This is what the add.ptx is compiled from
/// "nvcc add.cu --ptx"
extern "C" __global__ void sum(const float* x, const float* y, float* out, int count) {
for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < count; i += blockDim.x * gridDim.x) {
out[i] = x[i] + y[i];
}
}
/// ... |
6,297 | #include "includes.h"
__global__ void cunn_SpatialLogSoftMax_updateGradInput_kernel(float *gradInput, float *output, float *gradOutput, int classSize, int height, int width)
{
int batchIndex = blockIdx.x;
int index = threadIdx.x;
while (index < height*width) {
int y = index / width;
int x = index % width;
if (y >= hei... |
6,298 | // 20181010
// Yuqiong Li
// a basic CUDA function to familiarize with usage
#include<stdio.h>
#include<cuda.h>
// function declarations
__global__ void vecAddKernel(float * a, float * b, float * c, unsigned int N);
// main function
int main()
{
int N = 10; // length of vector
float * a, * b, * c; /... |
6,299 | #include "includes.h"
using namespace std;
#define N 32
__global__ void multSquareMatrix(int *A, int *B, int *result, int n)
{
int k, sum = 0;
int col = blockIdx.x * blockDim.x + threadIdx.x;
int row = blockIdx.y * blockDim.y + threadIdx.y;
for (k = 0; k < n; k++) {
sum += A[row * n + k] * B[k * n + col];
re... |
6,300 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <cuda.h>
#include <curand_kernel.h>
#define N 100 // total number of items in vectors
#define nthreads 4 // total number of threads in a block
__global__ void estimatepi(int n, int *sum)
{
__shared__ int counter[nthreads];
int threadI... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.