Skip to content

Commit 5b77c1e

Browse files
authored
[NFC][ESIMD] Move slm_allocator out of experimental namespace (#13901)
The slm_allocator class was not in experimental namespace in the file containing definitions for experimental functions, likely by mistake, so moved it to non experimental include file and moved intrinsics to avoid confusion
1 parent f9d870e commit 5b77c1e

File tree

4 files changed

+35
-34
lines changed

4 files changed

+35
-34
lines changed

sycl/include/sycl/ext/intel/esimd/detail/memory_intrin.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,4 +1160,8 @@ __ESIMD_INTRIN void
11601160
__esimd_nbarrier_arrive(uint8_t id, uint8_t thread_role, uint8_t num_producers,
11611161
uint8_t num_consumers) __ESIMD_INTRIN_END;
11621162

1163+
__ESIMD_INTRIN uint32_t __esimd_slm_alloc(uint32_t size) __ESIMD_INTRIN_END;
1164+
1165+
__ESIMD_INTRIN void __esimd_slm_free(uint32_t id) __ESIMD_INTRIN_END;
1166+
11631167
/// @endcond ESIMD_DETAIL

sycl/include/sycl/ext/intel/esimd/memory.hpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4502,6 +4502,37 @@ constexpr void check_atomic() {
45024502
/// @addtogroup sycl_esimd_memory_slm
45034503
/// @{
45044504

4505+
/// RAII-style class used to implement "semi-dynamic" SLM allocation.
4506+
/// SLM is allocated in the constructor and released in the destructor, that's
4507+
/// why it is "dynamic", as opposed to fully static allocation style of
4508+
/// 'slm_init'. Actual offset of SLM chunk allocated by the call is calculated
4509+
/// at compile time, that's why it is "semi-". To calculate SLM usage by a
4510+
/// kernel, compiler finds a path in a callgraph with the largest amount of SLM
4511+
/// "locked" by slm_allocator objects live along the paths. slm_init call also
4512+
/// participates in calculating SLM budget. It can be modelled as
4513+
/// \c slm_allocator object declared at the very beginning of a kernel and live
4514+
/// till its the very end.
4515+
/// Only compile-time constant SLM amount is supported for now, it is provided
4516+
/// as a class' template argument.
4517+
///
4518+
/// Since a call graph is used, function pointers and recursion is not
4519+
/// supported.
4520+
///
4521+
/// @tparam SLMAmount The amount allocated in bytes
4522+
template <int SLMAmount> class slm_allocator {
4523+
int offset;
4524+
4525+
public:
4526+
/// Allocates the amount of SLM which is class' template parameter.
4527+
slm_allocator() { offset = __esimd_slm_alloc(SLMAmount); }
4528+
4529+
/// @return The allocated chunk's offset in bytes.
4530+
ESIMD_INLINE int get_offset() const { return offset; }
4531+
4532+
/// Releases the SLM chunk allocated in the constructor.
4533+
~slm_allocator() { __esimd_slm_free(offset); }
4534+
};
4535+
45054536
/// Declare per-work-group slm size.
45064537
/// GPU RT/driver requires this function to be called in the beginning
45074538
/// of the kernel using SLM. There must be only 1 call site of slm_init()

sycl/include/sycl/ext/intel/experimental/esimd/detail/memory_intrin.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ template <__ESIMD_ENS::lsc_memory_kind Kind, __ESIMD_ENS::lsc_fence_op FenceOp,
3838
__ESIMD_INTRIN void
3939
__esimd_lsc_fence(__ESIMD_DNS::simd_mask_storage_t<N> pred) __ESIMD_INTRIN_END;
4040

41-
__ESIMD_INTRIN uint32_t __esimd_slm_alloc(uint32_t size) __ESIMD_INTRIN_END;
42-
43-
__ESIMD_INTRIN void __esimd_slm_free(uint32_t id) __ESIMD_INTRIN_END;
4441
__ESIMD_INTRIN uint8_t __esimd_named_barrier_allocate(uint8_t NbarCount)
4542
__ESIMD_INTRIN_END;
4643

sycl/include/sycl/ext/intel/experimental/esimd/memory.hpp

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2938,37 +2938,6 @@ atomic_update(AccessorTy acc, Toffset offset, simd<T, N> src0, simd<T, N> src1,
29382938
acc, offset, src1, src0, mask);
29392939
}
29402940

2941-
/// RAII-style class used to implement "semi-dynamic" SLM allocation.
2942-
/// SLM is allocated in the constructor and released in the destructor, that's
2943-
/// why it is "dynamic", as opposed to fully static allocation style of
2944-
/// 'slm_init'. Actual offset of SLM chunk allocated by the call is calculated
2945-
/// at compile time, that's why it is "semi-". To calculate SLM usage by a
2946-
/// kernel, compiler finds a path in a callgraph with the largest amount of SLM
2947-
/// "locked" by slm_allocator objects live along the paths. slm_init call also
2948-
/// participates in calculating SLM budget. It can be modelled as
2949-
/// \c slm_allocator object declared at the very beginning of a kernel and live
2950-
/// till its the very end.
2951-
/// Only compile-time constant SLM amount is supported for now, it is provided
2952-
/// as a class' template argument.
2953-
///
2954-
/// Since a call graph is used, function pointers and recursion is not
2955-
/// supported.
2956-
///
2957-
/// @tparam SLMAmount The amount allocated in bytes
2958-
template <int SLMAmount> class slm_allocator {
2959-
int offset;
2960-
2961-
public:
2962-
/// Allocates the amount of SLM which is class' template parameter.
2963-
slm_allocator() { offset = __esimd_slm_alloc(SLMAmount); }
2964-
2965-
/// @return The allocated chunk's offset in bytes.
2966-
ESIMD_INLINE int get_offset() const { return offset; }
2967-
2968-
/// Releases the SLM chunk allocated in the constructor.
2969-
~slm_allocator() { __esimd_slm_free(offset); }
2970-
};
2971-
29722941
} // namespace esimd
29732942
} // namespace ext::intel
29742943
} // namespace _V1

0 commit comments

Comments
 (0)