Skip to content

Commit 2b2e711

Browse files
committed
[OpenMP][NFC] Remove no-op __tgt_rtl_deinit_plugin
The order in which we deinit things, especially when shared libraries are involved, is complicated. To simplify our lives the nextgen plugin deinitializes the GenericPluginTy and subclasses automatically. The old __tgt_rtl_deinit_plugin is not needed anymore.
1 parent 9c33bf6 commit 2b2e711

File tree

5 files changed

+0
-34
lines changed

5 files changed

+0
-34
lines changed

openmp/libomptarget/include/omptargetplugin.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ extern "C" {
2323
// First method called on the plugin
2424
int32_t __tgt_rtl_init_plugin();
2525

26-
// Last method called on the plugin
27-
int32_t __tgt_rtl_deinit_plugin();
28-
2926
// Return the number of available devices of the type supported by the
3027
// target RTL.
3128
int32_t __tgt_rtl_number_of_devices(void);

openmp/libomptarget/include/rtl.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ struct __tgt_bin_desc;
3232

3333
struct RTLInfoTy {
3434
typedef int32_t(init_plugin_ty)();
35-
typedef int32_t(deinit_plugin_ty)();
3635
typedef int32_t(is_valid_binary_ty)(void *);
3736
typedef int32_t(is_valid_binary_info_ty)(void *, void *);
3837
typedef int32_t(is_data_exchangable_ty)(int32_t, int32_t);
@@ -90,7 +89,6 @@ struct RTLInfoTy {
9089

9190
// Functions implemented in the RTL.
9291
init_plugin_ty *init_plugin = nullptr;
93-
deinit_plugin_ty *deinit_plugin = nullptr;
9492
is_valid_binary_ty *is_valid_binary = nullptr;
9593
is_valid_binary_info_ty *is_valid_binary_info = nullptr;
9694
is_data_exchangable_ty *is_data_exchangable = nullptr;

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,17 +1632,6 @@ int32_t __tgt_rtl_init_plugin() {
16321632
return OFFLOAD_SUCCESS;
16331633
}
16341634

1635-
int32_t __tgt_rtl_deinit_plugin() {
1636-
auto Err = Plugin::deinitIfNeeded();
1637-
if (Err) {
1638-
REPORT("Failure to deinitialize plugin " GETNAME(TARGET_NAME) ": %s\n",
1639-
toString(std::move(Err)).data());
1640-
return OFFLOAD_FAIL;
1641-
}
1642-
1643-
return OFFLOAD_SUCCESS;
1644-
}
1645-
16461635
int32_t __tgt_rtl_is_valid_binary(__tgt_device_image *TgtImage) {
16471636
if (!Plugin::isActive())
16481637
return false;

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,13 +1167,6 @@ class Plugin {
11671167
return Error::success();
11681168
}
11691169

1170-
// Deinitialize the plugin if needed. The plugin could have been deinitialized
1171-
// because the plugin library was exiting.
1172-
static Error deinitIfNeeded() {
1173-
// Do nothing. The plugin is deinitialized automatically.
1174-
return Plugin::success();
1175-
}
1176-
11771170
/// Get a reference (or create if it was not created) to the plugin instance.
11781171
static GenericPluginTy &get() {
11791172
// This static variable will initialize the underlying plugin instance in

openmp/libomptarget/src/rtl.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,6 @@ bool RTLsTy::attemptLoadRTL(const std::string &RTLName, RTLInfoTy &RTL) {
193193
DP("Registering RTL %s supporting %d devices!\n", Name, RTL.NumberOfDevices);
194194

195195
// Optional functions
196-
*((void **)&RTL.deinit_plugin) =
197-
DynLibrary->getAddressOfSymbol("__tgt_rtl_deinit_plugin");
198196
*((void **)&RTL.is_valid_binary_info) =
199197
DynLibrary->getAddressOfSymbol("__tgt_rtl_is_valid_binary_info");
200198
*((void **)&RTL.deinit_device) =
@@ -598,14 +596,5 @@ void RTLsTy::unregisterLib(__tgt_bin_desc *Desc) {
598596

599597
PM->TblMapMtx.unlock();
600598

601-
// TODO: Write some RTL->unload_image(...) function?
602-
for (auto *R : UsedRTLs) {
603-
if (R->deinit_plugin) {
604-
if (R->deinit_plugin() != OFFLOAD_SUCCESS) {
605-
DP("Failure deinitializing RTL %s!\n", R->RTLName.c_str());
606-
}
607-
}
608-
}
609-
610599
DP("Done unregistering library!\n");
611600
}

0 commit comments

Comments
 (0)