SIRIUS 7.5.0
Electronic structure library and applications
Classes | Namespaces | Macros | Typedefs | Functions
acc.hpp File Reference

Interface to accelerators API. More...

Go to the source code of this file.

Classes

struct  sirius::GPU_Complex< double >
 
struct  sirius::GPU_Complex< float >
 
class  sirius::acc::stream_id
 Helper class to wrap stream id (integer number). More...
 

Namespaces

module  sirius
 Namespace of the SIRIUS library.
 
namespace  sirius::acc
 Namespace for accelerator-related functions.
 

Macros

#define GPU_PREFIX(x)   cuda##x
 
#define make_accDoubleComplex   make_cuDoubleComplex
 
#define make_accFloatComplex   make_cuFloatComplex
 
#define accCadd   cuCadd
 
#define accCsub   cuCsub
 
#define accCmul   cuCmul
 
#define accCdiv   cuCdiv
 
#define accConj   cuConj
 
#define accCaddf   cuCaddf
 
#define accCsubf   cuCsubf
 
#define accCmulf   cuCmulf
 
#define accCdivf   cuCdivf
 
#define accConjf   cuConjf
 
#define ACC_DYNAMIC_SHARED(type, var)   extern __shared__ type var[];
 
#define CALL_DEVICE_API(func__, args__)
 

Typedefs

using sirius::acc_stream_t = cudaStream_t
 
using sirius::acc_error_t = cudaError_t
 
using sirius::acc_complex_float_t = cuFloatComplex
 
using sirius::acc_complex_double_t = cuDoubleComplex
 
template<typename T >
using sirius::gpu_complex_type = typename GPU_Complex< T >::type
 

Functions

void sirius::acc::stack_backtrace ()
 
int sirius::acc::num_devices ()
 Get the number of devices. More...
 
void sirius::acc::set_device_id (int id__)
 Set the GPU id. More...
 
int sirius::acc::get_device_id ()
 Get current device ID. More...
 
std::vector< acc_stream_t > & sirius::acc::streams ()
 Vector of device streams. More...
 
acc_stream_t sirius::acc::stream (stream_id sid__)
 Return a single device stream. More...
 
int sirius::acc::num_streams ()
 Get number of streams. More...
 
void sirius::acc::create_streams (int num_streams__)
 Create CUDA streams. More...
 
void sirius::acc::destroy_streams ()
 Destroy CUDA streams. More...
 
void sirius::acc::sync_stream (stream_id sid__)
 Synchronize a single stream. More...
 
void sirius::acc::reset ()
 Reset device. More...
 
void sirius::acc::sync ()
 Synchronize device. More...
 
size_t sirius::acc::get_free_mem ()
 
void sirius::acc::print_device_info (int device_id__, std::ostream &out__)
 
template<typename T >
void sirius::acc::copy (T *target__, T const *source__, size_t n__)
 Copy memory inside a device. More...
 
template<typename T >
void sirius::acc::copy (T *target__, int ld1__, T const *source__, int ld2__, int nrow__, int ncol__)
 2D copy inside a device. More...
 
template<typename T >
void sirius::acc::copyin (T *target__, T const *source__, size_t n__)
 Copy memory from host to device. More...
 
template<typename T >
void sirius::acc::copyin (T *target__, T const *source__, size_t n__, stream_id sid__)
 Asynchronous copy from host to device. More...
 
template<typename T >
void sirius::acc::copyin (T *target__, int ld1__, T const *source__, int ld2__, int nrow__, int ncol__)
 2D copy to the device. More...
 
template<typename T >
void sirius::acc::copyin (T *target__, int ld1__, T const *source__, int ld2__, int nrow__, int ncol__, stream_id sid__)
 Asynchronous 2D copy to the device. More...
 
template<typename T >
void sirius::acc::copyout (T *target__, T const *source__, size_t n__)
 Copy memory from device to host. More...
 
template<typename T >
void sirius::acc::copyout (T *target__, T const *source__, size_t n__, stream_id sid__)
 Asynchronous copy from device to host. More...
 
template<typename T >
void sirius::acc::copyout (T *target__, int ld1__, T const *source__, int ld2__, int nrow__, int ncol__)
 2D copy from device to host. More...
 
template<typename T >
void sirius::acc::copyout (T *target__, int ld1__, T const *source__, int ld2__, int nrow__, int ncol__, stream_id sid__)
 Asynchronous 2D copy from device to host. More...
 
template<typename T >
void sirius::acc::zero (T *ptr__, size_t n__)
 Zero the device memory. More...
 
template<typename T >
void sirius::acc::zero (T *ptr__, size_t n__, stream_id sid__)
 
template<typename T >
void sirius::acc::zero (T *ptr__, int ld__, int nrow__, int ncol__)
 Zero the 2D block of device memory. More...
 
template<typename T >
T * sirius::acc::allocate (size_t size__)
 Allocate memory on the GPU. More...
 
void sirius::acc::deallocate (void *ptr__)
 Deallocate GPU memory. More...
 
template<typename T >
T * sirius::acc::allocate_host (size_t size__)
 Allocate pinned memory on the host. More...
 
void sirius::acc::deallocate_host (void *ptr__)
 Deallocate host memory. More...
 
void sirius::acc::begin_range_marker (const char *label__)
 
void sirius::acc::end_range_marker ()
 
template<typename T >
void sirius::acc::register_host (T *ptr__, size_t size__)
 
void sirius::acc::unregister_host (void *ptr)
 
bool sirius::acc::check_last_error ()
 
bool sirius::acc::check_device_ptr (void const *ptr__)
 
void sirius::scale_matrix_rows_gpu (int nrow, int ncol, acc_complex_double_t *mtrx, double const *v)
 
void sirius::scale_matrix_elements_gpu (acc_complex_double_t *ptr__, int ld__, int nrow__, int ncol__, double beta__)
 

Detailed Description

Interface to accelerators API.

Definition in file acc.hpp.

Macro Definition Documentation

◆ GPU_PREFIX

#define GPU_PREFIX (   x)    cuda##x

Definition at line 56 of file acc.hpp.

◆ make_accDoubleComplex

#define make_accDoubleComplex   make_cuDoubleComplex

Definition at line 80 of file acc.hpp.

◆ make_accFloatComplex

#define make_accFloatComplex   make_cuFloatComplex

Definition at line 81 of file acc.hpp.

◆ accCadd

#define accCadd   cuCadd

Definition at line 82 of file acc.hpp.

◆ accCsub

#define accCsub   cuCsub

Definition at line 83 of file acc.hpp.

◆ accCmul

#define accCmul   cuCmul

Definition at line 84 of file acc.hpp.

◆ accCdiv

#define accCdiv   cuCdiv

Definition at line 85 of file acc.hpp.

◆ accConj

#define accConj   cuConj

Definition at line 86 of file acc.hpp.

◆ accCaddf

#define accCaddf   cuCaddf

Definition at line 87 of file acc.hpp.

◆ accCsubf

#define accCsubf   cuCsubf

Definition at line 88 of file acc.hpp.

◆ accCmulf

#define accCmulf   cuCmulf

Definition at line 89 of file acc.hpp.

◆ accCdivf

#define accCdivf   cuCdivf

Definition at line 90 of file acc.hpp.

◆ accConjf

#define accConjf   cuConjf

Definition at line 91 of file acc.hpp.

◆ ACC_DYNAMIC_SHARED

#define ACC_DYNAMIC_SHARED (   type,
  var 
)    extern __shared__ type var[];

Definition at line 92 of file acc.hpp.

◆ CALL_DEVICE_API

#define CALL_DEVICE_API (   func__,
  args__ 
)
Value:
{ \
if (acc::num_devices()) { \
acc_error_t error; \
error = GPU_PREFIX(func__) args__; \
if (error != GPU_PREFIX(Success)) { \
char nm[1024]; \
gethostname(nm, 1024); \
std::printf("hostname: %s\n", nm); \
std::printf("Error in %s at line %i of file %s: %s\n", \
#func__, __LINE__, __FILE__, GPU_PREFIX(GetErrorString)(error)); \
stack_backtrace(); \
} \
} \
}
@ error
throw a parse_error exception in case of a tag
int num_devices()
Get the number of devices.
Definition: acc.cpp:32
@ nm
Non-magnetic case.

Definition at line 163 of file acc.hpp.