template<typename T,
std::size_t maxWordSize = 8>
struct TNL::Backend::Uninitialized< T, maxWordSize >
Storage wrapper for type-punning through an array of device words.
The storage is an array of device words whose size is selected as the largest word that evenly divides sizeof(T), does not exceed alignof(T), and does not exceed maxWordSize.
The maxWordSize parameter controls the upper bound on the word size:
- Default (8): uses the largest efficient word for __shared__ memory access (up to 8 bytes for standard integer types).
- 4: restricts to uint32_t words, which is the native word size for CUDA/HIP __shfl_*_sync intrinsics.
- Type-punning access
Two access patterns are provided:
- get() returns a T& via reinterpret_cast. This is safe when all accesses to the storage go through the same type (e.g. __shared__ variables in reducing kernels that are always accessed as T).
- load() / store() use memcpy to copy between T and the raw storage array. These must be used when the storage is also accessed through DeviceWord (e.g. in warp shuffle wrappers that shuffle individual words). The reinterpret_cast-based get() would be a strict aliasing violation in that case, which Clang (HIP) exploits to optimize away the connection between the two access paths — the shuffle then silently returns the thread's own value instead of the other lane's. HIP's own __shfl_xor for double uses the same memcpy-based pattern to avoid this.