10
10
//
11
11
// ===----------------------------------------------------------------------===//
12
12
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
21
14
22
15
#include < cstdlib>
23
16
#include < cstring>
@@ -34,15 +27,15 @@ void ompt_libomptarget_connect() {}
34
27
#undef DEBUG_PREFIX
35
28
#define DEBUG_PREFIX " OMPT"
36
29
37
- using namespace llvm ::omp::target::ompt;
38
-
39
30
// Define OMPT callback functions (bound to actual callbacks later on)
40
31
#define defineOmptCallback (Name, Type, Code ) \
41
32
Name##_t llvm::omp::target::ompt::Name##_fn = nullptr ;
42
33
FOREACH_OMPT_NOEMI_EVENT (defineOmptCallback)
43
34
FOREACH_OMPT_EMI_EVENT(defineOmptCallback)
44
35
#undef defineOmptCallback
45
36
37
+ using namespace llvm ::omp::target::ompt;
38
+
46
39
// / Forward declaration
47
40
class LibomptargetRtlFinalizer ;
48
41
@@ -226,26 +219,26 @@ void Interface::endTargetDataRetrieve(int64_t SrcDeviceId, void *SrcPtrBegin,
226
219
endTargetDataOperation ();
227
220
}
228
221
229
- void Interface::beginTargetSubmit (unsigned int numTeams ) {
222
+ void Interface::beginTargetSubmit (unsigned int NumTeams ) {
230
223
if (ompt_callback_target_submit_emi_fn) {
231
224
// HostOpId is set by the tool. Invoke the tool supplied target submit EMI
232
225
// callback
233
226
ompt_callback_target_submit_emi_fn (ompt_scope_begin, &TargetData, &HostOpId,
234
- numTeams );
227
+ NumTeams );
235
228
} else if (ompt_callback_target_submit_fn) {
236
229
// HostOpId is set by the runtime
237
230
HostOpId = createOpId ();
238
- ompt_callback_target_submit_fn (TargetData.value , HostOpId, numTeams );
231
+ ompt_callback_target_submit_fn (TargetData.value , HostOpId, NumTeams );
239
232
}
240
233
}
241
234
242
- void Interface::endTargetSubmit (unsigned int numTeams ) {
235
+ void Interface::endTargetSubmit (unsigned int NumTeams ) {
243
236
// Only EMI callback handles end scope
244
237
if (ompt_callback_target_submit_emi_fn) {
245
238
// HostOpId is set by the tool. Invoke the tool supplied target submit EMI
246
239
// callback
247
240
ompt_callback_target_submit_emi_fn (ompt_scope_end, &TargetData, &HostOpId,
248
- numTeams );
241
+ NumTeams );
249
242
}
250
243
}
251
244
@@ -458,7 +451,7 @@ class LibomptargetRtlFinalizer {
458
451
459
452
void finalize () {
460
453
for (auto FinalizationFunction : RtlFinalizationFunctions)
461
- FinalizationFunction (/* tool_data */ nullptr );
454
+ FinalizationFunction (/* tool_data= */ nullptr );
462
455
RtlFinalizationFunctions.clear ();
463
456
}
464
457
@@ -469,10 +462,11 @@ class LibomptargetRtlFinalizer {
469
462
int llvm::omp::target::ompt::initializeLibrary (ompt_function_lookup_t lookup,
470
463
int initial_device_num,
471
464
ompt_data_t *tool_data) {
472
- DP (" Executing initializeLibrary (libomp) \n " );
465
+ DP (" Executing initializeLibrary\n " );
473
466
#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, \
476
470
((void *)(uint64_t )DestinationFunction));
477
471
478
472
bindOmptFunctionName (ompt_get_callback, lookupCallbackByCode);
@@ -499,7 +493,7 @@ int llvm::omp::target::ompt::initializeLibrary(ompt_function_lookup_t lookup,
499
493
}
500
494
501
495
void llvm::omp::target::ompt::finalizeLibrary (ompt_data_t *data) {
502
- DP (" Executing finalizeLibrary (libomp) \n " );
496
+ DP (" Executing finalizeLibrary\n " );
503
497
// Before disabling OMPT, call the (plugin) finalizations that were registered
504
498
// with this library
505
499
LibraryFinalizer->finalize ();
@@ -508,7 +502,7 @@ void llvm::omp::target::ompt::finalizeLibrary(ompt_data_t *data) {
508
502
}
509
503
510
504
void llvm::omp::target::ompt::connectLibrary () {
511
- DP (" Entering connectLibrary (libomp) \n " );
505
+ DP (" Entering connectLibrary\n " );
512
506
// Connect with libomp
513
507
static OmptLibraryConnectorTy LibompConnector (" libomp" );
514
508
static ompt_start_tool_result_t OmptResult;
@@ -531,23 +525,7 @@ void llvm::omp::target::ompt::connectLibrary() {
531
525
FOREACH_OMPT_EMI_EVENT (bindOmptCallback)
532
526
#undef bindOmptCallback
533
527
534
- DP (" Exiting connectLibrary (libomp) \n " );
528
+ DP (" Exiting connectLibrary\n " );
535
529
}
536
530
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
- }
553
531
#endif // OMPT_SUPPORT
0 commit comments