|
1 | 1 | // REQUIRES: sg-16,aspect-usm_shared_allocations
|
2 |
| -// UNSUPPORTED: arch-intel_gpu_bmg_g21 |
3 |
| -// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/16921 |
4 | 2 | // RUN: %{build} -o %t.out
|
5 | 3 | // RUN: %{run} %t.out
|
6 | 4 |
|
7 | 5 | #include "include/asmhelper.h"
|
8 | 6 | #include <iostream>
|
9 | 7 | #include <sycl/usm.hpp>
|
10 | 8 |
|
| 9 | +namespace syclex = sycl::ext::oneapi::experimental; |
| 10 | + |
11 | 11 | constexpr size_t problem_size = 16;
|
12 | 12 |
|
13 | 13 | class kernel_name;
|
14 | 14 |
|
15 | 15 | int main() {
|
16 | 16 | sycl::queue q;
|
17 | 17 | sycl::device Device = q.get_device();
|
| 18 | + int Failed = 0; |
18 | 19 |
|
19 | 20 | if (!isInlineASMSupported(Device)) {
|
20 | 21 | std::cout << "Skipping test\n";
|
21 | 22 | return 0;
|
22 | 23 | }
|
| 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 | + |
23 | 35 | 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 | + |
26 | 38 | for (int i = 0; i < problem_size; i++) {
|
27 | 39 | a[i] = i;
|
28 | 40 | }
|
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([&]() { |
33 | 50 | #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])); |
41 | 59 | #else
|
42 |
| - a[idx[0]]++; |
| 60 | + a[idx[0]]++; |
43 | 61 | #endif
|
44 |
| - }); |
45 |
| - }).wait(); |
| 62 | + }); |
| 63 | + }) |
| 64 | + .wait(); |
46 | 65 |
|
47 |
| - bool currect = true; |
48 | 66 | for (int i = 0; i < problem_size; i++) {
|
49 | 67 | if (a[i] != (i + 1)) {
|
50 |
| - currect = false; |
51 | 68 | std::cerr << "error in a[" << i << "]=" << a[i] << "!=" << (i + 1)
|
52 | 69 | << std::endl;
|
53 |
| - break; |
| 70 | + ++Failed; |
54 | 71 | }
|
55 | 72 | }
|
56 | 73 |
|
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; |
64 | 74 | sycl::free(a, ctx);
|
65 |
| - return 0; |
| 75 | + return Failed; |
66 | 76 | }
|
0 commit comments