Celeritas 0.7+c0d26b9
Loading...
Searching...
No Matches
Classes | Functions
Ldg.hh File Reference
#include <cstddef>
#include <type_traits>
#include "corecel/Macros.hh"

Classes

struct  celeritas::LdgMember< Class, T >
 Storable projector that loads a struct member via ldg . More...
 

Functions

template<class T >
constexpr std::enable_if_t< std::is_arithmetic_v< T >, T const * > celeritas::ldg_data (T const *ptr) noexcept
 Get a pointer to the arithmetic data for use with __ldg .
 
template<class T >
constexpr std::enable_if_t< std::is_enum_v< T >, std::underlying_type_t< T > const * > celeritas::ldg_data (T const *ptr) noexcept
 Get a pointer to the underlying integer for an enum type.
 
template<class T >
constexpr T celeritas::ldg (T const *ptr)
 Wrap the low-level CUDA/HIP "load read-only global memory" function.
 
template<class Class , class T >
T celeritas::ldg (Class const &obj, T Class::*mp)
 Load a struct member via ldg using a pointer-to-member.
 
template<class Class , class T >
 celeritas::LdgMember (T Class::*) -> LdgMember< Class, T >
 Deduction guide: LdgMember{&Foo::bar} deduces LdgMember<Foo,Bar>
 

Function Documentation

◆ ldg() [1/2]

template<class Class , class T >
T celeritas::ldg ( Class const obj,
T Class::*  mp 
)

Load a struct member via ldg using a pointer-to-member.

Convenience overload for when the member is known at the call site.

BIHNodeId parent = ldg(node, &BIHLeafNode::parent);

◆ ldg() [2/2]

template<class T >
constexpr T celeritas::ldg ( T const ptr)
inlineconstexpr

Wrap the low-level CUDA/HIP "load read-only global memory" function.

This relies on ldg_data found by ADL to obtain a pointer to the underlying arithmetic type; see Cached device loading for usage and extension examples.

On CUDA the load is cached in L1/texture memory, improving performance when data is repeatedly read by many threads in a kernel.

Warning
The target address must be read-only for the lifetime of the kernel. This is generally true for Params data but not State data.

◆ ldg_data()

template<class T >
constexpr std::enable_if_t< std::is_arithmetic_v< T >, T const * > celeritas::ldg_data ( T const ptr)
inlineconstexprnoexcept

Get a pointer to the arithmetic data for use with __ldg .

Default overload for arithmetic types: returns the pointer unchanged.