Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
openmp/libomptarget/src/interface.cpp
Show All 12 Lines | ||||||||||||
#include "device.h" | #include "device.h" | |||||||||||
#include "omptarget.h" | #include "omptarget.h" | |||||||||||
#include "private.h" | #include "private.h" | |||||||||||
#include "rtl.h" | #include "rtl.h" | |||||||||||
#include "Utilities.h" | #include "Utilities.h" | |||||||||||
#include <cassert> | #include <cassert> | |||||||||||
jdoerfert: Not needed? | ||||||||||||
#include <cstdio> | #include <cstdio> | |||||||||||
#include <cstdlib> | #include <cstdlib> | |||||||||||
#include <mutex> | #include <mutex> | |||||||||||
#include <type_traits> | #include <type_traits> | |||||||||||
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// | |||||||||||
/// adds requires flags | /// adds requires flags | |||||||||||
EXTERN void __tgt_register_requires(int64_t Flags) { | EXTERN void __tgt_register_requires(int64_t Flags) { | |||||||||||
TIMESCOPE(); | TIMESCOPE(); | |||||||||||
PM->RTLs.registerRequires(Flags); | PM->RTLs.registerRequires(Flags); | |||||||||||
} | } | |||||||||||
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// | |||||||||||
/// adds a target shared library to the target execution image | /// adds a target shared library to the target execution image | |||||||||||
EXTERN void __tgt_register_lib(__tgt_bin_desc *Desc) { | EXTERN void __tgt_register_lib(__tgt_bin_desc *Desc) { | |||||||||||
TIMESCOPE(); | TIMESCOPE(); | |||||||||||
if(PM->RTLs.delayRegistration(Desc)) | ||||||||||||
return; | ||||||||||||
std::call_once(PM->RTLs.InitFlag, &RTLsTy::loadRTLs, &PM->RTLs); | std::call_once(PM->RTLs.InitFlag, &RTLsTy::loadRTLs, &PM->RTLs); | |||||||||||
for (auto &RTL : PM->RTLs.AllRTLs) { | PM->RTLs.registerToAllRTLs(Desc); | |||||||||||
if (RTL.register_lib) { | ||||||||||||
if ((*RTL.register_lib)(Desc) != OFFLOAD_SUCCESS) { | ||||||||||||
DP("Could not register library with %s", RTL.RTLName.c_str()); | ||||||||||||
} | ||||||||||||
} | ||||||||||||
} | ||||||||||||
PM->RTLs.registerLib(Desc); | PM->RTLs.registerLib(Desc); | |||||||||||
} | } | |||||||||||
jdoerfert: | ||||||||||||
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// | |||||||||||
/// Initialize all available devices without registering any image | /// Initialize all available devices without registering any image | |||||||||||
EXTERN void __tgt_init_all_rtls() { PM->RTLs.initAllRTLs(); } | EXTERN void __tgt_init_all_rtls() { PM->RTLs.initAllRTLs(); } | |||||||||||
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// | |||||||||||
/// unloads a target shared library | /// unloads a target shared library | |||||||||||
EXTERN void __tgt_unregister_lib(__tgt_bin_desc *Desc) { | EXTERN void __tgt_unregister_lib(__tgt_bin_desc *Desc) { | |||||||||||
TIMESCOPE(); | TIMESCOPE(); | |||||||||||
if(PM->RTLs.cancelDelayedRegistration(Desc)) | ||||||||||||
return; | ||||||||||||
PM->RTLs.unregisterLib(Desc); | PM->RTLs.unregisterLib(Desc); | |||||||||||
for (auto &RTL : PM->RTLs.UsedRTLs) { | for (auto &RTL : PM->RTLs.UsedRTLs) { | |||||||||||
if (RTL->unregister_lib) { | if (RTL->unregister_lib) { | |||||||||||
if ((*RTL->unregister_lib)(Desc) != OFFLOAD_SUCCESS) { | if ((*RTL->unregister_lib)(Desc) != OFFLOAD_SUCCESS) { | |||||||||||
DP("Could not register library with %s", RTL->RTLName.c_str()); | DP("Could not register library with %s", RTL->RTLName.c_str()); | |||||||||||
} | } | |||||||||||
} | } | |||||||||||
} | } | |||||||||||
▲ Show 20 Lines • Show All 332 Lines • Show Last 20 Lines |
Not needed?