[m-dev.] diff: cleanup of tabling, addendum 2
Zoltan Somogyi
zs at cs.mu.OZ.AU
Fri Jan 7 19:21:40 AEDT 2000
I accidentally included an old diff in the previous mail.
Estimated hours taken: 1
Address Fergus's after-commit comments.
library/io.m:
Introduce a new predicate io__report_stats/3 which does the job
of any one of the three previous statistics reporting predicates
depending on the value of a selector; this is to make the predicate
implementation-independent.
Remove the recently added io__report_tabling_stats as a separate
predicate. Make the old io__report_full_memory_stats obsolete.
Both functionalities are reachable through the new predicate.
runtime/mercury_tabling.c:
Fix some syntax errors.
Fix a bug: for tabling purposes floats should be compared bit by bit,
not according to IEEE semantics.
Conform to the naming conventions for macros.
Zoltan.
cvs diff: Diffing .
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/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
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/dynamic_linking
cvs diff: Diffing extras/graphics
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/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
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/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing library
Index: library/io.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/io.m,v
retrieving revision 1.192
diff -u -b -r1.192 io.m
--- library/io.m 2000/01/03 08:52:59 1.192
+++ library/io.m 2000/01/07 08:19:07
@@ -978,14 +978,35 @@
% Write complete memory usage statistics to stderr,
% including information about all procedures and types.
% (You need to compile with memory profiling enabled.)
+ %
+ % OBSOLETE: call io__report_stats/3 instead, with the first
+ % specified as "full_memory_stats".
+:- pragma obsolete(io__report_full_memory_stats/2).
:- pred io__report_full_memory_stats(io__state, io__state).
:- mode io__report_full_memory_stats(di, uo) is det.
- % Write statistics about the operation of the tabling system to stderr.
+ % Write statistics to stderr; what statistics will be written
+ % is controlled by the first argument, which acts a selector.
+ % What selector values cause what statistics to be printed
+ % is implementation defined.
+ %
+ % The Melbourne implementation supports the following selectors:
+ %
+ % "standard" Writes memory/time usage statistics.
+ %
+ % "full_memory_stats" Writes complete memory usage statistics,
+ % including information about all procedures
+ % and types. Requires compilation with
+ % memory profiling enabled.
+ %
+ % "tabling" Writes statistics about the internals
+ % of the tabling system. Requires the runtime
+ % to have been compiled with the macro
+ % MR_TABLE_STATISTICS defined.
-:- pred io__report_tabling_stats(io__state, io__state).
-:- mode io__report_tabling_stats(di, uo) is det.
+:- pred io__report_stats(string, io__state, io__state).
+:- mode io__report_stats(in, di, uo) is det.
/*** no longer supported, sorry
:- pred io__gc_call(pred(io__state, io__state), io__state, io__state).
@@ -2471,23 +2492,30 @@
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
-
-% memory management predicates
-:- pragma promise_pure(io__report_stats/2).
+% statistics reporting predicates
io__report_stats -->
- { impure report_stats }.
+ io__report_stats("standard").
-:- pragma promise_pure(io__report_full_memory_stats/2).
-
io__report_full_memory_stats -->
- { impure report_full_memory_stats }.
+ io__report_stats("full_memory_stats").
-:- pragma promise_pure(io__report_tabling_stats/2).
+:- pragma promise_pure(io__report_stats/3).
-io__report_tabling_stats -->
- { impure private_builtin__table_report_statistics }.
+io__report_stats(Selector) -->
+ { Selector = "standard" ->
+ impure report_stats
+ ; Selector = "full_memory_stats" ->
+ impure report_full_memory_stats
+ ; Selector = "tabling" ->
+ impure private_builtin__table_report_statistics
+ ;
+ string__format(
+ "io__report_stats: selector `%s' not understood",
+ [s(Selector)], Message),
+ error(Message)
+ }.
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
cvs diff: Diffing profiler
cvs diff: Diffing runtime
Index: runtime/mercury_tabling.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_tabling.c,v
retrieving revision 1.18
diff -u -b -r1.18 mercury_tabling.c
--- runtime/mercury_tabling.c 2000/01/03 08:53:07 1.18
+++ runtime/mercury_tabling.c 2000/01/07 08:07:40
@@ -9,6 +9,7 @@
#include "mercury_type_info.h"
#include "mercury_ho_call.h"
#include <stdio.h>
+#include <string.h>
/*---------------------------------------------------------------------------*/
@@ -180,27 +181,27 @@
#endif
#ifdef MR_TABLE_STATISTICS
- #define declare_probe_count Integer probe_count = 0;
- #define record_probe_count do { probe_count++; } while (0)
- #define record_lookup_count do { \
+ #define DECLARE_PROBE_COUNT Integer probe_count = 0;
+ #define record_probe_count() do { probe_count++; } while (0)
+ #define record_lookup_count() do { \
MR_table_hash_lookup_probes += \
probe_count; \
MR_table_hash_lookups++; \
} while (0)
- #define record_insert_count do { \
+ #define record_insert_count() do { \
MR_table_hash_insert_probes += \
probe_count; \
MR_table_hash_inserts++; \
} while (0)
- #define record_resize_count do { MR_table_hash_resizes++; } while (0)
- #define record_alloc_count do { MR_table_hash_allocs++; } while (0)
+ #define record_resize_count() do { MR_table_hash_resizes++; } while (0)
+ #define record_alloc_count() do { MR_table_hash_allocs++; } while (0)
#else
- #define declare_probe_count
- #define record_probe_count ((void) 0)
- #define record_lookup_count ((void) 0)
- #define record_insert_count ((void) 0)
- #define record_resize_count ((void) 0)
- #define record_alloc_count ((void) 0)
+ #define DECLARE_PROBE_COUNT
+ #define record_probe_count() ((void) 0)
+ #define record_lookup_count() ((void) 0)
+ #define record_insert_count() ((void) 0)
+ #define record_resize_count() ((void) 0)
+ #define record_alloc_count() ((void) 0)
#endif
#ifdef MR_TABLE_DEBUG
@@ -288,7 +289,7 @@
table_type *slot; \
Integer abs_hash; \
Integer home; \
- declare_probe_count \
+ DECLARE_PROBE_COUNT \
\
debug_key_msg(key, key_format, key_cast); \
\
@@ -313,7 +314,7 @@
new_threshold = (Integer) ((float) new_size \
* MAX_LOAD_FACTOR); \
debug_resize_msg(table->size, new_size, new_threshold); \
- record_resize_count; \
+ record_resize_count(); \
\
new_hash_table = MR_TABLE_NEW_ARRAY(MR_HashTableSlotPtr, \
new_size); \
@@ -358,10 +359,10 @@
slot = table->hash_table[home].table_field; \
while (slot != NULL) { \
debug_probe_msg(home); \
- record_probe_count; \
+ record_probe_count(); \
\
if (equal_keys(key, slot->key)) { \
- record_lookup_count; \
+ record_lookup_count(); \
debug_lookup_msg(home); \
return &slot->data; \
} \
@@ -370,7 +371,7 @@
} \
\
debug_insert_msg(home); \
- record_insert_count; \
+ record_insert_count(); \
\
if (table->freeleft == 0) { \
MR_AllocRecord *record; \
@@ -384,7 +385,7 @@
record->next = table->allocrecord; \
table->allocrecord = record; \
\
- record_alloc_count; \
+ record_alloc_count(); \
} \
\
slot = table->freespace.table_field; \
@@ -414,10 +415,16 @@
#undef key_cast
#undef table_type
#undef table_field
-#undef hash(key)
-#undef equal_keys(k1, k2)
+#undef hash
+#undef equal_keys
}
+/*
+** Note that the equal_keys operation should compare two floats for
+** bit-for-bit equality. This is different from the usual == operator
+** in the presence of NaNs, infinities, etc.
+*/
+
MR_TrieNode
MR_float_hash_lookup_or_add(MR_TrieNode t, Float key)
{
@@ -426,15 +433,15 @@
#define table_type MR_FloatHashTableSlot
#define table_field float_slot_ptr
#define hash(key) (hash_float(key))
-#define equal_keys(k1, k2) (k1 == k2)
+#define equal_keys(k1, k2) (memcmp(&k1, &k2, sizeof(Float)) == 0)
MR_GENERIC_HASH_LOOKUP_OR_ADD
#undef key_format
#undef key_cast
#undef debug_search_key
#undef table_type
#undef table_field
-#undef hash(key)
-#undef equal_keys(k1, k2)
+#undef hash
+#undef equal_keys
}
MR_TrieNode
@@ -452,8 +459,8 @@
#undef debug_search_key
#undef table_type
#undef table_field
-#undef hash(key)
-#undef equal_keys(k1, k2)
+#undef hash
+#undef equal_keys
}
/*---------------------------------------------------------------------------*/
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 scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
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/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/misc_tests
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 trial
cvs diff: Diffing util
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list