class closure_hydrator
Declaration
class closure_hydrator { /* full declaration omitted */ };
Description
The closure hydrator is used to inject information into objects (currently host/device and local accessors) that have been captured into a lambda closure. We abuse the copy constructor of the captured objects to modify them while the containing closure is being copied by the hydrate() function. Accessors request their corresponding information by means of per-closure unique "hydration ids" that are assigned upon accessor creation. The hydrator is implemented as a thread-local singleton that needs to be explicitly enabled per-thread. This is because kernel command function closures may be copied any number of times after having been passed to SYCL, which should not trigger the hydration mechanism.
Declared at: include/closure_hydrator.h:76
Member Variables
- std::vector<accessor_info> m_accessor_infos
- std::optional<target> m_armed_for = std::nullopt
- bool m_is_hydrating = false
- sycl::handler* m_sycl_cgh = nullptr
- static std::unique_ptr<closure_hydrator> m_instance
Member Function Overview
- arm(target tgt, std::vector<accessor_info> accessor_infos) → void
- closure_hydrator(closure_hydrator &&)
- closure_hydrator(const closure_hydrator &)
- template <target Tgt>
get_accessor_info(hydration_id hid) → accessor_info - get_instance() → static closure_hydrator &
- get_sycl_handler() → sycl::handler &
- template <target Tgt, typename Closure, std::enable_if_t<Tgt == target::device, int> = 0>
hydrate(sycl::handler & cgh, const Closure & closure) → [[nodiscard]] auto - template <target Tgt, typename Closure, std::enable_if_t<Tgt == target::host_task, int> = 0>
hydrate(const Closure & closure) → [[nodiscard]] auto - is_available() → static bool
- is_hydrating() const → bool
- make_available() → static void
- operator=(closure_hydrator &&) → closure_hydrator &
- operator=(const closure_hydrator &) → closure_hydrator &
- teardown() → static void
- ~closure_hydrator()
- closure_hydrator()
- template <typename Closure>
hydrate(target tgt, sycl::handler * cgh, const Closure & closure) → [[nodiscard]] auto
Member Functions
¶void arm(
target tgt,
std::vector<accessor_info> accessor_infos)
void arm(
target tgt,
std::vector<accessor_info> accessor_infos)
Description
Puts the hydrator into the "armed" state, after which hydrate() can be called to hydrate kernel functions. accessor_infos must contain one entry for each hydration id that has been assigned to accessors in the closure that is to be hydrated, in matching order.
Declared at: include/closure_hydrator.h:114
Parameters
- target tgt
- std::vector<accessor_info> accessor_infos
¶closure_hydrator(closure_hydrator&&)
closure_hydrator(closure_hydrator&&)
Declared at: include/closure_hydrator.h:89
Parameters
¶closure_hydrator(const closure_hydrator&)
closure_hydrator(const closure_hydrator&)
Declared at: include/closure_hydrator.h:88
Parameters
- const closure_hydrator&
¶template <target Tgt>
accessor_info get_accessor_info(hydration_id hid)
template <target Tgt>
accessor_info get_accessor_info(hydration_id hid)
Declared at: include/closure_hydrator.h:140
Template Parameters
- target Tgt
Parameters
- hydration_id hid
¶static closure_hydrator& get_instance()
static closure_hydrator& get_instance()
Declared at: include/closure_hydrator.h:103
¶sycl::handler& get_sycl_handler()
sycl::handler& get_sycl_handler()
Declared at: include/closure_hydrator.h:148
¶template <target Tgt,
typename Closure,
std::enable_if_t<Tgt == target::device,
int> = 0>
[[nodiscard]] auto hydrate(sycl::handler& cgh,
const Closure& closure)
template <target Tgt,
typename Closure,
std::enable_if_t<Tgt == target::device,
int> = 0>
[[nodiscard]] auto hydrate(sycl::handler& cgh,
const Closure& closure)
Description
Hydrates the provided closure by copying it in a context where calls to get_accessor_info and get_sycl_handler are allowed.
Declared at: include/closure_hydrator.h:125
Template Parameters
- target Tgt
- Closure
- std::enable_if_t<Tgt == target::device, int> = 0
Parameters
- sycl::handler& cgh
- const Closure& closure
¶template <
target Tgt,
typename Closure,
std::enable_if_t<Tgt == target::host_task,
int> = 0>
[[nodiscard]] auto hydrate(const Closure& closure)
template <
target Tgt,
typename Closure,
std::enable_if_t<Tgt == target::host_task,
int> = 0>
[[nodiscard]] auto hydrate(const Closure& closure)
Description
Hydrates the provided closure by copying it in a context where calls to get_accessor_info are allowed.
Declared at: include/closure_hydrator.h:133
Template Parameters
- target Tgt
- Closure
- std::enable_if_t<Tgt == target::host_task, int> = 0
Parameters
- const Closure& closure
¶static bool is_available()
static bool is_available()
Declared at: include/closure_hydrator.h:99
¶bool is_hydrating() const
bool is_hydrating() const
Declared at: include/closure_hydrator.h:137
¶static void make_available()
static void make_available()
Declared at: include/closure_hydrator.h:94
¶closure_hydrator& operator=(closure_hydrator&&)
closure_hydrator& operator=(closure_hydrator&&)
Declared at: include/closure_hydrator.h:91
Parameters
¶closure_hydrator& operator=(
const closure_hydrator&)
closure_hydrator& operator=(
const closure_hydrator&)
Declared at: include/closure_hydrator.h:90
Parameters
- const closure_hydrator&
¶static void teardown()
static void teardown()
Declared at: include/closure_hydrator.h:101
¶~closure_hydrator()
~closure_hydrator()
Declared at: include/closure_hydrator.h:92
¶closure_hydrator()
closure_hydrator()
Declared at: include/closure_hydrator.h:160
¶template <typename Closure>
[[nodiscard]] auto hydrate(target tgt,
sycl::handler* cgh,
const Closure& closure)
template <typename Closure>
[[nodiscard]] auto hydrate(target tgt,
sycl::handler* cgh,
const Closure& closure)
Declared at: include/closure_hydrator.h:163
Template Parameters
- Closure
Parameters
- target tgt
- sycl::handler* cgh
- const Closure& closure