-
Notifications
You must be signed in to change notification settings - Fork 793
[SYCL][Graph] async_malloc use allocation size for zeVirtualMemQueryPageSize #19402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: sycl
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,8 @@ namespace ext::oneapi::experimental { | |
|
||
__SYCL_EXPORT size_t get_mem_granularity(const device &SyclDevice, | ||
const context &SyclContext, | ||
granularity_mode Mode) { | ||
granularity_mode Mode, | ||
size_t allocationSize) { | ||
Comment on lines
+27
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to be an ABI-breaking change, we can't just do it like that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for pointing it out. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method is part of an experimental extension https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/experimental/sycl_ext_oneapi_virtual_mem.asciidoc Acording to https://github.com/intel/llvm/blob/sycl/sycl/doc/developer/ABIPolicyGuide.md Features clearly marked as experimental are considered as an exception to this guideline. I understand although ABI change is possible I should get consensus on API change with virtual_mem extension owners. @steffenlarsen , @aelovikov-intel , @aarongreig - you are code contributors for virtual mem, should I discuss it with you, some of you, some other people too? I'd like to start email thread with interested people about this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think in this case it would be as simple as using two overloads instead of default value for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. Previous behavior is the same as new one with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. Please check if the signature looks OK. If so I'll update extension documentation. |
||
if (!SyclDevice.has(aspect::ext_oneapi_virtual_mem)) | ||
throw sycl::exception( | ||
sycl::make_error_code(sycl::errc::feature_not_supported), | ||
|
@@ -45,20 +46,28 @@ __SYCL_EXPORT size_t get_mem_granularity(const device &SyclDevice, | |
#ifndef NDEBUG | ||
size_t InfoOutputSize = 0; | ||
Adapter->call<sycl::detail::UrApiKind::urVirtualMemGranularityGetInfo>( | ||
urCtx, urDevice, GranularityQuery, 0, nullptr, &InfoOutputSize); | ||
urCtx, urDevice, allocationSize, GranularityQuery, 0, nullptr, | ||
&InfoOutputSize); | ||
assert(InfoOutputSize == sizeof(size_t) && | ||
"Unexpected output size of granularity info query."); | ||
#endif // NDEBUG | ||
size_t Granularity = 0; | ||
Adapter->call<sycl::detail::UrApiKind::urVirtualMemGranularityGetInfo>( | ||
urCtx, urDevice, GranularityQuery, sizeof(size_t), &Granularity, nullptr); | ||
urCtx, urDevice, allocationSize, GranularityQuery, sizeof(size_t), | ||
&Granularity, nullptr); | ||
if (Granularity == 0) | ||
throw sycl::exception( | ||
sycl::make_error_code(sycl::errc::invalid), | ||
"Unexpected granularity result: memory granularity shouldn't be 0."); | ||
return Granularity; | ||
} | ||
|
||
__SYCL_EXPORT size_t get_mem_granularity(const device &SyclDevice, | ||
const context &SyclContext, | ||
granularity_mode Mode) { | ||
return get_mem_granularity(SyclDevice, SyclContext, Mode, 1); | ||
} | ||
|
||
__SYCL_EXPORT size_t get_mem_granularity(const context &SyclContext, | ||
granularity_mode Mode) { | ||
const std::vector<device> Devices = SyclContext.get_devices(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// RUN: %{build} -o %t.out | ||
// RUN: %{run} %t.out | ||
// Extra run to check for leaks in Level Zero using UR_L0_LEAKS_DEBUG | ||
// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=0 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %} | ||
// Extra run to check for immediate-command-list in Level Zero | ||
// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=1 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %} | ||
|
||
#define GRAPH_E2E_EXPLICIT | ||
|
||
#include "../Inputs/async_alloc_different_sizes.cpp" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Tests async allocations with different sizes. | ||
|
||
#include "../../graph_common.hpp" | ||
#include <sycl/ext/oneapi/experimental/async_alloc/async_alloc.hpp> | ||
|
||
void asyncAllocWorksWithSize(size_t Size) { | ||
queue Queue{}; | ||
|
||
exp_ext::command_graph Graph{Queue.get_context(), Queue.get_device()}; | ||
|
||
void *AsyncPtr = nullptr; | ||
// Add alloc node | ||
auto AllocNode = add_node(Graph, Queue, [&](handler &CGH) { | ||
AsyncPtr = exp_ext::async_malloc(CGH, usm::alloc::device, Size); | ||
}); | ||
|
||
add_node( | ||
Graph, Queue, | ||
[&](handler &CGH) { | ||
depends_on_helper(CGH, AllocNode); | ||
exp_ext::async_free(CGH, AsyncPtr); | ||
}, | ||
AllocNode); | ||
|
||
auto GraphExec = Graph.finalize(); | ||
} | ||
|
||
int main() { | ||
asyncAllocWorksWithSize(1); | ||
asyncAllocWorksWithSize(131); | ||
asyncAllocWorksWithSize(10071); | ||
asyncAllocWorksWithSize(1007177); | ||
asyncAllocWorksWithSize(191439360); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// RUN: %{build} -o %t.out | ||
// RUN: %{run} %t.out | ||
// Extra run to check for leaks in Level Zero using UR_L0_LEAKS_DEBUG | ||
// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=0 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %} | ||
// Extra run to check for immediate-command-list in Level Zero | ||
// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=1 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %} | ||
|
||
#define GRAPH_E2E_RECORD_REPLAY | ||
|
||
#include "../Inputs/async_alloc_different_sizes.cpp" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this? Can't we just pass UR_FORMAT_CPP_STYLE when configuring SYCL?