mirror of
https://github.com/intel/compute-runtime.git
synced 2025-11-10 05:49:51 +08:00
Add levelZeroSupported field to RuntimeCapabilityTable
So initialization fails gracefully when Level Zero is executed in unsupported platforms. Change-Id: I06bd9f00260ebb1266108bd4ccee7abbc9275200 Signed-off: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
562e45db81
commit
0c1282ab82
@@ -113,23 +113,33 @@ DriverHandleImp::~DriverHandleImp() {
|
||||
}
|
||||
|
||||
ze_result_t DriverHandleImp::initialize(std::vector<std::unique_ptr<NEO::Device>> devices) {
|
||||
this->memoryManager = devices[0]->getMemoryManager();
|
||||
if (this->memoryManager == nullptr) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
|
||||
this->svmAllocsManager = new NEO::SVMAllocsManager(memoryManager);
|
||||
if (this->svmAllocsManager == nullptr) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
}
|
||||
|
||||
this->numDevices = static_cast<uint32_t>(devices.size());
|
||||
|
||||
for (auto &neoDevice : devices) {
|
||||
if (!neoDevice->getHardwareInfo().capabilityTable.levelZeroSupported) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this->memoryManager == nullptr) {
|
||||
this->memoryManager = neoDevice->getMemoryManager();
|
||||
if (this->memoryManager == nullptr) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
}
|
||||
|
||||
this->svmAllocsManager = new NEO::SVMAllocsManager(memoryManager);
|
||||
if (this->svmAllocsManager == nullptr) {
|
||||
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
auto device = Device::create(this, neoDevice.release());
|
||||
this->devices.push_back(device);
|
||||
}
|
||||
|
||||
if (this->devices.size() == 0) {
|
||||
return ZE_RESULT_ERROR_UNINITIALIZED;
|
||||
}
|
||||
|
||||
this->numDevices = static_cast<uint32_t>(this->devices.size());
|
||||
|
||||
extensionFunctionsLookupMap = getExtensionFunctionsLookupMap();
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
|
||||
@@ -160,14 +160,20 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
if (productFamily == IGFX_UNKNOWN) {
|
||||
std::cout << "unknown or unsupported product family has been set: " << argv[i]
|
||||
std::cout << "unknown product family has been set: " << argv[i]
|
||||
<< std::endl;
|
||||
return -1;
|
||||
} else {
|
||||
std::cout << "product family: " << NEO::hardwarePrefix[productFamily] << " ("
|
||||
<< productFamily << ")" << std::endl;
|
||||
}
|
||||
|
||||
hwInfoForTests = *NEO::hardwareInfoTable[productFamily];
|
||||
if (!hwInfoForTests.capabilityTable.levelZeroSupported) {
|
||||
std::cout << "unsupported product family has been set: " << argv[i]
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::cout << "product family: " << NEO::hardwarePrefix[productFamily] << " ("
|
||||
<< productFamily << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
if (!strcmp("--disable_default_listener", argv[i])) {
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/os_interface/device_factory.h"
|
||||
#include "shared/source/os_interface/hw_info_config.h"
|
||||
#include "shared/test/unit_test/helpers/debug_manager_state_restore.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#include "level_zero/core/source/driver/driver_handle_imp.h"
|
||||
@@ -29,5 +33,98 @@ TEST_F(DriverVersionTest, returnsExpectedDriverVersion) {
|
||||
EXPECT_EQ(static_cast<uint32_t>(strtoul(NEO_VERSION_BUILD, NULL, 10)), versionBuild);
|
||||
}
|
||||
|
||||
TEST(DriverTestFamilySupport, whenInitializingDriverOnSupportedFamilyThenDriverIsCreated) {
|
||||
NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get();
|
||||
hwInfo.capabilityTable.levelZeroSupported = true;
|
||||
|
||||
NEO::MockDevice *neoDevice = NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(&hwInfo);
|
||||
NEO::DeviceVector devices;
|
||||
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
|
||||
|
||||
auto driverHandle = DriverHandle::create(std::move(devices));
|
||||
EXPECT_NE(nullptr, driverHandle);
|
||||
delete driverHandle;
|
||||
}
|
||||
|
||||
TEST(DriverTestFamilySupport, whenInitializingDriverOnNotSupportedFamilyThenDriverIsNotCreated) {
|
||||
NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get();
|
||||
hwInfo.capabilityTable.levelZeroSupported = false;
|
||||
|
||||
NEO::MockDevice *neoDevice = NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(&hwInfo);
|
||||
NEO::DeviceVector devices;
|
||||
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
|
||||
|
||||
auto driverHandle = DriverHandle::create(std::move(devices));
|
||||
EXPECT_EQ(nullptr, driverHandle);
|
||||
}
|
||||
|
||||
struct DriverTestMultipleFamilySupport : public ::testing::Test {
|
||||
void SetUp() override {
|
||||
VariableBackup<bool> mockDeviceFlagBackup(&MockDevice::createSingleDevice, false);
|
||||
|
||||
NEO::ExecutionEnvironment *executionEnvironment = new NEO::ExecutionEnvironment();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(numRootDevices);
|
||||
for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) {
|
||||
executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(NEO::defaultHwInfo.get());
|
||||
}
|
||||
|
||||
for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) {
|
||||
devices.push_back(std::unique_ptr<NEO::MockDevice>(NEO::MockDevice::createWithExecutionEnvironment<NEO::MockDevice>(NEO::defaultHwInfo.get(), executionEnvironment, i)));
|
||||
if (i < numSupportedRootDevices) {
|
||||
devices[i]->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.levelZeroSupported = true;
|
||||
} else {
|
||||
devices[i]->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.levelZeroSupported = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DebugManagerStateRestore restorer;
|
||||
std::vector<std::unique_ptr<NEO::Device>> devices;
|
||||
|
||||
const uint32_t numRootDevices = 3u;
|
||||
const uint32_t numSupportedRootDevices = 2u;
|
||||
};
|
||||
|
||||
TEST_F(DriverTestMultipleFamilySupport, whenInitializingDriverWithArrayOfDevicesThenDriverIsInitializedOnlyWithThoseSupported) {
|
||||
auto driverHandle = DriverHandle::create(std::move(devices));
|
||||
EXPECT_NE(nullptr, driverHandle);
|
||||
|
||||
L0::DriverHandleImp *driverHandleImp = reinterpret_cast<L0::DriverHandleImp *>(driverHandle);
|
||||
EXPECT_EQ(numSupportedRootDevices, driverHandleImp->devices.size());
|
||||
|
||||
for (auto d : driverHandleImp->devices) {
|
||||
EXPECT_TRUE(d->getNEODevice()->getHardwareInfo().capabilityTable.levelZeroSupported);
|
||||
}
|
||||
|
||||
delete driverHandle;
|
||||
}
|
||||
|
||||
struct DriverTestMultipleFamilyNoSupport : public ::testing::Test {
|
||||
void SetUp() override {
|
||||
VariableBackup<bool> mockDeviceFlagBackup(&MockDevice::createSingleDevice, false);
|
||||
|
||||
NEO::ExecutionEnvironment *executionEnvironment = new NEO::ExecutionEnvironment();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(numRootDevices);
|
||||
for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) {
|
||||
executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(NEO::defaultHwInfo.get());
|
||||
}
|
||||
|
||||
for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) {
|
||||
devices.push_back(std::unique_ptr<NEO::MockDevice>(NEO::MockDevice::createWithExecutionEnvironment<NEO::MockDevice>(NEO::defaultHwInfo.get(), executionEnvironment, i)));
|
||||
devices[i]->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.levelZeroSupported = false;
|
||||
}
|
||||
}
|
||||
|
||||
DebugManagerStateRestore restorer;
|
||||
std::vector<std::unique_ptr<NEO::Device>> devices;
|
||||
|
||||
const uint32_t numRootDevices = 3u;
|
||||
};
|
||||
|
||||
TEST_F(DriverTestMultipleFamilyNoSupport, whenInitializingDriverWithArrayOfNotSupportedDevicesThenDriverIsNull) {
|
||||
auto driverHandle = DriverHandle::create(std::move(devices));
|
||||
EXPECT_EQ(nullptr, driverHandle);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
} // namespace L0
|
||||
|
||||
@@ -138,14 +138,20 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
if (productFamily == IGFX_UNKNOWN) {
|
||||
std::cout << "unknown or unsupported product family has been set: " << argv[i]
|
||||
std::cout << "unknown product family has been set: " << argv[i]
|
||||
<< std::endl;
|
||||
return -1;
|
||||
} else {
|
||||
std::cout << "product family: " << NEO::hardwarePrefix[productFamily] << " ("
|
||||
<< productFamily << ")" << std::endl;
|
||||
}
|
||||
|
||||
hwInfoForTests = *NEO::hardwareInfoTable[productFamily];
|
||||
if (!hwInfoForTests.capabilityTable.levelZeroSupported) {
|
||||
std::cout << "unsupported product family has been set: " << argv[i]
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::cout << "product family: " << NEO::hardwarePrefix[productFamily] << " ("
|
||||
<< productFamily << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
if (!strcmp("--disable_default_listener", argv[i])) {
|
||||
|
||||
@@ -72,7 +72,8 @@ const RuntimeCapabilityTable EHL::capabilityTable{
|
||||
true, // supportsDeviceEnqueue
|
||||
false, // supportsPipes
|
||||
false, // supportsOcl21Features
|
||||
true // hostPtrTrackingEnabled
|
||||
true, // hostPtrTrackingEnabled
|
||||
false // levelZeroSupported
|
||||
};
|
||||
|
||||
WorkaroundTable EHL::workaroundTable = {};
|
||||
|
||||
@@ -73,7 +73,8 @@ const RuntimeCapabilityTable ICLLP::capabilityTable{
|
||||
true, // supportsDeviceEnqueue
|
||||
true, // supportsPipes
|
||||
true, // supportsOcl21Features
|
||||
true // hostPtrTrackingEnabled
|
||||
true, // hostPtrTrackingEnabled
|
||||
true // levelZeroSupported
|
||||
};
|
||||
|
||||
WorkaroundTable ICLLP::workaroundTable = {};
|
||||
|
||||
@@ -72,7 +72,8 @@ const RuntimeCapabilityTable LKF::capabilityTable{
|
||||
true, // supportsDeviceEnqueue
|
||||
false, // supportsPipes
|
||||
false, // supportsOcl21Features
|
||||
true // hostPtrTrackingEnabled
|
||||
true, // hostPtrTrackingEnabled
|
||||
false // levelZeroSupported
|
||||
};
|
||||
|
||||
WorkaroundTable LKF::workaroundTable = {};
|
||||
|
||||
@@ -74,7 +74,8 @@ const RuntimeCapabilityTable TGLLP::capabilityTable{
|
||||
true, // supportsDeviceEnqueue
|
||||
false, // supportsPipes
|
||||
true, // supportsOcl21Features
|
||||
false // hostPtrTrackingEnabled
|
||||
false, // hostPtrTrackingEnabled
|
||||
true // levelZeroSupported
|
||||
};
|
||||
|
||||
WorkaroundTable TGLLP::workaroundTable = {};
|
||||
|
||||
@@ -77,7 +77,8 @@ const RuntimeCapabilityTable BDW::capabilityTable{
|
||||
true, // supportsDeviceEnqueue
|
||||
true, // supportsPipes
|
||||
true, // supportsOcl21Features
|
||||
true // hostPtrTrackingEnabled
|
||||
true, // hostPtrTrackingEnabled
|
||||
false // levelZeroSupported
|
||||
};
|
||||
|
||||
WorkaroundTable BDW::workaroundTable = {};
|
||||
|
||||
@@ -74,7 +74,8 @@ const RuntimeCapabilityTable BXT::capabilityTable{
|
||||
false, // supportsDeviceEnqueue
|
||||
false, // supportsPipes
|
||||
false, // supportsOcl21Features
|
||||
true // hostPtrTrackingEnabled
|
||||
true, // hostPtrTrackingEnabled
|
||||
false // levelZeroSupported
|
||||
};
|
||||
|
||||
WorkaroundTable BXT::workaroundTable = {};
|
||||
|
||||
@@ -69,7 +69,8 @@ const RuntimeCapabilityTable CFL::capabilityTable{
|
||||
true, // supportsDeviceEnqueue
|
||||
true, // supportsPipes
|
||||
true, // supportsOcl21Features
|
||||
true // hostPtrTrackingEnabled
|
||||
true, // hostPtrTrackingEnabled
|
||||
true // levelZeroSupported
|
||||
};
|
||||
|
||||
WorkaroundTable CFL::workaroundTable = {};
|
||||
|
||||
@@ -69,7 +69,8 @@ const RuntimeCapabilityTable GLK::capabilityTable{
|
||||
false, // supportsDeviceEnqueue
|
||||
false, // supportsPipes
|
||||
false, // supportsOcl21Features
|
||||
true // hostPtrTrackingEnabled
|
||||
true, // hostPtrTrackingEnabled
|
||||
false // levelZeroSupported
|
||||
};
|
||||
|
||||
WorkaroundTable GLK::workaroundTable = {};
|
||||
|
||||
@@ -69,7 +69,8 @@ const RuntimeCapabilityTable KBL::capabilityTable{
|
||||
true, // supportsDeviceEnqueue
|
||||
true, // supportsPipes
|
||||
true, // supportsOcl21Features
|
||||
true // hostPtrTrackingEnabled
|
||||
true, // hostPtrTrackingEnabled
|
||||
true // levelZeroSupported
|
||||
};
|
||||
|
||||
WorkaroundTable KBL::workaroundTable = {};
|
||||
|
||||
@@ -77,7 +77,8 @@ const RuntimeCapabilityTable SKL::capabilityTable{
|
||||
true, // supportsDeviceEnqueue
|
||||
true, // supportsPipes
|
||||
true, // supportsOcl21Features
|
||||
true // hostPtrTrackingEnabled
|
||||
true, // hostPtrTrackingEnabled
|
||||
true // levelZeroSupported
|
||||
};
|
||||
WorkaroundTable SKL::workaroundTable = {};
|
||||
FeatureTable SKL::featureTable = {};
|
||||
|
||||
@@ -57,6 +57,7 @@ struct RuntimeCapabilityTable {
|
||||
bool supportsPipes;
|
||||
bool supportsOcl21Features;
|
||||
bool hostPtrTrackingEnabled;
|
||||
bool levelZeroSupported;
|
||||
};
|
||||
|
||||
struct HardwareCapabilities {
|
||||
|
||||
Reference in New Issue
Block a user