Skip to content

Commit 7c509e9

Browse files
dyniolsAlexeySachkovmaarquitos14
authored
[SYCL][E2E] Add granularity test for sycl_ext_oneapi_virtual_mem extension (#15848)
Based on the test plan #15509, this PR adds an e2e test checking memory granularities returned by `get_mem_granularity`. --------- Co-authored-by: Alexey Sachkov <[email protected]> Co-authored-by: Marcos Maronas <[email protected]>
1 parent e427e2f commit 7c509e9

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Tests are sharing same required aspect
2+
config.required_features += ['aspect-ext_oneapi_virtual_mem']
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// This test checks whether memory granularity returned is greater than 0 and
2+
// that the recommended granularity is the same size or greater than the minimum
3+
// granularity for virtual memory extension.
4+
5+
// RUN: %{build} -o %t.out
6+
// RUN: %{run} %t.out
7+
8+
#include <sycl/detail/core.hpp>
9+
10+
#include <sycl/ext/oneapi/virtual_mem/virtual_mem.hpp>
11+
12+
#include <cassert>
13+
14+
namespace syclext = sycl::ext::oneapi::experimental;
15+
16+
int main() {
17+
sycl::queue Q;
18+
sycl::context Context = Q.get_context();
19+
sycl::device Device = Q.get_device();
20+
21+
size_t DevRecommended = syclext::get_mem_granularity(
22+
Device, Context, syclext::granularity_mode::recommended);
23+
size_t ContextRecommended = syclext::get_mem_granularity(
24+
Context, syclext::granularity_mode::recommended);
25+
size_t DevMinimum = syclext::get_mem_granularity(
26+
Device, Context, syclext::granularity_mode::minimum);
27+
size_t ContextMinimum =
28+
syclext::get_mem_granularity(Context, syclext::granularity_mode::minimum);
29+
30+
assert(DevRecommended > 0 &&
31+
"recommended granularity for device should be greater than 0");
32+
assert(ContextRecommended > 0 &&
33+
"recommended granularity for context should be greater than 0");
34+
35+
assert(DevMinimum > 0 &&
36+
"minimum granularity for device should be greater than 0");
37+
assert(ContextMinimum > 0 &&
38+
"minimum granularity for context should be greater than 0");
39+
40+
assert(DevRecommended >= DevMinimum &&
41+
"recommended granularity size must be at least minimum granularity "
42+
"for device");
43+
assert(ContextRecommended >= ContextMinimum &&
44+
"recommended granularity size must be at least minimum granularity "
45+
"for context");
46+
47+
return 0;
48+
}

sycl/test-e2e/VirtualMem/vector_with_virtual_mem.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// REQUIRES: aspect-ext_oneapi_virtual_mem, aspect-usm_shared_allocations
1+
// REQUIRES: aspect-usm_shared_allocations
22

33
// XFAIL: linux && gpu-intel-dg2
44
// XFAIL-TRACKER: https://github.com/intel/llvm/issues/15812

0 commit comments

Comments
 (0)