1
0

copy_sm90_bulk_reduce.hpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /******************************************************************************
  2. * Copyright (c) 2024, Jay Shah, Ganesh Bikshandi, Ying Zhang, Vijay Thakkar, Pradeep Ramani, Tri Dao.
  3. ******************************************************************************/
  4. #pragma once
  5. #include<cute/arch/copy_sm90_tma.hpp>
  6. namespace cute
  7. {
  8. ////////////////////////////////////////////////////////////////////////////////////////////////////
  9. struct SM90_BULK_REDUCE_ADD
  10. {
  11. CUTE_HOST_DEVICE static void
  12. copy(float const* smem_ptr,
  13. float * gmem_ptr, int32_t store_bytes)
  14. {
  15. #if defined(CUTE_ARCH_TMA_SM90_ENABLED)
  16. uint32_t smem_int_ptr = cast_smem_ptr_to_uint(smem_ptr);
  17. asm volatile("cp.reduce.async.bulk.global.shared::cta.bulk_group.add.f32 [%0], [%1], %2;\n"
  18. :
  19. : "l"(gmem_ptr), "r"(smem_int_ptr), "r"(store_bytes)
  20. : "memory");
  21. #else
  22. CUTE_INVALID_CONTROL_PATH("Trying to use BULK_REDUCE_ADD without CUTE_ARCH_TMA_SM90_ENABLED.");
  23. #endif
  24. }
  25. CUTE_HOST_DEVICE static void
  26. copy(float const* smem_ptr,
  27. float * gmem_ptr, int32_t store_bytes, uint64_t cache_hint)
  28. {
  29. #if defined(CUTE_ARCH_TMA_SM90_ENABLED)
  30. uint32_t smem_int_ptr = cast_smem_ptr_to_uint(smem_ptr);
  31. asm volatile("cp.reduce.async.bulk.global.shared::cta.bulk_group.L2::cache_hint.add.f32 [%0], [%1], %2, %3;\n"
  32. :
  33. : "l"(gmem_ptr), "r"(smem_int_ptr), "r"(store_bytes), "l"(cache_hint)
  34. : "memory");
  35. #else
  36. CUTE_INVALID_CONTROL_PATH("Trying to use BULK_REDUCE_ADD without CUTE_ARCH_TMA_SM90_ENABLED.");
  37. #endif
  38. }
  39. };
  40. ////////////////////////////////////////////////////////////////////////////////////////////////////
  41. } // end namespace cute