[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`.
This commit is contained in:
Joseph Huber
2024-05-16 11:13:50 -05:00
committed by GitHub
parent 117d755b1b
commit 3abd3d6e59
3 changed files with 4 additions and 33 deletions

View File

@@ -958,8 +958,7 @@ struct GenericPluginTy {
/// Construct a plugin instance.
GenericPluginTy(Triple::ArchType TA)
: RequiresFlags(OMP_REQ_UNDEFINED), GlobalHandler(nullptr), JIT(TA),
RPCServer(nullptr) {}
: GlobalHandler(nullptr), JIT(TA), RPCServer(nullptr) {}
virtual ~GenericPluginTy() {}
@@ -1028,12 +1027,6 @@ struct GenericPluginTy {
return *RPCServer;
}
/// Get the OpenMP requires flags set for this plugin.
int64_t getRequiresFlags() const { return RequiresFlags; }
/// Set the OpenMP requires flags for this plugin.
void setRequiresFlag(int64_t Flags) { RequiresFlags = Flags; }
/// Initialize a device within the plugin.
Error initDevice(int32_t DeviceId);
@@ -1074,9 +1067,6 @@ public:
/// Return the number of devices this plugin can support.
int32_t number_of_devices();
/// Initializes the OpenMP register requires information.
int64_t init_requires(int64_t RequiresFlags);
/// Returns non-zero if the data can be exchanged between the two devices.
int32_t is_data_exchangable(int32_t SrcDeviceId, int32_t DstDeviceId);
@@ -1203,9 +1193,6 @@ private:
/// device was not initialized yet.
llvm::SmallVector<GenericDeviceTy *> Devices;
/// OpenMP requires flags.
int64_t RequiresFlags;
/// Pointer to the global handler for this plugin.
GenericGlobalHandlerTy *GlobalHandler;

View File

@@ -1618,11 +1618,6 @@ int32_t GenericPluginTy::init_device(int32_t DeviceId) {
int32_t GenericPluginTy::number_of_devices() { return getNumDevices(); }
int64_t GenericPluginTy::init_requires(int64_t RequiresFlags) {
setRequiresFlag(RequiresFlags);
return OFFLOAD_SUCCESS;
}
int32_t GenericPluginTy::is_data_exchangable(int32_t SrcDeviceId,
int32_t DstDeviceId) {
return isDataExchangable(SrcDeviceId, DstDeviceId);
@@ -1964,11 +1959,6 @@ int32_t GenericPluginTy::set_device_offset(int32_t DeviceIdOffset) {
}
int32_t GenericPluginTy::use_auto_zero_copy(int32_t DeviceId) {
// Automatic zero-copy only applies to programs that did
// not request unified_shared_memory and are deployed on an
// APU with XNACK enabled.
if (getRequiresFlags() & OMP_REQ_UNIFIED_SHARED_MEMORY)
return false;
return getDevice(DeviceId).useAutoZeroCopy();
}

View File

@@ -77,15 +77,7 @@ DeviceTy::~DeviceTy() {
}
llvm::Error DeviceTy::init() {
// Make call to init_requires if it exists for this plugin.
int32_t Ret = 0;
Ret = RTL->init_requires(PM->getRequirements());
if (Ret != OFFLOAD_SUCCESS)
return llvm::createStringError(
llvm::inconvertibleErrorCode(),
"Failed to initialize requirements for device %d\n", DeviceID);
Ret = RTL->init_device(RTLDeviceID);
int32_t Ret = RTL->init_device(RTLDeviceID);
if (Ret != OFFLOAD_SUCCESS)
return llvm::createStringError(llvm::inconvertibleErrorCode(),
"Failed to initialize device %d\n",
@@ -285,5 +277,7 @@ void DeviceTy::dumpOffloadEntries() {
}
bool DeviceTy::useAutoZeroCopy() {
if (PM->getRequirements() & OMP_REQ_UNIFIED_SHARED_MEMORY)
return false;
return RTL->use_auto_zero_copy(RTLDeviceID);
}