Skip to content

[SYCL][AsyncAlloc] Fix minor async alloc issues #17689

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

Merged
merged 2 commits into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sycl/source/detail/cg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ class CGAsyncAlloc : public CG {
ur_event_handle_t event, CG::StorageInitHelper CGData,
detail::code_location loc = {})
: CG(CGType::AsyncAlloc, std::move(CGData), std::move(loc)), MSize(size),
MMemPool(MemPool), MEvent(event) {}
MMemPool(std::move(MemPool)), MEvent(event) {}

std::shared_ptr<ext::oneapi::experimental::detail::memory_pool_impl>
getMemPool() const {
Expand Down
2 changes: 1 addition & 1 deletion sycl/source/detail/context_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ void context_impl::verifyProps(const property_list &Props) const {
std::shared_ptr<sycl::ext::oneapi::experimental::detail::memory_pool_impl>
context_impl::get_default_memory_pool(const context &Context,
const device &Device,
const usm::alloc &Kind) {
[[maybe_unused]] const usm::alloc &Kind) {

assert(Kind == usm::alloc::device);

Expand Down
4 changes: 2 additions & 2 deletions sycl/source/detail/handler_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ class handler_impl {
/// potential logging.
/// Event computed from async alloc which is passed through for processing.
std::shared_ptr<ext::oneapi::experimental::detail::memory_pool_impl> MMemPool;
size_t MAllocSize;
ur_event_handle_t MAsyncAllocEvent;
size_t MAllocSize = 0;
ur_event_handle_t MAsyncAllocEvent = nullptr;

// Allocation ptr to be freed asynchronously.
void *MFreePtr = nullptr;
Expand Down
12 changes: 8 additions & 4 deletions sycl/source/detail/memory_pool_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,14 @@ memory_pool_impl::~memory_pool_impl() {
if (MIsDefaultPool)
return;

ur_usm_pool_handle_t handle = this->get_handle();
sycl::context ctx = this->get_context();
sycl::device dev = this->get_device();
destroy_memory_pool(ctx, dev, handle);
try {
ur_usm_pool_handle_t handle = this->get_handle();
sycl::context ctx = this->get_context();
sycl::device dev = this->get_device();
destroy_memory_pool(ctx, dev, handle);
} catch (std::exception &e) {
__SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~memory_pool_impl", e);
}
}

size_t memory_pool_impl::get_threshold() const {
Expand Down
1 change: 1 addition & 0 deletions sycl/source/detail/scheduler/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3748,6 +3748,7 @@ ur_result_t ExecCGCommand::enqueueImpQueue() {
return UR_RESULT_SUCCESS;
}
case CGType::AsyncFree: {
assert(MQueue && "Async free submissions should have an associated queue");
CGAsyncFree *AsyncFree = (CGAsyncFree *)MCommandGroup.get();
const detail::AdapterPtr &Adapter = MQueue->getAdapter();
void *ptr = AsyncFree->getPtr();
Expand Down