TRIQS/nda 1.3.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches
Address spaces

Detailed Description

Currently supported address spaces and tools to work with them.

See nda::mem::AddressSpace for currently supported address spaces.

Enumerations

enum class  nda::mem::AddressSpace
 Enum providing identifiers for the different memory address spaces. More...
 

Variables

template<AddressSpace... AdrSpcs>
static const auto nda::mem::check_adr_sp_valid
 Check validity of a set of nda::mem::AddressSpace values.
 
template<AddressSpace A1, AddressSpace A2 = None, AddressSpace... As>
constexpr AddressSpace nda::mem::combine
 Promotion rules for nda::mem::AddressSpace values.
 
template<MemoryArray A1, MemoryArray... As>
constexpr AddressSpace nda::mem::common_addr_space = combine<get_addr_space<A1>, get_addr_space<As>...>
 Get common address space for a number of given nda::MemoryArray types.
 
template<typename T >
static constexpr AddressSpace nda::mem::get_addr_space = mem::None
 Variable template providing the address space for different types.
 
template<MemoryArray A>
static constexpr AddressSpace nda::mem::get_addr_space< A > = A::storage_t::address_space
 Specialization of nda::mem::get_addr_space for nda::Memory Array types.
 
template<char OP, ArrayOrScalar L, ArrayOrScalar R>
static constexpr AddressSpace nda::mem::get_addr_space< expr< OP, L, R > > = combine<get_addr_space<L>, get_addr_space<R>>
 Specialization of nda::mem::get_addr_space for binary expressions involving two nda::ArrayOrScalar types.
 
template<typename F , Array... As>
static constexpr AddressSpace nda::mem::get_addr_space< expr_call< F, As... > > = combine<get_addr_space<As>...>
 Specialization of nda::mem::get_addr_space for function call expressions involving nda::Array types.
 
template<char OP, Array A>
static constexpr AddressSpace nda::mem::get_addr_space< expr_unary< OP, A > > = get_addr_space<A>
 Specialization of nda::mem::get_addr_space for unary expressions involving an nda::Array type.
 
template<Handle H>
static constexpr AddressSpace nda::mem::get_addr_space< H > = H::address_space
 Specialization of nda::mem::get_addr_space for nda::Handle types.
 
template<typename... Ts>
static constexpr bool nda::mem::have_compatible_addr_space = (have_host_compatible_addr_space<Ts...> or have_device_compatible_addr_space<Ts...>)
 Constexpr variable that is true if all given types have compatible address spaces.
 
template<typename... Ts>
static constexpr bool nda::mem::have_device_compatible_addr_space = ((on_device<Ts> or on_unified<Ts>)and...)
 Constexpr variable that is true if all given types have an address space compatible with Device.
 
template<typename... Ts>
static constexpr bool nda::mem::have_host_compatible_addr_space = ((on_host<Ts> or on_unified<Ts>)and...)
 Constexpr variable that is true if all given types have an address space compatible with Host.
 
template<typename A0 , typename... A>
static constexpr bool nda::mem::have_same_addr_space = ((get_addr_space<A0> == get_addr_space<A>)and... and true)
 Constexpr variable that is true if all given types have the same address space.
 
template<typename... Ts>
static constexpr bool nda::mem::on_device = ((get_addr_space<Ts> == mem::Device) and ...)
 Constexpr variable that is true if all given types have a Device address space.
 
template<typename... Ts>
static constexpr bool nda::mem::on_host = ((get_addr_space<Ts> == mem::Host) and ...)
 Constexpr variable that is true if all given types have a Host address space.
 
template<typename... Ts>
static constexpr bool nda::mem::on_unified = ((get_addr_space<Ts> == mem::Unified) and ...)
 Constexpr variable that is true if all given types have a Unified address space.
 

Enumeration Type Documentation

◆ AddressSpace

enum class nda::mem::AddressSpace
strong

#include <nda/mem/address_space.hpp>

Enum providing identifiers for the different memory address spaces.

The following address spaces are available:

  • None: No address space.
  • Host: Address on CPU RAM.
  • Device: Address on GPU memory.
  • Unified: CUDA Unified memory address.

Definition at line 60 of file address_space.hpp.

Variable Documentation

◆ check_adr_sp_valid

template<AddressSpace... AdrSpcs>
const auto nda::mem::check_adr_sp_valid
static

#include <nda/mem/address_space.hpp>

Initial value:
= []() {
static_assert(((AdrSpcs != None) & ...), "Error in nda::mem::check_adr_sp_valid: Cannot use None address space");
static_assert(nda::have_device or ((AdrSpcs == Host) & ...),
"Error in nda::mem::check_adr_sp_valid: Device address space requires compiling with GPU support.");
}
static constexpr bool have_device
Constexpr variable that is true if the project is configured with GPU support.
Definition device.hpp:143

Check validity of a set of nda::mem::AddressSpace values.

Checks that the address spaces are not None and that the Device or Unified address spaces are only used when compiling with GPU support.

Template Parameters
AdrSpcsAddress spaces to check.

Definition at line 151 of file address_space.hpp.

◆ combine

template<AddressSpace A1, AddressSpace A2 = None, AddressSpace... As>
AddressSpace nda::mem::combine
constexpr

#include <nda/mem/address_space.hpp>

Initial value:
= []() {
static_assert(!(A1 == Host && A2 == Device) && !(A1 == Device && A2 == Host),
"Error in nda::mem::combine: Cannot combine Host and Device address spaces");
if constexpr (sizeof...(As) > 0) { return combine<std::max(A1, A2), As...>; }
return std::max(A1, A2);
}()
constexpr AddressSpace combine
Promotion rules for nda::mem::AddressSpace values.

Promotion rules for nda::mem::AddressSpace values.

Host and Device address spaces are not compatible and will result in a compilation error.

The promotion rules are as follows:

  • None -> Host -> Unified.
  • None -> Device -> Unified.
Template Parameters
A1First address space.
A2Second address space.
AsRemaining address spaces.

Definition at line 104 of file address_space.hpp.

◆ common_addr_space

template<MemoryArray A1, MemoryArray... As>
AddressSpace nda::mem::common_addr_space = combine<get_addr_space<A1>, get_addr_space<As>...>
constexpr

#include <nda/mem/address_space.hpp>

Get common address space for a number of given nda::MemoryArray types.

See nda::mem::combine for how the address spaces are combined.

Template Parameters
A1nda::MemoryArray type.
Asnda::MemoryArray types.

Definition at line 120 of file address_space.hpp.

◆ get_addr_space

template<typename T >
AddressSpace nda::mem::get_addr_space = mem::None
staticconstexpr

#include <nda/mem/address_space.hpp>

Variable template providing the address space for different types.

Has to be specialized for each type/concept separately.

Template Parameters
TType for which to get the address space.

Definition at line 80 of file address_space.hpp.