diff options
| author | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2016-09-27 17:11:17 +0000 |
|---|---|---|
| committer | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2016-09-27 17:11:17 +0000 |
| commit | b66d1aab25e415061d57b72487d26d2b3b05f9c2 (patch) | |
| tree | da1ab45a363c9ef8dd2e122ae04906fd319e5d97 /openmp/runtime/src/z_Linux_util.c | |
| parent | 83ebef5db3aec9b728bf17d51e2afb9a5945ad27 (diff) | |
| download | bcm5719-llvm-b66d1aab25e415061d57b72487d26d2b3b05f9c2.tar.gz bcm5719-llvm-b66d1aab25e415061d57b72487d26d2b3b05f9c2.zip | |
Disable monitor thread creation by default.
This change set disables creation of the monitor thread by default. The global
counter maintained by the monitor thread was replaced by logic that uses system
time directly, and cyclic yielding on Linux target was also removed since there
was no clear benefit of using it. Turning on KMP_USE_MONITOR variable (=1)
enables creation of monitor thread again if it is really necessary for some
reasons.
Differential Revision: https://reviews.llvm.org/D24739
llvm-svn: 282507
Diffstat (limited to 'openmp/runtime/src/z_Linux_util.c')
| -rw-r--r-- | openmp/runtime/src/z_Linux_util.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/openmp/runtime/src/z_Linux_util.c b/openmp/runtime/src/z_Linux_util.c index 578159b8f99..6c51301d1bf 100644 --- a/openmp/runtime/src/z_Linux_util.c +++ b/openmp/runtime/src/z_Linux_util.c @@ -87,6 +87,8 @@ static pthread_mutexattr_t __kmp_suspend_mutex_attr; static kmp_cond_align_t __kmp_wait_cv; static kmp_mutex_align_t __kmp_wait_mx; +double __kmp_ticks_per_nsec; + /* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */ @@ -757,6 +759,7 @@ __kmp_launch_worker( void *thr ) return exit_val; } +#if KMP_USE_MONITOR /* The monitor thread controls all of the threads in the complex */ static void* @@ -953,6 +956,7 @@ __kmp_launch_monitor( void *thr ) return thr; } +#endif // KMP_USE_MONITOR void __kmp_create_worker( int gtid, kmp_info_t *th, size_t stack_size ) @@ -1077,6 +1081,7 @@ __kmp_create_worker( int gtid, kmp_info_t *th, size_t stack_size ) } // __kmp_create_worker +#if KMP_USE_MONITOR void __kmp_create_monitor( kmp_info_t *th ) { @@ -1237,6 +1242,7 @@ __kmp_create_monitor( kmp_info_t *th ) KA_TRACE( 10, ( "__kmp_create_monitor: monitor created %#.8lx\n", th->th.th_info.ds.ds_thread ) ); } // __kmp_create_monitor +#endif // KMP_USE_MONITOR void __kmp_exit_thread( @@ -1245,6 +1251,7 @@ __kmp_exit_thread( pthread_exit( (void *)(intptr_t) exit_status ); } // __kmp_exit_thread +#if KMP_USE_MONITOR void __kmp_resume_monitor(); void @@ -1296,6 +1303,7 @@ __kmp_reap_monitor( kmp_info_t *th ) KMP_MB(); /* Flush all pending memory write invalidates. */ } +#endif // KMP_USE_MONITOR void __kmp_reap_worker( kmp_info_t *th ) @@ -1524,7 +1532,9 @@ __kmp_atfork_child (void) ++__kmp_fork_count; __kmp_init_runtime = FALSE; +#if KMP_USE_MONITOR __kmp_init_monitor = 0; +#endif __kmp_init_parallel = FALSE; __kmp_init_middle = FALSE; __kmp_init_serial = FALSE; @@ -1843,6 +1853,7 @@ void __kmp_resume_oncore(int target_gtid, kmp_flag_oncore *flag) { __kmp_resume_template(target_gtid, flag); } +#if KMP_USE_MONITOR void __kmp_resume_monitor() { @@ -1870,6 +1881,7 @@ __kmp_resume_monitor() KF_TRACE( 30, ( "__kmp_resume_monitor: T#%d exiting after signaling wake up for T#%d\n", gtid, KMP_GTID_MONITOR ) ); } +#endif // KMP_USE_MONITOR /* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */ @@ -1877,7 +1889,11 @@ __kmp_resume_monitor() void __kmp_yield( int cond ) { - if (cond && __kmp_yielding_on) { + if (cond +#if KMP_USE_MONITOR + && __kmp_yielding_on +#endif + ) { sched_yield(); } } @@ -2214,6 +2230,20 @@ __kmp_now_nsec() return KMP_NSEC_PER_SEC*t.tv_sec + 1000*t.tv_usec; } +#if KMP_ARCH_X86 || KMP_ARCH_X86_64 +/* Measure clock tick per nanosecond */ +void +__kmp_initialize_system_tick() +{ + kmp_uint64 delay = 100000; // 50~100 usec on most machines. + kmp_uint64 nsec = __kmp_now_nsec(); + kmp_uint64 goal = __kmp_hardware_timestamp() + delay; + kmp_uint64 now; + while ((now = __kmp_hardware_timestamp()) < goal); + __kmp_ticks_per_nsec = 1.0 * (delay + (now - goal)) / (__kmp_now_nsec() - nsec); +} +#endif + /* Determine whether the given address is mapped into the current address space. */ |

