mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-22 10:17:01 +08:00
Add global destructor of platforms
Change-Id: I7f0c9a9a13cae5cbf831e0d4e410c78c001a75d1 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
e079d94869
commit
40d487fa90
@@ -85,7 +85,6 @@ std::string getRunPath(char *argv0) {
|
||||
std::thread::id tempThreadID;
|
||||
|
||||
void applyWorkarounds() {
|
||||
NEO::platformsImpl.reserve(1);
|
||||
{
|
||||
std::ofstream f;
|
||||
const std::string fileName("_tmp_");
|
||||
|
||||
@@ -84,7 +84,7 @@ cl_int CL_API_CALL clGetPlatformIDs(cl_uint numEntries,
|
||||
|
||||
static std::mutex mutex;
|
||||
std::unique_lock<std::mutex> lock(mutex);
|
||||
if (platformsImpl.empty()) {
|
||||
if (platformsImpl->empty()) {
|
||||
auto executionEnvironment = new ClExecutionEnvironment();
|
||||
executionEnvironment->incRefInternal();
|
||||
auto allDevices = DeviceFactory::createDevices(*executionEnvironment);
|
||||
@@ -101,19 +101,19 @@ cl_int CL_API_CALL clGetPlatformIDs(cl_uint numEntries,
|
||||
retVal = CL_OUT_OF_HOST_MEMORY;
|
||||
break;
|
||||
}
|
||||
platformsImpl.push_back(std::move(pPlatform));
|
||||
platformsImpl->push_back(std::move(pPlatform));
|
||||
}
|
||||
if (retVal != CL_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
cl_uint numPlatformsToExpose = std::min(numEntries, static_cast<cl_uint>(platformsImpl.size()));
|
||||
cl_uint numPlatformsToExpose = std::min(numEntries, static_cast<cl_uint>(platformsImpl->size()));
|
||||
if (numEntries == 0) {
|
||||
numPlatformsToExpose = static_cast<cl_uint>(platformsImpl.size());
|
||||
numPlatformsToExpose = static_cast<cl_uint>(platformsImpl->size());
|
||||
}
|
||||
if (platforms) {
|
||||
for (auto i = 0u; i < numPlatformsToExpose; i++) {
|
||||
platforms[i] = platformsImpl[i].get();
|
||||
platforms[i] = (*platformsImpl)[i].get();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ cl_int CL_API_CALL clGetDeviceIDs(cl_platform_id platform,
|
||||
retVal = CL_DEVICE_NOT_FOUND;
|
||||
break;
|
||||
}
|
||||
pPlatform = platformsImpl[0].get();
|
||||
pPlatform = (*platformsImpl)[0].get();
|
||||
}
|
||||
|
||||
DEBUG_BREAK_IF(pPlatform->isInitialized() != true);
|
||||
|
||||
@@ -17,6 +17,7 @@ set(RUNTIME_SRCS_OS_INTERFACE_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_metrics_library.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/performance_counters_linux.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/performance_counters_linux.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/platform_teardown_linux.cpp
|
||||
)
|
||||
if(UNIX)
|
||||
target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${RUNTIME_SRCS_OS_INTERFACE_LINUX})
|
||||
|
||||
15
opencl/source/os_interface/linux/platform_teardown_linux.cpp
Normal file
15
opencl/source/os_interface/linux/platform_teardown_linux.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "opencl/source/platform/platform.h"
|
||||
|
||||
namespace NEO {
|
||||
void __attribute__((destructor)) platformsDestructor() {
|
||||
delete platformsImpl;
|
||||
platformsImpl = nullptr;
|
||||
}
|
||||
} // namespace NEO
|
||||
@@ -16,6 +16,7 @@ set(RUNTIME_SRCS_OS_INTERFACE_WINDOWS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_metrics_library.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/performance_counters_win.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/performance_counters_win.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/platform_teardown_win.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm_device_command_stream.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm_device_command_stream.inl
|
||||
)
|
||||
|
||||
18
opencl/source/os_interface/windows/platform_teardown_win.cpp
Normal file
18
opencl/source/os_interface/windows/platform_teardown_win.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "opencl/source/platform/platform.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
|
||||
if (fdwReason == DLL_PROCESS_DETACH) {
|
||||
delete platformsImpl;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
} // namespace NEO
|
||||
@@ -37,7 +37,7 @@
|
||||
#include <map>
|
||||
namespace NEO {
|
||||
|
||||
std::vector<std::unique_ptr<Platform>> platformsImpl;
|
||||
std::vector<std::unique_ptr<Platform>> *platformsImpl = new std::vector<std::unique_ptr<Platform>>;
|
||||
|
||||
Platform::Platform(ExecutionEnvironment &executionEnvironmentIn) : executionEnvironment(executionEnvironmentIn) {
|
||||
clDevices.reserve(4);
|
||||
|
||||
@@ -73,5 +73,5 @@ class Platform : public BaseObject<_cl_platform_id> {
|
||||
std::once_flag initializeExtensionsWithVersionOnce;
|
||||
};
|
||||
|
||||
extern std::vector<std::unique_ptr<Platform>> platformsImpl;
|
||||
extern std::vector<std::unique_ptr<Platform>> *platformsImpl;
|
||||
} // namespace NEO
|
||||
|
||||
@@ -352,7 +352,7 @@ cl_int CL_API_CALL clGetGLContextInfoKHR(const cl_context_properties *properties
|
||||
|
||||
if (paramName == CL_DEVICES_FOR_GL_CONTEXT_KHR || paramName == CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR) {
|
||||
if (!platform) {
|
||||
platform = platformsImpl[0].get();
|
||||
platform = (*platformsImpl)[0].get();
|
||||
}
|
||||
|
||||
ClDevice *deviceToReturn = nullptr;
|
||||
|
||||
@@ -55,7 +55,7 @@ struct clCreateCommandQueueWithPropertiesApi : public ApiFixture<>,
|
||||
}
|
||||
|
||||
void SetUp() override {
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
MemoryManagementFixture::SetUp();
|
||||
ApiFixture::SetUp();
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ TEST_F(clGetDeviceIDsTests, GivenDeviceTypeCpuWhenGettingDeviceIdsThenDeviceNotF
|
||||
}
|
||||
|
||||
TEST(clGetDeviceIDsTest, givenMultipleRootDevicesWhenGetDeviceIdsThenAllRootDevicesAreReturned) {
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
constexpr auto numRootDevices = 3u;
|
||||
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
||||
ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false;
|
||||
@@ -116,7 +116,7 @@ TEST(clGetDeviceIDsTest, givenMultipleRootDevicesWhenGetDeviceIdsThenAllRootDevi
|
||||
}
|
||||
}
|
||||
TEST(clGetDeviceIDsTest, givenMultipleRootDevicesWhenGetDeviceIdsButNumEntriesIsLowerThanNumDevicesThenSubsetOfRootDevicesIsReturned) {
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
constexpr auto numRootDevices = 3u;
|
||||
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
||||
ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false;
|
||||
@@ -147,7 +147,7 @@ TEST(clGetDeviceIDsTest, givenMultipleRootDevicesWhenGetDeviceIdsButNumEntriesIs
|
||||
}
|
||||
|
||||
TEST(clGetDeviceIDsTest, givenMultipleRootDevicesAndLimitedNumberOfReturnedDevicesWhenGetDeviceIdsThenLimitedNumberOfRootDevicesIsReturned) {
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
constexpr auto numRootDevices = 3u;
|
||||
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
||||
ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false;
|
||||
@@ -177,7 +177,7 @@ TEST(clGetDeviceIDsNegativeTests, whenFailToCreateDeviceThenclGetDeviceIDsReturn
|
||||
DeviceFactory::createRootDeviceFunc = [](ExecutionEnvironment &executionEnvironment, uint32_t rootDeviceIndex) -> std::unique_ptr<Device> {
|
||||
return nullptr;
|
||||
};
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
|
||||
constexpr auto numRootDevices = 3u;
|
||||
cl_uint numDevices = 0;
|
||||
|
||||
@@ -49,7 +49,7 @@ TEST_F(clGetPlatformIDsTests, GivenNumEntriesZeroAndPlatformNotNullWhenGettingPl
|
||||
}
|
||||
|
||||
TEST(clGetPlatformIDsNegativeTests, GivenFailedInitializationWhenGettingPlatformIdsThenClOutOfHostMemoryErrorIsReturned) {
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
VariableBackup<UltHwConfig> backup{&ultHwConfig};
|
||||
ultHwConfig.mockedPrepareDeviceEnvironmentsFuncResult = false;
|
||||
|
||||
@@ -63,14 +63,14 @@ TEST(clGetPlatformIDsNegativeTests, GivenFailedInitializationWhenGettingPlatform
|
||||
EXPECT_EQ(0u, numPlatforms);
|
||||
EXPECT_EQ(nullptr, platformRet);
|
||||
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
}
|
||||
TEST(clGetPlatformIDsNegativeTests, whenFailToCreateDeviceThenClGetPlatfomsIdsReturnsOutOfHostMemoryError) {
|
||||
VariableBackup<decltype(DeviceFactory::createRootDeviceFunc)> createFuncBackup{&DeviceFactory::createRootDeviceFunc};
|
||||
DeviceFactory::createRootDeviceFunc = [](ExecutionEnvironment &executionEnvironment, uint32_t rootDeviceIndex) -> std::unique_ptr<Device> {
|
||||
return nullptr;
|
||||
};
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
cl_platform_id platformRet = nullptr;
|
||||
@@ -82,7 +82,7 @@ TEST(clGetPlatformIDsNegativeTests, whenFailToCreateDeviceThenClGetPlatfomsIdsRe
|
||||
EXPECT_EQ(0u, numPlatforms);
|
||||
EXPECT_EQ(nullptr, platformRet);
|
||||
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
}
|
||||
|
||||
TEST(clGetPlatformIDsNegativeTests, whenFailToCreatePlatformThenClGetPlatfomsIdsReturnsOutOfHostMemoryError) {
|
||||
@@ -90,7 +90,7 @@ TEST(clGetPlatformIDsNegativeTests, whenFailToCreatePlatformThenClGetPlatfomsIds
|
||||
Platform::createFunc = [](ExecutionEnvironment &executionEnvironment) -> std::unique_ptr<Platform> {
|
||||
return nullptr;
|
||||
};
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
cl_platform_id platformRet = nullptr;
|
||||
@@ -102,7 +102,7 @@ TEST(clGetPlatformIDsNegativeTests, whenFailToCreatePlatformThenClGetPlatfomsIds
|
||||
EXPECT_EQ(0u, numPlatforms);
|
||||
EXPECT_EQ(nullptr, platformRet);
|
||||
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
}
|
||||
|
||||
TEST(clGetPlatformIDsNegativeTests, whenFailToInitializePlatformThenClGetPlatfomsIdsReturnsOutOfHostMemoryError) {
|
||||
@@ -116,7 +116,7 @@ TEST(clGetPlatformIDsNegativeTests, whenFailToInitializePlatformThenClGetPlatfom
|
||||
Platform::createFunc = [](ExecutionEnvironment &executionEnvironment) -> std::unique_ptr<Platform> {
|
||||
return std::make_unique<FailingPlatform>(executionEnvironment);
|
||||
};
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
cl_platform_id platformRet = nullptr;
|
||||
@@ -128,6 +128,6 @@ TEST(clGetPlatformIDsNegativeTests, whenFailToInitializePlatformThenClGetPlatfom
|
||||
EXPECT_EQ(0u, numPlatforms);
|
||||
EXPECT_EQ(nullptr, platformRet);
|
||||
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
}
|
||||
} // namespace ULT
|
||||
|
||||
@@ -52,7 +52,7 @@ struct CommandQueueMemoryDevice
|
||||
|
||||
void TearDown() override {
|
||||
ClDeviceFixture::TearDown();
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
MemoryManagementFixture::TearDown();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -62,7 +62,7 @@ HWTEST_F(PrepareDeviceEnvironmentsTest, givenPrepareDeviceEnvironmentsWhenCsrIsS
|
||||
}
|
||||
|
||||
DebugManager.flags.ProductFamilyOverride.set(productFamily);
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
ExecutionEnvironment *exeEnv = constructPlatform()->peekExecutionEnvironment();
|
||||
|
||||
const auto ret = prepareDeviceEnvironments(*exeEnv);
|
||||
@@ -149,7 +149,7 @@ HWTEST_F(PrepareDeviceEnvironmentsTest, givenPrepareDeviceEnvironmentsAndUnknown
|
||||
|
||||
DebugManager.flags.SetCommandStreamReceiver.set(csrType);
|
||||
DebugManager.flags.ProductFamilyOverride.set(productFamily);
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
ExecutionEnvironment *exeEnv = constructPlatform()->peekExecutionEnvironment();
|
||||
|
||||
auto ret = prepareDeviceEnvironments(*exeEnv);
|
||||
|
||||
@@ -119,7 +119,7 @@ struct ImageClearColorFixture : ::testing::Test {
|
||||
void setUpImpl() {
|
||||
hardwareInfo.capabilityTable.ftrRenderCompressedImages = true;
|
||||
|
||||
NEO::platformsImpl.clear();
|
||||
NEO::platformsImpl->clear();
|
||||
NEO::constructPlatform()->peekExecutionEnvironment()->prepareRootDeviceEnvironments(1u);
|
||||
NEO::platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]->setHwInfo(&hardwareInfo);
|
||||
NEO::platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]->initGmm();
|
||||
|
||||
@@ -39,7 +39,7 @@ class MemoryAllocatorFixture : public MemoryManagementFixture {
|
||||
|
||||
void TearDown() override {
|
||||
device.reset();
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
MemoryManagementFixture::TearDown();
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ void PlatformFixture::SetUp() {
|
||||
}
|
||||
|
||||
void PlatformFixture::TearDown() {
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
delete[] devices;
|
||||
}
|
||||
} // namespace NEO
|
||||
|
||||
@@ -33,7 +33,7 @@ TEST(clGetPlatformIDsMultiPlatformTest, whenCreateDevicesWithDifferentProductFam
|
||||
}
|
||||
return device;
|
||||
};
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
cl_platform_id platformsRet[2];
|
||||
@@ -59,5 +59,5 @@ TEST(clGetPlatformIDsMultiPlatformTest, whenCreateDevicesWithDifferentProductFam
|
||||
EXPECT_EQ(1u, platform1->getNumDevices());
|
||||
EXPECT_EQ(IGFX_SKYLAKE, platform1->getClDevice(0)->getHardwareInfo().platform.eProductFamily);
|
||||
EXPECT_EQ(0u, platform1->getClDevice(0)->getRootDeviceIndex());
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ class GTPinFixture : public ContextFixture, public MemoryManagementFixture {
|
||||
|
||||
public:
|
||||
void SetUp() override {
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
MemoryManagementFixture::SetUp();
|
||||
constructPlatform();
|
||||
pPlatform = platform();
|
||||
@@ -180,7 +180,7 @@ class GTPinFixture : public ContextFixture, public MemoryManagementFixture {
|
||||
|
||||
void TearDown() override {
|
||||
ContextFixture::TearDown();
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
MemoryManagementFixture::TearDown();
|
||||
NEO::isGTPinInitialized = false;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace NEO {
|
||||
void __attribute__((destructor)) platformsDestructor();
|
||||
}
|
||||
using namespace NEO;
|
||||
|
||||
class DrmTestsFixture {
|
||||
@@ -520,3 +523,11 @@ TEST_F(DrmTests, whenCreateDrmIsCalledThenProperHwInfoIsSetup) {
|
||||
EXPECT_LT(0u, currentHwInfo->gtSystemInfo.EUCount);
|
||||
EXPECT_LT(0u, currentHwInfo->gtSystemInfo.SubSliceCount);
|
||||
}
|
||||
|
||||
TEST(PlatformsDestructor, whenGlobalPlatformsDestructorIsCalledThenGlobalPlatformsAreDestroyed) {
|
||||
EXPECT_NE(nullptr, platformsImpl);
|
||||
platformsDestructor();
|
||||
|
||||
EXPECT_EQ(nullptr, platformsImpl);
|
||||
platformsImpl = new std::vector<std::unique_ptr<Platform>>;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ extern std::string lastTest;
|
||||
bool generateRandomInput = false;
|
||||
|
||||
void applyWorkarounds() {
|
||||
platformsImpl.reserve(1);
|
||||
platformsImpl->reserve(1);
|
||||
{
|
||||
std::ofstream f;
|
||||
const std::string fileName("_tmp_");
|
||||
|
||||
@@ -844,7 +844,7 @@ struct ValidHostPtr
|
||||
void TearDown() override {
|
||||
delete buffer;
|
||||
BaseClass::TearDown();
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
MemoryManagementFixture::TearDown();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class DestructorCallbackFixture : public MemoryManagementFixture {
|
||||
|
||||
void TearDown() override {
|
||||
delete BufferDefaults::context;
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
MemoryManagementFixture::TearDown();
|
||||
}
|
||||
|
||||
|
||||
@@ -737,7 +737,7 @@ struct CreateImageHostPtr
|
||||
void TearDown() override {
|
||||
delete image;
|
||||
BaseClass::TearDown();
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
MemoryManagementFixture::TearDown();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,18 +24,18 @@ bool MockPlatform::initializeWithNewDevices() {
|
||||
}
|
||||
|
||||
Platform *platform() {
|
||||
if (platformsImpl.empty()) {
|
||||
if (platformsImpl->empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
return platformsImpl[0].get();
|
||||
return (*platformsImpl)[0].get();
|
||||
}
|
||||
|
||||
Platform *constructPlatform() {
|
||||
static std::mutex mutex;
|
||||
std::unique_lock<std::mutex> lock(mutex);
|
||||
if (platformsImpl.empty()) {
|
||||
platformsImpl.push_back(std::make_unique<Platform>(*(new MockClExecutionEnvironment())));
|
||||
if (platformsImpl->empty()) {
|
||||
platformsImpl->push_back(std::make_unique<Platform>(*(new MockClExecutionEnvironment())));
|
||||
}
|
||||
return platformsImpl[0].get();
|
||||
return (*platformsImpl)[0].get();
|
||||
}
|
||||
} // namespace NEO
|
||||
|
||||
@@ -74,7 +74,7 @@ TEST_F(DeviceFactoryTest, WhenOverridingUsingDebugManagerThenOverridesAreApplied
|
||||
DebugManager.flags.OverrideEnableQuickKmdSleepForSporadicWaits.set(!refEnableQuickKmdSleepForSporadicWaits);
|
||||
DebugManager.flags.OverrideDelayQuickKmdSleepForSporadicWaitsMicroseconds.set(static_cast<int32_t>(refDelayQuickKmdSleepForSporadicWaitsMicroseconds) + 12);
|
||||
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
executionEnvironment = constructPlatform()->peekExecutionEnvironment();
|
||||
success = DeviceFactory::prepareDeviceEnvironments(*executionEnvironment);
|
||||
ASSERT_TRUE(success);
|
||||
|
||||
@@ -28,7 +28,7 @@ TEST_F(clGetGLContextInfoKhrTest, successWithDefaultPlatform) {
|
||||
|
||||
auto defaultPlatform = std::make_unique<MockPlatform>();
|
||||
defaultPlatform->initializeWithNewDevices();
|
||||
platformsImpl[0] = std::move(defaultPlatform);
|
||||
(*platformsImpl)[0] = std::move(defaultPlatform);
|
||||
auto expectedDevice = ::platform()->getClDevice(0);
|
||||
cl_device_id retDevice = 0;
|
||||
size_t retSize = 0;
|
||||
@@ -50,7 +50,7 @@ TEST_F(clGetGLContextInfoKhrTest, successWithDefaultPlatform) {
|
||||
using clGetGLContextInfoKHRNonDefaultPlatform = ::testing::Test;
|
||||
|
||||
TEST_F(clGetGLContextInfoKHRNonDefaultPlatform, successWithNonDefaultPlatform) {
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
|
||||
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
||||
ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false;
|
||||
@@ -132,7 +132,7 @@ TEST_F(clGetGLContextInfoKhrTest, GivenIncorrectPropertiesWhenCallclGetGLContext
|
||||
}
|
||||
|
||||
TEST_F(clGetGLContextInfoKHRNonDefaultPlatform, whenVerificationOfHdcHandleFailsThenInvalidGlReferenceErrorIsReturned) {
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
|
||||
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
||||
ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false;
|
||||
@@ -155,7 +155,7 @@ TEST_F(clGetGLContextInfoKHRNonDefaultPlatform, whenVerificationOfHdcHandleFails
|
||||
EXPECT_EQ(CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR, retVal);
|
||||
}
|
||||
TEST_F(clGetGLContextInfoKHRNonDefaultPlatform, whenVerificationOfHdcHandleFailsForFirstDeviceButSucceedsForSecondOneThenReturnTheSecondDevice) {
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.CreateMultipleRootDevices.set(2);
|
||||
|
||||
@@ -375,7 +375,7 @@ TEST_F(PlatformTest, WhenRemovingLastSpaceThenStringDoesNotEndWithSpace) {
|
||||
EXPECT_EQ(std::string("x"), xSpaceString);
|
||||
}
|
||||
TEST(PlatformConstructionTest, givenPlatformConstructorWhenItIsCalledTwiceThenTheSamePlatformIsReturned) {
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
auto platform1 = constructPlatform();
|
||||
EXPECT_EQ(platform1, platform());
|
||||
auto platform2 = constructPlatform();
|
||||
@@ -384,15 +384,15 @@ TEST(PlatformConstructionTest, givenPlatformConstructorWhenItIsCalledTwiceThenTh
|
||||
}
|
||||
|
||||
TEST(PlatformConstructionTest, givenPlatformConstructorWhenItIsCalledAfterResetThenNewPlatformIsConstructed) {
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
auto platform = constructPlatform();
|
||||
std::unique_ptr<Platform> temporaryOwnership(std::move(platformsImpl[0]));
|
||||
platformsImpl.clear();
|
||||
std::unique_ptr<Platform> temporaryOwnership(std::move((*platformsImpl)[0]));
|
||||
platformsImpl->clear();
|
||||
auto platform2 = constructPlatform();
|
||||
EXPECT_NE(platform2, platform);
|
||||
EXPECT_NE(platform, nullptr);
|
||||
EXPECT_NE(platform2, nullptr);
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
}
|
||||
|
||||
TEST(PlatformInitTest, givenNullptrDeviceInPassedDeviceVectorWhenInitializePlatformThenExceptionIsThrown) {
|
||||
|
||||
@@ -2595,7 +2595,7 @@ TEST(ProgramDestructionTests, givenProgramUsingDeviceWhenItIsDestroyedAfterPlatf
|
||||
auto globalAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{device->getRootDeviceIndex(), MemoryConstants::pageSize});
|
||||
pProgram->setGlobalSurface(globalAllocation);
|
||||
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
EXPECT_EQ(1, device->getRefInternalCount());
|
||||
EXPECT_EQ(1, pProgram->getRefInternalCount());
|
||||
context->decRefInternal();
|
||||
|
||||
@@ -25,7 +25,7 @@ void NEO::UltConfigListener::OnTestStart(const ::testing::TestInfo &testInfo) {
|
||||
}
|
||||
void NEO::UltConfigListener::OnTestEnd(const ::testing::TestInfo &testInfo) {
|
||||
// Clear global platform that it shouldn't be reused between tests
|
||||
platformsImpl.clear();
|
||||
platformsImpl->clear();
|
||||
MemoryManager::maxOsContextCount = 0u;
|
||||
|
||||
// Ensure that global state is restored
|
||||
|
||||
@@ -74,7 +74,7 @@ extern std::string lastTest;
|
||||
bool generateRandomInput = false;
|
||||
|
||||
void applyWorkarounds() {
|
||||
platformsImpl.reserve(1);
|
||||
platformsImpl->reserve(1);
|
||||
{
|
||||
std::ofstream f;
|
||||
const std::string fileName("_tmp_");
|
||||
|
||||
Reference in New Issue
Block a user