Skip to content

Commit 1d5076f

Browse files
authored
[SYCL][E2E] Run InlineAsm/letter_example and InlineAsm/malloc_shared_32 on only pre intel_gpu_bmg_g21 devices (#17175)
Purpose of this PR is to limit the execution of `InlineAsm/letter_example` and `InlineAsm/malloc_shared_32` tests to pre `intel_gpu_bmg_g21` devices.
1 parent a765263 commit 1d5076f

File tree

2 files changed

+71
-56
lines changed

2 files changed

+71
-56
lines changed
Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,76 @@
11
// REQUIRES: sg-16,aspect-usm_shared_allocations
2-
// UNSUPPORTED: arch-intel_gpu_bmg_g21
3-
// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/16921
42
// RUN: %{build} -o %t.out
53
// RUN: %{run} %t.out
64

75
#include "include/asmhelper.h"
86
#include <iostream>
97
#include <sycl/usm.hpp>
108

9+
namespace syclex = sycl::ext::oneapi::experimental;
10+
1111
constexpr size_t problem_size = 16;
1212

1313
class kernel_name;
1414

1515
int main() {
1616
sycl::queue q;
1717
sycl::device Device = q.get_device();
18+
int Failed = 0;
1819

1920
if (!isInlineASMSupported(Device)) {
2021
std::cout << "Skipping test\n";
2122
return 0;
2223
}
24+
25+
syclex::architecture CurrentDeviceArch =
26+
Device.get_info<syclex::info::device::architecture>();
27+
// This check is carried out because the test is not supported on BMG and
28+
// subsequent devices.
29+
if (CurrentDeviceArch >= syclex::architecture::intel_gpu_bmg_g21) {
30+
std::cout << "This test is not supported on BMG and later. Skipping..."
31+
<< std::endl;
32+
return 0;
33+
}
34+
2335
auto ctx = q.get_context();
24-
int *a =
25-
(int *)malloc_shared(sizeof(int) * problem_size, q.get_device(), ctx);
36+
int *a = (int *)malloc_shared(sizeof(int) * problem_size, Device, ctx);
37+
2638
for (int i = 0; i < problem_size; i++) {
2739
a[i] = i;
2840
}
29-
q.submit([&](sycl::handler &cgh) {
30-
cgh.parallel_for<kernel_name>(
31-
sycl::range<1>(problem_size),
32-
[=](sycl::id<1> idx) [[sycl::reqd_sub_group_size(16)]] {
41+
42+
q.parallel_for<kernel_name>(
43+
sycl::range<1>(problem_size),
44+
[=](sycl::id<1> idx) [[sycl::reqd_sub_group_size(16)]] {
45+
// The use of if_architecture_is_ge is a precaution in case the test is
46+
// compiled with the -fsycl-targets flag.
47+
syclex::if_architecture_is_ge<syclex::architecture::intel_gpu_bmg_g21>(
48+
[]() {})
49+
.otherwise([&]() {
3350
#if defined(__SYCL_DEVICE_ONLY__)
34-
int i = idx[0];
35-
asm volatile("{\n.decl V52 v_type=G type=d num_elts=16 align=GRF\n"
36-
"svm_gather.4.1 (M1, 16) %0.0 V52.0\n"
37-
"add(M1, 16) V52(0, 0)<1> V52(0, 0)<1; 1, 0> 0x1:w\n"
38-
"svm_scatter.4.1 (M1, 16) %0.0 V52.0\n}"
39-
:
40-
: "rw"(&a[i]));
51+
int i = idx[0];
52+
asm volatile(
53+
"{\n.decl V52 v_type=G type=d num_elts=16 align=GRF\n"
54+
"svm_gather.4.1 (M1, 16) %0.0 V52.0\n"
55+
"add(M1, 16) V52(0, 0)<1> V52(0, 0)<1; 1, 0> 0x1:w\n"
56+
"svm_scatter.4.1 (M1, 16) %0.0 V52.0\n}"
57+
:
58+
: "rw"(&a[i]));
4159
#else
42-
a[idx[0]]++;
60+
a[idx[0]]++;
4361
#endif
44-
});
45-
}).wait();
62+
});
63+
})
64+
.wait();
4665

47-
bool currect = true;
4866
for (int i = 0; i < problem_size; i++) {
4967
if (a[i] != (i + 1)) {
50-
currect = false;
5168
std::cerr << "error in a[" << i << "]=" << a[i] << "!=" << (i + 1)
5269
<< std::endl;
53-
break;
70+
++Failed;
5471
}
5572
}
5673

57-
if (!currect) {
58-
std::cerr << "Error" << std::endl;
59-
sycl::free(a, ctx);
60-
return 1;
61-
}
62-
63-
std::cerr << "Pass" << std::endl;
6474
sycl::free(a, ctx);
65-
return 0;
75+
return Failed;
6676
}
Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
// REQUIRES: sg-32,aspect-usm_shared_allocations
2-
// UNSUPPORTED: arch-intel_gpu_bmg_g21
3-
// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/16921
42
// RUN: %{build} -o %t.out
53
// RUN: %{run} %t.out
64

@@ -12,16 +10,28 @@ constexpr size_t problem_size = 32;
1210

1311
class kernel_name;
1412

13+
namespace syclex = sycl::ext::oneapi::experimental;
14+
1515
int main() {
1616
sycl::queue q;
17-
1817
sycl::device Device = q.get_device();
18+
int Failed = 0;
1919

2020
if (!isInlineASMSupported(Device)) {
2121
std::cout << "Skipping test\n";
2222
return 0;
2323
}
2424

25+
syclex::architecture CurrentDeviceArch =
26+
Device.get_info<syclex::info::device::architecture>();
27+
// This check is carried out because the test is not supported on BMG and
28+
// subsequent devices.
29+
if (CurrentDeviceArch >= syclex::architecture::intel_gpu_bmg_g21) {
30+
std::cout << "This test is not supported on BMG and later. Skipping..."
31+
<< std::endl;
32+
return 0;
33+
}
34+
2535
auto ctx = q.get_context();
2636
int *a =
2737
(int *)malloc_shared(sizeof(int) * problem_size, q.get_device(), ctx);
@@ -35,13 +45,17 @@ int main() {
3545
c[i] = i;
3646
}
3747

38-
q.submit([&](sycl::handler &cgh) {
39-
cgh.parallel_for<kernel_name>(
40-
sycl::range<1>(problem_size),
41-
[=](sycl::id<1> idx) [[sycl::reqd_sub_group_size(32)]] {
42-
int i = idx[0];
48+
q.parallel_for<kernel_name>(
49+
sycl::range<1>(problem_size),
50+
[=](sycl::id<1> idx) [[sycl::reqd_sub_group_size(32)]] {
51+
int i = idx[0];
52+
// The use of if_architecture_is_ge is a precaution in case the test is
53+
// compiled with the -fsycl-targets flag.
54+
syclex::if_architecture_is_ge<syclex::architecture::intel_gpu_bmg_g21>(
55+
[]() {})
56+
.otherwise([&]() {
4357
#if defined(__SYCL_DEVICE_ONLY__)
44-
asm volatile(R"a(
58+
asm volatile(R"a(
4559
{
4660
.decl V52 v_type=G type=d num_elts=16 align=GRF
4761
.decl V53 v_type=G type=d num_elts=16 align=GRF
@@ -59,35 +73,26 @@ int main() {
5973
svm_scatter.4.1 (M1, 16) %1.0 V53.0
6074
}
6175
)a" ::"rw"(&b[i]),
62-
"rw"(&b[i] + 16), "rw"(&a[i]), "rw"(&a[i] + 16),
63-
"rw"(&c[i]), "rw"(&c[i] + 16));
76+
"rw"(&b[i] + 16), "rw"(&a[i]), "rw"(&a[i] + 16),
77+
"rw"(&c[i]), "rw"(&c[i] + 16));
6478
#else
65-
b[i] = a[i] * c[i];
79+
b[i] = a[i] * c[i];
6680
#endif
67-
});
68-
}).wait();
81+
});
82+
})
83+
.wait();
6984

70-
bool currect = true;
7185
for (int i = 0; i < problem_size; i++) {
7286
if (b[i] != a[i] * c[i]) {
73-
currect = false;
7487
std::cerr << "error in a[" << i << "]=" << b[i] << "!=" << a[i] * c[i]
7588
<< std::endl;
76-
break;
89+
++Failed;
7790
}
7891
}
7992

80-
if (!currect) {
81-
std::cerr << "Error" << std::endl;
82-
sycl::free(a, ctx);
83-
sycl::free(b, ctx);
84-
sycl::free(c, ctx);
85-
return 1;
86-
}
87-
88-
std::cerr << "Pass" << std::endl;
8993
sycl::free(a, ctx);
9094
sycl::free(b, ctx);
9195
sycl::free(c, ctx);
92-
return 0;
96+
97+
return Failed;
9398
}

0 commit comments

Comments
 (0)