Skip to content

Commit

Permalink
Add check for source arguments of lsc atomics
Browse files Browse the repository at this point in the history
 Add check for source arguments of lsc atomics
  • Loading branch information
NikitaRudenkoIntel authored and Konstantin Vladimirov committed Jan 20, 2022
1 parent cced9a9 commit 047e15d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions clang/lib/Headers/cm/include/cm/cm_lsc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,8 @@ cm_atomic(SurfaceIndex Idx, vector<unsigned, N> Offset,
CM_STATIC_ERROR(lsc_check_simt<N>(), "unexpected number of channels");
CM_STATIC_ERROR((lsc_check_cache_hint<LSCAction::Atomic, L1H, L3H>()),
"unsupported cache hint");
CM_STATIC_ERROR(lsc_check_atomic_src<T>(),
"unsupported type for lsc atomic source or dest arguments");
constexpr DataSize _DS = lsc_expand_ds(lsc_data_size<T, DS>());
constexpr bool _Transposed = false;
using _IntRetTy = decltype(lsc_data_type_ext<T, N, VS>());
Expand Down Expand Up @@ -1166,6 +1168,8 @@ cm_atomic(SurfaceIndex Idx, vector<unsigned, N> Offset,
CM_STATIC_ERROR(lsc_check_simt<N>(), "unexpected number of channels");
CM_STATIC_ERROR((lsc_check_cache_hint<LSCAction::Atomic, L1H, L3H>()),
"unsupported cache hint");
CM_STATIC_ERROR(lsc_check_atomic_src<T>(),
"unsupported type for lsc atomic source or dest arguments");
constexpr DataSize _DS = lsc_expand_ds(lsc_data_size<T, DS>());
using _IntRetTy = decltype(lsc_data_type_ext<T, N, VS>());
using _SrcTy = decltype(lsc_data_type_ext<T, N, VS>());
Expand Down Expand Up @@ -1223,6 +1227,8 @@ cm_ptr_atomic(T *Ptr, vector<unsigned, N> Offset,
CM_STATIC_ERROR(lsc_check_simt<N>(), "unexpected number of channels");
CM_STATIC_ERROR((lsc_check_cache_hint<LSCAction::Atomic, L1H, L3H>()),
"unsupported cache hint");
CM_STATIC_ERROR(lsc_check_atomic_src<T>(),
"unsupported type for lsc atomic source or dest arguments");
constexpr DataSize _DS = lsc_expand_ds(lsc_data_size<T, DS>());
constexpr bool _Transposed = false;
uint64_t _Addr = (uint64_t)Ptr;
Expand Down Expand Up @@ -1254,6 +1260,8 @@ cm_ptr_atomic(T *Ptr, vector<unsigned, N> Offset,
CM_STATIC_ERROR(lsc_check_simt<N>(), "unexpected number of channels");
CM_STATIC_ERROR((lsc_check_cache_hint<LSCAction::Atomic, L1H, L3H>()),
"unsupported cache hint");
CM_STATIC_ERROR(lsc_check_atomic_src<T>(),
"unsupported type for lsc atomic source or dest arguments");
constexpr DataSize _DS = lsc_expand_ds(lsc_data_size<T, DS>());
using _IntRetTy = decltype(lsc_data_type_ext<T, N, VS>());
using _SrcTy = decltype(lsc_data_type_ext<T, N, VS>());
Expand Down Expand Up @@ -1336,6 +1344,8 @@ cm_atomic_slm(vector<unsigned, N> Offset,
CM_STATIC_ERROR(lsc_check_simt<N>(), "unexpected number of channels");
CM_STATIC_ERROR((lsc_check_cache_hint<LSCAction::Atomic, L1H, L3H>()),
"unsupported cache hint");
CM_STATIC_ERROR(lsc_check_atomic_src<T>(),
"unsupported type for lsc atomic source or dest arguments");
constexpr DataSize _DS = lsc_expand_ds(lsc_data_size<T, DS>());
constexpr bool _Transposed = false;
using _IntRetTy = decltype(lsc_data_type_ext<T, N, VS>());
Expand Down Expand Up @@ -1366,6 +1376,8 @@ cm_atomic_slm(vector<unsigned, N> Offset,
CM_STATIC_ERROR(lsc_check_simt<N>(), "unexpected number of channels");
CM_STATIC_ERROR((lsc_check_cache_hint<LSCAction::Atomic, L1H, L3H>()),
"unsupported cache hint");
CM_STATIC_ERROR(lsc_check_atomic_src<T>(),
"unsupported type for lsc atomic source or dest arguments");
constexpr DataSize _DS = lsc_expand_ds(lsc_data_size<T, DS>());
using _IntRetTy = decltype(lsc_data_type_ext<T, N, VS>());
using _SrcTy = decltype(lsc_data_type_ext<T, N, VS>());
Expand Down
7 changes: 7 additions & 0 deletions clang/lib/Headers/cm/include/cm/cm_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,13 @@ constexpr bool lsc_check_simt() {
#endif // CM_GENX >= 1280
}

// Check for valid type for atomic source and dest arguments
template <typename T>
constexpr bool lsc_check_atomic_src() {
// 8-bit atomics are unsupported
return sizeof(T) >= 2;
}

template <CacheHint mHint> class CacheHintWrap {
template <CacheHint...> class is_one_of_t;
template <CacheHint Last>
Expand Down

0 comments on commit 047e15d

Please sign in to comment.