Skip to content

Commit f3abf58

Browse files
[SYCL][E2E] Split vector scalar operator ordering test (#12953)
This commit splits the vec_binary_scalar_order test to improve coverage and reduce the compile-time overhead. --------- Signed-off-by: Larsen, Steffen <[email protected]>
1 parent 7e1bf63 commit f3abf58

File tree

5 files changed

+163
-55
lines changed

5 files changed

+163
-55
lines changed

sycl/test-e2e/Basic/vector/vec_binary_scalar_order.cpp renamed to sycl/test-e2e/Basic/vector/vec_binary_scalar_order.hpp

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
// REQUIRES: preview-breaking-changes-supported
2-
// RUN: %{build} -fpreview-breaking-changes -o %t.out
3-
// RUN: %{run} %t.out
1+
// Header with helper macros for testing vec binary operators.
42

5-
// This test currently fails on AMD HIP due to an unresolved memcmp function.
6-
// XFAIL: hip_amd
3+
#pragma once
74

8-
// Checks scalar/vec operator ordering.
9-
10-
#include <sycl.hpp>
5+
#include <sycl/sycl.hpp>
116

127
template <typename T>
138
using rel_t = std::conditional_t<
@@ -101,50 +96,3 @@ bool CheckResult(sycl::vec<T1, N> V, T2 Ref) {
10196
CHECK(Q, C, T, 4, IS_RELOP, OP) \
10297
CHECK(Q, C, T, 8, IS_RELOP, OP) \
10398
CHECK(Q, C, T, 16, IS_RELOP, OP)
104-
105-
// NOTE: For the sake of compile-time we pick only a few operators per category.
106-
#define CHECK_SIZES_AND_COMMON_OPS(Q, C, T) \
107-
CHECK_SIZES(Q, Failures, T, false, *) \
108-
CHECK_SIZES(Q, Failures, T, true, &&) \
109-
CHECK_SIZES(Q, Failures, T, true, ==) \
110-
CHECK_SIZES(Q, Failures, T, true, <) \
111-
CHECK_SIZES(Q, Failures, T, true, >=)
112-
#define CHECK_SIZES_AND_INT_ONLY_OPS(Q, C, T) \
113-
CHECK_SIZES(Q, Failures, T, false, %) \
114-
CHECK_SIZES(Q, Failures, T, false, >>) \
115-
CHECK_SIZES(Q, Failures, T, false, ^)
116-
117-
int main() {
118-
sycl::queue Q;
119-
int Failures = 0;
120-
121-
// Check operators on types with requirements if they are supported.
122-
if (Q.get_device().has(sycl::aspect::fp16)) {
123-
CHECK_SIZES_AND_COMMON_OPS(Q, Failures, sycl::half);
124-
}
125-
if (Q.get_device().has(sycl::aspect::fp64)) {
126-
CHECK_SIZES_AND_COMMON_OPS(Q, Failures, double);
127-
}
128-
129-
// Check all operators without requirements.
130-
CHECK_SIZES_AND_COMMON_OPS(Q, Failures, float);
131-
CHECK_SIZES_AND_COMMON_OPS(Q, Failures, int8_t);
132-
CHECK_SIZES_AND_COMMON_OPS(Q, Failures, int16_t);
133-
CHECK_SIZES_AND_COMMON_OPS(Q, Failures, int32_t);
134-
CHECK_SIZES_AND_COMMON_OPS(Q, Failures, int64_t);
135-
CHECK_SIZES_AND_COMMON_OPS(Q, Failures, uint8_t);
136-
CHECK_SIZES_AND_COMMON_OPS(Q, Failures, uint16_t);
137-
CHECK_SIZES_AND_COMMON_OPS(Q, Failures, uint32_t);
138-
CHECK_SIZES_AND_COMMON_OPS(Q, Failures, uint64_t);
139-
140-
// Check integer only operators.
141-
CHECK_SIZES_AND_INT_ONLY_OPS(Q, Failures, int8_t);
142-
CHECK_SIZES_AND_INT_ONLY_OPS(Q, Failures, int16_t);
143-
CHECK_SIZES_AND_INT_ONLY_OPS(Q, Failures, int32_t);
144-
CHECK_SIZES_AND_INT_ONLY_OPS(Q, Failures, int64_t);
145-
CHECK_SIZES_AND_INT_ONLY_OPS(Q, Failures, uint8_t);
146-
CHECK_SIZES_AND_INT_ONLY_OPS(Q, Failures, uint16_t);
147-
CHECK_SIZES_AND_INT_ONLY_OPS(Q, Failures, uint32_t);
148-
CHECK_SIZES_AND_INT_ONLY_OPS(Q, Failures, uint64_t);
149-
return Failures;
150-
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// REQUIRES: preview-breaking-changes-supported
2+
// RUN: %{build} -fpreview-breaking-changes -o %t.out
3+
// RUN: %{run} %t.out
4+
5+
// Checks scalar/vec arithmetic operator ordering.
6+
7+
#include "vec_binary_scalar_order.hpp"
8+
9+
#define CHECK_SIZES_AND_COMMON_OPS(Q, C, T) \
10+
CHECK_SIZES(Q, Failures, T, false, +) \
11+
CHECK_SIZES(Q, Failures, T, false, -) \
12+
CHECK_SIZES(Q, Failures, T, false, /) \
13+
CHECK_SIZES(Q, Failures, T, false, *)
14+
#define CHECK_SIZES_AND_INT_ONLY_OPS(Q, C, T) \
15+
CHECK_SIZES(Q, Failures, T, false, %)
16+
17+
int main() {
18+
sycl::queue Q;
19+
int Failures = 0;
20+
21+
// Check operators on types with requirements if they are supported.
22+
if (Q.get_device().has(sycl::aspect::fp16)) {
23+
CHECK_SIZES_AND_COMMON_OPS(Q, Failures, sycl::half);
24+
}
25+
if (Q.get_device().has(sycl::aspect::fp64)) {
26+
CHECK_SIZES_AND_COMMON_OPS(Q, Failures, double);
27+
}
28+
29+
// Check all operators without requirements.
30+
CHECK_SIZES_AND_COMMON_OPS(Q, Failures, float);
31+
CHECK_SIZES_AND_COMMON_OPS(Q, Failures, int8_t);
32+
CHECK_SIZES_AND_COMMON_OPS(Q, Failures, int16_t);
33+
CHECK_SIZES_AND_COMMON_OPS(Q, Failures, int32_t);
34+
CHECK_SIZES_AND_COMMON_OPS(Q, Failures, int64_t);
35+
CHECK_SIZES_AND_COMMON_OPS(Q, Failures, uint8_t);
36+
CHECK_SIZES_AND_COMMON_OPS(Q, Failures, uint16_t);
37+
CHECK_SIZES_AND_COMMON_OPS(Q, Failures, uint32_t);
38+
CHECK_SIZES_AND_COMMON_OPS(Q, Failures, uint64_t);
39+
40+
// Check integer only operators.
41+
CHECK_SIZES_AND_INT_ONLY_OPS(Q, Failures, int8_t);
42+
CHECK_SIZES_AND_INT_ONLY_OPS(Q, Failures, int16_t);
43+
CHECK_SIZES_AND_INT_ONLY_OPS(Q, Failures, int32_t);
44+
CHECK_SIZES_AND_INT_ONLY_OPS(Q, Failures, int64_t);
45+
CHECK_SIZES_AND_INT_ONLY_OPS(Q, Failures, uint8_t);
46+
CHECK_SIZES_AND_INT_ONLY_OPS(Q, Failures, uint16_t);
47+
CHECK_SIZES_AND_INT_ONLY_OPS(Q, Failures, uint32_t);
48+
CHECK_SIZES_AND_INT_ONLY_OPS(Q, Failures, uint64_t);
49+
return Failures;
50+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// REQUIRES: preview-breaking-changes-supported
2+
// RUN: %{build} -fpreview-breaking-changes -o %t.out
3+
// RUN: %{run} %t.out
4+
5+
// Checks scalar/vec bitwise operator ordering.
6+
7+
#include "vec_binary_scalar_order.hpp"
8+
9+
#define CHECK_SIZES_AND_OPS(Q, C, T) \
10+
CHECK_SIZES(Q, Failures, T, false, >>) \
11+
CHECK_SIZES(Q, Failures, T, false, <<) \
12+
CHECK_SIZES(Q, Failures, T, false, &) \
13+
CHECK_SIZES(Q, Failures, T, false, |) \
14+
CHECK_SIZES(Q, Failures, T, false, ^)
15+
16+
int main() {
17+
sycl::queue Q;
18+
int Failures = 0;
19+
20+
// Check operators.
21+
CHECK_SIZES_AND_OPS(Q, Failures, int8_t);
22+
CHECK_SIZES_AND_OPS(Q, Failures, int16_t);
23+
CHECK_SIZES_AND_OPS(Q, Failures, int32_t);
24+
CHECK_SIZES_AND_OPS(Q, Failures, int64_t);
25+
CHECK_SIZES_AND_OPS(Q, Failures, uint8_t);
26+
CHECK_SIZES_AND_OPS(Q, Failures, uint16_t);
27+
CHECK_SIZES_AND_OPS(Q, Failures, uint32_t);
28+
CHECK_SIZES_AND_OPS(Q, Failures, uint64_t);
29+
return Failures;
30+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// REQUIRES: preview-breaking-changes-supported
2+
// RUN: %{build} -fpreview-breaking-changes -o %t.out
3+
// RUN: %{run} %t.out
4+
5+
// Checks scalar/vec logical operator ordering.
6+
7+
#include "vec_binary_scalar_order.hpp"
8+
9+
#define CHECK_SIZES_AND_OPS(Q, C, T) \
10+
CHECK_SIZES(Q, Failures, T, true, &&) \
11+
CHECK_SIZES(Q, Failures, T, true, ||)
12+
13+
int main() {
14+
sycl::queue Q;
15+
int Failures = 0;
16+
17+
// Check operators on types with requirements if they are supported.
18+
if (Q.get_device().has(sycl::aspect::fp16)) {
19+
CHECK_SIZES_AND_OPS(Q, Failures, sycl::half);
20+
}
21+
if (Q.get_device().has(sycl::aspect::fp64)) {
22+
CHECK_SIZES_AND_OPS(Q, Failures, double);
23+
}
24+
25+
// Check all operators without requirements.
26+
CHECK_SIZES_AND_OPS(Q, Failures, float);
27+
CHECK_SIZES_AND_OPS(Q, Failures, int8_t);
28+
CHECK_SIZES_AND_OPS(Q, Failures, int16_t);
29+
CHECK_SIZES_AND_OPS(Q, Failures, int32_t);
30+
CHECK_SIZES_AND_OPS(Q, Failures, int64_t);
31+
CHECK_SIZES_AND_OPS(Q, Failures, uint8_t);
32+
CHECK_SIZES_AND_OPS(Q, Failures, uint16_t);
33+
CHECK_SIZES_AND_OPS(Q, Failures, uint32_t);
34+
CHECK_SIZES_AND_OPS(Q, Failures, uint64_t);
35+
return Failures;
36+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// REQUIRES: preview-breaking-changes-supported
2+
// RUN: %{build} -fpreview-breaking-changes -o %t.out
3+
// RUN: %{run} %t.out
4+
5+
// This test currently fails on AMD HIP due to an unresolved memcmp function.
6+
// XFAIL: hip_amd
7+
8+
// Checks scalar/vec relational operator ordering.
9+
10+
#include "vec_binary_scalar_order.hpp"
11+
12+
// NOTE: For the sake of compile-time we pick only a few operators per category.
13+
#define CHECK_SIZES_AND_OPS(Q, C, T) \
14+
CHECK_SIZES(Q, Failures, T, true, ==) \
15+
CHECK_SIZES(Q, Failures, T, true, !=) \
16+
CHECK_SIZES(Q, Failures, T, true, <) \
17+
CHECK_SIZES(Q, Failures, T, true, >) \
18+
CHECK_SIZES(Q, Failures, T, true, <=) \
19+
CHECK_SIZES(Q, Failures, T, true, >=)
20+
21+
int main() {
22+
sycl::queue Q;
23+
int Failures = 0;
24+
25+
// Check operators on types with requirements if they are supported.
26+
if (Q.get_device().has(sycl::aspect::fp16)) {
27+
CHECK_SIZES_AND_OPS(Q, Failures, sycl::half);
28+
}
29+
if (Q.get_device().has(sycl::aspect::fp64)) {
30+
CHECK_SIZES_AND_OPS(Q, Failures, double);
31+
}
32+
33+
// Check all operators without requirements.
34+
CHECK_SIZES_AND_OPS(Q, Failures, float);
35+
CHECK_SIZES_AND_OPS(Q, Failures, int8_t);
36+
CHECK_SIZES_AND_OPS(Q, Failures, int16_t);
37+
CHECK_SIZES_AND_OPS(Q, Failures, int32_t);
38+
CHECK_SIZES_AND_OPS(Q, Failures, int64_t);
39+
CHECK_SIZES_AND_OPS(Q, Failures, uint8_t);
40+
CHECK_SIZES_AND_OPS(Q, Failures, uint16_t);
41+
CHECK_SIZES_AND_OPS(Q, Failures, uint32_t);
42+
CHECK_SIZES_AND_OPS(Q, Failures, uint64_t);
43+
return Failures;
44+
}

0 commit comments

Comments
 (0)