@@ -95,6 +95,20 @@ ESIMD_INLINE simd<T, N> lsc_format_ret(simd<T1, N> Vals) {
95
95
}
96
96
}
97
97
98
+ // / Extracts a cache hint with the given 'Level' to pass it to
99
+ // / ESIMD/GENX intrinsics. If `PropertyListT` does not have the requested
100
+ // / cache-hint, then 'cache_hint::none' is returned.
101
+ template <typename PropertyListT, cache_level Level>
102
+ constexpr cache_hint getCacheHintForIntrin () {
103
+ static_assert (Level == cache_level::L1 || Level == cache_level::L2,
104
+ " ESIMD/GENX intrinsics accept only L1/L2 cache hints" );
105
+ if constexpr (Level == cache_level::L1) {
106
+ return getPropertyValue<PropertyListT, cache_hint_L1_key>(cache_hint::none);
107
+ } else {
108
+ return getPropertyValue<PropertyListT, cache_hint_L2_key>(cache_hint::none);
109
+ }
110
+ }
111
+
98
112
// / USM pointer gather.
99
113
// / Supported platforms: DG2, PVC
100
114
// / VISA instruction: lsc_load.ugm
@@ -123,10 +137,8 @@ __ESIMD_API simd<T, N * NElts> gather_impl(const T *p, simd<OffsetT, N> offsets,
123
137
check_lsc_vector_size<NElts>();
124
138
check_lsc_data_size<T, DS>();
125
139
check_cache_hints<cache_action::load, PropertyListT>();
126
- constexpr cache_hint L1H =
127
- getPropertyValue<PropertyListT, cache_hint_L1_key>(cache_hint::none);
128
- constexpr cache_hint L2H =
129
- getPropertyValue<PropertyListT, cache_hint_L2_key>(cache_hint::none);
140
+ constexpr auto L1H = getCacheHintForIntrin<PropertyListT, cache_level::L1>();
141
+ constexpr auto L2H = getCacheHintForIntrin<PropertyListT, cache_level::L2>();
130
142
constexpr uint16_t AddressScale = 1 ;
131
143
constexpr int ImmOffset = 0 ;
132
144
constexpr lsc_data_size EDS = expand_data_size (finalize_data_size<T, DS>());
@@ -167,10 +179,8 @@ __ESIMD_API void scatter_impl(T *p, simd<Toffset, N> offsets,
167
179
check_lsc_vector_size<NElts>();
168
180
check_lsc_data_size<T, DS>();
169
181
check_cache_hints<cache_action::store, PropertyListT>();
170
- constexpr cache_hint L1H =
171
- getPropertyValue<PropertyListT, cache_hint_L1_key>(cache_hint::none);
172
- constexpr cache_hint L2H =
173
- getPropertyValue<PropertyListT, cache_hint_L2_key>(cache_hint::none);
182
+ constexpr auto L1H = getCacheHintForIntrin<PropertyListT, cache_level::L1>();
183
+ constexpr auto L2H = getCacheHintForIntrin<PropertyListT, cache_level::L2>();
174
184
constexpr uint16_t AddressScale = 1 ;
175
185
constexpr int ImmOffset = 0 ;
176
186
constexpr lsc_data_size EDS = expand_data_size (finalize_data_size<T, DS>());
@@ -904,10 +914,8 @@ block_load_impl(const T *p, simd_mask<1> pred, simd<T, NElts> pass_thru) {
904
914
using LoadElemT = __ESIMD_DNS::__raw_t <
905
915
std::conditional_t <SmallIntFactor == 1 , T,
906
916
std::conditional_t <Use64BitData, uint64_t , uint32_t >>>;
907
- constexpr cache_hint L1H =
908
- getPropertyValue<PropertyListT, cache_hint_L1_key>(cache_hint::none);
909
- constexpr cache_hint L2H =
910
- getPropertyValue<PropertyListT, cache_hint_L2_key>(cache_hint::none);
917
+ constexpr auto L1H = getCacheHintForIntrin<PropertyListT, cache_level::L1>();
918
+ constexpr auto L2H = getCacheHintForIntrin<PropertyListT, cache_level::L2>();
911
919
912
920
constexpr uint16_t AddressScale = 1 ;
913
921
constexpr int ImmOffset = 0 ;
@@ -1005,10 +1013,8 @@ __ESIMD_API
1005
1013
using LoadElemT = __ESIMD_DNS::__raw_t <
1006
1014
std::conditional_t <SmallIntFactor == 1 , T,
1007
1015
std::conditional_t <Use64BitData, uint64_t , uint32_t >>>;
1008
- constexpr cache_hint L1H =
1009
- getPropertyValue<PropertyListT, cache_hint_L1_key>(cache_hint::none);
1010
- constexpr cache_hint L2H =
1011
- getPropertyValue<PropertyListT, cache_hint_L2_key>(cache_hint::none);
1016
+ constexpr auto L1H = getCacheHintForIntrin<PropertyListT, cache_level::L1>();
1017
+ constexpr auto L2H = getCacheHintForIntrin<PropertyListT, cache_level::L2>();
1012
1018
constexpr uint16_t AddressScale = 1 ;
1013
1019
constexpr int ImmOffset = 0 ;
1014
1020
constexpr lsc_data_size ActualDS =
@@ -1105,10 +1111,8 @@ __ESIMD_API
1105
1111
using LoadElemT = __ESIMD_DNS::__raw_t <
1106
1112
std::conditional_t <SmallIntFactor == 1 , T,
1107
1113
std::conditional_t <Use64BitData, uint64_t , uint32_t >>>;
1108
- constexpr cache_hint L1H =
1109
- getPropertyValue<PropertyListT, cache_hint_L1_key>(cache_hint::none);
1110
- constexpr cache_hint L2H =
1111
- getPropertyValue<PropertyListT, cache_hint_L2_key>(cache_hint::none);
1114
+ constexpr auto L1H = getCacheHintForIntrin<PropertyListT, cache_level::L1>();
1115
+ constexpr auto L2H = getCacheHintForIntrin<PropertyListT, cache_level::L2>();
1112
1116
constexpr uint16_t AddressScale = 1 ;
1113
1117
constexpr int ImmOffset = 0 ;
1114
1118
constexpr lsc_data_size ActualDS =
@@ -1165,10 +1169,8 @@ block_store_impl(T *p, simd<T, NElts> vals, simd_mask<1> pred) {
1165
1169
using StoreType = __ESIMD_DNS::__raw_t <
1166
1170
std::conditional_t <SmallIntFactor == 1 , T,
1167
1171
std::conditional_t <Use64BitData, uint64_t , uint32_t >>>;
1168
- constexpr cache_hint L1H =
1169
- getPropertyValue<PropertyListT, cache_hint_L1_key>(cache_hint::none);
1170
- constexpr cache_hint L2H =
1171
- getPropertyValue<PropertyListT, cache_hint_L2_key>(cache_hint::none);
1172
+ constexpr auto L1H = getCacheHintForIntrin<PropertyListT, cache_level::L1>();
1173
+ constexpr auto L2H = getCacheHintForIntrin<PropertyListT, cache_level::L2>();
1172
1174
constexpr uint16_t AddressScale = 1 ;
1173
1175
constexpr int ImmOffset = 0 ;
1174
1176
constexpr lsc_data_size ActualDS =
@@ -1230,10 +1232,8 @@ __ESIMD_API
1230
1232
using StoreElemT = __ESIMD_DNS::__raw_t <
1231
1233
std::conditional_t <SmallIntFactor == 1 , T,
1232
1234
std::conditional_t <Use64BitData, uint64_t , uint32_t >>>;
1233
- constexpr cache_hint L1H =
1234
- getPropertyValue<PropertyListT, cache_hint_L1_key>(cache_hint::none);
1235
- constexpr cache_hint L2H =
1236
- getPropertyValue<PropertyListT, cache_hint_L2_key>(cache_hint::none);
1235
+ constexpr auto L1H = getCacheHintForIntrin<PropertyListT, cache_level::L1>();
1236
+ constexpr auto L2H = getCacheHintForIntrin<PropertyListT, cache_level::L2>();
1237
1237
constexpr uint16_t AddressScale = 1 ;
1238
1238
constexpr int ImmOffset = 0 ;
1239
1239
constexpr lsc_data_size ActualDS =
@@ -2586,10 +2586,8 @@ scatter_impl(AccessorTy acc, simd<OffsetT, N> offsets, simd<T, N * NElts> vals,
2586
2586
check_lsc_vector_size<NElts>();
2587
2587
check_lsc_data_size<T, DS>();
2588
2588
check_cache_hints<cache_action::store, PropertyListT>();
2589
- constexpr cache_hint L1H =
2590
- getPropertyValue<PropertyListT, cache_hint_L1_key>(cache_hint::none);
2591
- constexpr cache_hint L2H =
2592
- getPropertyValue<PropertyListT, cache_hint_L2_key>(cache_hint::none);
2589
+ constexpr auto L1H = getCacheHintForIntrin<PropertyListT, cache_level::L1>();
2590
+ constexpr auto L2H = getCacheHintForIntrin<PropertyListT, cache_level::L2>();
2593
2591
constexpr uint16_t AddressScale = 1 ;
2594
2592
constexpr int ImmOffset = 0 ;
2595
2593
constexpr lsc_data_size EDS = expand_data_size (finalize_data_size<T, DS>());
@@ -2686,10 +2684,8 @@ gather_impl(AccessorT acc, simd<OffsetT, N / VS> byte_offsets,
2686
2684
constexpr lsc_vector_size LSCVS = to_lsc_vector_size<VS>();
2687
2685
constexpr auto Transposed = lsc_data_order::nontranspose;
2688
2686
using MsgT = typename lsc_expand_type<T>::type;
2689
- constexpr cache_hint L1H =
2690
- getPropertyValue<PropertyListT, cache_hint_L1_key>(cache_hint::none);
2691
- constexpr cache_hint L2H =
2692
- getPropertyValue<PropertyListT, cache_hint_L2_key>(cache_hint::none);
2687
+ constexpr auto L1H = getCacheHintForIntrin<PropertyListT, cache_level::L1>();
2688
+ constexpr auto L2H = getCacheHintForIntrin<PropertyListT, cache_level::L2>();
2693
2689
auto SI = get_surface_index (acc);
2694
2690
simd<uint32_t , N / VS> ByteOffsets32 = convert<uint32_t >(byte_offsets);
2695
2691
simd<MsgT, N> PassThruExpanded = lsc_format_input<MsgT>(pass_thru);
@@ -2793,10 +2789,8 @@ __ESIMD_API void prefetch_impl(const T *p, simd<Toffset, N> byte_offsets,
2793
2789
check_lsc_vector_size<NElts>();
2794
2790
check_lsc_data_size<T, DS>();
2795
2791
check_cache_hints<cache_action::prefetch, PropertyListT>();
2796
- constexpr cache_hint L1H =
2797
- getPropertyValue<PropertyListT, cache_hint_L1_key>(cache_hint::none);
2798
- constexpr cache_hint L2H =
2799
- getPropertyValue<PropertyListT, cache_hint_L2_key>(cache_hint::none);
2792
+ constexpr auto L1H = getCacheHintForIntrin<PropertyListT, cache_level::L1>();
2793
+ constexpr auto L2H = getCacheHintForIntrin<PropertyListT, cache_level::L2>();
2800
2794
constexpr uint16_t AddressScale = 1 ;
2801
2795
constexpr int ImmOffset = 0 ;
2802
2796
constexpr lsc_data_size EDS = expand_data_size (finalize_data_size<T, DS>());
@@ -2817,10 +2811,8 @@ prefetch_impl(const T *p, Toffset offset, simd_mask<1> pred) {
2817
2811
check_lsc_vector_size<NElts>();
2818
2812
check_lsc_data_size<T, DS>();
2819
2813
check_cache_hints<cache_action::prefetch, PropertyListT>();
2820
- constexpr cache_hint L1H =
2821
- getPropertyValue<PropertyListT, cache_hint_L1_key>(cache_hint::none);
2822
- constexpr cache_hint L2H =
2823
- getPropertyValue<PropertyListT, cache_hint_L2_key>(cache_hint::none);
2814
+ constexpr auto L1H = getCacheHintForIntrin<PropertyListT, cache_level::L1>();
2815
+ constexpr auto L2H = getCacheHintForIntrin<PropertyListT, cache_level::L2>();
2824
2816
constexpr uint16_t AddressScale = 1 ;
2825
2817
constexpr int ImmOffset = 0 ;
2826
2818
constexpr lsc_data_size EDS = finalize_data_size<T, DS>();
@@ -2872,10 +2864,8 @@ prefetch_impl(AccessorTy acc, simd<OffsetT, N> byte_offsets,
2872
2864
check_lsc_vector_size<NElts>();
2873
2865
check_lsc_data_size<T, DS>();
2874
2866
check_cache_hints<cache_action::prefetch, PropertyListT>();
2875
- constexpr cache_hint L1H =
2876
- getPropertyValue<PropertyListT, cache_hint_L1_key>(cache_hint::none);
2877
- constexpr cache_hint L2H =
2878
- getPropertyValue<PropertyListT, cache_hint_L2_key>(cache_hint::none);
2867
+ constexpr auto L1H = getCacheHintForIntrin<PropertyListT, cache_level::L1>();
2868
+ constexpr auto L2H = getCacheHintForIntrin<PropertyListT, cache_level::L2>();
2879
2869
constexpr uint16_t AddressScale = 1 ;
2880
2870
constexpr int ImmOffset = 0 ;
2881
2871
constexpr lsc_data_size EDS = expand_data_size (finalize_data_size<T, DS>());
@@ -2919,10 +2909,8 @@ prefetch_impl(AccessorTy acc, OffsetT byte_offset, simd_mask<1> pred) {
2919
2909
check_lsc_vector_size<NElts>();
2920
2910
check_lsc_data_size<T, DS>();
2921
2911
check_cache_hints<cache_action::prefetch, PropertyListT>();
2922
- constexpr cache_hint L1H =
2923
- getPropertyValue<PropertyListT, cache_hint_L1_key>(cache_hint::none);
2924
- constexpr cache_hint L2H =
2925
- getPropertyValue<PropertyListT, cache_hint_L2_key>(cache_hint::none);
2912
+ constexpr auto L1H = getCacheHintForIntrin<PropertyListT, cache_level::L1>();
2913
+ constexpr auto L2H = getCacheHintForIntrin<PropertyListT, cache_level::L2>();
2926
2914
constexpr uint16_t AddressScale = 1 ;
2927
2915
constexpr int ImmOffset = 0 ;
2928
2916
constexpr lsc_data_size EDS = finalize_data_size<T, DS>();
@@ -3058,10 +3046,8 @@ __ESIMD_API simd<T, N> load_2d_impl(const T *Ptr, unsigned SurfaceWidth,
3058
3046
unsigned SurfacePitch, int X, int Y) {
3059
3047
3060
3048
check_cache_hints<cache_action::load, PropertyListT>();
3061
- constexpr cache_hint L1H =
3062
- getPropertyValue<PropertyListT, cache_hint_L1_key>(cache_hint::none);
3063
- constexpr cache_hint L2H =
3064
- getPropertyValue<PropertyListT, cache_hint_L2_key>(cache_hint::none);
3049
+ constexpr auto L1H = getCacheHintForIntrin<PropertyListT, cache_level::L1>();
3050
+ constexpr auto L2H = getCacheHintForIntrin<PropertyListT, cache_level::L2>();
3065
3051
using RawT = __raw_t <T>;
3066
3052
check_lsc_block_2d_restrictions<RawT, BlockWidth, BlockHeight, NBlocks,
3067
3053
Transposed, Transformed, block_2d_op::load>();
@@ -3172,10 +3158,8 @@ __ESIMD_API void prefetch_2d_impl(const T *Ptr, unsigned SurfaceWidth,
3172
3158
check_cache_hints<cache_action::prefetch, PropertyListT>();
3173
3159
check_lsc_block_2d_restrictions<RawT, BlockWidth, BlockHeight, NBlocks, false ,
3174
3160
false , block_2d_op::prefetch>();
3175
- constexpr cache_hint L1H =
3176
- getPropertyValue<PropertyListT, cache_hint_L1_key>(cache_hint::none);
3177
- constexpr cache_hint L2H =
3178
- getPropertyValue<PropertyListT, cache_hint_L2_key>(cache_hint::none);
3161
+ constexpr auto L1H = getCacheHintForIntrin<PropertyListT, cache_level::L1>();
3162
+ constexpr auto L2H = getCacheHintForIntrin<PropertyListT, cache_level::L2>();
3179
3163
constexpr lsc_data_size DS =
3180
3164
finalize_data_size<RawT, lsc_data_size::default_size>();
3181
3165
uintptr_t Addr = reinterpret_cast <uintptr_t >(Ptr);
@@ -3220,10 +3204,8 @@ __ESIMD_API void store_2d_impl(T *Ptr, unsigned SurfaceWidth,
3220
3204
using RawT = __raw_t <T>;
3221
3205
__ESIMD_DNS::check_cache_hints<__ESIMD_DNS::cache_action::store,
3222
3206
PropertyListT>();
3223
- constexpr cache_hint L1H =
3224
- getPropertyValue<PropertyListT, cache_hint_L1_key>(cache_hint::none);
3225
- constexpr cache_hint L2H =
3226
- getPropertyValue<PropertyListT, cache_hint_L2_key>(cache_hint::none);
3207
+ constexpr auto L1H = getCacheHintForIntrin<PropertyListT, cache_level::L1>();
3208
+ constexpr auto L2H = getCacheHintForIntrin<PropertyListT, cache_level::L2>();
3227
3209
check_lsc_block_2d_restrictions<RawT, BlockWidth, BlockHeight, 1 , false ,
3228
3210
false , block_2d_op::store>();
3229
3211
constexpr lsc_data_size DS =
@@ -6164,10 +6146,8 @@ atomic_update_impl(T *p, simd<Toffset, N> offsets, simd_mask<N> pred) {
6164
6146
check_atomic<Op, T, N, 0 , /* IsLSC*/ true >();
6165
6147
check_lsc_data_size<T, DS>();
6166
6148
check_cache_hints<cache_action::atomic, PropertyListT>();
6167
- constexpr cache_hint L1H =
6168
- getPropertyValue<PropertyListT, cache_hint_L1_key>(cache_hint::none);
6169
- constexpr cache_hint L2H =
6170
- getPropertyValue<PropertyListT, cache_hint_L2_key>(cache_hint::none);
6149
+ constexpr auto L1H = getCacheHintForIntrin<PropertyListT, cache_level::L1>();
6150
+ constexpr auto L2H = getCacheHintForIntrin<PropertyListT, cache_level::L2>();
6171
6151
constexpr uint16_t AddressScale = 1 ;
6172
6152
constexpr int ImmOffset = 0 ;
6173
6153
constexpr lsc_data_size EDS = expand_data_size (finalize_data_size<T, DS>());
@@ -6208,10 +6188,8 @@ atomic_update_impl(T *p, simd<Toffset, N> offsets, simd<T, N> src0,
6208
6188
check_lsc_data_size<T, DS>();
6209
6189
check_atomic<Op, T, N, 1 , /* IsLSC*/ true >();
6210
6190
check_cache_hints<cache_action::atomic, PropertyListT>();
6211
- constexpr cache_hint L1H =
6212
- getPropertyValue<PropertyListT, cache_hint_L1_key>(cache_hint::none);
6213
- constexpr cache_hint L2H =
6214
- getPropertyValue<PropertyListT, cache_hint_L2_key>(cache_hint::none);
6191
+ constexpr auto L1H = getCacheHintForIntrin<PropertyListT, cache_level::L1>();
6192
+ constexpr auto L2H = getCacheHintForIntrin<PropertyListT, cache_level::L2>();
6215
6193
constexpr uint16_t AddressScale = 1 ;
6216
6194
constexpr int ImmOffset = 0 ;
6217
6195
constexpr lsc_data_size EDS = expand_data_size (finalize_data_size<T, DS>());
@@ -6254,10 +6232,8 @@ atomic_update_impl(T *p, simd<Toffset, N> offsets, simd<T, N> src0,
6254
6232
check_lsc_data_size<T, DS>();
6255
6233
check_atomic<Op, T, N, 2 , /* IsLSC*/ true >();
6256
6234
check_cache_hints<cache_action::atomic, PropertyListT>();
6257
- constexpr cache_hint L1H =
6258
- getPropertyValue<PropertyListT, cache_hint_L1_key>(cache_hint::none);
6259
- constexpr cache_hint L2H =
6260
- getPropertyValue<PropertyListT, cache_hint_L2_key>(cache_hint::none);
6235
+ constexpr auto L1H = getCacheHintForIntrin<PropertyListT, cache_level::L1>();
6236
+ constexpr auto L2H = getCacheHintForIntrin<PropertyListT, cache_level::L2>();
6261
6237
constexpr uint16_t AddressScale = 1 ;
6262
6238
constexpr int ImmOffset = 0 ;
6263
6239
constexpr lsc_data_size EDS = expand_data_size (finalize_data_size<T, DS>());
@@ -6310,10 +6286,8 @@ __ESIMD_API
6310
6286
check_lsc_data_size<T, DS>();
6311
6287
check_atomic<Op, T, N, 0 , /* IsLSC*/ true >();
6312
6288
check_cache_hints<cache_action::atomic, PropertyListT>();
6313
- constexpr cache_hint L1H =
6314
- getPropertyValue<PropertyListT, cache_hint_L1_key>(cache_hint::none);
6315
- constexpr cache_hint L2H =
6316
- getPropertyValue<PropertyListT, cache_hint_L2_key>(cache_hint::none);
6289
+ constexpr auto L1H = getCacheHintForIntrin<PropertyListT, cache_level::L1>();
6290
+ constexpr auto L2H = getCacheHintForIntrin<PropertyListT, cache_level::L2>();
6317
6291
constexpr uint16_t AddressScale = 1 ;
6318
6292
constexpr int ImmOffset = 0 ;
6319
6293
constexpr lsc_data_size EDS = expand_data_size (finalize_data_size<T, DS>());
@@ -6365,10 +6339,8 @@ __ESIMD_API
6365
6339
check_lsc_data_size<T, DS>();
6366
6340
check_atomic<Op, T, N, 1 , /* IsLSC*/ true >();
6367
6341
check_cache_hints<cache_action::atomic, PropertyListT>();
6368
- constexpr cache_hint L1H =
6369
- getPropertyValue<PropertyListT, cache_hint_L1_key>(cache_hint::none);
6370
- constexpr cache_hint L2H =
6371
- getPropertyValue<PropertyListT, cache_hint_L2_key>(cache_hint::none);
6342
+ constexpr auto L1H = getCacheHintForIntrin<PropertyListT, cache_level::L1>();
6343
+ constexpr auto L2H = getCacheHintForIntrin<PropertyListT, cache_level::L2>();
6372
6344
constexpr uint16_t AddressScale = 1 ;
6373
6345
constexpr int ImmOffset = 0 ;
6374
6346
constexpr lsc_data_size EDS = expand_data_size (finalize_data_size<T, DS>());
@@ -6422,10 +6394,8 @@ __ESIMD_API
6422
6394
check_lsc_data_size<T, DS>();
6423
6395
check_atomic<Op, T, N, 2 , /* IsLSC*/ true >();
6424
6396
check_cache_hints<cache_action::atomic, PropertyListT>();
6425
- constexpr cache_hint L1H =
6426
- getPropertyValue<PropertyListT, cache_hint_L1_key>(cache_hint::none);
6427
- constexpr cache_hint L2H =
6428
- getPropertyValue<PropertyListT, cache_hint_L2_key>(cache_hint::none);
6397
+ constexpr auto L1H = getCacheHintForIntrin<PropertyListT, cache_level::L1>();
6398
+ constexpr auto L2H = getCacheHintForIntrin<PropertyListT, cache_level::L2>();
6429
6399
constexpr uint16_t AddressScale = 1 ;
6430
6400
constexpr int ImmOffset = 0 ;
6431
6401
constexpr lsc_data_size EDS = expand_data_size (finalize_data_size<T, DS>());
0 commit comments