Skip to content

Commit 7a3095c

Browse files
Report failure given Compiler Library Load failed for L0
- Return ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE given the Compiler cannot be loaded. - Print dlopen and LoadLibrary error strings given Debug Print Messages are enabled. Related-To: LOCI-1313 Signed-off-by: Spruit, Neil R <[email protected]>
1 parent 95b9880 commit 7a3095c

37 files changed

+297
-49
lines changed

level_zero/core/source/device/device.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ struct Device : _ze_device_handle_t {
106106

107107
inline ze_device_handle_t toHandle() { return this; }
108108

109-
static Device *create(DriverHandle *driverHandle, NEO::Device *neoDevice, uint32_t currentDeviceMask, bool isSubDevice);
109+
static Device *create(DriverHandle *driverHandle, NEO::Device *neoDevice, uint32_t currentDeviceMask, bool isSubDevice, ze_result_t *returnValue);
110110

111111
virtual NEO::PreemptionMode getDevicePreemptionMode() const = 0;
112112
virtual const NEO::DeviceInfo &getDeviceInfo() const = 0;

level_zero/core/source/device/device_imp.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ uint32_t DeviceImp::getMaxNumHwThreads() const { return maxNumHwThreads; }
587587

588588
const NEO::HardwareInfo &DeviceImp::getHwInfo() const { return neoDevice->getHardwareInfo(); }
589589

590-
Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, uint32_t currentDeviceMask, bool isSubDevice) {
590+
Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, uint32_t currentDeviceMask, bool isSubDevice, ze_result_t *returnValue) {
591591
auto device = new DeviceImp;
592592
UNRECOVERABLE_IF(device == nullptr);
593593

@@ -629,7 +629,7 @@ Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, uint3
629629
ze_device_handle_t subDevice = Device::create(driverHandle,
630630
device->neoDevice->getDeviceById(i),
631631
0,
632-
true);
632+
true, returnValue);
633633
if (subDevice == nullptr) {
634634
return nullptr;
635635
}
@@ -646,6 +646,8 @@ Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, uint3
646646
auto sipType = NEO::SipKernel::getSipKernelType(hwInfo.platform.eRenderCoreFamily, neoDevice->getDebugger());
647647
NEO::initSipKernel(sipType, *neoDevice);
648648
}
649+
} else {
650+
*returnValue = ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE;
649651
}
650652

651653
auto supportDualStorageSharedMemory = neoDevice->getMemoryManager()->isLocalMemorySupported(device->neoDevice->getRootDeviceIndex());
@@ -660,10 +662,10 @@ Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, uint3
660662
cmdQueueDesc.flags = 0;
661663
cmdQueueDesc.stype = ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC;
662664
cmdQueueDesc.mode = ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS;
663-
ze_result_t returnValue = ZE_RESULT_SUCCESS;
665+
ze_result_t resultValue = ZE_RESULT_SUCCESS;
664666
device->pageFaultCommandList =
665667
CommandList::createImmediate(
666-
device->neoDevice->getHardwareInfo().platform.eProductFamily, device, &cmdQueueDesc, true, NEO::EngineGroupType::RenderCompute, returnValue);
668+
device->neoDevice->getHardwareInfo().platform.eProductFamily, device, &cmdQueueDesc, true, NEO::EngineGroupType::RenderCompute, resultValue);
667669
}
668670

669671
if (device->getSourceLevelDebugger()) {

level_zero/core/source/driver/driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void DriverImp::initialize(ze_result_t *result) {
5555
auto neoDevices = NEO::DeviceFactory::createDevices(*executionEnvironment);
5656
executionEnvironment->decRefInternal();
5757
if (!neoDevices.empty()) {
58-
GlobalDriverHandle = DriverHandle::create(std::move(neoDevices), envVariables);
58+
GlobalDriverHandle = DriverHandle::create(std::move(neoDevices), envVariables, result);
5959
if (GlobalDriverHandle != nullptr) {
6060
*result = ZE_RESULT_SUCCESS;
6161

level_zero/core/source/driver/driver_handle.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ struct DriverHandle : _ze_driver_handle_t {
8686
DriverHandle &operator=(const DriverHandle &) = delete;
8787
DriverHandle &operator=(DriverHandle &&) = delete;
8888

89-
static DriverHandle *create(std::vector<std::unique_ptr<NEO::Device>> devices, const L0EnvVariables &envVariables);
89+
static DriverHandle *create(std::vector<std::unique_ptr<NEO::Device>> devices, const L0EnvVariables &envVariables, ze_result_t *returnValue);
9090
};
9191

9292
} // namespace L0

level_zero/core/source/driver/driver_handle_imp.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ ze_result_t DriverHandleImp::initialize(std::vector<std::unique_ptr<NEO::Device>
202202

203203
bool multiOsContextDriver = false;
204204
for (auto &neoDevice : neoDevices) {
205+
ze_result_t returnValue = ZE_RESULT_SUCCESS;
205206
if (!neoDevice->getHardwareInfo().capabilityTable.levelZeroSupported) {
206207
continue;
207208
}
@@ -226,10 +227,13 @@ ze_result_t DriverHandleImp::initialize(std::vector<std::unique_ptr<NEO::Device>
226227
this->deviceBitfields.insert({neoDevice->getRootDeviceIndex(), neoDevice->getDeviceBitfield()});
227228

228229
auto pNeoDevice = neoDevice.release();
229-
auto device = Device::create(this, pNeoDevice, pNeoDevice->getExecutionEnvironment()->rootDeviceEnvironments[pNeoDevice->getRootDeviceIndex()]->deviceAffinityMask, false);
230+
auto device = Device::create(this, pNeoDevice, pNeoDevice->getExecutionEnvironment()->rootDeviceEnvironments[pNeoDevice->getRootDeviceIndex()]->deviceAffinityMask, false, &returnValue);
230231
this->devices.push_back(device);
231232

232233
multiOsContextDriver |= device->isMultiDeviceCapable();
234+
if (returnValue != ZE_RESULT_SUCCESS) {
235+
return returnValue;
236+
}
233237
}
234238

235239
if (this->devices.size() == 0) {
@@ -254,7 +258,7 @@ ze_result_t DriverHandleImp::initialize(std::vector<std::unique_ptr<NEO::Device>
254258
return ZE_RESULT_SUCCESS;
255259
}
256260

257-
DriverHandle *DriverHandle::create(std::vector<std::unique_ptr<NEO::Device>> devices, const L0EnvVariables &envVariables) {
261+
DriverHandle *DriverHandle::create(std::vector<std::unique_ptr<NEO::Device>> devices, const L0EnvVariables &envVariables, ze_result_t *returnValue) {
258262
DriverHandleImp *driverHandle = new DriverHandleImp;
259263
UNRECOVERABLE_IF(nullptr == driverHandle);
260264

@@ -264,6 +268,7 @@ DriverHandle *DriverHandle::create(std::vector<std::unique_ptr<NEO::Device>> dev
264268
ze_result_t res = driverHandle->initialize(std::move(devices));
265269
if (res != ZE_RESULT_SUCCESS) {
266270
delete driverHandle;
271+
*returnValue = res;
267272
return nullptr;
268273
}
269274

level_zero/core/test/unit_tests/fixtures/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (C) 2020 Intel Corporation
2+
# Copyright (C) 2020-2021 Intel Corporation
33
#
44
# SPDX-License-Identifier: MIT
55
#
@@ -15,7 +15,7 @@ set(L0_FIXTURES_SOURCES
1515
${CMAKE_CURRENT_SOURCE_DIR}/module_fixture.h
1616
)
1717

18-
add_library(${TARGET_NAME} OBJECT ${L0_FIXTURES_SOURCES})
18+
add_library(${TARGET_NAME} OBJECT ${L0_FIXTURES_SOURCES} ${IGDRCL_SRCS_tests_compiler_mocks})
1919

2020
target_include_directories(${TARGET_NAME} PRIVATE
2121
$<TARGET_PROPERTY:gmock-gtest,INTERFACE_INCLUDE_DIRECTORIES>

level_zero/core/test/unit_tests/fixtures/device_fixture.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include "shared/test/common/helpers/default_hw_info.h"
1313
#include "shared/test/common/mocks/mock_device.h"
1414

15+
#include "opencl/test/unit_test/mocks/mock_compilers.h"
16+
1517
#include "level_zero/core/source/context/context_imp.h"
1618
#include "level_zero/core/test/unit_tests/mocks/mock_driver_handle.h"
1719

@@ -22,6 +24,7 @@ struct Device;
2224
namespace ult {
2325

2426
struct DeviceFixture {
27+
NEO::MockCompilerEnableGuard compilerMock = NEO::MockCompilerEnableGuard(true);
2528
virtual void SetUp(); // NOLINT(readability-identifier-naming)
2629
virtual void TearDown(); // NOLINT(readability-identifier-naming)
2730

@@ -32,6 +35,7 @@ struct DeviceFixture {
3235
};
3336

3437
struct MultiDeviceFixture {
38+
NEO::MockCompilerEnableGuard compilerMock = NEO::MockCompilerEnableGuard(true);
3539
virtual void SetUp(); // NOLINT(readability-identifier-naming)
3640
virtual void TearDown(); // NOLINT(readability-identifier-naming)
3741

level_zero/core/test/unit_tests/fixtures/host_pointer_manager_fixture.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "shared/test/common/helpers/default_hw_info.h"
1414
#include "shared/test/common/mocks/mock_device.h"
1515

16+
#include "opencl/source/os_interface/os_inc_base.h"
17+
#include "opencl/test/unit_test/mocks/mock_compilers.h"
1618
#include "opencl/test/unit_test/mocks/mock_memory_operations_handler.h"
1719

1820
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
@@ -25,6 +27,7 @@ namespace ult {
2527

2628
struct HostPointerManagerFixure {
2729
void SetUp() {
30+
NEO::MockCompilerEnableGuard mock(true);
2831
NEO::DeviceVector devices;
2932
neoDevice = NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(NEO::defaultHwInfo.get());
3033
auto mockBuiltIns = new MockBuiltins();

level_zero/core/test/unit_tests/fixtures/module_fixture.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "shared/test/common/mocks/mock_graphics_allocation.h"
1515

1616
#include "opencl/source/program/kernel_info.h"
17+
#include "opencl/test/unit_test/mocks/mock_compilers.h"
1718
#include "opencl/test/unit_test/mocks/mock_memory_manager.h"
1819

1920
#include "level_zero/core/source/module/module.h"
@@ -172,6 +173,7 @@ struct ModuleImmutableDataFixture : public DeviceFixture {
172173

173174
struct ModuleFixture : public DeviceFixture {
174175
void SetUp() override {
176+
NEO::MockCompilerEnableGuard mock(true);
175177
DeviceFixture::SetUp();
176178
createModuleFromBinary();
177179
}

level_zero/core/test/unit_tests/gen11/test_cmdqueue_thread_arbitration_policy_gen11.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "shared/test/common/helpers/debug_manager_state_restore.h"
1111

1212
#include "opencl/source/helpers/hardware_commands_helper.h"
13+
#include "opencl/test/unit_test/mocks/mock_compilers.h"
1314
#include "test.h"
1415

1516
#include "level_zero/core/source/driver/driver_imp.h"
@@ -22,6 +23,8 @@ namespace ult {
2223

2324
struct CommandQueueThreadArbitrationPolicyTests : public ::testing::Test {
2425
void SetUp() override {
26+
NEO::MockCompilerEnableGuard mock(true);
27+
ze_result_t returnValue = ZE_RESULT_SUCCESS;
2528
auto executionEnvironment = new NEO::ExecutionEnvironment();
2629
auto mockBuiltIns = new MockBuiltins();
2730
executionEnvironment->prepareRootDeviceEnvironments(1);
@@ -33,7 +36,7 @@ struct CommandQueueThreadArbitrationPolicyTests : public ::testing::Test {
3336
std::vector<std::unique_ptr<NEO::Device>> devices;
3437
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
3538

36-
auto driverHandleUlt = whitebox_cast(DriverHandle::create(std::move(devices), L0EnvVariables{}));
39+
auto driverHandleUlt = whitebox_cast(DriverHandle::create(std::move(devices), L0EnvVariables{}, &returnValue));
3740
driverHandle.reset(driverHandleUlt);
3841

3942
ASSERT_NE(nullptr, driverHandle);
@@ -46,7 +49,6 @@ struct CommandQueueThreadArbitrationPolicyTests : public ::testing::Test {
4649
ASSERT_NE(nullptr, device);
4750

4851
ze_command_queue_desc_t queueDesc = {};
49-
ze_result_t returnValue;
5052
commandQueue = whitebox_cast(CommandQueue::create(productFamily, device,
5153
neoDevice->getDefaultEngine().commandStreamReceiver,
5254
&queueDesc,

0 commit comments

Comments
 (0)