Skip to content

Commit 6143863

Browse files
committed
Revert "[Offload] Port llvm-offload-device-info to new offload API (llvm#155626)"
breaks offload build, needs prior patches This reverts commit 4e8b4d6.
1 parent 441982f commit 6143863

File tree

2 files changed

+3
-254
lines changed

2 files changed

+3
-254
lines changed

offload/tools/deviceinfo/llvm-offload-device-info.cpp

Lines changed: 0 additions & 254 deletions
Original file line numberDiff line numberDiff line change
@@ -11,262 +11,8 @@
1111
//
1212
//===----------------------------------------------------------------------===//
1313

14-
//<<<<<<< HEAD
1514
#include "omptarget.h"
1615
#include <cstdio>
17-
#include <OffloadAPI.h>
18-
#include <iostream>
19-
#include <vector>
20-
21-
#define OFFLOAD_ERR(X) \
22-
if (auto Err = X) { \
23-
return Err; \
24-
}
25-
26-
enum class PrintKind {
27-
NORMAL,
28-
FP_FLAGS,
29-
};
30-
31-
template <typename T, PrintKind PK = PrintKind::NORMAL>
32-
void doWrite(std::ostream &S, T &&Val) {
33-
S << Val;
34-
}
35-
36-
template <>
37-
void doWrite<ol_platform_backend_t>(std::ostream &S,
38-
ol_platform_backend_t &&Val) {
39-
switch (Val) {
40-
case OL_PLATFORM_BACKEND_UNKNOWN:
41-
S << "UNKNOWN";
42-
break;
43-
case OL_PLATFORM_BACKEND_CUDA:
44-
S << "CUDA";
45-
break;
46-
case OL_PLATFORM_BACKEND_AMDGPU:
47-
S << "AMDGPU";
48-
break;
49-
case OL_PLATFORM_BACKEND_HOST:
50-
S << "HOST";
51-
break;
52-
default:
53-
S << "<< INVALID >>";
54-
break;
55-
}
56-
}
57-
template <>
58-
void doWrite<ol_device_type_t>(std::ostream &S, ol_device_type_t &&Val) {
59-
switch (Val) {
60-
case OL_DEVICE_TYPE_GPU:
61-
S << "GPU";
62-
break;
63-
case OL_DEVICE_TYPE_CPU:
64-
S << "CPU";
65-
break;
66-
case OL_DEVICE_TYPE_HOST:
67-
S << "HOST";
68-
break;
69-
default:
70-
S << "<< INVALID >>";
71-
break;
72-
}
73-
}
74-
template <>
75-
void doWrite<ol_dimensions_t>(std::ostream &S, ol_dimensions_t &&Val) {
76-
S << "{x: " << Val.x << ", y: " << Val.y << ", z: " << Val.z << "}";
77-
}
78-
template <>
79-
void doWrite<ol_device_fp_capability_flags_t, PrintKind::FP_FLAGS>(
80-
std::ostream &S, ol_device_fp_capability_flags_t &&Val) {
81-
S << Val << " {";
82-
83-
if (Val & OL_DEVICE_FP_CAPABILITY_FLAG_CORRECTLY_ROUNDED_DIVIDE_SQRT) {
84-
S << " CORRECTLY_ROUNDED_DIVIDE_SQRT";
85-
}
86-
if (Val & OL_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_NEAREST) {
87-
S << " ROUND_TO_NEAREST";
88-
}
89-
if (Val & OL_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_ZERO) {
90-
S << " ROUND_TO_ZERO";
91-
}
92-
if (Val & OL_DEVICE_FP_CAPABILITY_FLAG_ROUND_TO_INF) {
93-
S << " ROUND_TO_INF";
94-
}
95-
if (Val & OL_DEVICE_FP_CAPABILITY_FLAG_INF_NAN) {
96-
S << " INF_NAN";
97-
}
98-
if (Val & OL_DEVICE_FP_CAPABILITY_FLAG_DENORM) {
99-
S << " DENORM";
100-
}
101-
if (Val & OL_DEVICE_FP_CAPABILITY_FLAG_FMA) {
102-
S << " FMA";
103-
}
104-
if (Val & OL_DEVICE_FP_CAPABILITY_FLAG_SOFT_FLOAT) {
105-
S << " SOFT_FLOAT";
106-
}
107-
108-
S << " }";
109-
}
110-
111-
template <typename T>
112-
ol_result_t printPlatformValue(std::ostream &S, ol_platform_handle_t Plat,
113-
ol_platform_info_t Info, const char *Desc) {
114-
S << Desc << ": ";
115-
116-
if constexpr (std::is_pointer_v<T>) {
117-
std::vector<uint8_t> Val;
118-
size_t Size;
119-
OFFLOAD_ERR(olGetPlatformInfoSize(Plat, Info, &Size));
120-
Val.resize(Size);
121-
OFFLOAD_ERR(olGetPlatformInfo(Plat, Info, sizeof(Val), Val.data()));
122-
doWrite(S, reinterpret_cast<T>(Val.data()));
123-
} else {
124-
T Val;
125-
OFFLOAD_ERR(olGetPlatformInfo(Plat, Info, sizeof(Val), &Val));
126-
doWrite(S, std::move(Val));
127-
}
128-
S << "\n";
129-
return OL_SUCCESS;
130-
}
131-
132-
template <typename T, PrintKind PK = PrintKind::NORMAL>
133-
ol_result_t printDeviceValue(std::ostream &S, ol_device_handle_t Dev,
134-
ol_device_info_t Info, const char *Desc,
135-
const char *Units = nullptr) {
136-
S << Desc << ": ";
137-
138-
if constexpr (std::is_pointer_v<T>) {
139-
std::vector<uint8_t> Val;
140-
size_t Size;
141-
OFFLOAD_ERR(olGetDeviceInfoSize(Dev, Info, &Size));
142-
Val.resize(Size);
143-
OFFLOAD_ERR(olGetDeviceInfo(Dev, Info, sizeof(Val), Val.data()));
144-
doWrite<T, PK>(S, reinterpret_cast<T>(Val.data()));
145-
} else {
146-
T Val;
147-
OFFLOAD_ERR(olGetDeviceInfo(Dev, Info, sizeof(Val), &Val));
148-
doWrite<T, PK>(S, std::move(Val));
149-
}
150-
if (Units)
151-
S << " " << Units;
152-
S << "\n";
153-
return OL_SUCCESS;
154-
}
155-
156-
ol_result_t printDevice(std::ostream &S, ol_device_handle_t D) {
157-
ol_platform_handle_t Platform;
158-
OFFLOAD_ERR(
159-
olGetDeviceInfo(D, OL_DEVICE_INFO_PLATFORM, sizeof(Platform), &Platform));
160-
161-
std::vector<char> Name;
162-
size_t NameSize;
163-
OFFLOAD_ERR(olGetDeviceInfoSize(D, OL_DEVICE_INFO_PRODUCT_NAME, &NameSize))
164-
Name.resize(NameSize);
165-
OFFLOAD_ERR(
166-
olGetDeviceInfo(D, OL_DEVICE_INFO_PRODUCT_NAME, NameSize, Name.data()));
167-
S << "[" << Name.data() << "]\n";
168-
169-
OFFLOAD_ERR(printPlatformValue<const char *>(
170-
S, Platform, OL_PLATFORM_INFO_NAME, "Platform Name"));
171-
OFFLOAD_ERR(printPlatformValue<const char *>(
172-
S, Platform, OL_PLATFORM_INFO_VENDOR_NAME, "Platform Vendor Name"));
173-
OFFLOAD_ERR(printPlatformValue<const char *>(
174-
S, Platform, OL_PLATFORM_INFO_VERSION, "Platform Version"));
175-
OFFLOAD_ERR(printPlatformValue<ol_platform_backend_t>(
176-
S, Platform, OL_PLATFORM_INFO_BACKEND, "Platform Backend"));
177-
178-
OFFLOAD_ERR(
179-
printDeviceValue<const char *>(S, D, OL_DEVICE_INFO_NAME, "Name"));
180-
OFFLOAD_ERR(printDeviceValue<const char *>(S, D, OL_DEVICE_INFO_PRODUCT_NAME,
181-
"Product Name"));
182-
OFFLOAD_ERR(
183-
printDeviceValue<ol_device_type_t>(S, D, OL_DEVICE_INFO_TYPE, "Type"));
184-
OFFLOAD_ERR(printDeviceValue<const char *>(
185-
S, D, OL_DEVICE_INFO_DRIVER_VERSION, "Driver Version"));
186-
OFFLOAD_ERR(printDeviceValue<uint32_t>(
187-
S, D, OL_DEVICE_INFO_MAX_WORK_GROUP_SIZE, "Max Work Group Size"));
188-
OFFLOAD_ERR(printDeviceValue<ol_dimensions_t>(
189-
S, D, OL_DEVICE_INFO_MAX_WORK_GROUP_SIZE_PER_DIMENSION,
190-
"Max Work Group Size Per Dimension"));
191-
OFFLOAD_ERR(printDeviceValue<uint32_t>(S, D, OL_DEVICE_INFO_MAX_WORK_SIZE,
192-
"Max Work Size"));
193-
OFFLOAD_ERR(printDeviceValue<ol_dimensions_t>(
194-
S, D, OL_DEVICE_INFO_MAX_WORK_SIZE_PER_DIMENSION,
195-
"Max Work Size Per Dimension"));
196-
OFFLOAD_ERR(
197-
printDeviceValue<uint32_t>(S, D, OL_DEVICE_INFO_VENDOR_ID, "Vendor ID"));
198-
OFFLOAD_ERR(printDeviceValue<uint32_t>(S, D, OL_DEVICE_INFO_NUM_COMPUTE_UNITS,
199-
"Num Compute Units"));
200-
OFFLOAD_ERR(printDeviceValue<uint32_t>(
201-
S, D, OL_DEVICE_INFO_MAX_CLOCK_FREQUENCY, "Max Clock Frequency", "MHz"));
202-
OFFLOAD_ERR(printDeviceValue<uint32_t>(S, D, OL_DEVICE_INFO_MEMORY_CLOCK_RATE,
203-
"Memory Clock Rate", "MHz"));
204-
OFFLOAD_ERR(printDeviceValue<uint32_t>(S, D, OL_DEVICE_INFO_ADDRESS_BITS,
205-
"Address Bits"));
206-
OFFLOAD_ERR(printDeviceValue<uint64_t>(
207-
S, D, OL_DEVICE_INFO_MAX_MEM_ALLOC_SIZE, "Max Mem Allocation Size", "B"));
208-
OFFLOAD_ERR(printDeviceValue<uint64_t>(S, D, OL_DEVICE_INFO_GLOBAL_MEM_SIZE,
209-
"Global Mem Size", "B"));
210-
OFFLOAD_ERR(
211-
(printDeviceValue<ol_device_fp_capability_flags_t, PrintKind::FP_FLAGS>(
212-
S, D, OL_DEVICE_INFO_SINGLE_FP_CONFIG,
213-
"Single Precision Floating Point Capability")));
214-
OFFLOAD_ERR(
215-
(printDeviceValue<ol_device_fp_capability_flags_t, PrintKind::FP_FLAGS>(
216-
S, D, OL_DEVICE_INFO_DOUBLE_FP_CONFIG,
217-
"Double Precision Floating Point Capability")));
218-
OFFLOAD_ERR(
219-
(printDeviceValue<ol_device_fp_capability_flags_t, PrintKind::FP_FLAGS>(
220-
S, D, OL_DEVICE_INFO_HALF_FP_CONFIG,
221-
"Half Precision Floating Point Capability")));
222-
OFFLOAD_ERR(
223-
printDeviceValue<uint32_t>(S, D, OL_DEVICE_INFO_NATIVE_VECTOR_WIDTH_CHAR,
224-
"Native Vector Width For Char"));
225-
OFFLOAD_ERR(
226-
printDeviceValue<uint32_t>(S, D, OL_DEVICE_INFO_NATIVE_VECTOR_WIDTH_SHORT,
227-
"Native Vector Width For Short"));
228-
OFFLOAD_ERR(printDeviceValue<uint32_t>(S, D,
229-
OL_DEVICE_INFO_NATIVE_VECTOR_WIDTH_INT,
230-
"Native Vector Width For Int"));
231-
OFFLOAD_ERR(
232-
printDeviceValue<uint32_t>(S, D, OL_DEVICE_INFO_NATIVE_VECTOR_WIDTH_LONG,
233-
"Native Vector Width For Long"));
234-
OFFLOAD_ERR(
235-
printDeviceValue<uint32_t>(S, D, OL_DEVICE_INFO_NATIVE_VECTOR_WIDTH_FLOAT,
236-
"Native Vector Width For Float"));
237-
OFFLOAD_ERR(printDeviceValue<uint32_t>(
238-
S, D, OL_DEVICE_INFO_NATIVE_VECTOR_WIDTH_DOUBLE,
239-
"Native Vector Width For Double"));
240-
OFFLOAD_ERR(
241-
printDeviceValue<uint32_t>(S, D, OL_DEVICE_INFO_NATIVE_VECTOR_WIDTH_HALF,
242-
"Native Vector Width For Half"));
243-
244-
return OL_SUCCESS;
245-
}
246-
247-
ol_result_t printRoot(std::ostream &S) {
248-
OFFLOAD_ERR(olInit());
249-
S << "Liboffload Version: " << OL_VERSION_MAJOR << "." << OL_VERSION_MINOR
250-
<< "." << OL_VERSION_PATCH << "\n";
251-
252-
std::vector<ol_device_handle_t> Devices;
253-
OFFLOAD_ERR(olIterateDevices(
254-
[](ol_device_handle_t Device, void *UserData) {
255-
reinterpret_cast<decltype(Devices) *>(UserData)->push_back(Device);
256-
return true;
257-
},
258-
&Devices));
259-
260-
S << "Num Devices: " << Devices.size() << "\n";
261-
262-
for (auto &D : Devices) {
263-
S << "\n";
264-
OFFLOAD_ERR(printDevice(S, D));
265-
}
266-
267-
OFFLOAD_ERR(olShutDown());
268-
return OL_SUCCESS;
269-
}
27016

27117
int main(int argc, char **argv) {
27218
__tgt_bin_desc EmptyDesc = {0, nullptr, nullptr, nullptr};

revert_patches.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ d57230c7 [AMDGPU][MC] Disallow op_sel in some VOP3P dot instructions (#100485)
1515
Revert "[SLP]Support LShr as base for copyable elements"
1616
breaks build rocPRIM
1717
---
18+
needs more offload patches
19+
[Offload] Port llvm-offload-device-info to new offload API (#155626)
20+
---

0 commit comments

Comments
 (0)