Host/device portability tiers¶
Slam’s types are designed to run both on the host and inside GPU kernels.
Not every C++ facility is safe in device code across all of Slam’s backends (sequential, OpenMP, CUDA, HIP), so Slam categorizes the constructs it uses into three portability tiers. Compile-time features generate no device code and are therefore unconditionally kernel-safe.
Tier |
Contents |
Allowed where |
|---|---|---|
A |
All compile-time language features (concepts, |
everywhere, including kernels |
B |
|
host only: builders, registries, |
C |
Virtual functions on host-device types; standard containers held inside view types; throwing accessors on host-device paths. |
nowhere (existing instances are migration targets) |
Device std::optional¶
Slam uses std::optional for optional-returning APIs.
The CUDA host-configs enable --expt-relaxed-constexpr,
and HIP’s compiler accepts these standard library calls from host-device paths in the supported builds.
The device-side contract is to check has_value() before dereferencing with
operator*, or to use value_or. Avoid value() in kernels because
standard library implementations can route the disengaged case through a
throwing host-only helper.