Skip to content

[SYCL][ESIMD][NFC] Replace the uses of std::max in ESIMD with ternary op #11847

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 1 commit into from
Nov 10, 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
16 changes: 7 additions & 9 deletions sycl/include/sycl/ext/intel/esimd/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ block_load_impl(const T *p, simd_mask<1> pred, FlagsT flags) {

constexpr int SmallIntFactor64Bit = sizeof(uint64_t) / sizeof(T);
constexpr int SmallIntFactor32Bit =
(std::max)(static_cast<size_t>(1), sizeof(uint32_t) / sizeof(T));
sizeof(uint32_t) / sizeof(T) > 1 ? sizeof(uint32_t) / sizeof(T) : 1;
static_assert(NElts > 0 && NElts % SmallIntFactor32Bit == 0,
"Number of elements is not supported by Transposed load");

Expand Down Expand Up @@ -333,7 +333,7 @@ block_load_impl(const T *p, simd_mask<1> pred, simd<T, NElts> pass_thru,

constexpr int SmallIntFactor64Bit = sizeof(uint64_t) / sizeof(T);
constexpr int SmallIntFactor32Bit =
(std::max)(static_cast<size_t>(1), sizeof(uint32_t) / sizeof(T));
sizeof(uint32_t) / sizeof(T) > 1 ? sizeof(uint32_t) / sizeof(T) : 1;
static_assert(NElts > 0 && NElts % SmallIntFactor32Bit == 0,
"Number of elements is not supported by Transposed load");

Expand Down Expand Up @@ -430,7 +430,7 @@ __ESIMD_API

constexpr int SmallIntFactor64Bit = sizeof(uint64_t) / sizeof(T);
constexpr int SmallIntFactor32Bit =
(std::max)(static_cast<size_t>(1), sizeof(uint32_t) / sizeof(T));
sizeof(uint32_t) / sizeof(T) > 1 ? sizeof(uint32_t) / sizeof(T) : 1;
static_assert(NElts > 0 && NElts % SmallIntFactor32Bit == 0,
"Number of elements is not supported by Transposed load");

Expand Down Expand Up @@ -529,7 +529,7 @@ __ESIMD_API

constexpr int SmallIntFactor64Bit = sizeof(uint64_t) / sizeof(T);
constexpr int SmallIntFactor32Bit =
(std::max)(static_cast<size_t>(1), sizeof(uint32_t) / sizeof(T));
sizeof(uint32_t) / sizeof(T) > 1 ? sizeof(uint32_t) / sizeof(T) : 1;
static_assert(NElts > 0 && NElts % SmallIntFactor32Bit == 0,
"Number of elements is not supported by Transposed load");

Expand Down Expand Up @@ -586,9 +586,7 @@ block_store_impl(T *p, simd<T, NElts> vals, simd_mask<1> pred, FlagsT flags) {

constexpr int SmallIntFactor64Bit = sizeof(uint64_t) / sizeof(T);
constexpr int SmallIntFactor32Bit =
sizeof(uint32_t) / sizeof(T) > static_cast<size_t>(1)
? sizeof(uint32_t) / sizeof(T)
: static_cast<size_t>(1);
sizeof(uint32_t) / sizeof(T) > 1 ? sizeof(uint32_t) / sizeof(T) : 1;
static_assert(NElts > 0 && NElts % SmallIntFactor32Bit == 0,
"Number of elements is not supported by Transposed store");

Expand Down Expand Up @@ -2614,7 +2612,7 @@ slm_block_load(uint32_t byte_offset, simd_mask<1> pred,

constexpr int SmallIntFactor64Bit = sizeof(uint64_t) / sizeof(T);
constexpr int SmallIntFactor32Bit =
(std::max)(static_cast<size_t>(1), sizeof(uint32_t) / sizeof(T));
sizeof(uint32_t) / sizeof(T) > 1 ? sizeof(uint32_t) / sizeof(T) : 1;
static_assert(N > 0 && N % SmallIntFactor32Bit == 0,
"Number of elements is not supported by Transposed load");

Expand Down Expand Up @@ -2700,7 +2698,7 @@ slm_block_load(uint32_t offset, simd_mask<1> pred, simd<T, N> pass_thru,

constexpr int SmallIntFactor64Bit = sizeof(uint64_t) / sizeof(T);
constexpr int SmallIntFactor32Bit =
(std::max)(static_cast<size_t>(1), sizeof(uint32_t) / sizeof(T));
sizeof(uint32_t) / sizeof(T) > 1 ? sizeof(uint32_t) / sizeof(T) : 1;
static_assert(N > 0 && N % SmallIntFactor32Bit == 0,
"Number of elements is not supported by Transposed load");

Expand Down
5 changes: 4 additions & 1 deletion sycl/include/sycl/ext/intel/esimd/xmx/dpas.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,11 @@ constexpr int verify_parameters_and_deduce_exec_size() {
"Cannot deduce element size of input arguments");
verify_repeat_count<RepeatCount, AElemBitSize, BElemBitSize, IsDPASW>();

constexpr int MaxElemBitSize =
AElemBitSize > BElemBitSize ? AElemBitSize : BElemBitSize;
constexpr int MaxElemsInDword = 32 / MaxElemBitSize;
constexpr int OpsPerChannel =
(std::max)((std::min)(32 / (std::max)(AElemBitSize, BElemBitSize), 8), 1);
MaxElemsInDword > 8 ? 8 : (MaxElemsInDword < 1 ? 1 : MaxElemsInDword);

// A(_Mx_K) * B(_Kx_N) + C(_Mx_N)
// where:
Expand Down