XeTLA v0.3.6
IntelĀ® Xe Templates for Linear Algebra - API Definition Document
 
Loading...
Searching...
No Matches
bit_mask_manipulation.hpp
Go to the documentation of this file.
1/*******************************************************************************
2* Copyright (c) 2022-2023 Intel Corporation
3*
4* Licensed under the Apache License, Version 2.0 (the "License");
5* you may not use this file except in compliance with the License.
6* You may obtain a copy of the License at
7*
8* http://www.apache.org/licenses/LICENSE-2.0
9*
10* Unless required by applicable law or agreed to in writing, software
11* distributed under the License is distributed on an "AS IS" BASIS,
12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13* See the License for the specific language governing permissions and
14* limitations under the License.
15*******************************************************************************/
16
19
20#pragma once
21
24
25#pragma clang diagnostic push
26#pragma clang diagnostic ignored "-Wunused-parameter"
27namespace gpu::xetla {
28
31
42template <typename T0, typename T1, int SZ, typename U,
43 class Sat = xetla_saturation_off_tag>
45 xetla_vector<T1, SZ> src0, U src1, Sat sat = {}) {
46 return __ESIMD_ENS::shl<T0, T1, SZ, U, typename Sat::sat_tag>(
47 src0, src1, Sat::value);
48}
49
59template <typename T0, typename T1, typename T2,
60 class Sat = xetla_saturation_off_tag>
61typename std::remove_const<T0>::type xetla_shl(T1 src0, T2 src1, Sat sat = {}) {
62 return __ESIMD_ENS::shl<T0, T1, T2, typename Sat::sat_tag>(
63 src0, src1, Sat::value);
64}
65
76template <typename T0, typename T1, int SZ, typename U,
77 class Sat = xetla_saturation_off_tag>
79 xetla_vector<T1, SZ> src0, U src1, Sat sat = {}) {
80 return __ESIMD_ENS::shr<T0, T1, SZ, U, typename Sat::sat_tag>(
81 src0, src1, Sat::value);
82}
83
93template <typename T0, typename T1, typename T2,
94 class Sat = xetla_saturation_off_tag>
95__XETLA_API typename std::remove_const<T0>::type xetla_shr(
96 T1 src0, T2 src1, Sat sat = {}) {
97 return __ESIMD_ENS::shr<T0, T1, T2, typename Sat::sat_tag>(
98 src0, src1, Sat::value);
99}
100
109template <typename T0, typename T1, int SZ>
112 return __ESIMD_ENS::rol<T0, T1, SZ>(src0, src1);
113}
114
123template <typename T0, typename T1, int SZ, typename U>
124__XETLA_API std::enable_if_t<std::is_integral<T0>::value
125 && std::is_integral<T1>::value && std::is_integral<U>::value
126 && is_xetla_scalar<U>::value,
127 xetla_vector<T0, SZ>>
129 return __ESIMD_ENS::rol<T0, T1, SZ, U>(src0, src1);
130}
131
139template <typename T0, typename T1, typename T2>
140__XETLA_API std::enable_if_t<std::is_integral<T0>::value
141 && std::is_integral<T1>::value && std::is_integral<T2>::value,
143xetla_rol(T1 src0, T2 src1) {
144 return __ESIMD_ENS::rol<T0, T1, T2>(src0, src1);
145}
146
155template <typename T0, typename T1, int SZ>
158 return __ESIMD_ENS::ror<T0, T1, SZ>(src0, src1);
159}
160
169template <typename T0, typename T1, int SZ, typename U>
170__XETLA_API std::enable_if_t<std::is_integral<T0>::value
171 && std::is_integral<T1>::value && std::is_integral<U>::value
172 && is_xetla_scalar<U>::value,
173 xetla_vector<T0, SZ>>
175 return __ESIMD_ENS::ror<T0, T1, SZ, U>(src0, src1);
176}
177
185template <typename T0, typename T1, typename T2>
186__XETLA_API std::enable_if_t<std::is_integral<T0>::value
187 && std::is_integral<T1>::value && std::is_integral<T2>::value,
189xetla_ror(T1 src0, T2 src1) {
190 return __ESIMD_ENS::ror<T0, T1, T2>(src0, src1);
191}
192
203template <typename T0, typename T1, int SZ, typename U,
204 class Sat = xetla_saturation_off_tag>
206 xetla_vector<T1, SZ> src0, U src1, Sat sat = {}) {
207 return __ESIMD_ENS::lsr<T0, T1, SZ, U, typename Sat::sat_tag>(
208 src0, src1, Sat::value);
209}
210
221template <typename T0, typename T1, typename T2,
222 class Sat = xetla_saturation_off_tag>
223__XETLA_API typename std::remove_const<T0>::type xetla_lsr(
224 T1 src0, T2 src1, Sat sat = {}) {
225 return __ESIMD_ENS::lsr<T0, T1, T2, typename Sat::sat_tag>(
226 src0, src1, Sat::value);
227}
228
239template <typename T0, typename T1, int SZ, typename U,
240 class Sat = xetla_saturation_off_tag>
242 xetla_vector<T1, SZ> src0, U src1, Sat sat = {}) {
243 return __ESIMD_ENS::asr<T0, T1, SZ, U, typename Sat::sat_tag>(
244 src0, src1, Sat::value);
245}
246
257template <typename T0, typename T1, typename T2,
258 class Sat = xetla_saturation_off_tag>
259__XETLA_API typename std::remove_const<T0>::type xetla_asr(
260 T1 src0, T2 src1, Sat sat = {}) {
261 return __ESIMD_ENS::asr<T0, T1, T2, typename Sat::sat_tag>(
262 src0, src1, Sat::value);
263}
264
273template <int N>
275 return __ESIMD_NS::pack_mask<N>(src0);
276}
277
285template <int N>
287 return __ESIMD_NS::unpack_mask<N>(src0);
288}
289
291
292} // namespace gpu::xetla
293#pragma clang diagnostic pop
C++ API.
typename std::remove_const< T >::type remove_const_t
Definition common.hpp:26
#define __XETLA_API
Definition common.hpp:43
__ESIMD_NS::simd< native_type_t< Ty >, N > xetla_vector
wrapper for xetla_vector.
Definition base_types.hpp:149
__ESIMD_NS::simd_mask< N > xetla_mask
wrapper for xetla_mask.
Definition base_types.hpp:165
__XETLA_API xetla_mask< N > xetla_unpack_mask(uint32_t src0)
Unpack an unsigned 32-bit integer value into a xetla_mask.
Definition bit_mask_manipulation.hpp:286
__XETLA_API xetla_vector< T0, SZ > xetla_asr(xetla_vector< T1, SZ > src0, U src1, Sat sat={})
Arithmetical Shift Right (vector version)
Definition bit_mask_manipulation.hpp:241
__XETLA_API xetla_vector< T0, SZ > xetla_rol(xetla_vector< T1, SZ > src0, xetla_vector< T1, SZ > src1)
Rotate left operation with two vector inputs.
Definition bit_mask_manipulation.hpp:110
__XETLA_API xetla_vector< T0, SZ > xetla_shr(xetla_vector< T1, SZ > src0, U src1, Sat sat={})
Shift right operation (vector version)
Definition bit_mask_manipulation.hpp:78
__XETLA_API xetla_vector< T0, SZ > xetla_lsr(xetla_vector< T1, SZ > src0, U src1, Sat sat={})
Logical Shift Right (vector version)
Definition bit_mask_manipulation.hpp:205
__XETLA_API uint32_t xetla_pack_mask(xetla_mask< N > src0)
Pack a xetla_mask into a single unsigned 32-bit integer value.
Definition bit_mask_manipulation.hpp:274
__XETLA_API xetla_vector< T0, SZ > xetla_ror(xetla_vector< T1, SZ > src0, xetla_vector< T1, SZ > src1)
Rotate right operation with two vector inputs.
Definition bit_mask_manipulation.hpp:156
__XETLA_API xetla_vector< T0, SZ > xetla_shl(xetla_vector< T1, SZ > src0, U src1, Sat sat={})
Shift left operation (vector version)
Definition bit_mask_manipulation.hpp:44
Definition arch_config.hpp:24