Skip to content

Commit

Permalink
[openmp] restore some lost content : gobal_allocate and ompt
Browse files Browse the repository at this point in the history
Change-Id: I647e0b6e7a314999981707081ce26e963be35b2d
  • Loading branch information
ronlieb committed Dec 3, 2023
1 parent f865d68 commit a7fc64b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions openmp/libomptarget/src/PluginManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
//
//===----------------------------------------------------------------------===//

#include "OmptTracing.h"
#include "OpenMP/OMPT/Callback.h"
#include "PluginManager.h"

using namespace llvm;
Expand Down Expand Up @@ -231,6 +233,11 @@ int target(ident_t *Loc, DeviceTy &Device, void *HostPtr,
void PluginManager::unregisterLib(__tgt_bin_desc *Desc) {
DP("Unloading target library!\n");

// Flush in-process OMPT trace records and shut down helper threads
// before unloading the library.
OMPT_TRACING_IF_ENABLED(
llvm::omp::target::ompt::TraceRecordManager.shutdownHelperThreads(););

PM->RTLsMtx.lock();
// Find which RTL understands each image, if any.
for (DeviceImageTy &DI : PM->deviceImages()) {
Expand Down
11 changes: 11 additions & 0 deletions openmp/libomptarget/src/rtl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "llvm/OffloadArch/OffloadArch.h"

#include "DeviceImage.h"
#include "OmptTracing.h"
#include "OpenMP/OMPT/Callback.h"
#include "PluginManager.h"
#include "device.h"
Expand All @@ -37,6 +38,7 @@ using namespace llvm::omp::target;

#ifdef OMPT_SUPPORT
extern void ompt::connectLibrary();
extern OmptTracingBufferMgr llvm::omp::target::ompt::TraceRecordManager;
#endif

__attribute__((constructor(101))) void init() {
Expand All @@ -57,5 +59,14 @@ __attribute__((constructor(101))) void init() {

__attribute__((destructor(101))) void deinit() {
DP("Deinit target library!\n");

delete PM;
}

// HACK: These depricated device stubs still needs host versions for fallback
// FIXME: Deprecate upstream, change test cases to use malloc & free directly
extern "C" char *global_allocate(uint32_t sz) { return (char *)malloc(sz); }
extern "C" int global_free(void *ptr) {
free(ptr);
return 0;
}

0 comments on commit a7fc64b

Please sign in to comment.