-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathDevice.h
More file actions
83 lines (63 loc) · 2.25 KB
/
Device.h
File metadata and controls
83 lines (63 loc) · 2.25 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//===- Device.h - Offload API 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
//
//===----------------------------------------------------------------------===//
//
//
//===----------------------------------------------------------------------===//
#ifndef OFFLOADTEST_API_DEVICE_H
#define OFFLOADTEST_API_DEVICE_H
#include "Config.h"
#include "API/API.h"
#include "API/Capabilities.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/iterator_range.h"
#include <memory>
#include <string>
namespace llvm {
class raw_ostream;
}
namespace offloadtest {
struct Pipeline;
struct DeviceConfig {
bool EnableDebugLayer = false;
bool EnableValidationLayer = false;
};
class Device {
protected:
std::string Description;
public:
virtual const Capabilities &getCapabilities() = 0;
virtual llvm::StringRef getAPIName() const = 0;
virtual GPUAPI getAPI() const = 0;
virtual llvm::Error executeProgram(Pipeline &P) = 0;
virtual void printExtra(llvm::raw_ostream &OS) {}
virtual uint32_t getSubgroupSize() const = 0;
virtual std::pair<uint32_t, uint32_t> getMinMaxSubgroupSize() const = 0;
virtual ~Device() = 0;
llvm::StringRef getDescription() const { return Description; }
static void registerDevice(std::shared_ptr<Device> D);
static llvm::Error initialize(const DeviceConfig Config);
static void uninitialize();
using DeviceArray = llvm::SmallVector<std::shared_ptr<Device>>;
using DeviceIterator = DeviceArray::iterator;
using DeviceRange = llvm::iterator_range<DeviceIterator>;
static DeviceIterator begin();
static DeviceIterator end();
static inline DeviceRange devices() { return DeviceRange(begin(), end()); }
#ifdef OFFLOADTEST_ENABLE_D3D12
static llvm::Error initializeDXDevices(const DeviceConfig Config);
#endif
#ifdef OFFLOADTEST_ENABLE_VULKAN
static llvm::Error initializeVKDevices(const DeviceConfig Config);
static void cleanupVKDevices();
#endif
#ifdef OFFLOADTEST_ENABLE_METAL
static llvm::Error initializeMtlDevices(const DeviceConfig Config);
#endif
};
} // namespace offloadtest
#endif // OFFLOADTEST_API_DEVICE_H