You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** * @brief given a pointer, this function returns a pointer to the first location * at the boundary of a given alignment size. This what std:align does but it * does not work with CUDA so this a stripped down version of it. * @tparam T type of the pointer * @param byte_alignment number of bytes to get the pointer to be aligned to * @param ptr input/output pointer pointing at first usable location. On return, * it will be properly aligned to the beginning of the first element that is * aligned to alignment*/template <typename T>
__device__ __host__ __inline__ voidalign(const std::size_t byte_alignment,
T*& ptr) noexcept
{
constuint64_t intptr = reinterpret_cast<uint64_t>(ptr);
constuint64_tremainder = intptr % byte_alignment;
if (remainder == 0) {
return;
}
constuint64_t aligned = intptr + byte_alignment - remainder;
ptr = reinterpret_cast<T*>(aligned);
}
Code from RXMesh: https://github.com/owensgroup/RXMesh/blob/memcpy_async/include/rxmesh/util/util.h#L390-L411
https://nvidia.github.io/libcudacxx/extended_api/shapes/aligned_size_t.html
https://stackoverflow.com/questions/70765553/cuda-shared-memory-alignement-in-documentation
The text was updated successfully, but these errors were encountered: