mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-17 02:13:54 +00:00
b357a3dadcdf29c8d8ca184d65f7634a1a94de36
28 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
3c07fc2121 |
Use explicit streams in deep_profiler/*.m.
deep_profiler/analysis_utils.m:
deep_profiler/autopar_find_best_par.m:
deep_profiler/autopar_reports.m:
deep_profiler/autopar_search_callgraph.m:
deep_profiler/autopar_search_goals.m:
deep_profiler/callgraph.m:
deep_profiler/canonical.m:
deep_profiler/cliques.m:
deep_profiler/coverage.m:
deep_profiler/dump.m:
deep_profiler/mdprof_cgi.m:
deep_profiler/mdprof_create_feedback.m:
deep_profiler/mdprof_dump.m:
deep_profiler/mdprof_procrep.m:
deep_profiler/mdprof_report_feedback.m:
deep_profiler/mdprof_test.m:
deep_profiler/profile.m:
deep_profiler/read_profile.m:
deep_profiler/recursion_patterns.m:
deep_profiler/startup.m:
deep_profiler/var_use_analysis.m:
Replace implicit streams with explicit streams.
In some places, simplify some code, often using constructs such as
string.format that either did not exist or were too expensive to use
when the original code was written.
Consistenly use the spelling StdErr over Stderr.
In mdbprof_dump.m, put filename and reason-for-failing-to-open-that-file
in the right order in an error message.
deep_profiler/DEEP_FLAGS.in:
Turn on --warn-implicit-stream-calls for the entire deep_profiler
directory.
mdbcomp/program_representation.m:
mdbcomp/trace_counts.m:
Replace implicit streams with explicit streams. These are the two mdbcomp
modules that (a) used to use implicit streams, and (2) are used by the
deep profiler.
mdbcomp/Mercury.options:
Turn on --warn-implicit-stream-calls for these two modules.
slice/mcov.m:
slice/mtc_union.m:
Conform to the changes in mdbcomp.
|
||
|
|
2c68193c08 |
Mark some redundant library predicates obsolete.
library/set.m:
library/set_bbbtree.m:
library/set_ctree234.m:
library/set_ordlist.m:
library/set_tree234.m:
library/set_unordlist.m:
Mark empty/1 and non_empty/1 as obsolete with is_empty and is_non_empty
as suggested replacements, and mark set/1 as obsolete with list_to_set/1
as suggested replacement.
NEWS:
Mention the above changes.
configure.ac:
Require the installed compiler to handle suggested replacements
in obsolete pragmas.
compiler/analysis.m:
Avoid calling the newly obsolete predicates.
Remove a workaround that probably hasn't been needed in a long time.
compiler/error_util.m:
compiler/hlds_args.m:
compiler/intermod.m:
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/mercury_compile_main.m:
compiler/module_cmds.m:
compiler/old_type_constraints.m:
compiler/options.m:
compiler/ordering_mode_constraints.m:
compiler/par_conj_gen.m:
compiler/parse_pragma.m:
compiler/prog_ctgc.m:
compiler/rbmm.add_rbmm_goal_infos.m:
compiler/rbmm.live_region_analysis.m:
compiler/structure_reuse.domain.m:
compiler/structure_reuse.versions.m:
compiler/structure_sharing.domain.m:
compiler/switch_detection.m:
compiler/term_constr_fixpoint.m:
compiler/term_constr_util.m:
compiler/tupling.m:
deep_profiler/analysis_utils.m:
deep_profiler/autopar_annotate.m:
deep_profiler/autopar_calc_overlap.m:
deep_profiler/recursion_patterns.m:
deep_profiler/var_use_analysis.m:
Avoid calling the newly obsolete predicates.
|
||
|
|
95f8f56716 | Delete unneeded $module args from calls to expect/unexpected. | ||
|
|
f8d188fda8 |
Fix minor documentation problems.
deep_profiler/display_report.m:
deep_profiler/message.m:
deep_profiler/recursion_patterns.m:
deep_profiler/var_use_analsis.m:
java/runtime/UnreachableDefault.java:
runtime/mercury_engine.c:
runtime/mercury_minimal_model.c:
runtime/mercury_signal.h:
runtime/mercury_stack_layout.h:
runtime/mercury_wrapper.c:
runtime/mercury_threadscope.c:
trace/mercury_trace_external.c:
HISTORY:
As above.
|
||
|
|
9095985aa8 |
Fix more warnings from --warn-inconsistent-pred-order-clauses.
deep_profiler/*.m:
Fix inconsistencies between (a) the order in which functions and predicates
are declared, and (b) the order in which they are defined.
In most modules, either the order of the declarations or the order
of the definitions made sense, and I changed the other to match.
In some modules, neither made sense, so I changed *both* to an order
that *does* make sense (i.e. it has related predicates together).
In query.m, put the various commands in the same sensible order
as the code processing them.
In html_format.m, merge two exported functions together, since
they can't be used separately.
In some places, put dividers between groups of related
functions/predicates, to make the groups themselves more visible.
In some places, fix comments or programming style.
deep_profiler/DEEP_FLAGS.in:
Since all the modules in this directory are now free from any warnings
generated by --warn-inconsistent-pred-order-clauses, specify that option
by default in this directory to keep it that way.
|
||
|
|
5054ccbe31 |
Fix spelling.
deep_profiler/dump.m:
deep_profiler/recursion_patterns.m:
library/array.m:
library/type_desc.m:
As above.
|
||
|
|
62ec97d443 |
Report imports shadowed by other imports.
If a module has two or more import_module or use_module declarations
for the same module, (typically, but not always, one being in its interface
and one in its implementation), generate an informational message about
each redundant declaration if --warn-unused-imports is enabled.
compiler/hlds_module.m:
We used to record the set of imported/used modules, and the set of
modules imported/used in the interface of the current module. However,
these sets
- did not record the distinction between imports and uses;
- did not allow distinction between single and multiple imports/uses;
- did not record the locations of the imports/uses.
The first distinction was needed only by module_qual.m, which *did*
pay attention to it; the other two were not needed at all.
To generate messages for imports/uses shadowing other imports/uses,
we need all three, so change the data structure storing such information
for *direct* imports to one that records all three of the above kinds
of information. (For imports made by read-in interface and optimization
files, the old set of modules approach is fine, and this diff leaves
the set of thus *indirectly* imported module names alone.)
compiler/unused_imports.m:
Use the extra information now available to generate a
severity_informational message about any import or use that is made
redundant by an earlier, more general import or use.
Fix two bugs in the code that generated warnings for just plain unused
modules.
(1) It did not consider that a use of the builtin type char justified
an import of char.m, but without that import, the type is not visible.
(2) It scanned cons_ids in goals in procedure bodies, but did not scan
cons_ids that have been put into the const_struct_db. (I did not update
the code here when I added the const_struct_db.)
Also, add a (hopefully temporary) workaround for a bug in
make_hlds_passes.m, which is noted below.
However, there are at least three problems that prevent us from enabling
--warn-unused-imports by default.
(1) In some places, the import of a module is used only by clauses for
a predicate that also has foreign procs. When compiled in a grade that
selects one of those foreign_procs as the implementation of the predicate,
the clauses are discarded *without* being added to the HLDS at all.
This leads unused_imports.m to generate an uncalled-for warning in such
cases. To fix this, we would need to preserve the Mercury clauses for
*all* predicates, even those with foreign procs, and do all the semantic
checks on them before throwing them away. (I tried to do this once, and
failed, but the task should be easier after the item list change.)
(2) We have two pieces of code to generate import warnings. The one in
unused_imports.m operates on the HLDS after type and mode checking,
while module_qual.m operates on the parse tree before the creation of
the HLDS. The former is more powerful, since it knows e.g. what types and
modes are used in the bodies of predicates, and hence can generate warnings
about an import being unused *anywhere* in a module, as opposed to just
unused in its interface.
If --warn-unused-imports is enabled, we will get two separate set of
reports about an interface import being unused in the interface,
*unless* we get a type or mode error, in which case unused_imports.m
won't be invoked. But in case we do get such errors, we don't want to
throw away the warnings from module_qual.m. We could store them and
throw them away only after we know we won't need them, or just get
the two modules to generate identical error_specs for each warning,
so that the sort_and_remove_dups of the error specs will do the
throwing away for us for free, if we get that far.
(3) The valid/bug100.m test case was added as a regression test for a bug
that was fixed in module_qual.m. However the bug is still present in
unused_imports.m.
compiler/make_hlds_passes.m:
Give hlds_module.m the extra information it now needs for each item_avail.
Add an XXX for a bug that cannot be fixed right now: the setting of
the status of abstract instances to abstract_imported. (The "abstract"
part is correct; the "imported" part may not be.)
compiler/intermod.m:
compiler/try_expand.m:
compiler/xml_documentation.m:
Conform to the change in hlds_module.m.
compiler/module_qual.m:
Update the documentation of the relationship of this module
with unused_imports.m.
compiler/hlds_data.m:
Document a problem with the status of instance definitions.
compiler/hlds_out_module.m:
Update the code that prints out the module_info to conform to the change
to hlds_module.m.
Print status information about instances, which was needed to diagnose
one of the bugs in unused_imports.m. Format the output for instances
nicer.
compiler/prog_item.m:
Add a convenience predicate.
compiler/prog_data.m:
Remove a type synonym that makes things harder to understand, not easier.
compiler/modules.m:
Delete an XXX that asks for the feature this diff implements.
Add another XXX about how that feature could be improved.
compiler/Mercury.options.m:
Add some more modules to the list of modules on which the compiler
should be invoked with --no-warn-unused-imports.
compiler/*.m:
library/*.m:
mdbcomp/*.m:
browser/*.m:
deep_profiler/*.m:
mfilterjavac/*.m:
Delete unneeded imports. Many of these shadow other imports, and some
are just plain unneeded, as shown by --warn-unused-imports. In a few
modules, there were a *lot* of unneeded imports, but most had just
one or two.
In a few cases, removing an import from a module, because it *itself*
does not need it, required adding that same import to those of its
submodules which *do* need it.
In a few cases, conform to other changes above.
tests/invalid/Mercury.options:
Test the generation of messages about import shadowing on the existing
import_in_parent.m test case (although it was also tested very thoroughly
when giving me the information needed for the deletion of all the
unneeded imports above).
tests/*/*.{m,*exp}:
Delete unneeded imports, and update any expected error messages
to expect the now-smaller line numbers.
|
||
|
|
a3e72a4f61 |
Avoid solutions/2 in the deep profiler.
deep_profiler/autopar_costs.m:
deep_profiler/display_report.m:
deep_profiler/recursion_patterns.m:
deep_profiler/var_use_analysis.m:
As above. Code that computes a list of solutions directly is easier to
read, since the reader does not have to wonder where in a large nondet
predicate the actual points of choice are.
library/list.m:
Add a predicate, list.member_indexes0, that return all the indexes
in a list at which a given element appears, unlike the old
list.member_index0, which returned these one at a time via nondet code.
|
||
|
|
270170416d |
Bring the style of deep_profiler/* up-to-date.
deep_profiler/*.m:
Replace ( C -> T ; E ) if-then-elses with (if C then T else E ).
Replace calls to error/1 with calls to unexpected/3.
Add some module qualifications where this makes the code easier to read.
|
||
|
|
340c5300e6 |
Fix spelling in the deep profiler.
Fix some other issues as well that I found while fixing the spelling.
mdbcomp/feedback.automatic_parallelism.m:
deep_profiler/autopar_find_best_par.m:
deep_profiler/mdprof_create_feedback.m:
Rename the best_par_algorithm type to alg_for_finding_best_par,
since the old name was misleading. Perform the same rename for
another type based on it, and the option specifying it.
Remove the functor estimate_speedup_by_num_vars, since it hasn't
been used by anything in a long time, and won't in the future.
deep_profiler/autopar_calc_overlap.m:
deep_profiler/autopar_costs.m:
deep_profiler/autopar_reports.m:
deep_profiler/autopar_search_callgraph.m:
deep_profiler/autopar_search_goals.m:
deep_profiler/coverage.m:
deep_profiler/create_report.m:
deep_profiler/dump.m:
deep_profiler/mdprof_report_feedback.m:
deep_profiler/measurement_units.m:
deep_profiler/measurements.m:
deep_profiler/message.m:
deep_profiler/query.m:
deep_profiler/recursion_patterns.m:
deep_profiler/report.m:
deep_profiler/startup.m:
deep_profiler/var_use_analysis.m:
mdbcomp/mdbcomp.goal_path.m:
mdbcomp/program_representation.m:
Conform to the above. Fix spelling errors. In some places, improve
comments and/or variable names.
|
||
|
|
2d0bfc0674 |
The algorithm that decides whether the order independent state update
Estimated hours taken: 120 Branches: main The algorithm that decides whether the order independent state update transformation is applicable in a given module needs access to the list of oisu pragmas in that module, and to information about the types of variables in the procedures named in those pragmas. This diff puts this information in Deep.procrep files, to make them available to the autoparallelization feedback program, to which that algorithm will later be added. Compilers that have this diff will generate Deep.procrep files in a new, slightly different format, but the deep profiler will be able to read Deep.procrep files not just in the new format, but in the old format as well. runtime/mercury_stack_layout.h: Add to module layout structures the fields holding the new information we want to put into Deep.procrep files. This means three things: - a bytecode array in module layout structures encoding the list of oisu pragmas in the module; - additions to the bytecode arrays in procedure layout structures mapping the procedure's variables to their types; and - a bytecode array containing the encoded versions of those types themselves in the module layout structure. This allows us to represent each type used in the module just once. Since there is now information in module layout structures that is needed only for deep profiling, as well as information that is needed only for debugging, the old arrangement that split a module's information between two structures, MR_ModuleLayout (debug specific info) and MR_ModuleCommonLayout (info used by both debugging and profiling), is no longer approriate. We could add a third structure containing profiling-specific info, but it is simpler to move all the info into just one structure, some of whose fields may not be used. This wastes only a few words of memory per module, but allows the runtime system to avoid unnecessary indirections. runtime/mercury_types.h: Remove the type synonym for the deleted type. runtime/mercury_grade.h: The change in mercury_stack_layout.h destroys binary compatibility with previous versions of Mercury for debug and deep profiling grades, so bump their grade-component-specific version numbers. runtime/mercury_deep_profiling.c: Write out the information in the new fields in module layout structures, if they are filled in. Since this changes the format of the Deep.procrep file, bump its version number. runtime/mercury_deep_profiling.h: runtime/mercury_stack_layout.c: Conform to the change to mercury_stack_layout.h. mdbcomp/program_representation.m: Add to module representations information about the oisu pragmas defined in that module, and the type table of the module. Optionally add to procedure representations a map mapping the variables of the procedure to their types. Rename the old var_table type to be the var_name_table type, since it contains just names. Make the var to type map separate, since it will be there only for selected procedures. Modify the predicates reading in module and procedure representations to allow them to read in the new representation, while still accepting the old one. Use the version number in the Deep.procrep file to decide which format to expect. mdbcomp/rtti_access.m: Add functions to encode the data representations that this module also decodes. Conform to the changes above. mdbcomp/feedback.automatic_parallelism.m: Conform the changes above. mdbcomp/prim_data.m: Fix layout. compiler/layout.m: Update the compiler's representation of layout structures to conform to the change to runtime/mercury_stack_layout.h. compiler/layout_out.m: Output the new parts of module layout structures. compiler/opt_debug.m: Allow the debugging of code referring to the new parts of module layout structures. compiler/llds_out_file.m: Conform to the move to a single module layout structure. compiler/prog_rep_tables.m: This new module provided mechanisms for building the string table and the type table components of module layouts. The string table part is old (it is moved here from stack_layout.m); the type table part is new. Putting this code in a module of its own allows us to remove a circular dependency between prog_rep.m and stack_layout.m; instead, both now just depend on prog_rep_tables.m. compiler/ll_backend.m: Add the new module. compiler/notes/compiler_design.html: Describe the new module. compiler/prog_rep.m: When generating the representation of a module for deep profiling, include the information needed by the order independent state update analysis: the list of oisu pragmas in the module, if any, and information about the types of variables in selected procedures. To avoid having these additions increasing the size of the bytecode representation too much, convert some fixed 32 bit numbers in the bytecode to use variable sized numbers, which will usually be 8 or 16 bits. Do not use predicates from bytecode_gen.m to encode numbers, since there is nothing keeping these in sync with the code that reads them in mdbcomp/program_representation.m. Instead, use new predicates in program_representation.m itself. compiler/stack_layout.m: Generate the new parts of module layouts. Remove the code moved to prog_rep_tables.m. compiler/continuation_info.m: compiler/proc_gen.m: Make some more information available to stack_layout.m. compiler/prog_data.m: Fix some formatting. compiler/introduce_parallelism.m: Conform to the renaming of the var_table type. compiler/follow_code.m: Fix the bug that used to cause the failure of the hard_coded/mode_check_clauses test case in deep profiling grades. deep_profiler/program_representation_utils.m: Output the new parts of module and procedure representations, to allow the correctness of this change to be tested. deep_profiler/mdprof_create_feedback.m: If we cannot read the Deep.procrep file, print a single error message and exit, instead of continuing with an analysis that will generate a whole bunch of error messages, one for each attempt to access a procedure's representation. deep_profiler/mdprof_procrep.m: Give this program an option that specifies what file it is to look at; do not hardwire in "Deep.procrep" in the current directory. deep_profiler/report.m: Add a report type that just prints the representation of a module. It returns the same information as mdprof_procrep, but from within the deep profiler, which can be more convenient. deep_profiler/create_report.m: deep_profiler/display_report.m: Respectively create and display the new report type. deep_profiler/query.m: Recognize a query asking for the new report type. deep_profiler/autopar_calc_overlap.m: deep_profiler/autopar_find_best_par.m: deep_profiler/autopar_reports.m: deep_profiler/autopar_search_callgraph.m: deep_profiler/autopar_search_goals.m: deep_profiler/autopar_types.m: deep_profiler/branch_and_bound.m: deep_profiler/coverage.m: deep_profiler/display.m: deep_profiler/html_format.m: deep_profiler/mdprof_test.m: deep_profiler/measurements.m: deep_profiler/query.m: deep_profiler/read_profile.m: deep_profiler/recursion_patterns.m: deep_profiler/top_procs.m: deep_profiler/top_procs.m: Conform to the changes above. Fix layout. tests/debugger/declarative/dependency.exp2: Add this file as a possible expected output. It contains the new field added to module representations. |
||
|
|
d013a4cfcf |
Change the types that represent forward and reverse goal paths from being
Estimated hours taken: 20 Branches: main Change the types that represent forward and reverse goal paths from being wrappers around lists of steps, to being full discriminated union types. This is meant to accomplish two objectives. First, since taking the wrappers off and putting them back on is inconvenient, code often dealt with naked lists of steps, with the meaning of those steps sometimes being unclear. Second, in a future change I intend to change the way the debugger represents goal paths from being strings to being statically allocated terms of the reverse_goal_path type. This should have two benefits. One is reduced memory consumption, since two different goal path strings cannot share memory but two different reverse goal paths can share the memory containing their common tail (the goal paths steps near the root). The other is that the declarative debugger won't need to do any conversion from string to structure, and should therefore be faster. Having the compiler generate static terms of the reverse_goal_path type into the .c files it generates for every Mercury program being compiled with debugging requires it to have access to the definition of that type and all its components. The best way to do this is to put all those types into a new builtin module in the library (a debugging equivalent of e.g. profiling_builtin.m). We cannot put the definition of the list type into that module without causing considerable backward incompatibilities. mdbcomp/mdbcomp.goal_path.m: Make the change described above. Add some more predicates implementing abstract operations on goal paths. browser/declarative_tree.m: compiler/goal_path.m: compiler/goal_util.m: compiler/hlds_goal.m: compiler/introduce_parallelism.m: compiler/mode_ordering.m: compiler/push_goals_together.m: compiler/rbmm.condition_renaming.m: compiler/trace_gen.m: compiler/tupling.m: compiler/unneeded_code.m: deep_profiler/autopar_costs.m: deep_profiler/autopar_reports.m: deep_profiler/autopar_search_callgraph.m: deep_profiler/autopar_search_goals.m: deep_profiler/create_report.m: deep_profiler/message.m: deep_profiler/program_representation_utils.m: deep_profiler/read_profile.m: deep_profiler/recursion_patterns.m: deep_profiler/var_use_analysis.m: Conform to the change in representation. In some cases, remove predicates whose only job was to manipulate wrappers. In others, replace concrete operations on lists of steps with abstract operations on goal paths. compiler/mode_constraints.m: Comment out some code that I do not understand, which I think never worked (not surprising, since the whole module has never been operational). mdbcomp/slice_and_dice.m: Since this diff changes the types representing goal paths, it also changes their default ordering, as implemented by builtin.compare. When ordering slices and dices by goal paths, make the ordering explicitly work on the forward goal path, since ordering by the reverse goal path (the actual data being used) gives nonintuitive results. library/list.m: Speed up some code. mdbcomp/feedback.automatic_parallelism.m: Fix some formatting. |
||
|
|
6473555b25 |
Mark the predicates in the sv* modules in the standard library (except for the
Branches: main Mark the predicates in the sv* modules in the standard library (except for the recently added ones) as obsolete. They will be deleted after the 11.07 release. library/svarray.m: library/svbag.m: library/svbimap.m: library/sveqvclass.m: library/svmap.m: library/svmulti_map.m: library/svqueue.m: library/svset.m: library/svvarset.m: Mark these modules as obsolete. deep_profiler/dump.m: deep_profiler/recursion_patterns.m: profiler/snapshots.m: Avoid using predicates from sv* modules. |
||
|
|
9f68c330f0 |
Change the argument order of many of the predicates in the map, bimap, and
Branches: main
Change the argument order of many of the predicates in the map, bimap, and
multi_map modules so they are more conducive to the use of state variable
notation, i.e. make the order the same as in the sv* modules.
Prepare for the deprecation of the sv{bimap,map,multi_map} modules by
removing their use throughout the system.
library/bimap.m:
library/map.m:
library/multi_map.m:
As above.
NEWS:
Announce the change.
Separate out the "highlights" from the "detailed listing" for
the post-11.01 NEWS.
Reorganise the announcement of the Unicode support.
benchmarks/*/*.m:
browser/*.m:
compiler/*.m:
deep_profiler/*.m:
extras/*/*.m:
mdbcomp/*.m:
profiler/*.m:
tests/*/*.m:
ssdb/*.m:
samples/*/*.m
slice/*.m:
Conform to the above change.
Remove any dependencies on the sv{bimap,map,multi_map} modules.
|
||
|
|
59b0edacbe |
New module for calculating the overlap between the conjuncts of a
Estimated hours taken: 2 deep_profiler/autopar_calc_overlap.m: New module for calculating the overlap between the conjuncts of a parallelised conjunction. Its contents are taken from the old autopar_search_callgraph.m. deep_profiler/autopar_costs.m: New module for calculating the costs of goals. Its contents are taken from the old autopar_search_callgraph.m. deep_profiler/autopar_reports.m: New module for creating reports. Its contents are taken from the old autopar_search_callgraph.m. deep_profiler/autopar_search_goals.m: New module for searching goals for parallelizable conjunctions. Its contents are taken from the old autopar_search_callgraph.m. deep_profiler/autopar_search_callgraph.m: Remove the code moved to other modules. deep_profiler/mdprof_fb.automatic_parallelism.m: Add the new modules. deep_profiler/*.m: Remove unnecessary imports. Fix copyright years on the new modules. browser/*.m: compiler/*.m: mdbcomp/*.m: Remove unnecessary imports. library/Mercury.options: Make it possible to compile a whole workspace with --warn-unused-imports by turning that option off for type_desc.m (which has a necessary import that --warn-unused-imports thinks is unused). |
||
|
|
2070f42b24 |
Refactor goal annotations in the deep profiler.
Goal annotations have previously been attached to goals using type-polymorphism
and in some cases type classes. This has become clumsy as new annotations are
created. Using the goal_id code introduced recently, this change associates
annotations with goals by storing them in an array indexed by goal ids. Many
analyses have been updated to make use of this code. This code should also be
faster as less allocation is done when annotating a goal as the goal
representation does not have to be reconstructed.
mdbcomp/mdbcomp.goal_path.m:
Add predicates for working with goal attribute arrays. These are
polymorphic arrays that are indexed by goal id and can be used to associate
information with goals.
deep_profiler/report.m:
The procrep coverage info report now stores the coverage annotations in a
goal_attr_array.
deep_profiler/coverage.m:
The coverage analysis now returns its result in a goal_attr_array rather
than by annotation the goal directly.
The interface for the coverage module has changed, it now allows
programmers to pass a goal_rep to it directly. This makes it easier to
call from other analyses.
The coverage analysis no longer uses the calls_and_exits structure.
Instead it uses the cost_and_callees structure like many other analyses.
This also makes it easier to perform this annotation and others using only
a single call site map structure.
Moved add_coverage_point_to_map/5 from create_report.m to coverage.m.
deep_profiler/analysis_utils.m:
Made cost_and_callees structure polymorphic so that any type can be used to
represent the callees. (So that either static or dynamic callees can be
used).
Added the number of exit port counts to the cost_and_callees structure.
Added build_static_call_site_cost_and_callees_map/4.
Rename build_call_site_cost_and_callees_map/4 to
build_dynamic_call_site_cost_and_callees_map/4.
deep_profiler/var_use_analysis.m:
Update the var_use_analysis to use coverage information provided in a
goal_attr_array.
deep_profiler/recursion_patterns.m:
Update the recursion analysis to use coverage information provided in a
goal_attr_array.
deep_profiler/program_representation_utils.m:
Add label_goals/4 to label goals with goal ids and build a map of goal ids
to goal paths.
Update pretty printing fucntions to work with either annotation on the
goals themselves or provided by a higher order value. The higher order
argument maps nicly to the function goal_get_attribute/3 in goal_path.m
deep_profiler/mdprof_fb.automatic_parallelism.m:
Modify goal_annotate_with_instmap, it now returns the instmap annotations
in a goal_attr_array.
Conform to changes in:
program_representation_utils.m
coverage.m
var_use_analysis.m
deep_profiler/message.m:
Updated messagee to more correctly express the problems that
mdprof_fb.automatic_parallelism.m may encounter.
deep_profiler/create_report.m:
Conform to changes in coverage.m.
Make use of code in analysis_utils.m to prepare call site maps for coverage
analysis.
deep_profiler/recursion_patterns.m:
deep_profiler/var_use_analysis.m:
Conform to changes in analysis_utils.m.
deep_profiler/display_report.m:
Conform to changes in program_representation_utils.m.
|
||
|
|
681e8be040 |
A bug fix and some other corrections for the deep profiler tools.
deep_profiler/analysis_utils.m:
Handle calculating the recursive call costs at the base case by returning
an empty dictionary since there are none. Previously a dictionary
containing incorrect values was returned.
Remove a 'is det' from a pred declaration that has sepearte mode
declarations.
deep_profiler/coverage.m:
Adjust layout slightly.
Fixed trailing whitespace.
deep_profiler/recursion_patterns.m:
Fix an incorrect comment.
deep_profiler/measurements.m:
Add recursion_depth_is_base_case/1.
Check for negative depths in recursion_depth_descend/2.
|
||
|
|
d43239d6a7 |
Move some of the goal path code from compiler/goal_path.m to the mdbcomp
library where it can be used by the deep profiler.
Also move the goal path code from program_representation.m to the new module,
goal_path.m in mdbcomp/
mdbcomp/goal_path.m:
New module containing goal path code.
mdbcomp/program_representation.m:
Original location of goal path code.
compiler/goal_path.m:
Move some of this goal_path code into mdbcomp/goal_path.m
mdbcomp/feedback.automatic_parallelisation.m:
mdbcomp/rtti_access.m:
mdbcomp/slice_and_dice.m:
mdbcomp/trace_counts.m:
browser/debugger_interface.m:
browser/declarative_execution.m:
browser/declarative_tree.m:
compiler/build_mode_constraints.m:
compiler/call_gen.m:
compiler/code_info.m:
compiler/continuation_info.m:
compiler/coverage_profiling.m:
compiler/deep_profiling.m:
compiler/format_call.m:
compiler/goal_path.m:
compiler/goal_util.m:
compiler/hlds_data.m:
compiler/hlds_goal.m:
compiler/hlds_out_goal.m:
compiler/hlds_out_pred.m:
compiler/hlds_pred.m:
compiler/interval.m:
compiler/introduce_parallelism.m:
compiler/layout_out.m:
compiler/llds.m:
compiler/mode_constraint_robdd.m:
compiler/mode_constraints.m:
compiler/mode_ordering.m:
compiler/ordering_mode_constraints.m:
compiler/polymorphism.m:
compiler/post_typecheck.m:
compiler/prog_rep.m:
compiler/prop_mode_constraints.m:
compiler/push_goals_together.m:
compiler/rbmm.condition_renaming.m:
compiler/smm_common.m:
compiler/stack_layout.m:
compiler/stack_opt.m:
compiler/trace_gen.m:
compiler/tupling.m:
compiler/type_constraints.m:
compiler/typecheck.m:
compiler/unify_gen.m:
compiler/unneeded_code.m:
deep_profiler/Mmakefile:
deep_profiler/analysis_utils.m:
deep_profiler/coverage.m:
deep_profiler/create_report.m:
deep_profiler/display_report.m:
deep_profiler/dump.m:
deep_profiler/mdprof_fb.automatic_parallelism.m:
deep_profiler/message.m:
deep_profiler/old_query.m:
deep_profiler/profile.m:
deep_profiler/program_representation_utils.m:
deep_profiler/read_profile.m:
deep_profiler/recursion_patterns.m:
deep_profiler/report.m:
deep_profiler/var_use_analysis.m:
slice/Mmakefile:
slice/mcov.m:
Conform to the move of the goal path code.
|
||
|
|
a2cd0da5b3 |
The existing representation of goal_paths is suboptimal for several reasons.
Estimated hours taken: 80 Branches: main The existing representation of goal_paths is suboptimal for several reasons. - Sometimes we need forward goal paths (e.g. to look up goals), and sometimes we need reverse goal paths (e.g. when computing goal paths in the first place). We had two types for them, but - their names, goal_path and goal_path_consable, were not expressive, and - we could store only one of them in goal_infos. - Testing whether goal A is a subgoal of goal B is quite error-prone using either form of goal paths. - Using a goal path as a key in a map, which several compiler passes want to do, requires lots of expensive comparisons. This diff replaces most uses of goal paths with goal ids. A goal id is an integer, so it can be used as a key in faster maps, or even in arrays. Every goal in the body of a procedure gets its id allocated in a depth first search. Since we process each goal before we dive into is descendants, the goal representing the whole body of a procedure always gets goal id 0. The depth first traversal also builds up a map (the containing goal map) that tells us the parent goal of ever subgoal, with the obvious exception of the root goal itself. From the containing goal map, one can compute both reverse and forward goal paths. It can also serve as the basis of an efficient test of whether the goal identified by goal id A is an ancestor of another goal identified by goal id B. We don't yet use this test, but I expect we will in the future. mdbcomp/program_representation.m: Add the goal_id type. Replace the existing goal_path and goal_path_consable types with two new types, forward_goal_path and reverse_goal_path. Since these now have wrappers around the list of goal path steps that identify each kind of goal path, it is now ok to expose their representations. This makes several compiler passes easier to code. Update the set of operations on goal paths to work on the new data structures. Add a couple of step types to represent lambdas and try goals. Their omission prior to this would have been a bug for constraint-based mode analysis, or any other compiler pass prior to the expansion out of lambda and try goals that wanted to use goal paths to identify subgoals. browser/declarative_tree.m: mdbcomp/rtti_access.m: mdbcomp/slice_and_dice.m: mdbcomp/trace_counts.m: slice/mcov.m: deep_profiler/*.m: Conform to the changes in goal path representation. compiler/hlds_goal: Replace the goal_path field with a goal_id field in the goal_info, indicating that from now on, this should be used to identify goals. Keep a reverse_goal_path field in the goal_info for use by RBMM and CTGC. Those analyses were too hard to convert to using goal_ids, especially since RBMM uses goal_paths to identify goals in multi-pass algorithms that should be one-pass and should not NEED to identify any goals for later processing. compiler/goal_path: Add predicates to fill in goal_ids, and update the predicates filling in the now deprecated reverse goal path fields. Add the operations needed by the rest of the compiler on goal ids and containing goal maps. Remove the option to set goal paths using "mode equivalent steps". Constraint based mode analysis now uses goal ids, and can now do its own equivalent optimization quite simply. Move the goal_path module from the check_hlds package to the hlds package. compiler/*.m: Conform to the changes in goal path representation. Most modules now use goal_ids to identify goals, and use a containing goal map to convert the goal ids to goal paths when needed. However, the ctgc and rbmm modules still use (reverse) goal paths. library/digraph.m: library/group.m: library/injection.m: library/pprint.m: library/pretty_printer.m: library/term_to_xml.m: Minor style improvements. |
||
|
|
8a28e40c9b |
Add the predicates sorry, unexpected and expect to library/error.m.
Estimated hours taken: 2 Branches: main Add the predicates sorry, unexpected and expect to library/error.m. compiler/compiler_util.m: library/error.m: Move the predicates sorry, unexpected and expect from compiler_util to error. Put the predicates in error.m into the same order as their declarations. compiler/*.m: Change imports as needed. compiler/lp.m: compiler/lp_rational.m: Change imports as needed, and some minor cleanups. deep_profiler/*.m: Switch to using the new library predicates, instead of calling error directly. Some other minor cleanups. NEWS: Mention the new predicates in the standard library. |
||
|
|
887a55f783 |
Make variable use analysis assume that the compiler cannot push signals or
waits for futures across module boundaries, which is usually true.
Add a new option to the feedback tool
--implicit-parallelism-intermodule-var-use. This option re-enables the old
behaviour.
Fix a number of bugs and improve the pretty-printing of candidate parallel
conjunctions.
deep_profiler/var_use_analysis.m:
Implement the new behaviour and allow it to be controlled.
Refactor some code to slightly reduce the number of arguments passed to
predicates.
deep_profiler/mdprof_feedback.m:
Implement the new command line option.
Conform to changes in feedback.automatic_parallelism.m.
deep_profiler/recursion_patterns.m:
Fixed a bug in the handling of can-fail switches.
deep_profiler/mdprof_fb.automatic_parallelism.m:
Fix a bug in the calculation of dependency graphs. All goals are
represented by vertexes and dependencies are edges. The program failed to
create a vertex for a goal that had no edges.
Fix a crash when trying to compute variable use information for a goal that
is never called. This was triggered by providing the new variable use
information in the feedback format.
Using the extra feedback information improve the pretty-printing of
candidate parallelisations.
Conform to changes in feedback.automatic_parallelism.m
Conform to changes in var_use_analysis.m
mdbcomp/feedback.automatic_parallelism.m:
Add the new option to control intermodule variable use analysis.
Provided more information in the candidate parallel conjunctions feedback.
The costs of the goals before and after the parallel conjunction are
now provided.
The cost of every goal is now provided (not just calls)
Variable production and consumption times of the shared variables are
provided for each goal if the analysis evaluated them.
Modified convert_candidate_par_conjunctions_proc/3 and
convert_candidate_par_conjunction/3 to pass a reference to the current
parallel conjunction to their higher order argument.
mdbcomp/feedback.m:
Increment feedback file version number.
deep_profiler/program_representation_utils.m:
Improve the pretty-printing of goal representations, in particular, their
annotations.
deep_profiler/create_report.m:
Conform to changes in var_use_analysis.m.
deep_profiler/display_report.m:
Conform to changes in program_representation_utils.m.
library/lazy.m:
Added a new predicate, read_if_val(Lazy, Value) which is true of Lazy has
already been forced and produced Value.
(No update to NEWS necessary).
|
||
|
|
41cb1d2f79 |
Variable use analysis now uses conservative assumptions for recursive call costs
when recursive call site cost information cannot be computed.
deep_profiler/var_use_analysis.m:
The var use analysis predicates now use instantiation state subtypes for
the recursion type information.
Only look for variable use in recursive calls if we know the cost of the
recursive call.
In call_var_first_use, use map.lookup to get the cost of a call site rather
than map.search. All call site costs are now guaranteed to be known since
this predicate is only valid for recursion types that provide this
information.
deep_profiler/recursion_patterns.m:
Fix bugs in the calculation of recursion data in semidet code.
Use instantiation states to support the subtypes used in
var_use_analysis.m.
deep_profiler/measurements.m:
Add a new abstract type, recursion_depth.
deep_profiler/analysis_utils.m:
deep_profiler/recursion_patterns.m:
deep_profiler/mdprof_fb.automatic_parallelism.m:
Conform to changes in measurements.m
|
||
|
|
3f6a984a49 |
Make the recursion patterns analysis more robust.
Handle semidet and committed choice disjunctions in the recursion patterns
analysis.
deep_profiler/recursion_patterns.m:
As above.
deep_profiler/measurement_units.m:
Add a new function, not_probability that returns the probability that a
certain probability will not occur.
|
||
|
|
881039cfed |
Correct problems in the automatic parallelism analysis.
This patch fixes various problems, the most significant is the calculation of
variable use information. The parallelisation analysis uses deep profiling
data. In other words, profiling data that is attached to context information
referring to not just the procedure but the chain of calls leading to that
invocation of that procedure (modulo recursion). The variable use analysis did
not use deep profiling data, therefore comparing the time that a variable is
produced with a call to the time in total of that call was not sound, and
sometimes resulted in information that is not possible, such as a variable
being produced or consumed after the call that produces or consumes it has
exited.
This change-set updates the variable use analysis to use deep profiling data to
avoid these problems. At the same time it provides more accurate information
to the automatic parallelisation pass. This is possible because of an earlier
change that allowed the coverage data to use deep profiling data.
In its current state, the parallelisation analysis now finishes without errors
and computes meaningful results when analysing a profile of the mercury
compiler's execution.
deep_profiler/report.m:
The proc var use report is now a call site dynamic var use report.
1) It now uses deep profiling data.
2) It makes more sense from the callers perspective so it's now based
around a call site rather than a proc.
Add inst subtypes to the recursion_type type.
deep_profiler/query.m:
The proc var use query is now a call site dynamic var use query, see
report.m.
deep_profiler/var_use_analysis.m:
Fix a bug here and in mdprof_fb.automatic_parallelism.m: If a
variable is consumed by a call and appears in it's argument list more than
once, take the earliest consumption time rather than the one for the
earliest argument.
Variable use analysis now uses recursion_patterns.m to correctly compute
the cost of recursive calls. It also uses 'deep' profiler data.
Only measure variable use relative to the entry into a procedure, rather
than either relative to the entry or exit. This allows us to simplify a
lot of code.
deep_profiler/create_report.m:
The proc var use info report is now a call site dynamic var use info
report.
Move some utility code from here to the new analysis_utils.m module.
deep_profiler/display_report.m:
Conform to changes in report.m.
Improve the information displayed for variable first-use time
reports.
deep_profiler/mdprof_fb.automatic_parallelism.m:
Conform to changes in report.m
Refactored the walk down the clique tree. This no-longer uses the
clique reports from the deep profiling tool.
We now explore the same static procedure more than once. It may be best to
parallelise it in some contexts rather than others but for now we assume
that the benefits in some context are worth the costs without benefit in
the other contexts. This is better than reaching a context where it is
undesirable first and never visiting a case where parallelisation is
desirable.
Fix a bug in the calculation of how much parallelisation is used by
parallelisations in a clique's parents. This used to trigger an
assertion.
Don't try to parallelize anything in the "exception" module.
There's probably other builtin code we should skip over here.
Removed an overzealous assertion that was too easily triggered by the
inaccuracies of IEEE-754 arithmetic.
Compute variable use information lazily for each variable in each call. I
believe that this has made our implementation much faster as it no-longer
computes information that is never used.
Refactor and move build_recursive_call_site_cost_map to the new
module analysis_utils.m where it can be used by other analyses.
Call site cost maps now use the cs_cost_csq type to store costs,
code in this module now conforms to this change.
Conform to changes in messages.m
deep_profiler/recursion_patterns.m:
Export a new predicate, recursion_type_get_maybe_avg_max_depth/2. This
retrieves the average maximum recursion depth from recursion types that know
this information.
Move code that builds a call site cost map for a procedure to
analysis_utils.m where it can be used by other analyses.
deep_profiler/analysis_utils.m:
Added a new module containing various utility predicates for profile
analysis.
deep_profiler/coverage.m:
Added an extra utility predicate get_coverage_after/2.
deep_profiler/message.m:
Each message has a location that it refers to, a new location type has
been added: call_site_dynamic.
Added a new warning that can be used to describe when a call site's
argument's use time cannot be computed.
Added new predicates for printing out messages whose level is below a
certain threshold. These predicates can be called from io trace goals.
Message levels start at 0 and currently go to 4, more critical messages
have lower levels. The desired verbosity level is stored in a module local
mutable.
deep_profiler/mdprof_feedback.m:
Move the message printing code from here to message.m.
deep_profiler/old_html_format.m:
deep_profiler/old_query.m:
Conform to changes in query.m.
mdbcomp/feedback.automatic_parallelism.m:
Added a new function for computing the 'cpu time' of a parallel
computation.
library/lazy.m:
Moved lazy.m from extras to the standard library.
library/list.m:
Add a new predicate member_index0/3. Like member/2 except it also gives
the zero-based index of the current element within the list.
library/maybe.m:
Add two new insts.
maybe_yes(I) for the maybe type's yes/1 constructor.
maybe_error_ok(I) for the maybe_error type's ok/1 constructor.
library/Mercury.options:
Add a work around for compiling lazy.m with intermodule optimisations.
NEWS:
Update news file for the addition of lazy.m and the member_index0 predicate
in list.m
deep_profiler/.cvsignore:
Ignore feedback.automatic_parallelism.m which is copied by Mmakefile from
the mdbcomp/ directory.
|
||
|
|
1793e3898b |
Updated the automatic parallelism analysis to use the new recursive call costs
analysis.
deep_profiler/mdprof_fb.automatic_parallelism.m:
Use new clique recursion costs report to give the costs of recursive calls.
This is more accurate than the current method which is only accurate in some
less-common situations.
Refactored the walk through the program's call graph so that it fits more
neatly with the calculation of recursive calls. For instance it is
no-longer necessary to know the cost of the call into the current clique.
Delete a number of predicates that are never called.
deep_profiler/message.m:
Added a new message type, warning_cannot_compute_cost_of_recursive_calls
since the new recursive call cost algorithm is incomplete.
deep_profiler/recursion_patterns.m:
Avoid a thrown exception when trying to retrieve the parent call site of the
initial clique.
Fix the calculation of recursion depth. Name some variables more clearly
to avoid similar issues.
deep_profiler/report.m:
Add a clarifying comment to the recursion_type data type to indicate that
costs are per-call.
mdbcomp/program_representation.m:
Added a new exported predicate goal_path_inside/3 like goal_path_inside/2
except that it also returns the goal path of the inner goal relative to the
outer goal.
Made goal_path_inside/2 more efficient by using list.remove_suffix rather
than list.append which creates a choice point whose second solution always
fails. (See the comment on list.append/3 in mode out, in, in.
|
||
|
|
ba1f56c6d5 |
Finish the cost of recursive calls analysis for linear recursions.
This code will be used by the automatic parallelisation analysis. It is
accessible as a developer report in the deep profiler.
Thanks to Thibaut Feydy who helped me with the formula for the average cost of
recursive calls, and some missing parts in my maths knowledge :-).
deep_profiler/report.m:
Add extra fields to the rt_single constructor for the recursion_type data
type:
The average total depth of recursion.
The cost of a recursive call at the average recursion level.
A higher-order value that gives the cost of recursive calls at a given
level.
deep_profiler/recursion_patterns.m:
Use a per-call cost for the recursive call site cost report.
Document and code formulas for calculating the cost of recursive calls at
any level and at the average level for linear recursion.
Conform to changes in report.m.
deep_profiler/display_report.m:
In the recursive call cost report:
Print the average cost of recursive calls as well as the costs of
levels 0, 1, 2, N/2, N-2, N-1 and N.
Update text in column headers to indicate that costs are 'per call'.
Conform to changes in report.m
Fix a bug whereby visiting the menu screen and following some links from
it reset the user's preferences.
|
||
|
|
067934f008 |
Start using the new dynamic coverage information in the deep profiler.
This patch separates the coverage annotated procedure report into two
reports, one with dynamic coverage data and one with static coverage data.
This restores the functionality of the static coverage report since my last
change, and provides access to the dynamic report via new controls only
visible to developers.
deep_profiler/query.m:
In the cmd data-type:
Rename deep_cmd_procrep_coverage constructor to
deep_cmd_static_procrep_coverage.
Add deep_cmd_procrep_dynamic_coverage.
In the preferences data-type:
Add a new field pref_developer_mode which indicates if developer-only
options are visible or not.
Add code to parse and print the new command and preference option.
deep_profiler/create_report.m:
Specialise create_procrep_coverage_report/3 into
create_{static,dynamic}_coverage_report/4.
Created a new exported function deep_get_maybe_procrep. This is useful for
getting a procedure representation from the deep data-structure in one
step.
deep_profiler/display.m:
Add a new display item, display_developer. This wraps another display
item but is only displayed when developer mode is active.
deep_profiler/display_report.m:
Add a control to the main screen that enables or disabled developer mode.
This control has been placed at the bottom of the screen so that it's out
of the way.
Put the developer controls on the main screen into their own list (there's
only one at the moment).
For now the coverage-annotated procedure representation link on a (static)
procedure's page is not a developer option. Should this be a developer
option?
Added a link to the dynamic coverage annotated procedure representation
report from the dump proc dynamic report.
Added a link to the clique dump report from the clique report, the dynamic
coverage annotated procedure representation report can be accessed
transitively through this link.
Added a link the variable use analysis report and proc static report to the
procedure report and static coverage annotated procedure representation
report.
deep_profiler/html_format.m:
Support the new display_developer item.
Refactor the item_to_html code for lists.
deep_profiler/profile.m:
Include a new field in the deep data-structure for storing coverage data
that is indexed by a proc_static_ptr. When dynamic coverage information is
used this field is populated by adding per ProcDynamic data for each static
procedure.
deep_profiler/startup.m:
Fill in the per ProcStatic coverage data when the deep profiler starts up.
deep_profiler/measurements.m:
Create a new data type static_coverage_info which represents per ProcStatic
coverage information.
Include functions that are used when calculating per ProcStatic coverage
information from per ProcDynamic coverage information.
deep_profiler/mdprof_cgi.m:
Remove rarely used command line option rather making it conform to changes
in query.m.
deep_profiler/old_html_format.m:
deep_profiler/old_query.m:
Conform to changes in query.m.
deep_profiler/mdprof_test.m:
deep_profiler/mdprof_fb.automatic_parallelism.m:
deep_profiler/recursion_patterns.m:
deep_profiler/var_use_analysis.m:
Conform to changes in create_report.
deep_profiler/array_util.m:
Add a new predicate, array_foldl3_from_1 to support propagation of coverage
information from proc dynamics to proc statics.
|
||
|
|
848e48ce3b |
'cvs add' a missing file.
deep_profiler/recursion_patterns.m:
I forgot to include this file with an earlier changeset.
|