Skip to content

Commit 3573177

Browse files
committed
Fixes
1 parent 45d116d commit 3573177

File tree

3 files changed

+23
-21
lines changed

3 files changed

+23
-21
lines changed

offload/libomptarget/device.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,14 @@ bool DeviceTy::isAccessiblePtr(const void *Ptr, size_t Size) {
373373
}
374374

375375
uint64_t DeviceTy::getMaxSharedTeamMemory() {
376-
using DeviceQueryKind = llvm::omp::target::plugin::DeviceQueryKind;
377-
return RTL->query_device_info(
378-
RTLDeviceID, DeviceQueryKind::DEVICE_QUERY_MAX_SHARED_TEAM_MEM);
376+
InfoTreeNode Info = RTL->query_device_info(RTLDeviceID);
377+
378+
auto EntryOpt = Info.get(DeviceInfo::WORK_GROUP_SHARED_MEM_SIZE);
379+
if (!EntryOpt)
380+
return 0;
381+
382+
auto Entry = *EntryOpt;
383+
if (!std::holds_alternative<uint64_t>(Entry->Value))
384+
return 0;
385+
return std::get<uint64_t>(Entry->Value);
379386
}

offload/plugins-nextgen/common/include/PluginInterface.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,6 @@ struct InfoTreeNode {
299299
}
300300
};
301301

302-
enum class DeviceQueryKind {
303-
DEVICE_QUERY_MAX_SHARED_TEAM_MEM = 0,
304-
};
305-
306302
/// Class wrapping a __tgt_device_image and its offload entry table on a
307303
/// specific device. This class is responsible for storing and managing
308304
/// the offload entries for an image on a device.
@@ -1515,12 +1511,12 @@ struct GenericPluginTy {
15151511
/// Query the current state of an asynchronous queue.
15161512
int32_t query_async(int32_t DeviceId, __tgt_async_info *AsyncInfoPtr);
15171513

1514+
/// Obtain information about the given device.
1515+
InfoTreeNode obtain_device_info(int32_t DeviceId);
1516+
15181517
/// Prints information about the given devices supported by the plugin.
15191518
void print_device_info(int32_t DeviceId);
15201519

1521-
/// Retrieve information about the given device.
1522-
int64_t query_device_info(int32_t DeviceId, DeviceQueryKind Query);
1523-
15241520
/// Creates an event in the given plugin if supported.
15251521
int32_t create_event(int32_t DeviceId, void **EventPtr);
15261522

offload/plugins-nextgen/common/src/PluginInterface.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2037,23 +2037,22 @@ int32_t GenericPluginTy::query_async(int32_t DeviceId,
20372037
return OFFLOAD_SUCCESS;
20382038
}
20392039

2040+
InfoTreeNode GenericPluginTy::obtain_device_info(int32_t DeviceId) {
2041+
auto InfoOrErr = getDevice(DeviceId).obtainInfo();
2042+
if (auto Err = InfoOrErr.takeError()) {
2043+
REPORT("Failure to obtain device %d info: %s\n", DeviceId,
2044+
toString(std::move(Err)).data());
2045+
return InfoTreeNode{};
2046+
}
2047+
return *InfoOrErr;
2048+
}
2049+
20402050
void GenericPluginTy::print_device_info(int32_t DeviceId) {
20412051
if (auto Err = getDevice(DeviceId).printInfo())
20422052
REPORT("Failure to print device %d info: %s\n", DeviceId,
20432053
toString(std::move(Err)).data());
20442054
}
20452055

2046-
int64_t GenericPluginTy::query_device_info(int32_t DeviceId,
2047-
DeviceQueryKind Query) {
2048-
const GenericDeviceTy &Device = getDevice(DeviceId);
2049-
2050-
switch (Query) {
2051-
case DeviceQueryKind::DEVICE_QUERY_MAX_SHARED_TEAM_MEM:
2052-
return Device.getMaxBlockSharedMemSize();
2053-
}
2054-
return 0;
2055-
}
2056-
20572056
int32_t GenericPluginTy::create_event(int32_t DeviceId, void **EventPtr) {
20582057
auto Err = getDevice(DeviceId).createEvent(EventPtr);
20592058
if (Err) {

0 commit comments

Comments
 (0)