Skip to content

Commit 3abd3d6

Browse files
authored
[Libomptarget] Remove requires information from plugin (#80345)
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 117d755 commit 3abd3d6

File tree

3 files changed

+4
-33
lines changed

3 files changed

+4
-33
lines changed

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -958,8 +958,7 @@ struct GenericPluginTy {
958958

959959
/// Construct a plugin instance.
960960
GenericPluginTy(Triple::ArchType TA)
961-
: RequiresFlags(OMP_REQ_UNDEFINED), GlobalHandler(nullptr), JIT(TA),
962-
RPCServer(nullptr) {}
961+
: GlobalHandler(nullptr), JIT(TA), RPCServer(nullptr) {}
963962

964963
virtual ~GenericPluginTy() {}
965964

@@ -1028,12 +1027,6 @@ struct GenericPluginTy {
10281027
return *RPCServer;
10291028
}
10301029

1031-
/// Get the OpenMP requires flags set for this plugin.
1032-
int64_t getRequiresFlags() const { return RequiresFlags; }
1033-
1034-
/// Set the OpenMP requires flags for this plugin.
1035-
void setRequiresFlag(int64_t Flags) { RequiresFlags = Flags; }
1036-
10371030
/// Initialize a device within the plugin.
10381031
Error initDevice(int32_t DeviceId);
10391032

@@ -1074,9 +1067,6 @@ struct GenericPluginTy {
10741067
/// Return the number of devices this plugin can support.
10751068
int32_t number_of_devices();
10761069

1077-
/// Initializes the OpenMP register requires information.
1078-
int64_t init_requires(int64_t RequiresFlags);
1079-
10801070
/// Returns non-zero if the data can be exchanged between the two devices.
10811071
int32_t is_data_exchangable(int32_t SrcDeviceId, int32_t DstDeviceId);
10821072

@@ -1203,9 +1193,6 @@ struct GenericPluginTy {
12031193
/// device was not initialized yet.
12041194
llvm::SmallVector<GenericDeviceTy *> Devices;
12051195

1206-
/// OpenMP requires flags.
1207-
int64_t RequiresFlags;
1208-
12091196
/// Pointer to the global handler for this plugin.
12101197
GenericGlobalHandlerTy *GlobalHandler;
12111198

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,11 +1618,6 @@ int32_t GenericPluginTy::init_device(int32_t DeviceId) {
16181618

16191619
int32_t GenericPluginTy::number_of_devices() { return getNumDevices(); }
16201620

1621-
int64_t GenericPluginTy::init_requires(int64_t RequiresFlags) {
1622-
setRequiresFlag(RequiresFlags);
1623-
return OFFLOAD_SUCCESS;
1624-
}
1625-
16261621
int32_t GenericPluginTy::is_data_exchangable(int32_t SrcDeviceId,
16271622
int32_t DstDeviceId) {
16281623
return isDataExchangable(SrcDeviceId, DstDeviceId);
@@ -1964,11 +1959,6 @@ int32_t GenericPluginTy::set_device_offset(int32_t DeviceIdOffset) {
19641959
}
19651960

19661961
int32_t GenericPluginTy::use_auto_zero_copy(int32_t DeviceId) {
1967-
// Automatic zero-copy only applies to programs that did
1968-
// not request unified_shared_memory and are deployed on an
1969-
// APU with XNACK enabled.
1970-
if (getRequiresFlags() & OMP_REQ_UNIFIED_SHARED_MEMORY)
1971-
return false;
19721962
return getDevice(DeviceId).useAutoZeroCopy();
19731963
}
19741964

offload/src/device.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +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-
Ret = RTL->init_requires(PM->getRequirements());
83-
if (Ret != OFFLOAD_SUCCESS)
84-
return llvm::createStringError(
85-
llvm::inconvertibleErrorCode(),
86-
"Failed to initialize requirements for device %d\n", DeviceID);
87-
88-
Ret = RTL->init_device(RTLDeviceID);
80+
int32_t Ret = RTL->init_device(RTLDeviceID);
8981
if (Ret != OFFLOAD_SUCCESS)
9082
return llvm::createStringError(llvm::inconvertibleErrorCode(),
9183
"Failed to initialize device %d\n",
@@ -285,5 +277,7 @@ void DeviceTy::dumpOffloadEntries() {
285277
}
286278

287279
bool DeviceTy::useAutoZeroCopy() {
280+
if (PM->getRequirements() & OMP_REQ_UNIFIED_SHARED_MEMORY)
281+
return false;
288282
return RTL->use_auto_zero_copy(RTLDeviceID);
289283
}

0 commit comments

Comments
 (0)