serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
16,501 | #include <iostream>
typedef float4 Real3;
void puts(Real3 v){
std::cout << "(" << v.x << " " << v.y << " " << v.z << ")" << std::endl;
}
Real3 operator+(Real3 v1, Real3 v2){
Real3 p;
p.x = v1.x + v2.x;
p.y = v1.y + v2.y;
p.z = v1.z = v2.z;
return p;
}
Real3 genReal3(float x, float y, float z){
Real3 p;... |
16,502 | #include <iostream>
struct SharedMemory
{
__device__ inline operator float *()
{
extern __shared__ int __smem[];
return (float *)__smem;
}
__device__ inline operator const float *() const
{
extern __shared__ int __smem[];
return (float *)__smem;
}
};
__gl... |
16,503 | #include <fstream>
#include <iterator>
#include <vector>
#include <iostream>
#include <cstdlib>
#include <string>
#include <sstream>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#define energySize 64000000
#define blockSize 256
//define macro for error checking
#define cudaCheckError(){ \
... |
16,504 | /*
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <conio.h>
#include <stdio.h>
__constant__ int d_m[6];
__global__ void convolution(int *N,int *P,int maskwidth,int width)
{
int i =blockIdx.x*blockDim.x+ threadIdx.x;
int pvalue=0;
int startpt=i-(maskwidth/2);
for(int j=0;j<maskwidth;j... |
16,505 | #include "includes.h"
__global__ void __dds(int nrows, int nnz, double *A, double *B, int *Cir, int *Cic, double *P) {
__shared__ double parts[32*DDS_BLKY];
int jstart = ((long long)blockIdx.x) * nnz / gridDim.x;
int jend = ((long long)(blockIdx.x + 1)) * nnz / gridDim.x;
int tid = threadIdx.x + blockDim.x * threadIdx.... |
16,506 | #include<stdio.h>
__global__ void cube(int * a, int * b)
{
int id=blockIdx.x*blockDim.x+threadIdx.x;
b[id]=a[id]*a[id]*a[id];
}
#define N 25
#define B 5
int main(void)
{
int a[N],b[N];
int *d_a,*d_b;
for(int i=0;i<N;i++)
{
a[i]=int(i);
}
cudaMalloc((void **)&d_a,N*sizeof(int));
cudaMalloc((void **)&d_b,N*sizeof(int... |
16,507 | #include "includes.h"
#define N 1024 //wielkoæ obliczanych wektorów
#define imin(a, b) (a<b?a:b)
const int threadsPerBlock = 256; //iloæ w¹tków na k¹zdy blok
const int blocksPerGrid = imin(32, (N + threadsPerBlock - 1) / threadsPerBlock);//iloæ wykorzystywanych bloków
__global__ void multiplyMatrix(float *a, f... |
16,508 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <cuda_runtime.h>
#define TILE_WIDTH 2
#define INPUT_CONSTANT 1.5
#define BLOCK_SIZE 2
__host__
float *allocateMatrix(int rows, int columns){
return (float *) malloc(sizeof(float) * rows * columns);
}
__host__
void initializeMatrix(int rows, int col... |
16,509 | /*
* name: task-6.cu
*/
#include<stdio.h>
__global__ void myHelloOnGPU(int *array){
// Position-1
int index_x = blockIdx.x * blockDim.x + threadIdx.x;
int index_y = blockIdx.y * blockDim.y + threadIdx.y;
array[index_y * blockDim.x * blockDim.y + index_x] =
11 * (( blockDim.x * gridDim.x )-(( bloc... |
16,510 | // Copyright 2009-2023 NTESS. Under the terms
// of Contract DE-NA0003525 with NTESS, the U.S.
// Government retains certain rights in this software.
//
// Copyright (c) 2009-2023, NTESS
// All rights reserved.
//
// Portions are copyright of other developers:
// See the file CONTRIBUTORS.TXT in the top level directory... |
16,511 | #include <stdio.h>
#include <assert.h>
__global__ void func(int *data)
{
int i = threadIdx.x;
data[i] = data[i] + data[i+32];
if (i < 16) {
data[i] = data[i] + data[i+16];
}
__syncthreads();
if (i < 8) {
data[i] = data[i] + data[i+8];
}
__syncthreads();
if (i < 4) {
data[i] = data[i] + data[i+8];
}
_... |
16,512 | #include "includes.h"
__global__ void add_kernel( float4 * __restrict output_buf, const float4 * __restrict input_buf1, const float4 * __restrict input_buf2, float alpha1, float alpha2, int elem_count)
{
int elem_id = blockDim.x * blockIdx.x + threadIdx.x;
if (elem_id < elem_count)
{
float4 val1 = input_buf1[elem_id];
... |
16,513 | #include <stdio.h>
void __global__ kernel_vectorAdd(const float* __restrict__ a,
const float* __restrict__ b,
float* c,
int length)
{
uint gid = threadIdx.x + __umul24(blockDim.x, blockIdx.x);
if(gid < length)
{
c[gid] = a[gid] + b[gid];
}
... |
16,514 | ///////////////////////////////////////////////////////////////////////////////
// Simple program to add vectors on CPU and GPU
//
// Intended to show common CUDA error checking and usage
///////////////////////////////////////////////////////////////////////////////
#include <cassert>
#include <numeric>
#include <ios... |
16,515 | #include "fastgemm.cuh"
using namespace std;
int main(int argc, char const *argv[]) {
#ifdef DEBUG
struct cudaDeviceProp prop;
int device = 0;
cudaGetDeviceProperties(&prop, device);
cout << "Device name: " << prop.name << endl;
cout << "Total Global Memory (bytes): " << prop.totalGlobalMem << endl;
cout... |
16,516 |
#include "sql_drop.cuh"
using namespace std;
#define invalidQuery(query) {utils::invalidQuery(query); return;}
void sql_drop::execute(std::string &query) {
utils::toLower(query);
tokenizer t(query);
string word;
t >> word;
if(word != "drop")
invalidQuery(query);
t >> word;
if(!utils::tableExists(wo... |
16,517 | /*#include<cuda.h>
#include<cuda_runtime.h>
#include<stdio.h>
#include<device_atomic_functions.h>
#include<device_launch_parameters.h>
#include<memory.h>
#define totalThreads 1000
#define totalBlocks 100000
#define arraySize 10
#define arrLen(arr)((sizeof(arr)>0)?sizeof(arr)/sizeof(arr[0]):-1)
__global__ void atomicAd... |
16,518 | extern "C"
__global__ void multiply(int colsA, int sizeB, double** A, double* B, double* C, double* Displacement)
{
int tid = threadIdx.x + blockIdx.x * blockDim.x;
if(tid < sizeB){
double sum = 0.0;
C[tid] = 0;
for(int i = 0; i < sizeB; i++) {
sum = sum + A[tid][i]*B[i];
... |
16,519 | #include<stdlib.h>
#include<stdio.h>
#include<time.h>
#define n 1024
__global__ void mul_mat(int *a, int *b, int *c) {
int myx, myy, i;
myx = blockIdx.x * blockDim.x + threadIdx.x;
myy = blockIdx.y * blockDim.y + threadIdx.y;
int local;
for (i = 0; i < n; i++)
local += a[myx+n*i] * b[n*i+myy];
c[myx*n+myy]... |
16,520 | /*
* Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*
* 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
* ... |
16,521 | #include "includes.h"
__global__ void reduce3(float *in, float *out, int size)
{
extern __shared__ float sdata[];
int tid = threadIdx.x;
int index = blockIdx.x * blockDim.x + threadIdx.x;
sdata[tid] = (index < size) ? in[index] : 0;
__syncthreads();
for(int s = blockDim.x/2; s>0; s>>=1)
{
if(tid<s)
sdata[tid] += sdata... |
16,522 | #include "includes.h"
__global__ void matrixSum(const double * M1,const double * M2,double * Msum,double alpha,double beta, int rows, int cols)
{
int row = blockIdx.x * blockDim.x + threadIdx.x;
int col = blockIdx.y * blockDim.y + threadIdx.y;
if (row < rows && col < cols){
Msum[row + col*rows] = alpha*M1[row+col*rows]... |
16,523 | #include <asm/unistd.h>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <linux/kernel-page-flags.h>
#include <map>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/mount.h>
#include <sys/mman.h>... |
16,524 | #include <string.h>
#include <stdio.h>
#include <stdlib.h>
__global__ void vectAdd(char *a, char *b, char *c, char *res, int len)
{
int i;
i = blockIdx.x * blockDim.x + threadIdx.x;
res[i] = a[i] + b[i] + c[i];
}
/* Function computing the final string to print */
void compute_string(char *res, char *a, char *... |
16,525 | #include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <cuda_runtime.h>
typedef struct
{
int len;
// host
float *h_input, *h_output;
// device
float *d_input, *d_output;
// cuda stream
cudaStream_t stream;
} MGPUdata;
__global__ void testKernel(float*x, float*y, int len)
{
int tid = threadIdx... |
16,526 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
/*
to compile :
nvcc -o 2039276_Task3_A 2039276_Task3_A.cu
to run:
./2039276_Task3_A
Sonam Wangdi Sherpa, UID: 2039276
*/
__device__ char* CudaCrypt(char* rawPassword){
char * newPassword = (char *) malloc(sizeof(char) * 11);
newPassword[0] = rawPa... |
16,527 | #include "includes.h"
__global__ void kernElementWiseMax(const size_t numPoints, double* dest, double* src) {
// Called to standardize arrays to be a power of two
// Assumes a 2D grid of 1D blocks
int b = blockIdx.y * gridDim.x + blockIdx.x;
int i = b * blockDim.x + threadIdx.x;
if(i < numPoints) {
if(dest[i] < src[i... |
16,528 | #include "includes.h"
__global__ void populate_reverse_pad(const double *Q, double *Q_reverse_pad, const double *mean, const int window_size, const int size)
{
int tid = blockIdx.x * blockDim.x + threadIdx.x;
double mu = *mean;
if(tid < window_size) {
Q_reverse_pad[tid] = Q[window_size - 1 - tid] - mu;
}else if(tid < s... |
16,529 | #include <stdio.h>
__global__ void init_ptr_chase(size_t *p, int buf_size, int stride) {
int stride_num = buf_size / stride;
if (stride_num <= 1) {
return;
}
for (int i = 0; i < stride_num - 1; ++i) {
p[i * stride / sizeof(size_t)] = (size_t)(p + (i + 1) * stride / sizeof(size_t));
//printf("%p, %p... |
16,530 | ////////////////////////////////////////////////////////////////////////////
//
// Copyright 1993-2015 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 u... |
16,531 | //x: Pointer to matrix
//N: Size of each row
//NPow2: Size of each row rounded up to nearest power of 2
__global__ void bitonicSort(float* X, int N, int NPow2)
{
extern __shared__ float x[];
int N2 = NPow2 >> 1;
int offset = blockIdx.x*N;
int jump = N2;
int k, i, i1, i2;
float min, max;
int ... |
16,532 | #include "includes.h"
#define N 10000000
__global__ void compute_histogram(unsigned char *data, unsigned int *histogram)
{
__shared__ unsigned int cache[256];
int i = blockIdx.x * blockDim.x + threadIdx.x;
cache[threadIdx.x] = 0;
__syncthreads();
while(i < N)
{
atomicAdd(&cache[data[i]], 1);
i += blockDim.x * gridD... |
16,533 | #include <cuda.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#define DTYPE float
__global__ void kernel(float *a, float *x, float* buff,int Xblocks,int size)
{
int i=threadIdx.x+blockIdx.x*blockDim.x;
int j=threadIdx.y+blockIdx.y*blockDim.y;
__shared__ float... |
16,534 | #include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
bool CUDA_INIT(void)
{
// cudaGetDeviceCount(&device_count)
int device_count;
if (cudaGetDeviceCount(&device_count))
{
printf(" There is zero device beyond 1.0\n");
return false;
}
else
printf("There is %d device beyond 1.0\n", device_count)... |
16,535 | /*
============================================================================
Name : lab.cu
Author :
Version :
Copyright : Your copyright notice
Description : CUDA compute reciprocals
============================================================================
*/
#include <iostream>
#inclu... |
16,536 | #include <float.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NOT_USED 0 // node which is currently not used
#define LEAF_NODE 1 // node which contains a leaf node
#define A_MERGER 2 // node which contains a merged pair of previous root clusters
#define MAX_LABEL_LEN 16
#... |
16,537 | //pass
//--gridDim=[2,2,1] --blockDim=[2,2,2]
#include "printf.h"
#define CUPRINTF cuPrintf
__global__ void testKernel(int val)
{
CUPRINTF("\tValue is:%d\n", val);
}
|
16,538 | #define W 500
#define H 500
#define TX 32
#define TY 32
__device__
unsigned char clip(int n){
return n>255?255:(n<0?0:n);
}
__global__
void distanceKernel(uchar4 *d_out,int w,int h,int2 pos){
const int c=blockIdx.x*blockDim.x+threadIdx.x;
const int r=blockIdx.y*blockDim.y+threadIdx.y;
const int i =r*w+c;
if ((c>... |
16,539 | extern "C" __global__ void
update_particles(float* x, float* y, float* z,
const float* k1x, const float* k1y, const float* k1z,
const float* k2x, const float* k2y, const float* k2z,
const float* k3x, const float* k3y, const float* k3z,
const float* k4x... |
16,540 | //This is a tutorial program for COMP5112 - assignment 4
#include <string>
#include <cassert>
#include <iostream>
#include <fstream>
#include <vector>
#include <climits>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <sys/time.h>
#include <time.h>
#include <getopt.h>
#include <cuda_runtime.h>
#incl... |
16,541 | #include <stdlib.h>
#include <stdio.h>
#include <math.h>
//Thread block size
#define BLOCK_SIZE 3
#define WA 3
// Matrix A width
#define HA 3
// Matrix A height
#define WB 3// Matrix B
#define HB WA
// Matrix B
#define WC WB
// Matrix C
#define HC HA
// Matrix C height
//Allocates a matrix with random float entries.
vo... |
16,542 | //#include "cuPrintf.cu"
#include <stdio.h>
extern "C" void kernel_wrapper(int *a, int *b);
__global__ void kernel(int *a, int *b){
int tx = threadIdx.x;
// cuPrintf("tx = %d\n", tx);
switch( tx ){
case 0:
*a = *a + 10;
break;
case 1:
*b = *b + 3;
break;
default:
... |
16,543 | /*
* A classical DFT program that calculates the density profile of hard spheres in a hard box in three dimensions
* on graphics cards using C/C++ and the CUDA programming language.
* The program employs the original Rosenfeld functional without any correction (such as q3 or tensorial extensions).
* It serves a... |
16,544 | #include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <fstream>
#include "SearchKernel.cuh"
using namespace std;
#ifndef MAX
#define MAX(a,b) (a > b ? a : b)
#endif
#define CUDA_CHECK_RETURN(value) { \
cudaError_t _m_cudaStat = value; \
if (_m_cudaStat != cudaSucc... |
16,545 | /**********************************************************************
* DESCRIPTION:
* Serial Concurrent Wave Equation - C Version
* This program implements the concurrent wave equation
*********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <math... |
16,546 | #include "includes.h"
__global__ void upsample_kernel(size_t N, float *x, int w, int h, int c, int batch, int stride, int forward, float scale, float *out)
{
size_t i = (blockIdx.x + blockIdx.y*gridDim.x) * blockDim.x + threadIdx.x;
if (i >= N) return;
int out_index = i;
int out_w = i % (w*stride);
i = i / (w*stride);
... |
16,547 |
#include <stdio.h>
#include <iostream>
#include <unistd.h>
#include <sys/time.h>
#include <sys/time.h>
// Shorthand for formatting usage options
#define fpe(msg) fprintf(stderr, "\t%s\n", msg);
#define HANDLE_ERROR(err) ( HandleError( err, __FILE__, __LINE__ ) )
#define MAX_THREADS (65536 * 1024)
/**
* DEFINED V... |
16,548 | #include <stdio.h>
#include <time.h>
#include <malloc.h>
const int N = 1 << 20;
__global__ void gInitVectors(double* vector1, double* vector2) {
for (int i = 0; i < N; i++) {
vector1[i] = (double)i; //rand();
vector2[i] = (double)i;
}
}
__global__ void gVectorAddition(double* vector1, double* vector2, double* v... |
16,549 | #include <iostream>
// Kernel function to add the elements of two arrays
__global__ void add(int n, int *x, int *y, int a)
{
int tid = blockIdx.x*blockDim.x + threadIdx.x;
if(tid<n) x[tid] = a*x[tid] + y[tid];
}
int main(void)
{
int dNum = 1<<24;
int *x, *y, *d_x, *d_y;
// memory size for each arr... |
16,550 | #ifndef __GPUFI_KERNEL__
#define __GPUFI_KERNEL__
#include <stdio.h>
__device__
int GPUFI_EXIT(int errno)
{
int *addr = 0x0;
*addr = 0x80;
return 100 / errno;
}
#endif |
16,551 | #include "../../include/image_processing/morphology.cuh"
|
16,552 | __global__ void
convolution1D(float *A,float *B,const int size)
{
int i = blockDim.x*blockIdx.x + threadIdx.x;
if (i < size)
{
float pos1=0,pos2=0,pos3=0,pos4=0;
if(i>1)pos1 = A[i-2];
if(i>0)pos2 = A[i-1];
if(i<size-1)pos3 = A[i+1];
if(i<size-2) pos4 = A[i+2... |
16,553 | #ifdef _WIN32
# define NOMINMAX
#endif
// includes, system
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
double* read_array(const char* filename, int len) {
double *x = (double*) malloc(len * sizeof(double));
FILE *fp = fopen(filename, "r");
for (int i = 0; i < len; i++) {
fsca... |
16,554 | #include <stdio.h>
#define N 2048
#define nthreads 512
__global__ void matrix_mul (int* A, int*B,int*C,int size){
int i=threadIdx.x+(blockIdx.x*blockDim.x);
int rowidx= (i/size)*size;
int colidx= i%size;
int acc=0;
int k;
for(k=0; k<size;k++){
acc+=A[rowidx+k]*B[colidx+k*size];
}
C[i]=acc;
}
... |
16,555 | #include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <cuda.h>
#define ACC_J 19.013
#define ACC_K 25.253
#define ACC_L 6503.0
__constant__ int d_excitations_number,d_ionizations_number, d_datapoints, d_block_mult;
__constant__ double d_T_r;
void gauss_integration_setup32(double *weights... |
16,556 | __device__ __host__ inline double cal_mean(const double *observations, int n_observations){
double mean = 0;
for(int o = 0; o < n_observations; o++){
mean += observations[o];
}
mean /= double(n_observations);
return mean;
}
__device__ __host__ inline double cal_variance(const double *observations, int n_... |
16,557 | /*****************************************************************************/
/* */
/* Copyright (c) 2020 Seoul National University. */
/* All rights reserved. */
... |
16,558 | #include <cuda_runtime.h>
#include <assert.h>
#include <stdio.h>
#include <time.h>
#include <sys/time.h>
#include <stdlib.h>
#include <device_launch_parameters.h>
#define CUDA_CALL(x) { const cudaError_t a = (x); if(a != cudaSuccess) { printf("\nCuda Error: %s (err_num=%d) at line:%d\n", cudaGetErrorString(a), a, __L... |
16,559 | #include <stdio.h>
#include <stdlib.h>
#include <curand.h>
#include <curand_kernel.h>
#include <iostream>
using namespace std;
__global__ void smallSimplex(double* job, int width, int height)
{
extern __shared__ double shared[];
double* pivotColumn = &shared[0];
double* pivotRow = &shared[height];
double* rat... |
16,560 | #include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <thrust/transform_reduce.h>
#include <thrust/functional.h>
#include <cmath>
using namespace std;
template <typename T>
struct square {
__host__ __device__ T operator()(const T &x) const
{
return x * x;
}
};
int main()
{
float hostarr[4] ... |
16,561 | #include "includes.h"
__global__ void skip_res_add(size_t sz, float_t* f5, float* f1, float_t* skip_out_sum, size_t stride)
{
size_t index = blockDim.x * blockIdx.x + threadIdx.x;
if(index < sz)
{
skip_out_sum[index] += f5[index+stride];
f1[index] += f5[index];
}
} |
16,562 | #include<stdio.h>
#include<stdlib.h>
#include<cuda.h>
#define BlockSize (8)
#define n (8)
void printMatrix(int *a){
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
printf("%d ",a[i*n+j]);
}
printf("\n");
}
printf("\n");
}
__global__ void matrixMulKernel(int *da, int *db, int *dc){
int row=blockI... |
16,563 | #include <thrust/device_vector.h>
#include <thrust/sequence.h>
#include <thrust/copy.h>
#include <thrust/count.h>
#include <thrust/remove.h>
#include <iostream>
#include <stdio.h>
// helper routine
template <typename String, typename Vector>
void print(const String& s, const Vector& v)
{
std::cout << s << " [";
fo... |
16,564 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include <cuda.h>
void Algorithm1(int m, int n, int l);
#define BLOCK_SIZE 256
__global__ void device_Matrix_multi(const double* const device_matrix_A,const double* const device_matrix_B,
double* device_matrix_C,
... |
16,565 | #include <cmath>
#include <cstdlib>
#include <cstdio>
#include <ctime>
#include <cuda_runtime.h>
#include <thrust/reduce.h>
#include <thrust/device_ptr.h>
#define Max(a, b) ((a)>(b)?(a):(b))
#define CUDA_SAFE_CALL(call)\
do {\
cudaError_t err = call;\
if (cudaSuccess != err) {\
printf("Cuda error in... |
16,566 | #include "includes.h"
__global__ void convolutionColumnGPU(double *h_Dst, double *h_Src, double *h_Filter, int imageW, int imageH, int filterR){
int k;
double sum = 0;
int ix = blockIdx.x * blockDim.x + threadIdx.x;
int iy = blockIdx.y * blockDim.y + threadIdx.y;
for (k = -filterR; k <= filterR; k++) {
int d = iy + k;
... |
16,567 | /*
**Author: Mark Williams
** Simple matrix multiplication using device code (NVIDIA GPU).
** Matrix size is 16*16, values are all 32 and the output is 256.
*/
#include <stdio.h>
#include <stdlib.h>
__global__ void MatrixMulKernel(float *Md, float *Nd, float *Pd, int Width){
//2D Thread ID
int tx = threadIdx.x;
... |
16,568 | /*!
\brief sequence.cu
\author Andrew Kerr
\brief simple test of a CUDA implementation's ability to allocate memory on the device, launch
a kernel, and fetch its results. One kernel requires no syncthreads, another kernel requires
one synchronization
*/
#include <stdio.h>
extern "C" __global__ void sequence(i... |
16,569 | #include "includes.h"
__global__ void CreateAndRefreshConnectionKernel( int s1, int s2, int *connection, int *age, int maxCells )
{
int threadId = blockDim.x*blockIdx.y*gridDim.x //rows preceeding current row in grid
+ blockDim.x*blockIdx.x //blocks preceeding current block
+ threadIdx.x;
if(threadId < 1)
{
conne... |
16,570 | /********************************************************
* life_seq_cuda.cu
* Modifed BY Thomas Kinch
* Date: 5/14/18
*******************************************************/
/* Compile with `gcc life.c`.
* When CUDA-fied, compile with `nvcc life.cu`
*/
#include <cuda.h>
#include <stdlib.h> // for rand
#include <s... |
16,571 | //: nvcc mm.cu -o mm
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
__global__ void mm_kernel(float *d_m, float *d_n, float *d_p, int size)
{
const int row = blockIdx.y;
const int col = blockIdx.x;
float val = 0.0;
for (int i = 0; i < size; ++i)
{
val += d_m[row * size + i] * d_n... |
16,572 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cuda_runtime.h>
__device__ double* myrealloc(int oldsize, int newsize, double* old)
{
double * newT = (double *) malloc (newsize * sizeof(double));
for(int i = 0; i < oldsize; i++)
newT[i] = old[i];
free(old);
return newT;
}
... |
16,573 | #include "includes.h"
__global__ void matrixKernel(float* d_in, float* d_out) {
// Block index
int bx = blockIdx.x;
int by = blockIdx.y;
// Thread index (current coefficient)
int tx = threadIdx.x;
int ty = threadIdx.y;
float dividend =
d_in[(by * BLOCK_SIZE + 0) * STRIDE + (bx * BLOCK_SIZE + 0)];
float divisor =
d_in... |
16,574 | #include "kernels.cuh"
extern "C" __global__
void ratesKernelVersion1(float* const input, float* output, dim3 domain)
{
int tid = blockIdx.x * blockDim.x + threadIdx.x;
if (tid < domain.x) output[tid] = input[tid];
}
extern "C" __global__
void ratesKernelVersion2(float* const input, float* output, dim3 domain)
{
... |
16,575 | #include <stdio.h>
#include <chrono>
#include <algorithm>
#include <cuda.h>
#include <iostream>
__global__ void spmvCSRKernel(float *out, int *matCols, int *matRows,
float *matData, float *vec, int dim) {
//@@ insert spmv kernel for csr format
}
__global__ void spmvJDSKernel(float *out... |
16,576 | /*
This is an upper-triangularization operation on a 'nearly upper triangular' matrix.
In order to place rME and rMI in registers for optimal performance, the number of
non-zero values below the subdiagonal must be known at compile time. The only
known way to do this is templating the function. See line 31... |
16,577 | #include "includes.h"
__global__ void yuan(const char *text, int *pos, int text_size) {
int textP = blockIdx.x * blockDim.x + threadIdx.x;
if (textP >= text_size) return;
const char *start = text + textP;
while (start >= text && *start > ' ') {
start--;
}
pos[textP] = text + textP - start;
} |
16,578 | #include "includes.h"
using namespace std;
long long remaining_N2(int , int ,long long );
long long remaining_N(int , int ,int );
__global__ void ker(float * cormat, float * upper,int n1,int n)
{
long idx = blockDim.x*blockIdx.x+threadIdx.x;
long i = idx%n1;
long j = idx/n1;
if(i<j && i<n1 && j<n)
{
long tmp=i;
tmp*=(... |
16,579 | #include <thrust/sort.h>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <random>
#include <chrono>
using namespace std;
template<typename T>
std::vector<std::size_t> tag_sort(const std::vector<T>& v)
{
std::... |
16,580 | #include <thrust/device_vector.h>
#include <thrust/transform_reduce.h>
#include <thrust/sequence.h>
#include <thrust/random.h>
#include <thrust/gather.h>
#include <thrust/extrema.h>
#include <thrust/sort.h>
#include <stdio.h>
#include "tools.cuh"
using namespace thrust::placeholders;
#define MASK 99
#define INF 9999;... |
16,581 | #include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/generate.h>
#include <thrust/sort.h>
#include <thrust/copy.h>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cassert>
int main(int argc, char **argv) {
assert(argc == 2);
size_t count = std::atoi(argv[1]);
... |
16,582 | #include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
#include <cuda.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
// #include <device_functions.h>
#include <cuda_runtime_api.h>
using namespace std;
typedef double ld;
typedef long long L... |
16,583 | #include "includes.h"
// Copyright (c) 2020, Michael Kunz. All rights reserved.
// https://github.com/kunzmi/ImageStackAlignator
//
// This file is part of ImageStackAlignator.
//
// ImageStackAlignator is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public Licens... |
16,584 | // #include "rysq.hpp"
// #include "cuda/host.hpp"
// #include "cuda/kernels.hpp"
// #include "cuda/kernels/side.hpp"
// #include "cuda/kernels/device.hpp"
// #include "roots/rysq_roots.h"
// using namespace rysq::cuda::kernels;
// __device__ __constant__ double2 _ssss_cBraket[36*36 + 2*36];
// extern __shared__ dou... |
16,585 | #include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <cuda.h>
#include <inttypes.h>
#include <thrust/sort.h>
#include <thrust/execution_policy.h>
#define BLOCKSIZE 32
#define NUM_BLOCK... |
16,586 | #include<stdio.h>
#define DEBUG 0
#define N DEBUG ? 3:1000
#define M DEBUG ? 3:1500
#define type float
#define THREADS 256
#define MAXS 2048
#define SAFE(A) do{ \
cudaError_t e = A; \
if (e) { ... |
16,587 | #include "includes.h"
__global__ void blockcopyFromOpenMM( float *target, float *source, int *blocks, int numblocks, int setnum, int N ) {
int blockNum = blockIdx.x * blockDim.x + threadIdx.x;
int dof = 3 * blocks[blockNum] + setnum;
int atom = dof / 3;
if( atom >= N || ( blockNum != numblocks && atom >= blocks[blockN... |
16,588 | extern "C" {
__global__ void kernel_vadd(const float *a, const float *b, float *c)
{
int i = blockIdx.x *blockDim.x + threadIdx.x;
c[i] = a[i] + b[i];
}
__global__ void kernel_float4(const float4 *a, float4 *b)
{
b[0] = a[0];
}
__global__ void kernel_uint2(const uint2 *a, uint2 *b)
{
b[0] = a[0];
}
... |
16,589 | #include <cstdlib>
#include <math.h>
#include <time.h>
#include <cstdio>
// Assertion to check for errors
#define CUDA_SAFE_CALL(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, char *file, int line, bool abort=true)
{
if (code != cudaSuccess)
{
fp... |
16,590 | #include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
#include <time.h>
#define NUM_THREADS 256
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++) {
... |
16,591 | // cuda规约求和
#include <stdio.h>
#include <cuda_runtime.h>
#include <chrono>
using namespace std::chrono;
int serial_reduce(int* in, int len) {
int sum = 0;
for (int i = 0; i < len; ++i) {
sum += in[i];
}
return sum;
}
__global__ void reduce_kernerl_v1(int* in, int* out, int len) {
int i... |
16,592 | #include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cstdlib>
#include <curand.h>
#include <curand_kernel.h>
#include <math.h>
unsigned int N_SIMS, N_RANDS, N_BLK, N_THRD, N_BYTES;
const unsigned int MAX_THREADS = 512; // max threads per block
// Calculate and return mean of an array of floats
float... |
16,593 | #include "includes.h"
const int Nthreads = 1024, maxFR = 100000, NrankMax = 3, nmaxiter = 500, NchanMax = 32;
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////... |
16,594 | #include <cuda_runtime.h>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <iostream>
#include "bfs.cuh"
#define BLOCK_SIZE 256
__global__ void cudaBfsKernel(int *, int *, int *, int *, int *, int);
int emptyFrontier(int *F, int vertexCount)
{
for (int i = 0; i < vertexCount; ++i)
if (F[i] == 1)
... |
16,595 | // TILE_SIZE and N are variable/parameter here
#define TILE_SIZE 4
__device__ void store_full_row(float* read_data,float* write_data,int i,int N)
{
int global_y;
int global_x = i*blockDim.x + threadIdx.x;
global_y = 0*blockDim.y + threadIdx.y;
write_data[global_y*N + global_x] = read_data[thre... |
16,596 | //seqRuntime.cu
#include <iostream>
using namespace std;
#include <thrust/reduce.h>
#include <thrust/sequence.h>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
__global__ void fillKernel(int *a, int n)
{
int tid = blockIdx.x*blockDim.x + threadIdx.x;
if (tid < n) a[tid] = tid;
}
void fill(int*... |
16,597 | #include <chrono>
#include <iostream>
//Kernel definition
template<typename T>
__global__
void copyKernel (T* out,
T* in,
const unsigned int N)
{
const unsigned int id = threadIdx.x + blockIdx.x * blockDim.x;
for (unsigned int i= id; i < N; i = i + blockDim.x * gridDim.x)
{
const unsigned el_id = i;
((T*)... |
16,598 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <cuda.h>
#include <cuda_runtime.h>
#define BLK_SIZE 100
#define MAX_NUM_THREADS_PER_BLK 1024
const int N = 1e2;
__global__ void reduce0(int *g_idata, int *g_odata) {
__shared__ int sdata[MAX_NUM_THREADS_PER_BLK];
// each thread loads one element fr... |
16,599 | #include "includes.h"
__global__ void sumArraysOnGPU(float *A, float *B, float *C) {
int id = threadIdx.x;
C[id] = A[id] + B[id];
} |
16,600 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#define NUM_BLOCKS 16
#define BLOCK_WIDTH 1
__global__ void hello()
{
printf("Hello world! I'm a thread in block %d\n",blockIdx.x);
}
__global__ void use_local_memory_GPU(float in)
{
float f;
f = in;
}
__global__ void use_globa... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.