Fixed Global Driver to be void * with library unload driver cleanup

- Changed Global Driver to be a void * to avoid auto add of Global
Driver Destructor to run before destruction of other L0 data structures
that might be enqueued to destory in static object destructors.
- Added register of library unload driverdestructor to cleanup
driver/device as the last destructor run.

Change-Id: I8ba6c5c27424b942a86a2613edd52fc682ab1c64
Signed-off-by: Spruit, Neil R <neil.r.spruit@intel.com>
This commit is contained in:
Spruit, Neil R
2020-04-11 09:52:49 +00:00
committed by sys_ocldev
parent a9c2840770
commit e1d9f92b94
14 changed files with 63 additions and 7 deletions

View File

@@ -57,6 +57,7 @@ struct CommandQueueThreadArbitrationPolicyTests : public ::testing::Test {
void TearDown() override {
commandList->destroy();
commandQueue->destroy();
L0::GlobalDriver = nullptr;
}
DebugManagerStateRestore restorer;

View File

@@ -57,6 +57,7 @@ struct CommandQueueThreadArbitrationPolicyTests : public ::testing::Test {
void TearDown() override {
commandList->destroy();
commandQueue->destroy();
L0::GlobalDriver = nullptr;
}
DebugManagerStateRestore restorer;

View File

@@ -13,6 +13,7 @@
#include "opencl/test/unit_test/mocks/mock_source_level_debugger.h"
#include "level_zero/core/source/cmdqueue/cmdqueue_hw.h"
#include "level_zero/core/source/driver/driver_handle_imp.h"
#include "level_zero/core/source/fence/fence.h"
#include "level_zero/core/source/module/module.h"
#include "level_zero/core/test/unit_tests/mocks/mock_built_ins.h"
@@ -54,6 +55,7 @@ struct ActiveDebuggerFixture {
ASSERT_NE(nullptr, deviceL0);
}
void TearDown() { // NOLINT(readability-identifier-naming)
L0::GlobalDriver = nullptr;
}
std::unique_ptr<L0::ult::WhiteBox<L0::DriverHandle>> driverHandle;

View File

@@ -47,6 +47,7 @@ TEST(DriverTestFamilySupport, whenInitializingDriverOnSupportedFamilyThenDriverI
auto driverHandle = DriverHandle::create(std::move(devices));
EXPECT_NE(nullptr, driverHandle);
delete driverHandle;
L0::GlobalDriver = nullptr;
}
TEST(DriverTestFamilySupport, whenInitializingDriverOnNotSupportedFamilyThenDriverIsNotCreated) {
@@ -75,6 +76,7 @@ TEST(DriverTest, givenNullEnvVariableWhenCreatingDriverThenEnableProgramDebuggin
EXPECT_FALSE(driverHandle->enableProgramDebugging);
delete driverHandle;
L0::GlobalDriver = nullptr;
}
TEST(DriverTest, givenEnvVariableNonZeroWhenCreatingDriverThenEnableProgramDebuggingIsSetTrue) {
@@ -93,6 +95,7 @@ TEST(DriverTest, givenEnvVariableNonZeroWhenCreatingDriverThenEnableProgramDebug
EXPECT_TRUE(driverHandle->enableProgramDebugging);
delete driverHandle;
L0::GlobalDriver = nullptr;
}
struct DriverTestMultipleFamilySupport : public ::testing::Test {
@@ -134,6 +137,7 @@ TEST_F(DriverTestMultipleFamilySupport, whenInitializingDriverWithArrayOfDevices
}
delete driverHandle;
L0::GlobalDriver = nullptr;
}
struct DriverTestMultipleFamilyNoSupport : public ::testing::Test {
@@ -224,6 +228,7 @@ TEST_F(DriverTestMultipleDeviceWithAffinityMask,
}
delete driverHandle;
L0::GlobalDriver = nullptr;
}
TEST_P(DriverTestMultipleDeviceWithAffinityMask,
@@ -284,6 +289,7 @@ TEST_P(DriverTestMultipleDeviceWithAffinityMask,
}
delete driverHandle;
L0::GlobalDriver = nullptr;
}
MaskArray maskArray;