Skip to content

Commit 285d32a

Browse files
[SYCL][Level Zero] Add a test for sycl_ext_intel_queue_index extension
Implementation: intel/llvm#7599.
1 parent 2aa315f commit 285d32a

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %level_zero_options %s -o %t.out
2+
// RUN: env ZEX_NUMBER_OF_CCS=0:4 env ZE_DEBUG=1 %GPU_RUN_PLACEHOLDER %t.out 2>&1 %GPU_CHECK_PLACEHOLDER --check-prefixes=CHECK-PVC
3+
4+
// Requires: level_zero
5+
6+
#include <sycl/sycl.hpp>
7+
8+
using namespace sycl;
9+
10+
void test_pvc(device &d) {
11+
std::cout << "Test PVC Begin" << std::endl;
12+
// CHECK-PVC: Test PVC Begin
13+
bool IsPVC = [&]() {
14+
if (!d.has(aspect::ext_intel_device_id))
15+
return false;
16+
return (d.get_info<ext::intel::info::device::device_id>() & 0xff0) == 0xbd0;
17+
}();
18+
std::cout << "IsPVC: " << std::boolalpha << IsPVC << std::endl;
19+
if (IsPVC) {
20+
assert(d.get_info<ext::intel::info::device::max_compute_queue_indices>() ==
21+
1);
22+
23+
auto sub_devices = d.create_sub_devices<
24+
info::partition_property::partition_by_affinity_domain>(
25+
info::partition_affinity_domain::next_partitionable);
26+
device &sub_device = sub_devices[1];
27+
assert(
28+
sub_device
29+
.get_info<ext::intel::info::device::max_compute_queue_indices>() ==
30+
4);
31+
32+
auto sub_sub_devices = sub_device.create_sub_devices<
33+
// TODO: Update using sycl_ext_intel_cslice proposal.
34+
info::partition_property::partition_by_affinity_domain>(
35+
info::partition_affinity_domain::next_partitionable);
36+
device &sub_sub_device = sub_sub_devices[1];
37+
assert(
38+
sub_sub_device
39+
.get_info<ext::intel::info::device::max_compute_queue_indices>() ==
40+
1);
41+
42+
{
43+
bool ExceptionThrown = false;
44+
try {
45+
std::ignore = queue{d, ext::intel::property::queue::compute_index{-1}};
46+
47+
} catch (...) {
48+
ExceptionThrown = true;
49+
}
50+
assert(ExceptionThrown);
51+
}
52+
{
53+
bool ExceptionThrown = false;
54+
try {
55+
std::ignore = queue{sub_sub_device,
56+
ext::intel::property::queue::compute_index{1}};
57+
58+
} catch (...) {
59+
ExceptionThrown = true;
60+
}
61+
assert(ExceptionThrown);
62+
}
63+
64+
{
65+
queue q{sub_device};
66+
// CHECK-PVC: [getZeQueue]: create queue ordinal = 0, index = 0 (round robin in [0, 0])
67+
q.single_task([=]() {}).wait();
68+
}
69+
{
70+
queue q{sub_device, ext::intel::property::queue::compute_index{2}};
71+
// CHECK-PVC: [getZeQueue]: create queue ordinal = 0, index = 2 (round robin in [2, 2])
72+
q.single_task([=]() {}).wait();
73+
}
74+
{
75+
queue q{sub_device, ext::intel::property::queue::compute_index{2}};
76+
// CHECK-PVC: [getZeQueue]: create queue ordinal = 0, index = 2 (round robin in [2, 2])
77+
q.single_task([=]() {}).wait();
78+
}
79+
{
80+
queue q{sub_sub_device};
81+
// CHECK-PVC: [getZeQueue]: create queue ordinal = 0, index = 1 (round robin in [1, 1])
82+
q.single_task([=]() {}).wait();
83+
}
84+
} else {
85+
// Make FileCheck pass.
86+
std::cout << "Fake ZE_DEBUG output for FileCheck:" << std::endl;
87+
std::cout << "[getZeQueue]: create queue ordinal = 0, index = 0 (round robin in [0, 0])" << std::endl;
88+
std::cout << "[getZeQueue]: create queue ordinal = 0, index = 2 (round robin in [2, 2])" << std::endl;
89+
std::cout << "[getZeQueue]: create queue ordinal = 0, index = 2 (round robin in [2, 2])" << std::endl;
90+
std::cout << "[getZeQueue]: create queue ordinal = 0, index = 1 (round robin in [1, 1])" << std::endl;
91+
}
92+
std::cout << "Test PVC End" << std::endl;
93+
// CHECK-PVC: Test PVC End
94+
}
95+
96+
int main() {
97+
device d;
98+
99+
test_pvc(d);
100+
101+
return 0;
102+
}

0 commit comments

Comments
 (0)