8 #include <hip/hip_runtime.h>
26 template <
typename ADataType,
typename BDataType>
32 std::size_t rotating_count_hint,
37 rotating_count(rotating_count_hint),
42 p_a_grids.push_back(a_ptr);
43 p_b_grids.push_back(b_ptr);
46 const uint64_t footprint = (size_a + size_b);
47 const uint64_t max_rotating_count = (1ULL << 31) / footprint;
48 rotating_count =
std::min(rotating_count, max_rotating_count);
51 for(
size_t i = 1; i < rotating_count; i++)
57 const_cast<void*
>(p_a_grids[0]),
59 hipMemcpyDeviceToDevice));
60 p_a_grids.push_back(pADeviceBuf);
67 const_cast<void*
>(p_b_grids[0]),
69 hipMemcpyDeviceToDevice));
70 p_b_grids.push_back(pBDeviceBuf);
78 if(rotating_count > 1)
80 std::size_t idx = iter++ % rotating_count;
81 a_ptr = p_a_grids[idx];
82 b_ptr = p_b_grids[idx];
87 std::cout <<
"RotatingMemWrapper: { size_a: " << size_a <<
", size_b: " << size_b
88 <<
", rotating_count: " << rotating_count <<
"}" << std::endl;
93 if(rotating_count > 1)
100 for(
size_t i = 1; i < rotating_count; i++)
111 std::size_t iter = 0;
112 std::size_t rotating_count = 1;
113 std::size_t size_a = 0;
114 std::size_t size_b = 0;
115 std::vector<const void*> p_a_grids;
116 std::vector<const void*> p_b_grids;
120 hipDeviceProp_t deviceProps;
126 constexpr
int32_t blocks_per_cu = 60;
127 int32_t gpu_block3 = deviceProps.multiProcessorCount * blocks_per_cu;
129 ck_tile::flush_cache<<<dim3(gpu_block3), dim3(64), 0,
nullptr>>>();
#define HIP_CHECK_ERROR(retval_or_funcall)
Definition: hip_check_error.hpp:21
__host__ constexpr __device__ T min(T x)
Definition: math.hpp:116
Definition: cluster_descriptor.hpp:13
CK_TILE_HOST void hip_check_error(hipError_t x)
Definition: hip_check_error.hpp:13
int32_t int32_t
Definition: integer.hpp:10
void flush_icache()
Definition: rotating_buffers.hpp:118
unsigned __int64 uint64_t
Definition: stdint.h:136
Definition: rotating_buffers.hpp:28
void Print()
Definition: rotating_buffers.hpp:85
void Next()
Definition: rotating_buffers.hpp:76
RotatingMemWrapper(const void *a_ptr_, const void *b_ptr_, std::size_t rotating_count_hint, std::size_t size_a_, std::size_t size_b_)
Definition: rotating_buffers.hpp:30
RotatingMemWrapper()=delete
~RotatingMemWrapper() noexcept
Definition: rotating_buffers.hpp:91