serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
21,601 |
#include "filter.cuh"
//////////////////////////////////////////////////////////////
// constructors
/////////////////////////////////////////////////////////////
Filter::Filter( const float mu[], const float sigma[], const float worldPoints[] )
{
// allocate memory on GPU
cudaMalloc( &d_states1, N_PAR... |
21,602 | #include "includes.h"
#define KERNEL_RADIUS 31
#define KERNEL_LENGTH (2 * KERNEL_RADIUS + 1)
__constant__ float c_Kernel[ KERNEL_LENGTH ];
__global__ void convolutionX_63_Kernel( float *d_Dst, float *d_Src, int imageW, int imageH, int imageD, int outofbounds, float outofboundsvalue )
{
__shared__ float s_Data[ROWS_B... |
21,603 | /*
* Alexandre Maros - 2016
*
* Cuda Matrix Multiplication with Shared Memory.
*
* nvcc cuda_matrix_shared.cu -o cs.o
*
* Implemented by Alexandre Maros for learning purposes.
* A version of this code using Global Memory is in here:
* https://github.com/alepmaros/cuda_matrix_multiplication
*
* Distributed un... |
21,604 | /* Kernel for vector squaring */
__global__ void threechannel(float in[], int red[], int green[], int blue[], int ret[], int num)
{
ret[threadIdx.x] = in[threadIdx.x];
}
|
21,605 | #include <stdio.h>
#define N 32
template<int T>
__global__ void reduce(const int *in, float *out_stud, float *out_que) {
__shared__ int tile[T * (T + 1)];
int x4 = blockIdx.x*(T/4) + threadIdx.x;
int y = blockIdx.y* T + threadIdx.y;
int width = gridDim.x*(T/4);
int4 val = reinterpret_cast<co... |
21,606 | #include <stdio.h>
#include <stdlib.h>
const int threadsPerBlock = 4;
// Square matrix multiplication with dimention that has power of 8
__global__ void kernel(float *a, float *b, float *c, int i, int n){
// // const int shared_size = n;
__shared__ float cache[threadsPerBlock];
int k = threadIdx.x;
int j ... |
21,607 | #include <stdio.h>
#include <cuda.h>
#include <math.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#define BLOCK_DIM 1024
#define SEED 26
__global__ void data(double *a, double *b, double *c, int count) {
int t_id = blockDim.x * blockIdx.x + threadIdx.x;
if (t_id < count)
c[t_id] = a[t_... |
21,608 | #include "includes.h"
__global__ void ComputeL2Distance(float *corrData, int numPts1) {
// Get the global point index, not the local index within our 16x16 chunk
const int p1 = blockIdx.x * 16 + threadIdx.x;
const int p2 = blockIdx.y * 16 + threadIdx.y;
// Make sure p1 and p2 are both within bounds
if (p1 < numPts1) {... |
21,609 | #include <stdio.h>
#include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <stdlib.h>
// qsub -I -q coc-ice -l nodes=1:ppn=1:nvidiagpu,walltime=2:00:00,pmem=2gb
// qsub -I -q coc-ice -l nodes=1:ppn=1:nvidiagpu:teslap100,walltime=2:00:00,pmem=2gb
// ss... |
21,610 | #include "includes.h"
__global__ void kernelGetOmega(const int N, double *omega, double *kSqr, const double sigma2, const double sigma4, const double lambda, const double g)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < N)
{
omega[i] = sqrt(1 + kSqr[i] + 3 * lambda * sigma2 + 15 * g * sigma4);
}
} |
21,611 |
/*******************************
1 - Install nvidia-cuda-toolkit
2 - Compile this program using:
nvcc add.cu -o add_cuda.out
*******************************/
/*
Program that runs block size dynamically. As the number of threads increase,
the number of blocks is determined as a function of threads and input siz... |
21,612 | /*
Copyright 2018 - The OPRECOMP Project Consortium, Alma Mater Studiorum
Università di Bologna. All rights reserved.
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
htt... |
21,613 | /*
* madd_gpu.cu -- Device code for matrix additon benchmark
*
* Michael McThrow
*/
#define get_element_index(i, j, cols) ((i) * (cols) + (j))
__global__ void madd_kernel(unsigned int *a, unsigned int *b, unsigned int *c,
unsigned int rows, unsigned int cols)
{
int row = blockIdx.y * blockDim.y + threadIdx.y;
... |
21,614 | // See CUDA BY EXAMPLE for a basic gpu info display thing :)
|
21,615 | #include "includes.h"
__global__ void createRaysOrthoKernel(float4* rays, int width, int height, float x0, float y0, float z, float dx, float dy, unsigned rayMask )
{
int rayx = threadIdx.x + blockIdx.x*blockDim.x;
int rayy = threadIdx.y + blockIdx.y*blockDim.y;
if( rayx >= width || rayy >= height )
return;
float tMin... |
21,616 | #include "includes.h"
__global__ void cunn_LookupTable_accGradParametersKernel( float *input, float *indices, float *gradOutput, float *gradWeight, float *count, float defaultScale, long numel, long stride) {
int idx = blockIdx.x * 4 + threadIdx.y;
// Each warp is responsible for an input into the LookupTable.
// If ... |
21,617 | /**************************************************************************
* Unix-like crypt(3) Algorithm for Password Encryption
*
* File : crypt3.c
* Purpose : Provides crypt(3) functionality to ANSI C compilers
* without a need for the crypt library.
* Author : Michael Dipperstein
*... |
21,618 | /* Lab2Matrix.cu
*
* Created on: 29 Feb 2020
* Author: sc01716
*/
#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#define BLOCK_SIZE 16
// Matrices are stored in row-major order
typedef struct {
int width;
int height;
float* elements;
} Matrix;
__global__ void MatrixMultKern(const Matrix A, con... |
21,619 | #include <cstdio>
#include <cstdlib>
#include <vector>
bool check(int*vec, size_t n)
{
bool res = true;
for (size_t k = 0; k < n - 1; k++)
{
res = res & (vec[k] <= vec[k + 1]);
}
printf("%d\n", res);
return res;
}
__global__ void bucketSort(int *key, int *bucket, int *a, int *b, int n, int range)
{
... |
21,620 | #include <iostream>
#include <vector>
#define NUM 512
class Double
{
public:
__device__
float operator()(float val)
{
return 2*val;
}
};
template<typename F>
__global__
void gpu_kernel(float * buf, F func)
{
int idx = threadIdx.x;
buf[idx] = func(buf[idx]);
}
void gpu_run(void)
{
... |
21,621 | /*
* SPDX-FileCopyrightText: Copyright (c) 1993-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* 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 Lic... |
21,622 | #include<bits/stdc++.h>
using namespace std;
bool sortcol( const int* v1,
const int* v2 ) {
/*if(v1[1]>v2[1]){
printf("Pakda gaya\n");
}*/
return v1[1] < v2[1];
}
void my_custom_sort(int * &input1,int size){
int **list1;
list1=new int*[size];
for(in... |
21,623 |
#include<stdio.h>
#include <cuda.h>
void random_ints(int* a, int N)
{
int i;
for (i = 0; i < N; ++i)
a[i] = rand()%20000;
}
void add_array(int* a, int N)
{
for (int i = 0; i < N; ++i)
a[i] =i;
}
__global__ void binary_search(int* a, int* b, bool* c, int sizeofa) //kernal function
{
int index = blockIdx.x ... |
21,624 | #include <iostream>
#include <cuda_runtime.h>
#define DATA_SIZE 1048576
#define THREAD_NUM 256
#define BLOCK_NUM 32
bool initCUDA()
{
int count;
cudaGetDeviceCount(&count);
if(count == 0){
std::cout<<"There is no device."<<std::endl;
return false;
}
int i;
for(i=0;i<count;i++)... |
21,625 | /**************************************
***************************************
* Code Can be compiled using --> nvcc kernel5.cu -lcurand if the cuRand lib is the envirement PATH
* else use nvcc kernel5.cu -L</path/to/the/lib> -lcurand
***************************************
**************************************/
#... |
21,626 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
__global__ void unique_gid_calculation_2d_2d(int *data) {
int tid = blockDim.x * threadIdx.y + threadIdx.x;
int num_threads_in_a_block = blockDim.x * blockDim.y;
int block_offset = blockIdx.x * num_threads_in_a_block;
int num_... |
21,627 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include<time.h>
#include <stdio.h>
#include <stdlib.h>
#define max(a,b) (((a)>(b))?(a):(b))
//Costos de la funcion SW
#define indel -1
#define match 2
#define mismatch -1
#define TILE_WIDTH 8
#define NUM_THREADS 32
const int arraySize = 65536;
#define... |
21,628 | // Exemplo para o curso de Super Computacao
// Criado por: Luciano P. Soares (10 de Abril de 2018)
#include <stdio.h>
#include <stdlib.h>
//#include <cuda.h>
//#include <cuda_runtime.h>
/* Informacoes da GPU */
int main() {
int dev_count;
cudaGetDeviceCount(&dev_count);
printf("Numero de devices (GPU) = %d... |
21,629 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <time.h>
#include <iostream>
#include <iomanip>
#include <stdio.h>
using namespace std;
struct Node{
int key;
int nextIdx;
int nextLevel;
};
__global__ void assign(Node *sl, Node *data)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
int ... |
21,630 | #include <iostream>
#include <cstdlib>
__global__ void func(int* a) {
const auto tid = threadIdx.x + blockIdx.x * blockDim.x;
a[tid] = tid;
}
void check(const int* a,
const int size) {
for (int i = 0; i < size; i++) {
if (a[i] != i) {
std::cerr << "Error occurs (a[i] != i) at " << __FILE__ ... |
21,631 | //nvcc -o lab5_31 lab5_31.cu
/*Author:Pedro Silva*/
/*3. Implemente um programa em CUDA que devolva a transposta de uma matriz
Teste para vários tamanhos da matriz.*/ |
21,632 | #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 absErr(int N, int M, float *A, float *Y)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
int j = blockIdx.y * b... |
21,633 | #include "includes.h"
#define K 3
#define BLCH 8
#define BLCW 32
__global__ void compute_gpu(float *img, float *f, float * out, int bh, int bw, int imgH, int imgW, int imgN, int nF, int convH, int convW){
int idY = blockDim.y * blockIdx.y + threadIdx.y;
int idX = blockDim.x * blockIdx.x + threadIdx.x;
int inm1, inm2,... |
21,634 | #include "includes.h"
__global__ void FpropH(float* layer1, const float* synH, const int offset)
{
int i = blockDim.x*blockIdx.x + threadIdx.x; //256
int j = blockDim.y*blockIdx.y + threadIdx.y; //256
atomicAdd(&layer1[256*offset + j], layer1[256*(offset-1) + i] * synH[i*256 + j]);
//__syncthreads();
//if (i == 0)
// ... |
21,635 | // IFF-6/11 Nerijus Dulke L4a
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;
// masyvu skaicius
const int N = 4;
// automobiliu skaicius masyve
const int K = 10;
// maksimalus pavadini... |
21,636 | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<sys/time.h>
double rtclock(void)
{
struct timezone Tzp;
struct timeval Tp;
int stat;
stat = gettimeofday (&Tp, &Tzp);
if (stat != 0) printf("Error return from gettimeofday: %d",stat);
return(Tp.tv_sec + Tp.tv_usec*1.0e-6);
}
//=============... |
21,637 | #include<stdio.h>
#include<iostream>
extern "C" {
__global__ void GPU_add(
int n,
int* d_a,
int* d_b
);
void calling_routine_c (
int n,
int* d_a,
int* d_b
)
{
//printf("cuda c stream = %lld\n",streamid);
// Call the cuda kernel:
GPU_add<<... |
21,638 | #include "includes.h"
__global__ void matrixMulGPU( int * a, int * b, int * c )
{
int val = 0;
int row = blockIdx.x * blockDim.x + threadIdx.x;
int col = blockIdx.y * blockDim.y + threadIdx.y;
if (row < N && col < N)
{
for ( int k = 0; k < N; ++k )
val += a[row * N + k] * b[k * N + col];
c[row * N + col] = val;
}
} |
21,639 | /*
* SumSquares.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.
... |
21,640 | #include "cuda.h" // Unix系统下调用CUDA使用"cuda.h",Win系统下调用CUDA使用"cuda.runtime"
#include "stdio.h" // 标准输入输出,后面调用函数printf
#define N 10000
__global__ void vectorAdd(float *A, float *B, float *C)
{
int j = blockIdx.x * blockDim.x + threadIdx.x;
int i = blockIdx.y * blockDim.y + threadIdx.y;
C[i*N+j] = A[i*N+j] + B[i*N... |
21,641 | //thrust
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/sort.h>
#include <thrust/functional.h>
extern "C"
void cuda_HistogramOrder(unsigned int* _histogramData, unsigned int* _reference, unsigned int* _order, unsigned int _size)
{
unsigned int* d_histogramData_ptr;
unsigned int* d... |
21,642 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
//Definicion del kernel
__global__ void gpuMatmult(int* m1, int* m2, int* ans, int n){
int k, sum = 0;
int i = blockIdx.x * blockDim.x + threadIdx.x;
int j = blockIdx.y * blockDim.y + threadIdx.y;
if (i < n && j < n) {
for (k = 0; k < n; k++) {
... |
21,643 | /* declare a 1d array and copy it to each block
each thread find the maximum of the 1d array. This will be replaced by the inner loop in HW
use reduce sum up the mymaximum found by each thread
finally each block return a sum of maximum.
parallel_max_each_chunk<<<dimGrid,dimBlock,(n+numthreadsBlock)*size... |
21,644 | #include <stdio.h>
#define BLOCK_SIZE 256
__global__ void calculateNext(double* oldCylinder, double* newCylinder, const unsigned long long int numSlices) {
int i = blockIdx.x * BLOCK_SIZE + threadIdx.x;
if (i < numSlices) {
if (i == 0) {
newCylinder[i] = (oldCylinder[i] + oldCylinder[i + ... |
21,645 | #include <iostream>
#include <fstream>
#include <string.h>
#include <sys/time.h>
#include <stdlib.h> /* srand, rand */
#include <time.h> /* time */
using namespace std;
//Poner esto a 1 para imprimir los resultados
double cpuSecond(){
struct timeval tp;
gettimeofday(&tp, NULL);
return((double)tp.tv_se... |
21,646 | /*------------------------------------------------------------------------------
# File Name : matrix_multiply_double.cu
#
# Author : Ki-Hwan Kim (wbkifun@korea.ac.kr)
#
# Written date : 2010. 8. 17
# Modify date :
#
# Copyright : GNU GPL
#
# Description :
# CUDA example
# Matrix Multiplication C=AxB
# This cuda k... |
21,647 | /*
Name: Daniyal Manair
Student Number: 20064993
*/
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <vector>
#include <stdio.h>
#include <random>
#include <algorithm>
#include <chrono>
#include <map>
__global__ void MatrixMulGPU(float* A, float* B, float* C, const int N) {
unsigned int col... |
21,648 | #include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
#include <fstream>
#include <math.h>
#include <unistd.h>
#include <stdlib.h>
#include <string>
#include <stdio.h>
#include <cmath>
#include<sys/stat.h>
#include<ctime>
#include <cuda_runtime.h>
#include<thrust/reduce.h>
#include<cuda_runti... |
21,649 | #include "people_allocation.cuh"
#include <assert.h>
#include <algorithm>
#define NUM_CELLS 1024 // 1回に扱うセルの数
__device__
float dot(float* preference, float* feature, int numComponents) {
float ret = 0.0;
for (int i = 0; i < numComponents; ++i) {
ret += preference[i] * feature[i];
}
return ret;
}
/**
* GPUカー... |
21,650 | // 系统头文件
#include <stdlib.h>
#include <stdio.h>
// cuda头文件
#include <cuda_runtime.h>
#include "device_launch_parameters.h"
#define N 10
#define GRID_SIZE 32
#define BLOCK_SIZE 16
__global__ void matrixMultiplication(float *a, float *b, float *c, int width) {
int tx = threadIdx.x;
int ty = threadIdx.y;
f... |
21,651 | #include<iostream>
using namespace std;
__global__ void hello() {
printf("Hello world from device\n");
}
int main() {
hello<<<1, 1>>>();
cout << "Hello world from host" << endl;
cudaDeviceSynchronize();
return 0;
}
|
21,652 | #include <cuda.h>
#include <math.h>
__global__ void extf( double *out, double *img1, double *img2, double *grad, int rows, int columns )
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
int j = blockIdx.y * blockDim.y + threadIdx.y;
// if (i >= columns || j >= rows)
// return;
out[i + j * columns] = 2 * (img1... |
21,653 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <iostream>
using namespace std;
//host
extern float *Hy, coe_Hy, dt, dz;
extern int size_space, size_Hy;
const float PI = 3.141592653589793f;
const float mu = (4 * PI)*1e-7f;
//device
extern float *dev_Hy, *dev_Ex;
void Hy_init_malloc(int );
v... |
21,654 | #include "includes.h"
__global__ void tanh_f32 (float* vector, float* output, int len) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < len) {
float tmp = vector[idx]; output[idx] = tmp / (1.0 + (tmp < 0.0 ? -tmp : tmp));
}
} |
21,655 | #include "includes.h"
__global__ void cheby_calc_u( const int x_inner, const int y_inner, const int halo_depth, const double* p, double* u)
{
const int gid = threadIdx.x+blockIdx.x*blockDim.x;
if(gid >= x_inner*y_inner) return;
const int x = x_inner + 2*halo_depth;
const int col = gid % x_inner;
const int row = gid / ... |
21,656 | //nvcc -arch=sm_30 -lcufft fft_batched.cu
#include <cuda.h>
#include <cufft.h>
#include <stdio.h>
#include <math.h>
#define DATASIZE 8
#define BATCH 3
#define GRID_DIMENSION 3
#define BLOCK_DIMENSION 3
/********************/
/* CUDA ERROR CHECK */
/********************/
#define gpuErrchk(ans) { gpuAssert((ans),... |
21,657 | #include "includes.h"
__global__ void addInc(unsigned int* deviceInput, unsigned int* deviceOutput, int eleCnt, unsigned int* deviceInc)
{
/*
__shared__ int inc;
if (threadIdx.x == 0)
{
inc = deviceInc[blockIdx.x];
}
__syncthreads();
*/
int inc = deviceInc[blockIdx.x];
int cntInB = blockDim.x * 2;
int idxInG = blockId... |
21,658 | #include "includes.h"
/**
* Programma che simula il comportamento del gpdt per
* la risoluzione di un kernel di una serie di
* valori di dimensione variabile utilizzando la
* tecnologia cuda.
* compilare con:
* nvcc -o simil_gpdt_si_cuda simil_gpdt_si_cuda.cu
* lanciare con:
* ./simil_gpdt_si_cuda [numero vettori] [num... |
21,659 | // kernel to convert from OpenCV channel representation to channel-first
// see: https://docs.opencv.org/2.4/doc/tutorials/core/how_to_scan_images/how_to_scan_images.html#how-the-image-matrix-is-stored-in-the-memory
constexpr size_t BLOCK_SIZE = 1024U;
#include <cuda_runtime.h>
#include <math_constants.h>
#include <ar... |
21,660 | __global__ void exampleDevice(float * d){
int idx = blockIdx.x * blockDim.x + threadIdx.x;
d[idx] = idx;
}
extern "C" void exampleHost(float * h, int blockDim, int threadDim){
float * d;
cudaMalloc((void**)&d, blockDim * threadDim*sizeof(float));
exampleDevice<<<blockDim, threadDim>>>(d);
cudaMemcpy(h, d, block... |
21,661 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#define DEFAULT_ROW 16384
#define DEFAULT_COL 16384
// time stamp function in seconds
double getTimeStamp() {
struct timeval tv ;
gettimeofday( &tv, NULL ) ;
return (double) tv.tv_usec/1000000 + tv.tv_sec ;
}
// host side matrix addition
void h_addmat(fl... |
21,662 | /*
* The Game of Life
*
* a cell is born, if it has exactly three neighbours
* a cell dies of loneliness, if it has less than two neighbours
* a cell dies of overcrowding, if it has more than three neighbours
* a cell survives to the next generation, if it does not die of loneliness
* or overcrowding
*
* In th... |
21,663 |
/* Includes, system */
#include <stdio.h>
#include <cuda.h>
#include <cuda_runtime.h>
/* DEVICE CODE */
__global__ void primer_kernel(){
}
/* HOST CODE*/
int main(int argc, char** argv)
{
int DeviceCount = 0;
/* Initialize CUDA */
if (cuInit(0) != 0){
printf("ERROR de inicializacion\n");
... |
21,664 | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define INF 1073741824
#define BLOCK_SZ 16
// small
#define SMALL_M 1024
#define SMALL_N 256
#define SMALL_K 8
#define SMALL_B 64
// middle
#define MIDDLE_M 4096
#define MIDDLE_N 1024
#define MIDDLE_K 16
#define MIDDLE_B 256
// large
#define LARGE_M 16384
#de... |
21,665 | //
// This code is based on code from:
// https://en.cppreference.com/w/cpp/algorithm/reduce
// and
//
// This code uses a GPU and thrust to perform a reduction
//
#include <iostream>
#include <chrono>
#include <vector>
#include <numeric>
#include <thrust/reduce.h>
#include <thrust/device_vector.h>
#include <thrust/fun... |
21,666 | #include "includes.h"
__global__ void initializeElementsTo(int initialValue, int *a, int N)
{
int i = threadIdx.x + blockIdx.x * blockDim.x;
if (i < N)
{
a[i] = initialValue;
}
} |
21,667 | #include <stdio.h>
__device__ const char *STR = "deNet is ON!\n";
const char STR_LENGTH = 13;
__global__ void deNet()
{
printf("%c\n", STR[threadIdx.x % STR_LENGTH]);
}
int main(void)
{
int num_threads = STR_LENGTH;
int num_blocks = 1;
deNet<<<num_blocks,num_threads>>>();
cudaDeviceSynchronize();... |
21,668 | #include <stdio.h>
#include <assert.h>
#include <iostream>
#define N 2048 * 2048 // Number of elements in each vector
inline cudaError_t checkCuda(cudaError_t result)
{
if (result != cudaSuccess) {
fprintf(stderr, "CUDA Runtime Error: %s\n", cudaGetErrorString(result));
//assert(result == cudaSuccess);
}
... |
21,669 | /* Voxel sampling GPU implementation
* Author Zhaoyu SU
* All Rights Reserved. Sep., 2019.
*/
#include <stdio.h>
#include <iostream>
#include <float.h>
#include <vector>
__device__ inline int get_batch_id(int* accu_list, int batch_size, int id) {
for (int b=0; b<batch_size-1; b++) {
if (id >= accu_list... |
21,670 | #include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <sys/time.h>
#include "cuda_runtime.h"
#include <chrono>
using namespace std;
using namespace std::chrono;
#define Bsize_addition 256
#define Bsize_minimum 128
__global__ void reduceSum( float * d_V, int N ) {
... |
21,671 | #include <stdio.h>
#include <stdlib.h>
/*
* In CUDA it is necessary to define block sizes
* The grid of data that will be worked on is divided into blocks
*/
#define BLOCK_SIZE 512
#define gpuErrchk(ans) \
{ gpuAssert((ans), __FILE__, __LINE__); }
inline vo... |
21,672 | #include <stdio.h>
#include "includes/utils.cuh"
inline int _ConvertSMVer2Cores(int major, int minor);
void AllocateCudaMem(float **pointer, int size) {
cudaError_t err = cudaSuccess;
err = cudaMalloc((void **)pointer, size);
if (err != cudaSuccess) {
fprintf(stderr, "Failed to allocate device memory (err... |
21,673 | #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);
}
int main()
{
// 16! different output
hello <<< NUM_BLOCKS, BLOCK_WIDTH >>> ();
// Wait for th... |
21,674 | const int threadsPerBlock = 256;
extern "C" __global__ void dotProductFloat(const float* A, const float* B, float* C, size_t size)
{
__shared__ float sumBuffer[threadsPerBlock];
int sumBufferIdx = threadIdx.x;
int stride = blockDim.x * gridDim.x;
float strideSum = 0;
for (int cellIdx = blockIdx.x * blockDim.x ... |
21,675 | #include <stdio.h>
#include <cuda.h>
#include <time.h>
#include <stdlib.h>
#include <math.h>
struct point
{
float x;
float y;
};
struct dist
{
float da;
float db;
float dc;
};
float eucli(float fx, float fy)
{
return sqrt(fx * fx + fy * fy);
}
__global__ void trilaterate(struct point a, struct point b, struct... |
21,676 | #include <stdio.h>
#include <cuda_runtime.h>
#include <time.h>
#include <sys/time.h>
void checkResult(float *hostRef, float *gpuRef, const int N){
double epsilon = 1.0E-8;
bool match = 1;
for (int i = 0; i < N; ++i) {
if (abs(hostRef[i] - gpuRef[i]) > epsilon){
match = 0;
pr... |
21,677 | #include <iostream>
#include <cuda.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
#define ARRAY_SIZE 128
#define ARRAY_SIZE_IN_BYTES (sizeof(unsigned int) * (ARRAY_SIZE))
/*定义 const 指针(由于指针本身的值不能改变所以必须得初始化)*/
__global__ void what_is_my_id(unsigned int * const block,
unsigned int * const thread,
u... |
21,678 | __global__ void kern() {
// do nothing
}
int main() {
kern <<< 1, 1 >>> ();
return 0;
} |
21,679 | /*
*
* CUDA Example
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <iostream>
#include <cuda_runtime.h>
using namespace std;
void incrementArrayOnHost(float *a, int N)
{
int i;
for (i=0; i < N; i++) a[i] = a[i]+5.f;
}
__global__ void incrementArrayOnDevice(float *a, int N)
{
int ... |
21,680 | #include "includes.h"
__global__ void inputKernel(float *x, int N)
{
int ix = blockIdx.x * blockDim.x + threadIdx.x;
int iy = blockIdx.y * blockDim.y + threadIdx.y;
int idx = iy * NUM_OF_X_THREADS + ix;
if (idx < N)
x[idx] = x[idx] + (float)idx;
} |
21,681 | #include <iostream>
#include <vector>
#include <cmath>
#include <chrono>
#include <cuda.h>
#include <cuda_runtime.h>
using namespace std;
// #if __CUDA_ARCH__ < 600
// __device__ double atomicAdd(double* address, double val)
// {
// unsigned long long int* address_as_ull =
// (unsign... |
21,682 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include "stdio.h"
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// input: features (n,c), idx (n,3), weight (n,3)
// output: probs (n,c)
__gl... |
21,683 | // Compile: nvcc -o kmeans_gpu kmeans_gpu.cu
#include <math.h>
#include <stdlib.h>
#include <malloc.h>
#include <ctype.h>
#include <sys/time.h>
#include <time.h>
#define BLOCK_SIZE 16
#define GRID_SIZE 256
#define uchar unsigned char
__constant__ int d_k;
__constant__ int d_pixelCount;
__global__ void assignCluste... |
21,684 | #include <stdio.h>
#include <future>
#include <thread>
#include <chrono>
#include <iostream>
#define N 1000000
#define NUM_THREADS_PER_BLOCK 256
#define NUM_BLOCKS_PER_GRID 1024
//#define NUM_BLOCKS_PER_GRID (N + NUM_THREADS_PER_BLOCK-1) / NUM_THREADS_PER_BLOCK;
__constant__ int factor = 0;
__global__
void vectorAd... |
21,685 |
#include <type_traits>
using tt = std::true_type;
using ft = std::false_type;
int __host__ static_cuda11_func(int x)
{
return x * x + std::integral_constant<int, 17>::value;
}
|
21,686 | #include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <cuda_runtime.h>
#include <cuda_runtime_api.h>
#include <curand_kernel.h>
#include <device_functions.h>
const int digest_size = 256;
const int digest_size_bytes = digest_size / 8;
//cudaEvent... |
21,687 | #include<stdio.h>
// Kernel definition
__global__ void VecAdd(float* A, float* B, float* C, int N)
{
int i = blockDim.x*blockIdx.x + threadIdx.x;
if(i<N)
C[i] = A[i] + B[i];
printf("In thread-i, we are using value %f + %f = %f\n", A[i], B[i], C[i]);
}
int main()
{
int N = 1024;
float* h_A, *h_B, *h_C;
size_t ar... |
21,688 | #define TILE_DIM 1024
template<typename T>
__device__ void argmin(const T* vector, int* result, const int length) {
__shared__ T partsVals[TILE_DIM];
__shared__ int partsArgs[TILE_DIM];
int index = threadIdx.x;
int partLength = (length + TILE_DIM - 1) / TILE_DIM;
T min;
int argmin;
if (index < length... |
21,689 | #include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <iostream>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/sort.h>
using namespace std;
int main() {
thrust::host_vector<int> h_vec(24);
thrust::generate(h_vec.begin(), h_vec.end(), rand);
thrust::device_vector<in... |
21,690 | //==============================================================
// Copyright 2019 Intel Corporation
//
// SPDX-License-Identifier: MIT
// =============================================================
#include <stdio.h>
#include <cuda_runtime.h>
extern void run_util();
__global__ void kernel_main(int n) {
print... |
21,691 | /*
**********************************************
* CS314 Principles of Programming Languages *
* Fall 2020 *
**********************************************
*/
#include <stdio.h>
#include <stdlib.h>
__global__ void markFilterEdges_gpu(int * src, int * dst, int * matches, int * ke... |
21,692 | #include <ctime>
#include <iostream>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <cmath>
#include <locale.h>
const int PWD_LENGTH = 4;
const int HASH_LENGTH = 64;
const int NUM_BLOCKS = 64;
const int NUM_THREADS = 256;
const int KERNEL_SIZE = NUM_BLOCKS * NUM_THREADS;
const int CHARACTER_SET = ... |
21,693 | //#include <algorithm>
//#include <cassert>
//#include <cstdlib>
//#include <functional>
//#include <iostream>
//#include <vector>
//#include <cuda_runtime.h>
//#include "device_launch_parameters.h"
//#include <random>
//
//using std::cout;
//using std::generate;
//using std::vector;
//
//using namespace std;
//
//#def... |
21,694 | /* Matrix normalization.
* Compile with "gcc matrixNorm.c"
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include <math.h>
/* Program Parameters */
#define MAXN 10000 /* Matrix size */
int BLOCK_SIZE = 256;
int N=6000;
/* Matrices */
volatile float A[MAXN][MAXN], B[... |
21,695 | __global__ void plotLines(unsigned char* result, int w, int h, int* points, unsigned char blue, unsigned char green, unsigned char read) {
int x = blockDim.x * blockIdx.x + threadIdx.x;
int y = blockDim.y * blockIdx.y + threadIdx.y;
int tid = y * w + x;
int _r = w * h * 0;
int _g = w * h * 1;
int ... |
21,696 | #include <iostream>
#include "cuda_runtime_api.h"
using namespace std;
int main(int argc, char ** argv) {
int count;
cudaGetDeviceCount(&count);
if(count == 0) {
std::cerr << "Could not find a CUDA device";
return 1;
}
if(count != 1) {
std::cerr << "Warning: Expected ex... |
21,697 | #include <stdio.h>
__global__ void add (int a, int b, int *c) {
*c=a+b;
}
int main(int argc, char **argv) {
int c;
int *dev_c;
/* Allocate memory on device */
/* Note, the pointer returned is *not* valid on the host */
/* and dereferencing it will not work */
cudaMalloc( (void **)&dev_c,sizeof(int));
add<<... |
21,698 | #include <stdio.h>
#define N 256
#define T 4
__global__ void vecAdd(int *A){
int i = blockIdx.x * blockDim.x + threadIdx.x;
if(i < N){
A[i] = i;
}
}
int main(int argc, char *argv[]){
int i;
int blocks = N/T;
int size = N*sizeof(int);
int a[N], *devA;
cudaMalloc( (void**) &devA, size);
cudaMem... |
21,699 | #include "includes.h"
using namespace std;
__global__ void matrixMultiplicationKernel(long* A, long* B, long* C, long N) {
long ROW = (blockIdx.y*blockDim.y) + threadIdx.y;
long COL = (blockIdx.x*blockDim.x) + threadIdx.x;
long tmpSum = 0;
if (ROW < N && COL < N) {
// each thread computes one element of the bloc... |
21,700 | #include <iostream>
#include <string>
#include <iomanip>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
// #define imin(a, b) (a<b?a:b)
//定义X,Y,Z各维的长度
const int dimX = 10;
const int dimY = 10;
const int dimZ = 10;
const int SIZE = dimX * dimY * dimZ;
//设置每个线程块中线程数量,此处设置三维一样
const int threadPerBlock... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.