Hermes
cuda_utils.h File Reference

Auxiliary classes and macros for CUDA calls. More...

Go to the source code of this file.

Classes

struct  hermes::cuda_utils::LaunchInfo
 Holds CUDA launch parameters. More...
 
class  hermes::cuda_utils::Lock
 Synchronization lock. More...
 

Macros

#define GPU_BLOCK_SIZE   1024
 Maximum thread block size.
 
#define GPU_BLOCK_SIZE_X   1024
 Maximum thread block size in 1st dimension.
 
#define GPU_BLOCK_SIZE_Y   1024
 Maximum thread block size in 2nd dimension.
 
#define GPU_BLOCK_SIZE_Z   64
 Maximum thread block size in 3rd dimension.
 
#define GPU_WARP_SIZE   32
 Warp size.
 
#define HERMES_CUDA_TIME(LAUNCH, ELAPSED_TIME_IN_MS)
 Computes execution time from a given CUDA call. More...
 
#define HERMES_CUDA_DEVICE_SYNCHRONIZE   HERMES_CHECK_CUDA_CALL(cudaDeviceSynchronize());
 Calls cudaDeviceSynchronize.
 
#define HERMES_CUDA_LAUNCH(LAUNCH_INFO, NAME, ...)
 Launches a CUDA kernel given its parameters. More...
 
#define HERMES_CUDA_LAUNCH_AND_SYNC(LAUNCH_INFO, NAME, ...)
 Launches a CUDA kernel given its parameters and synchronizes with host. More...
 
#define HERMES_CUDA_THREAD_INDEX_I    u32 i = threadIdx.x + blockIdx.x * blockDim.x
 Creates a 1-dimensional index based on current cuda thread index.
 
#define HERMES_CUDA_THREAD_INDEX_IJ
 Creates a 2-dimensional index based on current cuda thread index. More...
 
#define HERMES_CUDA_THREAD_INDEX_IJK
 Creates a 3-dimensional index based on current cuda thread index. More...
 
#define HERMES_CUDA_RETURN_IF_NOT_THREAD_0
 Ensures just thread of index 0 is run. More...
 
#define HERMES_CUDA_THREAD_INDEX_LT(I, BOUNDS)
 Creates a 1-dimensional index and tests it against bounds. More...
 
#define HERMES_CUDA_THREAD_INDEX2_LT(IJ, BOUNDS)
 Creates a 2-dimensional index and tests it against bounds. More...
 
#define HERMES_CUDA_THREAD_INDEX3_LT(IJK, BOUNDS)
 Creates a 3-dimensional index and tests it against bounds. More...
 
#define HERMES_CUDA_THREAD_INDEX_I_LT(BOUNDS)   HERMES_CUDA_THREAD_INDEX_LT(i, BOUNDS)
 Creates a 1-dimensional index variable i and tests it against bounds. More...
 
#define HERMES_CUDA_THREAD_INDEX_IJ_LT(BOUNDS)   HERMES_CUDA_THREAD_INDEX2_LT(ij, BOUNDS)
 Creates a 2-dimensional index variable ij and tests it against bounds. More...
 
#define HERMES_CUDA_THREAD_INDEX_IJK_LT(BOUNDS)   HERMES_CUDA_THREAD_INDEX3_LT(ijk, BOUNDS)
 Creates a 3-dimensional index variable ijk and tests it against bounds. More...
 
#define HERMES_CHECK_CUDA_CALL(err)
 Checks (and logs) a CUDA method return code for errors. More...
 
#define HERMES_CHECK_LAST_CUDA_CALL   HERMES_CHECK_CUDA_CALL(cudaGetLastError());
 Checks (and logs) the last CUDA call for errors.
 
#define CUDA_MEMORY_USAGE
 Outputs in stdout current GPU memory usage. More...
 

Functions

cudaMemcpyKind hermes::cuda_utils::copyDirection (MemoryLocation src, MemoryLocation dst)
 Computes cuda flag of memory block copy direction. More...
 
std::ostream & hermes::cuda_utils::operator<< (std::ostream &o, const LaunchInfo &info)
 LaunchInfo support for std::ostream << operator. More...
 
void hermes_print_cuda_devices ()
 Outputs in stdout information about all devices in the current machine.
 
void hermes_print_cuda_memory_usage ()
 Outputs in stdout current GPU memory usage.
 

Detailed Description

Auxiliary classes and macros for CUDA calls.

Copyright (c) 2021, FilipeCN.

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Author
FilipeCN (filip.nosp@m.edec.nosp@m.n@gma.nosp@m.il.c.nosp@m.om)
Date
2021-06-30

Function Documentation

◆ copyDirection()

cudaMemcpyKind hermes::cuda_utils::copyDirection ( MemoryLocation  src,
MemoryLocation  dst 
)
inline

Computes cuda flag of memory block copy direction.

Parameters
src
dst
Returns

◆ operator<<()

std::ostream& hermes::cuda_utils::operator<< ( std::ostream &  o,
const LaunchInfo info 
)
inline

LaunchInfo support for std::ostream << operator.

Parameters
o
info
Returns