Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 00fef07

Browse files
authored
[SYCL] Adopt test for CUDA backend (#240)
The value passed into memadvise is backend-specific. For OpenCL and Level Zero this test assumes 0 is a valid value. For CUDA this is not the case. The valid values for CUDA are 1 through 6.
1 parent e1607bf commit 00fef07

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

SYCL/USM/memadvise.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@ int main() {
2929
queue q;
3030
auto dev = q.get_device();
3131
auto ctxt = q.get_context();
32+
const int mem_advice = ((dev.get_backend() == backend::cuda) ? 1 : 0);
3233
if (!dev.get_info<info::device::usm_shared_allocations>())
3334
return 0;
3435

3536
Node *s_head = (Node *)malloc_shared(sizeof(Node), dev, ctxt);
3637
if (s_head == nullptr) {
3738
return -1;
3839
}
39-
q.mem_advise(s_head, sizeof(Node), (pi_mem_advice)0);
40+
q.mem_advise(s_head, sizeof(Node), (pi_mem_advice)mem_advice);
4041
Node *s_cur = s_head;
4142

4243
for (int i = 0; i < numNodes; i++) {
@@ -47,7 +48,7 @@ int main() {
4748
if (s_cur->pNext == nullptr) {
4849
return -1;
4950
}
50-
q.mem_advise(s_cur->pNext, sizeof(Node), (pi_mem_advice)0);
51+
q.mem_advise(s_cur->pNext, sizeof(Node), (pi_mem_advice)mem_advice);
5152
} else {
5253
s_cur->pNext = nullptr;
5354
}

0 commit comments

Comments
 (0)