Skip to content

Commit e9b8f43

Browse files
[SYCL] extract_bits function is specified to be const. Updating declaration. (#4702)
Signed-off-by: Chris Perkins <[email protected]>
1 parent 973aee9 commit e9b8f43

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

sycl/doc/extensions/SubGroupMask/SubGroupMask.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ struct sub_group_mask {
274274
void insert_bits(const T &bits, id<1> pos = 0);
275275
276276
template <typename T>
277-
void extract_bits(T &out, id<1> pos = 0);
277+
void extract_bits(T &out, id<1> pos = 0) const;
278278
279279
void set();
280280
void set(id<1> id, bool value = true);

sycl/include/sycl/ext/oneapi/sub_group_mask.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ struct sub_group_mask {
124124

125125
template <typename Type,
126126
typename = sycl::detail::enable_if_t<std::is_integral<Type>::value>>
127-
void extract_bits(Type &bits, id<1> pos = 0) {
127+
void extract_bits(Type &bits, id<1> pos = 0) const {
128128
uint32_t Res = Bits;
129129
if (pos.get(0) < size()) {
130130
if (pos.get(0) > 0) {

sycl/test/extensions/sub_group_mask.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,17 @@ int main() {
7777
b.insert_bits(sycl::marray<char, 8>{1, 2, 4, 8, 16, 32, 64, 128}, 5);
7878
assert(!b[18] && !b[20] && !b[22] && !b[24] && !b[30] && !b[16] && b[3] &&
7979
b[5] && b[14] && b[23]);
80-
char r;
80+
char r, rbc;
81+
const auto b_const{b};
8182
b.extract_bits(r);
83+
b_const.extract_bits(rbc);
8284
assert(r == 0b00101000);
83-
long r2 = -1;
85+
assert(rbc == 0b00101000);
86+
long r2 = -1, r2bc = -1;
8487
b.extract_bits(r2, 16);
88+
b_const.extract_bits(r2bc, 16);
8589
assert(r2 == 128);
90+
assert(r2bc == 128);
8691
b[31] = true;
8792
sycl::marray<char, 6> r3{-1};
8893
b.extract_bits(r3, 14);

0 commit comments

Comments
 (0)