Skip to content

[SYCL][ESIMD] Add supported versions of raw_send APIs #11333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sycl/include/sycl/ext/intel/esimd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
/// @defgroup sycl_esimd_raw_send Raw send APIs.
/// Implements the \c send instruction to send messages to variaous components
/// of the Intel(R) processor graphics, as defined in the documentation at
/// https://01.org/sites/default/files/documentation/intel-gfx-prm-osrc-icllp-vol02a-commandreference-instructions_2.pdf
/// https://www.intel.com/content/www/us/en/docs/graphics-for-linux/developer-reference/1-0/hardware-specs.html

/// @defgroup sycl_esimd_misc Miscellaneous ESIMD convenience functions.

Expand Down
12 changes: 12 additions & 0 deletions sycl/include/sycl/ext/intel/esimd/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ enum class rgba_channel : uint8_t { R, G, B, A };
/// identified by its "binding table index" - surface index.
using SurfaceIndex = unsigned int;

/// Specify if end of thread should be set.
enum class raw_send_eot : uint8_t {
not_eot = 0,
eot = 1,
};

/// Specify if sendc should be used.
enum class raw_send_sendc : uint8_t {
not_sendc = 0,
sendc = 1,
};

namespace detail {

// Type used in internal functions to designate SLM access by
Expand Down
164 changes: 164 additions & 0 deletions sycl/include/sycl/ext/intel/esimd/detail/memory_intrin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,4 +581,168 @@ ESIMD_INLINE __ESIMD_NS::SurfaceIndex __esimd_get_surface_index(MemObjTy obj)
}
#endif // __SYCL_DEVICE_ONLY__

// \brief Raw sends.
//
// @param modifier the send message flags (Bit-0: isSendc, Bit-1: isEOT).
//
// @param execSize the execution size, which must be a compile time constant.
//
// @param pred the predicate to specify enabled channels.
//
// @param numSrc0 the number of GRFs for source-0, which must be a compile time
// constant.
//
// @param numSrc1 the number of GRFs for source-1, which must be a compile time
// constant.
//
// @param numDst the number of GRFs for destination, which must be a compile
// time constant.
//
// @param sfid the shared function ID, which must be a compile time constant.
//
// @param exDesc the extended message descriptor.
//
// @param msgDesc the message descriptor.
//
// @param msgSrc0 the first source operand of send message.
//
// @param msgSrc1 the second source operand of send message.
//
// @param msgDst the destination operand of send message.
//
// Returns a simd vector of type Ty1 and size N1.
//
template <typename Ty1, int N1, typename Ty2, int N2, typename Ty3, int N3,
int N = 16>
__ESIMD_INTRIN __ESIMD_DNS::vector_type_t<Ty1, N1>
__esimd_raw_sends2(uint8_t modifier, uint8_t execSize,
__ESIMD_DNS::simd_mask_storage_t<N> pred, uint8_t numSrc0,
uint8_t numSrc1, uint8_t numDst, uint8_t sfid,
uint32_t exDesc, uint32_t msgDesc,
__ESIMD_DNS::vector_type_t<Ty2, N2> msgSrc0,
__ESIMD_DNS::vector_type_t<Ty3, N3> msgSrc1,
__ESIMD_DNS::vector_type_t<Ty1, N1> msgDst)
#ifdef __SYCL_DEVICE_ONLY__
;
#else
{
__ESIMD_UNSUPPORTED_ON_HOST;
}
#endif // __SYCL_DEVICE_ONLY__

// \brief Raw send.
//
// @param modifier the send message flags (Bit-0: isSendc, Bit-1: isEOT).
//
// @param execSize the execution size, which must be a compile time constant.
//
// @param pred the predicate to specify enabled channels.
//
// @param numSrc0 the number of GRFs for source-0, which must be a compile time
// constant.
//
// @param numDst the number of GRFs for destination, which must be a compile
// time constant.
//
// @param sfid the shared function ID, which must be a compile time constant.
//
// @param exDesc the extended message descriptor.
//
// @param msgDesc the message descriptor.
//
// @param msgSrc0 the first source operand of send message.
//
// @param msgDst the destination operand of send message.
//
// Returns a simd vector of type Ty1 and size N1.
//
template <typename Ty1, int N1, typename Ty2, int N2, int N = 16>
__ESIMD_INTRIN __ESIMD_DNS::vector_type_t<Ty1, N1>
__esimd_raw_send2(uint8_t modifier, uint8_t execSize,
__ESIMD_DNS::simd_mask_storage_t<N> pred, uint8_t numSrc0,
uint8_t numDst, uint8_t sfid, uint32_t exDesc,
uint32_t msgDesc, __ESIMD_DNS::vector_type_t<Ty2, N2> msgSrc0,
__ESIMD_DNS::vector_type_t<Ty1, N1> msgDst)
#ifdef __SYCL_DEVICE_ONLY__
;
#else
{
__ESIMD_UNSUPPORTED_ON_HOST;
}
#endif // __SYCL_DEVICE_ONLY__

// \brief Raw sends.
//
// @param modifier the send message flags (Bit-0: isSendc, Bit-1: isEOT).
//
// @param execSize the execution size, which must be a compile time constant.
//
// @param pred the predicate to specify enabled channels.
//
// @param numSrc0 the number of GRFs for source-0, which must be a compile time
// constant.
//
// @param numSrc1 the number of GRFs for source-1, which must be a compile time
// constant.
//
// @param sfid the shared function ID, which must be a compile time constant.
//
// @param exDesc the extended message descriptor.
//
// @param msgDesc the message descriptor.
//
// @param msgSrc0 the first source operand of send message.
//
// @param msgSrc1 the second source operand of send message.
//
template <typename Ty1, int N1, typename Ty2, int N2, int N = 16>
__ESIMD_INTRIN void
__esimd_raw_sends2_noresult(uint8_t modifier, uint8_t execSize,
__ESIMD_DNS::simd_mask_storage_t<N> pred,
uint8_t numSrc0, uint8_t numSrc1, uint8_t sfid,
uint32_t exDesc, uint32_t msgDesc,
__ESIMD_DNS::vector_type_t<Ty1, N1> msgSrc0,
__ESIMD_DNS::vector_type_t<Ty2, N2> msgSrc1)
#ifdef __SYCL_DEVICE_ONLY__
;
#else
{
__ESIMD_UNSUPPORTED_ON_HOST;
}
#endif // __SYCL_DEVICE_ONLY__

// \brief Raw send.
//
// @param modifier the send message flags (Bit-0: isSendc, Bit-1: isEOT).
//
// @param execSize the execution size, which must be a compile time constant.
//
// @param pred the predicate to specify enabled channels.
//
// @param numSrc0 the number of GRFs for source-0, which must be a compile time
// constant.
//
// @param sfid the shared function ID, which must be a compile time constant.
//
// @param exDesc the extended message descriptor.
//
// @param msgDesc the message descriptor.
//
// @param msgSrc0 the first source operand of send message.
//
template <typename Ty1, int N1, int N = 16>
__ESIMD_INTRIN void
__esimd_raw_send2_noresult(uint8_t modifier, uint8_t execSize,
__ESIMD_DNS::simd_mask_storage_t<N> pred,
uint8_t numSrc0, uint8_t sfid, uint32_t exDesc,
uint32_t msgDesc,
__ESIMD_DNS::vector_type_t<Ty1, N1> msgSrc0)
#ifdef __SYCL_DEVICE_ONLY__
;
#else
{
__ESIMD_UNSUPPORTED_ON_HOST;
}
#endif // __SYCL_DEVICE_ONLY__

/// @endcond ESIMD_DETAIL
164 changes: 164 additions & 0 deletions sycl/include/sycl/ext/intel/esimd/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2313,6 +2313,170 @@ scatter_rgba(AccessorT acc, simd<uint32_t, N> offsets,
__ESIMD_DNS::localAccessorToOffset(acc),
vals, mask);
}

/// @addtogroup sycl_esimd_raw_send
/// @{

/// Raw sends. "s" suffix designates "split" variant - i.e. two sources.
/// This is a low-level API not recommended for general usage.
///
/// @tparam exec_size is the execution size.
/// @tparam sfid is the shared function ID.
/// @tparam num_src0 is the number of GRFs for source-0.
/// @tparam num_src1 is the number of GRFs for source-1.
/// @tparam num_dst is the number of GRFs for destination.
/// @tparam eot is the flag that indicates whether this is an EOT message
/// (optional - default to off).
/// @tparam sendc is the flag that indicates whether sendc should be used
/// (optional - default to off).
/// @param msg_dst is the old value of the destination operand.
/// @param msg_src0 is the first source operand of send message.
/// @param msg_src1 is the second source operand of send message.
/// @param ex_desc is the extended message descriptor.
/// @param msg_desc is the message descriptor.
/// @param mask is the predicate to specify enabled channels (optional - default
/// to on).
/// @return the vector value read from memory.
template <uint8_t exec_size, uint8_t sfid, uint8_t num_src0, uint8_t num_src1,
uint8_t num_dst, raw_send_eot eot = raw_send_eot::not_eot,
raw_send_sendc sendc = raw_send_sendc::not_sendc, typename T1, int n1,
typename T2, int n2, typename T3, int n3>
__ESIMD_API __ESIMD_NS::simd<T1, n1>
raw_sends(__ESIMD_NS::simd<T1, n1> msg_dst, __ESIMD_NS::simd<T2, n2> msg_src0,
__ESIMD_NS::simd<T3, n3> msg_src1, uint32_t ex_desc,
uint32_t msg_desc, __ESIMD_NS::simd_mask<exec_size> mask = 1) {
constexpr unsigned _Width1 = n1 * sizeof(T1);
static_assert(_Width1 % 32 == 0, "Invalid size for raw send rspVar");
constexpr unsigned _Width2 = n2 * sizeof(T2);
static_assert(_Width2 % 32 == 0, "Invalid size for raw send msg_src0");
constexpr unsigned _Width3 = n3 * sizeof(T3);
static_assert(_Width3 % 32 == 0, "Invalid size for raw send msg_src1");

using ElemT1 = __ESIMD_DNS::__raw_t<T1>;
using ElemT2 = __ESIMD_DNS::__raw_t<T2>;
using ElemT3 = __ESIMD_DNS::__raw_t<T3>;

constexpr uint8_t modifier =
((eot == raw_send_eot::eot) << 1) | (sendc == raw_send_sendc::sendc);

return __esimd_raw_sends2<ElemT1, n1, ElemT2, n2, ElemT3, n3, exec_size>(
modifier, exec_size, mask.data(), num_src0, num_src1, num_dst, sfid,
ex_desc, msg_desc, msg_src0.data(), msg_src1.data(), msg_dst.data());
}

/// Raw send. This is a low-level API not recommended for general usage.
///
/// @tparam exec_size is the execution size.
/// @tparam sfid is the shared function ID.
/// @tparam num_src0 is the number of GRFs for source-0.
/// @tparam num_dst is the number of GRFs for destination.
/// @tparam eot is the flag that indicates whether this is an EOT message
/// (optional - default to off).
/// @tparam sendc is the flag that indicates whether sendc should be used
/// (optional - default to off).
/// @param msg_dst is the old value of the destination operand.
/// @param msg_src0 is the first source operand of send message.
/// @param ex_desc is the extended message descriptor.
/// @param msg_desc is the message descriptor.
/// @param mask is the predicate to specify enabled channels (optional - default
/// to on).
/// @return the vector value read from memory
template <uint8_t exec_size, uint8_t sfid, uint8_t num_src0, uint8_t num_dst,
raw_send_eot eot = raw_send_eot::not_eot,
raw_send_sendc sendc = raw_send_sendc::not_sendc, typename T1, int n1,
typename T2, int n2>
__ESIMD_API __ESIMD_NS::simd<T1, n1>
raw_send(__ESIMD_NS::simd<T1, n1> msg_dst, __ESIMD_NS::simd<T2, n2> msg_src0,
uint32_t ex_desc, uint32_t msg_desc,
__ESIMD_NS::simd_mask<exec_size> mask = 1) {
constexpr unsigned _Width1 = n1 * sizeof(T1);
static_assert(_Width1 % 32 == 0, "Invalid size for raw send rspVar");
constexpr unsigned _Width2 = n2 * sizeof(T2);
static_assert(_Width2 % 32 == 0, "Invalid size for raw send msg_src0");

using ElemT1 = __ESIMD_DNS::__raw_t<T1>;
using ElemT2 = __ESIMD_DNS::__raw_t<T2>;

constexpr uint8_t modifier =
((eot == raw_send_eot::eot) << 1) | (sendc == raw_send_sendc::sendc);
return __esimd_raw_send2<ElemT1, n1, ElemT2, n2, exec_size>(
modifier, exec_size, mask.data(), num_src0, num_dst, sfid, ex_desc,
msg_desc, msg_src0.data(), msg_dst.data());
}

/// Raw sends. "s" suffix designates "split" variant - i.e. two sources.
/// This is a low-level API not recommended for general usage.
///
/// @tparam exec_size is the execution size.
/// @tparam sfid is the shared function ID.
/// @tparam num_src0 is the number of GRFs for source-0.
/// @tparam num_src1 is the number of GRFs for source-1.
/// @tparam eot is the flag that indicates whether this is an EOT message
/// (optional - default to off).
/// @tparam sendc is the flag that indicates whether sendc should be used
/// (optional - default to off).
/// @param msg_src0 is the first source operand of send message.
/// @param msg_src1 is the second source operand of send message.
/// @param ex_desc is the extended message descriptor.
/// @param msg_desc is the message descriptor.
/// @param mask is the predicate to specify enabled channels (optional - default
/// to on).
template <uint8_t exec_size, uint8_t sfid, uint8_t num_src0, uint8_t num_src1,
raw_send_eot eot = raw_send_eot::not_eot,
raw_send_sendc sendc = raw_send_sendc::not_sendc, typename T1, int n1,
typename T2, int n2>
__ESIMD_API void raw_sends(__ESIMD_NS::simd<T1, n1> msg_src0,
__ESIMD_NS::simd<T2, n2> msg_src1, uint32_t ex_desc,
uint32_t msg_desc,
__ESIMD_NS::simd_mask<exec_size> mask = 1) {
constexpr unsigned _Width1 = n1 * sizeof(T1);
static_assert(_Width1 % 32 == 0, "Invalid size for raw send msg_src0");
constexpr unsigned _Width2 = n2 * sizeof(T2);
static_assert(_Width2 % 32 == 0, "Invalid size for raw send msg_src1");

using ElemT1 = __ESIMD_DNS::__raw_t<T1>;
using ElemT2 = __ESIMD_DNS::__raw_t<T2>;

constexpr uint8_t modifier =
((eot == raw_send_eot::eot) << 1) | (sendc == raw_send_sendc::sendc);
__esimd_raw_sends2_noresult<ElemT1, n1, ElemT2, n2, exec_size>(
modifier, exec_size, mask.data(), num_src0, num_src1, sfid, ex_desc,
msg_desc, msg_src0.data(), msg_src1.data());
}

/// Raw send. Generates a \c send or \c sendc instruction for the message
/// gateway. This is a low-level API not recommended for general usage.
///
/// @tparam exec_size is the execution size.
/// @tparam sfid is the shared function ID.
/// @tparam num_src0 is the number of GRFs for source-0.
/// @tparam eot is the flag that indicates whether this is an EOT message
/// (optional - default to off).
/// @tparam sendc is the flag that indicates whether sendc should be used
/// (optional - default to off).
/// @param msg_src0 is the first source operand of send message.
/// @param ex_desc is the extended message descriptor.
/// @param msg_desc is the message descriptor.
/// @param mask is the predicate to specify enabled channels (optional - default
/// to on).
template <uint8_t exec_size, uint8_t sfid, uint8_t num_src0,
raw_send_eot eot = raw_send_eot::not_eot,
raw_send_sendc sendc = raw_send_sendc::not_sendc, typename T1, int n1>
__ESIMD_API void raw_send(__ESIMD_NS::simd<T1, n1> msg_src0, uint32_t ex_desc,
uint32_t msg_desc,
__ESIMD_NS::simd_mask<exec_size> mask = 1) {
constexpr unsigned _Width1 = n1 * sizeof(T1);
static_assert(_Width1 % 32 == 0, "Invalid size for raw send msg_src0");
using ElemT1 = __ESIMD_DNS::__raw_t<T1>;
constexpr uint8_t modifier =
((eot == raw_send_eot::eot) << 1) | (sendc == raw_send_sendc::sendc);
__esimd_raw_send2_noresult<ElemT1, n1, exec_size>(
modifier, exec_size, mask.data(), num_src0, sfid, ex_desc, msg_desc,
msg_src0.data());
}

/// @} sycl_esimd_raw_send

/// @} sycl_esimd_memory

/// @cond EXCLUDE
Expand Down
Loading