Skip to content

Commit 2b622d3

Browse files
committed
[SYCL][Grapg] async_malloc use allocation size for zeVirtualMemQueryPageSize
1 parent fa10808 commit 2b622d3

File tree

25 files changed

+115
-65
lines changed

25 files changed

+115
-65
lines changed

sycl/cmake/modules/FetchUnifiedRuntime.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ set(UR_BUILD_TESTS "${SYCL_UR_BUILD_TESTS}" CACHE BOOL "" FORCE)
2828
# UR tests require the examples to be built
2929
set(UR_BUILD_EXAMPLES "${SYCL_UR_BUILD_TESTS}" CACHE BOOL "" FORCE)
3030

31+
option(SYCL_UR_FORMAT_CPP_STYLE "Format code style of UR C++ sources" OFF)
32+
set(UR_FORMAT_CPP_STYLE "${SYCL_UR_FORMAT_CPP_STYLE}" CACHE BOOL "" FORCE)
33+
3134
# Here we override the defaults to unified-runtime
3235
set(UR_BUILD_XPTI_LIBS OFF CACHE BOOL "")
3336
set(UR_ENABLE_SYMBOLIZER ON CACHE BOOL "Enable symbolizer for sanitizer layer.")

sycl/include/sycl/ext/oneapi/virtual_mem/virtual_mem.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ enum class granularity_mode : char {
2828

2929
__SYCL_EXPORT size_t
3030
get_mem_granularity(const device &SyclDevice, const context &SyclContext,
31-
granularity_mode Mode = granularity_mode::recommended);
31+
granularity_mode Mode = granularity_mode::recommended,
32+
size_t allocationSize = 1);
3233

3334
__SYCL_EXPORT size_t
3435
get_mem_granularity(const context &SyclContext,

sycl/source/detail/graph/memory_pool.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ void *graph_mem_pool::malloc(size_t Size, usm::alloc AllocType,
4242
context_impl &CtxImpl = *getSyclObjImpl(MContext);
4343
adapter_impl &Adapter = CtxImpl.getAdapter();
4444

45-
size_t Granularity = get_mem_granularity(MDevice, MContext);
45+
const size_t Granularity = get_mem_granularity(
46+
MDevice, MContext, granularity_mode::recommended, Size);
4647
uintptr_t StartPtr = 0;
4748
size_t AlignedSize = alignByteSize(Size, Granularity);
4849
// See if we can find an allocation to reuse

sycl/source/virtual_mem.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ namespace ext::oneapi::experimental {
2424

2525
__SYCL_EXPORT size_t get_mem_granularity(const device &SyclDevice,
2626
const context &SyclContext,
27-
granularity_mode Mode) {
27+
granularity_mode Mode,
28+
size_t allocationSize) {
2829
if (!SyclDevice.has(aspect::ext_oneapi_virtual_mem))
2930
throw sycl::exception(
3031
sycl::make_error_code(sycl::errc::feature_not_supported),
@@ -45,13 +46,15 @@ __SYCL_EXPORT size_t get_mem_granularity(const device &SyclDevice,
4546
#ifndef NDEBUG
4647
size_t InfoOutputSize = 0;
4748
Adapter->call<sycl::detail::UrApiKind::urVirtualMemGranularityGetInfo>(
48-
urCtx, urDevice, GranularityQuery, 0, nullptr, &InfoOutputSize);
49+
urCtx, urDevice, allocationSize, GranularityQuery, 0, nullptr,
50+
&InfoOutputSize);
4951
assert(InfoOutputSize == sizeof(size_t) &&
5052
"Unexpected output size of granularity info query.");
5153
#endif // NDEBUG
5254
size_t Granularity = 0;
5355
Adapter->call<sycl::detail::UrApiKind::urVirtualMemGranularityGetInfo>(
54-
urCtx, urDevice, GranularityQuery, sizeof(size_t), &Granularity, nullptr);
56+
urCtx, urDevice, allocationSize, GranularityQuery, sizeof(size_t),
57+
&Granularity, nullptr);
5558
if (Granularity == 0)
5659
throw sycl::exception(
5760
sycl::make_error_code(sycl::errc::invalid),

sycl/test-e2e/Graph/AsyncAlloc/Inputs/async_alloc_different_sizes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ int main() {
3030
asyncAllocWorksWithSize(131);
3131
asyncAllocWorksWithSize(10071);
3232
asyncAllocWorksWithSize(1007177);
33-
// asyncAllocWorksWithSize(191439360); // BUG
33+
asyncAllocWorksWithSize(191439360);
3434
}

unified-runtime/include/ur_api.h

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unified-runtime/include/ur_ddi.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unified-runtime/include/ur_print.hpp

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unified-runtime/scripts/core/virtual_memory.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ params:
4141
[in][optional] is the device to get the granularity from, if the
4242
device is null then the granularity is suitable for all devices in
4343
context.
44+
- type: size_t
45+
name: allocationSize
46+
desc: "[in] size in bytes of allocation size which granurality we search for."
4447
- type: $x_virtual_mem_granularity_info_t
4548
name: propName
4649
desc: "[in] type of the info to query."

unified-runtime/source/adapters/cuda/virtual_mem.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
UR_APIEXPORT ur_result_t UR_APICALL urVirtualMemGranularityGetInfo(
2020
ur_context_handle_t, ur_device_handle_t hDevice,
21+
[[maybe_unused]] size_t allocationSize,
2122
ur_virtual_mem_granularity_info_t propName, size_t propSize,
2223
void *pPropValue, size_t *pPropSizeRet) {
2324
UrReturnHelper ReturnValue(propSize, pPropValue, pPropSizeRet);

0 commit comments

Comments
 (0)