mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-23 05:13:48 +00:00
083d376e6598628362ee91c2da170febd83590f4
8 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
bc0e8e8129 | Avoid long test times on this test case. | ||
|
|
3d1acbb7f4 | Update the style of the tabling tests. | ||
|
|
fdd141bf77 |
Clean up the tests in the other test directories.
tests/invalid/*.{m,err_exp}:
tests/misc_tests/*.m:
tests/mmc_make/*.m:
tests/par_conj/*.m:
tests/purity/*.m:
tests/stm/*.m:
tests/string_format/*.m:
tests/structure_reuse/*.m:
tests/submodules/*.m:
tests/tabling/*.m:
tests/term/*.m:
tests/trailing/*.m:
tests/typeclasses/*.m:
tests/valid/*.m:
tests/warnings/*.{m,exp}:
Make these tests use four-space indentation, and ensure that
each module is imported on its own line. (I intend to use the latter
to figure out which subdirectories' tests can be executed in parallel.)
These changes usually move code to different lines. For the tests
that check compiler error messages, expect the new line numbers.
browser/cterm.m:
browser/tree234_cc.m:
Import only one module per line.
tests/hard_coded/boyer.m:
Fix something I missed.
|
||
|
|
40d69de28a |
Make doubly sure that the tabling tests aren't run in grades that do not
support tabling. (The Makefiles in tests directory should prevent this, but in at least one grade on neptune this isn't currently happening and it's rendering that machine unusable - I'll fix the Makefile issue separately.) tests/tabling/*.m: Add require_feature_set pragmas to all the tabling tests to ensure they aren't accidently run in grades that don't support tabling. |
||
|
|
bbe6de9387 |
Make tabling statistics much more useful, and avoid core dumps while printing
Estimated hours taken: 30 Branches: main Make tabling statistics much more useful, and avoid core dumps while printing them (thereby fixing bug #23 in Mantis). runtime/mercury_tabling.h: Expand the set of statistics we can gather about tabling (starting to gather information about memory consumption). Put the statistics into logical groups: enum functors, non-enum du functors, hash tables, and the expandable table used for I/O tabling. For du types and polymorphic types, we can gather different statistics for different parts of a term. We used to use one field to gather more than one related kind of count, but these are now separated. Group the MR_ProcTableInfo struct fields relating to statistics into substructures. The substructures describing a call or answer table have their own substructures giving the statistics about the individual steps; put these in parallel with the descriptions of the steps themselves. Put those substructures into two-element arrays to allow them to be handled uniformly. runtime/mercury_types.h: Add the typedefs needed by mercury_tabling.h. runtime/mercury_tabling_macros.h: Conform to the modified classification of tabling categories. runtime/mercury_tabling.c: runtime/mercury_hash_lookup_or_add_body.h: runtime/mercury_table_int_fix_index_body.h: runtime/mercury_table_int_start_index_body.h: runtime/mercury_table_type_body.h: runtime/mercury_tabling_stats_defs.h: runtime/mercury_tabling_stats_nodefs.h: runtime/mercury_tabling_stats_undefs.h: Gather the modified and expanded set of statistics. Use more meaningful names (with MR_ prefixes) for macros. library/table_builtin.m: library/table_statistics.m: Move the material relating to statistics that used to be in table_builtin.m to the new module table_statistics.m. This is necessary because table_builtin.m is deliberately not included in the library documentation, yet users needs to know how to print out and interpret tabling statistics. Expand the code for handling statistics, adding predicates for printing them together with (hopefully explanatory) labels. Make it all work with the new runtime data structures. library/library.m: Include the new library module. mdbcomp/prim_data.m: Provide a way to refer to the tabling statistics module. compiler/hlds_pred.m: Add utility function to compute the kind of statistics we gather for a given kind of tabling step. compiler/rtti.m: Change the compiler's representation of tabling's runtime data structures to conform to the change to runtime/mercury_tabling.h. Replace a bool with a purpose-designed type (is_array), and add other similar types (call_or_answer_table, curr_or_prev_table). compiler/rtti_out.m: compiler/llds_out.m: Output the updated data structures. compiler/ml_code_gen.m: Generate the updated data structures. compiler/table_gen.m: Update the C code we generate to gather statistics. Gather the extra information needed by the updated data structures in the compiler (to fill in the updated data structures in the runtime). compiler/mlds.m: Add a new kind of constant, one that has just a name. This allows ml_code_gen.m to avoid lying about the type of constants of enum tyes (such as the kind of tabling stats we gather for a step). compiler/modules.m: Import the new table_statistics module automatically if any tabling pragma asks for statistics. compiler/add_pragma.m: compiler/hlds_out.m: compiler/llds.m: compiler/mlds_to_c.m: compiler/mlds_to_gcc.m: compiler/mlds_to_il.m: compiler/mlds_to_java.m: compiler/mlds_to_managed.m: trace/mercury_trace_cmd_developer.c: Conform to the changes above. tests/tabling/fib_stats.{m,exp}: tests/tabling/specified_stats.{m,exp}: New test cases to the test tabling statistics. tests/tabling/Mmakefile: Enable the new test cases. tests/tabling/fib.m: tests/tabling/specified.m: Clean up the code of these test cases, which were used as the basis of the new test cases. |
||
|
|
74ce85d476 |
Provide a mechanism for collecting statistics about tabling operations,
Estimated hours taken: 60
Branches: main
Provide a mechanism for collecting statistics about tabling operations,
and provide a much more convenient mechanism for resetting tables.
Since it would too complex to do this while preserving the capability
of setting --tabling-via-extra-args to no, eliminate that capability
and the option. That option was useful only for measurements of the
performance boost from setting --tabling-via-extra-args to yes in any case,
so users lose no functionality.
Previously, the only way to debug the low level details of the tabling
mechanism was to build a runtime with a specific C macro (MR_TABLE_DEBUG)
and link with that runtime; this was cumbersome. Change that so that
every one of the debuggable tabling macros has a bool argument that says
whether debugging is enabled or not. The compiler can then set this to
MR_TRUE if the new option --table-debug is given, and to MR_FALSE otherwise.
If set to MR_FALSE, the C compiler should optimize away the debug code,
with zero impact on program size or speed.
Since these changes to macros require nontrivial bootstrapping, which we don't
want to do unnecessarily, modify the interface of the tabling macros as
required to support size limits on tables. This diff also implements the
parsing of size limit specifications on tables, but does not implement them
yet; that is for a future change.
To make the syntax simpler, this diff deletes the free-standing fast_loose_memo
pragma. The same functionality is now available with a fast_loose annotation
on an ordinary memo pragma.
Make a bunch of changes to improve readability and maintainability
in the process. These mostly take the form of renaming ambiguous and/or
not sufficiently expressive function symbols.
runtime/mercury_stack_layout.h:
runtime/mercury_tabling.h:
Move the description of structure of tables from mercury_stack_layout.h
to mercury_tabling.h, since we now need it for statistics even if
execution tracing is not enabled.
Modify those data structures to have room for the statistics.
Don't distinguish "strict", "fast_loose" and "specified" memoing
as separate eval methods; treat them as just different kinds
of the same eval method: "memo".
Remove underscores from the names of some types that the style guide
says shouldn't be there.
runtime/mercury_tabling_preds.h:
runtime/mercury_tabling_macros.h:
Modify the approach we use for macros that implement the predicates
of library/table_builtin.m. Instead of selecting between debug and
nondebug based on whether MR_TABLE_DEBUG is defined or not, add
an explicit argument controlling this to each debuggable macro.
The advantage of the new arrangement is that it scales. Another
argument controls whether we are computing statistics (and if yes,
where do we put it), and a third argument controls whether we maintain
back links in the tries and hash tables (this last argument is present
but is ignored for now).
Since the values of the arguments will be known when the .c files
containing calls to these macros are compiled, we pay the space and
time cost of debugging, statistics gathering and the maintenance of
back links if and only we need the revelant functionality.
Provide macros for limited backward compatibility with the old set
of macros; these allow workspaces created by old compilers to work
with the new macros in the runtime. The old macros followed the
naming scheme MR_table_*, the new ones are named MR_tbl_*.
runtime/mercury_table_int_fix_index_body.h:
runtime/mercury_table_int_start_index_body.h:
runtime/mercury_table_type_body.h:
New files containing parts of the old mercury_tabling.c. Each of these
files contains the body of the functions that used to be in
mercury_tabling.c. The new mercury_tabling.c #includes each of these
files more than once, to provide more than one variant of the old
function. These variants differ in aspects such as whether debugging
is enabled or statistics is being collected. Each variant therefore
incurs only the time costs it needs to. (We pay the space cost of
having all these variants all the time of course, but this cost
is negligible.)
runtime/mercury_tabling_stats_defs.h:
runtime/mercury_tabling_stats_nodefs.h:
runtime/mercury_tabling_stats_undefs.h:
New files that serve as wrappers around the newly #included files,
controlling how they handle statistics.
runtime/mercury_tabling.c:
Delete functions now in the new files, and #include them instead.
Delete the data structures that used to contain summary statistics;
the new approach keeps statistics in compiler-generated,
procedure-specific data structures.
runtime/mercury_trace_base.c:
Use the new versions of the tabling macros to access the I/O table.
runtime/mercury_type_info.h:
Update some documentation for the movement of code out of
mercury_tabling.c.
runtime/mercury_types.h:
Provide forward declarations of the identifiers denoting the new types
in mercury_tabling.h.
runtime/mercury_grade.h:
Increment the exec trace version number, since we have changed
a part of the exec trace structure.
runtime/mercury_bootstrap.h:
Fix some temporary issues that arise from some renames above.
runtime/mercury_hash_lookup_or_add_body.h:
Fix comment.
runtime/Mmakefile:
Mention the new files and the dependencies that involve them.
library/table_builtin.m:
Provide a type for representing statistics and a predicate for
printing statistics.
Use the updated versions of the macros in
runtime/mercury_tabling_preds.h.
compiler/prog_item.m:
Change representation of tabling pragmas to allow room for the new
attributes.
Allow an item to be marked as being generated by the compiler
as a result of a pragma memo attribute. We use this for the reset
and statistics predicates.
compiler/mercury_to_mercury.m:
Write out the new attributes of the tabling pragma.
compiler/prog_data.m:
compiler/hlds_data.m:
Change the cons_id that used to refer to a procedure's call table root
to refer to the entirety of the new data structure now containing it.
The compiler now needs a way to refer to the other components of this
new data structure, since it contains the statistics.
As in the runtime, don't distinguish "strict", "fast_loose" and
"specified" memoing as separate eval methods; treat them as just
different kinds of the same eval method: "memo".
Rename some of the uses of the function symbols "c", "java", "il".
compiler/hlds_pred.m:
Add an extra field in proc_infos for storing any tabling attributes.
Change the existing proc_info field that records information about
the kinds of arguments of tabled procedures to record the information
needed by the debugger too. This was needed to allow us to shift all
the RTTI for procedure-specific tables (as opposed to the RTTI for
the global I/O table) from mercury_stack_layout.h to mercury_tabling.h
without duplicating the data (which would be a maintenance problem).
Reformat some comments to make them easier to read.
compiler/layout.m:
compiler/layout_out.m:
Delete the part of the exec trace information that used to record
RTTI for tables, since this information is not generated only as
part of the debugger data structures anymore.
compiler/prog_io_pragma.m:
Recognize the updated syntax for tabling pragmas.
compiler/add_pragma.m:
When processing tabling pragmas for inclusion in the HLDS, create
any reset and statistics predicates they ask for.
compiler/make_hlds_passes.m:
Export a predicate now needed by add_pragma.m.
Handle the new attributes on tabling pragmas
compiler/globals.m:
Change the function symbols of the types describing backends and
foreign languages to say what they are. Previously, both types (as well
as several others) included the function symbol "c"; now, they are
target_c and lang_c respectively.
compiler/table_gen.m:
Implement the changes described at the top.
When passing around varsets and vartypes, pass the arguments in the
standard order.
compiler/goal_util.m:
compiler/hlds_goal.m:
When passing around varsets and vartypes, pass the arguments in the
standard order.
compiler/rtti.m:
Provide types for representing the runtime's data structures for
tabling (which are now significantly more complex than a single word)
and predicates for manipulating them, for use by both the ml and ll
backends.
compiler/llds.m:
Replace the comp_gen_c_var type with the tabling_info_struct type,
which contains the information needed to create the per-procedure
tabling data structures.
Replace references to call tables with references to the various
components of the new tabling data structures.
compiler/llds_out.m:
Add code to write out tabling_info_structs.
Delete the code required for the old, hacky way of resetting tables.
Reorder some code more logically.
compiler/proc_gen.m:
Generate tabling_info_structs.
compiler/stack_layout.m:
Don't generate the information now generated in proc_gen.m.
compiler/mlds.m:
Give mlds_proc_labels their own function symbols, instead of using
a pair. Rename some other function symbols to avoid ambiguity and add
expressiveness.
Provide for the representation of references to the various components
of the new tabling data structures, and for the representation of their
types.
compiler/ml_code_gen.m:
When generating code for a tabled procedure, generate also the data
structures required for its table.
compiler/rtti_to_mlds.m:
compiler/ml_util.m:
Move some predicates from rtti_to_mlds.m to ml_util.m, since we
now also want to call them from ml_code_gen.m.
compiler/name_mangle.m:
Add some utility predicates.
compiler/options.m:
Delete the old --allow-table-reset option.
Add the new --table-debug option.
Comment out an implementor-only option.
compiler/add_pred.m:
compiler/add_solver.m:
compiler/add_trail_ops.m:
compiler/add_type.m:
compiler/bytecode_gen.m:
compiler/code_gen.m:
compiler/compile_target_code.m:
compiler/complexity.m:
compiler/dependency_graph.m:
compiler/det_report.m:
compiler/export.m:
compiler/fact_table.m:
compiler/foreign.m:
compiler/global_data.m:
compiler/globals.m:
compiler/handle_options.m:
compiler/higher_order.m:
compiler/hlds_code_util.m:
compiler/hlds_data.m:
compiler/hlds_goal.m:
compiler/hlds_out.m:
compiler/inlining.m:
compiler/intermod.m:
compiler/make.dependencies.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/make_hlds_passes.m:
compiler/mercury_compile.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_switch_gen.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_ilasm.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
compiler/modes.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/polymorphism.m:
compiler/pragma_c_gen.m:
compiler/proc_label.m:
compiler/prog_data.m:
compiler/prog_foreign.m:
compiler/prog_item.m:
compiler/prog_mutable.m:
compiler/prog_out.m:
compiler/prog_rep.m:
compiler/prog_util.m:
compiler/recompilation.version.m:
compiler/size_prof.m:
compiler/special_pred.m:
compiler/switch_util.m:
compiler/transform_llds.m:
compiler/tupling.m:
compiler/type_ctor_info.m:
compiler/unify_gen.m:
Conform to the changes above, and/or improve some comments.
mdbcomp/prim_data.m:
Make the names of the function symbols of the proc_label type more
expressive and less ambiguous.
mdbcomp/prim_data.m:
mdbcomp/mdbcomp.m:
mdbcomp/program_representation.m:
mdbcomp/rtti_access.m:
mdbcomp/slice_and_dice.m:
mdbcomp/trace_counts.m:
Use . instead of __ as module qualifier.
Conform to the change to prim_data.m.
browser/declarative_execution.m:
browser/declarative_oracle.m:
browser/declarative_tree.m:
Conform the change to mdbcomp/prim_data.m.
tests/debugger/Mercury.options:
Don't specify --allow-table-reset for fib.m, since that option
doesn't exist anymore.
tests/debugger/fib.m:
Use the new mechanism for resetting the table.
tests/debugger/print_table.m:
Use the new syntax for pragma memo attributes.
tests/invalid/specified.{m,err_exp}:
Use to the new syntax and reset method for pragma memo attributes.
Test the handling of errors in the new attribute syntax.
tests/tabling/Mercury.options:
Don't specify --allow-table-reset for specified.m, since that option
doesn't exist anymore.
tests/tabling/specified.m:
Use the new syntax for pragma memo attributes, and use the new
mechanism for resetting tables. We could also use this test case
for testing the printing of statistics, but the format of that
output is still not final.
tests/tabling/fast_loose.m:
Use the new syntax for pragma memo attributes, and use the new
mechanism for resetting tables.
trace/mercury_trace.c:
trace/mercury_trace_cmd_developer.c:
Conform to the changes in the RTTI data structures regarding tabling.
Remove underscores from the names of some types that the style guide
says shouldn't be there.
library/robdd.m:
Comment out the tabling pragma until this change is bootstrapped.
Without this, the conflict between the old calls to macros generated
by the existing compiler and the new definition of those macros
in the runtime would cause errors from the C compiler.
|
||
|
|
459847a064 |
Move the univ, maybe, pair and unit types from std_util into their own
Estimated hours taken: 18 Branches: main Move the univ, maybe, pair and unit types from std_util into their own modules. std_util still contains the general purpose higher-order programming constructs. library/std_util.m: Move univ, maybe, pair and unit (plus any other related types and procedures) into their own modules. library/maybe.m: New module. This contains the maybe and maybe_error types and the associated procedures. library/pair.m: New module. This contains the pair type and associated procedures. library/unit.m: New module. This contains the types unit/0 and unit/1. library/univ.m: New module. This contains the univ type and associated procedures. library/library.m: Add the new modules. library/private_builtin.m: Update the declaration of the type_ctor_info struct for univ. runtime/mercury.h: Update the declaration for the type_ctor_info struct for univ. runtime/mercury_mcpp.h: runtime/mercury_hlc_types.h: Update the definition of MR_Univ. runtime/mercury_init.h: Fix a comment: ML_type_name is now exported from type_desc.m. compiler/mlds_to_il.m: Update the the name of the module that defines univs (which are handled specially by the il code generator.) library/*.m: compiler/*.m: browser/*.m: mdbcomp/*.m: profiler/*.m: deep_profiler/*.m: Conform to the above changes. Import the new modules where they are needed; don't import std_util where it isn't needed. Fix formatting in lots of modules. Delete duplicate module imports. tests/*: Update the test suite to confrom to the above changes. |
||
|
|
f7c8e5899d |
Add a new tabling method, one which specifies how each argument should
Estimated hours taken: 20
Branches: main
Add a new tabling method, one which specifies how each argument should
be treated, like this:
:- pragma memo(p(in, in, in, out), [value, addr, promise_implied, output]).
doc/reference_manual.texi:
Document the new tabling method.
compiler/prog_data.m:
Add a new tabling method, one which specifies how each argument should
be treated.
compiler/hlds_pred.m:
Provide for the description of untabled input arguments of tabled
procedures.
compiler/prog_io_pragma.m:
Parse the new tabling method.
Fix a bunch of formatting problems.
compiler/add_pragma.m:
When adding a tabling pragma to the HLDS, check that if the pragma
individually specifies the tabling methods of a procedure's arguments,
then those tabling methods agree with the modes of those arguments.
Fix an old bug: check whether a tabled predicate's arguments are
fully input or fully output, and print an error message if not.
We used to check this only in table_gen.m, but there we could only
abort the compiler if the check failed.
Factor out some common code and thereby fix an old bug: check for
conflicting tabling pragmas not just when adding the pragma to all
procedures of a predicate, but also when adding it to only a
specified procedure.
compiler/table_gen.m:
Implement the new tabling method.
compiler/prog_out.m:
compiler/layout_out.m:
Conform to the changes above.
runtime/mercury_stack_layout.h:
Provide for the description of untabled input arguments of tabled
procedures.
trace/mercury_trace.c:
Handle the new tabling method.
trace/mercury_trace_internal.c:
Handle the new tabling method. Delete the defaults from some switches
on enums to allow gcc to recognize missing cases.
Handle the untabled input arguments of tabled procedures: skip over
them when printing procedures' call tables.
Enable better completion for mdb's "table" command.
trace/mercury_trace_tables.[ch]:
Rename the breakpoint completer the proc_spec completer, since it does
completions on procedure specifications.
tests/debugger/print_table.{m,inp,exp}:
Modify this test case to test the ability to print the tables of
predicates with some untabled arguments.
tests/tabling/specified.{m,exp}:
New test case to check the functioning of the new tabling method
by testing whether it is in fact faster to table the address of
an argument instead of its value, or to not table it at all.
Since the gains here are not quite as dramatic as tabled vs untabled,
use a slightly looser criterion for comparing speeds than we use
in the various versions of the fib test case.
tests/tabling/Mmakefile:
tests/tabling/Mercury.options:
Enable the new test case, and set up the option it needs.
tests/invalid/specified.{m,err_exp}:
New test case, a slight variant of tests/tabling/specified.m,
to check the compiler's ability to detect errors in the new form
of tabling pragma.
tests/invalid/Mmakefile:
Enable the new test case.
|