serial_no int64 1 24.2k | cuda_source stringlengths 11 9.01M |
|---|---|
17,201 | #include "includes.h"
__global__ void gpu_matrix_mult_two(int *d_M, int *d_N, int *d_P, int m, int n, int k)
{
// shared memory for tiling
__shared__ int Mds [TILE_WIDTH][TILE_WIDTH];
__shared__ int Nds [TILE_WIDTH][TILE_WIDTH];
int bx = blockIdx.x; int by = blockIdx.y;
int tx = threadIdx.x; int ty = threadIdx.y;
/... |
17,202 | #include "pulses.cuh"
__device__ __host__ Pulse::Pulse(real start, real duration, real strength, Vector3 bDir, Vector3 rDir)
: start(start), duration(duration), strength(strength), bDir(bDir), rDir(rDir){
end = start + duration;
#ifndef __CUDA_ARCH__
printf("Pulse start: %f\nPulse end: %f\n================\n", start... |
17,203 | #include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
__global__ void mem_trs_3d(int *input) {
int tid = threadIdx.z * blockDim.x * blockDim.y + blockDim.x * threadIdx.y +
threadIdx.x;
int num_threads_in_a_block = bl... |
17,204 | //ECGR 6090 Heterogeneous Computing Homework 0
// Problem 2 c - 1D Stencil on GPU with shared memory
//Written by Aneri Sheth - 801085402
// Reference taken from Lecture Slides by Dr. Tabkhi
//Other reference taken from https://github.com/szymonm/pwir-cuda-labs/tree/master/lab1 and https://docs.nvidia.com/cuda/cuda-c... |
17,205 | #include "includes.h"
__global__ void gpu_reduce_kernel (int N, float * vector, float * sum)
{
extern __shared__ float partialSum[];
int tid = threadIdx.x + blockIdx.x*blockDim.x;
partialSum[threadIdx.x] = 0.f;
__syncthreads();
while(tid < N)
{
partialSum[threadIdx.x] += vector[tid];
tid += blockDim.x*gridDim.x;
}... |
17,206 | #include <cstdio>
#include <cstdlib>
#include <vector>
__global__ void bucket_sort(int *key, int* bucket){
atomicAdd(&bucket[key[threadIdx.x]], 1);
__syncthreads();
int buck_val = 0;
for (int i = threadIdx.x; i >= bucket[buck_val]; i-=bucket[buck_val++]);
key[threadIdx.x] = buck_val;
}
int main() {
int n ... |
17,207 | #include <iostream>
__global__
void default_function_kernel0(const float* __restrict__ Data,
const float* __restrict__ K0,
const float* __restrict__ K1,
const float* __restrict__ K2,
const float* __restrict__ K3,
float* __restrict__ Output) {
float Output_local[2];
__shared__ float pad_temp_... |
17,208 | #include <math.h>
#include <stdint.h>
#include <stdio.h>
// src_size x 3 -> 256 x N
__global__ void make_partial_histograms_BGR_kernel(uint8_t *src, int *dst, int src_size) {
int pixel_idx = threadIdx.x + blockIdx.x*blockDim.x;
int t_idx = threadIdx.x;
__shared__ int s[256];
for (int i = 0; t_idx + ... |
17,209 | /******************************************************************************
*cr
*cr (C) Copyright 2010 The Board of Trustees of the
*cr University of Illinois
*cr All Rights Reserved
*cr
*****************************************************************... |
17,210 | #include "includes.h"
__global__ void mul_by_veff_real_real_gpu_kernel(int nr__, double* buf__, double const* veff__)
{
int i = blockDim.x * blockIdx.x + threadIdx.x;
if (i < nr__) {
buf__[i] *= veff__[i];
}
} |
17,211 | // http://www.nvidia.com/docs/io/116711/sc11-cuda-c-basics.pdf
/* C stuff */
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
/* Cuda stuff */
#include <cuda_runtime_api.h>
#include <cuda.h>
#define N (2048*2048)
#define TH_PER_BLOCK 512
__global__ ... |
17,212 | #include "includes.h"
__global__ void cudaKernelTexture2D(unsigned char* surface, int width, int height, size_t pitch, float t)
{
int x = blockIdx.x*blockDim.x + threadIdx.x;
int y = blockIdx.y*blockDim.y + threadIdx.y;
unsigned char* pixel;
// in the case where, due to quantization into grids, we have
// more threads... |
17,213 | //#include "CUDADiffusion.hh"
//#include "DiffusionUtils.hh"
//#include "SymmetricTensor.hh"
//#include <vector>
//#include <map>
//#include "options.h"
//#include "cudautil.h"
#include <stdio.h>
//#include "Ledger.hh"
#define XTILE 20
typedef double Real;
__global__ void diff_6face_v1(const Real* d_psi, Real* d_np... |
17,214 | /*
* Copyright 2018 Foundation for Research and Technology - Hellas
*
* 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 [1] [1]
*
* Unless... |
17,215 | /*------------------------------------------------------------------------------
* File:
* prog2.cu
*
* Purpose:
* Host program and CUDA kernel to multiply a sq... |
17,216 | #include "includes.h"
__global__ void softmax_x_ent_kernel(int n, float *pred, float *truth, float *delta, float *error)
{
int i = (blockIdx.x + blockIdx.y*gridDim.x) * blockDim.x + threadIdx.x;
if (i < n) {
float t = truth[i];
float p = pred[i];
error[i] = (t) ? -log(p) : 0;
delta[i] = t - p;
}
} |
17,217 | #include <iostream>
#include <cstdlib>
#include <cstdio>
#include <fstream>
#include <curand_kernel.h>
#include <thrust/reduce.h>
#include <thrust/functional.h>
#include <thrust/execution_policy.h>
#include <thrust/extrema.h>
#include <thrust/device_ptr.h>
#define bucketLimitDecr 600
#define bucketLimitIncr 1400
us... |
17,218 |
#include <stdio.h>
// CUDA runtime
#include <cuda_runtime.h>
// __global__ 声明 gpu 线程调用
__global__ void sum(int *a, int *b, int *c ){
c[0] = a[0] + b[0];
}
int main(int argc, char **argv)
{
// 声明 Host 变量
int a[1]={1},b[1] ={2},c[1]={0};
// 声明 device 变量
int *gpu_a, *gpu_b, *gpu_c;... |
17,219 | // Add 2 numbers
#include<iostream>
__global__ void numadd(float *d_a, float *d_b, float *d_c){
// int i = blockDim.x * blockIdx.x + threadIdx.x;
*d_c = *d_a + *d_b;
}
int main(){
float h_a, h_b, h_c;
std::cout << "Enter a number" << std::endl;
std::cin >> h_a;
std::cout << "Enter another number" << std::endl;
std... |
17,220 | __global__ void
decompositionKernel(double *deviceMtrx, int mtrxSize, int idx, int maxIndex)
{
//Get thread id
int tid = threadIdx.x + blockIdx.x * blockDim.x;
//Calculate first an last index for thread
while (tid < maxIndex)
{
int startIdx = ((idx + tid + 1) * mtrxSize + idx);
int e... |
17,221 | /**
* 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... |
17,222 | #include <stdio.h>
#include <iostream>
#include <cuda_profiler_api.h>
//#include <cutil.h>
#include <cuda_runtime.h>
float* h_A;
float* h_B;
float* h_C;
float* h_res;
float* d_A;
float* d_B;
float* d_C;
float* d_res;
__global__
//void compute(const float* A, const float* B, const float* C, float* D, int n) {
void com... |
17,223 | #include <stdlib.h>
#include <stdio.h>
#include <malloc.h>
#include <assert.h>
#include <sys/time.h>
#define xMin 0.74395
#define xMax 0.74973
#define yMin 0.11321
#define yMax 0.11899
static void WriteBMP(int x, int y, unsigned char *bmp, const char * name)
{
const unsigned char bmphdr[54] = {66, 77, 255, 255, 255... |
17,224 | /*
* Copyright 1993-2010 NVIDIA Corporation. All rights reserved.
*
* NVIDIA Corporation and its licensors retain all intellectual property and
* proprietary rights in and to this software and related documentation.
* Any use, reproduction, disclosure, or distribution of this software
* and related documentat... |
17,225 | ////////////////////////////////////////////////////////////////////////////
//
// Copyright 1993-2015 NVIDIA Corporation. All rights reserved.
//
// Please refer to the NVIDIA end user license agreement (EULA) associated
// with this source code for terms and conditions that govern your use of
// this software. Any u... |
17,226 | /*
* Name: add_vec.cu
* Description: "Hello World" CUDA program to add two vectors
*/
#include <stdio.h>
//============================= GPU Kernel ====================================
/*
The "__global__" tag tells nvcc that the function will execute on the device
but will be called from the host. Notice that we m... |
17,227 | // ==========================================================================
// $Id$
// ==========================================================================
// (C)opyright: 2009
//
// Ulm University
//
// Creator: Hendrik Lensch, Holger Dammertz
// Email: hendrik.lensch@uni-ulm.de, holger.dammertz@uni-ulm.d... |
17,228 | #include <thrust/sort.h>
#include <thrust/device_ptr.h>
#include <fstream>
using namespace std;
const unsigned long MASK = 0x000000000000FFFF;
struct sort_ulong2 {
__host__ __device__
bool operator()(const ulong2 &a, const ulong2 &b) const {
if ((a.x&MASK) < (b.x&MASK)) return true;
else if ((a.... |
17,229 | // Simple CUDA example by Ingemar Ragnemalm 2009. Simplest possible?
// Assigns every element in an array with its index.
// nvcc simple.cu -L /usr/local/cuda/lib -lcudart -o simple
#include <stdio.h>
#include <math.h>
const int N = 16;
const int blocksize = 16;
__global__ void parallel_sqrt(float *c)
{
c[threa... |
17,230 | /** size of A = 768
size of B = 180
gridDim = 60
blockDim = 256
k= 200000
x = 3
**/
__global__ void CompareAddVectors(const int* A, const int* B, int* C, int x, int k)
{
int size_A = x*blockDim.x;
int B_start_index = (blockIdx.x*gridDim.y + blockIdx.y)*x;
int t,i,j,temp;
__shared__ int c[3][76... |
17,231 | __device__ inline double sq(double x) { return x*x;}
__device__ double optimsquare_eps_2d_descent(double u[12], double xi[12], int sc, double epsilon, double w, int steps) {
double no, nxi[12], r;
r = 1./(1+epsilon/4.);
for (int c = 0; c < 3; c++) {
u[c*4 + 0] -= xi[c*4 + 0]-xi[c*4 + 3];
for (int i=1;i<... |
17,232 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <cuda.h>
/*********************************/
/** constants/define statements **/
/*********************************/
#define THREADS_PER_BLOCK 1024
#define MAX_BLOCKS 65535
#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE... |
17,233 |
#include <cstdio>
#include <math.h>
#include <cuda_runtime.h>
#include "GillespieCuda.cuh"
#define b 10.0f
#define g 1.0f
#define Kon 0.1f
#define Koff 0.9f
/* This kernel performs a single iteration of the gillespie algorithm.
*
* productionStates is an array of 0s and 1s where each value signals whether or
* ... |
17,234 | #include "includes.h"
__global__ void golGpu(int height, int width, unsigned char* pBuffer1, unsigned char* pBuffer2){
int x = blockIdx.x * 2 + threadIdx.x;
int y = blockIdx.y * 2 + threadIdx.y;
int indx = x * height + y;
pBuffer2[indx] = pBuffer1[indx];
int num = 0;
if (x-1 >= 0 && x-1 < height && y >= 0 && y < w... |
17,235 |
// update the velocities
__global__ void update_vel(int npart, float qom, float dx, float dt, float *Epx, float *u){
int tid = threadIdx.x + blockIdx.x * blockDim.x;
while ( tid < npart) {
u[tid] = u[tid] + float(qom)*Epx[tid]*float(dt);
tid += blockDim.x * gridDim.x;
}
}
|
17,236 | #include <iostream>
#include <assert.h>
#include <cuda.h>
#include <math.h>
#define N 100
__global__ void sum(int a[][N], int b[][N], int c[][N]) {
int row_index = blockDim.y * blockIdx.y + threadIdx.y;
int col_index = blockDim.x * blockIdx.x + threadIdx.x;
if (row_index < N && col_index < N) {
c[row_index][col_... |
17,237 | /*
Collatz code for CS 4380 / CS 5351
Copyright (c) 2019 Texas State University. All rights reserved.
Redistribution in source or binary form, with or without modification,
is *not* permitted. Use in source and binary forms, with or without
modification, is only permitted for academic use in CS 4380 or... |
17,238 | /*! @file gpu_info.cpp
*! @brief print gpu info
*/
#include <stdio.h>
#include <cuda.h>
#include <stdlib.h>
void print_device_props_short()
{
const size_t kb = 1024;
const size_t mb = kb * kb;
int devCount;
cudaGetDeviceCount(&devCount);
printf("Found the following GPUs:\n");
for(int i = 0... |
17,239 |
#include "stdio.h"
#define COLUMNS 4
#define ROWS 3
__global__ void add(int * a, int*b) {
int x = threadIdx.x;
int sum = 0;
for(unsigned int i = 0; i < ROWS; i++){
sum += a[i*COLUMNS+x];
}
b[x] = sum;
}
int main() {
int a[ROWS][COLUMNS], b[COLUMNS];
int *dev_a;
int *d... |
17,240 | // Mezclar threads y bloques
#include <stdio.h>
#define N (2048 * 2048)
#define THREADS_PER_BLOCK 512
__global__ void add(int*a, int*b, int*c, int n) {
int index = threadIdx.x + blockIdx.x * blockDim.x;
if(index < n)
c[index] = a[index] + b[index];
}
int main(){
int *a, *b, *c; // Copias de a b y... |
17,241 | #include <cuda.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#define NANO 1000000000
#define PGSIZE 0x1000
#define BLOCK1 1024
#define BLOCK2 32
int size;
float *matrixA, *vectorB, *vectorX;
__global__
void cudaPivot(float *A_d, int *max_pivot, int pivot, int size)... |
17,242 | #include "includes.h"
__global__ void matrix_multiply(float *a, float *b, float *c, int num, size_t width)
{
// create shorthand names for threadIdx & blockIdx
int tx = threadIdx.x, ty = threadIdx.y;
int bx = blockIdx.x, by = blockIdx.y;
// allocate 2D tiles in __shared__ memory
__shared__ float s_a[TILE_WIDTH][TILE_W... |
17,243 |
#include "kernel.cuh"
/*__global__ void PointsMean(double *points, double *means, int rows)
{
int tid = threadIdx.x;
if (tid < 3){
for (int i = 0; i < rows; i++)
{
means[tid] += points[i * 3 + tid];
}
means[tid] /= rows;
}
}
__global__ void PointsDis(double* points,double *means, int rows)
{
int i = t... |
17,244 | __global__ void addSubArray2 (int *A, int *B, int w, int h) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
for (int j = 0; j < h; j += 2) {
B[j * w + i] += A[i];
B[(j + 1) * w + i] -= A[i];
}
} |
17,245 | #include <cstdio>
__global__ void checkIndexKernel()
{
int threadID = threadIdx.x + threadIdx.y * blockDim.x + threadIdx.z * blockDim.x * blockDim.y;
int blockID = blockIdx.x + blockIdx.y * gridDim.x + blockIdx.z * gridDim.x * gridDim.y;
int threadDinGrid = threadID + blockID * blockDim.x * blo... |
17,246 | #include <cuda_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <malloc.h>
#define CHECK(call) \
{ \
const cudaError_t error = call; \
if (error != cudaSuccess) \
{ \
printf("Error: %s:%d, ", __FILE__, __LINE__); \
printf("code:%d, reason: %s\n", error, cudaGet... |
17,247 | /*
* nn.cu
* Nearest Neighbor
*
*/
#include <stdio.h>
#include <sys/time.h>
#include <float.h>
#include <vector>
#include "cuda.h"
#define min( a, b ) a > b ? b : a
#define ceilDiv( a, b ) ( a + b - 1 ) / b
#define print( x ) printf( #x ": %lu\n", (unsigned long) x )
#define DEBUG false
#define DEFAULT_T... |
17,248 | #include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include <curand_kernel.h>
#include <stdlib.h>
#include <cuda.h>
#include <sys/time.h>
#include "aux_fields.cu"
#include<chrono>
#include<iostream>
using namespace std;
using namespace std::chrono;
int blocks_[20][2] = {{8,8},{16,16},{24,24... |
17,249 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
inline void GPUassert(cudaError_t code, char * file, int line, bool Abort=true)
{
if (code != 0) {
fprintf(stderr, "GPUassert: %s %s %d\n", cudaGetErrorString(code),file,line);
if (Abort) exit(code);
}
}
#define GPUerrchk(ans) { G... |
17,250 | // CUDA -First Programs: “Hello, world” is traditionally the first program we write. We can do the same for CUDA. Here it is:
// In file hello.cu:
#include "stdio.h"
int main()
{
printf("Hello, world\n");
return 0;
}
// On your host machine, you can compile and this with:
// $ nvcc hello.cu
// Execution on GPU ... |
17,251 | #include <stdio.h>
#include <stdlib.h>
#define NUMBER 512
__global__ void reduction(int *arr,int num){
int tx=threadIdx.x;
int round=1;
arr[tx]=1;
__syncthreads();
while(round<NUMBER){
if((tx%round==0)&&((tx+round)<NUMBER)){
arr[tx]=arr[tx+round]+arr[tx];
__syncthreads();
}
round=round<<1;
//__sy... |
17,252 | #include <iostream>
using namespace std;
__host__ void checkStatus(cudaError_t status) {
if (status != cudaSuccess) {
printf("%s \n", cudaGetErrorString(status));
return;
}
}
__global__ void fast_add(float* a, float* b, float* res) {
res[threadIdx.x] = a[threadIdx.x] + b[threadIdx.x];
return;
}
int main() ... |
17,253 | #include <iostream>
#include <fstream>
#include <math.h>
#include <time.h>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <string>
#include <map>
#include <stdint.h>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/reduce.h>
using namespace std;
#define BLOCK_SIZE... |
17,254 |
// Babak Poursartip
// 09/14/2020
// Udemy Cuda
// unique index calculation
#include <cstdio>
// ===========================================
// 2d grid, 1d block
__global__ void unique_gid_calculation_2d(int *input) {
int tid = threadIdx.x;
int block_offset = blockIdx.x * blockDim.x;
int row_offset = blockId... |
17,255 | #include <iostream>
__global__ void _sobel_process_kernel_(unsigned char* d_src, unsigned char* d_dst, int row, int col)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
int idy = blockIdx.y * blockDim.y + threadIdx.y;
int src_center = idy * col + idx;
if(idy >= row || idx >= col)
return;
... |
17,256 | /*
* Tiled version of matrix multiplication
* Sequential Matrix multiplication
* TODO Step 1. Matrix dimensions are multiples of TILE_WIDTH [DONE]
* TODO Step 1.a make each thread do more work
* TODO Step 2. MAtrix dimensions are arbitary size
*/
#include<stdio.h>
#include<assert.h>
#include<cuda.h>
#include<stdl... |
17,257 | __device__ void MatrixInverse( void* param)
{
float* paramIn = (float*)param;
int N = (int)paramIn[0];
paramIn = paramIn+1;
float* A = paramIn;
float* B = paramIn+N*N;
int x = threadIdx.x;
if (x < N)
{
for (int y = 0; y < N; ++y)
{
float pivot = 0;
for (int i = 0; i... |
17,258 | #include <stdio.h>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include "cuda.h"
#include "kernel.cuh"
__global__ void cuda_hello() {
int id = threadIdx.x;
printf("Hello World from GPU! blockid.x = %d threadidx = %d\n",blockIdx.x,id);
}
__global__ void addKernel(int *c, const int *a, const int ... |
17,259 | /*Demo 1D sheath PIC simulation with CUDA
GPU1: particle mover moved to the GPU
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
/*CUDA error wraper*/
static void CUDA_ERROR( cudaError_t err)
{
if (er... |
17,260 | #include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <math.h>
#include <string.h>
int size_n, SEED;
#define CUDA_ERROR_EXIT(str) do{\
cudaError err = cudaGetLastError();\
if( err != cudaSuccess){\
... |
17,261 | #include "cuda_runtime.h"
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
struct vec3
{
float x,y,z;
};
__global__ void vectorAdd(vec3 *c, vec3 *a, vec3 *b)
{
int tid = threadIdx.x;
/* 1-1. write vector addition function */
c->x = a->x + b->x;
c->y = a->y + b->y;
c->z = a... |
17,262 | #include <stdio.h>
#define N 500
__global__ void VecAdd(int* DA, int* DB, int* DC)
{
int i = threadIdx.x;
DC[i] = DA[i] + DB[i];
}
int main()
{ int HA[N], HB[N], HC[N];
int *DA, *DB, *DC;
int i; int size = N*sizeof(int);
// reservamos espacio en la memoria global del device
cudaMalloc((void**)&DA, si... |
17,263 | #include "includes.h"
//iojpegparts.cu
__global__ void GaussianBlurCuda (unsigned char *pic, unsigned char * outpic, double *mask, int *size){ // size: width, height, mask_width
int pxPosCen = blockIdx.x * blockDim.x + threadIdx.x;
if (pxPosCen >= size[0]*size[1] || pxPosCen < 0) return;
int row, col, x, y, pos;
row ... |
17,264 | #include "cuda.h"
#include "stdio.h"
#include <sys/time.h>
#include <sys/resource.h>
double dwalltime(){
double sec;
struct timeval tv;
gettimeofday(&tv,NULL);
sec = tv.tv_sec + tv.tv_usec/1000000.0;
return sec;
}
int cant = 512;
int cant_elem = cant * cant;
// arreglos u... |
17,265 | #include <fstream>
#include <iterator>
#include <vector>
#include <iostream>
#include <cstdlib>
#include <string>
#include <sstream>
#include <iomanip>
#include <math.h>
#include <stdio.h>
//Define the Z direction size as a global variable
#define z 400
#define blockSize 128
#define energySize 64000000
//define macr... |
17,266 | #include "includes.h"
using namespace std;
#define ITERATIONS 40000
enum pixel_position {INSIDE_MASK, BOUNDRY, OUTSIDE};
__global__ void poisson_jacobi_kernel(float *targetimg, float *outimg, int *boundary_array,int c, int w, int h, int boundBoxMinX, int boundBoxMaxX, int boundBoxMinY, int boundBoxMaxY){
int x = th... |
17,267 | #include "includes.h"
__global__ void reduction(float *g_data, int n)
{
__shared__ float s_data[NUM_ELEMENTS];
int tid = threadIdx.x;
int myIndex = threadIdx.x + blockIdx.x*blockDim.x;
//s_data[tid] = 0.0;
s_data[tid] = g_data[myIndex];
__syncthreads();
for(int s = blockDim.x / 2; s > 0; s >>=1)
{
if(tid < s)
{
... |
17,268 | #include "includes.h"
__global__ void InitCentroidsKernel( float *centroidCoordinates, float *randomNumbers, float minX, float maxX, float minY, float maxY, int centroids )
{
int threadId = blockDim.x*blockIdx.y*gridDim.x //rows preceeding current row in grid
+ blockDim.x*blockIdx.x //blocks preceeding current blo... |
17,269 | #include "includes.h"
__global__ void add( int a, int b, int *c )
{
*c = a+b;
} |
17,270 | #include "OddEvenSort_kernel.cu"
#define THREADSPERBLOCK 512
extern "C" void TestOddEvenSort( const int n, float* eigenvalues, float* eigenvectors ) {
float* gpu_eigenvalues;
cudaMalloc( (void**) &gpu_eigenvalues, n*sizeof(float));
cudaMemcpy( gpu_eigenvalues, eigenvalues, n*sizeof(float), cudaMemcpyHostT... |
17,271 | #include "cuda.h"
#include "math.h"
#include "stdio.h"
#include "stdlib.h"
#include "thrust/scan.h"
#define BLOCK_SIZE 512
#define DOUBLE_BLOCK 1024
#define LOG_NUM_BANKS 4
#define CONFLICT_FREE_OFFSET(x) ((x) >> LOG_NUM_BANKS)
__global__ void prescanKernel(double* d_in, double* d_out, double* d_sums,
... |
17,272 | #include <stdio.h>
#include <math.h>
#include <time.h>
#include <cuda.h>
//Code written by Alan Fleming
//CONSTANTS
#define MATRIXSIZE 2048
#define BLOCKSIZE 1024
//Code to prefix sum using the cpu
void prefixSumCPU(int* x, int* y, int N){
y[0] = x[0];
for(int i = 1; i < N; i++){
y[i] = y[i-1] + x[i];
}
}
__g... |
17,273 | #include "CudaLife.cuh"
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
__global__ void cudaDecKernel(
cudaSurfaceObject_t surfaceIn,
cudaSurfaceObject_t surfaceOut,
unsigned int width,
unsigned int height
) {
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threa... |
17,274 | #include <stdio.h>
__global__ void kernel( void ) {}
int main( void )
{
kernel<<< 1, 1 >>>(); //kernel call
printf( "Hello, World!\n" );
return 0;
}
|
17,275 | #include <stdio.h>
#include <sys/time.h>
#include <cuda.h>
long long getCurrentTime() {
struct timeval te;
gettimeofday(&te, NULL); // get current time
long long microseconds = te.tv_sec*1000000LL + te.tv_usec;
return microseconds;
}
#define CUDA_ERROR_CHECK
#define CudaSafeCall( err ) __cudaSafeCall(... |
17,276 | #include<stdio.h>
#include<iostream>
__global__ void foo() {}
int main() {
foo<<<1,1>>>();
std::cout<<"The Result is "
<<cudaGetErrorString(cudaGetLastError())<<std::endl;
return 0;
}
|
17,277 | #include <bits/stdc++.h>
#include <thrust/device_vector.h>
#include <thrust/copy.h>
#include <thrust/execution_policy.h>
#define to_ptr(x) thrust::raw_pointer_cast(&x[0])
#define gpu_copy(x, y) thrust::copy((x).begin(), (x).end(), (y).begin())
#define gpu_copy_to(x, y, pos) thrust::copy((x).begin(), (x).end(), (y).begi... |
17,278 | /*
* Updater.cpp
*
* Created on: 11 янв. 2016 г.
* Author: aleksandr
*/
#include "Updater.h"
#include <iostream>
void Updater::iterate() {
updateFields();
updateBoundaryCond();
updateSources();
updateRoutines();
}
|
17,279 | #include "includes.h"
/***********************************************************
By Huahua Wang, the University of Minnesota, twin cities
***********************************************************/
__global__ void xexp( float* X, float* C, float* Y, float* Z, unsigned int size)
{
const unsigned int idx =... |
17,280 | #include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <sys/time.h>
#include <time.h>
#include <cuda_runtime.h>
#define NUM_ELEMENTS 753411
#define EPSILON 0.000005
#define NUM_THREADS_PER_BLOCK 256
#define NUM_BLOCKS NUM_ELEMENTS/NUM_THREADS_PER_BLOCK+1
void functionSerial(float* d_in,... |
17,281 | #include <stdlib.h>
#include <stdio.h>
#include <time.h>
#define n 1024
//execution time 251.549927 ms
__global__ void mul_matrix(int *a, int *b, int *c){
int my_x, my_y, i;
my_x = blockIdx.x*blockDim.x + threadIdx.x;
my_y = blockIdx.y*blockDim.y + threadIdx.y;
int local_c;
for (i=0;i<n;i++)
local_c += a[my_... |
17,282 | #include <cuda.h>
#include <stdio.h>
__global__ void K1(int *dst, int nelem) {
printf("\t%d\n", dst[nelem - 1]);
}
int main() {
int nbytes = (1 << 30);
int nelem = nbytes / sizeof(int);
//int *src = (int *)malloc(nbytes);
int *src; cudaHostAlloc(&src, nbytes, 0);
src[nelem - 1] = 523;
int *dst;
cudaMalloc(&dst... |
17,283 | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <cuda.h>
#include <curand.h>
#include <curand_kernel.h>
const int SWEEPS = 100;
void printArray(int* arr, int size) {
for (int i = 0; i < size; i++) {
printf("%d ", arr[i]);
}
printf("\n");
}
int getSize(FILE* fptr) {
int size = 0;
int temp;
w... |
17,284 | #include <cuda_runtime.h>
#include <stdio.h>
int main(int argc, char** argv){
int n = (1<<10);
dim3 block(1024);
dim3 grid((n-1)/block.x+1);
printf("grid.x %d block.x %d\n", grid.x, block.x);
block.x = 512;
grid.x = (n-1)/block.x+1;
printf("grid.x %d block.x %d\n", grid.x, block.x);... |
17,285 | //pass
//--gridDim=[100,10] --blockDim=1
__global__ void executeThirdLayer(float *Layer3_Neurons_GPU, float *Layer3_Weights_GPU,float *Layer4_Neurons_GPU)
{
int blockID=blockIdx.x;
//int pixelY=threadIdx.y;
int weightBegin=blockID*1251;
float result=0;
result+=Layer3_Weights_GPU[weightBegin];
++weightBegin... |
17,286 | // https://devblogs.nvidia.com/parallelforall/even-easier-introduction-cuda/
#include <iostream>
#include <math.h>
#include <random>
int BLOCK_SIZE = 256;
__global__
void multiply(int n, float *x, float *y, float *z) {
int index = blockIdx.x * blockDim.x + threadIdx.x;
int stride = blockDim.x * gridDim.x;
... |
17,287 | #include <cuda.h>
#include <cuda_runtime.h>
/************************/
/* RASTRIGIN FUNCTIONAL */
/************************/
__device__ float rastrigin(float x) { return x * x - 10.0f * cosf(2.0f * x) + 10.0f; }
/*********************/
/* SPHERE FUNCTIONAL */
/*********************/
__device__ float sphere(float x) {... |
17,288 | #include <stdio.h>
#include <stdlib.h>
int pagerank(float *coovala,int *coorowinda,int *coocolinda,int nnz,int nodes,float q,int max_iters,float accept_key,float *pr,int *real_iters,float *real_key);
int main()
{
FILE *fp=NULL;
float *value=NULL,*pr=NULL;
int *row=NULL,*col=NULL;
float elaps... |
17,289 | #include <stdio.h>
#include <cuda.h>
__global__ void dkernel(char *arr, int arrlen) {
unsigned id = threadIdx.x;
if (id < arrlen) {
++arr[id];
}
}
int main() {
char cpuarr[] = "Gdkkn\x1fVnqkc-", *gpuarr;
cudaMalloc(&gpuarr, sizeof(char) * (1 + strlen(cpuarr)));
cudaMemcpy(gpuarr, cpuarr, sizeof(char) * (1 + st... |
17,290 | /*
* Copyright 2018 German Research Center for Artificial Intelligence (DFKI)
* Author: Clemens Lutz <clemens.lutz@dfki.de>
*
* 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:... |
17,291 | #include <iostream>
#include <cstdlib>
#include <ctime>
#define BLOCK_SIZE 32
using namespace std;
int N;
__global__ void gpu(const int *a, const int *b, int n, int * c) {
int bx = blockIdx.x;
int by = blockIdx.y;
int tx = threadIdx.x;
int ty = threadIdx.y;
float sum = 0;
int ... |
17,292 | #include "includes.h"
__global__ void normalize(int *values, int *max, float *output, int n)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
if(i < n)
{
output[i] = (float)values[i] / (float)*max;
}
} |
17,293 | // ###
// ###
// ### Practical Course: GPU Programming in Computer Vision
// ###
// ###
// ### Technical University Munich, Computer Vision Group
// ### Summer Semester 2014, September 8 - October 10
// ###
// ###
// ### Maria Klodt, Jan Stuehmer, Mohamed Souiai, Thomas Moellenhoff
// ###
// ###
// ### Dennis Mack, den... |
17,294 | #include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <cuda_runtime_api.h>
#define SQ(x) ((x) * (x))
static const float A = -4.0, B = 4.0; // limites de integración
static const int N = 1 << 22; // número de intervalos = 2^22
static const float H = (B - A) / N; // tamaño del... |
17,295 | #include <stdio.h>
#include <assert.h>
// Convenience function for checking CUDA runtime API results
// can be wrapped around any runtime API call. No-op in release builds.
inline
cudaError_t checkCuda(cudaError_t result)
{
#if defined(DEBUG) || defined(_DEBUG)
if (result != cudaSuccess) {
fprintf(stderr, "CUDA ... |
17,296 |
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
#define N 1024
__global__ void getMaxValueOfRow(float *d_arr, float *maxArray) {
int t = threadIdx.x;
int bid = blockIdx.x;
for (int stride = 1; stride < blockDim.x; stride *= 2) {
__synct... |
17,297 | #include <stdio.h>
#include <cuda.h>
#include <string>
#include <iostream>
#include <fstream>
#include "f_eval.cuh"
using namespace std;
__inline__ __host__ __device__ double f_eval(double* p_x, int m);
double* readFile(string input, int *m, int *n);
void writeFile(string output, double* A, int m, int n);
__global__... |
17,298 | #include "includes.h"
/*
* file name: mm_omp_vs_cuda.cu
*
* mm_omp_vs_cuda.cu contains the code that realize some common used matrix operations in CUDA, and
* an implementation of matrix multiplication speedup via openmp, this is a practice to compare the
* of performance of cuda and openmp, as well as a trail of u... |
17,299 |
///////////////////////////////// DEVICE FUNCTIONS /////////////////////////////////
//__device__ int sgn(float val) {
// return ((0.0 < val) ? 1 : -1 );
//}
///////////////////////////////// GLOBAL GPU FUNCTIONS /////////////////////////////////
__global__ void testkernel1(float* phi, int Nx, int Ny, int... |
17,300 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
//#include "cublas.h"
//#include "magma.h"
//#include "magmablas.h"
#define NN 4096
void host_mv(int n,float *a,int lda,float *x,float *y){
int i,j;
for(j=0;j<n;j++){
for(i=0;i<n;i++){
y[i]+=a[i+j*lda]*x[j];
}
}
}
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.