serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
16,901 | #include "includes.h"
__global__ void row_sums(const float *A, float *sums, size_t ds){
int idx = threadIdx.x+blockDim.x*blockIdx.x; // create typical 1D thread index from built-in variables
if (idx < ds){
float sum = 0.0f;
for (size_t i = 0; i < ds; i++)
sum += A[idx*ds+i]; // write a for loop that will cause ... |
16,902 | //
// main.cu
// CS 426 - Project 4
//
// Created by Muhammed Cavusoglu on 19.05.2019.
// Copyright © 2019 Muhammed Cavusoglu. All rights reserved.
//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void read_matrix(int **row_ptr, int **col_ind, float **values, const char *filename, int *num_rows, int ... |
16,903 | // Copyright 2013 Yangqing Jia
#include <cmath>
#include <cstdlib>
#include <cstring>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
__global__ void im2col(const int n, const float * data_im,
const int height, const int width, const int ksize,
const int stride, const int heig... |
16,904 | /* Taken from CUDA_example.cu from Paul Baine's talk on GPUs.
Originally taken from some other site, I believe.
*/
#define COS_THREAD_CNT 512
#define N 10000000
#define TWO_PI 6.283185
/* --------------------------- target code ------------------------------*/
struct cosParams {
float *arg;
float *r... |
16,905 | #include "includes.h"
extern "C" {
}
__global__ void sgd_with_momentum(float* w, const float* dw, float learning_rate, float momentum, float* v, unsigned int len) {
int tid = blockIdx.x*blockDim.x + threadIdx.x;
if (tid < len) {
v[tid] = momentum * v[tid] + dw[tid];
w[tid] -= learning_rate * v[tid];
}
} |
16,906 | #include "includes.h"
#define _SIZE_ 1000000
/*
cudaError_t addWithCuda(int *c, const int *a, const int *b, unsigned int size);
*/
__global__ void addLoopGPU(int* a, int* b, int* c)
{
int tid = blockIdx.x;
if (tid < 64)
c[tid] = abs(powf(b[tid], 2) - powf(b[tid], 2));
} |
16,907 | #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 process_cross_edges(int* parent, Edge* edge_list, int e, bool* flag, bool* cross_edges){
int bid = blockIdx.x;
int tid = threadIdx.x;
int id = bid*blockDim.x + ... |
16,908 | #include "includes.h"
__global__ void depthwise_conv3d_forward(int B, int N, int M, int C, int r, int K, const int* nnIndex, const int* nnCount, const int* binIndex, const float* input, const float* filter, float* output)
{
for(int i=blockIdx.x;i<B;i+=gridDim.x)
{
for(int j=blockIdx.y*blockDim.x+threadIdx.x;j<M*(C*r);j... |
16,909 | #include <cuda.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
//define max value of array allement
#define MAX 100000
//defined threads per block for cims machines
#define THREADS_PER_BLOCK 1024
void generate(int *a);
__global__ void get_max(int *array);
//generate random numbers in array
void generate(... |
16,910 | #include <thrust/device_vector.h>
#include <thrust/transform.h>
struct triple
{
// functor puede ser utilizado por el host o el device
__host__ __device__
int operator()(int x)
{
return 3 * x;
}
};
int main(void)
{
thrust::device_vector<int> input(4);
input[0] = 10; input[1] = 20; ... |
16,911 | #include <stdlib.h>
#include <iostream>
#include <math.h>
#include <time.h>
#include <sys/time.h>
timeval t1, t2;
__global__ void Submanifold_conv(float* image, float* filter, float* result, int image_Rows, int image_Cols, int filterRC, int filter_Depth, int result_Rows, int result_Cols, int padding)
{
int row = ... |
16,912 | template<typename T>
__device__ void getRowsValues(const T* matrix, const int* indices, 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) {
int row = indices[col];
result[col] = matrix[... |
16,913 | /**********************************************************************
* DESCRIPTION:
* Serial Concurrent Wave Equation - C Version
* This program implements the concurrent wave equation
*********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <math... |
16,914 | /* Reduction of arbitrary sized vectors. Host side code. This is perhaps not the best implementation since
the size of the problem directly influences the number of threads created.
Author: Naga Kandasamy
Date: 2/23/2017
*/
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <string.h>
#includ... |
16,915 | #include "stdio.h"
#include <cuda.h>
#include <cuda_runtime.h>
#include <iostream>
// Defining number of elements in Array
#define N 5
#define M 6
#define BLOCK_SIZE 512
// Kernel function for squaring number
__global__ void gpuTranspose(float *d_in, float *d_out, int rows, int cols) {
int idx = blockIdx.x * blockDi... |
16,916 | #include<stdio.h>
#include<time.h>
#include<iostream>
#define w 256
#define h 256
#define N w*h
using namespace std;
__global__ void reduce(int*,int*);
int main(void)
{
int* hostA = (int*)malloc(N*sizeof(int));
int* hostB = (int*)malloc(N*sizeof(int));
int* deviceA,*deviceB;
cudaMalloc(&deviceA,sizeof(int)*N)... |
16,917 | //blur cuda
#include <stdio.h>
#include <cuda.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/time.h>
#define TY 32
#define TX 32
//this kernel does the regular blurring process
__global__
void blurKernel (int *R, int *G, int *B, int *Rnew, int *Gnew, int *Bnew, int rowsize, int colsi... |
16,918 | #include "includes.h"
__global__ void __set_lval(long long *A, long long val, int length) {
int ip = threadIdx.x + blockDim.x * (blockIdx.x + gridDim.x * blockIdx.y);
for (int i = ip; i < length; i += blockDim.x * gridDim.x * gridDim.y) {
A[i] = val;
}
} |
16,919 | #include <cuda_runtime.h>
#include <stdio.h>
#include <sys/time.h>
double seconds(){
struct timeval tp;
struct timezone tzp;
int i = gettimeofday(&tp,&tzp);
return ((double)tp.tv_sec+(double)tp.tv_usec*1.e-6);
}
__global__ void warmingup(float *c){
int tid = blockIdx.x * blockDim.x + threadIdx... |
16,920 | /*
David Ebert
Homework 1 - GPU Addition
Output:
(N=100)
Time in milliseconds= 0.053000000000000
Last Values are A[99] = 198.000000000000000 B[99] = 99.000000000000000 C[99] = 297.000000000000000
(N=600)
Time in milliseconds= 0.053000000000000
Last Values are A[599] = 1198.000000000000000 B[599] = 599.000000000000... |
16,921 | /*
*
* compiling:
* nvcc -lglut -LGLEW life.cuda.cu -o life
*
* for it's work:
* export LD_LIBRARY_PATH=:/usr/local/cuda/lib
* export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/libnvvp/
*
* cuda-gdb
*/
#include <stdio.h>
#define uchar unsigned char
#define NUMBER_OF_THREADS 512
uchar * dev_array1;
... |
16,922 | __global__ void
mat_add(float *a, float *b, float *c, int limit)
{
const int i = blockDim.x * blockIdx.x + threadIdx.x;
if (i < limit)
{
c[i] = a[i] + b[i];
}
}
|
16,923 | //
// main.cpp
// matrix-test
//
// Created by Nikita Makarov on 22/03/16.
// Copyright © 2016 Nikita Makarov. All rights reserved.
//
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iomanip>
using namespace std;
const double eps = 10e-7;
void print_matrix(double **M, long n... |
16,924 | #include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#define THREADS_PER_BLOCK 4
__global__ void kernelFunc(int m, int n, int k, double* ad, double* bd, double* cd, int lda, int ldb, int ldc) {
double v = 0.0;
int col = blockIdx.y * blockDim.y + threadIdx.y;
int row = blockIdx.x * blockDim.x + threadIdx.x;
i... |
16,925 | #include <cuda.h>
#include <stdio.h>
__global__ void gTest(float* a)
{
a[threadIdx.x + blockDim.x * blockIdx.x] = (float)((threadIdx.x + blockDim.x * blockIdx.x) * 2);
}
int main()
{
int m, n, k;
scanf("%d%d%d", &m, &n, &k);
float* mas = new float[m];
float* da;
int dev;
cudaSetDevice(de... |
16,926 | #include "includes.h"
__global__ void kShuffleColumns(float* source, float* target, float* indices, int width, int height){
const unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x;
const unsigned int numThreads = blockDim.x * gridDim.x;
float temp1, temp2;
unsigned int column, row, pos1, pos2;
for (unsigned int... |
16,927 | #include <stdio.h>
#include <sys/time.h>
#include <stdio.h>
#define SIZE 10
// HELPER CODE TO INITIALIZE, PRINT AND TIME
struct timeval start, end;
void starttime() {
gettimeofday( &start, 0 );
}
void endtime(const char* c) {
gettimeofday( &end, 0 );
double elapsed = ( end.tv_sec - start.tv_sec ) * 1000.0 ... |
16,928 | #include "includes.h"
__global__ void picaod_kernel(unsigned int *dev_v, long size, unsigned int *temp)
{
int x = threadIdx.x + blockIdx.x * blockDim.x;
int y = threadIdx.y + blockIdx.y * blockDim.y;
int offset = x + y * blockDim.x * gridDim.x;
atomicAdd(&(temp[0]), dev_v[offset]);
} |
16,929 | /*
Test max arg size (256 Byte) for Cuda kernel.
Passing struct to kernel arguments to overcome limitation of number of args in kernel
But regular kernel turns out working properly with 70 args
https://devtalk.nvidia.com/default/topic/458705/is-there-any-limit-on-of-arguments-in-cuda-kernel-/
*/
#include <cmath> //fo... |
16,930 | #ifndef INC_RENDERER_CUH
#define INC_RENDERER_CUH
// #ifndef __CUDACC__
// #define __CUDACC__
// #endif
#include <cuda.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <stdlib.h>
#include <complex>
#include <iostream>
namespace Render2
{
using sInt = signed int;
using byte = sign... |
16,931 | /* Derived from MLIFE exercise */
#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#define BORN 1
#define DIES 0
#define id(r,c) ((r)*Ncolumns+(c))
/* build board */
void init(int Nrows, int Ncolumns, int **board, int **newboard, int **c_board, int **c_newboard){
int r,c,n;
*board = (int*) calloc(N... |
16,932 | /*
Copyright (c) 2016, David lu
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 conditions and the following di... |
16,933 | // GPU kernel
__device__ void StencilUpdate(void* param)
{
float* paramIn = (float*)param;
int N = (int)paramIn[0];
float h = paramIn[1];
float dt = paramIn[2];
float alpha = paramIn[3];
float* u = paramIn+5;
float* u_prev = paramIn+5+N*N;
// Setting up indices
int i = threadIdx.x;
... |
16,934 | /*****************************************************************************
* A microbenchmark to test the performance of varying memory copy operations
* including different sizes and different sources and destinations
****************************************************************************/
#include <stdio... |
16,935 | #include "includes.h"
__global__ void kernelAddConstant(int *g_a, const int b)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
g_a[idx] += b;
} |
16,936 | #include <stdio.h>
__global__ void hello()
{
printf("hello, My gridDim is %d, %d, %d\n", gridDim.x, gridDim.y, gridDim.z);
printf("hello, My blockDim is %d, %d, %d\n", blockDim.x, blockDim.y, blockDim.z);
}
int main(int argc, char** argv)
{
dim3 cat(1, 2, 3);
dim3 dog(2, 1, 2);
hello<<<cat, dog>>>();
cudaDe... |
16,937 | #include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#define N 20480
// declare the kernel
__global__ void daxpy(double a, double *x, double *y) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < N) {
y[i] += a*x[i];
}
}
int main(void) {
double *x, *y, *d, a, *dx, *... |
16,938 | #include "includes.h"
__global__ void kernel2DXYp ( double* dataOutput, double* dataInput, double* boundaryTop, double* boundaryBottom, const double* weights, const int numSten, const int numStenHoriz, const int numStenLeft, const int numStenRight, const int numStenVert, const int numStenTop, const int numStenBottom, c... |
16,939 | /*Title:Implement nxn matrix parallel multiplication using CUDA/OpenCL GPU, use shared memory.
Assignmnet no:
Batch:T2
*/
#include<cuda.h>
#include<stdio.h>
int main(void)
{
void MatrixMultiplication(float *, float *, float *, int);
//const int Width = 5;
float M[5*5], N[5*5], P[5*5];
... |
16,940 | #include <iostream>
#include <random>
#include <fstream>
#include <string>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#define nr 512
#define nc 512
#define Blk_H 8
#define Blk_W 8
#define stclX 1
#define stclY 1
using namespace std;
// cuda code
#define cudaCheckErrors(msg) \
do { \
cud... |
16,941 | char *title = "Floyd's algorithm";
char *description = "Алгоритм Флойда - поиск всех кратчайших путей в графе";
/*
Алгоритм Флойда является одним из методов поиска кратчайших путей в графе.
В отличии от алгоритма Дейкстры, который позволяет при доведении до конца построить
ориентированное дерево кратчайших путей от ... |
16,942 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <float.h>
#include <limits.h>
#define TEMP_BOT 0
#define TEMP_LEFT 0
#define TEMP_UP 200
#define TEMP_RIGHT 200
#define TEMP_BEGIN 20
#define ANIMATION_FRAME_DELAY 10
#define TIME 21
#define ALFA1 1
#define ALFA2 1
#define EPS 0.001
float delta;
floa... |
16,943 | # include <stdio.h>
__device__ float doTheCalculation(float f) {
return f * f * f;
}
__global__ void cube(float *d_in, float *d_out) {
int idx = threadIdx.x + blockIdx.x * blockDim.x;
float f = d_in[idx];
//d_out[idx] = f * f *f;
d_out[idx] = doTheCalculation(f);
}
int main() {
const int ARRA... |
16,944 | // fermi
/*
* Copyright 2018 Vrije Universiteit Amsterdam, The Netherlands
*
* 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
* Unles... |
16,945 | // Accessing Dimensions
#include <stdio.h>
#include <cuda.h>
__global__ void dkernel()
{
if(threadIdx.x == 0 && blockIdx.x == 0
&& threadIdx.y == 0 && blockIdx.y == 0
&& threadIdx.z == 0 && blockIdx.z == 0)
printf("%d %d %d %d %d %d\n", gridDim.x, gridDim.y, gridDim.z,
... |
16,946 | #include <iostream>
#include <string>
#include <cmath>
#include <chrono>
#include <cuda.h>
#define PI 3.1415926535897932f
const size_t nThreadsPerBlock = 256;
static void HandleError(cudaError_t err, const char *file, int line )
{
if (err != cudaSuccess) {
printf( "%s in %s at line %d\n", cudaGetErrorStrin... |
16,947 | #include "includes.h"
__global__ void reduce(int *in, int *out, int N) {
int sum = 0;
for (int i = blockIdx.x * blockDim.x + threadIdx.x;
i < N;
i += blockDim.x * gridDim.x) {
sum += in[i];
}
//sum = warpReduceSum(sum);
//if (threadIdx.x & (warpSize - 1) == 0) atomicAdd(out, sum);
} |
16,948 |
/* 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,int var_5,float var_6,float var_7,float var_8,float var_9,float var_10) {
if (comp == (+1.1633E-35f / ceilf(var_3 / +1.3... |
16,949 | #include <cmath>
__global__ void mylog2(double* value)
{
value[threadIdx.x] = std::log2(value[threadIdx.x]);
}
|
16,950 | #include "includes.h"
__global__ void helper(float * output, float * blocksum, int len) {
int i = blockIdx.x*blockDim.x + threadIdx.x;
if (i < len){
for (int j=0; j<i/blockDim.x; j++)
output[i] += blocksum[j];
}
} |
16,951 | #include <cmath>
#include <cstdlib>
#include <cstdio>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include "ImmersedBoundary.cuh"
#define PI 3.14159
//__device__ const double RHO_0 = 1.;
//__device__ const double C_S = 0.57735;
__device__ const double c_l[9 * 2] = //VELOCITY COMPONENTS
{
0.,0. ... |
16,952 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define SIZE 1024*1024
#define nTHREAD 512
__global__ void min(float *input, float *out) {
__shared__ float sData[nTHREAD];
int tid = threadIdx.x;
int iter = tid + blockIdx.x*blockDim.x;
sData[tid] = input[iter];
__syncthreads();
for(int s = blockDim.x/2;... |
16,953 | #include<iostream>
#include<chrono>
#include<memory>
#include<string>
#include<cuda_runtime.h>
class TimeIt{
private:
std::chrono::time_point<std::chrono::system_clock> start_time;
public:
TimeIt();
~TimeIt();
};
TimeIt::TimeIt() {
this->start_time = std::chrono::system_clock::now();
}
TimeIt::~Tim... |
16,954 | #include "includes.h"
__global__ void copy_kernel(size_t sz, float_t* src, float_t* dest)
{
size_t index = blockDim.x * blockIdx.x + threadIdx.x;
if(index < sz)
{
dest[index]=src[index];
}
} |
16,955 | #include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <sys/time.h>
typedef int32_t Int;
#define NUM_BYTES(n) ((n) * (sizeof(Int)))
__global__ void compressedRow(Int* matrix, Int* rowIndex, Int* nums, Int* cols, Int* rows, Int width) {
Int* row = ((matrix + (bl... |
16,956 | #include "includes.h"
__global__ void cudaSTargetBiasPropagate_kernel( unsigned int size, const float bias, const float* inputs, const float* diffInputs, float* outputs)
{
const unsigned int index = blockIdx.x * blockDim.x + threadIdx.x;
const unsigned int stride = blockDim.x * gridDim.x;
for (unsigned int i = index; ... |
16,957 | #include <math.h>
#include <float.h>
#include <cuda.h>
__global__ void gpu_Heat (float *h, float *g, float *residual,int N) {
int i = (blockIdx.x * blockDim.x) + threadIdx.x + 1;
int j = (blockIdx.y * blockDim.y) + threadIdx.y + 1;
if( i < N-1 && j < N-1) {
int pos = (i*N)+j;
g[pos]= 0.25 * (h[pos-1] + h[pos+1... |
16,958 | #include <iostream>
using namespace std;
#include <thrust/device_vector.h>
#include <thrust/sequence.h>
int main(int argc, char* argv[])
{
int nGPU;
if(argc < 2) {
cerr << "Use: number of integers" << endl;
return(1);
}
cudaGetDeviceCount(&nGPU);
int n = atoi(argv[1]);
int size = nGPU * n * siz... |
16,959 | #include <iostream>
#include <chrono>
#define BLOCK_SIZE 1024
#define NUM_OF_BANKS 32
#define LOG_NUM_OF_BANKS 5
#define SHIFT_BANK(n) \
(n + (n >> LOG_NUM_OF_BANKS))
__global__ void prefix_sum(float *in, float *out, float* aux, int noc, int res) {
__shared__ float temp[2*BLOCK_SIZE];
int n = BLOCK_SIZE*... |
16,960 | //**********************************************************************
// *
// University Of North Carolina Charlotte *
// *
//Program: Vecotr adder ... |
16,961 | /*
============================================================================
Name : Esercizio3.cu
Author :
Version :
Copyright : Your copyright notice
Description : CUDA compute reciprocals
============================================================================
*/
#include <stdio.h>
... |
16,962 | #include <stddef.h> // NULL, size_t
#include <math.h> // expf
#include <stdio.h> // printf
#include <time.h> // time
#include <sys/time.h> // gettimeofday
#include <assert.h>
#include <curand.h>
#include <cuda.h>
#include <curand_kernel.h>
//#include "cutil.h" // CUDA_SAFE_CALL, CUT_CHECK_ERROR
#include <iostream... |
16,963 | #include <stdio.h>
#include <stdlib.h>
__global__ void testKernel(int param){
printf("%d, %d\n", threadIdx.x, param);
}
int main(void){
// initialize cuPrintf
int N = 3;
int a = 456;
dim3 threadsPerBlock(N, N);
printf("init\n");
testKernel<<<1,threadsPerBlock>>>(a);
return 0;
}
|
16,964 | #include "includes.h"
__global__ void end_coloring_mark() {} |
16,965 | #include <cuda.h>
#include <stdio.h>
#include <math.h>
__global__ void vectorAdd(int *d_a, int *d_b, int *d_c, int n) {
int i = threadIdx.x + blockIdx.x * blockDim.x;
int b = blockIdx.x ;
if (i >= n) {
return;
}
d_c[i] = d_a[i] + d_b[i];
/*for (int i = 0; i < n; i++) {
d_c[i] = d_a[i] + d_b[i];
printf("C... |
16,966 | #include <stdio.h>
#include <assert.h>
#include <cuda.h>
#include <cuda_runtime_api.h>
extern "C" {
__device__ size_t getIndex(const size_t x,const size_t y,const size_t n) {
size_t k = ( n * ( n - 1 ) / 2 ) - ( ( n - x ) * ( n - x - 1 ) / 2 ) + y - x - 1;
return k;
}
__device__ void getPos(const size_t k,const... |
16,967 | extern "C"
{
__global__ void vAoverBupdate(const int lengthA, const double alpha, const double *gradc, const double *a, const double *b, double *gradn)
{
int i = threadIdx.x + blockIdx.x * blockDim.x;
if (i<lengthA)
{
gradn[i] -= alpha*gradc[i]*a[i] / (b[i]* b[i]);
}
}
} |
16,968 | #include "includes.h"
__global__ void initPayoff_k(float* payoff, float dx, float Smin, float strike, size_t P1, size_t P2) {
size_t spot_idx = threadIdx.x;
size_t state_idx = blockIdx.x;
float spot = Smin * expf(spot_idx * dx);
size_t idx = spot_idx + state_idx * blockDim.x;
// !! state grid value is equal to state ... |
16,969 | #include "includes.h"
__global__ void cudaComputeAndNormalizeGradientLength(unsigned char *channel_values, int* x_gradient, int* y_gradient, int chunk_size_per_thread) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
for (int i = index * chunk_size_per_thread; i < (index + 1) * chunk_size_per_thread; i++) {
int gra... |
16,970 | /*
*
* Allocating less memory in GPU than required
* Matrix multiplication
* Vector_addition:unspecified launch failure
* Matrix multiplication:invalid argument while copying
*
*/
#include <cuda.h>
#include <cuda_runtime.h>
#include <stdio.h>
#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inl... |
16,971 | #include <cuda.h>
#include <iostream>
#include <sys/time.h>
#include <stdio.h>
using namespace std;
/* Overlapping data transfers and kernel execution
* - pinned memory
* - streams
* - different strategies depending on concurrent data transfers enabled or not
*/
#define TILE_DIM 16
#define BLOCK_ROWS 16
__g... |
16,972 | #include <stdio.h>
#include <stdlib.h>
// Variables
float* h_A; // host vectors
float* h_C;
float* d_A; // device vectors
float* d_C;
// Functions
void RandomInit(float*, int);
__global__ void FindMax(const float*, float*, int);
// Host Code
int main(){
// Settings
// gid -> GPU device id (0, 1, ...)
// err ... |
16,973 |
#include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
static void HandleError( cudaError_t err, const char *file, int line ) {
if (err != cudaSuccess) {
printf( "%s in %s at line %d\n", cudaGetErrorString( err ), file, line );
exit( EXIT_FAILURE );
}
}
#define HANDLE_ERROR( err ) (... |
16,974 | /********************************************************************************
* Trabalho 2: Programação Paralela para Processador Many-core (GPU) Usando CUDA
* Professora: Nahri Moreano
* Aluno: Ian Haranaka | RGA: 2018.1904.009-7
* Comando de compilação: nvcc dist_par.cu -o dist_par
**************************... |
16,975 | #include "includes.h"
const int Nthreads = 1024, maxFR = 100000, NrankMax = 3, nmaxiter = 500, NchanMax = 32;
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////... |
16,976 | #include <stdio.h>
#include <stdlib.h>
//#define N 16384
__global__ void addVecGrande(int *a, int *b, int *c, int N)
{
int tid=threadIdx.x+blockIdx.x*blockDim.x;
if(tid<N)
{
c[tid]=a[tid]+b[tid];
}
}
int main (void)
{
int *dev_a, *dev_b, *dev_c,*a,*b,*c;
int N,num_blocs,num_hilos,div;
printf("Ingres... |
16,977 | #include "includes.h"
// filename: eeTanh.cu
// a simple CUDA kernel to square the elements of a matrix
extern "C" // ensure function name to be exactly "eeTanh"
{
}
__global__ void tanhActivation(int N, int M, float *z)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
int j = blockIdx.y * b... |
16,978 | #include "includes.h"
__global__ void AddIntsCUDA(int *a, int *b) //Kernel Definition
{
*a = *a + *b;
} |
16,979 | #include "includes.h"
__global__ void adaptivemaxgradinput(float *gradInput, float *gradOutput, float *indices_x, float *indices_y, int input_n, int input_h, int input_w, int output_h, int output_w)
{
// iterators
int xx, yy;
// compute offsets based on thread/block ID
int o = blockIdx.x;
int i = o;
//int k = blockIdx... |
16,980 | #include <stdio.h>
#define cudaCheckErrors(msg) \
do { \
cudaError_t __err = cudaGetLastError(); \
if (__err != cudaSuccess) { \
fprintf(stderr, "Fatal error: %s (%s at %s:%d)\n", \
msg, cudaGetErrorString(__err), \
__FILE__, __LINE__); \
fprintf(stderr, "*** FAILED - ABORTING\n"); \
exit(1); \... |
16,981 | #include "includes.h"
__global__ void FillOnes(float* vec, int value)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if(idx > value) return ;
vec[idx] = 1.0f;
} |
16,982 | /* matrixadd.cu
*
*
* Jonathan Lehman
* February 12, 2012
*
* Homework Assignment 3
*
* This program uses a CUDA capable GPU to add two randomly generated matrices in parallel. The matrix dimensions
* are specified by the user as an argument, as are the grid and block dimensions to be used on the GPU.
* Thi... |
16,983 | #include <iostream>
#include <fstream>
#include <chrono>
#include <sstream>
#include <string>
#include <ctime>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include<algorithm>
#include <vector>
#define d 0.85
#define epsilon 0.00000001
#include <time.h>
using namespace std;
using namespace std::chron... |
16,984 | /**
* block loading rho calculation. should be much faster
* system('nvcc -ptx citydist_rho4.cu')
* iA is multiple of chunk (16)
*/
#include <cuda_runtime.h>
// #include "cublas_v2.h"
#include <math.h>
#define ABS(my_val) ((my_val) < 0) ? (-1*(my_val)) : (my_val)
#define MIN(A,B) ((A)<(B)) ? (A) : (B)
#define MAX(A... |
16,985 | #include "includes.h"
__global__ void gpuSmMM( float *Ad , float *Bd , float *Cd , int dimention )
{
//Taking shared array to break the MAtrix in Tile widht and fatch them in that array per ele
__shared__ float Ads [tilewidth][tilewidth] ;
__shared__ float Bds [tilewidth][tilewidth] ;
// calculate thread id
unsigned i... |
16,986 | /*
The program takes an array as input, multiply the elements with 2 and stores the output in another array.
For the array size less than 4000, CPU runs faster than GPU and then GPU takes over CPU's performance.
*/
#include <iostream>
#include <stdio.h>
#include <cuda.h>
#include <sys/time.h>
__global__ void vecMul... |
16,987 | #include <cassert>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <iostream>
#include <limits>
#include <random>
#include <vector>
#include <cuda_runtime_api.h>
#include <cuda.h>
/* Define the kernel function: */
__global__ void add_vec_kernel(
double const* __restrict__ x, do... |
16,988 | /*
* a simple test
*/
__shared__ float data1[32][32];
__shared__ float data2[32][32];
__shared__ float data3[32][32];
__device__ void mult(__shared__ float d1[32][32],
__shared__ float d2[32][32],
__shared__ float d3[32][32],
int idx)
{
int i;
for ... |
16,989 | #include <cuda.h>
#include <stdio.h>
__host__ __device__ void fun(int *counter) {
++*counter;
}
__global__ void printk(int *counter) {
fun(counter);
printf("printk (after fun): %d\n", *counter);
}
int main() {
int *counter;
cudaHostAlloc(&counter, sizeof(int), 0);
//cudaMalloc(&counter, sizeof(int));
*counter... |
16,990 | #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <curand.h>
#include <string>
#define N 9
#define n 3
#define cudaCheckError() { \
cudaError_t error = cudaGetLastError(); \
if(error !... |
16,991 | #include "includes.h"
#define N 128
__global__ void calc_freq(int *freq, int file_size, char *buffer, int total_threads){
int temp[N];
int idx = blockIdx.x * blockDim.x + threadIdx.x;
// Initialize temp with value 0
for (int i = 0; i < N; i++){
temp[i] = 0;
}
// Do the calculation
for(int i = idx; i < file_size; i... |
16,992 | /**
* 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 use, reproduction, disclosure, or distribution of
* this software and relate... |
16,993 | #include "includes.h"
__global__ void apply_grad(float *output, float *grad, const int N)
{
const int pos = blockIdx.x * blockDim.x + threadIdx.x;
const int size = blockDim.x * gridDim.x;
for (int idx = N * pos / size; idx < N * (pos+1) / size; ++idx) {
output[idx] += dt * grad[idx];
}
} |
16,994 | #include "includes.h"
__global__ void calculation( char *a, char *b, int *c, int constant, int vector_size ) {
int tid = (blockIdx.x*blockDim.x) + threadIdx.x; // this thread handles the data at its thread id
__shared__ char sharedDataA[block_size+2]; // border for the block are needed
char curr_b;
// Populate... |
16,995 | #include <cuda_runtime.h>
#include <stdio.h>
constexpr int numThreadsPerBlock = 1024;
__global__ void reduce0(int *input, int *output) {
__shared__ int sdata[numThreadsPerBlock];
int tid = threadIdx.x;
int i = blockIdx.x * blockDim.x + threadIdx.x;
sdata[tid] = input[i];
__syncthreads();
f... |
16,996 | /****************************************************************************
*
* cuda-dot.cu - Dot product with CUDA
*
* Written in 2017 by Moreno Marzolla <moreno.marzolla(at)unibo.it>
*
* To the extent possible under law, the author(s) have dedicated all
* copyright and related and neighboring rights to this... |
16,997 | //
// Created by songzeceng on 2020/11/16.
//
#include "cuda_runtime.h"
#include "stdio.h"
__device__ int myAtomicAdd(int *address, int increment) {
int expected = *address;
int oldValue = atomicCAS(address, expected, expected + increment);
// if value changed after *address and before atomicCAS, the oldV... |
16,998 | #include <vector>
#include <limits>
#include <iostream>
using namespace std;
typedef pair<int, int> PInt;
typedef vector<int> VInt;
typedef vector<VInt> VVInt;
typedef vector<PInt> VPInt;
const int inf = numeric_limits<int>::max();
VPInt hungarian(const VVInt &matrix) {
int height = matrix.size(), width =... |
16,999 | #include "kernels.hh"
#include "conv2d.hh"
#include "matmul.hh"
#include "sigmoid.hh"
#include "softmax.hh"
#include "relu.hh"
#include "sum.hh"
#include "update.hh"
namespace gpu
{
/**
* blockDim: number of threads in a block
* gridDim: number of blocks in a grid
* blockIdx: current block index i... |
17,000 | #include <stdio.h>
#define NDIM 2
template <int8_t kNdim>
class IndexIterator {
public:
__host__ __device__ void Set(int64_t i) {
int8_t j = kNdim;
for (; --j >= 1;) {
index_[j] = i % shape_[j];
i /= shape_[j];
}
index_[j] = i % shape_[j];
}
__host_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.