[m-rev.] for review: ThreadScope changes

Paul Bone paul at bone.id.au
Fri May 30 16:49:55 AEST 2014


Branches: master

For review by anyone

---

ThreadScope changes

runtime/mercury_par_profile.c:
runtime/mercury_par_profile.h:
    Update comments in these files to Describe the origin of this code and
    that it is no-longer intended to be compatible with ThreadScope.

runtime/mercury_context.c:
    Fix a bug where the incorrect C macro was used to conditionally compile
    the logging of a parallel profiling event.

library/benchmarking.m:
    Deprecate log_threadscope_message/3 in favor of the new predicate
    log_parprof_message/3.
---
 library/benchmarking.m        | 20 +++++++++++++++-----
 runtime/mercury_context.c     |  2 +-
 runtime/mercury_par_profile.c | 20 +++++++++++++++++++-
 runtime/mercury_par_profile.h | 22 +++++++++++++++++-----
 4 files changed, 52 insertions(+), 12 deletions(-)

diff --git a/library/benchmarking.m b/library/benchmarking.m
index aadd5d8..53b0316 100644
--- a/library/benchmarking.m
+++ b/library/benchmarking.m
@@ -142,10 +142,17 @@
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
 
-    % Place a log message in the threadscope event stream.  The event will be
-    % logged as being generated by the current Mercury Engine.  This is a no-op
-    % when threadscope is not available.
+    % Place a log message in the parallel profiling event stream.  The event
+    % will be logged as being generated by the current Mercury engine and
+    % context.  This is a no-op when parallel profiling is not available.
     %
+:- pred log_parprof_message(string::in, io::di, io::uo) is det.
+
+    % This is the same as log_parprof_message.  As Mercury will not be
+    % compatible with ThreadScope in the future we're renaming this to avoid
+    % confusion.
+    %
+:- pragma obsolete(log_threadscope_message/3).
 :- pred log_threadscope_message(string::in, io::di, io::uo) is det.
 
 %-----------------------------------------------------------------------------%
@@ -1309,13 +1316,16 @@ dump_trace_counts_to(_, 1, !IO).
 %-----------------------------------------------------------------------------%
 
 :- pragma foreign_proc("C",
-    log_threadscope_message(Message::in, _IO0::di, _IO::uo),
+    log_parprof_message(Message::in, _IO0::di, _IO::uo),
     [will_not_call_mercury, will_not_throw_exception, thread_safe, 
         promise_pure, tabled_for_io],
 "
 #if MR_PARPROF
-    MR_threadscope_post_log_msg(Message);
+    MR_parprof_post_log_msg(Message);
 #endif
 ").
 
+log_threadscope_message(Message, !IO) :-
+    log_parprof_message(Message, !IO).
+
 %-----------------------------------------------------------------------------%
diff --git a/runtime/mercury_context.c b/runtime/mercury_context.c
index 9d40f4b..c490713 100644
--- a/runtime/mercury_context.c
+++ b/runtime/mercury_context.c
@@ -1551,7 +1551,7 @@ MR_schedule_context(MR_Context *ctxt)
 
     notify_context_data.MR_ewa_context = ctxt;
 
-#ifdef MR_PROFILE_PARALLEL_EXECUTION_SUPPORT
+#ifdef MR_PARPROF
     MR_parprof_post_context_runnable(ctxt);
 #endif
 
diff --git a/runtime/mercury_par_profile.c b/runtime/mercury_par_profile.c
index e0be235..fb787ca 100644
--- a/runtime/mercury_par_profile.c
+++ b/runtime/mercury_par_profile.c
@@ -2,7 +2,7 @@
 ** vim: ts=4 sw=4 expandtab
 */
 /*
-** Copyright (C) 2009-2011,2013 The University of Melbourne.
+** Copyright (C) 2009-2011,2013-2014 The University of Melbourne.
 ** Copyright (C) 2008-2009 The GHC Team.
 **
 ** This file may only be copied under the terms of the GNU Library General
@@ -10,6 +10,24 @@
 */
 
 /*
+** mercury_par_profile.c - defines Mercury parallel profiling support.
+**
+** The code in this file and mercury_par_profile.h was originally designed
+** to be compatible with ThreadScope, see:
+**
+**   + Don Jones Jr, Simon Marlow and Satnam Singh: Parallel Preformance
+**     Tuning for Haskell.
+**
+**   + Paul Bone and Zoltan Somogyi: Profiling parallel Mercury programs
+**     with ThreadScope.
+**
+** Maintaining compatibility with ThreadScope has been problematic, we no
+** longer support compatibility with ThreadScope, however this code is
+** intially based off ThreadScope and GHC's runtime system support for
+** ThreadScope.
+*/
+
+/*
 ** Event log format
 **
 ** The log format is designed to be extensible: old tools should be able
diff --git a/runtime/mercury_par_profile.h b/runtime/mercury_par_profile.h
index 230de4d..27e4dd2 100644
--- a/runtime/mercury_par_profile.h
+++ b/runtime/mercury_par_profile.h
@@ -2,17 +2,28 @@
 ** vim:ts=4 sw=4 expandtab
 */
 /*
-** Copyright (C) 2009-2011,2013 The University of Melbourne.
+** Copyright (C) 2009-2011,2013-2014 The University of Melbourne.
 **
 ** This file may only be copied under the terms of the GNU Library General
 ** Public License - see the file COPYING.LIB in the Mercury distribution.
 */
 
 /*
-** mercury_par_profile.h - defines Mercury threadscope profiling support.
+** mercury_par_profile.h - defines Mercury parallel profiling support.
 **
-** See "Parallel Preformance Tuning for Haskell" - Don Jones Jr, Simon Marlow
-** and Satnam Singh for information about threadscope.
+** The code in this file and mercury_par_profile.c was originally designed
+** to be compatible with ThreadScope, see:
+**
+**   + Don Jones Jr, Simon Marlow and Satnam Singh: Parallel Preformance
+**     Tuning for Haskell.
+**
+**   + Paul Bone and Zoltan Somogyi: Profiling parallel Mercury programs
+**     with ThreadScope.
+**
+** Maintaining compatibility with ThreadScope has been problematic, we no
+** longer support compatibility with ThreadScope, however this code is
+** intially based off ThreadScope and GHC's runtime system support for
+** ThreadScope.
 */
 
 #ifndef MERCURY_PAR_PROFILE_H
@@ -73,7 +84,8 @@ extern void MR_parprof_finalize_engine(MercuryEngine *eng);
 /*
 ** It looks like we don't need TSC synchronization code on modern x86(-64) CPUs
 ** including multi-socket systems (tested on goliath and taura).  If we find
-** systems where this is needed we can enable it via a runtime check.
+** systems where this is needed we can uncomment this code and introduce
+** runtime configuration.
 */
 /*
 ** Synchronize a slave thread's TSC offset to the master's.  The master thread
-- 
2.0.0.rc0




More information about the reviews mailing list