[OpenMP][OMPT] A few improvements

This change includes miscellaneous improvements as follows:
1) Added ompt_get_proc_id() implementation for Windows
2) Added parser and print tool for omp-tool-var, just in case it needs
   to be printed (OMP_DISPLAY_ENV)
3) omp_control_tool is exported on Windows

Patch by Hansang Bae

Differential Revision: https://reviews.llvm.org/D50538

llvm-svn: 343137
This commit is contained in:
Jonathan Peyton 2018-09-26 20:19:44 +00:00
parent a89731ca71
commit 60eec6fecb
7 changed files with 38 additions and 22 deletions

View File

@ -557,6 +557,9 @@ kmp_set_disp_num_buffers 890
omp_thread_mem_alloc DATA
%endif # OMP_50
%ifdef OMP_50
omp_control_tool 891
%endif # OMP_50
%ifndef stub
# Ordinals between 900 and 999 are reserved

View File

@ -18,13 +18,6 @@
* is the largest value __kmp_nth may take, 1 is the smallest.
*/
// Need to raise Win version from XP to Vista here for support of
// InterlockedExchange64
#if defined(_WIN32_WINNT) && defined(_M_IX86)
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0502
#endif
#include "kmp.h"
#include "kmp_error.h"
#include "kmp_i18n.h"

View File

@ -17,13 +17,6 @@
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
// Need to raise Win version from XP to Vista here for support of
// InterlockedExchange64
#if defined(_WIN32_WINNT) && defined(_M_IX86)
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0502
#endif
#include "kmp.h"
#include "kmp_error.h"
#include "kmp_i18n.h"

View File

@ -4658,6 +4658,22 @@ static void __kmp_stg_print_omp_cancellation(kmp_str_buf_t *buffer,
#endif
#if OMP_50_ENABLED && OMPT_SUPPORT
static int __kmp_tool = 1;
static void __kmp_stg_parse_omp_tool(char const *name, char const *value,
void *data) {
__kmp_stg_parse_bool(name, value, &__kmp_tool);
} // __kmp_stg_parse_omp_tool
static void __kmp_stg_print_omp_tool(kmp_str_buf_t *buffer, char const *name,
void *data) {
if (__kmp_env_format) {
KMP_STR_BUF_PRINT_BOOL_EX(name, __kmp_tool, "enabled", "disabled");
} else {
__kmp_str_buf_print(buffer, " %s=%s\n", name,
__kmp_tool ? "enabled" : "disabled");
}
} // __kmp_stg_print_omp_tool
static char *__kmp_tool_libraries = NULL;
@ -4939,6 +4955,8 @@ static kmp_setting_t __kmp_stg_table[] = {
#endif
#if OMP_50_ENABLED && OMPT_SUPPORT
{"OMP_TOOL", __kmp_stg_parse_omp_tool, __kmp_stg_print_omp_tool, NULL, 0,
0},
{"OMP_TOOL_LIBRARIES", __kmp_stg_parse_omp_tool_libraries,
__kmp_stg_print_omp_tool_libraries, NULL, 0, 0},
#endif

View File

@ -31,9 +31,11 @@ int __kmp_default_tp_capacity(int, int, int);
__kmp_str_buf_print(buffer, " %s %s", KMP_I18N_STR(Device), name)
#define KMP_STR_BUF_PRINT_NAME_EX(x) \
__kmp_str_buf_print(buffer, " %s %s='", KMP_I18N_STR(Device), x)
#define KMP_STR_BUF_PRINT_BOOL_EX(n, v, t, f) \
__kmp_str_buf_print(buffer, " %s %s='%s'\n", KMP_I18N_STR(Device), n, \
(v) ? t : f)
#define KMP_STR_BUF_PRINT_BOOL \
__kmp_str_buf_print(buffer, " %s %s='%s'\n", KMP_I18N_STR(Device), name, \
value ? "TRUE" : "FALSE");
KMP_STR_BUF_PRINT_BOOL_EX(name, value, "TRUE", "FALSE")
#define KMP_STR_BUF_PRINT_INT \
__kmp_str_buf_print(buffer, " %s %s='%d'\n", KMP_I18N_STR(Device), name, \
value)
@ -48,9 +50,11 @@ int __kmp_default_tp_capacity(int, int, int);
__kmp_str_buf_print(buffer, " %s %s", KMP_I18N_STR(Host), name)
#define KMP_STR_BUF_PRINT_NAME_EX(x) \
__kmp_str_buf_print(buffer, " %s %s='", KMP_I18N_STR(Host), x)
#define KMP_STR_BUF_PRINT_BOOL_EX(n, v, t, f) \
__kmp_str_buf_print(buffer, " %s %s='%s'\n", KMP_I18N_STR(Host), n, \
(v) ? t : f)
#define KMP_STR_BUF_PRINT_BOOL \
__kmp_str_buf_print(buffer, " %s %s='%s'\n", KMP_I18N_STR(Host), name, \
value ? "TRUE" : "FALSE");
KMP_STR_BUF_PRINT_BOOL_EX(name, value, "TRUE", "FALSE")
#define KMP_STR_BUF_PRINT_INT \
__kmp_str_buf_print(buffer, " %s %s='%d'\n", KMP_I18N_STR(Host), name, value)
#define KMP_STR_BUF_PRINT_UINT64 \

View File

@ -452,7 +452,8 @@ int __kmp_str_match_false(char const *data) {
int result =
__kmp_str_match("false", 1, data) || __kmp_str_match("off", 2, data) ||
__kmp_str_match("0", 1, data) || __kmp_str_match(".false.", 2, data) ||
__kmp_str_match(".f.", 2, data) || __kmp_str_match("no", 1, data);
__kmp_str_match(".f.", 2, data) || __kmp_str_match("no", 1, data) ||
__kmp_str_match("disabled", 0, data);
return result;
} // __kmp_str_match_false
@ -460,7 +461,8 @@ int __kmp_str_match_true(char const *data) {
int result =
__kmp_str_match("true", 1, data) || __kmp_str_match("on", 2, data) ||
__kmp_str_match("1", 1, data) || __kmp_str_match(".true.", 2, data) ||
__kmp_str_match(".t.", 2, data) || __kmp_str_match("yes", 1, data);
__kmp_str_match(".t.", 2, data) || __kmp_str_match("yes", 1, data) ||
__kmp_str_match("enabled", 0, data);
return result;
} // __kmp_str_match_true

View File

@ -635,11 +635,14 @@ OMPT_API_ROUTINE int ompt_get_partition_place_nums(int place_nums_size,
****************************************************************************/
OMPT_API_ROUTINE int ompt_get_proc_id(void) {
#if KMP_OS_LINUX
if (__kmp_get_gtid() < 0)
return -1;
#if KMP_OS_LINUX
return sched_getcpu();
#elif KMP_OS_WINDOWS
PROCESSOR_NUMBER pn;
GetCurrentProcessorNumberEx(&pn);
return 64 * pn.Group + pn.Number;
#else
return -1;
#endif