Skip to content
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

[SYCL][ESIMD] Add support for different types for lsc functions #6952

Merged
merged 5 commits into from
Oct 6, 2022

Conversation

fineg74
Copy link
Contributor

@fineg74 fineg74 commented Oct 4, 2022

No description provided.

@fineg74
Copy link
Contributor Author

fineg74 commented Oct 4, 2022

Complementary test PR intel/llvm-test-suite#1305

Comment on lines 188 to 189
using type =
typename std::conditional<sizeof(T) <= 4, int32_t, int64_t>::type;
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor comment: this can be shortened to 1 line:

Suggested change
using type =
typename std::conditional<sizeof(T) <= 4, int32_t, int64_t>::type;
using type = std::conditional_t<sizeof(T) <= 4, uint32_t, uint64_t>;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

without typename it gives a compilation error for some reason

Copy link
Contributor

Choose a reason for hiding this comment

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

it fails if only remove 'typename', but it should pass if also add "_t" to std::conditional

public:
using type =
typename std::conditional<sizeof(_type2) == 1, _type2, _type1>::type;
using type = typename std::conditional_t<
Copy link
Contributor

@v-klochkov v-klochkov Oct 4, 2022

Choose a reason for hiding this comment

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

L194: 'typename' is not needed with std::conditional_t

Comment on lines 194 to 199
using type = typename std::conditional_t<
sizeof(T) == 1, int8_t,
std::conditional_t<
sizeof(T) == 2, int16_t,
std::conditional_t<sizeof(T) == 4, int32_t,
std::conditional_t<sizeof(T) == 8, int64_t, T>>>>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Was the switch from unsigned types to signed intentional? I see in other places unsigned type is still used.
If either (signed or unsigned) works fine, then you can just re-use the existing __ESIMD_DNS::uint_type_t

Suggested change
using type = typename std::conditional_t<
sizeof(T) == 1, int8_t,
std::conditional_t<
sizeof(T) == 2, int16_t,
std::conditional_t<sizeof(T) == 4, int32_t,
std::conditional_t<sizeof(T) == 8, int64_t, T>>>>;
using type = __ESIMD_DNS::uint_type_t<sizeof(T)>;

@@ -449,7 +449,8 @@ __ESIMD_API std::enable_if_t<!std::is_pointer<AccessorTy>::value,
lsc_gather(AccessorTy acc, __ESIMD_NS::simd<uint32_t, N> offsets,
__ESIMD_NS::simd_mask<N> pred = 1) {
#ifdef __ESIMD_FORCE_STATELESS_MEM
return lsc_gather<T, N, DS, L1H>(acc.get_pointer().get(), offsets, pred);
return lsc_gather<T, NElts, DS, L1H, L3H>(acc.get_pointer().get(), offsets,
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch, thank you for fixing this!

__esimd_lsc_load_bti<uint32_t, L1H, L3H, _AddressScale, _ImmOffset,
lsc_data_size::u32, _VS, _Transposed, N>(
pred.data(), offsets.data(), si);
return result.template bit_cast_view<T>();
Copy link
Contributor

Choose a reason for hiding this comment

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

@kbobrovs - accordingly to your experience, is this bit_cast_view() always optimized away if the type is already integral?
If not, then it probably makes sense to write something like:

if constexpr (std::is_integral_v<T>) {
    return __esimd_lsc_load_bit<....>(....); 
} else {
    result = __esimd_lsc_load_bit<uint..., >(....);
    return result.template bit_cast_view<T>();
}

What is your recommendation here?

Copy link
Contributor

Choose a reason for hiding this comment

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

It is optimized, but I'd prefer sycl::bit_cast instead in such cases.

__esimd_lsc_load_stateless<uint32_t, L1H, L3H, _AddressScale,
_ImmOffset, lsc_data_size::u32, _VS,
_Transposed, N>(pred.data(), addrs.data());
return result.template bit_cast_view<T>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I suggest to use sycl::bit_cast when view is not really needed (like in this case)

Copy link
Contributor

@v-klochkov v-klochkov left a comment

Choose a reason for hiding this comment

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

Approved taking into account that the functionality is needed and also the accidental/wrong merge of intel/llvm-test-suite#1305
Please though make additional effort trying using sycl::bit_cast instead of bit_cast_view() in follow-up PR.

@pvchupin pvchupin merged commit d9e40ec into intel:sycl Oct 6, 2022
@fineg74 fineg74 deleted the lsc_float branch October 6, 2022 19:32
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.

4 participants