Skip to content

Commit 33facd0

Browse files
[SYCL][E2E] Reenable get_backend test (#9240)
This patch makes 2 changes: it removes the outdated usage of device selector (in SYCL 2020 it always picks from all available devices instead of being limited to the context passed along with it) and adds a workaround for the problem described below. There is an issue with extension function pointer caching in OpenCL plugin: each extension function call helper keeps a pi_context-to-fptr map cache, however, these maps aren't cleaned up on context release. This can lead to the following situation: - Context A is created - An extension function is called in context A - Context A is destroyed - A new context B is created, which happens to have the same pi_context handle - The cached function is called for context B If these two contexts have different platforms (like in get_backend test), this will lead to an error. This patch removes the use of USM functions from the test to circumvent this issue.
1 parent f344077 commit 33facd0

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

sycl/test-e2e/Basic/get_backend.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// REQUIRES: TEMPORARY_DISABLED
21
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
32
// RUN: %t.out
43
//
@@ -43,22 +42,24 @@ int main() {
4342
return_fail();
4443
}
4544

46-
queue q(c, default_selector_v);
47-
if (q.get_backend() != plt.get_backend()) {
45+
auto device = c.get_devices()[0];
46+
if (device.get_backend() != plt.get_backend()) {
4847
return_fail();
4948
}
5049

51-
auto device = q.get_device();
52-
if (device.get_backend() != plt.get_backend()) {
50+
queue q(c, device);
51+
if (q.get_backend() != plt.get_backend()) {
5352
return_fail();
5453
}
5554

56-
unsigned char *HostAlloc = (unsigned char *)malloc_host(1, c);
57-
auto e = q.memset(HostAlloc, 42, 1);
55+
buffer<int, 1> buf{range<1>(1)};
56+
event e = q.submit([&](handler &cgh) {
57+
auto acc = buf.get_access<access::mode::read_write>(cgh);
58+
cgh.fill(acc, 0);
59+
});
5860
if (e.get_backend() != plt.get_backend()) {
5961
return_fail();
6062
}
61-
free(HostAlloc, c);
6263
}
6364
std::cout << "Passed" << std::endl;
6465
return 0;

0 commit comments

Comments
 (0)