Pass ExecutionEnvironment to get devices.

- this would allow for further re-use of objects allocated here.

Change-Id: I73b62ae3991ebd786dea3c085e1391194b8de6ba
This commit is contained in:
Mrozek, Michal 2018-08-07 14:46:15 +02:00
parent 4eb2e64231
commit d17879d412
18 changed files with 51 additions and 37 deletions

View File

@ -61,7 +61,7 @@ CommandStreamReceiver *createCommandStreamImpl(const HardwareInfo *pHwInfo) {
return commandStreamReceiver;
}
bool getDevicesImpl(HardwareInfo **hwInfo, size_t &numDevicesReturned) {
bool getDevicesImpl(HardwareInfo **hwInfo, size_t &numDevicesReturned, ExecutionEnvironment &executionEnvironment) {
bool result;
int32_t csr = DebugManager.flags.SetCommandStreamReceiver.get();
if (csr) {
@ -78,12 +78,12 @@ bool getDevicesImpl(HardwareInfo **hwInfo, size_t &numDevicesReturned) {
return true;
}
case CSR_HW_WITH_AUB:
return DeviceFactory::getDevices(hwInfo, numDevicesReturned);
return DeviceFactory::getDevices(hwInfo, numDevicesReturned, executionEnvironment);
default:
return false;
}
}
result = DeviceFactory::getDevices(hwInfo, numDevicesReturned);
result = DeviceFactory::getDevices(hwInfo, numDevicesReturned, executionEnvironment);
DEBUG_BREAK_IF(result && (hwInfo == nullptr));
return result;
}

View File

@ -25,6 +25,7 @@
#include "runtime/helpers/hw_info.h"
namespace OCLRT {
class ExecutionEnvironment;
extern CommandStreamReceiver *createCommandStreamImpl(const HardwareInfo *pHwInfo);
extern bool getDevicesImpl(HardwareInfo **hwInfo, size_t &numDevicesReturned);
extern bool getDevicesImpl(HardwareInfo **hwInfo, size_t &numDevicesReturned, ExecutionEnvironment &executionEnvironment);
} // namespace OCLRT

View File

@ -36,8 +36,8 @@ CommandStreamReceiver *createCommandStream(const HardwareInfo *pHwInfo) {
return createCommandStreamImpl(pHwInfo);
}
bool getDevices(HardwareInfo **hwInfo, size_t &numDevicesReturned) {
return getDevicesImpl(hwInfo, numDevicesReturned);
bool getDevices(HardwareInfo **hwInfo, size_t &numDevicesReturned, ExecutionEnvironment &executionEnviornment) {
return getDevicesImpl(hwInfo, numDevicesReturned, executionEnviornment);
}
} // namespace OCLRT

View File

@ -26,10 +26,11 @@
namespace OCLRT {
struct HardwareInfo;
class ExecutionEnvironment;
class DeviceFactory {
public:
static bool getDevices(HardwareInfo **pHWInfos, size_t &numDevices);
static bool getDevices(HardwareInfo **pHWInfos, size_t &numDevices, ExecutionEnvironment &executionEnvironment);
static void releaseDevices();
protected:

View File

@ -38,7 +38,7 @@ namespace OCLRT {
size_t DeviceFactory::numDevices = 0;
HardwareInfo *DeviceFactory::hwInfos = nullptr;
bool DeviceFactory::getDevices(HardwareInfo **pHWInfos, size_t &numDevices) {
bool DeviceFactory::getDevices(HardwareInfo **pHWInfos, size_t &numDevices, ExecutionEnvironment &executionEnvironment) {
std::vector<HardwareInfo> tHwInfos;
unsigned int devNum = 0;
size_t requiredDeviceCount = 1;

View File

@ -36,7 +36,7 @@ extern const HardwareInfo *hardwareInfoTable[IGFX_MAX_PRODUCT];
size_t DeviceFactory::numDevices = 0;
HardwareInfo *DeviceFactory::hwInfos = nullptr;
bool DeviceFactory::getDevices(HardwareInfo **pHWInfos, size_t &numDevices) {
bool DeviceFactory::getDevices(HardwareInfo **pHWInfos, size_t &numDevices, ExecutionEnvironment &executionEnvironment) {
auto totalDeviceCount = 1u;
if (DebugManager.flags.CreateMultipleDevices.get()) {
totalDeviceCount = DebugManager.flags.CreateMultipleDevices.get();

View File

@ -42,7 +42,7 @@ namespace OCLRT {
std::unique_ptr<Platform> platformImpl;
bool getDevices(HardwareInfo **hwInfo, size_t &numDevicesReturned);
bool getDevices(HardwareInfo **hwInfo, size_t &numDevicesReturned, ExecutionEnvironment &executionEnvironment);
Platform *platform() { return platformImpl.get(); }
@ -138,7 +138,7 @@ bool Platform::initialize() {
return true;
}
state = OCLRT::getDevices(&hwInfo, numDevicesReturned) ? StateIniting : StateNone;
state = OCLRT::getDevices(&hwInfo, numDevicesReturned, *executionEnvironment) ? StateIniting : StateNone;
if (state == StateNone) {
return false;

View File

@ -21,6 +21,7 @@
*/
#include "runtime/command_stream/command_stream_receiver.h"
#include "runtime/execution_environment/execution_environment.h"
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
#include "runtime/os_interface/device_factory.h"
#include "runtime/helpers/options.h"
@ -57,7 +58,8 @@ HWTEST_P(GetDevicesTest, givenGetDevicesWhenCsrIsSetToValidTypeThenTheFuntionRet
int i = 0;
size_t numDevices = 0;
HardwareInfo *hwInfo = nullptr;
auto ret = getDevices(&hwInfo, numDevices);
ExecutionEnvironment executionEnvironment;
auto ret = getDevices(&hwInfo, numDevices, executionEnvironment);
switch (csrType) {
case CSR_HW:

View File

@ -29,7 +29,7 @@ GEN10TEST_F(DeviceFactoryLinuxTestCnl, queryWhitelistedPreemptionRegister) {
HardwareInfo *hwInfo = nullptr;
size_t numDevices = 0;
bool success = DeviceFactory::getDevices(&hwInfo, numDevices);
bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment);
EXPECT_TRUE(success);
#if defined(I915_PARAM_HAS_PREEMPTION)
EXPECT_TRUE(hwInfo->capabilityTable.whitelistedRegisters.csChicken1_0x2580);
@ -45,7 +45,7 @@ GEN10TEST_F(DeviceFactoryLinuxTestCnl, queryNotWhitelistedPreemptionRegister) {
HardwareInfo *hwInfo = nullptr;
size_t numDevices = 0;
bool success = DeviceFactory::getDevices(&hwInfo, numDevices);
bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment);
EXPECT_TRUE(success);
EXPECT_FALSE(hwInfo->capabilityTable.whitelistedRegisters.csChicken1_0x2580);

View File

@ -20,6 +20,7 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "runtime/execution_environment/execution_environment.h"
#include "unit_tests/os_interface/windows/os_interface_win_tests.h"
#include "unit_tests/gen_common/test.h"
@ -30,7 +31,8 @@ GEN10TEST_F(OsInterfaceTestCnl, askKmdIfPreemptionRegisterWhitelisted) {
const HardwareInfo *refHwinfo = *platformDevices;
size_t numDevices = 0;
bool success = DeviceFactory::getDevices(&hwInfo, numDevices);
ExecutionEnvironment executionEnvironment;
bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment);
EXPECT_TRUE(success);
for (size_t i = 0u; i < numDevices; i++) {

View File

@ -29,7 +29,7 @@ GEN9TEST_F(DeviceFactoryLinuxTestSkl, queryWhitelistedPreemptionRegister) {
HardwareInfo *hwInfo = nullptr;
size_t numDevices = 0;
bool success = DeviceFactory::getDevices(&hwInfo, numDevices);
bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment);
EXPECT_TRUE(success);
#if defined(I915_PARAM_HAS_PREEMPTION)
EXPECT_TRUE(hwInfo->capabilityTable.whitelistedRegisters.csChicken1_0x2580);
@ -45,7 +45,7 @@ GEN9TEST_F(DeviceFactoryLinuxTestSkl, queryNotWhitelistedPreemptionRegister) {
HardwareInfo *hwInfo = nullptr;
size_t numDevices = 0;
bool success = DeviceFactory::getDevices(&hwInfo, numDevices);
bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment);
EXPECT_TRUE(success);
EXPECT_FALSE(hwInfo->capabilityTable.whitelistedRegisters.csChicken1_0x2580);

View File

@ -20,6 +20,7 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "runtime/execution_environment/execution_environment.h"
#include "unit_tests/os_interface/windows/os_interface_win_tests.h"
#include "unit_tests/gen_common/test.h"
@ -30,7 +31,8 @@ GEN9TEST_F(OsInterfaceTestSkl, askKmdIfPreemptionRegisterWhitelisted) {
const HardwareInfo *refHwinfo = *platformDevices;
size_t numDevices = 0;
bool success = DeviceFactory::getDevices(&hwInfo, numDevices);
ExecutionEnvironment executionEnvironment;
bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment);
EXPECT_TRUE(success);
for (size_t i = 0u; i < numDevices; i++) {

View File

@ -52,13 +52,13 @@ CommandStreamReceiver *createCommandStream(const HardwareInfo *pHwInfo) {
return commandStreamReceiver;
}
bool getDevices(HardwareInfo **hwInfo, size_t &numDevicesReturned) {
bool getDevices(HardwareInfo **hwInfo, size_t &numDevicesReturned, ExecutionEnvironment &executionEnvironment) {
if (overrideDeviceWithDefaultHardwareInfo) {
*hwInfo = const_cast<HardwareInfo *>(*platformDevices);
numDevicesReturned = numPlatformDevices;
return getDevicesResult;
}
return getDevicesImpl(hwInfo, numDevicesReturned);
return getDevicesImpl(hwInfo, numDevicesReturned, executionEnvironment);
}
} // namespace OCLRT

View File

@ -27,5 +27,5 @@ extern bool overrideCommandStreamReceiverCreation;
extern bool overrideDeviceWithDefaultHardwareInfo;
extern CommandStreamReceiver *createCommandStream(const HardwareInfo *pHwInfo);
extern bool getDevices(HardwareInfo **hwInfo, size_t &numDevicesReturned);
extern bool getDevices(HardwareInfo **hwInfo, size_t &numDevicesReturned, ExecutionEnvironment &executionEnvironment);
} // namespace OCLRT

View File

@ -20,6 +20,7 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "runtime/execution_environment/execution_environment.h"
#include "runtime/helpers/hw_info.h"
#include "runtime/helpers/options.h"
#include "runtime/os_interface/device_factory.h"
@ -45,13 +46,14 @@ struct DeviceFactoryTest : public ::testing::Test {
protected:
OsLibrary *mockGdiDll;
ExecutionEnvironment executionEnvironment;
};
TEST_F(DeviceFactoryTest, GetDevices_Expect_True_If_Returned) {
DeviceFactoryCleaner cleaner;
HardwareInfo *hwInfo = nullptr;
size_t numDevices = 0;
bool success = DeviceFactory::getDevices(&hwInfo, numDevices);
bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment);
EXPECT_TRUE((numDevices > 0) ? success : !success);
}
@ -60,7 +62,7 @@ TEST_F(DeviceFactoryTest, GetDevices_Check_HwInfo_Null) {
DeviceFactoryCleaner cleaner;
HardwareInfo *hwInfo = nullptr;
size_t numDevices = 0;
bool success = DeviceFactory::getDevices(&hwInfo, numDevices);
bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment);
EXPECT_TRUE((numDevices > 0) ? success : !success);
if (numDevices > 0) {
@ -78,7 +80,7 @@ TEST_F(DeviceFactoryTest, GetDevices_Check_HwInfo_Platform) {
const HardwareInfo *refHwinfo = *platformDevices;
size_t numDevices = 0;
bool success = DeviceFactory::getDevices(&hwInfo, numDevices);
bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment);
EXPECT_TRUE((numDevices > 0) ? success : !success);
if (numDevices > 0) {
@ -97,7 +99,7 @@ TEST_F(DeviceFactoryTest, overrideKmdNotifySettings) {
HardwareInfo *hwInfoOverriden = nullptr;
size_t numDevices = 0;
bool success = DeviceFactory::getDevices(&hwInfoReference, numDevices);
bool success = DeviceFactory::getDevices(&hwInfoReference, numDevices, executionEnvironment);
ASSERT_TRUE(success);
auto refEnableKmdNotify = hwInfoReference->capabilityTable.kmdNotifyProperties.enableKmdNotify;
auto refDelayKmdNotifyMicroseconds = hwInfoReference->capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds;
@ -116,7 +118,7 @@ TEST_F(DeviceFactoryTest, overrideKmdNotifySettings) {
DebugManager.flags.OverrideEnableQuickKmdSleepForSporadicWaits.set(!refEnableQuickKmdSleepForSporadicWaits);
DebugManager.flags.OverrideDelayQuickKmdSleepForSporadicWaitsMicroseconds.set(static_cast<int32_t>(refDelayQuickKmdSleepForSporadicWaitsMicroseconds) + 12);
success = DeviceFactory::getDevices(&hwInfoOverriden, numDevices);
success = DeviceFactory::getDevices(&hwInfoOverriden, numDevices, executionEnvironment);
ASSERT_TRUE(success);
EXPECT_EQ(!refEnableKmdNotify, hwInfoOverriden->capabilityTable.kmdNotifyProperties.enableKmdNotify);
@ -139,7 +141,7 @@ TEST_F(DeviceFactoryTest, getEngineTypeDebugOverride) {
HardwareInfo *hwInfoOverriden = nullptr;
size_t numDevices = 0;
bool success = DeviceFactory::getDevices(&hwInfoOverriden, numDevices);
bool success = DeviceFactory::getDevices(&hwInfoOverriden, numDevices, executionEnvironment);
ASSERT_TRUE(success);
ASSERT_NE(nullptr, hwInfoOverriden);
int32_t actualEngineType = static_cast<int32_t>(hwInfoOverriden->capabilityTable.defaultEngineType);
@ -150,7 +152,7 @@ TEST_F(DeviceFactoryTest, givenPointerToHwInfoWhenGetDevicedCalledThenRequiedSur
DeviceFactoryCleaner cleaner;
HardwareInfo *hwInfo = nullptr;
size_t numDevices = 0;
bool success = DeviceFactory::getDevices(&hwInfo, numDevices);
bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment);
ASSERT_TRUE(success);
EXPECT_EQ(hwInfo->pSysInfo->CsrSizeInMb * MemoryConstants::megaByte, hwInfo->capabilityTable.requiredPreemptionSurfaceSize);
@ -163,7 +165,7 @@ TEST_F(DeviceFactoryTest, givenCreateMultipleDevicesDebugFlagWhenGetDevicesIsCal
DebugManager.flags.CreateMultipleDevices.set(requiredDeviceCount);
HardwareInfo *hwInfo = nullptr;
size_t numDevices = 0;
bool success = DeviceFactory::getDevices(&hwInfo, numDevices);
bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment);
ASSERT_NE(nullptr, hwInfo);
for (auto deviceIndex = 0u; deviceIndex < requiredDeviceCount; deviceIndex++) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Intel Corporation
* Copyright (c) 2017 - 2018, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@ -30,7 +30,7 @@ TEST_F(DeviceFactoryLinuxTest, GetDevicesCheckEUCntSSCnt) {
pDrm->StoredEUVal = 11;
pDrm->StoredSSVal = 8;
bool success = DeviceFactory::getDevices(&hwInfo, numDevices);
bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment);
EXPECT_TRUE(success);
EXPECT_EQ((int)numDevices, 1);
@ -52,7 +52,7 @@ TEST_F(DeviceFactoryLinuxTest, GetDevicesDrmCreateFailed) {
size_t numDevices = 0;
pushDrmMock(nullptr);
bool success = DeviceFactory::getDevices(&hwInfo, numDevices);
bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment);
EXPECT_FALSE(success);
popDrmMock();
@ -64,7 +64,7 @@ TEST_F(DeviceFactoryLinuxTest, GetDevicesDrmCreateFailedConfigureHwInfo) {
pDrm->StoredRetValForDeviceID = -1;
bool success = DeviceFactory::getDevices(&hwInfo, numDevices);
bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment);
EXPECT_FALSE(success);
pDrm->StoredRetValForDeviceID = 0;
@ -83,7 +83,7 @@ TEST_F(DeviceFactoryLinuxTest, ReleaseDevices) {
pDrm->StoredMinEUinPool = 9;
pDrm->StoredRetVal = -1;
bool success = mockDeviceFactory.getDevices(&hwInfo, numDevices);
bool success = mockDeviceFactory.getDevices(&hwInfo, numDevices, executionEnvironment);
EXPECT_TRUE(success);
mockDeviceFactory.releaseDevices();

View File

@ -23,6 +23,7 @@
#pragma once
#include "runtime/device/device.h"
#include "runtime/execution_environment/execution_environment.h"
#include "runtime/helpers/options.h"
#include "runtime/os_interface/device_factory.h"
#include "unit_tests/mocks/mock_device_factory.h"
@ -50,4 +51,5 @@ struct DeviceFactoryLinuxTest : public ::testing::Test {
}
DrmMock *pDrm;
ExecutionEnvironment executionEnvironment;
};

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Intel Corporation
* Copyright (c) 2017 - 2018, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@ -20,6 +20,7 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "runtime/execution_environment/execution_environment.h"
#include "runtime/helpers/hw_info.h"
#include "unit_tests/custom_event_listener.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
@ -28,7 +29,7 @@
using namespace OCLRT;
namespace OCLRT {
bool getDevices(HardwareInfo **hwInfo, size_t &numDevicesReturned);
bool getDevices(HardwareInfo **hwInfo, size_t &numDevicesReturned, ExecutionEnvironment &executionEnvironment);
}
TEST(CSRTests, getDevices) {
@ -37,7 +38,8 @@ TEST(CSRTests, getDevices) {
DebugManagerStateRestore dbgState;
DebugManager.flags.SetCommandStreamReceiver.set(2);
OCLRT::getDevices(&hwInfo, numDevicesReturned);
ExecutionEnvironment executionEnvironment;
OCLRT::getDevices(&hwInfo, numDevicesReturned, executionEnvironment);
ASSERT_NE(nullptr, hwInfo);
ASSERT_NE(nullptr, hwInfo->pSysInfo);