Celeritas  0.5.0-56+6b053cd
Functions
Ref.hh File Reference

Helper functions for memspace-specific references. More...

#include "corecel/Types.hh"
#include "detail/RefImpl.hh"
This graph shows which files directly or indirectly include this file:

Functions

template<template< Ownership, MemSpace > class S, MemSpace M>
S< Ownership::reference, M > celeritas::make_ref (S< Ownership::value, M > &states)
 Construct a reference object pointing to state data. More...
 
template<template< Ownership, MemSpace > class P, MemSpace M>
P< Ownership::const_reference, M > celeritas::make_ref (P< Ownership::value, M > const &params)
 Construct a reference object pointing to params data.
 
template<template< Ownership, MemSpace > class P, MemSpace M>
decltype(auto) celeritas::make_const_ref (P< Ownership::value, M > const &params)
 Construct a const reference object pointing to params data.
 
template<MemSpace M, class T >
decltype(auto) celeritas::get_ref (T &&obj)
 Get a reference to memory-spaced data owned by a params/state object. More...
 
template<template< Ownership, MemSpace > class CG, Ownership W, MemSpace M>
auto celeritas::make_host_val (CG< W, M > const &source)
 Copy an entire collection group to the host. More...
 

Detailed Description

Helper functions for memspace-specific references.

Function Documentation

◆ get_ref()

template<MemSpace M, class T >
decltype(auto) celeritas::get_ref ( T &&  obj)

Get a reference to memory-spaced data owned by a params/state object.

The object must have host_ref and device_ref accessors depending on the value of M.

◆ make_host_val()

template<template< Ownership, MemSpace > class CG, Ownership W, MemSpace M>
auto celeritas::make_host_val ( CG< W, M > const &  source)
inline

Copy an entire collection group to the host.

This is mostly useful for debugging and testing. It is not performant and should not be used as part of the stepping loop, since it is likely to perform many allocations.

auto my_states = make_host_val(states.device_ref());
auto make_host_val(CG< W, M > const &source)
Copy an entire collection group to the host.
Definition: Ref.hh:88

◆ make_ref()

template<template< Ownership, MemSpace > class S, MemSpace M>
S<Ownership::reference, M> celeritas::make_ref ( S< Ownership::value, M > &  states)
inline

Construct a reference object pointing to state data.

Since the "reference" type is a value whose scope must extend beyond all references to it, it's often necessary to create a "reference" instance from a "value" instance. Collection groups don't define templated copy constructors, so this function (and the others like it) provide a workaround.

auto my_states = make_ref(my_state_values);
S< Ownership::reference, M > make_ref(S< Ownership::value, M > &states)
Construct a reference object pointing to state data.
Definition: Ref.hh:32