Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions lib/API/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#include "Config.h"

#include "llvm/Support/Error.h"
#include "llvm/Support/raw_ostream.h"

#include <cstdlib>
#include <memory>

using namespace offloadtest;
Expand All @@ -27,21 +27,31 @@ Device::~Device() {}
llvm::Expected<llvm::SmallVector<std::unique_ptr<Device>>>
offloadtest::initializeDevices(const DeviceConfig Config) {
llvm::SmallVector<std::unique_ptr<Device>> Devices;
llvm::Error Err = llvm::Error::success();

#ifdef OFFLOADTEST_ENABLE_D3D12
if (auto Err = initializeDX12Devices(Config, Devices))
return Err;
if (auto E = initializeDX12Devices(Config, Devices))
Err = llvm::joinErrors(std::move(Err), std::move(E));
#endif

#ifdef OFFLOADTEST_ENABLE_VULKAN
if (auto Err = initializeVulkanDevices(Config, Devices))
return Err;
if (auto E = initializeVulkanDevices(Config, Devices))
Err = llvm::joinErrors(std::move(Err), std::move(E));
#endif

#ifdef OFFLOADTEST_ENABLE_METAL
if (auto Err = initializeMetalDevices(Config, Devices))
return Err;
if (auto E = initializeMetalDevices(Config, Devices))
Err = llvm::joinErrors(std::move(Err), std::move(E));
#endif

if (Devices.empty()) {
if (Err)
return std::move(Err);
return llvm::createStringError(std::errc::no_such_device,
"No GPU devices found.");
}
// Log errors from backends that failed while others succeeded.
if (Err)
llvm::logAllUnhandledErrors(std::move(Err), llvm::errs());
return Devices;
}
2 changes: 1 addition & 1 deletion test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def setDeviceFeatures(config, device, compiler):
target_device = None
# Find the right device to configure against
pattern = re.compile(GPUName, re.IGNORECASE)
for device in devices["Devices"]:
for device in devices.get("Devices", []):
is_warp = "Microsoft Basic Render Driver" in device["Description"]
is_gpu_name_match = bool(pattern.search(device["Description"]))
if device["API"] == "DirectX" and config.offloadtest_enable_d3d12:
Expand Down
Loading