Skip to content

Commit d36f66b

Browse files
authored
[NFC][offload][OMPT] Cleanup of OMPT internals (llvm#109005)
Removed `OmptCallbacks.cpp` since relevant contents were duplicated. Because of the static linking there should be no change in functionality.
1 parent bad5444 commit d36f66b

File tree

6 files changed

+25
-129
lines changed

6 files changed

+25
-129
lines changed

offload/include/OpenMP/OMPT/Callback.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
//
1212
//===----------------------------------------------------------------------===//
1313

14-
#ifndef OMPTARGET_OPENMP_OMPT_CALLBACK_H
15-
#define OMPTARGET_OPENMP_OMPT_CALLBACK_H
14+
#ifndef OFFLOAD_INCLUDE_OPENMP_OMPT_CALLBACK_H
15+
#define OFFLOAD_INCLUDE_OPENMP_OMPT_CALLBACK_H
1616

1717
#ifdef OMPT_SUPPORT
1818

@@ -102,4 +102,4 @@ extern bool Initialized;
102102
#define performIfOmptInitialized(stmt)
103103
#endif // OMPT_SUPPORT
104104

105-
#endif // OMPTARGET_OPENMP_OMPT_CALLBACK_H
105+
#endif // OFFLOAD_INCLUDE_OPENMP_OMPT_CALLBACK_H

offload/include/OpenMP/OMPT/Interface.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#ifndef _OMPTARGET_OMPTINTERFACE_H
14-
#define _OMPTARGET_OMPTINTERFACE_H
13+
#ifndef OFFLOAD_INCLUDE_OPENMP_OMPT_INTERFACE_H
14+
#define OFFLOAD_INCLUDE_OPENMP_OMPT_INTERFACE_H
1515

1616
// Only provide functionality if target OMPT support is enabled
1717
#ifdef OMPT_SUPPORT
18-
#include <functional>
19-
#include <tuple>
20-
2118
#include "Callback.h"
2219
#include "omp-tools.h"
2320

2421
#include "llvm/Support/ErrorHandling.h"
2522

23+
#include <functional>
24+
#include <tuple>
25+
2626
#define OMPT_IF_BUILT(stmt) stmt
2727

2828
/// Callbacks for target regions require task_data representing the
@@ -326,4 +326,4 @@ class ReturnAddressSetterRAII {
326326
#define OMPT_IF_BUILT(stmt)
327327
#endif
328328

329-
#endif // _OMPTARGET_OMPTINTERFACE_H
329+
#endif // OFFLOAD_INCLUDE_OPENMP_OMPT_INTERFACE_H

offload/plugins-nextgen/common/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ elseif(${LIBOMPTARGET_GPU_LIBC_SUPPORT})
3838
endif()
3939
endif()
4040

41-
# If we have OMPT enabled include it in the list of sources.
42-
if (OMPT_TARGET_DEFAULT AND LIBOMPTARGET_OMPT_SUPPORT)
43-
target_sources(PluginCommon PRIVATE OMPT/OmptCallback.cpp)
44-
target_include_directories(PluginCommon PRIVATE OMPT)
45-
endif()
46-
4741
# Define the TARGET_NAME and DEBUG_PREFIX.
4842
target_compile_definitions(PluginCommon PRIVATE
4943
TARGET_NAME="PluginInterface"

offload/plugins-nextgen/common/OMPT/OmptCallback.cpp

Lines changed: 0 additions & 75 deletions
This file was deleted.

offload/src/OpenMP/OMPT/Callback.cpp

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#ifndef OMPT_SUPPORT
14-
15-
extern "C" {
16-
/// Dummy definition when OMPT is disabled
17-
void ompt_libomptarget_connect() {}
18-
}
19-
20-
#else // OMPT_SUPPORT is set
13+
#ifdef OMPT_SUPPORT
2114

2215
#include <cstdlib>
2316
#include <cstring>
@@ -34,15 +27,15 @@ void ompt_libomptarget_connect() {}
3427
#undef DEBUG_PREFIX
3528
#define DEBUG_PREFIX "OMPT"
3629

37-
using namespace llvm::omp::target::ompt;
38-
3930
// Define OMPT callback functions (bound to actual callbacks later on)
4031
#define defineOmptCallback(Name, Type, Code) \
4132
Name##_t llvm::omp::target::ompt::Name##_fn = nullptr;
4233
FOREACH_OMPT_NOEMI_EVENT(defineOmptCallback)
4334
FOREACH_OMPT_EMI_EVENT(defineOmptCallback)
4435
#undef defineOmptCallback
4536

37+
using namespace llvm::omp::target::ompt;
38+
4639
/// Forward declaration
4740
class LibomptargetRtlFinalizer;
4841

@@ -226,26 +219,26 @@ void Interface::endTargetDataRetrieve(int64_t SrcDeviceId, void *SrcPtrBegin,
226219
endTargetDataOperation();
227220
}
228221

229-
void Interface::beginTargetSubmit(unsigned int numTeams) {
222+
void Interface::beginTargetSubmit(unsigned int NumTeams) {
230223
if (ompt_callback_target_submit_emi_fn) {
231224
// HostOpId is set by the tool. Invoke the tool supplied target submit EMI
232225
// callback
233226
ompt_callback_target_submit_emi_fn(ompt_scope_begin, &TargetData, &HostOpId,
234-
numTeams);
227+
NumTeams);
235228
} else if (ompt_callback_target_submit_fn) {
236229
// HostOpId is set by the runtime
237230
HostOpId = createOpId();
238-
ompt_callback_target_submit_fn(TargetData.value, HostOpId, numTeams);
231+
ompt_callback_target_submit_fn(TargetData.value, HostOpId, NumTeams);
239232
}
240233
}
241234

242-
void Interface::endTargetSubmit(unsigned int numTeams) {
235+
void Interface::endTargetSubmit(unsigned int NumTeams) {
243236
// Only EMI callback handles end scope
244237
if (ompt_callback_target_submit_emi_fn) {
245238
// HostOpId is set by the tool. Invoke the tool supplied target submit EMI
246239
// callback
247240
ompt_callback_target_submit_emi_fn(ompt_scope_end, &TargetData, &HostOpId,
248-
numTeams);
241+
NumTeams);
249242
}
250243
}
251244

@@ -458,7 +451,7 @@ class LibomptargetRtlFinalizer {
458451

459452
void finalize() {
460453
for (auto FinalizationFunction : RtlFinalizationFunctions)
461-
FinalizationFunction(/* tool_data */ nullptr);
454+
FinalizationFunction(/*tool_data=*/nullptr);
462455
RtlFinalizationFunctions.clear();
463456
}
464457

@@ -469,10 +462,11 @@ class LibomptargetRtlFinalizer {
469462
int llvm::omp::target::ompt::initializeLibrary(ompt_function_lookup_t lookup,
470463
int initial_device_num,
471464
ompt_data_t *tool_data) {
472-
DP("Executing initializeLibrary (libomp)\n");
465+
DP("Executing initializeLibrary\n");
473466
#define bindOmptFunctionName(OmptFunction, DestinationFunction) \
474-
DestinationFunction = (OmptFunction##_t)lookup(#OmptFunction); \
475-
DP("initializeLibrary (libomp) bound %s=%p\n", #DestinationFunction, \
467+
if (lookup) \
468+
DestinationFunction = (OmptFunction##_t)lookup(#OmptFunction); \
469+
DP("initializeLibrary bound %s=%p\n", #DestinationFunction, \
476470
((void *)(uint64_t)DestinationFunction));
477471

478472
bindOmptFunctionName(ompt_get_callback, lookupCallbackByCode);
@@ -499,7 +493,7 @@ int llvm::omp::target::ompt::initializeLibrary(ompt_function_lookup_t lookup,
499493
}
500494

501495
void llvm::omp::target::ompt::finalizeLibrary(ompt_data_t *data) {
502-
DP("Executing finalizeLibrary (libomp)\n");
496+
DP("Executing finalizeLibrary\n");
503497
// Before disabling OMPT, call the (plugin) finalizations that were registered
504498
// with this library
505499
LibraryFinalizer->finalize();
@@ -508,7 +502,7 @@ void llvm::omp::target::ompt::finalizeLibrary(ompt_data_t *data) {
508502
}
509503

510504
void llvm::omp::target::ompt::connectLibrary() {
511-
DP("Entering connectLibrary (libomp)\n");
505+
DP("Entering connectLibrary\n");
512506
// Connect with libomp
513507
static OmptLibraryConnectorTy LibompConnector("libomp");
514508
static ompt_start_tool_result_t OmptResult;
@@ -531,23 +525,7 @@ void llvm::omp::target::ompt::connectLibrary() {
531525
FOREACH_OMPT_EMI_EVENT(bindOmptCallback)
532526
#undef bindOmptCallback
533527

534-
DP("Exiting connectLibrary (libomp)\n");
528+
DP("Exiting connectLibrary\n");
535529
}
536530

537-
extern "C" {
538-
/// Used for connecting libomptarget with a plugin
539-
void ompt_libomptarget_connect(ompt_start_tool_result_t *result) {
540-
DP("Enter ompt_libomptarget_connect\n");
541-
if (Initialized && result && LibraryFinalizer) {
542-
// Cache each fini function, so that they can be invoked on exit
543-
LibraryFinalizer->registerRtl(result->finalize);
544-
// Invoke the provided init function with the lookup function maintained
545-
// in this library so that callbacks maintained by this library are
546-
// retrieved.
547-
result->initialize(lookupCallbackByName,
548-
/* initial_device_num */ 0, /* tool_data */ nullptr);
549-
}
550-
DP("Leave ompt_libomptarget_connect\n");
551-
}
552-
}
553531
#endif // OMPT_SUPPORT

offload/src/exports

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ VERS1.0 {
7070
__tgt_interop_init;
7171
__tgt_interop_use;
7272
__tgt_interop_destroy;
73-
ompt_libomptarget_connect;
7473
__llvmPushCallConfiguration;
7574
__llvmPopCallConfiguration;
7675
llvmLaunchKernel;

0 commit comments

Comments
 (0)