From f1e917d07bd16b7d3e27ddd37d76f75f9ac97f96 Mon Sep 17 00:00:00 2001 From: Joseph Huber Date: Thu, 6 Feb 2025 08:24:01 -0600 Subject: [Offload] Unify offloading entries into a single section (#125731) Summary: This patch unifies the existing offloading entires into a single section called `llvm_offload_entires`. This lets us use a more unified offloading infrastructure so that all targets share the same handling. The effect is that people in the runtimes now need to check if the kind is what they expect, but the expectation is that you can combine multiple potential providers into a compile job. Doesn't fully work yet because of other runtime issues, but some day. Mostly this helps the future of liboffload where we want to handle different languages than OpenMP. --- offload/src/PluginManager.cpp | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) (limited to 'offload/src/PluginManager.cpp') diff --git a/offload/src/PluginManager.cpp b/offload/src/PluginManager.cpp index f623b423f450..8b77852d1343 100644 --- a/offload/src/PluginManager.cpp +++ b/offload/src/PluginManager.cpp @@ -330,7 +330,8 @@ void PluginManager::unregisterLib(__tgt_bin_desc *Desc) { PM->TblMapMtx.lock(); for (llvm::offloading::EntryTy *Cur = Desc->HostEntriesBegin; Cur < Desc->HostEntriesEnd; ++Cur) { - PM->HostPtrToTableMap.erase(Cur->Address); + if (Cur->Kind == object::OffloadKind::OFK_OpenMP) + PM->HostPtrToTableMap.erase(Cur->Address); } // Remove translation table for this descriptor. @@ -400,6 +401,9 @@ static int loadImagesOntoDevice(DeviceTy &Device) { TransTable->TargetsEntries[DeviceId]; for (llvm::offloading::EntryTy &Entry : llvm::make_range(Img->EntriesBegin, Img->EntriesEnd)) { + if (Entry.Kind != object::OffloadKind::OFK_OpenMP) + continue; + __tgt_device_binary &Binary = *BinaryOrErr; llvm::offloading::EntryTy DeviceEntry = Entry; @@ -437,22 +441,6 @@ static int loadImagesOntoDevice(DeviceTy &Device) { __tgt_target_table *TargetTable = TransTable->TargetsTable[DeviceId] = &TransTable->DeviceTables[DeviceId]; - // 4) Verify whether the two table sizes match. - size_t Hsize = - TransTable->HostTable.EntriesEnd - TransTable->HostTable.EntriesBegin; - size_t Tsize = TargetTable->EntriesEnd - TargetTable->EntriesBegin; - - // Invalid image for these host entries! - if (Hsize != Tsize) { - REPORT( - "Host and Target tables mismatch for device id %d [%zx != %zx].\n", - DeviceId, Hsize, Tsize); - TransTable->TargetsImages[DeviceId] = 0; - TransTable->TargetsTable[DeviceId] = 0; - Rc = OFFLOAD_FAIL; - break; - } - MappingInfoTy::HDTTMapAccessorTy HDTTMap = Device.getMappingInfo().HostDataToTargetMap.getExclusiveAccessor(); @@ -463,7 +451,8 @@ static int loadImagesOntoDevice(DeviceTy &Device) { *EntryDeviceEnd = TargetTable->EntriesEnd; CurrDeviceEntry != EntryDeviceEnd; CurrDeviceEntry++, CurrHostEntry++) { - if (CurrDeviceEntry->Size == 0) + if (CurrDeviceEntry->Size == 0 || + CurrDeviceEntry->Kind != object::OffloadKind::OFK_OpenMP) continue; assert(CurrDeviceEntry->Size == CurrHostEntry->Size && -- cgit v1.2.3