Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions sycl/source/detail/global_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ class GlobalHandler {
// For testing purposes only
void attachScheduler(Scheduler *Scheduler);

// Used in SYCL unit tests to reset the GlobalHandler instance.
static void resetGlobalHandler() {
RTGlobalObjHandler = new GlobalHandler();
};

private:
// Constructor and destructor are declared out-of-line to allow incomplete
// types as template arguments to unique_ptr.
Expand Down
4 changes: 4 additions & 0 deletions sycl/unittests/helpers/MockDeviceImage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,10 @@ template <size_t __NumberOfImages> class MockDeviceImageArray {
static constexpr size_t NumberOfImages = __NumberOfImages;

MockDeviceImageArray(MockDeviceImage *Imgs) {

if (!GlobalHandler::isInstanceAlive())
GlobalHandler::resetGlobalHandler();

for (size_t Idx = 0; Idx < NumberOfImages; ++Idx)
MNativeImages[Idx] = Imgs[Idx].convertToNativeType();

Expand Down
4 changes: 4 additions & 0 deletions sycl/unittests/pipes/host_pipe_registration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <helpers/MockKernelInfo.hpp>
#include <helpers/UrMock.hpp>
#include <sycl/detail/host_pipe_map.hpp>
#include <detail/global_handler.hpp>

class TestKernel;
MOCK_INTEGRATION_HEADER(TestKernel)
Expand All @@ -32,6 +33,9 @@ using Pipe = sycl::ext::intel::experimental::pipe<PipeID, int, 10,
static sycl::unittest::MockDeviceImage generateDefaultImage() {
using namespace sycl::unittest;

if (!GlobalHandler::isInstanceAlive())
GlobalHandler::resetGlobalHandler();

sycl::detail::host_pipe_map::add(Pipe::get_host_ptr(),
"test_host_pipe_unique_id");

Expand Down
Loading