-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OpenMP] [OMPT] [amdgpu] [5/8] Implemented device init/fini/load call…
…backs Added support in the generic plugin to invoke registered callbacks. Depends on D124070 Patch from John Mellor-Crummey <johnmc@rice.edu> (With contributions from Dhruva Chakrabarti <Dhruva.Chakrabarti@amd.com>) Differential Revision: https://reviews.llvm.org/D124652
- Loading branch information
Showing
20 changed files
with
319 additions
and
272 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
//===---- OmptCallback.h - Target independent OMPT callbacks --*- C++ -*---===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Interface used by target-independent runtimes to coordinate registration and | ||
// invocation of OMPT callbacks and initialization / finalization. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _OMPTCALLBACK_H | ||
#define _OMPTCALLBACK_H | ||
|
||
#ifdef OMPT_SUPPORT | ||
|
||
#include "omp-tools.h" | ||
|
||
#define DEBUG_PREFIX "OMPT" | ||
|
||
#define FOREACH_OMPT_TARGET_CALLBACK(macro) \ | ||
FOREACH_OMPT_DEVICE_EVENT(macro) \ | ||
FOREACH_OMPT_NOEMI_EVENT(macro) \ | ||
FOREACH_OMPT_EMI_EVENT(macro) | ||
|
||
#define performOmptCallback(CallbackName, ...) \ | ||
do { \ | ||
if (ompt_callback_##CallbackName##_fn) \ | ||
ompt_callback_##CallbackName##_fn(__VA_ARGS__); \ | ||
} while (0) | ||
|
||
namespace llvm { | ||
namespace omp { | ||
namespace target { | ||
namespace ompt { | ||
|
||
#define declareOmptCallback(Name, Type, Code) extern Name##_t Name##_fn; | ||
FOREACH_OMPT_NOEMI_EVENT(declareOmptCallback) | ||
FOREACH_OMPT_EMI_EVENT(declareOmptCallback) | ||
#undef declareOmptCallback | ||
|
||
/// This function will call an OpenMP API function. Which in turn will lookup a | ||
/// given enum value of type \p ompt_callbacks_t and copy the address of the | ||
/// corresponding callback funtion into the provided pointer. | ||
/// The pointer to the runtime function is passed during 'initializeLibrary'. | ||
/// \p which the enum value of the requested callback function | ||
/// \p callback the destination pointer where the address shall be copied | ||
extern ompt_get_callback_t lookupCallbackByCode; | ||
|
||
/// Lookup function to be used by the lower layer (e.g. the plugin). This | ||
/// function has to be provided when actually calling callback functions like | ||
/// 'ompt_callback_device_initialize_fn' (param: 'lookup'). | ||
/// The pointer to the runtime function is passed during 'initializeLibrary'. | ||
/// \p InterfaceFunctionName the name of the OMPT callback function to look up | ||
extern ompt_function_lookup_t lookupCallbackByName; | ||
|
||
/// This is the function called by the higher layer (libomp / libomtarget) | ||
/// responsible for initializing OMPT in this library. This is passed to libomp | ||
/// as part of the OMPT connector object. | ||
/// \p lookup to be used to query callbacks registered with libomp | ||
/// \p initial_device_num initial device num (id) provided by libomp | ||
/// \p tool_data as provided by the tool | ||
int initializeLibrary(ompt_function_lookup_t lookup, int initial_device_num, | ||
ompt_data_t *tool_data); | ||
|
||
/// This function is passed to libomp / libomtarget as part of the OMPT | ||
/// connector object. It is called by libomp during finalization of OMPT in | ||
/// libomptarget -OR- by libomptarget during finalization of OMPT in the plugin. | ||
/// \p tool_data as provided by the tool | ||
void finalizeLibrary(ompt_data_t *tool_data); | ||
|
||
/// This function will connect the \p initializeLibrary and \p finalizeLibrary | ||
/// functions to their respective higher layer. | ||
void connectLibrary(); | ||
|
||
} // namespace ompt | ||
} // namespace target | ||
} // namespace omp | ||
} // namespace llvm | ||
|
||
#endif // OMPT_SUPPORT | ||
|
||
#endif // _OMPTCALLBACK_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.