summaryrefslogtreecommitdiffstats
path: root/openmp/runtime/src/ompt-general.cpp
diff options
context:
space:
mode:
authorJonas Hahnfeld <hahnjo@hahnjo.de>2017-11-03 18:28:19 +0000
committerJonas Hahnfeld <hahnjo@hahnjo.de>2017-11-03 18:28:19 +0000
commitf0a1c65fb007d727ff93bd8ff9c438f689cde77d (patch)
tree15f4808dd4e47ef7dd31bf66465d9c9b976a830d /openmp/runtime/src/ompt-general.cpp
parent8fe9fb0ae57b7da25bceb154f4a798d347def42f (diff)
downloadbcm5719-llvm-f0a1c65fb007d727ff93bd8ff9c438f689cde77d.tar.gz
bcm5719-llvm-f0a1c65fb007d727ff93bd8ff9c438f689cde77d.zip
Revert "Updating implementation of OMPT as specified in OpenMP 5.0 Preview 2 (TR6)"
This reverts commit r317339 which discarded some recent commits. llvm-svn: 317346
Diffstat (limited to 'openmp/runtime/src/ompt-general.cpp')
-rw-r--r--openmp/runtime/src/ompt-general.cpp84
1 files changed, 67 insertions, 17 deletions
diff --git a/openmp/runtime/src/ompt-general.cpp b/openmp/runtime/src/ompt-general.cpp
index 753fced459b..a6f0647b78e 100644
--- a/openmp/runtime/src/ompt-general.cpp
+++ b/openmp/runtime/src/ompt-general.cpp
@@ -74,7 +74,7 @@ ompt_mutex_impl_info_t ompt_mutex_impl_info[] = {
ompt_callbacks_internal_t ompt_callbacks;
-static ompt_start_tool_result_t *ompt_start_tool_result = NULL;
+static ompt_fns_t *ompt_fns = NULL;
/*****************************************************************************
* forward declarations
@@ -97,8 +97,7 @@ OMPT_API_ROUTINE ompt_data_t *ompt_get_thread_data(void);
* found, ompt_tool's return value is used to initialize the tool. Otherwise,
* NULL is returned and OMPT won't be enabled */
-typedef ompt_start_tool_result_t *(*ompt_start_tool_t)(unsigned int,
- const char *);
+typedef ompt_fns_t *(*ompt_start_tool_t)(unsigned int, const char *);
#if KMP_OS_UNIX
@@ -110,13 +109,13 @@ _OMP_EXTERN
#else
#error Activation of OMPT is not supported on this platform.
#endif
-ompt_start_tool_result_t *
+ompt_fns_t *
ompt_start_tool(unsigned int omp_version, const char *runtime_version) {
#ifdef KMP_DYNAMIC_LIB
- ompt_start_tool_result_t *ret = NULL;
+ ompt_fns_t *ret = NULL;
// Try next symbol in the address space
ompt_start_tool_t next_tool = NULL;
- *(void **)(&next_tool) = dlsym(RTLD_NEXT, "ompt_start_tool");
+ next_tool = (ompt_start_tool_t)dlsym(RTLD_NEXT, "ompt_start_tool");
if (next_tool)
ret = (next_tool)(omp_version, runtime_version);
return ret;
@@ -137,8 +136,8 @@ ompt_start_tool(unsigned int omp_version, const char *runtime_version) {
// The number of loaded modules to start enumeration with EnumProcessModules()
#define NUM_MODULES 128
-static ompt_start_tool_result_t *
-ompt_tool_windows(unsigned int omp_version, const char *runtime_version) {
+static ompt_fns_t *ompt_tool_windows(unsigned int omp_version,
+ const char *runtime_version) {
int i;
DWORD needed, new_size;
HMODULE *modules;
@@ -196,9 +195,9 @@ ompt_tool_windows(unsigned int omp_version, const char *runtime_version) {
#error Either __attribute__((weak)) or psapi.dll are required for OMPT support
#endif // OMPT_HAVE_WEAK_ATTRIBUTE
-static ompt_start_tool_result_t *
-ompt_try_start_tool(unsigned int omp_version, const char *runtime_version) {
- ompt_start_tool_result_t *ret = NULL;
+static ompt_fns_t *ompt_try_start_tool(unsigned int omp_version,
+ const char *runtime_version) {
+ ompt_fns_t *ret = NULL;
ompt_start_tool_t start_tool = NULL;
#if KMP_OS_WINDOWS
// Cannot use colon to describe a list of absolute paths on Windows
@@ -221,7 +220,7 @@ ompt_try_start_tool(unsigned int omp_version, const char *runtime_version) {
#if KMP_OS_UNIX
void *h = dlopen(fname, RTLD_LAZY);
if (h) {
- *(void **)(&start_tool) = dlsym(h, "ompt_start_tool");
+ start_tool = (ompt_start_tool_t)dlsym(h, "ompt_start_tool");
#elif KMP_OS_WINDOWS
HMODULE h = LoadLibrary(fname);
if (h) {
@@ -276,7 +275,7 @@ void ompt_pre_init() {
//--------------------------------------------------
// Load tool iff specified in environment variable
//--------------------------------------------------
- ompt_start_tool_result =
+ ompt_fns =
ompt_try_start_tool(__kmp_openmp_version, ompt_get_runtime_version());
memset(&ompt_enabled, 0, sizeof(ompt_enabled));
@@ -308,9 +307,8 @@ void ompt_post_init() {
//--------------------------------------------------
// Initialize the tool if so indicated.
//--------------------------------------------------
- if (ompt_start_tool_result) {
- ompt_enabled.enabled = !!ompt_start_tool_result->initialize(
- ompt_fn_lookup, &(ompt_start_tool_result->tool_data));
+ if (ompt_fns) {
+ ompt_enabled.enabled = !!ompt_fns->initialize(ompt_fn_lookup, ompt_fns);
ompt_thread_t *root_thread = ompt_get_thread();
@@ -333,7 +331,7 @@ void ompt_post_init() {
void ompt_fini() {
if (ompt_enabled.enabled) {
- ompt_start_tool_result->finalize(&(ompt_start_tool_result->tool_data));
+ ompt_fns->finalize(ompt_fns);
}
memset(&ompt_enabled, 0, sizeof(ompt_enabled));
@@ -579,6 +577,56 @@ OMPT_API_ROUTINE int ompt_get_proc_id(void) {
}
/*****************************************************************************
+ * placeholders
+ ****************************************************************************/
+
+// Don't define this as static. The loader may choose to eliminate the symbol
+// even though it is needed by tools.
+#define OMPT_API_PLACEHOLDER
+
+// Ensure that placeholders don't have mangled names in the symbol table.
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+OMPT_API_PLACEHOLDER void ompt_idle(void) {
+ // This function is a placeholder used to represent the calling context of
+ // idle OpenMP worker threads. It is not meant to be invoked.
+ assert(0);
+}
+
+OMPT_API_PLACEHOLDER void ompt_overhead(void) {
+ // This function is a placeholder used to represent the OpenMP context of
+ // threads working in the OpenMP runtime. It is not meant to be invoked.
+ assert(0);
+}
+
+OMPT_API_PLACEHOLDER void ompt_barrier_wait(void) {
+ // This function is a placeholder used to represent the OpenMP context of
+ // threads waiting for a barrier in the OpenMP runtime. It is not meant
+ // to be invoked.
+ assert(0);
+}
+
+OMPT_API_PLACEHOLDER void ompt_task_wait(void) {
+ // This function is a placeholder used to represent the OpenMP context of
+ // threads waiting for a task in the OpenMP runtime. It is not meant
+ // to be invoked.
+ assert(0);
+}
+
+OMPT_API_PLACEHOLDER void ompt_mutex_wait(void) {
+ // This function is a placeholder used to represent the OpenMP context of
+ // threads waiting for a mutex in the OpenMP runtime. It is not meant
+ // to be invoked.
+ assert(0);
+}
+
+#ifdef __cplusplus
+};
+#endif
+
+/*****************************************************************************
* compatability
****************************************************************************/
@@ -641,5 +689,7 @@ static ompt_interface_fn_t ompt_fn_lookup(const char *s) {
FOREACH_OMPT_INQUIRY_FN(ompt_interface_fn)
+ FOREACH_OMPT_PLACEHOLDER_FN(ompt_interface_fn)
+
return (ompt_interface_fn_t)0;
}
OpenPOWER on IntegriCloud