Commit cb0f8831 authored by Po-Yen, Chen's avatar Po-Yen, Chen
Browse files

Merge branch 'feature/support-readfirstlane-for-object-types' into...

Merge branch 'feature/support-readfirstlane-for-object-types' into feature/simplify-karg-for-device-gemm-xdl-improved
parents 257b690e ad8bc60b
...@@ -50,8 +50,9 @@ template < ...@@ -50,8 +50,9 @@ template <
typename = std::enable_if_t<std::is_class_v<Object> && std::is_trivially_copyable_v<Object>>> typename = std::enable_if_t<std::is_class_v<Object> && std::is_trivially_copyable_v<Object>>>
__device__ auto readfirstlane(const Object& obj) __device__ auto readfirstlane(const Object& obj)
{ {
constexpr unsigned SgprSize = 4; using Size = unsigned;
constexpr unsigned ObjectSize = sizeof(Object); constexpr Size SgprSize = 4;
constexpr Size ObjectSize = sizeof(Object);
using Sgpr = detail::get_unsigned_int_t<SgprSize>; using Sgpr = detail::get_unsigned_int_t<SgprSize>;
...@@ -59,12 +60,13 @@ __device__ auto readfirstlane(const Object& obj) ...@@ -59,12 +60,13 @@ __device__ auto readfirstlane(const Object& obj)
auto* const from_obj = reinterpret_cast<const std::byte*>(&obj); auto* const from_obj = reinterpret_cast<const std::byte*>(&obj);
constexpr unsigned RemainedSize = ObjectSize % SgprSize; constexpr Size RemainedSize = ObjectSize % SgprSize;
constexpr unsigned CompleteSgprCopyBoundary = ObjectSize - RemainedSize; constexpr Size CompleteSgprCopyBoundary = ObjectSize - RemainedSize;
static_for<0, CompleteSgprCopyBoundary, SgprSize>{}([&](auto offset) { for(Size offset = 0; offset < CompleteSgprCopyBoundary; offset += SgprSize)
{
*reinterpret_cast<Sgpr*>(to_obj + offset) = *reinterpret_cast<Sgpr*>(to_obj + offset) =
readfirstlane(*reinterpret_cast<const Sgpr*>(from_obj + offset)); readfirstlane(*reinterpret_cast<const Sgpr*>(from_obj + offset));
}); }
if constexpr(0 < RemainedSize) if constexpr(0 < RemainedSize)
{ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment