[m-rev.] for review: deep profiling fixes, determinism algorithm change

Zoltan Somogyi zs at cs.mu.OZ.AU
Wed Aug 14 14:29:36 AEST 2002


On 14-Aug-2002, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> I will post a relative diff later today.

Here it is.

Diffing .
Diffing bench
Diffing bench/progs
Diffing bench/progs/compress
Diffing bench/progs/icfp2000
Diffing bench/progs/icfp2001
Diffing bench/progs/nuc
Diffing bench/progs/ray
Diffing bench/progs/tree234
Diffing bindist
Diffing boehm_gc
Diffing boehm_gc/Mac_files
Diffing boehm_gc/cord
Diffing boehm_gc/cord/private
Diffing boehm_gc/doc
Diffing boehm_gc/include
Diffing boehm_gc/include/private
Diffing boehm_gc/tests
Diffing browser
Diffing bytecode
Diffing compiler
--- ws86.basis//compiler/det_analysis.m	Sun Aug 11 11:53:33 2002
+++ ws86/compiler/det_analysis.m	Wed Aug 14 13:24:19 2002
@@ -843,6 +843,17 @@
 		Msgs1),
 	determinism_components(Detism1, CanFail1, MaxSolns1),
 	Goal = _ - GoalInfo,
+	% If a disjunct cannot succeed but is marked with the
+	% preserve_backtrack_into feature, treat it as being able to succeed
+	% when computing the max number of solutions of the disjunction as a
+	% whole, *provided* that some earlier disjuct could succeed. The idea
+	% is that ( marked failure ; det ) should be treated as det, since all
+	% backtracking is local within it, while disjunctions of the form
+	% ( det ; marked failure ) should be treated as multi, since we want
+	% to be able to backtrack to the second disjunct from *outside*
+	% the disjunction. This is useful for program transformation that want
+	% to get control on exits to and redos into model_non procedures.
+	% Deep profiling is one such transformation.
 	(
 		MaxSolns0 \= at_most_zero,
 		MaxSolns1 = at_most_zero,
--- ws86.basis//compiler/hlds_goal.m	Mon Aug 12 21:49:32 2002
+++ ws86/compiler/hlds_goal.m	Wed Aug 14 13:21:08 2002
@@ -725,7 +725,11 @@
 				% nondeterminism inside the some() should be
 				% exposed to the environment outside.
 	;	preserve_backtrack_into
-				% This
+				% Determinism analysis should preserve
+				% backtracking into goals marked with this
+				% feature, even if their determinism puts an
+				% at_most_zero upper bound on the number of
+				% solutions they have.
 	;	tailcall.	% This goal represents a tail call. This marker
 				% is used by deep profiling.
 
Diffing compiler/notes
Diffing debian
Diffing deep_profiler
Diffing deep_profiler/notes
Diffing doc
Diffing extras
Diffing extras/aditi
Diffing extras/cgi
Diffing extras/complex_numbers
Diffing extras/complex_numbers/samples
Diffing extras/complex_numbers/tests
Diffing extras/concurrency
Diffing extras/curs
Diffing extras/curs/samples
Diffing extras/curses
Diffing extras/curses/sample
Diffing extras/dynamic_linking
Diffing extras/graphics
Diffing extras/graphics/mercury_opengl
Diffing extras/graphics/mercury_tcltk
Diffing extras/graphics/samples
Diffing extras/graphics/samples/calc
Diffing extras/graphics/samples/maze
Diffing extras/graphics/samples/pent
Diffing extras/lazy_evaluation
Diffing extras/lex
Diffing extras/lex/samples
Diffing extras/logged_output
Diffing extras/moose
Diffing extras/moose/samples
Diffing extras/morphine
Diffing extras/morphine/non-regression-tests
Diffing extras/morphine/scripts
Diffing extras/morphine/source
Diffing extras/odbc
Diffing extras/posix
Diffing extras/quickcheck
Diffing extras/quickcheck/tutes
Diffing extras/references
Diffing extras/references/samples
Diffing extras/references/tests
Diffing extras/stream
Diffing extras/trailed_update
Diffing extras/trailed_update/samples
Diffing extras/trailed_update/tests
Diffing extras/xml
Diffing extras/xml/samples
Diffing java
Diffing java/library
Diffing java/runtime
Diffing library
Diffing profiler
Diffing robdd
Diffing runtime
--- ws86.basis//runtime/mercury_engine.h	Mon Aug 12 01:15:42 2002
+++ ws86/runtime/mercury_engine.h	Wed Aug 14 14:18:52 2002
@@ -36,6 +36,11 @@
 
 extern	MR_bool	MR_debugflag[];
 
+/*
+** These #defines, except MR_MAXFLAG, should not be used anywhere
+** except in the immediately following block of #defines.
+*/
+
 #define	MR_PROGFLAG		0
 #define	MR_GOTOFLAG		1
 #define	MR_CALLFLAG		2
@@ -51,12 +56,62 @@
 #define	MR_TABLESTACKFLAG	12
 #define	MR_UNBUFFLAG		13
 #define	MR_AGC_FLAG 		14
-#define	MR_ORDINARYREGFLAG	15
-#define	MR_ANYREGFLAG 		16
+#define	MR_ORDINARY_REG_FLAG	15
+#define	MR_ANY_REG_FLAG 	16
 #define	MR_DETAILFLAG		17
 #define	MR_MAXFLAG		18
 /* MR_DETAILFLAG should be the last real flag */
 
+/*
+** The macros control different kinds of low level debugging messages.
+** Usually, their values are all false.
+**
+** MR_progdebug controls whether we want to get several mostly explicitly
+** programmed diagnostics.
+**
+** MR_sregdebug controls whether we want to print the values of the special
+** registers (e.g. those that point to the stack) at some diagnostic points.
+**
+** MR_ordregdebug controls whether we want to print the values of the ordinary
+** registers (e.g. r1, r2 etc) at some diagnostic points.
+**
+** MR_anyregdebug controls whether we want to print the values of the any
+** registers, either special or ordinary, at some diagnostic points.
+**
+** MR_gotodebug controls whether we should generate diagnostics at gotos.
+**
+** MR_calldebug controls whether we should generate diagnostics when control
+** crosses procedure boundaries, i.e. calls, exits, redos and fails.
+**
+** MR_detstackdebug and MR_nondstackdebug control whether we should generate
+** diagnostics when incrementing and decrementing the pointers to the
+** respective stacks.
+**
+** MR_heapdebug controls whether we should generate diagnostics when we
+** allocate memory on the heap.
+**
+** MR_tabledebug controls whether we should generate diagnostics for tabling
+** operations. MR_tablestackdebug control whether these should include the
+** contents of stack segments manipulated by minimal model tabling.
+** MR_hashdebug controls whether these should include details of hash table
+** accesses.
+**
+** MR_agcdebug controls whether we should generate diagnostics for accurate
+** gc operations.
+**
+** MR_detaildebug controls whether we want more or less detail in some
+** diagnostics.
+**
+** MR_unbufdebug controls whether the runtime will make stdout and stderr
+** unbuffered.
+**
+** MR_memdebug controls whether we want to get diagnostics on the setup of
+** memory zones.
+**
+** MR_finaldebug controls whether we want to get diagnostics showing how
+** execution reaches the end of the program.
+*/
+
 #define	MR_progdebug		MR_debugflag[MR_PROGFLAG]
 #define	MR_gotodebug		MR_debugflag[MR_GOTOFLAG]
 #define	MR_calldebug		MR_debugflag[MR_CALLFLAG]
@@ -72,8 +127,8 @@
 #define	MR_tablestackdebug	MR_debugflag[MR_TABLESTACKFLAG]
 #define	MR_unbufdebug		MR_debugflag[MR_UNBUFFLAG]
 #define	MR_agc_debug		MR_debugflag[MR_AGC_FLAG]
-#define	MR_ordregdebug		MR_debugflag[MR_ORDINARYREGFLAG]
-#define	MR_anyregdebug		MR_debugflag[MR_ANYREGFLAG]
+#define	MR_ordregdebug		MR_debugflag[MR_ORDINARY_REG_FLAG]
+#define	MR_anyregdebug		MR_debugflag[MR_ANY_REG_FLAG]
 #define	MR_detaildebug		MR_debugflag[MR_DETAILFLAG]
 
 	/* 
--- ws86.basis//runtime/mercury_wrapper.c	Mon Aug 12 18:12:12 2002
+++ ws86/runtime/mercury_wrapper.c	Wed Aug 14 14:03:54 2002
@@ -106,9 +106,48 @@
 /* use readline() in the debugger even if the input stream is not a tty */
 MR_bool		MR_force_readline = MR_FALSE;
 
-/* other options */
+/*
+** Low level debugging options.
+**
+** If MR_watch_addr is not NULL, then the some of the low level debugging
+** messages will print the value it points to.
+**
+** If MR_watch_csd_addr is not NULL, then the some of the low level debugging
+** messages will print the MR_CallSiteDynamic structure it points to. Since
+** this structure is typically in memory that not part of the address space of
+** the program at started, this printing will be inhibited until
+** MR_watch_csd_started is set to true, which will happen when you call a
+** procedure whose entry label matches the string in MR_watch_csd_start_name.
+**
+** If the low level debugging of calls is enabled, MR_lld_cur_call is the
+** sequence number of the last call executed by the program.
+**
+** Getting low level debugging messages from *every* call, *every* heap
+** allocation etc usually results in an avalanche of data that buries
+** the information you are looking for, and often runs filesystems out of
+** space. Therefore we inhibit these messages unless any one three conditions
+** apply.  We implement this by making MR_lld_print_enabled, which controls
+** the printing of these messages, the sum of MR_lld_print_name_enabled,
+** MR_lld_print_csd_enabled and MR_lld_print_region_enabled, which are flags
+** implementing the three conditions. (While these four flags could be
+** booleans, that would make the cost of recomputing MR_lld_print_enabled
+** substantially higher than out current method of simply adding the integer
+** values of the three component flags.)
+**
+** One condition is MR_lld_start_block calls starting with a call to a
+** predicate whose entry label matches MR_lld_start_name. Another is
+** MR_lld_start_block calls starting with a call at which the value of the
+** MR_next_call_site_dynamic global variable matches the value in
+** MR_watch_csd_addr. The third is calls whose sequence number is in a range
+** specified by MR_lld_print_more_min_max, which should point to a string
+** containing a comma-separated list of integer intervals (the last interval
+** may be open ended).
+**
+** MR_lld_start_until and MR_lld_csd_until give the end call numbers of the 
+** blocks printed for the first two conditions. MR_lld_print_{min,max} give the
+** boundaries of the (current or next) block for the third condition.
+*/
 
-MR_bool		MR_check_space = MR_FALSE;
 MR_Word		*MR_watch_addr = NULL;
 MR_CallSiteDynamic
 		*MR_watch_csd_addr = NULL;
@@ -116,13 +155,14 @@
 char		*MR_watch_csd_start_name = NULL;
 
 unsigned long	MR_lld_cur_call = 0;
-int		MR_lld_print_enabled = 1;
+int		MR_lld_print_enabled = 0;
 int		MR_lld_print_name_enabled = 0;
 int		MR_lld_print_csd_enabled = 0;
 int		MR_lld_print_region_enabled = 0;
 
 char		*MR_lld_start_name = NULL;
-unsigned	MR_lld_start_block = 100;
+unsigned	MR_lld_start_block = 100;	/* by default, print stuff */
+						/* for a block of 100 calls */
 unsigned long	MR_lld_start_until = (unsigned long) -1;
 
 unsigned long	MR_lld_csd_until = (unsigned long) -1;
@@ -131,6 +171,9 @@
 unsigned long	MR_lld_print_max = 0;
 char		*MR_lld_print_more_min_max = NULL;
 
+/* other options */
+
+MR_bool		MR_check_space = MR_FALSE;
 static	MR_bool	benchmark_all_solns = MR_FALSE;
 static	MR_bool	use_own_timer = MR_FALSE;
 static	int	repeats = 1;
@@ -1178,64 +1221,42 @@
 	exit(1);
 } /* end usage() */
 
+/*
+** Get the next interval from *more_str_ptr, which should point to a string
+** containing a comma-separated list of integer intervals. The last interval
+** may be open ended.
+*/
+
 void
 MR_setup_call_intervals(char **more_str_ptr,
 	unsigned long *min_ptr, unsigned long *max_ptr)
 {
 	char	*more_str;
+	unsigned long	min, max;
 	int	n;
 
 	more_str = *more_str_ptr;
-	if (more_str == NULL || more_str[0] == '\0') {
-		goto end;
-	}
-
-	n = 0;
-	while (MR_isdigit(more_str[0])) {
-		n = n * 10 + more_str[0] - '0';
-		more_str++;
-	}
-
-	if (n == 0) {
-		goto end;
-	}
-
-	*min_ptr = n;
-	if (more_str[0] == '-' && more_str[1] == '\0') {
-		*max_ptr = (unsigned long) -1;
-		*more_str_ptr = NULL;
-		return;
-	}
-
-	if (more_str[0] != '-') {
-		goto end;
-	}
-
-	more_str++;
 
-	n = 0;
-	while (MR_isdigit(more_str[0])) {
-		n = n * 10 + more_str[0] - '0';
-		more_str++;
-	}
-
-	if (n == 0) {
-		goto end;
-	}
-
-	*max_ptr = n;
+	/* Relying on the return value from sscanf() with %n is
+	   non-portable, so we need to call sscanf() twice here. */
+	if (sscanf(more_str, "%lu-%lu", &min, &max) == 2) {
+		sscanf(more_str, "%lu-%lu%n", &min, &max, &n);
+		more_str += n;
 	if (more_str[0] == ',') {
 		more_str++;
 	}
+	} else if (sscanf(more_str, "%lu-", &min) == 1) {
+		more_str = NULL;
+		max = (unsigned long) -1;
+	} else {
+		more_str = NULL;
+		min = 0;
+		max = (unsigned long) -1;
+	}
 
 	*more_str_ptr = more_str;
-	return;
-
-end:
-	*more_str_ptr = NULL;
-	*min_ptr = (unsigned long) -1;
-	*max_ptr = 0;
-	return;
+	*min_ptr = min;
+	*max_ptr = max;
 }
 
 /*---------------------------------------------------------------------------*/
Diffing runtime/GETOPT
Diffing runtime/machdeps
Diffing samples
Diffing samples/c_interface
Diffing samples/c_interface/c_calls_mercury
Diffing samples/c_interface/cplusplus_calls_mercury
Diffing samples/c_interface/mercury_calls_c
Diffing samples/c_interface/mercury_calls_cplusplus
Diffing samples/c_interface/mercury_calls_fortran
Diffing samples/c_interface/simpler_c_calls_mercury
Diffing samples/c_interface/simpler_cplusplus_calls_mercury
Diffing samples/diff
Diffing samples/muz
Diffing samples/rot13
Diffing samples/solutions
Diffing samples/tests
Diffing samples/tests/c_interface
Diffing samples/tests/c_interface/c_calls_mercury
Diffing samples/tests/c_interface/cplusplus_calls_mercury
Diffing samples/tests/c_interface/mercury_calls_c
Diffing samples/tests/c_interface/mercury_calls_cplusplus
Diffing samples/tests/c_interface/mercury_calls_fortran
Diffing samples/tests/c_interface/simpler_c_calls_mercury
Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
Diffing samples/tests/diff
Diffing samples/tests/muz
Diffing samples/tests/rot13
Diffing samples/tests/solutions
Diffing samples/tests/toplevel
Diffing scripts
Diffing tests
Diffing tests/benchmarks
Diffing tests/debugger
Diffing tests/debugger/declarative
Diffing tests/dppd
Diffing tests/general
Diffing tests/general/accumulator
Diffing tests/general/structure_reuse
Diffing tests/hard_coded
Diffing tests/hard_coded/exceptions
Diffing tests/hard_coded/purity
Diffing tests/hard_coded/sub-modules
Diffing tests/hard_coded/typeclasses
Diffing tests/invalid
Diffing tests/invalid/purity
Diffing tests/misc_tests
Diffing tests/recompilation
Diffing tests/tabling
Diffing tests/term
Diffing tests/valid
Diffing tests/warnings
Diffing tools
--- ws86.basis//tools/lmc	Sat Aug 10 23:57:54 2002
+++ ws86/tools/lmc	Wed Aug 14 14:22:05 2002
@@ -22,6 +22,15 @@
 # pass -g to the C compiler and to the linker by setting the environment
 # variable MMC_CDEBUG to the string "true".
 #
+# You can also ask the script to enable low level debugging of the generated
+# code by setting the environment variable MMC_LOWLEVEL_DEBUG to the string
+# "true".
+#
+# You can ask for additional C flags to compile with by setting the environment
+# variable MMC_ADDED_CFLAGS to those flags. Setting up this environment
+# variable one can be more convenient than repeatedbly supplying
+"--cflag <flag>" arguments on the command line.
+#
 # If you want to track down some low level bug, you can ask this script to
 # execute the Mercury compiler under gdb by setting the environment variable
 # MMC_UNDER_GDB to the string "true".
@@ -64,9 +73,9 @@
 	CDEBUG_FLAGS=""
 fi
 
-if test "$ADDED_CFLAGS" != ""
+if test "$MMC_ADDED_CFLAGS" != ""
 then
-	CDEBUG_FLAGS="$CDEBUG_FLAGS --cflags \"$ADDED_CFLAGS\""
+	CDEBUG_FLAGS="$CDEBUG_FLAGS --cflags \"$MMC_ADDED_CFLAGS\""
 fi
 
 C_FLAGS="--c-include-directory $WORKSPACE/trace --c-include-directory $WORKSPACE/library --c-include-directory $WORKSPACE/library/Mercury/mihs --c-include-directory $WORKSPACE/runtime --c-include-directory $WORKSPACE/boehm_gc --c-include-directory $WORKSPACE/boehm_gc/include"
Diffing trace
Diffing util
Diffing vim
Diffing vim/after
Diffing vim/ftplugin
Diffing vim/syntax
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list