Skip to content

Commit b38a2db

Browse files
committed
Add more fixes
1 parent ec77765 commit b38a2db

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

offload/include/device.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
#include "PluginInterface.h"
3838

3939
using GenericPluginTy = llvm::omp::target::plugin::GenericPluginTy;
40+
using DeviceInfo = llvm::omp::target::plugin::DeviceInfo;
41+
using InfoTreeNode = llvm::omp::target::plugin::InfoTreeNode;
4042

4143
// Forward declarations.
4244
struct __tgt_bin_desc;
@@ -167,8 +169,20 @@ struct DeviceTy {
167169
/// Indicate that there are pending images for this device or not.
168170
void setHasPendingImages(bool V) { HasPendingImages = V; }
169171

170-
/// Get the maximum shared memory per team for any kernel.
171-
uint64_t getMaxSharedTeamMemory();
172+
/// Get information from the device.
173+
template <typename T>
174+
T getInfo(DeviceInfo Info) const {
175+
InfoTreeNode DevInfo = RTL->obtain_device_info(RTLDeviceID);
176+
177+
auto EntryOpt = DevInfo.get(Info);
178+
if (!EntryOpt)
179+
return 0;
180+
181+
auto Entry = *EntryOpt;
182+
if (!std::holds_alternative<T>(Entry->Value))
183+
return T{};
184+
return std::get<T>(Entry->Value);
185+
}
172186

173187
private:
174188
/// Deinitialize the device (and plugin).

offload/include/omptarget.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,8 @@ void ompx_dump_mapping_tables(void);
280280
int omp_get_num_devices(void);
281281
int omp_get_device_num(void);
282282
int omp_get_initial_device(void);
283-
size_t
284-
omp_get_groupprivate_limit(int DeviceNum,
285-
omp_access_t AccessGroup = omp_access_cgroup);
283+
size_t omp_get_groupprivate_limit(int DeviceNum,
284+
omp_access_t AccessGroup = omp_access_cgroup);
286285
void *omp_target_alloc(size_t Size, int DeviceNum);
287286
void omp_target_free(void *DevicePtr, int DeviceNum);
288287
int omp_target_is_present(const void *Ptr, int DeviceNum);

offload/libomptarget/OpenMP/API.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ EXTERN size_t omp_get_groupprivate_limit(int DeviceNum,
9090
if (!DeviceOrErr)
9191
FATAL_MESSAGE(DeviceNum, "%s", toString(DeviceOrErr.takeError()).c_str());
9292

93-
return DeviceOrErr->getMaxSharedTeamMemory();
93+
return DeviceOrErr->getInfo<uint64_t>(DeviceInfo::WORK_GROUP_LOCAL_MEM_SIZE);
9494
}
9595

9696
EXTERN void *omp_target_alloc(size_t Size, int DeviceNum) {

offload/libomptarget/device.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -371,16 +371,3 @@ bool DeviceTy::useAutoZeroCopy() {
371371
bool DeviceTy::isAccessiblePtr(const void *Ptr, size_t Size) {
372372
return RTL->is_accessible_ptr(RTLDeviceID, Ptr, Size);
373373
}
374-
375-
uint64_t DeviceTy::getMaxSharedTeamMemory() {
376-
InfoTreeNode Info = RTL->obtain_device_info(RTLDeviceID);
377-
378-
auto EntryOpt = Info.get(DeviceInfo::WORK_GROUP_LOCAL_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);
386-
}

0 commit comments

Comments
 (0)