On some systems the CPU's time stamp counter (TSC) cannot reliabily be

used.  Mercury's ThreadScope support will now use gettimeofday() by
default, but use of the TSC may be enabled.

Note that in Linux, gettimeofday() does not always make a system call.

runtime/mercury_threadscope.[ch]:
    Add support for measuring time with gettimeofday().

    Use gettimeofday() to measure time by default.

runtime/mercury_atomic_ops.[ch]
    Add a new function MR_tsc_is_sensible(), It returns true if the TSC can
    (as far as the RTS can detect) be used.

    Fix trailing whitespace.

runtime/mercury_wrapper.c:
    Add a new runtime option --threadscope-use-tsc.
    When specified this option allows threadscope to use the CPU's TSC to
    measure time.

doc/userguide.texi:
    Document the --threadscope-use-tsc option.  This documentation is
    commented out.
This commit is contained in:
Paul Bone
2012-06-20 13:13:34 +00:00
parent 7380ec7f59
commit a9f82d004b
6 changed files with 121 additions and 41 deletions

View File

@@ -49,6 +49,14 @@ typedef struct MR_Threadscope_String {
MR_TS_StringId MR_tsstring_id;
} MR_Threadscope_String;
/*
** Set this to true to use the CPU's time stamp counter.
**
** This is initially set in mercury_wrapper.c and may be reset by
** MR_setup_threadscope if the TSC can't be used.
*/
extern MR_bool MR_threadscope_use_tsc;
/*
** This must be called by the primordial thread before starting any other
** threads but after the primordial thread has been pinned.