Skip to content

Conversation

v-klochkov
Copy link
Contributor

@v-klochkov v-klochkov commented Aug 25, 2022

The template argument for saturation was declared/used such a way
that any type could be passed to it, which would cause enforcement of
saturation when not intended.
In even worse scenarios the DPAS call with 3 simd arguments was
recognized as DPAS with 2 simd arguments + saturation argument:
dpas(src0,src1,src2) was treated as dpas(src1,src2,sat),
which caused totally incorrect behavior at runtime.

Also, this patch fixes the incorrect detection of ops_per_channel for
tfloat32 type on HOST.

The corresponding LIT test: intel/llvm-test-suite#1180

Signed-off-by: Vyacheslav N Klochkov [email protected]

The template argument for saturation was declared/used such a way
that any type could be passed to it, which would cause enforcement of
saturation when not intended.
In even worse scenarios the DPAS call with 3 simd arguments was
recognized as DPAS with 2 simd arguments + saturation argument:
dpas(src0,src1,src2) was treated as dpas(src1,src2,sat),
which caused totally incorrect behavior at runtime.

Also, this patch fixes the incorrect detection of ops_per_channel for
tfloat32 type on HOST.

Signed-off-by: Vyacheslav N Klochkov <[email protected]>
@@ -449,7 +449,10 @@ __esimd_dpas_inner(const __ESIMD_DNS::vector_type_t<T0, SZ> *src0,
__ESIMD_EMU_DNS::is_inttype<RT>::value>::set();

constexpr __ESIMD_NS::uint ops_per_chan =
src1_precision == __ESIMD_ENS::argument_type::BF16 ||
src1_precision == __ESIMD_ENS::argument_type::TF32 ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: seems this logic overlaps with __esimd_dpas_bits_precision. As a variant:

constexpr auto nbits1 = __esimd_dpas_bits_precision<src1_precision>();
constexpr auto nbits2 = __esimd_dpas_bits_precision<src2_precision>();
constexpr auto nbits = max(nbits1, nbits2);
constexpr __ESIMD_NS::uint ops_per_chan = std::min(32 / nbits, 8);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Fixed in c3b1981

@v-klochkov v-klochkov merged commit 6636103 into intel:sycl Aug 29, 2022
@v-klochkov v-klochkov deleted the esimd_fix_sat_usage branch August 29, 2022 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants