forked from llvm/offload-test-suite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDevice.cpp
More file actions
57 lines (45 loc) · 1.66 KB
/
Device.cpp
File metadata and controls
57 lines (45 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//===- DX/Device.cpp - DirectX Device API ---------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
//
//===----------------------------------------------------------------------===//
#include "API/Device.h"
#include "Config.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/raw_ostream.h"
#include <memory>
using namespace offloadtest;
Queue::~Queue() {}
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 E = initializeDX12Devices(Config, Devices))
Err = llvm::joinErrors(std::move(Err), std::move(E));
#endif
#ifdef OFFLOADTEST_ENABLE_VULKAN
if (auto E = initializeVulkanDevices(Config, Devices))
Err = llvm::joinErrors(std::move(Err), std::move(E));
#endif
#ifdef OFFLOADTEST_ENABLE_METAL
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;
}