MCPcopy Create free account
hub / github.com/NVIDIA/cutlass / cooperative_prefetch

Function cooperative_prefetch

include/cute/algorithm/prefetch.hpp:46–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44template <uint32_t NumThreads, uint32_t FetchBytes = 64,
45 class GEngine, class GLayout>
46CUTE_HOST_DEVICE
47void
48cooperative_prefetch(uint32_t const& tid,
49 Tensor<GEngine, GLayout> const& src)
50{
51 static_assert(is_gmem<GEngine>::value, "Expected global tensor for prefetch");
52
53 constexpr int V = decltype(max_common_vector(src, src))::value;
54
55 if constexpr (V > 1) {
56 // L2 sector is 32B, default fetch granularity is 64B
57 using VecType = conditional_t<(V * sizeof_bits_v<typename GEngine::value_type>) < (FetchBytes * 8),
58 ArrayEngine<typename GEngine::value_type, V>,
59 uint8_t[FetchBytes] >;
60
61 Tensor src_v = recast<VecType const>(src);
62 CUTE_UNROLL
63 for (int i = tid; i < size(src_v); i += NumThreads) {
64 prefetch(raw_pointer_cast(&src_v(i)));
65 }
66 } else {
67 CUTE_UNROLL
68 for (int i = tid; i < size(src); i += NumThreads) {
69 prefetch(raw_pointer_cast(&src(i)));
70 }
71 }
72}
73
74template <class GEngine, class GLayout>
75CUTE_HOST_DEVICE

Callers

nothing calls this directly

Calls 4

prefetchFunction · 0.70
max_common_vectorFunction · 0.50
sizeFunction · 0.50
raw_pointer_castFunction · 0.50

Tested by

no test coverage detected