|
| 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 | +} |
0 commit comments