File tree Expand file tree Collapse file tree 4 files changed +19
-19
lines changed
Expand file tree Collapse file tree 4 files changed +19
-19
lines changed Original file line number Diff line number Diff line change 3737#include " PluginInterface.h"
3838
3939using 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.
4244struct __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
173187private:
174188 // / Deinitialize the device (and plugin).
Original file line number Diff line number Diff line change @@ -280,9 +280,8 @@ void ompx_dump_mapping_tables(void);
280280int omp_get_num_devices (void );
281281int omp_get_device_num (void );
282282int 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);
286285void *omp_target_alloc (size_t Size, int DeviceNum);
287286void omp_target_free (void *DevicePtr, int DeviceNum);
288287int omp_target_is_present (const void *Ptr, int DeviceNum);
Original file line number Diff line number Diff 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
9696EXTERN void *omp_target_alloc (size_t Size, int DeviceNum) {
Original file line number Diff line number Diff line change @@ -371,16 +371,3 @@ bool DeviceTy::useAutoZeroCopy() {
371371bool 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- }
You can’t perform that action at this time.
0 commit comments