serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
4,601 | #include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cuda.h>
#include<curand_kernel.h>
#include <time.h>
#define NO_COLOR 0
#define MIN_COLOR -1
#define MAX_COLOR 1
struct new_csr_graph{
int v_count,*A, *IA, *color;
};
__global__
void init_kernel(int *d_color, float *d_node_val, curandState* state, unsign... |
4,602 | #include <math.h>
#include <float.h>
#include <cuda.h>
// First solution with global memory
__global__ void gpu_Heat (float *u, float *utmp, float *residual,int N) {
// TODO: kernel computation
int sizey = N;
int j = blockIdx.x * blockDim.x + threadIdx.x;
int i = blockIdx.y * blockDim.y + threadIdx.y;
float diff... |
4,603 | #include "includes.h"
__global__ void Vector_Addition ( int *dev_a , int *dev_b , int *dev_c)
{
//Lay ra id cua thread trong 1 block.
int tid = blockIdx.x ; // blockDim.x*blockIdx.x+threadIdx.x
if ( tid < N )
*(dev_c+tid) = *(dev_a+tid) + *(dev_b+tid) ;
} |
4,604 | #include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
// HELPER FUNCTIONS
// Print an array of floats in [,,] format
void printFloatArray(float *arr, int len){
printf("[");
for (int i = 0; i < len -1; ++i) {
printf("%.2f, ", arr[i]);
}
printf("%.2f]", arr[len-1]);
p... |
4,605 | #include "GetCuDNNVersion.h"
using DeepNeuralNetwork::GetCuDNNVersion;
int main()
{
GetCuDNNVersion version {};
version.pretty_print();
} |
4,606 | #include "includes.h"
__global__ void cudaFillArray( float *gpu_array, float val, int N )
{
int i = (blockIdx.x + blockIdx.y*gridDim.x) * blockDim.x + threadIdx.x;
if( i < N ){
gpu_array[i] = val;
}
} |
4,607 | #include<stdio.h>
#include<math.h>
#include<cuda.h>
#define N 256
__global__ void matrix_vector_multi_gpu_1_1(float *A_d,float *B_d,float *C_d,int *tensuu_d){
int i,j;
printf("tensuu_d=%d\n",*tensuu_d);
for(j=0;j<N;j++){
A_d[j]=0.0;
for(i=0;i<N;i++){
A_d[j]=A_d[j]+B_d[j*N+i]*C_d[i];
}
}
}
... |
4,608 | // PABLO ANDRES COUTINHO BURGOS
// AUGUSTO ESTUARDO ALONSO ASCENCIO
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <sstream>
#include <utility>
#include <stdio.h>
#include <string>
#include <cmath>
#include <math.h>
using namespace std;
__global__
void getTotal... |
4,609 | #include<stdio.h>
#include<cuda.h>
#include<stdlib.h>
#include<cuda_runtime_api.h>
#define Tile_size 3
#define funcCheck(stmt) do { \
cudaError_t err = stmt; \
if (err != cudaSuccess) { ... |
4,610 | /***************************************************************************//**
* \file .cu
* \author Christopher Minar (minarc@oregonstate.edu)
* \CPU Author, Anush Krishnan (anush@bu.edu)
* \brief Implementation of the methods of the class \c DirectForcingSolver to tag
* points near the immersed boundary... |
4,611 |
#include <stdio.h>
#include <pthread.h>
#define BLOCK_SIZE 64
#define REDUCTION_BLOCK_SIZE 1024
#define PIx2 6.2831853071795864769252867665590058f
#include <sys/time.h>
struct kValues {
float Kx;
float Ky;
float Kz;
float PhiMag;
};
//size needed: numK * 1
__global__ void ComputePhiMagGPU(struct kValues* kVals... |
4,612 | #include <algorithm>
#include <cassert>
#include <iostream>
#include <random>
#include <vector>
#include <cuda.h>
using std::cout;
using std::endl;
int constexpr kN = 1000;
std::mt19937_64 rand_engine;
void cudaCheckSuccess(cudaError_t const cuda_status, std::string const& message)
{
if(cudaSuccess != cuda_stat... |
4,613 | #include <iostream>
using namespace std;
static void HandleError(cudaError_t err, const char *file, int line) {
if (err != cudaSuccess) {
cout << cudaGetErrorString(err) << " in file '" << file << "' at line " << line << endl;
exit(EXIT_FAILURE);
}
}
#define HANDLE_ERROR(err) (HandleError(err, __FILE__, _... |
4,614 | __device__ float backwardRelu (float forward, float chain)
{
if(forward > 0.0) {
return chain;
}
else {
return 0.0;
}
}
extern "C"
__global__ void backwardReluKernel (int length, float *forward, float *chain, float *destination)
{
int index = blockDim.x * blockIdx.x + threadI... |
4,615 | #include <cuda_runtime.h>
// ctrl+shift+space to see parameters
//Formatear code ctr+k ctrl+d
//Scroll barra es información general
int main() {
int* a;
cudaMalloc(&a, 100);
cudaFree(a);
return 0;
} |
4,616 | #include "includes.h"
#define UPPERTHRESHOLD 90
#define LOWERTHRESHOLD 30
const float G_x[3 * 3] = {
-1, 0, 1,
-2, 0, 2,
-1, 0, 1
};
const float G_y[3 * 3] = {
1, 2, 1,
0, 0, 0,
-1, -2, -1
};
const float gaussian[5 * 5] = {
2.f/159, 4.f/159, 5.f/159, 4.f/159, 2.f/159,
4.f/159, 9.f/159, 12.f/159, 9.f/159, 4.f/159,
5... |
4,617 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <math.h>
#define MASK_WIDTH 11
#define COMMENT "Histogram_GPU"
#define RGB_COMPONENT_COLOR 255
#define DIM_BLOCO 32
typedef struct {
unsigned char red, green, blue;
} PPMPixel;
typedef struct {
int x, y;
PPMPixel *data;
} PPMImage;
dou... |
4,618 | #include "includes.h"
__global__ void kSqSumColumnwise(float* mat, float* target, unsigned int width, unsigned int height) {
__shared__ float sum_vals[32];
float cur_sum = 0;
for (unsigned int i = threadIdx.x; i < height; i += 32) {
cur_sum += mat[blockIdx.x * height + i] * mat[blockIdx.x * height + i];
}
sum_vals[th... |
4,619 | //#include "Solver.cuh"
//
//namespace cudacp {
//CPUSolver::CPUSolver() {
//}
//
//CPUSolver::~CPUSolver() {
//}
////} |
4,620 | #include "includes.h"
__global__ void callOperationSharedStatic(int *a, int *b, int *res, int k, int p, int n)
{
int idx = blockDim.x * blockIdx.x + threadIdx.x;
int idy = blockDim.y * blockIdx.y + threadIdx.y;
if (idx >= n || idy >= n)
{
return;
}
int tid = idx * n + idy;
__shared__ int s_a[size * size], s_b[size *... |
4,621 | #include "VectorAddition.cuh"
#include <cuda_runtime.h>
namespace CUDASamples
{
namespace Introduction
{
__global__ void vector_add(
const float* A,
const float* B,
float* C,
std::size_t number_of_elements)
{
std::size_t i {blockDim.x * blockIdx.x + threadIdx.x};
if (i < number_of_elements)
{
C[i]... |
4,622 | /***********************************************************************************
* *
* NAME: main.cu *
* ... |
4,623 |
#define TILE_DIM 24
//#define BLOCK_ROWS 16
__global__ void copy(float *odata, float* idata, int width,
int height, int nreps, const int BLOCK_ROWS)
{
int xIndex = blockIdx.x*TILE_DIM + threadIdx.x;
int yIndex = blockIdx.y*TILE_DIM + threadIdx.y;
int index = xInd... |
4,624 | #include <cuda.h>
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#define BLOCK_SIZE 1024
// kernel
__global__ void tiledConvolution_1D_Kernel(float* d_m, const float* __restrict__ d_mask, float* d_n, size_t length, size_t maskLength, int N_TILE_LENGTH)
{
float result = 0;
// indexing variables
... |
4,625 | #include <cuda.h>
#include <stdio.h>
#include <iostream>
#include <time.h>
using namespace std;
//prod matrice matrice terza versione(vedi slide)
//input: l,m,n, size blocco (blocchi bidimensionali, quadrati, l m ed n devono essere multipli interi di sizeblocco)
__host__ void allocaEInizializzaMatrice(int **res,in... |
4,626 | #include "includes.h"
__global__ void ReduceMeanKernel (double *Dens, double *Energy, int nsec, double *mean_dens, double *mean_energy, double *mean_dens2, double *mean_energy2, int nrad)
{
int j = threadIdx.x + blockDim.x*blockIdx.x;
int i = 0;
if(j<nsec){
mean_dens[j] = Dens[i*nsec+ j];
mean_energy[j] = Energy[i*nse... |
4,627 | #include <stdio.h>
__global__ void bitonic_sort(float* mat, int N, int* idx);
int main() {
float arr[64] = {
0, 1, 1, 1, 1, 0, 1, 0, // 5
1, 1, 1, 1, 1, 0, 1, 0, // 6
0, 1, 1, 1, 0, 0, 1, 0, // 4
0, 1, 0, 0, 1, 0, 1, 0, // 3
0, 1, 1, 1, 1, 1, 1, 1, // 7
0, 0, 0, 0, 0... |
4,628 | #include <stdio.h>
#include <assert.h>
// Here you can set the device ID that was assigned to you
#define MYDEVICE 0
// Simple utility function to check for CUDA runtime errors
void checkCUDAError(const char *msg);
// Part 2 of 4: implement the kernel
__global__ void kernel( int *a, int dimx, int dimy ) {
int i = ... |
4,629 | #include <stdio.h>
__global__ void printSuccessForCorrectExecutionConfiguration()
{
if(threadIdx.x == 3 && blockIdx.x == 4)
{
printf("Success!\n");
} else {
//printf("Failure. Update the execution configuration as necessary.\n");
}
}
int main()
{
// altering such that we get success once
print... |
4,630 | __global__ void ds(float *ds,int * y, float *delta, const unsigned int r, const unsigned int c )
{
int col = blockDim.x * blockIdx.x + threadIdx.x;
int row = blockDim.y * blockIdx.y + threadIdx.y;
if(row < r && col < c) {
if( delta[row * c + col] > 0)
ds[row * c + col ] = 1;
__syncthre... |
4,631 | // "Copyright 2018 <Fabio M. Graetz>"
#include <cuda.h>
#include <cuda_runtime.h>
#include <stdio.h>
#include <iostream>
template<class T>
__global__ void scanHillisSteele(T *d_out, T *d_in, const int n) {
unsigned int i = threadIdx.x + blockDim.x * blockIdx.x;
if (i < n) {
// extern __shared__ int shared_mem[... |
4,632 | #include <stdio.h>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <cuda_runtime_api.h>
/*
To compile:
nvcc -o KripesLinear KripesLinear.cu
./KripesLinear
*/
typedef struct point_t {
double x;
double y;
} point_t;
int n_data = 1000;
__device__ int d_n_data = 1000;
point_t data[] ={
{75.62,... |
4,633 | #include <stdio.h>
#include <iostream>
__global__ void add_gpu(float *a, float *b, float *out, int n){
int id = (blockIdx.x*blockDim.x)+threadIdx.x;
if (id < n){
out[id] = a[id] + b[id];
}
}
float* add(float* a, float* b, int n){
// host arrays
float* h_out;
h_out = (float*)malloc(sizeof(float)*n);
// ... |
4,634 | #include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>
const int MAXTILE = 32;
__global__ void gpu_mult_kernel(int* A, int* B, int* C, const int n)
{
// determine access location based on block ids and threadids
int i = blockIdx.y * blockDim.y + threa... |
4,635 | #include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
using namespace std;
int * make_array_2_to_n(int n) {
// Makes array of size n-1 (index 0 to n-2 map to 2 to n)
int * array = (int *) malloc((n-1) * sizeof(int));
for (int i = 0; i < (n-1); i++) {
array[i] = 1;
}
return array;
}
voi... |
4,636 | #include<stdio.h>
#include<cuda.h>
#include<stdlib.h>
#include<time.h>
__global__ void addition(float *d_a, float *d_b, float *d_c, int n)
{
// kernel function for calculating vector addition. blockIdx.x determines the block number, blockDim.x determines the number of threads per block and
// threadIdx.x tells us... |
4,637 | #include <stdio.h>
__global__ void helloWorld(){
printf("Hello World!\n");
}
int main(){
helloWorld<<<1,1>>>();
return 0;
}
|
4,638 | #include "includes.h"
__global__ void reduceNeighboredLess (int *g_idata, int *g_odata, unsigned int n)
{
// set thread ID
unsigned int tid = threadIdx.x;
unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x;
// convert global data pointer to the local pointer of this block
int *idata = g_idata + blockIdx.x * bloc... |
4,639 | #define d_vx(z,x) d_vx[(x)*(nz)+(z)]
#define d_vy(z,x) d_vy[(x)*(nz)+(z)]
#define d_vz(z,x) d_vz[(x)*(nz)+(z)]
#define d_szz(z,x) d_szz[(x)*(nz)+(z)] // Pressure
#define d_mem_dszz_dz(z,x) d_mem_dszz_dz[(x)*(nz)+(z)]
#define d_mem_dsxx_dx(z,x) d_mem_dsxx_dx[(x)*(nz)+(z)]
#define d_mem_dvz_dz(z,x) d_mem_dvz_dz[(x)*(n... |
4,640 | //pass
//--gridDim=[1200,1,1] --blockDim=[256,1,1]
__global__
void AddKernel(const float *op1, const float *op2, int count, float *sum)
{
const int pos = threadIdx.x + blockIdx.x * blockDim.x;
if (pos >= count) return;
sum[pos] = op1[pos] + op2[pos];
}
|
4,641 |
#include <inttypes.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <iostream>
#include <assert.h>
#include <cuda.h>
#define AES_BLOCK_SIZE 16
#define THREADS_PER_BLOCK 256
#define cudaCHECK(code) \
do... |
4,642 | ///*
// * Copyright 1993-2010 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 softwa... |
4,643 | #include <cuda_runtime.h>
#include "xray_ct_cuda.cuh"
__global__
void
cudaHighPassFilter(cufftComplex *dev_sinogram_cmplx,
const unsigned int sinogram_width, const unsigned int nAngles) {
unsigned int len = sinogram_width*nAngles;
float sinogram_spec_center = (sinogram_width - 1) / 2.0;
unsigned int s... |
4,644 | #include <stdio.h>
// 1-D index
int __device__ getIdx_1D_1D()
{
return blockIdx.x*blockDim.x + threadIdx.x;
}
int __device__ getIdx_1D_2D()
{
return blockIdx.x*blockDim.x*blockDim.y
+ threadIdx.y*blockDim.x
+ threadIdx.x;
}
int __device__ getIdx_2D_1D()
{
int bid = blockIdx.x*gridD... |
4,645 | #include "includes.h"
__global__ void DrawRgbaTextureKernel(float *target, int targetWidth, int targetHeight, int inputX, int inputY, float *texture, int textureWidth, int textureHeight)
{
int id = blockDim.x * blockIdx.y * gridDim.x
+ blockDim.x * blockIdx.x
+ threadIdx.x;
int targetPixels = targetWidth * targetHeigh... |
4,646 | /*
* @Author: jose
* @Date: 2020-08-24 00:00:00
* @Last Modified by: jose
* @Last Modified time: 2020-08-24 00:00:00
*/
// local libs
#include "kernels.cuh"
#include <cufft.h>
// ===========================================
// Check Errors
// ===========================================
#define imart_assert_kernel(... |
4,647 | #include "cuda.h"
#include "cuda_runtime.h"
#include <cstdio>
#define CUDA_SAFE_CALL(expr) \
{ \
cudaError_t err = (expr); \
if (err != cudaSuccess) \
{ \
printf("Cuda error: %s\n", cudaGetErrorString(err)); \
exit(1); \
} \
}
int main(void)
{
int deviceCount;
CUDA_SAFE_CALL(c... |
4,648 | #include <cuda_runtime.h>
#include <stdio.h>
#include <time.h>
#include <unistd.h>
static const int ROW=1024;
static const int COL=1024;
void printArr(const char * name, float * arr, unsigned int len)
{
for (int i=0;i<len;i++)
printf("arr %s [%u]=%5.5f\n", name, i, arr[i]);
}
void initData(float *ip, int size)
{
... |
4,649 | #include "includes.h"
__global__ void halve_bins(int *bin, const int n)
{
unsigned int xIndex = blockDim.x * blockIdx.x + threadIdx.x;
if ( xIndex < n )
bin[xIndex] = bin[xIndex]/2;
} |
4,650 |
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <stdlib.h>
#include "cuda_runtime.h"
#include <curand.h>
#include <curand_kernel.h>
#include "device_launch_parameters.h"
#include <stdio.h>
__global__ void monteCarlo(long timeVal, int N, int a, int b, long double* answer)
{
long double temp = 0;
in... |
4,651 | // thrustest
#pragma warning( disable : 4244) // thrust::reduce int mismatch
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include "thrust/host_vector.h"
#include "thrust/device_vector.h"
#include "thrust/execution_policy.h"
#include "thrust/for_each.h"
#include "thrust/scan.h"
#include <stdio.h>... |
4,652 | __global__ void delta_stepping(int* V, int* E, int* W, int* n, int* s, int* delta, int* dist, int* predist, int* nowIsNull, int* quickBreak){
const int u0 = threadIdx.z * blockDim.x * blockDim.y + threadIdx.y * blockDim.x + threadIdx.x;
const int offset = blockDim.x * blockDim.y * blockDim.z;
const int localSiz... |
4,653 | #include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <iostream>
#include <time.h>
#include <unistd.h>
#include <sys/time.h>
#include <cuda_runtime.h>
#define TILE_WIDTH 8
#define BLOCK_SIZE 32
// a sequential version of matrix_multiply
void matrix_multiply_seq(float... |
4,654 | #ifndef __CUDA_RUNTIME_H__
#include "cuda_runtime.h"
#endif // !"cuda_runtime.h"
#ifndef __DEVICE_LAUNCH_PARAMETERS_H__
#include "device_launch_parameters.h"
#endif // !__DEVICE_LAUNCH_PARAMETERS_H__
#include <stdio.h>
#include <string>
#include <iostream>
#include <chrono>
#include <ctime>
#include <vector>
#includ... |
4,655 | #include<stdio.h>
#include<stdlib.h>
__global__ void transpose(int *a,int *t)
{
int id=blockIdx.x*blockDim.x+threadIdx.x;
int flag=0,comp,j=1;
if(blockIdx.x==0 || (blockIdx.x+1)%gridDim.x == 0 || threadIdx.x==0 || (threadIdx.x+1)%blockDim.x==0)
flag=1;
if(!flag)
{
t[id]=0;
while(a[id]!=0... |
4,656 | /**
* 3DConvolution.cu: This file is part of the PolyBench/GPU 1.0 test suite.
*
*
* Contact: Scott Grauer-Gray <sgrauerg@gmail.com>
* Louis-Noel Pouchet <pouchet@cse.ohio-state.edu>
* Web address: http://www.cse.ohio-state.edu/~pouchet/software/polybench/GPU
*/
#include <unistd.h>
#include <stdio.h>
#include <... |
4,657 | #include "includes.h"
__global__ void kernelMultMatrices(float *a, float *b, float *c,int m, int n) {
int i = threadIdx.x + blockIdx.x*blockDim.x;
int j = threadIdx.y + blockIdx.y*blockDim.y;
//printf("%d,%d\n",i,j);
c[j+i*n]=0;
for(int k=0;k<N;k++) c[j+i*n]+=a[j+k*n]*b[k+i*n];;
__syncthreads();
} |
4,658 | #include<iostream>
#include <thrust/sort.h>
using namespace std;
int main(int argc, char const *argv[]) {
int numOfArrays = atoi(argv[1]);
int maxElements = atoi(argv[2]);
int N = numOfArrays*maxElements;
float *data = new float[numOfArrays*maxElements];
float *keys = new float[numOfArrays*maxElements];
for(... |
4,659 | #include "includes.h"
__global__ void gpu_blur(unsigned char* Pout, unsigned char* Pin, int width, int height){
int col = threadIdx.x + blockIdx.x * blockDim.x;
int row = threadIdx.y + blockIdx.y * blockDim.y;
int k_size = 3;
if (col < width && row < height){
int pixVal = 0;
int pixels = 0;
for(int blurRow = -k_size;... |
4,660 | __global__
void solvePressure(const float volumeLoss,
const float * d_levelset,
const float * d_velIn_x,
const float * d_velIn_y,
const float * d_pressureIn,
float * d_pressureOut)
{
}
void solvePressure(dim3 blocks,
... |
4,661 | //============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURP... |
4,662 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
__global__ void print_threadIds()
{
printf("blockIdx.x : %d blockIdx.y : %d blockIdx.z : %d gridDim.x : %d gridDim.y : %d gridDim.z : %d\n", blockIdx.x, blockIdx.y, blockIdx.z, gridDim.x, gridDim.y, gridDim.z);
}
int main()
{
... |
4,663 | #include "includes.h"
__global__ void PossionImageCloningIteration( const float *fixed, const float *mask, float *input, float *output, const int wt, const int ht, const int round ){
const int dir[16][2] = {{-2, -2}, {0, -2}, {2, -2},
{-1, -1}, {0, -1}, {1, -1},
{-2, 0}, {-1, 0}, {1, 0}, {2, 0},
{-1, 1}, {0, 1}... |
4,664 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <cuda.h>
#define TPB 1024 //elements per thread
#define BN 64 //block number
/*function declarations*/
int getmax(int *, int);
__global__ void kernel_getmax(int *, int, int);
__device__ void thread_getmax(int *, int *, int, int);
//the sequential v... |
4,665 | /*
Please use "inp.txt" as input file and output/write your results of each question to a separate file named as "q1a.txt", "q1b.txt" etc. The output file should have the same format as the input file.
You only need to submit three source code files, e.g. q1.cu, q2.cu and q3.cu and the input file "inp.txt". Don't subm... |
4,666 | #include "includes.h"
__global__ void kernel1(int* D, int* q, int b){
int i = threadIdx.x + b * THR_PER_BL;
int j = threadIdx.y + b * THR_PER_BL;
float d, f, e;
for(int k = b * THR_PER_BL; k < (b + 1) * THR_PER_BL; k++)
{
d = D[i * N + j];
f = D[i * N + k];
e = D[k * N + j];
__syncthreads();
if(d > f + e)
{
D[i * N... |
4,667 | // A shared memory matrix multiplication program
#include "stdio.h"
#include "stdlib.h"
// Keep the SIZE evenly divisible by TILE_WIDTH
#define SIZE 512
#define TILE_WIDTH 16
// kernels that are called by another kernel use the __device__ identifier
__device__ float * GetSubMatrix(float * large_matrix, int row, int... |
4,668 | #include <iostream>
#define INDEX_NUM 3
#define INDEX_SUM 0
#define INDEX_MAX 1
#define INDEX_MIN 2
#define NUM_MAX 1024
#define ITEMS_NUM (1024 * 1024)
#define BLOCK_SIZE 256
using namespace std;
// TODO-1 => ./task_no_atomic
// 1 thread does all compute, no atomic/sync
// thread.0 of ... |
4,669 | #include "includes.h"
__global__ void matmul_kernel(float *C, float *A, float *B) {
int x = blockIdx.x * block_size_x + threadIdx.x;
int y = blockIdx.y * block_size_y + threadIdx.y;
float sum = 0.0;
for (int k=0; k<WIDTH; k++) {
sum += A[y*WIDTH+k] * B[k*WIDTH+x];
}
C[y*WIDTH+x] = sum;
} |
4,670 | #include <iostream>
using namespace std;
template<class T> struct Triplet {
T x,y,z;
Triplet(T i) : x(i), y(i), z(i) {}
};
Triplet<int> a = Triplet<int>(42);
int main () {
cout << "hi " << a.z << endl;
return 0;
}
|
4,671 | #include "includes.h"
__global__ void kernel2(int k, int n, float* sub_searchPoints, float* referencePoints, float* dist)
{
float diff, squareSum;
int tid = blockDim.x * blockIdx.x + threadIdx.x;
if (tid < n) {
squareSum = 0;
for (int i = 0; i < k; i++) {
diff = sub_searchPoints[i] - referencePoints[k * tid + i];
squar... |
4,672 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
// Normal c++ function. Adds each element pair one at a time.
void vecAdd(double *a, double *b, double *c, int n)
{
for (int i=0; i<n; i++)
c[i] = a[i] + b[i];
}
int main( int argc, char* argv[] )
{
// Size of vectors
int n = 100000;
... |
4,673 | /*
Template code for convolution. CS6023, IITM */
#include<stdio.h>
#include<cuda.h>
#include<math.h>
#define W 1024 // Input DIM
#define OW (W-4) // Output DIM
#define D 8 // Input and Kernel Depth
#define T 5 // Kernel DIM
#define N 128 // Number of kernels
void fillMatrix(unsigned char *matrix){
unsigned char ... |
4,674 | #include <stdint.h>
#include <unistd.h>
#include <png.h>
#include <cuda.h>
#include <math.h>
#define rel params[0]
#define img params[1]
#define scl params[2]
__device__ void writeHSV(uint8_t *pixel, int theta) {
unsigned char region, remainder, q, t;
region = theta / 43;
remainder = (theta - (region * 4... |
4,675 | #include "includes.h"
/*
* This program is a CUDA C program simulating the N-body system
* of two galaxies as PHY 241 FINAL PROJECTS
*
*/
/*
* TODO:
* 1. andromeda
* 2. For accel of center of A, only consider accel from center of B. The same for B.
* 3. When the distance between A and B, the soft paramet... |
4,676 | #include "includes.h"
__device__ void sort(unsigned char* filterVector)
{
for (int i = 0; i < FILTER_WIDTH*FILTER_HEIGHT; i++) {
for (int j = i + 1; j < FILTER_WIDTH*FILTER_HEIGHT; j++) {
if (filterVector[i] > filterVector[j]) {
//Swap the variables
unsigned char tmp = filterVector[i];
filterVector[i] = filterVector[j]... |
4,677 | #include <stdio.h>
int main() {
int nDevices;
cudaGetDeviceCount(&nDevices);
for (int i = 0; i < nDevices; i++) {
cudaDeviceProp prop;
cudaGetDeviceProperties(&prop, i);
printf("Device Number: %d\n", i);
printf(" Device name: %s\n", prop.name);
printf(" Compute capability: %d.%d\n", pro... |
4,678 | /* 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 ... |
4,679 | #include <stdio.h>
#include <cooperative_groups.h>
#include "reduction.h"
using namespace cooperative_groups;
/*
Parallel sum reduction using shared memory
- takes log(n) steps for n input elements
- uses n threads
- only works for power-of-2 arrays
*/
/**
Two warp level primitives are used here ... |
4,680 | __global__ void create_newline_index(char *arr, long n, int *indices, long *result) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
int stride = blockDim.x * gridDim.x;
int offset = indices[index];
long chars_per_thread = (n+stride-1) / stride;
long start = index * chars_per_thread;
long end = start +... |
4,681 | #include "includes.h"
__global__ void histogram_equalization( int * lut, unsigned char * img_out, unsigned char * img_in, int * hist_in, int img_size, int nbr_bin){
int tx=threadIdx.x;
int ty=threadIdx.y;
int bx=blockIdx.x;
int by=blockIdx.y;
__shared__ int smem[256];
smem[ threadIdx.x ] = lut[ threadIdx.x ];
__synct... |
4,682 |
__global__ void
process_kernel1(const float *A, const float *B, float *C, const int size)
{
int threads_per_block = blockDim.x*blockDim.y*blockDim.z;
int i = blockIdx.z*(gridDim.x*gridDim.y)*threads_per_block + blockIdx.y*(gridDim.x)*(threads_per_block) + blockIdx.x*threads_per_block //Specifying the thread no... |
4,683 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
void init_timing(struct timeval* tstart)
{
gettimeofday(tstart, NULL);
}
float ellapsed_time(struct timeval tstart)
{
struct timeval tmp;
long long diff;
gettimeofday(&tmp, NULL);
diff = tmp.tv_usec - tstart.tv_usec;
diff += (tmp.tv_... |
4,684 | #include "includes.h"
const int Nthreads = 1024, maxFR = 100000, NrankMax = 3, nmaxiter = 500, NchanMax = 32;
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////... |
4,685 | #include "includes.h"
__global__ void hierarchical_scan_kernel_phase3(int *S, int *Y) {
int tx = threadIdx.x, bx = blockIdx.x;
int i = bx * SECTION_SIZE + tx;
//printf("Y[%d] = %.2f\n", i, Y[i]);
if (bx > 0)
{
for (int j = 0; j < SECTION_SIZE ; j += BLOCK_DIM ) {
Y[i + j] += S[bx - 1];
}
}
} |
4,686 | #include "includes.h"
#define max(a, b) a > b ? a : b
#define min(a, b) a < b ? a : b
struct Edge{
long long int x;
};
///*
//*/
__global__ void root_pointer_jumping(int* parent, int* vertex_state, int n, bool* flag){
int bid = blockIdx.x;
int tid = threadIdx.x;
int id = bid*blockDim.x + tid;
int parent_... |
4,687 | /*
This is the function you need to implement. Quick reference:
- input rows: 0 <= y < ny
- input columns: 0 <= x < nx
- element at row y and column x is stored in data[x + y*nx]
- correlation between rows i and row j has to be stored in result[i + j*ny]
- only parts with 0 <= j <= i < ny need to be filled
*/
#include ... |
4,688 | #include<iostream>
#include<cuda.h>
#include<cuda_runtime.h>
using namespace std;
#define N 10
#define intswap(A,B) {int temp=A;A=B;B=temp;}
__global__ void sort(int *c,int *count)
{
int l;
if(*count%2==0)
l=*count/2;
else
l=(*count/2)+1;
for(int i=0;i<l;i++)
{
if((... |
4,689 |
extern __device__ int file2_func(int);
int __device__ file1_func(int x)
{
return file2_func(x);
}
|
4,690 | #include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
double cpu_time();
#define M 500
#define N 500
void calculate_solution_gold(double w[M][N], double epsilon)
{
double diff;
double ctime;
double ctime1;
double ctime2;
int i;
int j;
int iterations;
int iteration... |
4,691 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include "cufft.h"
#include <stdio.h>
#include <malloc.h>
#include <math.h>
#include <complex>
#define BATCH 1
void fft(cufftDoubleComplex *in, cufftDoubleComplex *out, int size)
{
cufftDoubleComplex *inDev;
cufftDoubleComplex *outDev;
cudaMalloc((vo... |
4,692 | /*-------------int_para.cu----------------------------------------------------//
*
* int_para -- CUDA in parallel
*
* Purpose: Parallelize int_gpu.cu
*
* Notes: block: parallel invocation of kernel
* grid: set of blocks
*
*------------------------------------------------------------------------... |
4,693 | #include "includes.h"
// VectorAdd.cu
#define N 10 // size of vectors
#define B 1 // blocks in the grid
#define T 10 // threads in a block
__global__ void add (int *a,int *b, int *c) {
int tid = blockIdx.x * blockDim.x + threadIdx.x;
if(tid < N) {
c[tid] = a[tid]+b[tid];
}
} |
4,694 | // Compile with:
// nvcc --std=c++11 fft_stream.cu -o fft_stream -lcufft
#include <iostream>
#include <cuda.h>
#include <cuda_runtime.h>
#include <cufft.h>
#include <chrono>
#include <iomanip>
using namespace std;
using namespace std::chrono;
// Print file name, line number, and error code when a CUDA error occur... |
4,695 | //#include<stdio.h>
#include <iostream>
#include <vector>
__global__ void gaxpymm(double *y, double *a, double *b, int m, int n, int p){
int bid = blockIdx.x;
int tid = threadIdx.x;
extern __shared__ double dots_s[];
if(bid<m)
if(tid<n){
for(int c=0;c<p;c++)
dots_s[bid*n*p+tid*p+c] = a[bid*n+tid] *... |
4,696 | #include <iostream>
#include <stdlib.h>
#include <iomanip>
#include <time.h>
#include <sys/time.h>
#include <cuda.h>
using namespace std;
#define MAX_ARRAY_SIZE 2048
#define RANDOM_MAX 2.0
#define RANDOM_MIN 1.0
#define TILE_WIDTH 32
#define EPSILON 0.000001
#define NUM_BLOCKS (MAX_ARRAY_SIZE/TILE_WIDTH)
float A[M... |
4,697 | #include "includes.h"
// helper for CUDA error handling
__global__ void subtractMean( double* images, const double* meanImage, std::size_t imageNum, std::size_t pixelNum )
{
std::size_t col = blockIdx.x * blockDim.x + threadIdx.x;
if(col >= pixelNum)
{
return;
}
for(std::size_t row = 0; row < imageNum; ++row)
{
im... |
4,698 | #include "includes.h"
__global__ void saxpy(int * a, int * b, int * c)
{
int tid = blockIdx.x * blockDim.x * threadIdx.x;
if (tid < N)
c[tid] = 2 * a[tid] + b[tid];
} |
4,699 | #include <iostream>
#define M 50
#define tpb 256
#define bpg 1
__device__
bool is_same_block(int element_i, int other_i) {
return ((element_i + 10) / 10 == (other_i + 10) / 10);
}
__global__
void modify(int n, int *vector) {
__shared__ int s[M];
int i = threadIdx.x;
if (i < n) {
s[i] = i * 10 + 123 - 456... |
4,700 | #include <vector>
using Float = float;
__global__ void gpu_mul(Float * val, Float * wag, Float * inn, size_t N, size_t M)
{
auto val_ind = blockIdx.x + blockIdx.y * N;
auto wag_ind = blockIdx.x;
auto inn_ind = blockIdx.y;
if (val_ind < N*N and wag_ind < N and inn_ind < N)
{
val[blockIdx.x + blockIdx.y * N] ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.