Skip to content

Commit 8a379ad

Browse files
MarijnS95claude
andcommitted
api-query: Continue device initialization when a backend fails
Device::initialize() returns early when any backend fails to initialize, preventing subsequent backends from being discovered. For example, a Vulkan initialization failure (e.g. VK_ERROR_INCOMPATIBLE_DRIVER when MoltenVK is not installed) blocks Metal device discovery on macOS. Collect backend initialization errors with joinErrors() and return them together instead. Also make lit.cfg.py resilient to an empty device list from api-query. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e2679fa commit 8a379ad

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

lib/API/Device.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
#include "llvm/Support/Error.h"
1717

18-
#include <cstdlib>
1918
#include <memory>
2019

2120
using namespace offloadtest;
@@ -27,21 +26,24 @@ Device::~Device() {}
2726
llvm::Expected<llvm::SmallVector<std::unique_ptr<Device>>>
2827
offloadtest::initializeDevices(const DeviceConfig Config) {
2928
llvm::SmallVector<std::unique_ptr<Device>> Devices;
29+
llvm::Error Result = llvm::Error::success();
3030

3131
#ifdef OFFLOADTEST_ENABLE_D3D12
3232
if (auto Err = initializeDX12Devices(Config, Devices))
33-
return Err;
33+
Result = llvm::joinErrors(std::move(Result), std::move(Err));
3434
#endif
3535

3636
#ifdef OFFLOADTEST_ENABLE_VULKAN
3737
if (auto Err = initializeVulkanDevices(Config, Devices))
38-
return Err;
38+
Result = llvm::joinErrors(std::move(Result), std::move(Err));
3939
#endif
4040

4141
#ifdef OFFLOADTEST_ENABLE_METAL
4242
if (auto Err = initializeMetalDevices(Config, Devices))
43-
return Err;
43+
Result = llvm::joinErrors(std::move(Result), std::move(Err));
4444
#endif
4545

46+
if (Result)
47+
return std::move(Result);
4648
return Devices;
4749
}

test/lit.cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def setDeviceFeatures(config, device, compiler):
241241
target_device = None
242242
# Find the right device to configure against
243243
pattern = re.compile(GPUName, re.IGNORECASE)
244-
for device in devices["Devices"]:
244+
for device in devices.get("Devices", []):
245245
is_warp = "Microsoft Basic Render Driver" in device["Description"]
246246
is_gpu_name_match = bool(pattern.search(device["Description"]))
247247
if device["API"] == "DirectX" and config.offloadtest_enable_d3d12:

0 commit comments

Comments
 (0)