cuda::experimental::places::partition_mapper#

class partition_mapper#

The partitioner of a composite data place: how it maps data coordinates to a grid position, plus the identity that distinguishes it from other partitioners.

A plain partition_fn_t converts implicitly and is its own identity, so existing callers are unaffected. The second form exists for a mapper that cannot be called as a partition_fn_t - one reached through a foreign ABI, whose coordinate structs are its own types, or a stateful partitioner. Such a caller wraps the call in an adapter and supplies a separate identity.

Identity is what makes two composite places compare (and order) equal, and what lets the localized_array cache reuse a mapping, so it must be stable for a given partitioner. Note the identity is only ever compared, never called: reinterpret_cast between function pointer types is well defined as long as the result is not invoked, which is exactly how a foreign-ABI callback can serve as one.

LIFETIME CONTRACT (foreign-ABI callers): because caches key on the identity and may outlive the data place, the identity must stay unique for as long as any mapping derived from it can be reused. A trampoline freed and reallocated at the same address for a DIFFERENT mapper would alias the old cache entry and silently serve the old mapper’s placement. Bindings must therefore keep their trampoline (and thus its address) alive for the lifetime of any context that may cache placements from it. The Python bindings currently pin the trampoline for the data place’s lifetime, which narrows but does not close the window (a cache can outlive the place); making the cache robust to identity reuse (generation-tagged identities, or invalidation on mapper destruction) is follow-up work.

Public Types

using call_type = ::std::function<void(pos4 *result, pos4 data_coords, dim4 data_dims, dim4 grid_dims)>#

Public Functions

partition_mapper() = default#
inline partition_mapper(partition_fn_t fn)#

A raw partition function is its own identity.

inline partition_mapper(call_type call, partition_fn_t identity)#

A mapper that is not callable as a partition_fn_t, with an explicit identity.

inline void operator()(
pos4 *result,
pos4 data_coords,
dim4 data_dims,
dim4 grid_dims
) const#
inline explicit operator bool() const noexcept#

Friends

inline friend bool operator==(
const partition_mapper &lhs,
const partition_mapper &rhs
) noexcept#
inline friend bool operator!=(
const partition_mapper &lhs,
const partition_mapper &rhs
) noexcept#
inline friend bool operator<(
const partition_mapper &lhs,
const partition_mapper &rhs
) noexcept#