[llvm-branch-commits] [llvm] [offload][omp] Use liboffload to initialize devices (PR #226442)
Alex Duran via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Sep 29 08:51:51 PDT 2026
https://github.com/adurang updated https://github.com/llvm/llvm-project/pull/226442
>From 47c90bd565bf35a6216d61e08d41b26ebb2ddfd9 Mon Sep 17 00:00:00 2001
From: "Duran, Alex" <alejandro.duran at intel.com>
Date: Mon, 7 Sep 2026 03:18:41 -0700
Subject: [PATCH 1/3] [offload][omp] Use olIterateCompatibleDevices for device
init and image registration
---
offload/include/PluginManager.h | 13 +-
offload/include/device.h | 5 +-
offload/liboffload/src/OffloadImpl.cpp | 4 +
offload/libompaccsupport/PluginManager.cpp | 243 ++++++++++--------
offload/libompaccsupport/device.cpp | 17 +-
.../common/include/PluginInterface.h | 6 -
.../common/src/PluginInterface.cpp | 15 --
7 files changed, 151 insertions(+), 152 deletions(-)
diff --git a/offload/include/PluginManager.h b/offload/include/PluginManager.h
index eea8b62a8c39d..36b8f7d3c914b 100644
--- a/offload/include/PluginManager.h
+++ b/offload/include/PluginManager.h
@@ -120,11 +120,9 @@ struct PluginManager {
return Devices.getExclusiveAccessor();
}
- /// Initialize \p Plugin. Returns true on success.
- bool initializePlugin(GenericPluginTy &Plugin);
-
- /// Initialize device \p DeviceNo of \p Plugin. Returns true on success.
- bool initializeDevice(GenericPluginTy &Plugin, int32_t DeviceId);
+ /// Initialize device \p DeviceHandle as on OpenMP device. Returns true on
+ /// success.
+ bool initializeDevice(ol_device_handle_t DeviceHandle);
/// Eagerly initialize all plugins and their devices.
void initializeAllDevices();
@@ -158,9 +156,8 @@ struct PluginManager {
// List of all plugins, in use or not.
llvm::SmallVector<GenericPluginTy *> Plugins;
- // Mapping of plugins to the OpenMP device identifier.
- llvm::DenseMap<std::pair<const GenericPluginTy *, int32_t>, int32_t>
- DeviceIds;
+ // Mapping of device handles to the OpenMP device identifier.
+ llvm::DenseMap<ol_device_handle_t, int32_t> DeviceIds;
// Set of all device images currently in use.
llvm::DenseSet<const __tgt_device_image *> UsedImages;
diff --git a/offload/include/device.h b/offload/include/device.h
index 5918d04d9e0d4..ff6e18d66f335 100644
--- a/offload/include/device.h
+++ b/offload/include/device.h
@@ -34,6 +34,7 @@
#include "llvm/ADT/SmallVector.h"
#include "GlobalHandler.h"
+#include "OffloadAPI.h"
#include "PluginInterface.h"
using GenericPluginTy = llvm::omp::target::plugin::GenericPluginTy;
@@ -48,8 +49,10 @@ struct DeviceTy {
int32_t DeviceID;
GenericPluginTy *RTL;
int32_t RTLDeviceID;
+ ol_device_handle_t DeviceHandle;
- DeviceTy(GenericPluginTy *RTL, int32_t DeviceID, int32_t RTLDeviceID);
+ DeviceTy(GenericPluginTy *RTL, int32_t DeviceID, int32_t RTLDeviceID,
+ ol_device_handle_t DeviceHandle);
// DeviceTy is not copyable
DeviceTy(const DeviceTy &D) = delete;
DeviceTy &operator=(const DeviceTy &D) = delete;
diff --git a/offload/liboffload/src/OffloadImpl.cpp b/offload/liboffload/src/OffloadImpl.cpp
index cc5e8a2ad304d..2e9768523750c 100644
--- a/offload/liboffload/src/OffloadImpl.cpp
+++ b/offload/liboffload/src/OffloadImpl.cpp
@@ -1531,5 +1531,9 @@ GenericPluginTy *__ol_tgt_GetPluginFromPlatform(ol_platform_handle_t Platform) {
}
} // namespace tmp
+extern "C" int32_t __ol_tgt_GetPluginDeviceId(ol_device_handle_t Device) {
+ return Device->DeviceNum;
+}
+
} // namespace offload
} // namespace llvm
diff --git a/offload/libompaccsupport/PluginManager.cpp b/offload/libompaccsupport/PluginManager.cpp
index d15009dc437ba..45ff7fc381822 100644
--- a/offload/libompaccsupport/PluginManager.cpp
+++ b/offload/libompaccsupport/PluginManager.cpp
@@ -79,38 +79,32 @@ void PluginManager::deinit() {
ODBG(ODT_Deinit) << "RTLs unloaded!";
}
-bool PluginManager::initializePlugin(GenericPluginTy &Plugin) {
- if (Plugin.is_initialized())
+bool PluginManager::initializeDevice(ol_device_handle_t DeviceHandle) {
+ if (PM->DeviceIds.find(DeviceHandle) != PM->DeviceIds.end()) {
+ auto ExclusiveDevicesAccessor = getExclusiveDevicesAccessor();
+ (*ExclusiveDevicesAccessor)[PM->DeviceIds[DeviceHandle]]
+ ->setHasPendingImages(true);
return true;
+ }
- if (auto Err = Plugin.init()) {
- std::string InfoMsg = toString(std::move(Err));
- ODBG(ODT_Init) << "Failed to init plugin: " << InfoMsg;
+ ol_platform_handle_t PlatformHandle;
+ if (auto Ret = olGetDeviceInfo(DeviceHandle, OL_DEVICE_INFO_PLATFORM,
+ sizeof(PlatformHandle), &PlatformHandle);
+ Ret != OL_SUCCESS) {
+ REPORT() << "Failed to get platform while initializing device "
+ << DeviceHandle;
return false;
}
- ODBG(ODT_Init) << "Registered plugin " << Plugin.getName() << " with "
- << Plugin.number_of_devices() << " visible device(s)";
-
- return true;
-}
-
-bool PluginManager::initializeDevice(GenericPluginTy &Plugin,
- int32_t DeviceId) {
- if (Plugin.is_device_initialized(DeviceId)) {
- auto ExclusiveDevicesAccessor = getExclusiveDevicesAccessor();
- (*ExclusiveDevicesAccessor)[PM->DeviceIds[std::make_pair(&Plugin,
- DeviceId)]]
- ->setHasPendingImages(true);
- return true;
- }
+ GenericPluginTy &Plugin = *__ol_tgt_GetPluginFromPlatform(PlatformHandle);
+ int32_t DeviceId = __ol_tgt_GetPluginDeviceId(DeviceHandle);
- // Initialize the device information for the RTL we are about to use.
auto ExclusiveDevicesAccessor = getExclusiveDevicesAccessor();
-
+ // Initialize the device information for the RTL we are about to use.
int32_t UserId = ExclusiveDevicesAccessor->size();
- auto Device = std::make_unique<DeviceTy>(&Plugin, UserId, DeviceId);
+ auto Device =
+ std::make_unique<DeviceTy>(&Plugin, UserId, DeviceId, DeviceHandle);
if (auto Err = Device->init()) {
std::string InfoMsg = toString(std::move(Err));
ODBG(ODT_Init) << "Failed to init device " << DeviceId << ": " << InfoMsg;
@@ -121,21 +115,18 @@ bool PluginManager::initializeDevice(GenericPluginTy &Plugin,
// We need to map between the plugin's device identifier and the one
// that OpenMP will use.
- PM->DeviceIds[std::make_pair(&Plugin, DeviceId)] = UserId;
+ PM->DeviceIds[DeviceHandle] = UserId;
return true;
}
void PluginManager::initializeAllDevices() {
- for (auto &Plugin : plugins()) {
- if (!initializePlugin(Plugin))
- continue;
-
- for (int32_t DeviceId = 0; DeviceId < Plugin.number_of_devices();
- ++DeviceId) {
- initializeDevice(Plugin, DeviceId);
- }
- }
+ olIterateDevices(
+ [](ol_device_handle_t Device, void *UserData) {
+ PM->initializeDevice(Device);
+ return true;
+ },
+ nullptr);
// After all plugins are initialized, register atExit cleanup handlers
std::atexit([]() {
// Interop cleanup should be done before the plugins are deinitialized as
@@ -217,91 +208,115 @@ void PluginManager::registerLib(__tgt_bin_desc *Desc) {
PM->addDeviceImage(*Desc, Desc->DeviceImages[i]);
// Register the images with the RTLs that understand them, if any.
- llvm::DenseMap<GenericPluginTy *, llvm::DenseSet<int32_t>> UsedDevices;
+ llvm::SmallVector<ol_device_handle_t> UsedDevices;
for (int32_t i = 0; i < Desc->NumDeviceImages; ++i) {
// Obtain the image and information that was previously extracted.
__tgt_device_image *Img = &Desc->DeviceImages[i];
- GenericPluginTy *FoundRTL = nullptr;
-
- // Scan the RTLs that have associated images until we find one that supports
- // the current image.
- for (auto &R : plugins()) {
- StringRef Buffer(reinterpret_cast<const char *>(Img->ImageStart),
- utils::getPtrDiff(Img->ImageEnd, Img->ImageStart));
-
- if (!R.isPluginCompatible(Buffer))
- continue;
-
- if (!initializePlugin(R))
- continue;
-
- if (!R.number_of_devices()) {
- ODBG(ODT_Init) << "Skipping plugin " << R.getName()
- << " with no visible devices";
- continue;
- }
-
- for (int32_t DeviceId = 0; DeviceId < R.number_of_devices(); ++DeviceId) {
- // We only want a single matching image to be registered for each binary
- // descriptor. This prevents multiple of the same image from being
- // registered for the same device in the case that they are mutually
- // compatible, such as sm_80 and sm_89.
- if (UsedDevices[&R].contains(DeviceId)) {
- ODBG(ODT_Init) << "Image " << Img->ImageStart
- << " is a duplicate, not loaded on RTL " << R.getName()
- << " device " << DeviceId;
- continue;
- }
-
- if (!R.isDeviceCompatible(DeviceId, Buffer))
- continue;
-
- ODBG(ODT_Init) << "Image " << Img->ImageStart
- << " is compatible with RTL " << R.getName()
- << " device " << DeviceId;
-
- if (!initializeDevice(R, DeviceId))
- continue;
-
- // Initialize (if necessary) translation table for this library.
- PM->TrlTblMtx.lock();
- if (!PM->HostEntriesBeginToTransTable.count(Desc->HostEntriesBegin)) {
- PM->HostEntriesBeginRegistrationOrder.push_back(
- Desc->HostEntriesBegin);
- TranslationTable &TT =
- (PM->HostEntriesBeginToTransTable)[Desc->HostEntriesBegin];
- TT.HostTable.EntriesBegin = Desc->HostEntriesBegin;
- TT.HostTable.EntriesEnd = Desc->HostEntriesEnd;
- }
-
- // Retrieve translation table for this library.
- TranslationTable &TT =
- (PM->HostEntriesBeginToTransTable)[Desc->HostEntriesBegin];
-
- ODBG(ODT_Init) << "Registering image " << Img->ImageStart
- << " with RTL " << R.getName();
-
- auto UserId = PM->DeviceIds[std::make_pair(&R, DeviceId)];
- if (TT.TargetsTable.size() < static_cast<size_t>(UserId + 1)) {
- TT.DeviceTables.resize(UserId + 1, {});
- TT.TargetsImages.resize(UserId + 1, nullptr);
- TT.TargetsEntries.resize(UserId + 1, {});
- TT.TargetsTable.resize(UserId + 1, nullptr);
- }
-
- // Register the image for this target type and invalidate the table.
- TT.TargetsImages[UserId] = Img;
- TT.TargetsTable[UserId] = nullptr;
-
- UsedDevices[&R].insert(DeviceId);
- PM->UsedImages.insert(Img);
- FoundRTL = &R;
-
- PM->TrlTblMtx.unlock();
- }
- }
- if (!FoundRTL)
+ struct RegisterImageState {
+ __tgt_bin_desc *Desc;
+ __tgt_device_image *Img;
+ llvm::SmallVector<ol_device_handle_t> &UsedDevices;
+ bool FoundRTL = false;
+ } State{Desc, Img, UsedDevices, false};
+
+ if (ol_result_t Res = olIterateCompatibleDevices(
+ Img->ImageStart, utils::getPtrDiff(Img->ImageEnd, Img->ImageStart),
+ [](ol_device_handle_t DeviceHandle, void *Data) {
+ auto &State = *static_cast<RegisterImageState *>(Data);
+
+ ol_platform_handle_t PlatformHandle;
+ if (auto Res =
+ olGetDeviceInfo(DeviceHandle, OL_DEVICE_INFO_PLATFORM,
+ sizeof(PlatformHandle), &PlatformHandle);
+ Res != OL_SUCCESS) {
+ REPORT() << "Failed to get platform info for device "
+ << DeviceHandle << ":" << Res->Details;
+ PlatformHandle = nullptr;
+ }
+
+ llvm::SmallString<256> PlatformName("Unknown");
+ if (PlatformHandle) {
+ size_t PlatformNameSize = 0;
+ if (auto Res = olGetPlatformInfoSize(PlatformHandle,
+ OL_PLATFORM_INFO_NAME,
+ &PlatformNameSize);
+ Res != OL_SUCCESS)
+ PlatformNameSize = 0;
+
+ PlatformName.resize(PlatformNameSize);
+ if (PlatformNameSize > 0) {
+ if (auto Res = olGetPlatformInfo(
+ PlatformHandle, OL_PLATFORM_INFO_NAME,
+ PlatformNameSize, PlatformName.data());
+ Res != OL_SUCCESS)
+ PlatformName = "Unknown";
+ } else
+ PlatformName = "Unknown";
+ }
+
+ // We only want a single matching image to be registered for each
+ // binary descriptor. This prevents multiple of the same image
+ // from being registered for the same device in the case that
+ // they are mutually compatible, such as sm_80 and sm_89.
+ if (llvm::is_contained(State.UsedDevices, DeviceHandle)) {
+ ODBG(ODT_Init) << "Image " << State.Img->ImageStart
+ << " is a duplicate, not loaded on RTL "
+ << PlatformName << " on device " << DeviceHandle;
+ return true;
+ }
+
+ ODBG(ODT_Init)
+ << "Image " << State.Img->ImageStart << " with RTL "
+ << PlatformName << " on device " << DeviceHandle;
+
+ PM->initializeDevice(DeviceHandle);
+
+ // Initialize (if necessary) translation table for this library.
+ PM->TrlTblMtx.lock();
+ if (!PM->HostEntriesBeginToTransTable.count(
+ State.Desc->HostEntriesBegin)) {
+ PM->HostEntriesBeginRegistrationOrder.push_back(
+ State.Desc->HostEntriesBegin);
+ TranslationTable &TT =
+ (PM->HostEntriesBeginToTransTable)[State.Desc
+ ->HostEntriesBegin];
+ TT.HostTable.EntriesBegin = State.Desc->HostEntriesBegin;
+ TT.HostTable.EntriesEnd = State.Desc->HostEntriesEnd;
+ }
+
+ // Retrieve translation table for this library.
+ TranslationTable &TT =
+ (PM->HostEntriesBeginToTransTable)[State.Desc
+ ->HostEntriesBegin];
+
+ ODBG(ODT_Init) << "Registering image " << State.Img->ImageStart
+ << " with RTL " << PlatformName;
+
+ auto UserId = PM->DeviceIds[DeviceHandle];
+ if (TT.TargetsTable.size() < static_cast<size_t>(UserId + 1)) {
+ TT.DeviceTables.resize(UserId + 1, {});
+ TT.TargetsImages.resize(UserId + 1, nullptr);
+ TT.TargetsEntries.resize(UserId + 1, {});
+ TT.TargetsTable.resize(UserId + 1, nullptr);
+ }
+
+ // Register the image for this target type and invalidate the
+ // table.
+ TT.TargetsImages[UserId] = State.Img;
+ TT.TargetsTable[UserId] = nullptr;
+
+ State.UsedDevices.push_back(DeviceHandle);
+ PM->UsedImages.insert(State.Img);
+ State.FoundRTL = true;
+
+ PM->TrlTblMtx.unlock();
+ return true;
+ },
+ &State))
+ REPORT() << "Failed to iterate compatible devices: " << Res->Details;
+
+ if (!State.FoundRTL)
ODBG(ODT_Init) << "No RTL found for image " << Img->ImageStart << "!";
}
PM->RTLsMtx.unlock();
diff --git a/offload/libompaccsupport/device.cpp b/offload/libompaccsupport/device.cpp
index 5aec1156930d6..2c2fd60e26127 100644
--- a/offload/libompaccsupport/device.cpp
+++ b/offload/libompaccsupport/device.cpp
@@ -68,9 +68,10 @@ int HostDataToTargetTy::addEventIfNecessary(DeviceTy &Device,
return OFFLOAD_SUCCESS;
}
-DeviceTy::DeviceTy(GenericPluginTy *RTL, int32_t DeviceID, int32_t RTLDeviceID)
+DeviceTy::DeviceTy(GenericPluginTy *RTL, int32_t DeviceID, int32_t RTLDeviceID,
+ ol_device_handle_t DeviceHandle)
: DeviceID(DeviceID), RTL(RTL), RTLDeviceID(RTLDeviceID),
- MappingInfo(*this) {}
+ DeviceHandle(DeviceHandle), MappingInfo(*this) {}
DeviceTy::~DeviceTy() {
if (DeviceID == -1 || !(getInfoLevel() & OMP_INFOTYPE_DUMP_TABLE))
@@ -81,11 +82,11 @@ DeviceTy::~DeviceTy() {
}
llvm::Error DeviceTy::init() {
- int32_t Ret = RTL->init_device(RTLDeviceID);
- if (Ret != OFFLOAD_SUCCESS)
- return error::createOffloadError(error::ErrorCode::BACKEND_FAILURE,
- "failed to initialize device %d\n",
- DeviceID);
+ // TODO: Remove this once all device operations go through liboffload
+ // This just ensures the device is initialized for cases where we go through
+ // the plugin interface.
+ size_t Size = 0;
+ olGetDeviceInfoSize(DeviceHandle, OL_DEVICE_INFO_GLOBAL_MEM_SIZE, &Size);
OMPT_IF_BUILT_AND_INITIALIZED({
GenericDeviceTy &GenericDevice = RTL->getDevice(RTLDeviceID);
@@ -113,7 +114,7 @@ llvm::Error DeviceTy::init() {
bool EmitReport =
OMPX_EmitRecordReport || !OMPX_RecordReportFilename.get().empty();
- Ret = RTL->initialize_record_replay(
+ int32_t Ret = RTL->initialize_record_replay(
RTLDeviceID, OMPX_RecordMemSize, nullptr,
/*IsRecord=*/true, /*IsNative=*/true, OMPX_RecordOutput, EmitReport,
OMPX_RecordReportFilename.get().c_str(),
diff --git a/offload/plugins-nextgen/common/include/PluginInterface.h b/offload/plugins-nextgen/common/include/PluginInterface.h
index ca05ff32f06e8..e20f381b9d5d5 100644
--- a/offload/plugins-nextgen/common/include/PluginInterface.h
+++ b/offload/plugins-nextgen/common/include/PluginInterface.h
@@ -1741,12 +1741,6 @@ struct GenericPluginTy {
/// Returns non-zero if the \p Image is compatible with the device.
int32_t isDeviceCompatible(int32_t DeviceId, StringRef Image);
- /// Returns non-zero if the plugin device has been initialized.
- int32_t is_device_initialized(int32_t DeviceId) const;
-
- /// Initialize the device inside of the plugin.
- int32_t init_device(int32_t DeviceId);
-
/// Return the number of devices this plugin can support.
int32_t number_of_devices();
diff --git a/offload/plugins-nextgen/common/src/PluginInterface.cpp b/offload/plugins-nextgen/common/src/PluginInterface.cpp
index 118df2e3e6506..03ddf73ec3aaa 100644
--- a/offload/plugins-nextgen/common/src/PluginInterface.cpp
+++ b/offload/plugins-nextgen/common/src/PluginInterface.cpp
@@ -1524,21 +1524,6 @@ int32_t GenericPluginTy::isDeviceCompatible(int32_t DeviceId, StringRef Image) {
}
}
-int32_t GenericPluginTy::is_device_initialized(int32_t DeviceId) const {
- return isValidDeviceId(DeviceId) && Devices[DeviceId] != nullptr;
-}
-
-int32_t GenericPluginTy::init_device(int32_t DeviceId) {
- auto Err = initDevice(DeviceId);
- if (Err) {
- REPORT() << "Failure to initialize device " << DeviceId << ": "
- << toString(std::move(Err));
- return OFFLOAD_FAIL;
- }
-
- return OFFLOAD_SUCCESS;
-}
-
int32_t GenericPluginTy::number_of_devices() { return getNumDevices(); }
int32_t GenericPluginTy::is_data_exchangable(int32_t SrcDeviceId,
>From 735e888b68d84fe1562f8403c3b7be71e7ffd734 Mon Sep 17 00:00:00 2001
From: "Duran, Alex" <alejandro.duran at intel.com>
Date: Mon, 7 Sep 2026 22:38:35 -0700
Subject: [PATCH 2/3] remove two export lines
---
offload/liboffload/exports | 56 ++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/offload/liboffload/exports b/offload/liboffload/exports
index 168341aa7d938..dd7c0881c94b1 100644
--- a/offload/liboffload/exports
+++ b/offload/liboffload/exports
@@ -1,6 +1,62 @@
VERS1.0 {
global:
ol*;
+<<<<<<< HEAD
+=======
+ # Symbols currently used by libomptarget. They should be removed from here as
+ # they become replaced by calls to the liboffload API.
+ # No new symbols should be added here.
+ extern "C++" {
+ error::OffloadError::ID;
+ "error::OffloadErrCategory()";
+ "llvm::omp::target::RPCServerTy::registerCallback(unsigned int (*)(void*, unsigned int))";
+ "llvm::omp::target::plugin::GenericDeviceTy::dataFill(void*, void const*, long, long, __tgt_async_info*)";
+ "llvm::omp::target::plugin::GenericPluginTy::async_barrier(omp_interop_val_t*)";
+ "llvm::omp::target::plugin::GenericPluginTy::create_event(int, void**)";
+ "llvm::omp::target::plugin::GenericPluginTy::create_interop(int, int, interop_spec_t*)";
+ "llvm::omp::target::plugin::GenericPluginTy::data_alloc(int, long, void*, int)";
+ "llvm::omp::target::plugin::GenericPluginTy::data_delete(int, void*, int)";
+ "llvm::omp::target::plugin::GenericPluginTy::data_exchange(int, void*, int, void*, long)";
+ "llvm::omp::target::plugin::GenericPluginTy::data_exchange_async(int, void*, int, void*, long, __tgt_async_info*)";
+ "llvm::omp::target::plugin::GenericPluginTy::data_fence(int, __tgt_async_info*)";
+ "llvm::omp::target::plugin::GenericPluginTy::data_lock(int, void*, long, void**)";
+ "llvm::omp::target::plugin::GenericPluginTy::data_notify_mapped(int, void*, long)";
+ "llvm::omp::target::plugin::GenericPluginTy::data_notify_unmapped(int, void*)";
+ "llvm::omp::target::plugin::GenericPluginTy::data_retrieve_async(int, void*, void*, long, __tgt_async_info*)";
+ "llvm::omp::target::plugin::GenericPluginTy::data_submit(int, void*, void*, long)";
+ "llvm::omp::target::plugin::GenericPluginTy::data_submit_async(int, void*, void*, long, __tgt_async_info*)";
+ "llvm::omp::target::plugin::GenericPluginTy::data_unlock(int, void*)";
+ "llvm::omp::target::plugin::GenericPluginTy::destroy_event(int, void*)";
+ "llvm::omp::target::plugin::GenericPluginTy::flush_queue(omp_interop_val_t*)";
+ "llvm::omp::target::plugin::GenericPluginTy::get_function(__tgt_device_binary, char const*, void**)";
+ "llvm::omp::target::plugin::GenericPluginTy::get_global(__tgt_device_binary, unsigned long, char const*, void**)";
+ "llvm::omp::target::plugin::GenericPluginTy::initialize_record_replay(int, long, void*, bool, bool, bool, bool, char const*, char const*)";
+ "llvm::omp::target::plugin::GenericPluginTy::is_accessible_ptr(int, void const*, unsigned long)";
+ "llvm::omp::target::plugin::GenericPluginTy::is_data_exchangable(int, int)";
+ "llvm::omp::target::plugin::GenericPluginTy::is_initialized() const";
+ "llvm::omp::target::plugin::GenericPluginTy::launch_kernel(int, void*, llvm::omp::target::plugin::KernelLaunchArgsTy&, __tgt_async_info*)";
+ "llvm::omp::target::plugin::GenericPluginTy::load_binary(int, __tgt_device_image*, __tgt_device_binary*)";
+ "llvm::omp::target::plugin::GenericPluginTy::number_of_devices()";
+ "llvm::omp::target::plugin::GenericPluginTy::obtain_device_info(int)";
+ "llvm::omp::target::plugin::GenericPluginTy::print_device_info(int)";
+ "llvm::omp::target::plugin::GenericPluginTy::query_async(int, __tgt_async_info*)";
+ "llvm::omp::target::plugin::GenericPluginTy::record_event(int, void*, __tgt_async_info*)";
+ "llvm::omp::target::plugin::GenericPluginTy::release_interop(int, omp_interop_val_t*)";
+ "llvm::omp::target::plugin::GenericPluginTy::set_device_identifier(int, int)";
+ "llvm::omp::target::plugin::GenericPluginTy::sync_barrier(omp_interop_val_t*)";
+ "llvm::omp::target::plugin::GenericPluginTy::sync_event(int, void*)";
+ "llvm::omp::target::plugin::GenericPluginTy::synchronize(int, __tgt_async_info*)";
+ "llvm::omp::target::plugin::GenericPluginTy::use_auto_zero_copy(int)";
+ "llvm::omp::target::plugin::GenericPluginTy::wait_event(int, void*, __tgt_async_info*)";
+ llvm::omp::target::ompt::Initialized;
+ llvm::omp::target::ompt::lookupCallbackByCode;
+ llvm::omp::target::ompt::lookupCallbackByName;
+ # Temporary helpers to help transition of libomptarget to liboffload.
+ __ol_tgt_setInfoFlag;
+ __ol_tgt_GetPluginFromPlatform;
+ __ol_tgt_GetPluginDeviceId;
+ };
+>>>>>>> 885a6c290ea9 (remove two export lines)
local:
*;
};
>From 6692768939f3f42673ee6af04926a3cf1603ebf7 Mon Sep 17 00:00:00 2001
From: "Duran, Alex" <alejandro.duran at intel.com>
Date: Fri, 25 Sep 2026 02:07:25 -0700
Subject: [PATCH 3/3] restore export file
---
offload/liboffload/exports | 56 ----------------------
offload/liboffload/src/OffloadImpl.cpp | 4 +-
offload/libompaccsupport/PluginManager.cpp | 7 ++-
3 files changed, 7 insertions(+), 60 deletions(-)
diff --git a/offload/liboffload/exports b/offload/liboffload/exports
index dd7c0881c94b1..168341aa7d938 100644
--- a/offload/liboffload/exports
+++ b/offload/liboffload/exports
@@ -1,62 +1,6 @@
VERS1.0 {
global:
ol*;
-<<<<<<< HEAD
-=======
- # Symbols currently used by libomptarget. They should be removed from here as
- # they become replaced by calls to the liboffload API.
- # No new symbols should be added here.
- extern "C++" {
- error::OffloadError::ID;
- "error::OffloadErrCategory()";
- "llvm::omp::target::RPCServerTy::registerCallback(unsigned int (*)(void*, unsigned int))";
- "llvm::omp::target::plugin::GenericDeviceTy::dataFill(void*, void const*, long, long, __tgt_async_info*)";
- "llvm::omp::target::plugin::GenericPluginTy::async_barrier(omp_interop_val_t*)";
- "llvm::omp::target::plugin::GenericPluginTy::create_event(int, void**)";
- "llvm::omp::target::plugin::GenericPluginTy::create_interop(int, int, interop_spec_t*)";
- "llvm::omp::target::plugin::GenericPluginTy::data_alloc(int, long, void*, int)";
- "llvm::omp::target::plugin::GenericPluginTy::data_delete(int, void*, int)";
- "llvm::omp::target::plugin::GenericPluginTy::data_exchange(int, void*, int, void*, long)";
- "llvm::omp::target::plugin::GenericPluginTy::data_exchange_async(int, void*, int, void*, long, __tgt_async_info*)";
- "llvm::omp::target::plugin::GenericPluginTy::data_fence(int, __tgt_async_info*)";
- "llvm::omp::target::plugin::GenericPluginTy::data_lock(int, void*, long, void**)";
- "llvm::omp::target::plugin::GenericPluginTy::data_notify_mapped(int, void*, long)";
- "llvm::omp::target::plugin::GenericPluginTy::data_notify_unmapped(int, void*)";
- "llvm::omp::target::plugin::GenericPluginTy::data_retrieve_async(int, void*, void*, long, __tgt_async_info*)";
- "llvm::omp::target::plugin::GenericPluginTy::data_submit(int, void*, void*, long)";
- "llvm::omp::target::plugin::GenericPluginTy::data_submit_async(int, void*, void*, long, __tgt_async_info*)";
- "llvm::omp::target::plugin::GenericPluginTy::data_unlock(int, void*)";
- "llvm::omp::target::plugin::GenericPluginTy::destroy_event(int, void*)";
- "llvm::omp::target::plugin::GenericPluginTy::flush_queue(omp_interop_val_t*)";
- "llvm::omp::target::plugin::GenericPluginTy::get_function(__tgt_device_binary, char const*, void**)";
- "llvm::omp::target::plugin::GenericPluginTy::get_global(__tgt_device_binary, unsigned long, char const*, void**)";
- "llvm::omp::target::plugin::GenericPluginTy::initialize_record_replay(int, long, void*, bool, bool, bool, bool, char const*, char const*)";
- "llvm::omp::target::plugin::GenericPluginTy::is_accessible_ptr(int, void const*, unsigned long)";
- "llvm::omp::target::plugin::GenericPluginTy::is_data_exchangable(int, int)";
- "llvm::omp::target::plugin::GenericPluginTy::is_initialized() const";
- "llvm::omp::target::plugin::GenericPluginTy::launch_kernel(int, void*, llvm::omp::target::plugin::KernelLaunchArgsTy&, __tgt_async_info*)";
- "llvm::omp::target::plugin::GenericPluginTy::load_binary(int, __tgt_device_image*, __tgt_device_binary*)";
- "llvm::omp::target::plugin::GenericPluginTy::number_of_devices()";
- "llvm::omp::target::plugin::GenericPluginTy::obtain_device_info(int)";
- "llvm::omp::target::plugin::GenericPluginTy::print_device_info(int)";
- "llvm::omp::target::plugin::GenericPluginTy::query_async(int, __tgt_async_info*)";
- "llvm::omp::target::plugin::GenericPluginTy::record_event(int, void*, __tgt_async_info*)";
- "llvm::omp::target::plugin::GenericPluginTy::release_interop(int, omp_interop_val_t*)";
- "llvm::omp::target::plugin::GenericPluginTy::set_device_identifier(int, int)";
- "llvm::omp::target::plugin::GenericPluginTy::sync_barrier(omp_interop_val_t*)";
- "llvm::omp::target::plugin::GenericPluginTy::sync_event(int, void*)";
- "llvm::omp::target::plugin::GenericPluginTy::synchronize(int, __tgt_async_info*)";
- "llvm::omp::target::plugin::GenericPluginTy::use_auto_zero_copy(int)";
- "llvm::omp::target::plugin::GenericPluginTy::wait_event(int, void*, __tgt_async_info*)";
- llvm::omp::target::ompt::Initialized;
- llvm::omp::target::ompt::lookupCallbackByCode;
- llvm::omp::target::ompt::lookupCallbackByName;
- # Temporary helpers to help transition of libomptarget to liboffload.
- __ol_tgt_setInfoFlag;
- __ol_tgt_GetPluginFromPlatform;
- __ol_tgt_GetPluginDeviceId;
- };
->>>>>>> 885a6c290ea9 (remove two export lines)
local:
*;
};
diff --git a/offload/liboffload/src/OffloadImpl.cpp b/offload/liboffload/src/OffloadImpl.cpp
index 2e9768523750c..4da426a02aff9 100644
--- a/offload/liboffload/src/OffloadImpl.cpp
+++ b/offload/liboffload/src/OffloadImpl.cpp
@@ -1529,11 +1529,11 @@ namespace tmp {
GenericPluginTy *__ol_tgt_GetPluginFromPlatform(ol_platform_handle_t Platform) {
return Platform->Plugin.get();
}
-} // namespace tmp
-extern "C" int32_t __ol_tgt_GetPluginDeviceId(ol_device_handle_t Device) {
+int32_t __ol_tgt_GetPluginDeviceId(ol_device_handle_t Device) {
return Device->DeviceNum;
}
+} // namespace tmp
} // namespace offload
} // namespace llvm
diff --git a/offload/libompaccsupport/PluginManager.cpp b/offload/libompaccsupport/PluginManager.cpp
index 45ff7fc381822..ed8b33bb574c8 100644
--- a/offload/libompaccsupport/PluginManager.cpp
+++ b/offload/libompaccsupport/PluginManager.cpp
@@ -33,6 +33,7 @@ PluginManager *PM = nullptr;
namespace llvm::offload::tmp {
GenericPluginTy *__ol_tgt_GetPluginFromPlatform(ol_platform_handle_t Platform);
+int32_t __ol_tgt_GetPluginDeviceId(ol_device_handle_t Device);
} // namespace llvm::offload::tmp
void PluginManager::init() {
@@ -96,8 +97,10 @@ bool PluginManager::initializeDevice(ol_device_handle_t DeviceHandle) {
return false;
}
- GenericPluginTy &Plugin = *__ol_tgt_GetPluginFromPlatform(PlatformHandle);
- int32_t DeviceId = __ol_tgt_GetPluginDeviceId(DeviceHandle);
+ GenericPluginTy &Plugin =
+ *llvm::offload::tmp::__ol_tgt_GetPluginFromPlatform(PlatformHandle);
+ int32_t DeviceId =
+ llvm::offload::tmp::__ol_tgt_GetPluginDeviceId(DeviceHandle);
auto ExclusiveDevicesAccessor = getExclusiveDevicesAccessor();
// Initialize the device information for the RTL we are about to use.
More information about the llvm-branch-commits
mailing list