[m-rev.] diff: six percent speedup
Zoltan Somogyi
zs at cs.mu.OZ.AU
Wed Mar 30 10:54:14 AEST 2005
These are the benchmark results.
EXTRA_MCFLAGS =
EXTRA_CFLAGS = -DMR_CHECK_DU_EQ
GRADE = asm_fast.gc
mercury_compile.01 average of 12 with ignore=1 49.44
EXTRA_MCFLAGS =
EXTRA_CFLAGS =
GRADE = asm_fast.gc
mercury_compile.02 average of 12 with ignore=1 52.56
Zoltan.
runtime/mercury_unify_compare_body.h:
Add a mechanism, conditional on #ifdef MR_CHECK_DU_EQ, for testing
whether two values are bit-for-bit identical before invoking any of
the more specific unify or compare code.
Fix some old bugs which showed up only with -DMR_COMPARE_BY_RTTI:
we were invoking some macros with the wrong number of arguments.
runtime/mercury_conf_param.h:
Document MR_CHECK_DU_EQ. Turn it on unless another macro,
MR_DISABLE_CHECK_DU_EQ, is defined. This improves performance by
six percent. (Thanks to Ralph for the reminder to evaluate this again.
When I tried this several years ago, it was a performance loss.)
tests/debugger/uci.exp2:
Add this new expected output file for this test. While uci.exp contains
the expected output without -DMR_CHECK_DU_EQ, uci.exp2 contains the
expected output with it, since we no longer get calls to the
type-specific unify and compare predicates in some cases.
cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing mdbcomp
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
Index: runtime/mercury_conf_param.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_conf_param.h,v
retrieving revision 1.80
diff -u -b -r1.80 mercury_conf_param.h
--- runtime/mercury_conf_param.h 24 Mar 2005 01:58:04 -0000 1.80
+++ runtime/mercury_conf_param.h 27 Mar 2005 01:39:07 -0000
@@ -119,6 +119,13 @@
** Add extra backwards compatibility with C code using obsolete low-level
** constructs, e.g. referring to variables and macros without their MR_
** prefixes.
+**
+** MR_CHECK_DU_EQ
+** When unifying or comparing two values of discriminated union types,
+** check first whether the values (which are usually pointers) are equal.
+**
+** MR_DISABLE_CHECK_DU_EQ
+** MR_CHECK_DU_EQ is turned on by default; this macro prevents this.
*/
/*
@@ -514,6 +521,10 @@
#undef MR_DEEP_PROFILING_PORT_COUNTS
#undef MR_DEEP_PROFILING_TIMING
#undef MR_DEEP_PROFILING_MEMORY
+#endif
+
+#ifndef MR_DISABLE_CHECK_DU_EQ
+ #define MR_CHECK_DU_EQ
#endif
/*---------------------------------------------------------------------------*/
Index: runtime/mercury_unify_compare_body.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_unify_compare_body.h,v
retrieving revision 1.39
diff -u -b -r1.39 mercury_unify_compare_body.h
--- runtime/mercury_unify_compare_body.h 14 Dec 2004 01:07:25 -0000 1.39
+++ runtime/mercury_unify_compare_body.h 26 Mar 2005 01:56:00 -0000
@@ -181,6 +181,19 @@
int arity;
int i;
+ #ifdef MR_CHECK_DU_EQ
+ #ifdef select_compare_code
+ if (x == y) {
+ return_compare_answer(builtin, user_by_rtti, 0,
+ MR_COMPARE_EQUAL);
+ }
+ #else
+ if (x == y) {
+ return_unify_answer(builtin, user_by_rtti, 0, MR_TRUE);
+ }
+ #endif
+ #endif
+
#ifdef select_compare_code
#define MR_find_du_functor_desc(data, data_value, functor_desc) \
@@ -237,7 +250,7 @@
y_ptag = MR_tag(y);
if (x_ptag != y_ptag) {
- return_unify_answer(user, MR_FALSE);
+ return_unify_answer(builtin, user_by_rtti, 0, MR_FALSE);
}
ptaglayout = &MR_type_ctor_layout(type_ctor_info).
@@ -251,7 +264,8 @@
y_sectag = MR_unmkbody(y_data_value);
if (x_sectag != y_sectag) {
- return_unify_answer(user, MR_FALSE);
+ return_unify_answer(builtin, user_by_rtti, 0,
+ MR_FALSE);
}
break;
@@ -261,7 +275,8 @@
y_sectag = y_data_value[0];
if (x_sectag != y_sectag) {
- return_unify_answer(user, MR_FALSE);
+ return_unify_answer(builtin, user_by_rtti, 0,
+ MR_FALSE);
}
break;
@@ -407,6 +422,19 @@
case MR_TYPECTOR_REP_FOREIGN:
case MR_TYPECTOR_REP_STABLE_FOREIGN:
+ #ifdef MR_CHECK_DU_EQ
+ #ifdef select_compare_code
+ if (x == y) {
+ return_compare_answer(builtin, user_by_rtti, 0,
+ MR_COMPARE_EQUAL);
+ }
+ #else
+ if (x == y) {
+ return_unify_answer(builtin, user_by_rtti, 0, MR_TRUE);
+ }
+ #endif
+ #endif
+
/*
** We call the type-specific compare routine as
** `CompPred(...ArgTypeInfos..., Result, X, Y)' is det.
@@ -475,8 +503,8 @@
MR_TypeInfo arg_type_info;
/* type_infos are counted from one */
- arg_type_info = MR_TYPEINFO_GET_VAR_ARITY_ARG_VECTOR(
- type_info)[i + 1];
+ arg_type_info =
+ MR_TYPEINFO_GET_VAR_ARITY_ARG_VECTOR(type_info)[i + 1];
#ifdef select_compare_code
MR_save_transient_registers();
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
Index: tests/debugger/uci.exp2
===================================================================
RCS file: tests/debugger/uci.exp2
diff -N tests/debugger/uci.exp2
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/debugger/uci.exp2 27 Mar 2005 01:32:35 -0000
@@ -0,0 +1,80 @@
+ 1: 1 1 CALL pred uci.main/2-0 (det) uci.m:17
+mdb> echo on
+Command echo enabled.
+mdb> context none
+Contexts will not be printed.
+mdb> register --quiet
+mdb> break -A unif*uci.
+ 0: + stop interface __Unify__ for uci.t4/4-0 (semidet)
+ 1: + stop interface __Unify__ for uci.t3/3-0 (semidet)
+ 2: + stop interface __Unify__ for uci.t2/2-0 (semidet)
+ 3: + stop interface __Unify__ for uci.t1/1-0 (semidet)
+ 4: + stop interface __Unify__ for uci.t0/0-0 (semidet)
+ 5: + stop interface __Unify__ for uci.i/3-0 (semidet)
+mdb> break -A comp*uci.
+ 6: + stop interface __Compare__ for uci.t4/4-0 (det)
+ 7: + stop interface __Compare__ for uci.t3/3-0 (det)
+ 8: + stop interface __Compare__ for uci.t2/2-0 (det)
+ 9: + stop interface __Compare__ for uci.t1/1-0 (det)
+10: + stop interface __Compare__ for uci.t0/0-0 (det)
+11: + stop interface __Compare__ for uci.i/3-0 (det)
+mdb> c
+ 16: 8 3 CALL __Compare__ for uci.t1/1-0 (det)
+mdb> print goal
+__Compare__(_, b1(11), a1(1))
+mdb> c
+ 17: 8 3 EXIT __Compare__ for uci.t1/1-0 (det)
+mdb> print goal
+__Compare__('>', b1(11), a1(1))
+mdb> c
+ 34: 15 3 CALL __Compare__ for uci.t3/3-0 (det)
+mdb> print goal
+__Compare__(_, b3(11, 12, 13), a3(1, 2, 3))
+mdb> c
+ 35: 15 3 EXIT __Compare__ for uci.t3/3-0 (det)
+mdb> print goal
+__Compare__('>', b3(11, 12, 13), a3(1, 2, 3))
+mdb> c
+ 44: 19 3 CALL __Compare__ for uci.t4/4-0 (det)
+mdb> print goal
+__Compare__(_, a4(1, 2, 3, 4), b4(11, 12, 13, 14))
+mdb> c
+ 45: 19 3 EXIT __Compare__ for uci.t4/4-0 (det)
+mdb> print goal
+__Compare__('<', a4(1, 2, 3, 4), b4(11, 12, 13, 14))
+mdb> c
+ 70: 29 3 CALL __Unify__ for uci.t2/2-0 (semidet)
+mdb> print goal
+__Unify__(a2(1, 2), b2(11, 12))
+mdb> c
+ 71: 29 3 FAIL __Unify__ for uci.t2/2-0 (semidet)
+mdb> print goal
+__Unify__(a2(1, 2), b2(11, 12))
+mdb> c
+ 88: 36 3 CALL __Unify__ for uci.t4/4-0 (semidet)
+mdb> print goal
+__Unify__(a4(1, 2, 3, 4), b4(11, 12, 13, 14))
+mdb> c
+ 89: 36 3 FAIL __Unify__ for uci.t4/4-0 (semidet)
+mdb> print goal
+__Unify__(a4(1, 2, 3, 4), b4(11, 12, 13, 14))
+mdb> c
+ 98: 40 3 CALL __Compare__ for uci.i/3-0 (det)
+mdb> print goal
+__Compare__(_, ai(1), bi(11))
+mdb> c
+ 99: 40 3 EXIT __Compare__ for uci.i/3-0 (det)
+mdb> print goal
+__Compare__('<', ai(1), bi(11))
+mdb> c
+0 lt
+1 ge
+2 ge
+3 ge
+4 lt
+0 ne
+1 eq
+2 ne
+3 eq
+4 ne
+i lt
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: 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