serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
3,601 | #include <assert.h>
#include <pthread.h>
#include <stdio.h>
#define THREADS 4
int intervalsT = 100000000;
double store, base;
double partialStore[] = {0.0, 0.0, 0.0, 0.0};
void* threadRoutine(void* param) {
int i;
int* threadId = (int*)param;
int partialInterval = intervalsT / THREADS;
double height;... |
3,602 | #include <cuda.h>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <chrono>
/*1-20*/
#define BLOCK_WIDTH 2
#define BLOCK_SIZE 4
using namespace std;
/*
//BlockTranspose
__global__
void BlockTranspose(float *A_elements, int A_width, int A_height) {
__shared__ float blockA[BLOCK_WIDTH][BLOCK_WIDTH];
i... |
3,603 | #include "includes.h"
__global__ void add(int N, double *a,double *b)
{
int tid = blockIdx.x*blockDim.x + threadIdx.x;
if(tid < N)
{
b[tid] = a[tid]*a[tid];
}
} |
3,604 | #include <stdio.h>
// indica que é uma funo que vai rodar no device
__global__ void hello()
{
printf("Oi mundo! De thread: %d De: bloco %d\n", threadIdx.x, blockIdx.x);
}
int main(void)
{
int num_threads = 5;
int num_blocks = 5;
//chama a funo e especfica blocos e threads
hello<<<num_blocks,num_threads>>>();
/... |
3,605 | #include<stdio.h>
#include<cuda_runtime.h>
#include<device_launch_parameters.h>
__global__ void add(float *a,float *b){
int id = blockIdx.x*blockDim.x+threadIdx.x;
b[id] = sinf(a[id]);
}
int main(){
int n;
float a[10],b[10];
printf("Enter n:");
scanf("%d",&n);
printf("Enter A:\n");
for(int i=0;i<n... |
3,606 | #include <iostream>
#include <assert.h>
#include <limits.h>
#include <vector>
#include <curand.h>
#include <curand_kernel.h>
#include <algorithm>
using namespace std;
// #define RNG_DEF int& rx
// #define RNG_ARGS rx
// #define MY_RAND_MAX ((1U << 31) - 1)
// Command line arguments that get set below (these give defaul... |
3,607 | #include <stdio.h>
#include <stdlib.h>
#define KNZ_LEN 20
#define DIM_COUNT 3
#define DIM_SIZE 10000
#define FACT_SIZE 250000
// Datenstruktur
typedef struct _dim {
long id;
char knz[KNZ_LEN];
} DimTable;
typedef struct _factIn {
char knz[DIM_COUNT][KNZ_LEN];
} FactTableIn;
typedef struct _factOut {
... |
3,608 | #include "includes.h"
#define INTERVALS 1000000
// Max number of threads per block
#define THREADS 512
#define BLOCKS 64
double calculatePiCPU();
// Synchronous error checking call. Enable with nvcc -DDEBUG
__global__ static void sumReduce(int *n, float *g_sum)
{
int tx = threadIdx.x;
__shared__ float s_sum[THREAD... |
3,609 | /************************************************************************************\
* *
* Copyright � 2014 Advanced Micro Devices, Inc. *
* Copyright (c) 2015 Mark D. Hill and David A. Wood ... |
3,610 | #include <assert.h>
#include <cuda.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
static char* program_name;
// Just defination
__global__ void Jacobi(int** a, const int** b, const int N) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
int j = blockIdx.y * blockDim.y + threadIdx.... |
3,611 | #include <cuda.h>
#define THRESHOLD 10010000
__device__ void bubbleSort(int *pixelsToSort, int length){
for(int i = 0; i < length; i++ )
{
for(int j = 0; j < length-1; j++)
{
if( pixelsToSort[j] > pixelsToSort[j+1]){
int tmp = pixelsToSort[j];
pixels... |
3,612 | #include "includes.h"
__global__ void MarkCentroidsKernel( float *centroidCoordinates, float *visField, int imgWidth, int imgHeight, int centroids )
{
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(threa... |
3,613 | //This is a generated CUDA code
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
//f_alu = 1
//f_mad =8
//f_sfu =6
//d_alu =8
//d_mad =6
//b_alu =5
__constant__ float kconst[115] = {
2640.27049419,496.788317279,755.85277182,4070.19741521,6510.34703498,2039.14289025,3704.61925152,7755.66914948,
1861.26002473,1253.... |
3,614 | #include<iostream>
#include<fstream>
#include<string>
#include<cmath>
#include<assert.h>
#include<stdio.h>
#include<cuda.h>
#include<sys/time.h>
//using namespace std;
double getSeconds()
{
struct timeval tp;
gettimeofday(&tp, NULL);
return ((double)tp.tv_sec + (double)tp.tv_usec * 1e-6);
}
typedef double real;
s... |
3,615 | #include "MarkovChain.cuh"
/**
* Characters (26)
* Start of word (1)
* End of word (1)
*/
#define CHARACTERS 27
#define BUFFERSIZE 20
#define START 'S'
#define ENDINDEX 0
int getCharacterIndex(char character) {
switch (character) {
//The start character
case START:
return CHARACTERS;
//The end c... |
3,616 | #include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <iostream>
int main() {
thrust::host_vector<double> host(5, 0);
host[4] = 35;
/* na linha abaixo os dados são copiados
para GPU */
thrust::device_vector<double> dev(host);
/* a linha abaixo só muda o vetor na CPU... |
3,617 | #include<stdio.h>
#include<cuda.h>
#include<iostream>
#include<fstream>
#include<chrono>
using namespace std;
__global__ void serialReduction(int *d_array, int numberOfElements)
{
int sum = 0;
for(int i=0;i<numberOfElements;i++)
{
sum = sum + d_array[i];
}
printf("%d",sum);
}
void seri... |
3,618 | #include <cstdlib>
#include <cstdio>
#include <ctime>
#include <chrono>
__global__ void cuda_vecAdd(float *v1, float *v2, float *v3, int offset)
{
int i = offset + blockIdx.x * blockDim.x + threadIdx.x;
v3[i] = v1[i] + v2[i];
}
int main(void)
{
typedef std::chrono::high_resolution_clock Clock;
typedef std::chrono... |
3,619 |
#include <stdio.h>
/**
* CPU version of our CUDA Hello World!
*/
void cpu_helloworld()
{
printf("Hello from the CPU!\n");
}
/**
* GPU version of our CUDA Hello World!
*/
__global__ void gpu_helloworld()
{
int threadId = threadIdx.x;
printf("Hello from the GPU! My threadId is %d\n", threadId);
}
int ... |
3,620 | #include <iostream>
#include <cstdlib>
#include <vector>
__global__ void vectorAdd(int* a, int* b, int* c, int n) {
int tid = blockIdx.x * blockDim.x + threadIdx.x;
/* printf("tid: %d\n", tid); */
if(tid < n)
c[tid] = a[tid] + b[tid];
}
int main() {
int n = 1 << 20;
// Host array
/* std::vector<int... |
3,621 | /**
* Demo code of Cuda programming lecture
*
* This programme illustrates how warp divergence may influence the performance of CUDA programme
*
*
*/
#include <cstdio>
#include <cstdlib>
#include <sys/time.h>
#define HALF_BLOCK_SIZE 512
#define BLOCK_SIZE 1024
#define LOOP_NUM 1024
//Kernel1 (has warp divergen... |
3,622 | #include <iostream>
#include <cmath>
#include <cstdio>
#include <sys/time.h>
using namespace std;
#define CUDA_SAFE_CALL( err ) (safe_call(err, __LINE__))
#define BLOCK_SIZE 32
#define ERROR 1.0e-9
typedef unsigned long long int LONG;
void safe_call(cudaError_t ret, int line)
{
if(ret!=cudaSuccess)
{
cout << "E... |
3,623 | __global__ void fillOneIntegerArrayKernel(
int numberRows,
int numberEntries,
int* array,
int constant) {
int index = blockIdx.x * numberEntries + blockIdx.y * numberRows + threadIdx.x;
array[index] = constant;
} |
3,624 |
/*
// Cython function from 'thinc' library
class NumpyOps(Ops):
def mean_pool(self, float[:, ::1] X, int[::1] lengths):
cdef int B = lengths.shape[0]
cdef int O = X.shape[1]
cdef int T = X.shape[0]
cdef Pool mem = Pool()
means = <float*>mem.alloc(B * O, sizeof(float))
... |
3,625 | //#include <thrust/host_vector.h>
//#include <thrust/device_vector.h>
#include <iostream>
#include "diffraction.cuh"
#include <cuda.h>
#include <cuda_runtime.h>
#include <stdio.h>
#include <math_constants.h>
//#define THREADS_PER_BLOCK 200
/*
double cuda_func(double ang) {
// H has storage for 4 integers
thrust:... |
3,626 | #include <cuda.h>
#include <cuda_runtime.h>
int get_cuda_error_code()
{
return (int) cudaGetLastError();
}
|
3,627 | #include <iostream>
#include <sys/time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cuda.h>
#define t1 4096
#define t2 4096
#define N 1
#define ITERATIONS 10
#define BLOCK_SIZE 32
using namespace std;
float A[N * N], B[N * N], C[N * N], C_cmp[N * N];
__global__ void split(float *C11, float *C12, float *C21, flo... |
3,628 | #include <stdlib.h>
#include <stdio.h>
__global__ void run(void)
{
int cid = threadIdx.x;
int val = 0;
while(val<(cid+10)){
// do some "work" so the loop can't be compiled away
val++;
if(val == cid){
val = 0;
}
}
}
int main(int argc, char** argv)
{
for(;;){
run<<<1024,1024>>>();
cudaError_t err = ... |
3,629 | #include <fstream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
// Feature maps dimensionality descriptions and assumptions:
// : Height : Width : Channels : Number :
// INPUT / A | H | W | C | ... |
3,630 | #include "includes.h"
__global__ void blurKernel(uchar3 *in, uchar3 *out, int w, int h)
{
int Col = blockIdx.x*blockDim.x + threadIdx.x;
int Row = blockIdx.y*blockDim.y + threadIdx.y;
if(Col<w && Row<h)
{
int pixVal1 = 0;
// int pixVal2 = 0;
// int pixVal3 = 0;
int pixels1 = 0;
// int pixels2 = 0;
// int pixels3 = 0;
... |
3,631 |
typedef long long LL;
__device__
int cuda_field_modulus;
__device__
int inverse(int a, int p){
return a == 1 ? 1 : ((LL)(a-inverse(p%a, a))*p+1)/a;
}
__device__
void cuda_field_init(int m){
cuda_field_modulus = m;
}
struct cuda_field_element {
__device__
cuda_field_element(){}
__device__
cuda_field_elemen... |
3,632 | #include "assert.h"
#include "real.h"
#include <iostream>
#include "gpuerrchk.cuh"
#include "math.h"
#define MAX_MASK_WIDTH 10
#define TILE_SIZE 1000
__device__ __constant__ float d_M[1000];
__global__ void share_conv_kernel(real* A, real* P, int mask_width, int width){
__shared__ real A_s[TILE_SIZE];
A_s[threadId... |
3,633 | __global__ void update_e( int Nz, int Nyz, int Nyzm, 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 fidx = idx + idx/(Nz-1) + idx/Nyzm*Nz + Nyz + Nz + 1;
Ex[fidx] += CEx[fidx]*( Hz[fidx+Nz] - Hz[fidx] - Hy... |
3,634 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cuda_runtime.h>
#ifndef __CUDACC__
#define __CUDACC__
#endif
#include "device_launch_parameters.h"
#include <cuda.h>
#include <device_functions.h>
#include <cuda_runtime_api.h>
// Matrices are stored in row-major order:
// M(row, col) = *(M.elements... |
3,635 | /* This code implements the serial solution and CUDA version for finding the maximal burst in a time series;
How to compile:
nvcc compare.cu
How to run:
./a.out n k //n is the length of the time series and k is the minimum lenght of a subsequence
Results to see:
The burst found b... |
3,636 | #include "includes.h"
__global__ void Find3DMinMax(int *d_Result, float *d_Data1, float *d_Data2, float *d_Data3, int width, int pitch, int height)
{
// Data cache
__shared__ float data1[3*(MINMAX_W + 2)];
__shared__ float data2[3*(MINMAX_W + 2)];
__shared__ float data3[3*(MINMAX_W + 2)];
__shared__ float ymin1[(MINMAX... |
3,637 | #include "includes.h"
__global__ void kMartixSubstractMatrix(const int nThreads, const float *m1, const float *m2, float *output) {
/* Computes the (elementwise) difference between two arrays
Inputs:
m1: array
m2: array
output: array,the results of the computation are to be stored here
*/
for (int i = blockIdx.x * bl... |
3,638 | #include "includes.h"
__global__ void ComputePhiMag_GPU(float* phiR, float* phiI, float* phiMag, int numK) {
int indexK = blockIdx.x*KERNEL_PHI_MAG_THREADS_PER_BLOCK + threadIdx.x;
if (indexK < numK) {
float real = phiR[indexK];
float imag = phiI[indexK];
phiMag[indexK] = real*real + imag*imag;
}
} |
3,639 | /*
* cSumSquares.cu
*
* Copyright 2021 mike <mike@fedora33>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
... |
3,640 | #include <iostream>
#include <math.h>
#include <ctime>
#include <cmath>
#include <stdlib.h>
#include <fstream>
#include <sstream>
#define PI 3.14159265358979323846
__device__ double density(double Xold, double Xnew, double sigma, double r, double delta, double delta_t){
double f=0, x=0;
//x=(1/(sigma*sqrt(delta_t))... |
3,641 | #include "GOL_runner.cuh"
#include <stdio.h>
#define threadWidth 16
#define threadHeight 16
__device__ int horizCheck(bool* board, int width, int height, int x, int y) {
int horizIndex, vertIndex, realIndex, countH;
vertIndex = (y); countH = 0;
if ((x) + 1 == (width)) { horizIndex = 0; }
else { horizIndex = (x... |
3,642 | /**
This example is based on the article titled "CUDA Pro Tip: Occupancy API Simplifies Launch Configuration".
More info on https://devblogs.nvidia.com/parallelforall/cuda-pro-tip-occupancy-api-simplifies-launch-configuration/
*/
#include "stdio.h"
__global__ void VectorMultiplicationKernel(int *array, int arra... |
3,643 | #include "includes.h"
__global__ void vecAdd(float * in1, float * in2, float * out, int len) {
//@@ Insert code to implement vector addition here
int idx = threadIdx.x + blockDim.x * blockIdx.x;
if (idx < len) {
out[idx ] = in1[idx] + in2[idx];
}
} |
3,644 | #include <iostream>
const long int IMAGE_SIZE = 8192;
const int BLOCK_SIZE = 32;
const float alpha = 2.f;
const float beta = 2.f;
__global__ void sgemmNaive(float* A, float* B, float* C, int N)
{
int row = blockIdx.y * blockDim.y + threadIdx.y;
int col = blockIdx.x * blockDim.x + threadIdx.x;
float val ... |
3,645 | //#include <helper_cuda.h>
#include "project_kernel.cuh"
#include <stdio.h>
__constant__ float K[3][3];
__constant__ float Kinv[3][3];
__constant__ float eps2;
__constant__ int npoints;
__device__ float image[480*640];
__global__ void project_kernel(float *d_x, float *d_y, float *d_z, float *d_nx,
... |
3,646 | #include "includes.h"
/*
* SpaceTime Simulator
* Curso Deep Learning y Cuda - 2020
* Autor: Oscar Noel Amaya Garcia
* email: dbanshee@gmail.com
*/
#define RUN_MODE_SIM 0
#define RUN_MODE_BENCH 1
#define SP_FILENAME "sp.json"
#define SP_FILENAME_BUFF1 "sp_0.json"
#define S... |
3,647 | // ###
// ###
// ### Practical Course: GPU Programming in Computer Vision
// ###
// ###
// ### Technical University Munich, Computer Vision Group
// ### Summer Semester 2017, September 11 - October 9
// ###
#include <cuda_runtime.h>
#include <iostream>
using namespace std;
// cuda error checking
#define CUDA_CHECK c... |
3,648 | #include<bits/stdc++.h>
using namespace std;
#define BLOCK_SIZE 16
__global__ void matrix_multiplication(int *dev_a, int *dev_b, int *dev_c, int n){
__shared__ int tile_a[BLOCK_SIZE][BLOCK_SIZE];
__shared__ int tile_b[BLOCK_SIZE][BLOCK_SIZE];
int row = blockIdx.y*BLOCK_SIZE + threadIdx.y;
int col = ... |
3,649 | // Sorting reference, Odd-Even Algorithm using CUDA
__global__ void odd_even_sort_gpu_kernel_gmem(int * const data, const int num_elem) {
const int tid = (blockIdx.x * blockDim.x) + threadIdx.x;
int tid_idx;
int offset = 0; // Start off with even, then odd
int num_swaps;
// Calculation maximum index for a give... |
3,650 | // only kernel, not fully executable
#define RADIUS 7
#define BLOCK_SIZE 512
__global__ void stencil(int *in, int *out)
{
__shared__ int temp[BLOCK_SIZE + 2 * RADIUS];
int gindex = threadIdx.x + blockIdx.x * blockDim.x;
int lindex = threadIdx.x + RADIUS;
// Read input elements into shared memory
... |
3,651 | #include "includes.h"
__global__ void reduce(float* d_out, float* d_in) { // Parallel summation: steps = O(log(N)), work = O(N * log(N))
extern __shared__ float sdata[];
int globId = blockDim.x * blockIdx.x + threadIdx.x;
int tid = threadIdx.x;
sdata[tid] = d_in[globId];
__syncthreads();
int s = blockDim.x >> 1;
whi... |
3,652 | #include <stdio.h>
#include <time.h>
#define PI 3.1415926535897932384
#define mu0 4*PI*1e-7
//Threads per block is capped at 1024 for hardware reasons
//In some cases using a smaller number of threads per block will be more efficient
#define threadsPerBlock 1024
//Max grid points is to defined in order to allocate sha... |
3,653 | #include <stdio.h>
#include <cuda.h>
void test(int* C, int length);
/***********************/
/* TODO, write KERNEL */
/***********************/
__global__ void VecAdd(int* A, int* B, int* C, int N) {
int id = blockIdx.x*blockDim.x+threadIdx.x;
if(id<N){
C[id] = A[id]+B[id];
}
}
int main(int arg... |
3,654 |
#include <cstdio>
#include <cmath>
#define BLOCKDIM 1024
// device kernel def
__global__ void Action_noImage_center_GPU(double *D_,double *maskCenter,double *SolventMols_,double maxD, int Nmols , int NAtoms, int active_size);
__global__ void Action_noImage_no_center_GPU(double *D_,double *SolventMols_,double *Solute... |
3,655 | #include <cuda.h>
__device__ void lock(int *mutex) {
while (atomicCAS(mutex, 0, 1));
}
__device__ void unlock(int *mutex) {
atomicExch(mutex, 0);
}
__device__ long getThreadID() {
int blockId = blockIdx.x
+ blockIdx.y * gridDim.x
+ gridDim.x * gridDim.y * blockIdx.z;
int threadId = blockId... |
3,656 | #include "includes.h"
__global__ void absolute_deriviative_upd_kernel( float4 * __restrict input_errors, const float4 * __restrict output_errors, const float4 * __restrict input_neurons, bool add_update_to_destination, int elem_count)
{
int elem_id = blockDim.x * (blockIdx.y * gridDim.x + blockIdx.x) + threadIdx.x;
if ... |
3,657 | #include <cuda.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <float.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <string>
#include <algorithm>
/***all macros**/
#define E_INIT 5 // in joules
#define E_ELEC 50e-... |
3,658 | #include<iostream>
using namespace std;
__global__ void add(int *a,int*b,int *c,int n)
{
int row=blockIdx.y*blockDim.y+threadIdx.y;
int col=blockIdx.x*blockDim.x+threadIdx.x;
int sum=0;
for(int i=0;i<n;i++)
{
sum=sum+a[row*n+i]*b[i*n+col];
}
c[row*n+col]=sum;
}
int main()
{
cout<<"Enter size of mat... |
3,659 | #include <stdio.h>
#include <cuda.h>
#include <iostream>
#include <cooperative_groups.h>
#define TYPE int
using namespace cooperative_groups;
__global__ void my_kernel(int* a){
int tid = blockDim.x * blockIdx.x + threadIdx.x;
a[tid]=0;
}
int main(int argc, char **argv){
int dev = 1;
int numBlocksPerSm = 0;
int... |
3,660 | // filename: gax.cu
// a simple CUDA kernel to add two vectors
extern "C" // ensure function name to be exactly "gax"
{
__global__ void gax(const int lengthC, const double *a, const double *b, double *c)
{
int i = threadIdx.x + blockIdx.x * blockDim.x;
if (i<lengthC)
{
c[i] = a[0]*b[i]; //... |
3,661 | /**
* Copyright 1993-2012 NVIDIA Corporation. All rights reserved.
*
* Please refer to the NVIDIA end user license agreement (EULA) associated
* with this source code for terms and conditions that govern your use of
* this software. Any use, reproduction, disclosure, or distribution of
* this software and relate... |
3,662 | #define MAX_BLOCKS 65535
#define MAX_THREADS 512
#include <iostream>
using namespace std;
/*
__global__ void harmonic_sum_kernel(float *d_idata,int gulp_index, int size, int stretch_factor)
{
//float* d_idata_float = (float*)d_idata;
int Index = blockIdx.x * blockDim.x + threadIdx.x;
if(Index<size/stretch_f... |
3,663 | #include <thrust/device_vector.h>
#include <thrust/count.h>
#include <thrust/copy.h>
struct is_odd
{
__host__ __device__
bool operator()(int x)
{
return (x%2) == 1;
}
};
int main(void)
{
thrust::device_vector<int> data(8);
data[0] = 6;
data[1] = 3;
data[2] = 7;
data[3] = 5;
... |
3,664 | // Checks that cuda compilation does the right thing when passed
// -fcuda-flush-denormals-to-zero. This should be translated to
// -fdenormal-fp-math-f32=preserve-sign
// RUN: %clang -no-canonical-prefixes -### -target x86_64-linux-gnu -c -march=haswell --cuda-gpu-arch=sm_20 -fcuda-flush-denormals-to-zero -nocudainc ... |
3,665 | /*
* a simple test of the scan kernel.
*/
#include <stdio.h>
#include <stdlib.h>
__global__ void cudaScan(float* out, float *in, int size);
void startClock(char*);
void stopClock(char*);
void printClock(char*);
int main(int argc, char** argv) {
if (argc < 2) {
printf("Usage: %s size-of-array\n",argv[0]);
exi... |
3,666 | #include "includes.h"
__global__ void cuConvert8uC3To32fC4Kernel(const unsigned char *src, size_t src_pitch, float4* dst, size_t dst_stride, float mul_constant, float add_constant, int width, int height)
{
const int x = blockIdx.x*blockDim.x + threadIdx.x;
const int y = blockIdx.y*blockDim.y + threadIdx.y;
int src_c = ... |
3,667 | //
// Created by daniel on 10/23/20.
//
#include "brdf.cuh"
|
3,668 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <cuda_runtime.h>
struct Lock {
int *mutex;
Lock( void ) {
int state = 0;
cudaMalloc( (void**)& mutex, sizeof(int) );
cudaMemcpy( mutex, &state, sizeof(int), cudaMemcpyHostToDevice );
}
~Lock( void ) {
cudaFree( mutex );
}
... |
3,669 | // MIT License
//
// Copyright (c) 2019 Miikka Väisälä
//
// 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, mo... |
3,670 | // Based on: https://gist.github.com/1392067
#include <cuda.h>
#include <stdio.h>
#define NBLOCKS 4
#define NTHREADS 4
#define N (NTHREADS * NBLOCKS)
#define NBYTES (N * sizeof(unsigned))
#define SWAP(a, b) { unsigned tmp = (a); (a) = (b); (b) = tmp; }
__global__ void bitonic_sort_step(unsigned* values, unsigned j... |
3,671 | /*
Ye Wang
CPEG655
lab2 problem 1.b
*/
#include <stdio.h>
#include <assert.h>
#include <cuda_runtime.h>
#include <sys/time.h>
__global__ void
matrixMul_1b(int BLOCK_SIZE, float *C, float *A, float *B, int N);
void mm(float * C, float * A, float * B, int N);
float GetRand(int seed);
void randomInit(float *data, in... |
3,672 | #include "includes.h"
extern "C"
__global__ void wavee(int* tab, unsigned int rowSize, unsigned int centerX, unsigned int centerY, float A, float lambda, float time, float fi, unsigned int N)
{
int index = threadIdx.x + blockDim.x * blockIdx.x;
int w = int(index/rowSize);
int h = index%rowSize;
if ( w*rowSize+h < N ... |
3,673 | // setup variables for calculation
__shared__ unsigned int iBAM;
#define ASK 1
#define MID 2
#define BID 3
#define TOLX 4
__device__ struct {
int vol[200];
int errmap[200];
} optout;
__global__ void myfunc(void)
{
int tid = threadIdx.x;
// going through each type, ASK, MID, and BID
for (unsigned int ii... |
3,674 | #include "includes.h"
__global__ void InvertValuesKernel(float *input, float* outputs, int size)
{
int id = blockDim.x * blockIdx.y * gridDim.x
+ blockDim.x*blockIdx.x
+ threadIdx.x;
if(id < size)
{
outputs[id] = 1.00f - input[id];
}
} |
3,675 | #include <iostream>
#include <cmath>
#include <stdio.h>
#include <string.h>
__device__ __constant__ float D_H[ 3*3 ];
__device__ float norm(float val, int length) {
float mean = length/2;
float std = length/2;
return (val-mean)/std;
}
__device__ float unorm(float val, int length) {
float mean = lengt... |
3,676 | #include <stdio.h>
#include <assert.h>
#define N 2048 * 2048 // Number of elements in each vector
inline cudaError_t checkCuda(cudaError_t result) {
if (result != cudaSuccess) {
printf("Error: %s\n", cudaGetErrorString(result));
assert(result == cudaSuccess);
}
return result;
}
// Initial... |
3,677 | #include <stdio.h>
#define START 32
#define END 126
#define NBR 68
__global__ void histo_kernel(unsigned char *buffer,long size, unsigned int *histo){
int dt = 32;
int i = threadIdx.x + blockIdx.x *blockDim.x;
int stride = blockDim.x *gridDim.x;
while(i<size){
/*
if (buffer[i] >= 32 && buffer[i] < 97)
... |
3,678 | #include <stdio.h>
__global__ void square(float *d_out,float *d_in)
{
int idx = threadIdx.x;
float f = d_in[idx];
d_out[idx] = f * f *f;
}
int main(int argc, char **argv)
{
const int ARRAY_SIZE = 96;
const int ARRAY_BYTES = ARRAY_SIZE * sizeof(float);
float h_in[ARRAY_SIZE];
for(int i = 0; i < ARRAY_SIZ... |
3,679 | #include <iostream>
#include <fstream>
#include <string>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <time.h>
using namespace std;
__global__ void tryy(float *d_engrec,float *d_xrec,float *d_yrec, float *d_xx, float *d_yy, float *d_engg, float *d_inx, int blocks){
int is,il;
int count2;
int... |
3,680 | #include <stdio.h>
__global__ void helloFromGPU() {
const auto a = threadIdx.x;
printf("Hello World From GPU thread %d!\n", a);
}
int main() {
printf("Hello World From CPU1!\n");
helloFromGPU<<<1, 100>>>();
printf("Hello World From CPU2!\n");
cudaDeviceReset();
// cudaDeviceSynchronize();
... |
3,681 | #include <cuda.h>
#include <cuda_runtime_api.h>
#include <stdio.h>
#include <stdlib.h>
extern "C" void max_stride(float* src, float*dst, int stride, int src_ldx, int dst_ldx, int step, int size,int batch_size,int num_stride, int *mask);
int main()
{
int i;
float *x;
float *x_gpu;
int *mask;
int *m... |
3,682 | // From Appendix B.15 of the CUDA-C Programming Guide.
#include <assert.h>
#include <cuda.h>
// assert() is only supported
// for devices of compute capability 2.0 and higher
#if defined(__CUDA_ARCH__) && (__CUDA_ARCH__ < 200)
#undef assert
#define assert(arg)
#endif
__global__ void testAssert(void) {
int is_o... |
3,683 | #include "includes.h"
/*
Modified from
https://github.com/zhxfl/CUDA-CNN
*/
__global__ void elementwiseMul(float *x, float *y, float *z, int rows, int cols) {
int j = blockIdx.x * blockDim.x + threadIdx.x;
int i = blockIdx.y * blockDim.y + threadIdx.y;
if (j >= cols || i >= rows) return;
z[i * cols + j] = x[i * col... |
3,684 | // runSim2.cu
#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <math.h>
#include <thrust/reduce.h>
#include <thrust/execution_policy.h>
#include <assert.h>
// Executes the A1 operator optimized
/// @brief Executes the A1 step of the algorithm. Updates the positions of the p... |
3,685 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#define TILE_WIDTH 16
//M and N number of threads (grid and block)
void secuential(const int a[] ,const int b[], unsigned long int c[], const int sqrt_dim);
__global__ voi... |
3,686 | #include <stdio.h>
const int N = 20;
const int MAX_WORD_SIZE = 1024;
__global__
void hello(char *a, char *b, int *c, int size, int msize)
{
int i = 0;
for(i = 0; i < msize; i++){
if(a[N * threadIdx.x + i] != b[i]){
c[threadIdx.x] = 0;
break;
}
if(i == msize - 1){
c[threadIdx.x] = 1;
break;
... |
3,687 | // Program for Parallel Vector Addition in CUDA
// For Hadoop-CUDA Lab
#include <stdio.h>
#include <cuda.h>
#include <stdlib.h>
#include <time.h>
#define N 1024 // size of array
__global__ void add(int *a,int *b, int *c) {
int tid = blockIdx.x * blockDim.x + threadIdx.x;
if(tid < N){
c[ti... |
3,688 | #include<fstream>
#include<iostream>
#include<vector>
#include<ctime>
#include<cuda.h>
using namespace std;
int N,M;
#define THREADS_PER_BLOCK 512
vector<int> readVector(ifstream &fin)
{
//fin.open();
int n;
int c;
fin>>n;
vector<int> result;
for (int i=0;i<n;i++){
fin>>c;
... |
3,689 | #include <assert.h>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdlib.h>
#include <cstring>
#ifndef gpuAssert
#include <stdio.h>
#define gpuAssert( condition ) { \
if( (condition) != 0 ) { \
fprintf( stderr, "\n FAILURE %s in %s, line %d\n", \
cudaGetErrorString(condition), __FILE_... |
3,690 | #include <stdio.h>
#include <sys/time.h>
#include <cuda.h>
#include <fstream>
#include <iostream>
#define N_ROWS 5
#define N_COLUMNS 6
#define INF 99999
#define K 60000000
#define SERIAL_DEPTH 10
#define GPU_DEPTH 2
#define at(table, i, j) ((table[1] & (1LL << ((i) * N_COLUMNS + j))) ? ( ((table[0] & (1LL << ((i) * ... |
3,691 | #include <cufft.h>
#include <stdio.h>
#include <malloc.h>
#define NX 64
#define BATCH 1
#define pi 3.141592
__global__ void gInitData(cufftComplex *data){
int i=threadIdx.x+blockDim.x*blockIdx.x;
float x=i*2.0f*pi/(NX);
data[i].x=cosf(x)-3.0f*sinf(x);
data[i].y=0.0f;
}
int main(){
//инициализация (эмуляция получ... |
3,692 | #include "includes.h"
__global__ void compute_distance_texture(cudaTextureObject_t ref, int ref_width, float * query, int query_width, int query_pitch, int height, float* dist) {
unsigned int xIndex = blockIdx.x * blockDim.x + thre... |
3,693 | #include "includes.h"
#define THREADS_PER_BLOCK 1024
#define TIME 3600000
__global__ void compute(float *a_d, float *b_d, float *c_d, int arraySize)
{
int ix = blockIdx.x * blockDim.x + threadIdx.x;
float temp;
if( ix > 0 && ix < arraySize-1){
temp = (a_d[ix+1]+a_d[ix-1])/2.0;
__syncthreads();
b_d[ix]=temp;
_... |
3,694 | //
// Created by lidan on 26/10/2020.
//
|
3,695 | #include <iostream>
#include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <thrust/transform.h>
#include <thrust/fill.h>
struct saxpy_functor
{
const float a;
saxpy_functor(float _a) : a(_a) {}
__host__ __device__
float operator()(const float& x, const float& y) const {
... |
3,696 | #include "cuda.h"
#include "stdio.h"
int main(int argc, char *argv[]) {
int version, log2N_min, log2N_max;
float dur_max;
if (argc == 5) {
version = atoi(argv[1]);
log2N_min = atoi(argv[2]);
log2N_max = atoi(argv[3]);
dur_max = atof(argv[4]) * 1000.f;
} else {
printf("Usage: ./p1 <version> ... |
3,697 | extern "C"
__global__ void dispatchDots(
//Tree specs
// per Block In
int* dotIndexes,
int* stBl0, int* nPtBl0,
int* stBl1, int* nPtBl1,
int* blLevel,
// per GPU Block In
int* idBl,
int* offsBl,
// input values... |
3,698 | #include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
const long long tdelay = 1000000LL;
const int hdelay = 1000;
__global__ void dkern(){
long long start = clock64();
while(clock64() < start + tdelay);
}
int main(int argc, char *argv[]){
int i = 0;
int my_delay = hdelay;
if (argc > 1) my_delay = at... |
3,699 |
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <sys/types.h>
#include <sys/times.h>
#include <sys/time.h>
#include <time.h>
/* Program Parameters */
#define MAXN 15000 /* Max value of N */
#define TILE_WIDTH 32 /* Width of each block */
int N; /* Matrix size */
/* Matrices *... |
3,700 | #include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <thrust/functional.h>
#include <thrust/transform.h>
#include <iostream>
int main() {
thrust::device_vector<double> AAPL;
thrust::device_vector<double> MSFT;
thrust::device_vector<double> MEAN_DIF(2518,0);
double stocks_AAPL, st... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.