Skip to content

[OpenMP] Tear down GenericDeviceTy's with GenericPluginTy #73557

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions openmp/libomptarget/include/omptargetplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ int64_t __tgt_rtl_init_requires(int64_t RequiresFlags);
// return an error code.
int32_t __tgt_rtl_init_device(int32_t ID);

// Deinitialize the specified device. In case of success return 0; otherwise
// return an error code.
int32_t __tgt_rtl_deinit_device(int32_t ID);

// Pass an executable image section described by image to the specified
// device and prepare an address table of target entities. In case of error,
// return NULL. Otherwise, return a pointer to the built address table.
Expand Down
2 changes: 0 additions & 2 deletions openmp/libomptarget/include/rtl.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ struct RTLInfoTy {
typedef int32_t(is_data_exchangable_ty)(int32_t, int32_t);
typedef int32_t(number_of_devices_ty)();
typedef int32_t(init_device_ty)(int32_t);
typedef int32_t(deinit_device_ty)(int32_t);
typedef __tgt_target_table *(load_binary_ty)(int32_t, void *);
typedef void *(data_alloc_ty)(int32_t, int64_t, void *, int32_t);
typedef int32_t(data_submit_ty)(int32_t, void *, void *, int64_t);
Expand Down Expand Up @@ -94,7 +93,6 @@ struct RTLInfoTy {
is_data_exchangable_ty *is_data_exchangable = nullptr;
number_of_devices_ty *number_of_devices = nullptr;
init_device_ty *init_device = nullptr;
deinit_device_ty *deinit_device = nullptr;
load_binary_ty *load_binary = nullptr;
data_alloc_ty *data_alloc = nullptr;
data_submit_ty *data_submit = nullptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1688,17 +1688,6 @@ int32_t __tgt_rtl_init_device(int32_t DeviceId) {
return OFFLOAD_SUCCESS;
}

int32_t __tgt_rtl_deinit_device(int32_t DeviceId) {
auto Err = Plugin::get().deinitDevice(DeviceId);
if (Err) {
REPORT("Failure to deinitialize device %d: %s\n", DeviceId,
toString(std::move(Err)).data());
return OFFLOAD_FAIL;
}

return OFFLOAD_SUCCESS;
}

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

int64_t __tgt_rtl_init_requires(int64_t RequiresFlags) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,11 @@ class Plugin {
static Error deinit() {
assert(SpecificPlugin && "Plugin no longer valid");

for (int32_t DevNo = 0, NumDev = SpecificPlugin->getNumDevices();
DevNo < NumDev; ++DevNo)
if (auto Err = SpecificPlugin->deinitDevice(DevNo))
return Err;

// Deinitialize the plugin.
if (auto Err = SpecificPlugin->deinit())
return Err;
Expand Down
5 changes: 0 additions & 5 deletions openmp/libomptarget/src/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,11 +563,6 @@ int32_t DeviceTy::initOnce() {
return OFFLOAD_FAIL;
}

void DeviceTy::deinit() {
if (RTL->deinit_device)
RTL->deinit_device(RTLDeviceID);
}

// Load binary to device.
__tgt_target_table *DeviceTy::loadBinary(void *Img) {
std::lock_guard<decltype(RTL->Mtx)> LG(RTL->Mtx);
Expand Down
2 changes: 0 additions & 2 deletions openmp/libomptarget/src/rtl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,6 @@ bool RTLsTy::attemptLoadRTL(const std::string &RTLName, RTLInfoTy &RTL) {
// Optional functions
*((void **)&RTL.is_valid_binary_info) =
DynLibrary->getAddressOfSymbol("__tgt_rtl_is_valid_binary_info");
*((void **)&RTL.deinit_device) =
DynLibrary->getAddressOfSymbol("__tgt_rtl_deinit_device");
*((void **)&RTL.init_requires) =
DynLibrary->getAddressOfSymbol("__tgt_rtl_init_requires");
*((void **)&RTL.data_submit_async) =
Expand Down