Celeritas 0.7+c0d26b9
Loading...
Searching...
No Matches
Typedefs | Functions
LdgSpan.hh File Reference
#include <cstddef>
#include <type_traits>
#include "corecel/Types.hh"
#include "Span.hh"
#include "detail/LdgSpanImpl.hh"

Typedefs

template<class T , std::size_t Extent = dynamic_extent>
using celeritas::LdgSpan = Span< detail::LdgWrapper< T >, Extent >
 Alias for a Span iterating over device const values read using ldg .
 
template<class T , std::size_t Extent = dynamic_extent>
using celeritas::AutoLdgSpan = Span< std::conditional_t< detail::is_ldg_supported_v< T >, detail::LdgWrapper< T >, T >, Extent >
 An LdgSpan when referencing compatible types, or Span otherwise.
 

Functions

template<class T , std::size_t N>
constexpr auto celeritas::to_array (Span< detail::LdgWrapper< T const >, N > s)
 Construct an array from a fixed-size LdgSpan.
 
template<class T >
constexpr auto celeritas::make_ldg_span (T const &cont)
 Make an LdgSpan directly from a container, primarily for testing.
 
template<class T , std::size_t N>
constexpr LdgSpan< T const, N > celeritas::make_ldg_span (T const (&arr)[N])
 Make an LdgSpan directly from a C array, primarily for testing.
 
template<class T , std::size_t N>
constexpr Span< T const, N > celeritas::remove_ldg_wrapper (Span< detail::LdgWrapper< T const >, N > cont)
 Convert an LdgSpan to a regular Span, not using ldg.
 
template<class T , std::size_t N>
constexpr Span< T const, N > celeritas::remove_ldg_wrapper (Span< T const, N > cont)
 Convert an LdgSpan to a regular Span, not using ldg.
 

Typedef Documentation

◆ AutoLdgSpan

template<class T , std::size_t Extent = dynamic_extent>
using celeritas::AutoLdgSpan = typedef Span< std::conditional_t<detail::is_ldg_supported_v<T>, detail::LdgWrapper<T>, T>, Extent>

An LdgSpan when referencing compatible types, or Span otherwise.

Note that T must be const.

◆ LdgSpan

template<class T , std::size_t Extent = dynamic_extent>
using celeritas::LdgSpan = typedef Span<detail::LdgWrapper<T>, Extent>

Alias for a Span iterating over device const values read using ldg .

This instantiates Span with a special wrapper class to optimize constant data access in global device memory. In that case, data returned by front, back, operator[] and begin / end iterators use value semantics instead of reference.

Function Documentation

◆ to_array()

template<class T , std::size_t N>
constexpr auto celeritas::to_array ( Span< detail::LdgWrapper< T const >, N >  s)
inlineconstexpr

Construct an array from a fixed-size LdgSpan.

Note:

to_array(Span<T,N> const&)

is not reused because:

  1. Using this overload reads input data using ldg
  2. return to_array<T, N>(s)
    results in segfault (gcc 11.3). This might be a compiler bug because temporary lifetime should be extended until the end of the expression and we return a copy...