diff --git a/offload/include/OpenMP/InteropAPI.h b/offload/include/OpenMP/InteropAPI.h index 53ac4be2e2e98..71c78760a3226 100644 --- a/offload/include/OpenMP/InteropAPI.h +++ b/offload/include/OpenMP/InteropAPI.h @@ -13,69 +13,17 @@ #include "omp.h" -#include "PerThreadTable.h" #include "omptarget.h" extern "C" { typedef enum kmp_interop_type_t { kmp_interop_type_unknown = -1, - kmp_interop_type_target, - kmp_interop_type_targetsync, + kmp_interop_type_platform, + kmp_interop_type_device, + kmp_interop_type_tasksync, } kmp_interop_type_t; -struct interop_attrs_t { - bool inorder : 1; - int reserved : 31; - - /// Check if the supported attributes are compatible with the current - /// attributes. Only if an attribute is supported can the value be true, - /// otherwise it needs to be false - bool checkSupportedOnly(interop_attrs_t supported) const { - return supported.inorder || (!supported.inorder && !inorder); - } -}; - -struct interop_spec_t { - int32_t fr_id; - interop_attrs_t attrs; // Common attributes - int64_t impl_attrs; // Implementation specific attributes (recognized by each - // plugin) -}; - -struct interop_flags_t { - bool implicit : 1; // dispatch (true) or interop (false) - bool nowait : 1; // has nowait flag - int reserved : 30; -}; - -struct interop_ctx_t { - uint32_t version; // version of the interface (current is 0) - interop_flags_t flags; - int gtid; -}; - -struct dep_pack_t { - int32_t ndeps; - int32_t ndeps_noalias; - kmp_depend_info_t *deplist; - kmp_depend_info_t *noalias_deplist; -}; - -struct omp_interop_val_t; - -typedef void ompx_interop_cb_t(omp_interop_val_t *interop, void *data); - -struct omp_interop_cb_instance_t { - ompx_interop_cb_t *cb; - void *data; - - omp_interop_cb_instance_t(ompx_interop_cb_t *cb, void *data) - : cb(cb), data(data) {} - - void operator()(omp_interop_val_t *interop) { cb(interop, data); } -}; - /// The interop value type, aka. the interop object. typedef struct omp_interop_val_t { /// Device and interop-type are determined at construction time and fix. @@ -86,98 +34,10 @@ typedef struct omp_interop_val_t { __tgt_device_info device_info; const kmp_interop_type_t interop_type; const intptr_t device_id; - omp_vendor_id_t vendor_id = omp_vendor_llvm; - tgt_foreign_runtime_id_t fr_id = tgt_fr_none; - interop_attrs_t attrs{false, 0}; // Common prefer specification attributes - int64_t impl_attrs = 0; // Implementation prefer specification attributes - - // Constants - static constexpr int no_owner = -1; // This interop has no current owner - - void *rtl_property = nullptr; // Plugin dependent information - // For implicitly created Interop objects (e.g., from a dispatch construct) - // who owns the object - int owner_gtid = no_owner; - // Marks whether the object was requested since the last time it was synced - bool clean = true; - - typedef llvm::SmallVector callback_list_t; - - callback_list_t completion_cbs; - - void reset() { - owner_gtid = no_owner; - markClean(); - clearCompletionCbs(); - } - - llvm::Expected getDevice() const; - - bool hasOwner() const { return owner_gtid != no_owner; } - - void setOwner(int gtid) { owner_gtid = gtid; } - bool isOwnedBy(int gtid) { return owner_gtid == gtid; } - bool isCompatibleWith(int32_t InteropType, const interop_spec_t &Spec); - bool isCompatibleWith(int32_t InteropType, const interop_spec_t &Spec, - int64_t DeviceNum, int gtid); - void markClean() { clean = true; } - void markDirty() { clean = false; } - bool isClean() const { return clean; } - - int32_t flush(DeviceTy &Device); - int32_t sync_barrier(DeviceTy &Device); - int32_t async_barrier(DeviceTy &Device); - int32_t release(DeviceTy &Device); - - void addCompletionCb(ompx_interop_cb_t *cb, void *data) { - completion_cbs.push_back(omp_interop_cb_instance_t(cb, data)); - } - - int numCompletionCbs() const { return completion_cbs.size(); } - void clearCompletionCbs() { completion_cbs.clear(); } - - void runCompletionCbs() { - for (auto &cbInstance : completion_cbs) - cbInstance(this); - clearCompletionCbs(); - } + const omp_foreign_runtime_ids_t vendor_id = cuda; + const intptr_t backend_type_id = omp_interop_backend_type_cuda_1; } omp_interop_val_t; } // extern "C" -struct InteropTableEntry { - using ContainerTy = typename std::vector; - using iterator = typename ContainerTy::iterator; - - ContainerTy Interops; - - static constexpr int reservedEntriesPerThread = - 20; // reserve some entries to avoid reallocation - - void add(omp_interop_val_t *obj) { - if (Interops.capacity() == 0) - Interops.reserve(reservedEntriesPerThread); - Interops.push_back(obj); - } - - template void clear(ClearFuncTy f) { - for (auto &Obj : Interops) { - f(Obj); - } - } - - /// vector interface - int size() const { return Interops.size(); } - iterator begin() { return Interops.begin(); } - iterator end() { return Interops.end(); } - iterator erase(iterator it) { return Interops.erase(it); } -}; - -struct InteropTblTy - : public PerThreadTable { - void clear(); -}; - -void syncImplicitInterops(int gtid, void *event); - #endif // OMPTARGET_OPENMP_INTEROP_API_H diff --git a/offload/include/OpenMP/omp.h b/offload/include/OpenMP/omp.h index 49d9f1fa75c20..b44c6aff1b289 100644 --- a/offload/include/OpenMP/omp.h +++ b/offload/include/OpenMP/omp.h @@ -80,18 +80,15 @@ typedef enum omp_interop_rc { omp_irc_other = -6 } omp_interop_rc_t; -/* Foreign runtime values from OpenMP Additional Definitions document v2.1 */ -typedef enum tgt_foreign_runtime_id_t { - tgt_fr_none = 0, - tgt_fr_cuda = 1, - tgt_fr_cuda_driver = 2, - tgt_fr_opencl = 3, - tgt_fr_sycl = 4, - tgt_fr_hip = 5, - tgt_fr_level_zero = 6, - tgt_fr_hsa = 7, - tgt_fr_last = 8 -} tgt_foreign_runtime_id_t; +typedef enum omp_interop_fr { + omp_ifr_cuda = 1, + omp_ifr_cuda_driver = 2, + omp_ifr_opencl = 3, + omp_ifr_sycl = 4, + omp_ifr_hip = 5, + omp_ifr_level_zero = 6, + omp_ifr_last = 7 +} omp_interop_fr_t; typedef void *omp_interop_t; @@ -137,23 +134,19 @@ omp_get_interop_type_desc(const omp_interop_t, omp_interop_property_t); extern const char *__KAI_KMPC_CONVENTION omp_get_interop_rc_desc(const omp_interop_t, omp_interop_rc_t); -/* Vendor defined values from OpenMP Additional Definitions document v2.1*/ -typedef enum omp_vendor_id { - omp_vendor_unknown = 0, - omp_vendor_amd = 1, - omp_vendor_arm = 2, - omp_vendor_bsc = 3, - omp_vendor_fujitsu = 4, - omp_vendor_gnu = 5, - omp_vendor_hpe = 6, - omp_vendor_ibm = 7, - omp_vendor_intel = 8, - omp_vendor_llvm = 9, - omp_vendor_nec = 10, - omp_vendor_nvidia = 11, - omp_vendor_ti = 12, - omp_vendor_last = 13 -} omp_vendor_id_t; +typedef enum omp_interop_backend_type_t { + // reserve 0 + omp_interop_backend_type_cuda_1 = 1, +} omp_interop_backend_type_t; + +typedef enum omp_foreign_runtime_ids { + cuda = 1, + cuda_driver = 2, + opencl = 3, + sycl = 4, + hip = 5, + level_zero = 6, +} omp_foreign_runtime_ids_t; ///} InteropAPI diff --git a/offload/include/PerThreadTable.h b/offload/include/PerThreadTable.h deleted file mode 100644 index 45b196171b4c8..0000000000000 --- a/offload/include/PerThreadTable.h +++ /dev/null @@ -1,114 +0,0 @@ -//===-- PerThreadTable.h -- PerThread Storage Structure ----*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// Table indexed with one entry per thread. -// -//===----------------------------------------------------------------------===// - -#ifndef OFFLOAD_PERTHREADTABLE_H -#define OFFLOAD_PERTHREADTABLE_H - -#include -#include -#include - -// Using an STL container (such as std::vector) indexed by thread ID has -// too many race conditions issues so we store each thread entry into a -// thread_local variable. -// T is the container type used to store the objects, e.g., std::vector, -// std::set, etc. by each thread. O is the type of the stored objects e.g., -// omp_interop_val_t *, ... - -template struct PerThreadTable { - using iterator = typename ContainerType::iterator; - - struct PerThreadData { - size_t NElements = 0; - std::unique_ptr ThEntry; - }; - - std::mutex Mtx; - std::list> ThreadDataList; - - // define default constructors, disable copy and move constructors - PerThreadTable() = default; - PerThreadTable(const PerThreadTable &) = delete; - PerThreadTable(PerThreadTable &&) = delete; - PerThreadTable &operator=(const PerThreadTable &) = delete; - PerThreadTable &operator=(PerThreadTable &&) = delete; - ~PerThreadTable() { - std::lock_guard Lock(Mtx); - ThreadDataList.clear(); - } - -private: - PerThreadData &getThreadData() { - static thread_local std::shared_ptr ThData = nullptr; - if (!ThData) { - ThData = std::make_shared(); - std::lock_guard Lock(Mtx); - ThreadDataList.push_back(ThData); - } - return *ThData; - } - -protected: - ContainerType &getThreadEntry() { - auto &ThData = getThreadData(); - if (ThData.ThEntry) - return *ThData.ThEntry; - ThData.ThEntry = std::make_unique(); - return *ThData.ThEntry; - } - - size_t &getThreadNElements() { - auto &ThData = getThreadData(); - return ThData.NElements; - } - -public: - void add(ObjectType obj) { - auto &Entry = getThreadEntry(); - auto &NElements = getThreadNElements(); - NElements++; - Entry.add(obj); - } - - iterator erase(iterator it) { - auto &Entry = getThreadEntry(); - auto &NElements = getThreadNElements(); - NElements--; - return Entry.erase(it); - } - - size_t size() { return getThreadNElements(); } - - // Iterators to traverse objects owned by - // the current thread - iterator begin() { - auto &Entry = getThreadEntry(); - return Entry.begin(); - } - iterator end() { - auto &Entry = getThreadEntry(); - return Entry.end(); - } - - template void clear(F f) { - std::lock_guard Lock(Mtx); - for (auto ThData : ThreadDataList) { - if (!ThData->ThEntry || ThData->NElements == 0) - continue; - ThData->ThEntry->clear(f); - ThData->NElements = 0; - } - ThreadDataList.clear(); - } -}; - -#endif diff --git a/offload/include/PluginManager.h b/offload/include/PluginManager.h index 6c6fdebe76dff..ec3adadf0819b 100644 --- a/offload/include/PluginManager.h +++ b/offload/include/PluginManager.h @@ -35,8 +35,6 @@ #include #include -#include "OpenMP/InteropAPI.h" - using GenericPluginTy = llvm::omp::target::plugin::GenericPluginTy; /// Struct for the data required to handle plugins @@ -90,9 +88,6 @@ struct PluginManager { HostPtrToTableMapTy HostPtrToTableMap; std::mutex TblMapMtx; ///< For HostPtrToTableMap - /// Table of cached implicit interop objects - InteropTblTy InteropTbl; - // Work around for plugins that call dlopen on shared libraries that call // tgt_register_lib during their initialisation. Stash the pointers in a // vector until the plugins are all initialised and then register them. @@ -190,6 +185,5 @@ void initRuntime(); void deinitRuntime(); extern PluginManager *PM; -extern std::atomic RTLAlive; // Indicates if the RTL has been initialized -extern std::atomic RTLOngoingSyncs; // Counts ongoing external syncs + #endif // OMPTARGET_PLUGIN_MANAGER_H diff --git a/offload/include/Shared/APITypes.h b/offload/include/Shared/APITypes.h index 8c150b6bfc2d4..1982043bd9ef4 100644 --- a/offload/include/Shared/APITypes.h +++ b/offload/include/Shared/APITypes.h @@ -37,7 +37,6 @@ struct __tgt_device_image { struct __tgt_device_info { void *Context = nullptr; void *Device = nullptr; - void *Platform = nullptr; }; /// This struct is a record of all the host code that may be offloaded to a diff --git a/offload/libomptarget/OffloadRTL.cpp b/offload/libomptarget/OffloadRTL.cpp index 04bd21ec91a49..29b573a27d087 100644 --- a/offload/libomptarget/OffloadRTL.cpp +++ b/offload/libomptarget/OffloadRTL.cpp @@ -22,8 +22,6 @@ extern void llvm::omp::target::ompt::connectLibrary(); static std::mutex PluginMtx; static uint32_t RefCount = 0; -std::atomic RTLAlive{false}; -std::atomic RTLOngoingSyncs{0}; void initRuntime() { std::scoped_lock Lock(PluginMtx); @@ -43,9 +41,6 @@ void initRuntime() { PM->init(); PM->registerDelayedLibraries(); - - // RTL initialization is complete - RTLAlive = true; } } @@ -55,13 +50,6 @@ void deinitRuntime() { if (RefCount == 1) { DP("Deinit offload library!\n"); - // RTL deinitialization has started - RTLAlive = false; - while (RTLOngoingSyncs > 0) { - DP("Waiting for ongoing syncs to finish, count: %d\n", - RTLOngoingSyncs.load()); - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - } PM->deinit(); delete PM; PM = nullptr; diff --git a/offload/libomptarget/OpenMP/API.cpp b/offload/libomptarget/OpenMP/API.cpp index b0f0573833713..4576f9bd06121 100644 --- a/offload/libomptarget/OpenMP/API.cpp +++ b/offload/libomptarget/OpenMP/API.cpp @@ -16,7 +16,6 @@ #include "rtl.h" #include "OpenMP/InternalTypes.h" -#include "OpenMP/InteropAPI.h" #include "OpenMP/Mapping.h" #include "OpenMP/OMPT/Interface.h" #include "OpenMP/omp.h" @@ -684,21 +683,3 @@ EXTERN void *omp_get_mapped_ptr(const void *Ptr, int DeviceNum) { return TPR.TargetPointer; } - -// This routine gets called from the Host RTL at sync points (taskwait, barrier, -// ...) so we can synchronize the necessary objects from the offload side. -EXTERN void __tgt_target_sync(ident_t *loc_ref, int gtid, void *current_task, - void *event) { - if (!RTLAlive) - return; - - RTLOngoingSyncs++; - if (!RTLAlive) { - RTLOngoingSyncs--; - return; - } - - syncImplicitInterops(gtid, event); - - RTLOngoingSyncs--; -} diff --git a/offload/libomptarget/OpenMP/InteropAPI.cpp b/offload/libomptarget/OpenMP/InteropAPI.cpp index eb5425ecbf062..bdbc440c64a2c 100644 --- a/offload/libomptarget/OpenMP/InteropAPI.cpp +++ b/offload/libomptarget/OpenMP/InteropAPI.cpp @@ -10,7 +10,6 @@ #include "OpenMP/InternalTypes.h" #include "OpenMP/omp.h" -#include "OffloadPolicy.h" #include "PluginManager.h" #include "device.h" #include "omptarget.h" @@ -57,22 +56,22 @@ void getTypeMismatch(omp_interop_property_t Property, int *Err) { *Err = getPropertyErrorType(Property); } -static const char *VendorStrTbl[] = { - "unknown", "amd", "arm", "bsc", "fujitsu", "gnu", "hpe", - "ibm", "intel", "llvm", "nec", "nvidia", "ti"}; -const char *getVendorIdToStr(const omp_vendor_id_t VendorId) { - if (VendorId < omp_vendor_unknown || VendorId >= omp_vendor_last) - return ("unknown"); - return VendorStrTbl[VendorId]; -} - -static const char *ForeignRuntimeStrTbl[] = { - "none", "cuda", "cuda_driver", "opencl", - "sycl", "hip", "level_zero", "hsa"}; -const char *getForeignRuntimeIdToStr(const tgt_foreign_runtime_id_t FrId) { - if (FrId < tgt_fr_none || FrId >= tgt_fr_last) - return ("unknown"); - return ForeignRuntimeStrTbl[FrId]; +const char *getVendorIdToStr(const omp_foreign_runtime_ids_t VendorId) { + switch (VendorId) { + case cuda: + return ("cuda"); + case cuda_driver: + return ("cuda_driver"); + case opencl: + return ("opencl"); + case sycl: + return ("sycl"); + case hip: + return ("hip"); + case level_zero: + return ("level_zero"); + } + return ("unknown"); } template @@ -84,7 +83,7 @@ intptr_t getProperty(omp_interop_val_t &InteropVal, omp_interop_property_t Property, int *Err) { switch (Property) { case omp_ipr_fr_id: - return InteropVal.fr_id; + return InteropVal.backend_type_id; case omp_ipr_vendor: return InteropVal.vendor_id; case omp_ipr_device_num: @@ -100,8 +99,10 @@ const char *getProperty(omp_interop_val_t &InteropVal, omp_interop_property_t Property, int *Err) { switch (Property) { - case omp_ipr_fr_name: - return getForeignRuntimeIdToStr(InteropVal.fr_id); + case omp_ipr_fr_id: + return InteropVal.interop_type == kmp_interop_type_tasksync + ? "tasksync" + : "device+context"; case omp_ipr_vendor_name: return getVendorIdToStr(InteropVal.vendor_id); default: @@ -119,8 +120,6 @@ void *getProperty(omp_interop_val_t &InteropVal, return InteropVal.device_info.Device; *Err = omp_irc_no_value; return const_cast(InteropVal.err_str); - case omp_ipr_platform: - return InteropVal.device_info.Platform; case omp_ipr_device_context: return InteropVal.device_info.Context; case omp_ipr_targetsync: @@ -146,13 +145,13 @@ bool getPropertyCheck(omp_interop_val_t **InteropPtr, return false; } if (Property == omp_ipr_targetsync && - (*InteropPtr)->interop_type != kmp_interop_type_targetsync) { + (*InteropPtr)->interop_type != kmp_interop_type_tasksync) { if (Err) *Err = omp_irc_other; return false; } if ((Property == omp_ipr_device || Property == omp_ipr_device_context) && - (*InteropPtr)->interop_type == kmp_interop_type_targetsync) { + (*InteropPtr)->interop_type == kmp_interop_type_tasksync) { if (Err) *Err = omp_irc_other; return false; @@ -167,7 +166,7 @@ bool getPropertyCheck(omp_interop_val_t **InteropPtr, omp_interop_property_t property_id, \ int *err) { \ omp_interop_val_t *interop_val = (omp_interop_val_t *)interop; \ - assert((interop_val)->interop_type == kmp_interop_type_targetsync); \ + assert((interop_val)->interop_type == kmp_interop_type_tasksync); \ if (!getPropertyCheck(&interop_val, property_id, err)) { \ return (RETURN_TYPE)(0); \ } \ @@ -194,278 +193,119 @@ __OMP_GET_INTEROP_TY3(const char *, type_desc) __OMP_GET_INTEROP_TY3(const char *, rc_desc) #undef __OMP_GET_INTEROP_TY3 -extern "C" { +static const char *copyErrorString(llvm::Error &&Err) { + // TODO: Use the error string while avoiding leaks. + std::string ErrMsg = llvm::toString(std::move(Err)); + char *UsrMsg = reinterpret_cast(malloc(ErrMsg.size() + 1)); + strcpy(UsrMsg, ErrMsg.c_str()); + return UsrMsg; +} -omp_interop_val_t *__tgt_interop_get(ident_t *LocRef, int32_t InteropType, - int64_t DeviceNum, int32_t NumPrefers, - interop_spec_t *Prefers, - interop_ctx_t *Ctx, dep_pack_t *Deps) { - - DP("Call to %s with device_num %" PRId64 ", interop type %" PRId32 - ", number of preferred specs %" PRId32 "%s%s\n", - __func__, DeviceNum, InteropType, NumPrefers, - Ctx->flags.implicit ? " (implicit)" : "", - Ctx->flags.nowait ? " (nowait)" : ""); - - if (OffloadPolicy::get(*PM).Kind == OffloadPolicy::DISABLED) - return omp_interop_none; - - // Now, try to create an interop with device_num. - if (DeviceNum == OFFLOAD_DEVICE_DEFAULT) - DeviceNum = omp_get_default_device(); - - auto gtid = Ctx->gtid; - - if (InteropType == kmp_interop_type_targetsync) { - if (Ctx->flags.nowait) - DP("Warning: nowait flag on interop creation not supported yet. " - "Ignored\n"); - if (Deps) - __kmpc_omp_wait_deps(LocRef, gtid, Deps->ndeps, Deps->deplist, - Deps->ndeps_noalias, Deps->noalias_deplist); - } +extern "C" { - auto DeviceOrErr = PM->getDevice(DeviceNum); - if (!DeviceOrErr) { - DP("Couldn't find device %" PRId64 - " while constructing interop object: %s\n", - DeviceNum, toString(DeviceOrErr.takeError()).c_str()); - return omp_interop_none; - } - auto &Device = *DeviceOrErr; - omp_interop_val_t *Interop = omp_interop_none; - auto InteropSpec = Device.RTL->select_interop_preference( - DeviceNum, InteropType, NumPrefers, Prefers); - if (InteropSpec.fr_id == tgt_fr_none) { - DP("Interop request not supported by device %" PRId64 "\n", DeviceNum); - return omp_interop_none; - } - DP("Selected interop preference is fr_id=%s%s impl_attrs=%" PRId64 "\n", - getForeignRuntimeIdToStr((tgt_foreign_runtime_id_t)InteropSpec.fr_id), - InteropSpec.attrs.inorder ? " inorder" : "", InteropSpec.impl_attrs); - - if (Ctx->flags.implicit) { - // This is a request for an RTL managed interop object. - // Get it from the InteropTbl if possible - for (auto iop : PM->InteropTbl) { - if (iop->isCompatibleWith(InteropType, InteropSpec, DeviceNum, gtid)) { - Interop = iop; - Interop->markDirty(); - DP("Reused interop " DPxMOD " from device number %" PRId64 - " for gtid %" PRId32 "\n", - DPxPTR(Interop), DeviceNum, gtid); - return Interop; - } - } +void __tgt_interop_init(ident_t *LocRef, int32_t Gtid, + omp_interop_val_t *&InteropPtr, + kmp_interop_type_t InteropType, int32_t DeviceId, + int32_t Ndeps, kmp_depend_info_t *DepList, + int32_t HaveNowait) { + int32_t NdepsNoalias = 0; + kmp_depend_info_t *NoaliasDepList = NULL; + assert(InteropType != kmp_interop_type_unknown && + "Cannot initialize with unknown interop_type!"); + if (DeviceId == -1) { + DeviceId = omp_get_default_device(); } - Interop = Device.RTL->create_interop(DeviceNum, InteropType, &InteropSpec); - DP("Created an interop " DPxMOD " from device number %" PRId64 "\n", - DPxPTR(Interop), DeviceNum); - - if (Ctx->flags.implicit) { - // register the new implicit interop in the RTL - Interop->setOwner(gtid); - Interop->markDirty(); - PM->InteropTbl.add(Interop); - } else { - Interop->setOwner(omp_interop_val_t::no_owner); + if (InteropType == kmp_interop_type_tasksync) { + __kmpc_omp_wait_deps(LocRef, Gtid, Ndeps, DepList, NdepsNoalias, + NoaliasDepList); } - return Interop; -} + InteropPtr = new omp_interop_val_t(DeviceId, InteropType); -int __tgt_interop_use(ident_t *LocRef, omp_interop_val_t *Interop, - interop_ctx_t *Ctx, dep_pack_t *Deps) { - bool Nowait = Ctx->flags.nowait; - DP("Call to %s with interop " DPxMOD ", nowait %" PRId32 "\n", __func__, - DPxPTR(Interop), Nowait); - if (OffloadPolicy::get(*PM).Kind == OffloadPolicy::DISABLED || !Interop) - return OFFLOAD_FAIL; - - if (Interop->interop_type == kmp_interop_type_targetsync) { - if (Deps) { - if (Nowait) { - DP("Warning: nowait flag on interop use with dependences not supported" - "yet. Ignored\n"); - Nowait = false; - } - - __kmpc_omp_wait_deps(LocRef, Ctx->gtid, Deps->ndeps, Deps->deplist, - Deps->ndeps_noalias, Deps->noalias_deplist); - } + auto DeviceOrErr = PM->getDevice(DeviceId); + if (!DeviceOrErr) { + InteropPtr->err_str = copyErrorString(DeviceOrErr.takeError()); + return; } - auto DeviceOrErr = Interop->getDevice(); - if (!DeviceOrErr) { - REPORT("Failed to get device for interop " DPxMOD ": %s\n", DPxPTR(Interop), - toString(DeviceOrErr.takeError()).c_str()); - return OFFLOAD_FAIL; + DeviceTy &Device = *DeviceOrErr; + if (!Device.RTL || + Device.RTL->init_device_info(DeviceId, &(InteropPtr)->device_info, + &(InteropPtr)->err_str)) { + delete InteropPtr; + InteropPtr = omp_interop_none; } - auto &IOPDevice = *DeviceOrErr; - - if (Interop->async_info && Interop->async_info->Queue) { - if (Nowait) - Interop->async_barrier(IOPDevice); - else { - Interop->flush(IOPDevice); - Interop->sync_barrier(IOPDevice); - Interop->markClean(); + if (InteropType == kmp_interop_type_tasksync) { + if (!Device.RTL || + Device.RTL->init_async_info(DeviceId, &(InteropPtr)->async_info)) { + delete InteropPtr; + InteropPtr = omp_interop_none; } } - - return OFFLOAD_SUCCESS; } -int __tgt_interop_release(ident_t *LocRef, omp_interop_val_t *Interop, - interop_ctx_t *Ctx, dep_pack_t *Deps) { - DP("Call to %s with interop " DPxMOD "\n", __func__, DPxPTR(Interop)); - - if (OffloadPolicy::get(*PM).Kind == OffloadPolicy::DISABLED || !Interop) - return OFFLOAD_FAIL; - - if (Interop->interop_type == kmp_interop_type_targetsync) { - if (Ctx->flags.nowait) - DP("Warning: nowait flag on interop destroy not supported " - "yet. Ignored\n"); - if (Deps) { - __kmpc_omp_wait_deps(LocRef, Ctx->gtid, Deps->ndeps, Deps->deplist, - Deps->ndeps_noalias, Deps->noalias_deplist); - } +void __tgt_interop_use(ident_t *LocRef, int32_t Gtid, + omp_interop_val_t *&InteropPtr, int32_t DeviceId, + int32_t Ndeps, kmp_depend_info_t *DepList, + int32_t HaveNowait) { + int32_t NdepsNoalias = 0; + kmp_depend_info_t *NoaliasDepList = NULL; + assert(InteropPtr && "Cannot use nullptr!"); + omp_interop_val_t *InteropVal = InteropPtr; + if (DeviceId == -1) { + DeviceId = omp_get_default_device(); } + assert(InteropVal != omp_interop_none && + "Cannot use uninitialized interop_ptr!"); + assert((DeviceId == -1 || InteropVal->device_id == DeviceId) && + "Inconsistent device-id usage!"); - auto DeviceOrErr = Interop->getDevice(); + auto DeviceOrErr = PM->getDevice(DeviceId); if (!DeviceOrErr) { - REPORT("Failed to get device for interop " DPxMOD ": %s\n", DPxPTR(Interop), - toString(DeviceOrErr.takeError()).c_str()); - return OFFLOAD_FAIL; + InteropPtr->err_str = copyErrorString(DeviceOrErr.takeError()); + return; } - return Interop->release(*DeviceOrErr); -} - -EXTERN int ompx_interop_add_completion_callback(omp_interop_val_t *Interop, - ompx_interop_cb_t *CB, - void *Data) { - DP("Call to %s with interop " DPxMOD ", property callback " DPxMOD - "and data " DPxMOD "\n", - __func__, DPxPTR(Interop), DPxPTR(CB), DPxPTR(Data)); - - if (OffloadPolicy::get(*PM).Kind == OffloadPolicy::DISABLED || !Interop) - return omp_irc_other; - - Interop->addCompletionCb(CB, Data); - - return omp_irc_success; -} - -} // extern "C" - -llvm::Expected omp_interop_val_t::getDevice() const { - return PM->getDevice(device_id); -} - -bool omp_interop_val_t::isCompatibleWith(int32_t InteropType, - const interop_spec_t &Spec) { - if (interop_type != InteropType) - return false; - if (Spec.fr_id != fr_id) - return false; - if (Spec.attrs.inorder != attrs.inorder) - return false; - if (Spec.impl_attrs != impl_attrs) - return false; - - return true; -} - -bool omp_interop_val_t::isCompatibleWith(int32_t InteropType, - const interop_spec_t &Spec, - int64_t DeviceNum, int GTID) { - if (device_id != DeviceNum) - return false; - - if (GTID != owner_gtid) - return false; - - return isCompatibleWith(InteropType, Spec); -} - -int32_t omp_interop_val_t::flush(DeviceTy &Device) { - return Device.RTL->flush_queue(this); -} - -int32_t omp_interop_val_t::sync_barrier(DeviceTy &Device) { - if (Device.RTL->sync_barrier(this) != OFFLOAD_SUCCESS) { - FATAL_MESSAGE(device_id, "Interop sync barrier failed for %p object\n", - this); + if (InteropVal->interop_type == kmp_interop_type_tasksync) { + __kmpc_omp_wait_deps(LocRef, Gtid, Ndeps, DepList, NdepsNoalias, + NoaliasDepList); } - DP("Calling completion callbacks for " DPxMOD "\n", DPxPTR(this)); - runCompletionCbs(); - return OFFLOAD_SUCCESS; -} - -int32_t omp_interop_val_t::async_barrier(DeviceTy &Device) { - return Device.RTL->async_barrier(this); + // TODO Flush the queue associated with the interop through the plugin } -int32_t omp_interop_val_t::release(DeviceTy &Device) { - if (async_info != nullptr && (!hasOwner() || !isClean())) { - flush(Device); - sync_barrier(Device); +void __tgt_interop_destroy(ident_t *LocRef, int32_t Gtid, + omp_interop_val_t *&InteropPtr, int32_t DeviceId, + int32_t Ndeps, kmp_depend_info_t *DepList, + int32_t HaveNowait) { + int32_t NdepsNoalias = 0; + kmp_depend_info_t *NoaliasDepList = NULL; + assert(InteropPtr && "Cannot use nullptr!"); + omp_interop_val_t *InteropVal = InteropPtr; + if (DeviceId == -1) { + DeviceId = omp_get_default_device(); } - return Device.RTL->release_interop(device_id, this); -} -void syncImplicitInterops(int Gtid, void *Event) { - if (PM->InteropTbl.size() == 0) + if (InteropVal == omp_interop_none) return; - DP("target_sync: syncing interops for gtid %" PRId32 ", event " DPxMOD "\n", - Gtid, DPxPTR(Event)); - - for (auto iop : PM->InteropTbl) { - if (iop->async_info && iop->async_info->Queue && iop->isOwnedBy(Gtid) && - !iop->isClean()) { - - auto DeviceOrErr = iop->getDevice(); - if (!DeviceOrErr) { - REPORT("Failed to get device for interop " DPxMOD ": %s\n", DPxPTR(iop), - toString(DeviceOrErr.takeError()).c_str()); - continue; - } - auto &IOPDevice = *DeviceOrErr; - - iop->flush(IOPDevice); - iop->sync_barrier(IOPDevice); - iop->markClean(); - - // Alternate implementation option in case using barriers is not - // efficient enough: - // - // Instead of using a synchronous barrier, queue an asynchronous - // barrier and create a proxy task associated to the event to handle - // OpenMP synchronizations. - // When the event is completed, fulfill the proxy task to notify the - // OpenMP runtime. - // event = iop->asyncBarrier(); - // ptask = createProxyTask(); - // Events->add(event,ptask); - } + assert((DeviceId == -1 || InteropVal->device_id == DeviceId) && + "Inconsistent device-id usage!"); + auto DeviceOrErr = PM->getDevice(DeviceId); + if (!DeviceOrErr) { + InteropPtr->err_str = copyErrorString(DeviceOrErr.takeError()); + return; } - // This would be needed for the alternate implementation - // processEvents(); -} -void InteropTblTy::clear() { - DP("Clearing Interop Table\n"); - PerThreadTable::clear([](auto &IOP) { - auto DeviceOrErr = IOP->getDevice(); - if (!DeviceOrErr) { - REPORT("Failed to get device for interop " DPxMOD ": %s\n", DPxPTR(IOP), - toString(DeviceOrErr.takeError()).c_str()); - return; - } - IOP->release(*DeviceOrErr); - }); + if (InteropVal->interop_type == kmp_interop_type_tasksync) { + __kmpc_omp_wait_deps(LocRef, Gtid, Ndeps, DepList, NdepsNoalias, + NoaliasDepList); + } + // TODO Flush the queue associated with the interop through the plugin + // TODO Signal out dependences + + delete InteropPtr; + InteropPtr = omp_interop_none; } + +} // extern "C" diff --git a/offload/libomptarget/PluginManager.cpp b/offload/libomptarget/PluginManager.cpp index c8d6b42114d0f..ddc068ec85968 100644 --- a/offload/libomptarget/PluginManager.cpp +++ b/offload/libomptarget/PluginManager.cpp @@ -128,13 +128,6 @@ void PluginManager::initializeAllDevices() { initializeDevice(Plugin, DeviceId); } } - // After all plugins are initialized, register atExit cleanup handlers - std::atexit([]() { - // Interop cleanup should be done before the plugins are deinitialized as - // the backend libraries may be already unloaded. - if (PM) - PM->InteropTbl.clear(); - }); } // Returns a pointer to the binary descriptor, upgrading from a legacy format if diff --git a/offload/libomptarget/exports b/offload/libomptarget/exports index 8e2db6ba8bba4..2406776c1fb5f 100644 --- a/offload/libomptarget/exports +++ b/offload/libomptarget/exports @@ -36,7 +36,6 @@ VERS1.0 { __kmpc_push_target_tripcount; __kmpc_push_target_tripcount_mapper; ompx_dump_mapping_tables; - ompx_interop_add_completion_callback; omp_get_mapped_ptr; omp_get_num_devices; omp_get_device_num; @@ -68,10 +67,9 @@ VERS1.0 { omp_get_interop_int; omp_get_interop_name; omp_get_interop_type_desc; - __tgt_interop_get; + __tgt_interop_init; __tgt_interop_use; - __tgt_interop_release; - __tgt_target_sync; + __tgt_interop_destroy; __llvmPushCallConfiguration; __llvmPopCallConfiguration; llvmLaunchKernel; diff --git a/offload/plugins-nextgen/common/include/PluginInterface.h b/offload/plugins-nextgen/common/include/PluginInterface.h index 5620437716b31..79c1fb5051774 100644 --- a/offload/plugins-nextgen/common/include/PluginInterface.h +++ b/offload/plugins-nextgen/common/include/PluginInterface.h @@ -21,7 +21,6 @@ #include #include "ExclusiveAccess.h" -#include "OpenMP/InteropAPI.h" #include "Shared/APITypes.h" #include "Shared/Debug.h" #include "Shared/Environment.h" @@ -62,39 +61,6 @@ struct GenericDeviceTy; struct RecordReplayTy; template class GenericDeviceResourceManagerTy; -namespace Plugin { -/// Create a success error. This is the same as calling Error::success(), but -/// it is recommended to use this one for consistency with Plugin::error() and -/// Plugin::check(). -static inline Error success() { return Error::success(); } - -/// Create an Offload error. -template -static Error error(error::ErrorCode Code, const char *ErrFmt, ArgsTy... Args) { - return error::createOffloadError(Code, ErrFmt, Args...); -} - -inline Error error(error::ErrorCode Code, const char *S) { - return make_error(Code, S); -} - -inline Error error(error::ErrorCode Code, Error &&OtherError, - const char *Context) { - return error::createOffloadError(Code, std::move(OtherError), Context); -} - -/// Check the plugin-specific error code and return an error or success -/// accordingly. In case of an error, create a string error with the error -/// description. The ErrFmt should follow the format: -/// "Error in []: %s" -/// The last format specifier "%s" is mandatory and will be used to place the -/// error code's description. Notice this function should be only called from -/// the plugin-specific code. -/// TODO: Refactor this, must be defined individually by each plugin. -template -static Error check(int32_t ErrorCode, const char *ErrFmt, ArgsTy... Args); -} // namespace Plugin - /// Class that wraps the __tgt_async_info to simply its usage. In case the /// object is constructed without a valid __tgt_async_info, the object will use /// an internal one and will synchronize the current thread with the pending @@ -1070,21 +1036,6 @@ struct GenericDeviceTy : public DeviceAllocatorTy { bool useAutoZeroCopy(); virtual bool useAutoZeroCopyImpl() { return false; } - virtual Expected - createInterop(int32_t InteropType, interop_spec_t &InteropSpec) { - return nullptr; - } - - virtual Error releaseInterop(omp_interop_val_t *Interop) { - return Plugin::success(); - } - - virtual interop_spec_t selectInteropPreference(int32_t InteropType, - int32_t NumPrefers, - interop_spec_t *Prefers) { - return interop_spec_t{tgt_fr_none, {false, 0}, 0}; - } - /// Allocate and construct a kernel object. virtual Expected constructKernel(const char *Name) = 0; @@ -1351,20 +1302,6 @@ struct GenericPluginTy { virtual Expected isELFCompatible(uint32_t DeviceID, StringRef Image) const = 0; - virtual Error flushQueueImpl(omp_interop_val_t *Interop) { - return Plugin::success(); - } - - virtual Error syncBarrierImpl(omp_interop_val_t *Interop) { - return Plugin::error(error::ErrorCode::UNSUPPORTED, - "sync_barrier not supported"); - } - - virtual Error asyncBarrierImpl(omp_interop_val_t *Interop) { - return Plugin::error(error::ErrorCode::UNSUPPORTED, - "async_barrier not supported"); - } - protected: /// Indicate whether a device id is valid. bool isValidDeviceId(int32_t DeviceId) const { @@ -1508,33 +1445,6 @@ struct GenericPluginTy { int32_t get_function(__tgt_device_binary Binary, const char *Name, void **KernelPtr); - /// Return the interop specification that the plugin supports - /// It might not be one of the user specified ones. - interop_spec_t select_interop_preference(int32_t ID, int32_t InteropType, - int32_t NumPrefers, - interop_spec_t *Prefers) { - auto &Device = getDevice(ID); - return Device.selectInteropPreference(InteropType, NumPrefers, Prefers); - } - - /// Create OpenMP interop with the given interop context - omp_interop_val_t *create_interop(int32_t ID, int32_t InteropContext, - interop_spec_t *InteropSpec); - - /// Release OpenMP interop object - int32_t release_interop(int32_t ID, omp_interop_val_t *Interop); - - /// Flush the queue associated with the interop object if necessary - int32_t flush_queue(omp_interop_val_t *Interop); - - /// Perform a host synchronization with the queue associated with the interop - /// object and wait for it to complete. - int32_t sync_barrier(omp_interop_val_t *Interop); - - /// Queue an asynchronous barrier in the queue associated with the interop - /// object and return immediately. - int32_t async_barrier(omp_interop_val_t *Interop); - private: /// Indicates if the platform runtime has been fully initialized. bool Initialized = false; @@ -1567,6 +1477,39 @@ struct GenericPluginTy { RecordReplayTy *RecordReplay; }; +namespace Plugin { +/// Create a success error. This is the same as calling Error::success(), but +/// it is recommended to use this one for consistency with Plugin::error() and +/// Plugin::check(). +static inline Error success() { return Error::success(); } + +/// Create an Offload error. +template +static Error error(error::ErrorCode Code, const char *ErrFmt, ArgsTy... Args) { + return error::createOffloadError(Code, ErrFmt, Args...); +} + +inline Error error(error::ErrorCode Code, const char *S) { + return make_error(Code, S); +} + +inline Error error(error::ErrorCode Code, Error &&OtherError, + const char *Context) { + return error::createOffloadError(Code, std::move(OtherError), Context); +} + +/// Check the plugin-specific error code and return an error or success +/// accordingly. In case of an error, create a string error with the error +/// description. The ErrFmt should follow the format: +/// "Error in []: %s" +/// The last format specifier "%s" is mandatory and will be used to place the +/// error code's description. Notice this function should be only called from +/// the plugin-specific code. +/// TODO: Refactor this, must be defined individually by each plugin. +template +static Error check(int32_t ErrorCode, const char *ErrFmt, ArgsTy... Args); +} // namespace Plugin + /// Auxiliary interface class for GenericDeviceResourceManagerTy. This class /// acts as a reference to a device resource, such as a stream, and requires /// some basic functions to be implemented. The derived class should define an diff --git a/offload/plugins-nextgen/common/src/PluginInterface.cpp b/offload/plugins-nextgen/common/src/PluginInterface.cpp index 15b6b9866e5a2..dc5ca38d1789c 100644 --- a/offload/plugins-nextgen/common/src/PluginInterface.cpp +++ b/offload/plugins-nextgen/common/src/PluginInterface.cpp @@ -2204,74 +2204,6 @@ int32_t GenericPluginTy::get_function(__tgt_device_binary Binary, return OFFLOAD_SUCCESS; } -/// Create OpenMP interop with the given interop context -omp_interop_val_t * -GenericPluginTy::create_interop(int32_t ID, int32_t InteropContext, - interop_spec_t *InteropSpec) { - assert(InteropSpec && "Interop spec is null"); - auto &Device = getDevice(ID); - auto InteropOrErr = Device.createInterop(InteropContext, *InteropSpec); - if (!InteropOrErr) { - REPORT("Failure to create interop object for device " DPxMOD ": %s\n", - DPxPTR(InteropSpec), toString(InteropOrErr.takeError()).c_str()); - return nullptr; - } - return *InteropOrErr; -} - -/// Release OpenMP interop object -int32_t GenericPluginTy::release_interop(int32_t ID, - omp_interop_val_t *Interop) { - assert(Interop && "Interop is null"); - assert(Interop->device_id == ID && "Interop does not match device id"); - auto &Device = getDevice(ID); - auto Err = Device.releaseInterop(Interop); - if (Err) { - REPORT("Failure to release interop object " DPxMOD ": %s\n", - DPxPTR(Interop), toString(std::move(Err)).c_str()); - return OFFLOAD_FAIL; - } - return OFFLOAD_SUCCESS; -} - -/// Flush the queue associated with the interop object if necessary -int32_t GenericPluginTy::flush_queue(omp_interop_val_t *Interop) { - assert(Interop && "Interop is null"); - auto Err = flushQueueImpl(Interop); - if (Err) { - REPORT("Failure to flush interop object " DPxMOD " queue: %s\n", - DPxPTR(Interop), toString(std::move(Err)).c_str()); - return OFFLOAD_FAIL; - } - return OFFLOAD_SUCCESS; -} - -/// Perform a host synchronization with the queue associated with the interop -/// object and wait for it to complete. -int32_t GenericPluginTy::sync_barrier(omp_interop_val_t *Interop) { - assert(Interop && "Interop is null"); - auto Err = syncBarrierImpl(Interop); - if (Err) { - REPORT("Failure to synchronize interop object " DPxMOD ": %s\n", - DPxPTR(Interop), toString(std::move(Err)).c_str()); - return OFFLOAD_FAIL; - } - return OFFLOAD_SUCCESS; -} - -/// Queue an asynchronous barrier in the queue associated with the interop -/// object and return immediately. -int32_t GenericPluginTy::async_barrier(omp_interop_val_t *Interop) { - assert(Interop && "Interop is null"); - auto Err = asyncBarrierImpl(Interop); - if (Err) { - REPORT("Failure to queue barrier in interop object " DPxMOD ": %s\n", - DPxPTR(Interop), toString(std::move(Err)).c_str()); - return OFFLOAD_FAIL; - } - return OFFLOAD_SUCCESS; -} - int32_t GenericPluginTy::data_fence(int32_t DeviceId, __tgt_async_info *AsyncInfo) { auto Err = getDevice(DeviceId).dataFence(AsyncInfo); diff --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h index 83afc0e83f231..818edf9060ad1 100644 --- a/openmp/runtime/src/kmp.h +++ b/openmp/runtime/src/kmp.h @@ -4621,13 +4621,6 @@ static inline int __kmp_adjust_gtid_for_hidden_helpers(int gtid) { return adjusted_gtid; } -#if ENABLE_LIBOMPTARGET -// Pointers to callbacks registered by the offload library to be notified of -// task progress. -extern void (*kmp_target_sync_cb)(ident_t *loc_ref, int gtid, - void *current_task, void *event); -#endif // ENABLE_LIBOMPTARGET - // Support for error directive typedef enum kmp_severity_t { severity_warning = 1, diff --git a/openmp/runtime/src/kmp_barrier.cpp b/openmp/runtime/src/kmp_barrier.cpp index 4d7989d1ce5eb..88a5cbb69ba87 100644 --- a/openmp/runtime/src/kmp_barrier.cpp +++ b/openmp/runtime/src/kmp_barrier.cpp @@ -1853,14 +1853,6 @@ static int __kmp_barrier_template(enum barrier_type bt, int gtid, int is_split, } #endif -#if ENABLE_LIBOMPTARGET - // Give an opportunity to the offload runtime to make progress and create - // proxy tasks if necessary - if (UNLIKELY(kmp_target_sync_cb != NULL)) - (*kmp_target_sync_cb)( - NULL, gtid, KMP_TASKDATA_TO_TASK(this_thr->th.th_current_task), NULL); -#endif - if (!team->t.t_serialized) { #if USE_ITT_BUILD // This value will be used in itt notify events below. diff --git a/openmp/runtime/src/kmp_runtime.cpp b/openmp/runtime/src/kmp_runtime.cpp index 48e29c9f9fe45..39b7834d358af 100644 --- a/openmp/runtime/src/kmp_runtime.cpp +++ b/openmp/runtime/src/kmp_runtime.cpp @@ -93,9 +93,6 @@ static void __kmp_partition_places(kmp_team_t *team, int update_master_only = 0); #endif static void __kmp_do_serial_initialize(void); -#if ENABLE_LIBOMPTARGET -static void __kmp_target_init(void); -#endif // ENABLE_LIBOMPTARGET void __kmp_fork_barrier(int gtid, int tid); void __kmp_join_barrier(int gtid); void __kmp_setup_icv_copy(kmp_team_t *team, int new_nproc, @@ -7132,9 +7129,6 @@ static void __kmp_do_serial_initialize(void) { #if KMP_MIC_SUPPORTED __kmp_check_mic_type(); #endif -#if ENABLE_LIBOMPTARGET - __kmp_target_init(); -#endif /* ENABLE_LIBOMPTARGET */ // Some global variable initialization moved here from kmp_env_initialize() #ifdef KMP_DEBUG @@ -9361,15 +9355,6 @@ void __kmp_set_nesting_mode_threads() { set__max_active_levels(thread, __kmp_nesting_mode_nlevels); } -#if ENABLE_LIBOMPTARGET -void (*kmp_target_sync_cb)(ident_t *loc_ref, int gtid, void *current_task, - void *event) = NULL; -void __kmp_target_init() { - // Look for hooks in the libomptarget library - *(void **)(&kmp_target_sync_cb) = KMP_DLSYM("__tgt_target_sync"); -} -#endif // ENABLE_LIBOMPTARGET - // Empty symbols to export (see exports_so.txt) when feature is disabled extern "C" { #if !KMP_STATS_ENABLED diff --git a/openmp/runtime/src/kmp_tasking.cpp b/openmp/runtime/src/kmp_tasking.cpp index 37836fb457537..e4d92a78fd6b9 100644 --- a/openmp/runtime/src/kmp_tasking.cpp +++ b/openmp/runtime/src/kmp_tasking.cpp @@ -1149,13 +1149,6 @@ void __kmp_init_implicit_task(ident_t *loc_ref, kmp_info_t *this_thr, // thread: thread data structure corresponding to implicit task void __kmp_finish_implicit_task(kmp_info_t *thread) { kmp_taskdata_t *task = thread->th.th_current_task; -#if ENABLE_LIBOMPTARGET - // Give an opportunity to the offload runtime to synchronize any unfinished - // target async regions before finishing the implicit task - if (UNLIKELY(kmp_target_sync_cb != NULL)) - (*kmp_target_sync_cb)(NULL, thread->th.th_info.ds.ds_gtid, - KMP_TASKDATA_TO_TASK(task), NULL); -#endif // ENABLE_LIBOMPTARGET if (task->td_dephash) { int children; task->td_flags.complete = 1; @@ -2027,14 +2020,6 @@ static kmp_int32 __kmpc_omp_taskwait_template(ident_t *loc_ref, kmp_int32 gtid, } #endif // OMPT_SUPPORT && OMPT_OPTIONAL -#if ENABLE_LIBOMPTARGET - // Give an opportunity to the offload runtime to make progress and create - // any necessary proxy tasks - if (UNLIKELY(kmp_target_sync_cb)) - (*kmp_target_sync_cb)(loc_ref, gtid, KMP_TASKDATA_TO_TASK(taskdata), - NULL); -#endif // ENABLE_LIBOMPTARGET - // Debugger: The taskwait is active. Store location and thread encountered the // taskwait. #if USE_ITT_BUILD @@ -2734,13 +2719,6 @@ void __kmpc_end_taskgroup(ident_t *loc, int gtid) { } #endif -#if ENABLE_LIBOMPTARGET - // Give an opportunity to the offload runtime to make progress and create - // any necessary proxy tasks - if (UNLIKELY(kmp_target_sync_cb)) - (*kmp_target_sync_cb)(loc, gtid, KMP_TASKDATA_TO_TASK(taskdata), NULL); -#endif // ENABLE_LIBOMPTARGET - if (!taskdata->td_flags.team_serial || (thread->th.th_task_team != NULL && (thread->th.th_task_team->tt.tt_found_proxy_tasks || @@ -3184,13 +3162,6 @@ static inline int __kmp_execute_tasks_template( while (1) { // Outer loop keeps trying to find tasks in case of single thread // getting tasks from target constructs while (1) { // Inner loop to find a task and execute it -#if ENABLE_LIBOMPTARGET - // Give an opportunity to the offload runtime to make progress - if (UNLIKELY(kmp_target_sync_cb)) - (*kmp_target_sync_cb)(NULL, gtid, KMP_TASKDATA_TO_TASK(current_task), - NULL); -#endif // ENABLE_LIBOMPTARGET - task = NULL; if (task_team->tt.tt_num_task_pri) { // get priority task first task = __kmp_get_priority_task(gtid, task_team, is_constrained);