diff options
author | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2015-12-18 23:20:36 +0000 |
---|---|---|
committer | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2015-12-18 23:20:36 +0000 |
commit | 4fee5f64160d2487c9cee1e3e35e146042afe8de (patch) | |
tree | 000c5a093868485cfdfa82920cc52c5160e1f417 | |
parent | 6cb33c60bd629ccdf3206898b4d9271bb8ffa8d2 (diff) | |
download | bcm5719-llvm-4fee5f64160d2487c9cee1e3e35e146042afe8de.tar.gz bcm5719-llvm-4fee5f64160d2487c9cee1e3e35e146042afe8de.zip |
Prevent monitor thread creation when KMP_BLOCKTIME="infinite"
When users sets envirable KMP_BLOCKTIME to "infinite" (the time one busy-waits
at barrieres, etc.), the monitor thread is not useful and can be ignored. This
change prevents the creation of the monitor thread when the users sets
KMP_BLOCKTIME to "infinite".
Differential Revision: http://reviews.llvm.org/D15628
llvm-svn: 256061
-rw-r--r-- | openmp/runtime/src/z_Linux_util.c | 8 | ||||
-rw-r--r-- | openmp/runtime/src/z_Windows_NT_util.c | 9 |
2 files changed, 17 insertions, 0 deletions
diff --git a/openmp/runtime/src/z_Linux_util.c b/openmp/runtime/src/z_Linux_util.c index 237677b24cf..0ebd9c4a9b9 100644 --- a/openmp/runtime/src/z_Linux_util.c +++ b/openmp/runtime/src/z_Linux_util.c @@ -1123,6 +1123,13 @@ __kmp_create_monitor( kmp_info_t *th ) int status; int auto_adj_size = FALSE; + if( __kmp_dflt_blocktime == KMP_MAX_BLOCKTIME ) { + // We don't need monitor thread in case of MAX_BLOCKTIME + KA_TRACE( 10, ("__kmp_create_monitor: skipping monitor thread because of MAX blocktime\n" ) ); + th->th.th_info.ds.ds_tid = 0; // this makes reap_monitor no-op + th->th.th_info.ds.ds_gtid = 0; + return; + } KA_TRACE( 10, ("__kmp_create_monitor: try to create monitor\n" ) ); KMP_MB(); /* Flush all pending memory write invalidates. */ @@ -1291,6 +1298,7 @@ __kmp_reap_monitor( kmp_info_t *th ) // If both tid and gtid are KMP_GTID_DNE, the monitor has been shut down. KMP_DEBUG_ASSERT( th->th.th_info.ds.ds_tid == th->th.th_info.ds.ds_gtid ); if ( th->th.th_info.ds.ds_gtid != KMP_GTID_MONITOR ) { + KA_TRACE( 10, ("__kmp_reap_monitor: monitor did not start, returning\n") ); return; }; // if diff --git a/openmp/runtime/src/z_Windows_NT_util.c b/openmp/runtime/src/z_Windows_NT_util.c index db7965a562a..7ac3eaefa1f 100644 --- a/openmp/runtime/src/z_Windows_NT_util.c +++ b/openmp/runtime/src/z_Windows_NT_util.c @@ -1429,6 +1429,14 @@ __kmp_create_monitor( kmp_info_t *th ) DWORD idThread; int ideal, new_ideal; + if( __kmp_dflt_blocktime == KMP_MAX_BLOCKTIME ) { + // We don't need monitor thread in case of MAX_BLOCKTIME + KA_TRACE( 10, ("__kmp_create_monitor: skipping monitor thread because of MAX blocktime\n" ) ); + th->th.th_info.ds.ds_tid = 0; // this makes reap_monitor no-op + th->th.th_info.ds.ds_gtid = 0; + TCW_4( __kmp_init_monitor, 2 ); // Signal to stop waiting for monitor creation + return; + } KA_TRACE( 10, ("__kmp_create_monitor: try to create monitor\n" ) ); KMP_MB(); /* Flush all pending memory write invalidates. */ @@ -1613,6 +1621,7 @@ __kmp_reap_monitor( kmp_info_t *th ) // If both tid and gtid are KMP_GTID_DNE, the monitor has been shut down. KMP_DEBUG_ASSERT( th->th.th_info.ds.ds_tid == th->th.th_info.ds.ds_gtid ); if ( th->th.th_info.ds.ds_gtid != KMP_GTID_MONITOR ) { + KA_TRACE( 10, ("__kmp_reap_monitor: monitor did not start, returning\n") ); return; }; // if |