Skip to content

Commit

Permalink
Release resources on windows on shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
omarahmed1111 committed Sep 24, 2024
1 parent 3e98b3a commit 36690f4
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 24 deletions.
25 changes: 13 additions & 12 deletions sycl/source/detail/global_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,18 +298,6 @@ void GlobalHandler::drainThreadPool() {
MHostTaskThreadPool.Inst->drain();
}

#ifdef _WIN32
// because of something not-yet-understood on Windows
// threads may be shutdown once the end of main() is reached
// making an orderly shutdown difficult. Fortunately, Windows
// itself is very aggressive about reclaiming memory. Thus,
// we focus solely on unloading the adapters, so as to not
// accidentally retain device handles. etc
void shutdown_win() {
GlobalHandler *&Handler = GlobalHandler::getInstancePtr();
Handler->unloadAdapters();
}
#else
void shutdown_early() {
const LockGuard Lock{GlobalHandler::MSyclGlobalHandlerProtector};
GlobalHandler *&Handler = GlobalHandler::getInstancePtr();
Expand All @@ -331,6 +319,19 @@ void shutdown_early() {
Handler->releaseDefaultContexts();
}

#ifdef _WIN32
// because of something not-yet-understood on Windows
// threads may be shutdown once the end of main() is reached
// making an orderly shutdown difficult. Fortunately, Windows
// itself is very aggressive about reclaiming memory. Thus,
// we focus solely on unloading the plugins, so as to not
// accidentally retain device handles. etc
void shutdown_win() {
shutdown_early();
GlobalHandler *&Handler = GlobalHandler::getInstancePtr();
Handler->unloadPlugins();
}
#else
void shutdown_late() {
const LockGuard Lock{GlobalHandler::MSyclGlobalHandlerProtector};
GlobalHandler *&Handler = GlobalHandler::getInstancePtr();
Expand Down
3 changes: 1 addition & 2 deletions sycl/test-e2e/Basic/queue/release.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// RUN: %{build} -o %t.out
// RUN: env SYCL_UR_TRACE=2 %{run} %t.out | FileCheck %s
//
// TODO: Reenable on Windows, see https://github.com/intel/llvm/issues/14768
// XFAIL: hip_nvidia, windows
// XFAIL: hip_nvidia

#include <sycl/detail/core.hpp>
int main() {
Expand Down
3 changes: 0 additions & 3 deletions sycl/test-e2e/KernelAndProgram/disable-caching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
// RUN: env ZE_DEBUG=-6 SYCL_UR_TRACE=2 %{run} %t.out \
// RUN: | FileCheck %s --check-prefixes=CHECK-CACHE

// TODO: Reenable on Windows, see https://github.com/intel/llvm/issues/14768
// XFAIL: windows

#include <sycl/detail/core.hpp>

#include <sycl/specialization_id.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
// RUN: %{build} -o %t.out
// RUN: env SYCL_UR_TRACE=2 %{run} %t.out 2>&1 | FileCheck %s
//
// TODO: Reenable on Windows, see https://github.com/intel/llvm/issues/14768
// XFAIL: hip_nvidia, windows
// XFAIL: hip_nvidia

#include <sycl/detail/core.hpp>

Expand Down
3 changes: 0 additions & 3 deletions sycl/test-e2e/Regression/pi_release.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// REQUIRES: opencl || level_zero || cuda
// RUN: %{build} -o %t.out
// RUN: env SYCL_UR_TRACE=2 %{run} %t.out 2>&1 | FileCheck %s
//
// TODO: Reenable on Windows, see https://github.com/intel/llvm/issues/14768
// XFAIL: windows

#include <sycl/detail/core.hpp>

Expand Down
3 changes: 1 addition & 2 deletions sycl/test-e2e/Scheduler/ReleaseResourcesTest.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// RUN: %{build} -Wno-error=unused-command-line-argument -fsycl-dead-args-optimization -o %t.out
// RUN: env SYCL_UR_TRACE=2 %{run} %t.out 2>&1 | FileCheck %s
//
// TODO: Reenable on Windows, see https://github.com/intel/llvm/issues/14768
// XFAIL: hip_nvidia, windows
// XFAIL: hip_nvidia

//==------------------- ReleaseResourcesTests.cpp --------------------------==//
//
Expand Down

0 comments on commit 36690f4

Please sign in to comment.