Skip to content

Commit b259248

Browse files
committed
[Libomptarget] Remove requires information from plugin
Summary: Currently this is only used for the zero-copy handling. However, this can easily be moved into `libomptarget` so that we do not need to bother setting the requires flags in the plugin. The advantage here is that we no longer need to do this for every device redundently. Additionally, these requires flags are specifically OpenMP related, so they should live in `libomptarget`.
1 parent 28699e3 commit b259248

File tree

5 files changed

+6
-28
lines changed

5 files changed

+6
-28
lines changed

openmp/libomptarget/include/Shared/PluginAPI.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ int32_t __tgt_rtl_is_data_exchangable(int32_t SrcDevId, int32_t DstDevId);
4545
// functions)
4646
int32_t __tgt_rtl_supports_empty_images();
4747

48-
// Initialize the requires flags for the device.
49-
int64_t __tgt_rtl_init_requires(int64_t RequiresFlags);
50-
5148
// Initialize the specified device. In case of success return 0; otherwise
5249
// return an error code.
5350
int32_t __tgt_rtl_init_device(int32_t ID);

openmp/libomptarget/include/Shared/PluginAPI.inc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ PLUGIN_API_HANDLE(data_exchange, false);
3030
PLUGIN_API_HANDLE(data_exchange_async, false);
3131
PLUGIN_API_HANDLE(data_delete, true);
3232
PLUGIN_API_HANDLE(launch_kernel, true);
33-
PLUGIN_API_HANDLE(init_requires, false);
3433
PLUGIN_API_HANDLE(synchronize, false);
3534
PLUGIN_API_HANDLE(query_async, false);
3635
PLUGIN_API_HANDLE(supports_empty_images, false);

openmp/libomptarget/plugins-nextgen/common/include/PluginInterface.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,12 +1020,6 @@ struct GenericPluginTy {
10201020
return *RPCServer;
10211021
}
10221022

1023-
/// Get the OpenMP requires flags set for this plugin.
1024-
int64_t getRequiresFlags() const { return RequiresFlags; }
1025-
1026-
/// Set the OpenMP requires flags for this plugin.
1027-
void setRequiresFlag(int64_t Flags) { RequiresFlags = Flags; }
1028-
10291023
/// Initialize a device within the plugin.
10301024
Error initDevice(int32_t DeviceId);
10311025

openmp/libomptarget/plugins-nextgen/common/src/PluginInterface.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,7 @@ Error GenericDeviceTy::deinit(GenericPluginTy &Plugin) {
852852

853853
return deinitImpl();
854854
}
855+
855856
Expected<DeviceImageTy *>
856857
GenericDeviceTy::loadBinary(GenericPluginTy &Plugin,
857858
const __tgt_device_image *InputTgtImage) {
@@ -1637,11 +1638,6 @@ int32_t __tgt_rtl_init_device(int32_t DeviceId) {
16371638

16381639
int32_t __tgt_rtl_number_of_devices() { return Plugin::get().getNumDevices(); }
16391640

1640-
int64_t __tgt_rtl_init_requires(int64_t RequiresFlags) {
1641-
Plugin::get().setRequiresFlag(RequiresFlags);
1642-
return OFFLOAD_SUCCESS;
1643-
}
1644-
16451641
int32_t __tgt_rtl_is_data_exchangable(int32_t SrcDeviceId,
16461642
int32_t DstDeviceId) {
16471643
return Plugin::get().isDataExchangable(SrcDeviceId, DstDeviceId);
@@ -1989,8 +1985,6 @@ int32_t __tgt_rtl_use_auto_zero_copy(int32_t DeviceId) {
19891985
// Automatic zero-copy only applies to programs that did
19901986
// not request unified_shared_memory and are deployed on an
19911987
// APU with XNACK enabled.
1992-
if (Plugin::get().getRequiresFlags() & OMP_REQ_UNIFIED_SHARED_MEMORY)
1993-
return false;
19941988
return Plugin::get().getDevice(DeviceId).useAutoZeroCopy();
19951989
}
19961990

openmp/libomptarget/src/device.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,7 @@ DeviceTy::~DeviceTy() {
7777
}
7878

7979
llvm::Error DeviceTy::init() {
80-
// Make call to init_requires if it exists for this plugin.
81-
int32_t Ret = 0;
82-
if (RTL->init_requires)
83-
Ret = RTL->init_requires(PM->getRequirements());
84-
if (Ret != OFFLOAD_SUCCESS)
85-
return llvm::createStringError(
86-
llvm::inconvertibleErrorCode(),
87-
"Failed to initialize requirements for device %d\n", DeviceID);
88-
89-
Ret = RTL->init_device(RTLDeviceID);
90-
if (Ret != OFFLOAD_SUCCESS)
80+
if (RTL->init_device(RTLDeviceID) != OFFLOAD_SUCCESS)
9181
return llvm::createStringError(llvm::inconvertibleErrorCode(),
9282
"Failed to initialize device %d\n",
9383
DeviceID);
@@ -310,6 +300,10 @@ void DeviceTy::dumpOffloadEntries() {
310300
}
311301

312302
bool DeviceTy::useAutoZeroCopy() {
303+
// Automatic zero-copy only applies when unfiied shared memory is disabled.
304+
if (PM->getRequirements() & OMP_REQ_UNIFIED_SHARED_MEMORY)
305+
return false;
306+
313307
if (RTL->use_auto_zero_copy)
314308
return RTL->use_auto_zero_copy(RTLDeviceID);
315309
return false;

0 commit comments

Comments
 (0)