summaryrefslogtreecommitdiffstats
path: root/openmp/runtime/src
diff options
context:
space:
mode:
authorJoachim Protze <protze@itc.rwth-aachen.de>2018-01-17 10:05:55 +0000
committerJoachim Protze <protze@itc.rwth-aachen.de>2018-01-17 10:05:55 +0000
commit1dc2afdcaf887a322a58fa12d616a3097d9d47e9 (patch)
tree0997fad34e916e1b2b4efc8d661192ef9bef992b /openmp/runtime/src
parent2ae6037dd150893c6f54a67dcc4664003306ea8c (diff)
downloadbcm5719-llvm-1dc2afdcaf887a322a58fa12d616a3097d9d47e9.tar.gz
bcm5719-llvm-1dc2afdcaf887a322a58fa12d616a3097d9d47e9.zip
[OMPT] Return appropiate values for ompt runtime entry points for non-OpenMP threads
When the current thread is not an (initialized) OpenMP thread, the runtime entry points return values that correspond to "not available" or similar Differential Revision: https://reviews.llvm.org/D41167 llvm-svn: 322620
Diffstat (limited to 'openmp/runtime/src')
-rw-r--r--openmp/runtime/src/ompt-general.cpp9
-rw-r--r--openmp/runtime/src/ompt-specific.cpp23
2 files changed, 24 insertions, 8 deletions
diff --git a/openmp/runtime/src/ompt-general.cpp b/openmp/runtime/src/ompt-general.cpp
index 7e1c67a7c26..f9b98c19bd3 100644
--- a/openmp/runtime/src/ompt-general.cpp
+++ b/openmp/runtime/src/ompt-general.cpp
@@ -553,6 +553,9 @@ OMPT_API_ROUTINE int ompt_get_place_num(void) {
#if !KMP_AFFINITY_SUPPORTED
return -1;
#else
+ if (__kmp_get_gtid() < 0)
+ return -1;
+
int gtid;
kmp_info_t *thread;
if (!KMP_AFFINITY_CAPABLE())
@@ -571,6 +574,9 @@ OMPT_API_ROUTINE int ompt_get_partition_place_nums(int place_nums_size,
#if !KMP_AFFINITY_SUPPORTED
return 0;
#else
+ if (__kmp_get_gtid() < 0)
+ return 0;
+
int i, gtid, place_num, first_place, last_place, start, end;
kmp_info_t *thread;
if (!KMP_AFFINITY_CAPABLE())
@@ -604,6 +610,9 @@ 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;
+
return sched_getcpu();
#else
return -1;
diff --git a/openmp/runtime/src/ompt-specific.cpp b/openmp/runtime/src/ompt-specific.cpp
index 92665ade536..5488c6ede99 100644
--- a/openmp/runtime/src/ompt-specific.cpp
+++ b/openmp/runtime/src/ompt-specific.cpp
@@ -219,16 +219,20 @@ omp_state_t __ompt_get_state_internal(ompt_wait_id_t *ompt_wait_id) {
int __ompt_get_parallel_info_internal(int ancestor_level,
ompt_data_t **parallel_data,
int *team_size) {
- ompt_team_info_t *info;
- if (team_size) {
- info = __ompt_get_teaminfo(ancestor_level, team_size);
+ if (__kmp_get_gtid() >= 0) {
+ ompt_team_info_t *info;
+ if (team_size) {
+ info = __ompt_get_teaminfo(ancestor_level, team_size);
+ } else {
+ info = __ompt_get_teaminfo(ancestor_level, NULL);
+ }
+ if (parallel_data) {
+ *parallel_data = info ? &(info->parallel_data) : NULL;
+ }
+ return info ? 2 : 0;
} else {
- info = __ompt_get_teaminfo(ancestor_level, NULL);
- }
- if (parallel_data) {
- *parallel_data = info ? &(info->parallel_data) : NULL;
+ return 0;
}
- return info ? 2 : 0;
}
//----------------------------------------------------------
@@ -314,6 +318,9 @@ int __ompt_get_task_info_internal(int ancestor_level, int *type,
ompt_frame_t **task_frame,
ompt_data_t **parallel_data,
int *thread_num) {
+ if (__kmp_get_gtid() < 0)
+ return 0;
+
if (ancestor_level < 0)
return 0;
OpenPOWER on IntegriCloud