diff options
Diffstat (limited to 'openmp/libomptarget/src/device.cpp')
-rw-r--r-- | openmp/libomptarget/src/device.cpp | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/openmp/libomptarget/src/device.cpp b/openmp/libomptarget/src/device.cpp index feb5d64..d3481d4 100644 --- a/openmp/libomptarget/src/device.cpp +++ b/openmp/libomptarget/src/device.cpp @@ -11,9 +11,12 @@ //===----------------------------------------------------------------------===// #include "device.h" +#include "OffloadEntry.h" #include "OpenMP/OMPT/Callback.h" #include "OpenMP/OMPT/Interface.h" #include "PluginManager.h" +#include "Shared/APITypes.h" +#include "Shared/Debug.h" #include "omptarget.h" #include "private.h" #include "rtl.h" @@ -61,7 +64,7 @@ int HostDataToTargetTy::addEventIfNecessary(DeviceTy &Device, DeviceTy::DeviceTy(PluginAdaptorTy *RTL) : DeviceID(-1), RTL(RTL), RTLDeviceID(-1), IsInit(false), InitFlag(), - HasPendingGlobals(false), PendingCtorsDtors(), PendingGlobalsMtx() {} + PendingCtorsDtors(), PendingGlobalsMtx() {} DeviceTy::~DeviceTy() { if (DeviceID == -1 || !(getInfoLevel() & OMP_INFOTYPE_DUMP_TABLE)) @@ -807,3 +810,52 @@ bool deviceIsReady(int DeviceNum) { return true; } + +void DeviceTy::addOffloadEntry(OffloadEntryTy &Entry) { + std::lock_guard<decltype(PendingGlobalsMtx)> Lock(PendingGlobalsMtx); + DeviceOffloadEntries[Entry.getName()] = &Entry; + if (Entry.isGlobal()) + return; + + if (Entry.isCTor()) { + DP("Adding ctor " DPxMOD " to the pending list.\n", + DPxPTR(Entry.getAddress())); + MESSAGE("WARNING: Calling deprecated constructor for entry %s will be " + "removed in a future release \n", + Entry.getNameAsCStr()); + PendingCtorsDtors[Entry.getBinaryDescription()].PendingCtors.push_back( + Entry.getAddress()); + } else if (Entry.isDTor()) { + // Dtors are pushed in reverse order so they are executed from end + // to beginning when unregistering the library! + DP("Adding dtor " DPxMOD " to the pending list.\n", + DPxPTR(Entry.getAddress())); + MESSAGE("WARNING: Calling deprecated destructor for entry %s will be " + "removed in a future release \n", + Entry.getNameAsCStr()); + PendingCtorsDtors[Entry.getBinaryDescription()].PendingDtors.push_front( + Entry.getAddress()); + } + + if (Entry.isLink()) { + MESSAGE( + "WARNING: The \"link\" attribute is not yet supported for entry: %s!\n", + Entry.getNameAsCStr()); + } +} + +void DeviceTy::dumpOffloadEntries() { + fprintf(stderr, "Device %i offload entries:\n", DeviceID); + for (auto &It : DeviceOffloadEntries) { + const char *Kind = "kernel"; + if (It.second->isCTor()) + Kind = "constructor"; + else if (It.second->isDTor()) + Kind = "destructor"; + else if (It.second->isLink()) + Kind = "link"; + else if (It.second->isGlobal()) + Kind = "global var."; + fprintf(stderr, " %11s: %s\n", Kind, It.second->getNameAsCStr()); + } +} |