aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/openmp/runtime/src/ompt-general.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/openmp/runtime/src/ompt-general.cpp')
-rw-r--r--contrib/llvm-project/openmp/runtime/src/ompt-general.cpp119
1 files changed, 109 insertions, 10 deletions
diff --git a/contrib/llvm-project/openmp/runtime/src/ompt-general.cpp b/contrib/llvm-project/openmp/runtime/src/ompt-general.cpp
index 22eac2ebf7b8..c52a3f28c2e7 100644
--- a/contrib/llvm-project/openmp/runtime/src/ompt-general.cpp
+++ b/contrib/llvm-project/openmp/runtime/src/ompt-general.cpp
@@ -45,6 +45,20 @@
#define OMPT_STR_MATCH(haystack, needle) (!strcasecmp(haystack, needle))
#endif
+// prints for an enabled OMP_TOOL_VERBOSE_INIT.
+// In the future a prefix could be added in the first define, the second define
+// omits the prefix to allow for continued lines. Example: "PREFIX: Start
+// tool... Success." instead of "PREFIX: Start tool... PREFIX: Success."
+#define OMPT_VERBOSE_INIT_PRINT(...) \
+ if (verbose_init) \
+ fprintf(verbose_file, __VA_ARGS__)
+#define OMPT_VERBOSE_INIT_CONTINUED_PRINT(...) \
+ if (verbose_init) \
+ fprintf(verbose_file, __VA_ARGS__)
+
+static FILE *verbose_file;
+static int verbose_init;
+
/*****************************************************************************
* types
****************************************************************************/
@@ -230,6 +244,9 @@ ompt_try_start_tool(unsigned int omp_version, const char *runtime_version) {
const char *sep = ":";
#endif
+ OMPT_VERBOSE_INIT_PRINT("----- START LOGGING OF TOOL REGISTRATION -----\n");
+ OMPT_VERBOSE_INIT_PRINT("Search for OMP tool in current address space... ");
+
#if KMP_OS_DARWIN
// Try in the current address space
ret = ompt_tool_darwin(omp_version, runtime_version);
@@ -240,50 +257,114 @@ ompt_try_start_tool(unsigned int omp_version, const char *runtime_version) {
#else
#error Activation of OMPT is not supported on this platform.
#endif
- if (ret)
+ if (ret) {
+ OMPT_VERBOSE_INIT_CONTINUED_PRINT("Sucess.\n");
+ OMPT_VERBOSE_INIT_PRINT(
+ "Tool was started and is using the OMPT interface.\n");
+ OMPT_VERBOSE_INIT_PRINT("----- END LOGGING OF TOOL REGISTRATION -----\n");
return ret;
+ }
// Try tool-libraries-var ICV
+ OMPT_VERBOSE_INIT_CONTINUED_PRINT("Failed.\n");
const char *tool_libs = getenv("OMP_TOOL_LIBRARIES");
if (tool_libs) {
+ OMPT_VERBOSE_INIT_PRINT("Searching tool libraries...\n");
+ OMPT_VERBOSE_INIT_PRINT("OMP_TOOL_LIBRARIES = %s\n", tool_libs);
char *libs = __kmp_str_format("%s", tool_libs);
char *buf;
char *fname = __kmp_str_token(libs, sep, &buf);
+ // Reset dl-error
+ dlerror();
+
while (fname) {
#if KMP_OS_UNIX
+ OMPT_VERBOSE_INIT_PRINT("Opening %s... ", fname);
void *h = dlopen(fname, RTLD_LAZY);
- if (h) {
+ if (!h) {
+ OMPT_VERBOSE_INIT_CONTINUED_PRINT("Failed: %s\n", dlerror());
+ } else {
+ OMPT_VERBOSE_INIT_CONTINUED_PRINT("Success. \n");
+ OMPT_VERBOSE_INIT_PRINT("Searching for ompt_start_tool in %s... ",
+ fname);
start_tool = (ompt_start_tool_t)dlsym(h, "ompt_start_tool");
+ if (!start_tool) {
+ OMPT_VERBOSE_INIT_CONTINUED_PRINT("Failed: %s\n", dlerror());
+ } else
#elif KMP_OS_WINDOWS
+ OMPT_VERBOSE_INIT_PRINT("Opening %s... ", fname);
HMODULE h = LoadLibrary(fname);
- if (h) {
+ if (!h) {
+ OMPT_VERBOSE_INIT_CONTINUED_PRINT("Failed: Error %u\n", GetLastError());
+ } else {
+ OMPT_VERBOSE_INIT_CONTINUED_PRINT("Success. \n");
+ OMPT_VERBOSE_INIT_PRINT("Searching for ompt_start_tool in %s... ",
+ fname);
start_tool = (ompt_start_tool_t)GetProcAddress(h, "ompt_start_tool");
+ if (!start_tool) {
+ OMPT_VERBOSE_INIT_CONTINUED_PRINT("Failed: Error %s\n",
+ GetLastError());
+ } else
#else
#error Activation of OMPT is not supported on this platform.
#endif
- if (start_tool && (ret = (*start_tool)(omp_version, runtime_version)))
- break;
+ {// if (start_tool)
+ ret = (*start_tool)(omp_version, runtime_version);
+ if (ret) {
+ OMPT_VERBOSE_INIT_CONTINUED_PRINT("Success.\n");
+ OMPT_VERBOSE_INIT_PRINT(
+ "Tool was started and is using the OMPT interface.\n");
+ break;
+ }
+ OMPT_VERBOSE_INIT_CONTINUED_PRINT(
+ "Found but not using the OMPT interface.\n");
+ OMPT_VERBOSE_INIT_PRINT("Continuing search...\n");
+ }
}
fname = __kmp_str_token(NULL, sep, &buf);
}
__kmp_str_free(&libs);
+ } else {
+ OMPT_VERBOSE_INIT_PRINT("No OMP_TOOL_LIBRARIES defined.\n");
}
- if (ret)
+
+ // usable tool found in tool-libraries
+ if (ret) {
+ OMPT_VERBOSE_INIT_PRINT("----- END LOGGING OF TOOL REGISTRATION -----\n");
return ret;
+ }
#if KMP_OS_UNIX
{ // Non-standard: load archer tool if application is built with TSan
const char *fname = "libarcher.so";
+ OMPT_VERBOSE_INIT_PRINT(
+ "...searching tool libraries failed. Using archer tool.\n");
+ OMPT_VERBOSE_INIT_PRINT("Opening %s... ", fname);
void *h = dlopen(fname, RTLD_LAZY);
if (h) {
+ OMPT_VERBOSE_INIT_CONTINUED_PRINT("Success.\n");
+ OMPT_VERBOSE_INIT_PRINT("Searching for ompt_start_tool in %s... ", fname);
start_tool = (ompt_start_tool_t)dlsym(h, "ompt_start_tool");
- if (start_tool)
+ if (start_tool) {
ret = (*start_tool)(omp_version, runtime_version);
- if (ret)
- return ret;
+ if (ret) {
+ OMPT_VERBOSE_INIT_CONTINUED_PRINT("Success.\n");
+ OMPT_VERBOSE_INIT_PRINT(
+ "Tool was started and is using the OMPT interface.\n");
+ OMPT_VERBOSE_INIT_PRINT(
+ "----- END LOGGING OF TOOL REGISTRATION -----\n");
+ return ret;
+ }
+ OMPT_VERBOSE_INIT_CONTINUED_PRINT(
+ "Found but not using the OMPT interface.\n");
+ } else {
+ OMPT_VERBOSE_INIT_CONTINUED_PRINT("Failed: %s\n", dlerror());
+ }
}
}
#endif
+ OMPT_VERBOSE_INIT_PRINT("No OMP tool loaded.\n");
+ OMPT_VERBOSE_INIT_PRINT("----- END LOGGING OF TOOL REGISTRATION -----\n");
return ret;
}
@@ -311,11 +392,27 @@ void ompt_pre_init() {
else if (OMPT_STR_MATCH(ompt_env_var, "enabled"))
tool_setting = omp_tool_enabled;
+ const char *ompt_env_verbose_init = getenv("OMP_TOOL_VERBOSE_INIT");
+ // possible options: disabled | stdout | stderr | <filename>
+ // if set, not empty and not disabled -> prepare for logging
+ if (ompt_env_verbose_init && strcmp(ompt_env_verbose_init, "") &&
+ !OMPT_STR_MATCH(ompt_env_verbose_init, "disabled")) {
+ verbose_init = 1;
+ if (OMPT_STR_MATCH(ompt_env_verbose_init, "STDERR"))
+ verbose_file = stderr;
+ else if (OMPT_STR_MATCH(ompt_env_verbose_init, "STDOUT"))
+ verbose_file = stdout;
+ else
+ verbose_file = fopen(ompt_env_verbose_init, "w");
+ } else
+ verbose_init = 0;
+
#if OMPT_DEBUG
printf("ompt_pre_init(): tool_setting = %d\n", tool_setting);
#endif
switch (tool_setting) {
case omp_tool_disabled:
+ OMPT_VERBOSE_INIT_PRINT("OMP tool disabled. \n");
break;
case omp_tool_unset:
@@ -337,6 +434,8 @@ void ompt_pre_init() {
ompt_env_var);
break;
}
+ if (verbose_init && verbose_file != stderr && verbose_file != stdout)
+ fclose(verbose_file);
#if OMPT_DEBUG
printf("ompt_pre_init(): ompt_enabled = %d\n", ompt_enabled);
#endif
@@ -741,5 +840,5 @@ static ompt_interface_fn_t ompt_fn_lookup(const char *s) {
FOREACH_OMPT_INQUIRY_FN(ompt_interface_fn)
- return (ompt_interface_fn_t)0;
+ return NULL;
}