Commit Graph

36 Commits

Author SHA1 Message Date
Zoltan Somogyi
ec2c7fad76 Simplify the code reading/writing feedback files ...
mdbcomp/feedback.m:
    ... by avoiding the overuse of higher order code and exceptions.
    (The old code tried to catch exceptions, even though the code in the
    try block shouldn't be able to throw any.)

    Document a vulnerability in the use io.read/io.write on feedback files,
    which was discussed on m-rev in 2008 July when this file was created.
2023-04-25 01:42:23 +10:00
Zoltan Somogyi
a47de48c4d s/input_stream/text_input_stream/ ...
... and the same for output streams.
2023-04-24 14:59:20 +10:00
Zoltan Somogyi
198b307289 Use related names for related variables.
Add an XXX about a missing file close operation.
2021-03-06 21:50:46 +11:00
Mark Brown
d465fa53cb Update the COPYING.LIB file and references to it.
Discussion of these changes can be found on the Mercury developers
mailing list archives from June 2018.

COPYING.LIB:
    Add a special linking exception to the LGPL.

*:
    Update references to COPYING.LIB.

    Clean up some minor errors that have accumulated in copyright
    messages.
2018-06-09 17:43:12 +10:00
Zoltan Somogyi
1a778114db Fix more warnings from --warn-inconsistent-pred-order-clauses.
mdbcomp/builtin_modules.m:
mdbcomp/feedback.automatic_parallelism.m:
mdbcomp/feedback.m:
mdbcomp/mdbcomp.goal_path.m:
mdbcomp/mer_mdbcomp.m:
mdbcomp/prim_data.m:
mdbcomp/program_representation.m:
mdbcomp/rtti_access.m:
mdbcomp/slice_and_dice.m:
mdbcomp/sym_name.m:
mdbcomp/trace_counts.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).

    Move one predicate that is needed in two modules from one of them
    to a third module (prim_data.m), since that is the one that defines
    the type for which the predicate is a utility predicate.

    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.

mdbcomp/MDBCOMP_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.
2017-04-29 22:49:16 +10:00
Zoltan Somogyi
6650ffad55 Convert (C->T;E) to (if C then T else E). 2015-11-30 09:27:31 +11:00
Zoltan Somogyi
cc9912faa8 Don't import anything in packages.
Packages are modules whose only job is to serve as a container for submodules.
Modules like top_level.m, hlds.m, parse_tree.m and ll_backend.m are packages
in this (informal) sense.

Besides the include_module declarations for their submodules, most of the
packages in the compiler used to import some modules, mostly other packages
whose component modules their submodules may need. For example, ll_backend.m
used to import parse_tree.m. This meant that modules in the ll_backend package
did not have to import parse_tree.m before importing modules in the parse_tree
package.

However, this had a price. When we add a new module to the parse_tree package,
parse_tree.int would change, and this would require the recompilation of ALL
the modules in the ll_backend package, even the ones that did NOT import ANY
of the modules in the parse_tree package.

This happened even at one remove. Pretty much all modules in every one
of the backend have to import one or more modules in the hlds package,
and they therefore have import hlds.m. Since hlds.m imported transform_hlds.m,
any addition of a new middle pass to the transform_hlds package required
the recompilation of all backend modules, even in the usual case of the two
having nothing to do with each other.

This diff removes all import_module declarations from the packages,
and replaces them with import_module declarations in the modules that need
them. This includes only a SUBSET of their child modules and of the non-child
modules that import them.
2015-11-13 15:03:20 +11:00
Zoltan Somogyi
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.
2015-08-25 00:38:49 +10:00
Zoltan Somogyi
aa60524d71 Eliminate redundant output from tools/bootcheck.
runtime/mercury_goto.h:
    Cast the "const MR_LabelLayout *" argument of calls
    MR_insert_internal_label, since without this cast, we get C compiler
    warnings in the bootcheck output when the caller passes a
    "const MR_LabelLayoutNoVarInfo *" for this argument.

tests/hard_coded/Mmakefile:
    Redirect the output of the weak_ptr test to a file instead of including it
    in the output of bootcheck itself. The output is maybe be needed in a rare
    cases, but is not needed most of the time.

tests/hard_coded/weak_ptr.m:
    Fix white space.

tests/feedback/Mmakefile:
    Specify verbosity level 0 when invoking mdprof_create_feedback.

deep_profiling/mdprof_create_feedback.m:
    Record the verbosity level when we postprocess the options. We used to
    record it *after* creating the feedback file, and before printing the
    messages gathered during this process. This *mostly* worked, but some
    messages are printed using trace goals *during* the creation of the
    feedback file, and these ignored the specified verbosity level.

deep_profiling/query.m:
    Remove the IO arguments from exec and try_exec, since they do not use them.

deep_profiling/var_use_analysis.m:
    Eliminate some ambiguities by renaming two predicates.

    Simplify some overly complex code.

deep_profiling/autopar_costs.m:
deep_profiling/create_report.m:
deep_profiling/mdprof_cgi.m:
deep_profiling/mdprof_test.m:
    Conform to the above changes.

mdbcomp/feedback.m:
    Fix a typo.
2015-01-22 02:18:08 +11:00
Zoltan Somogyi
f7237359ae Simplify the deep profiler's feedback mechanism.
mdbcomp/feedback.m:
    Accessing the old representation of feedback information required
    using partially instantiated data structures, dynamic type checking,
    and purity promises. Replace this with a straightforward representation,
    a tuple with a separate field for each supported kind of feedback
    information that contains "yes(...)" if feedback of the given type is
    available and "no" if it isn't.

    Document all the places that need to be updated when a new kind
    of feedback information is added.

    Remove the feedback information used by Tannier's old attempt
    at automatic parallelization, since it hasn't been supported for
    a while now, and won't be in the future.

    The feedback_info structure had a field named fi_program_name that
    comments on several predicates have identified as being the name of
    the Mercury system program (such as mdprof_create_report) that created
    the feedback_info structure. It was actually intended to hold the
    name of the program whose execution yielded the profiling data
    that the feedback_info was created from, and therefore the program
    whose recompilation the feedback_info was intended to help. This diff
    switches the documented meaning of the field from the former to the latter.
    To this end:

    - we rename the field;
    - we fix the comments referring to it,
    - we check whether the names match when new feedback data is added;
    - we check whether the actual program name matches the expected program
      name (if any) when reading in a feedback file, instead of delaying
      the check until later; and
    - we make write_feedback_file use the name in the feedback_info structure
      when writing it out, instead of a name redundantly supplied by its
      caller.

    In clients of feedback.m, some code used to put a program name into
    a feedback_info, and then later check whether the name in there was
    still the one it put there earlier. With this diff, we delete the check.
    We can do this because the profiled program name field of each
    feedback_info is set at initialization, and never changed afterwards.

    We now put a wrapper around each piece of feedback information in the
    texts of feedback files, to tell the code reading the file WHAT KIND
    of feedback information it is. We therefore increment the feedback file
    format version number.

    Group related predicates together.

    Give some predicates better (less ambiguous) names.

    Add prefixes to the names of some function symbols that are
    ambiguous without them.

compiler/handle_options.m:
compiler/introduce_parallelism.m:
deep_profiler/autopar_reports.m:
deep_profiler/autopar_search_callgraph.m:
deep_profiler/mdprof_create_feedback.m:
deep_profiler/mdprof_report_feedback.m:
    Conform to the changes in mdbcomp/feedback.m
2014-12-01 22:12:46 +11:00
Zoltan Somogyi
4b44c29c2e Fix mantis bug 311.
compiler/simplify_goal_disj.m:
    Look for the conditions that lead to the bug (a disjunction that
    further instantiates an already partially instantiated variable).
    Generate an error message when found, PROVIDED that this happens
    in a context in which the surrounding procedure can succeed
    more than once. (If it cannot, then you cannot invoke an all-solutions
    predicate on it, and the bug cannot happen.)

    This condition (a model_non surrounding procedure) was motivated
    by mdbcomp/feedback.m, which does not compile without it.

compiler/simplify_info.m:
    The simplify_info type used to contain four different kinds of fields:

    1 static fields; set and then never changed, such as the id of the
      containing procedure
    2 global information, such as the varset and vartypes, which are updated
      as new variable are added, and whose updates need to be kept regardless
      of what part of the procedure is analyzed next
    3 information about the context surrounding the goal currently being
      analyzed, such as the number of lambda expressions we are inside
    4 information about the point in the code before the goal currently being
      analyzed, such as the set of equivalences that currently hold between
      variables (part of common_info).

    The code of the simplify_goal*.m modules used to have jump through hoops
    to handle 3 and 4 properly, given that the simplify_info was being
    threaded through code in a way that was suitable only for 1 and 2.

    This change takes categories 3 and 4 out of the simplify_info.
    It creates a new type, simplify_nested_context, for category 3,
    and adds information about the ability of the procedure surrounding
    the current point to succeed more than once (needed for the bug311 fix)
    to this new type.

compiler/simplify_tasks.m:
    Rename the do_once task to mark_code_model_changes, since this
    expresses what the task is much less ambiguously.

compiler/simplify_goal*.m:
compiler/simplify_proc.m:
compiler/common.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
    Conform to the changes to simplify_info (and simplify_tasks).
    Pass the current instmap and common_info (the two category 4 fields)
    separately.

    Mark some places that could be improved.

compiler/hlds_out_mode.m:
    Generate easier-to-understand debugging output. I needed this to track
    down a bug in my initial fix.

compiler/inst_match.m:
    Remove a redundant unification that couldn't fail (since it was invoked
    only if the exact same unification succeeded a few lines earlier).
    Apply another minor optimizations.

compiler/instmap.m:
    Remove references to the alias branch. It won't be coming back.

compiler/error_util.m:
    Fix some documentation.

mdbcomp/feedback.m:
    Put related stuff together.

tests/warnings/bug311.{m,err_exp}:
    New test case for the bug.

tests/warnings/Mmakefile:
    Enable the new test case.
2014-07-30 12:10:39 +02:00
Julien Fischer
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.
2011-05-03 04:35:04 +00:00
Zoltan Somogyi
0f16917890 Fix some problems identified during benchmarking for the overlap paper.
Estimated hours taken: 2
Branches: main

Fix some problems identified during benchmarking for the overlap paper.

compiler/options.m:
	Add two new options

		--report-cmd-line-args
		--report-cmd-line-args-in-doterr

	that would have been really useful to debug some problems.

doc/user_guide.texi:
	Document the new options.

compiler/mercury_compile.m:
	Implement the new options.

mdbcomp/feedback.m:
	When reporting a version number that differs from the expected,
	report the expected version number.

runtime/mercury_wrapper.c:
	Fix a bug that made an option unreachable from MERCURY_OPTIONS.
2011-01-26 16:08:07 +00:00
Paul Bone
5435fa3667 Various fixes, mostly to measuring the overlap between dependant parallel
conjunctions.  These fixes ensure that our implementation now matches the
algorithms in our paper.

Benchmarking can now begin for the paper.

deep_profiler/mdprof_fb.automatic_parallelism.m:
    Remove build_candidate_par_conjunction_maps since it's no-longer called.

    Fix a bug where candidate procedures where generated with no candidate
    conjunctions in them.

    Fix a bug where !ConjNum was not incremented in a loop, this caused
    SparkDelay to be calculated incorrectly when calculating the cost of a
    parallel conjunction.

    Account for the cost of calling signal in the right place when calculating
    the cost of a parallel conjunction.

    Conform to changes in measurements.m.

deep_profiler/mdprof_feedback.m:
    Add the command line option for the barrier cost during parallel execution.

deep_profiler/measurements.m:
    The incomplete parallel exec metrics structure now tracks deadtime due to
    futures explicitly.  Previously it was calculated from other values.

    Conform to the parallel execution time calculations in
    mdprof_fb.automatic_parallelism.m.  Each conjunct is delayed by:
        SparkDelay * (ConjNum - 1) except for the first.

    Fix signal costs, they're now stored with the conjunct that incurred them
    rather than the one that waited on the variable.  This also prevents them
    from being counted more than once.

    Added support for the new parallel execution overhead 'barrier cost'.

mdbcomp/feedback.automatic_parallelism.m:
    Added support for the new parallel execution overhead 'barrier cost'.

    Modified the parallel execution metrics so that different overheads are
    accounted for separately.

    Changed a comment so that it clarifies how the range of goals in the
    push_goal type should be interpreted.

mdbcomp/feedback.m:
    Increment feedback_version.
2011-01-22 04:27:02 +00:00
Paul Bone
70235cc3b8 Changes to goal-push feedback that _almost_ make it work. Ohe problem remains
that the recursive call looks cheap in cases where pushing goals is requited.

deep_profiler/mdprof_fb.automatic_parallelism.m:
    If pushing a goal and attempting a paralleisation fails then return the
    single costly goals to our caller so that it can attempt to push and
    parallelise these goals with it's own.

    Whether a goal is above the call site threshold or not no-longer depends on
    the goal type.  This switch has been removed.

    Add marks where pushes should be merged.

    Return pushes from goal_get_conjunctions_worth_parallelising and fill in
    the push goals list in the candidate procedure structure.

    Pretty-print the goal push list for a candidate procedure.

mdbcomp/feedback.automatic_parallelism.m:
    Remove the maybe push goal field from candidate conjunctions,

    There is already a list of push goals in the candidate procedure structure.

mdbcomp/feedback.m:
    Increment feedback_version.
2011-01-21 04:31:52 +00:00
Paul Bone
0d7e0e98cc Make the interesting recursion depth for singly-recursive code 2. This has the
affect that when trying to parallelise a loop that we assume the recursive call
will execute the recursive case once followed by the base case.  If this
parallelisation is optimistic, then it is optimistic to parallelise the whole
loop.

deep_profiler/mdprof_fb.automatic_parallelism.m:
    As above.

    Track the containing goal map for a procedure's implicit parallelism
    analysis.

deep_profiler/var_use_analysis.m:
    Fix the checks for module boundaries, they where placed in the wrong places.

    Handle recursive var use analysis by induction.

    Move the checks for unbounded recursion in this code to places that make
    more sense for the new analysis by induction.

    Duplicate the variable use analysis to create a specific one for computing
    variable use in the recursive and base cases.

    Documented this module's trace flags.

deep_profiler/measurement_utils.m:
    Fix the calculation of disjuncts of probabilities.

mdbcomp/mdbcomp.goal_path.m:
    Add another version of create_goal_id_array that takes a default value for
    each array slot.

mdbcomp/feedback.m:
    Increment feedback_version to reflect Zoltan's push goals changes.

mdbcomp/feedback.automatic_parallelism.m:
    Add a note asking people to increment feedback_version if they change any
    structures here.

deep_profiler/Mercury.options:
    Documented var_use_analysis' trace flags.
2011-01-20 13:44:11 +00:00
Paul Bone
0c42f810c2 Start working on the 'goal push' feedback.
This feedback information is part of automatic parallelisation feedback.  It
describes cases where goals after a branch goal but in the same conjunction
should be pushed into the branches of the branching goal.  This can allow the
pushed goal to be parallelised against goals that already exist in one or more
arms of the branch goal without parallelising the whole branch goal.

This change simply creates the data-structures within the feedback framework on
which this feature will be based.

nmdbcomp/feedback.automatic_parallelism.m:
    Introduce new push_goal structure that describes the transformation.

mdbcomp/feedback.m:
    Incremented feedback format version number.

deep_profiler/mdprof_fb.automatic_parallelism.m:
compiler/implicit_parallelism.m:
    Conform to changes in feedback.automatic_parallelism.m.

    The code to generate or use this feedback has not been implemented, that
    will come later.
2010-12-21 12:01:34 +00:00
Paul Bone
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).
2010-10-16 04:11:05 +00:00
Paul Bone
91e60619b0 Remove the concept of 'partitions' from the candidate parallel conjunction
mdbcomp/feedback.automatic_parallelism.m:
    Remove the concept of 'partitions' from the candidate parallel conjunction
    type.  We no-longer divide conjunctions into partitions before
    parallelising them.

mdbcomp/feedback.m:
    Increment the feedback format version number.

compiler/implicit_parallelism.m:
    Conform to changes in mdbcomp/feedback.automatic_parallelism.m.

deep_profiler/mdprof_fb.automatic_parallelism.m:
    Allow the non-atomic goals to be parallelised against one-another.

    Modify the goal annotations used internally, many annotations used only for
    calls are now used for any goal type.

    Variable use information is now stored in a map from variable name to lazy
    use data for every goal, not just for the arguments of calls.

    Do not partition conjunctions before attempting to parallelise them.

    Make the adjust_time_for_waits tolerate floating point errors more easily.

    Format costs with commas and, in most cases, two decimal places.

deep_profiler/var_use_analysis.m:
    Export a new predicate var_first_use that computes the first use of a
    variable within a goal.  This predicate uses a new typeclass to retrieve
    coverage data from any goal that can implement the typeclass.

deep_profiler/measurements.m:
    Added a new abstract type for measuring the cost of a goal, goal_cost_csq.
    This is like cs_cost_csq except that it can represent trivial goals (which
    don't have a call count).

deep_profiler/coverage.m:
    Added deterministic versions of the get_coverage_* predicates.

deep_profiler/program_representation_utils.m:
    Made initial_inst_map more generic in its type signature.

    Add a new predicate, atomic_goal_is_call/2 which can be used instead of a
    large switch on an atomic_goal_rep value.

deep_profiler/message.m:
    Rename a message type to make it more general, this is required now that we
    compute variable use information for arbitrary goals, not just calls.

library/list.m:
    Add map3_foldl.

NEWS:
    Announced change to list.m.
2010-10-14 04:02:22 +00:00
Zoltan Somogyi
fe58689750 Minor style fixes.
Estimated hours taken: 0.1
Branches: main

mdbcomp/feedback.m:
	Minor style fixes.
2010-08-24 06:36:39 +00:00
Paul Bone
7425922921 Refactor mdbcomp/feedback.m
Move automatic parallelisation specific code to a new module
mdbcomp/feedback.automatic_parallelism.m.

mdbcomp/feedback.m:
mdbcomp/feedback.automatic_parallelism.m:
	As above.

slice/Mmakefile
deep_profiler/Mmakefile
	Copy the new file into the current working directory when with the other
	mdbcomp files.

compiler/implicit_parallelism.m:
deep_profiler/mdprof_fb.automatic_parallelism.m:
deep_profiler/mdprof_feedback.m:
deep_profiler/measurements.m:
	Import the new module to access code that used to be in feedback.m

	Remove unused module imports.
2010-08-24 00:01:47 +00:00
Paul Bone
1580ad27ae Spell dependent correctly (not dependant) in identifiers comments and
strings.

mdbcomp/feedback.m:
deep_profiler/mdprof_fb.automatic_parallelism.m:
    As above.

mdbcomp/feedback.m:
    Increment the feedback version number.
2010-08-04 06:04:24 +00:00
Paul Bone
f16e8118bd Implement a linear alternative to the exponential algorithm that determines how
best to parallelise a conjunction.

Made other performance improvements.

mdbcomp/feedback.m:
    Add a field to the candidate_parallel_conjunction_params structure giving
    the preference of algorithm.

    Simplify the parallel exec metrics type here.  It is now used only to
    summarise information that has already been calculated.  The original code
    has been moved into deep_profiler/measurements.m

    Add a field to the candidate_par_conjunction structure giving the index
    within the conjunction of the first goal in the partition.  This is used
    for pretty-printing parallelisation reports.

    Incremented the feedback format version number.

deep_profiler/measurements.m:
    Move the original parallel exec metrics type and code here from
    mdbcomp/feedback.m

deep_profiler/create_report.m:
    Avoid a performance issue by memoizing create_proc_var_use_dump_report
    which is called by the analysis for the same procedure (at different
    dynamic call sites) many times.  In simple cases this more than doubled the
    execution time, in more complicated cases it should perform even better.

    Conform to changes in coverage.m

deep_profiler/mdprof_fb.automatic_parallelism.m:
    Implement the linear algorithm for parallelising a conjunction.

    Since we don't to parallelism specialisation don't try to parallelise the
    same procedure more than once.  This should avoid some performance problems
    but I haven't tested it.

    If it is impossible to generate an independent parallelisation generate a
    dependent one and then report it as something we cannot parallelise.  This
    can help programmers write more independent code.

    Use directed graphs rather than lookup maps to track dependencies.  This
    simplifies some code as the digraph standard library module already has
    code to compute reverse graphs and transitive closures of the graphs.

    Since there are now two parallelisation algorithms; code common to both of
    them has been factored out.

    The objective function used by the branch and bound search has been
    modified to take into account the overheads of parallel execution.  It is:
        minimise(ParTime + ParOverheads X 2.0)
    This way we allow the overheads to increase by 1csc provided that it
    reduces ParTime by more than 2csc.  (csc = call sequence counts)

    When pretty-printing parallelisation reports print each goal in the
    parallelised conjunction with it's new goal path.  This makes debugging
    easier for large procedures.

    Fix a bug where the goal path of scope goals was calculated incorrectly,
    this lead to a thrown exception in the coverage analysis code when it used
    the goalpath to lookup the call site of a call.

deep_profiler/mdprof_feedback.m:
    Support a new command line option for choosing which algorithm to use.
    Additionally the linear algorithm will be used if the problem is above a
    certain size and the exponential algorithm was chosen.  This can be
    configured including the fallback threshold.

    Print the user's choice of algorithm as part of the candidate parallel
    conjunctions report.

deep_profiler/message.m:
    Add an extra log message type for exceptions thrown during auto
    parallelisation.

deep_profiler/program_representation_utils.m:
    The goal_rep pretty printer now prints the goal path for each goal.

deep_profiler/coverage.m:
    procrep_annotate_with_coverage now catches and returns exceptions in a
    maybe_error result.

deep_profiler/cliques.m:
    Copy predicates from the standard library into cliques.m to prevent the
    lack of tail recursion from blowing the stack in some cases.  (cliques.m is
    compiled with --trace minimum).

deep_profiler/callgraph.m:
    Copy list.foldl from the standard library into callgraph.m and transform it
    so that it is less likely to smash the stack in non tail-recursive grades.

deep_profiler/read_profile.m:
    Transform read_nodes so that it is less likely to smash the stack in non
    tail-recursive grades.

deep_profiler/Mercury.options:
    Removed old options that where used to work around a bug.  The bug still
    exists but the work-around moved into the compiler long ago.
2010-08-04 02:25:02 +00:00
Paul Bone
531c2d94ea Automatic Parallelisation Improvements.
Factor in all the costs of parallelistion into the parallel overlap estimation
algorithm.  Previously only some costs where being taken into consideration.
Independent parallelsations are now generally preferred as they have fewer
overheads for similar parallelsations.

Generalised the branch and bound search algorithm into a new Mercury module.

mdbcomp/feedback.m:
    Grouped candidate parallel conjunction parameters into a single type.

    Added extra parameters:
        future_signal_cost
        future_wait_cost
        context_wakeup_delay.
    The first two replace locking cost, they are the costs of the signal and
    wait calls for futures respectively.  The third represents the length of
    time for a context to begin executing after it has been placed on the run
    queue.  It is used to estimate the cost of blocking.

    Refactored the parallel_exec_metrics type to make representing overheads easier.

    Modify parallel_exec_metrics so that it can represent the cost of calling
    signal in the left conjunct of any conjunct pair.

    Modify parallel_exec_metrics so that it stores the parallel execution time
    of the initial (leftmost) conjunct.  This is necessary as the parallel
    execution time includes the cost of the 'fork' call of the next conjunct.

    Modify parallel_exec_metrics to record the cost of blocking for the
    leftmost conjunct if it completes before the parallel conjunction completes
    as a whole.

    Increment the feedback file format version number.

compiler/implicit_parallelism.m:
    Conform to changes in mdbcomp/feedback.m.

deep_profiler/branch_and_bound.m:
    A generic branch and bound solver loop and utilities.

    The modified branch and bound code includes a profiling facility.

deep_profiler/Mercury.options:
    The new branch_and_bound module supports the debug_branch_and_bound trace
    flag.

deep_profiler/mdprof_fb.automatic_parallelism.m:
    Generalise and move branch and bound code to branch_and_bound.m

    Removed the candidate_parallel_conjunctions_opts type, we now use the
    candidate_par_conjunctions_params type in its place.

    Modify the code for parallelising conjunctions so that it works with lists
    of goals rather than cords of goals.

    Factor out the code tha looks for the next costly call, this is now handled
    by a preprocessing pass so that it has linear time rather than increasing
    the complexity of the search code.

    Documented some predicates in more detail.

deep_profiler/mdprof_feedback.m:
    Conform to changes in deep_profiler/mdprof_fb.automatic_parallelism.m and
    mdbcomp/feedback.m

    Add command line support for the new candidate parallel conjunctions
    feedback parameters.
2010-07-14 00:40:22 +00:00
Paul Bone
c877dceb2b Refactor profiler feedback code for implicit parallelism.
This change mostly re-factors the goal representation used to feedback implicit
parallelism information to the compiler.  The goal_rep datatype is now used
rather than the much simpler datatype.  (goal_rep is the same type that is used
by the declarative debugger).

This makes it easier for the compiler to match HLDS goals against goals from
the implicit parallelism analysis and will probably help in the future if the
analysis wants the compiler to re-order goals.

It also makes it easier to pretty-print the feedback sent to the compiler in
more detail.

mdbcomp/feedback.m:
    As above, redefine pard_goal as a type alias to
    goal_rep(pard_goal_annotation).

    Added a new type, candidate_par_conjunctions_proc, it represents candidate
    parallelisations within a procedure along with shared information for the
    procedure.

    Add a new predicate, convert_candidate_par_conjunctions_proc.

    Increment the feedback file format version number.

mdbcomp/program_representation.m:
    XXX: See about refactoring bytecode in/out put into one place.

    Add a new predicate transform_goal_rep for transforming a goal_rep
    structure from one arbitrary annotation type to another.

    Add extra predicates to aid in converting a prog_rep structure to and from
    bytecode.  This includes cut_byte/2 and can_fail_byte/2.

deep_profiler/program_representation_utils.m:
    Export print_goal_to_strings/4 so that it can be used when printing the
    feedback file reports.

deep_profiler/mdprof_fb.automatic_parallelism.m:
    Conform to changes in mdbcomp/feedback.m

    Wrap some lines at 76 characters.

    Improve explanations in comments.

    Use the goal_rep pretty-printer to print the candidate parallel
    conjunctions feedback report.

deep_profiler/mdprof_feedback.m:
    Conform to changes in deep_profiler/mdprof_fb.automatic_parallelism.m

deep_profiler/program_representation_utils.m:
    Modify print_goal_to_strings to print determinisms and annotations on
    separate lines before each goal.

deep_profiler/display_report.m:
    Modify pretty printing of coverage annotations so that they make sense
    after modifying print_goal_to_strings/4.

compiler/implicit_parallelism.m:
    Refactor goal matching code that compares HLDS goals to feedback goals.
    Goal matching is now more accurate and can more easily support goal
    re-ordering when parallelising code (this is not implemented yet).

    The code that builds parallel conjunctions has also been refactored.

    This pass now generates warnings if it is not able to parallelise
    a candidate parallel conjunction in the feedback data.

    Insert deeper and later parallelizations before shallower or earlier ones,
    this makes it easier to continue to parallelise a procedure as it's goal
    tree changes due to parallelisation.

    Silently ignore duplicate candidate parallel conjunctions.

    Refuse to parallelise a procedure that has been parallelized explicitly.

compiler/prog_rep.m:
    Re-factor the hlds_goal to bytecode transformation, this transformation now
    goes via goal_rep.  We use the hlds_goal to goal_rep portion of this
    transformation in compiler/implicit_parallelism.m.

    Add variable names prefixed with DCG_ to the list of those introduced by
    the compiler.

compiler/goal_util.m:
    Modify maybe_transform_goal_at_goal_path so that it returns a value that
    can describe the different kinds of error that may be encountered.

    Add a new predicate, maybe_transform_goal_at_goal_path_with_instmap.  Given
    a goal, goal path and initial inst map this predicate recurses the goal
    structure following the goal path and maintaining the inst map.  It then
    uses a higher order value to transform the goal at it's destination before
    re-constructing the goal.  It is different to
    maybe_transform_goal_at_goal_path in that it passes the instmap to it's
    higher order argument, the instmap is correct for the state immediately
    before executing the goal in question.

compiler/hlds_pred.m:
    Include the procedure's varset in the information used to construct the
    program representation data that is included in deep profiling builds.

compiler/instmap.m:
    Add a useful function, apply_instmap_delta_sv.  This is the same as
    apply_instmap_delta except that it's arguments are in a more convenient
    order for state variable notation.

compiler/stack_layout.m:
    Export compute_var_number_map for the use of implicit_parallelism.m and
    prog_rep.m

compiler/error_util.m:
    Add a new error phase, 'phase_auto_parallelism'.  This is used for warnings
    issued from the automatic parallelisation transformation.

compiler/deep_profiling.m:
    Conform to changes in hlds_pred.m

compiler/mercury_compile_middle_passes.m:
    Conform to changes in implicit_parallelism.m

compiler/type_constraints.m:
    Conform to changes in goal_util.
2010-07-04 10:24:09 +00:00
Paul Bone
455f87ba38 Automatic parallelisation improvements.
The automatic parallelisation analysis now searches for the best way to
parallelise a conjunction when it's deciding if parallelisation is worth-while.
This mostly affects unifications and other cheap goals between two calls being
parallelised; it decides which parallel conjunct each of these goals should be
placed in.  The search used is a branch and bound search.

deep_profiler/mdprof_fb.automatic_parallelism.m:
    As above,

    find_costly_call now returns find_costly_call_result rather than using the
    maybe type.  Instantiation sub-typing is used to guarantee that the goal
    returned is indeed a costly call.

    Fix a bug in calculate_dependant_parallel_cost.

    When printing the candidate parallel conjunction report include the goals
    before and after a parallel conjunction.

    Document the debug_parallel_conjunction_speedup trace flag.

    Create a new type parallelise_dep_conjs rather than using a boolean to
    represent this option.

    Add a new trace flag, debug_branch_and_bound enables trace goals that can
    be used to debug the branch and bound search for the best parallelisation.

deep_profiler/mdprof_feedback.m:
    When printing the candidate parallel conjunction report remove some
    vertical whitespace after the header of the report.

deep_profiler/Mercury.options:
    Add a new trace flag, debug_branch_and_bound enables trace goals that can
    be used to debug the branch and bound search for the best parallelisation.
    This is commented out.

mdbcomp/feedback.m:
    Include the goals before and after a parallel conjunction in the
    candidate_par_conjunction type.

    Modify the parallel_exec_metrics code so that it can handle the cost of the
    goals before and after a parallel conjunction.

    Increment the feedback file format version.

    When reading a feedback file strip the program name of leading and trailing
    whitespace.

    When printing a message for the incorrect_program_name error enclose the
    program names in quotes.

    Conform to changes in mdprof_fb.automatic_parallelism.m
2010-06-08 13:00:51 +00:00
Paul Bone
452dcd116c mdprof_feedback improvements.
Add an option to mdprof_feedback to print the feedback report without modifying
it.  This option also avoids reading and parsing a Deep.data file, this makes
it quick and convenient if you just wish to view the feedback report.

deep_profiler/mdprof_feedback.m:
    As above,

    These changes make it necessary for the feedback_info structure to store
    the program's name that the feedback is generated for.  mdprof_feedback now
    also checks that the program names in the feedback file, and deep profiling
    data match.

mdbcomp/feedback.m:
    Store the name of the program in the feedback_info structure and provide
    methods to query this.

    read_or_create now takes a new parameter, the name of the program that
    we're creating a feedback file for.  Or if a feedback file already exists,
    the name that is checked against the one in the existing feedback file.

    init_feedback_file now takes a new parameter, the name of the program that
    this feedback_info structure is for.

    These changes haven't changed the format of the feedback file, it always
    contained the program's name.  Therefore the feedback file version number
    has not been incremented.

compiler/globals.m:
    The feedback field in the compiler's globals structure now has the type
    maybe(feedback).  If feedback data couldn't be, or wasn't read then empty
    feedback data is no longer used.

compiler/handle_options.m:
    Conform to changes in mdbcomp/feedback.m and compiler/globals.m.

compiler/implicit_parallelism.m:
    Conform to changes in compiler/globals.m
2010-05-13 02:27:38 +00:00
Paul Bone
b7f0270f36 Implement the new algorithm for calculating how dependant parallel conjuncts'
executions overlap.  This algorithm has also been generalised to handle cases
where there are more than two conjuncts in a parallel conjunction.  A number of
other improvements have also been made.

deep_profiler/mdprof_fb.automatic_parallelism.m:
    Wrote dependant parallel conjunction overlap analysis algorithm (as above).

    This algorithm introduced a new structure, parallel_execution_overlap.
    This structure describes how dependant parallel executions overlap.

    Use both sparking cost and sparking delay as costs of parallelisation.
    Sparking cost is the cost from the perspective of the sparker, whereas
    delay is the delay between creating the spark and actually beginning the
    execution of the spark.

    Handle pretty-printing of the candidate parallel conjunction structure.

    Include variable identifiers as well as canonical names in the
    pardgoal_type structure.

    The inst_map_info structure has been modified to contain the sets of
    consumed and produced variables separately, rather than simply containing a
    set of all consumed and produced variables.

    Improve the readability of messages printed by trace goals.

    The search code no longer attempts to look up procedure bodies for code
    whose module is "Mercury runtime".

    Conjunctions that did not have a speedup due to parallelisation are now
    printed out by a new trace goal.

deep_profiler/mdprof_feedback.m:
    Include support for pretty printing the feedback information after
    creating it.  This is handled by the new --report command line option.

    Include a new --implicit-parallelism-sparking-delay command line option.
    This may be used to specify how long it takes an engine to steal a spark.

mdbcomp/feedback.m:
    Export the sparking delay as part of the feedback information.

    Create a new structure parallel_exec_metrics which contains many metrics
    about parallel execution performance.  This is exported for each candidate
    parallel conjunction rather than only exporting the Speedup.

    Create predicates for creating and querying the parallel_exec_metrics
    structure.

    Create a new predicate, get_all_feedback_data/2, this is used to retrieve
    all the data for building the report in the mdprof_feedback tool.

    Increment the feedback file format version number.

deep_profiler/message.m:
    Improve the readability of the messages printed due to verbosity settings.

    Export some predicates that can be used for managing indentation while
    pretty-printing structures.

compiler/implicit_parallelism.m:
    Conform to changes in feedback_data_candidate_parallel_conjunctions.

    Add a pi_sparking_delay field to parallelism information.

deep_profiler/program_representation_utils.m:
    Fix a bug in calc_inst_map_delta/3.

    Correct a comment for inst_map_ground_vars/5.

deep_profiler/cliques.m:
    Fixed a minor indentation issue.

deep_profiler/Mercury.options:
    Document the new trace goal that enables printing of candidate parallel
    conjunctions that do not result in a speedup.
2010-04-30 13:09:54 +00:00
Paul Bone
3d6770a091 Refactor feedback parallelisation code.
These changes rename some poorly named types from inner_goal to pard_goal.
'pard' means 'parallelised'.  This is explained in a comment near this type.
The candidate_par_conjunction type has been made polymorphic on the type that
it uses to represent individual goals.  This is easier than using slightly
different candidate_par_conjunction types in different modules.

mdbcomp/feedback.m:
    Changes to types as above.

    Introduce predicates to convert candidate_par_conjunctions from one type to
    anther given a function to convert the type of goal used.

    Increment the feedback file format version number.

deep_profiler/mdprof_fb.automatic_parallelism.m:
    Remove our alternative candidate_par_conjunction types in favor of the
    polymorphic type in feedback.m

    Rename the type inner_goal_internal to pard_goal_detail.

    Rename occurrences inner_goal or InnerGoal to pard_goal or PardGoal.

    Use the generic conversion code in feedback.m to convert between different
    types of candidate_par_conjunction.

    Conform to changes in mdbcomp/feedback.m

compiler/implicit_parallelism.m:
    Rename occurrences inner_goal or InnerGoal to pard_goal or PardGoal.

    Conform to changes in mdbcomp/feedback.m
2010-03-25 01:17:03 +00:00
Paul Bone
79c3f39a68 Implicit parallelism work.
The implicit parallelism algorithm, feedback file format and therefore compiler
have been updated.  They now support parallelisation across other goals and, in
theory, parallelising three or more calls against one another.  The algorithm
is far from complete and very much experimental, it has been tested on a
modified version of icfp_2000 where it improves the runtime.  Note that
automatic parallelisation of dependant conjunctions is disabled for now.

mdbcomp/feedback.m:
    Modify deep profiling feedback data, a candidate parallel conjunct now
    contains a list of sequential conjunctions that contain other goals.
    Previously only two calls to be parallelised against one-another where
    listed.

    Document restrictions on the new candidate parallel conjunct structure that
    can't be expressed by the type system.

    Incremented the feedback file format number.

mdbcomp/program_representation.m:
    Made a semidet predicate version of empty_goal_path.

    Created maybe_search_var_name which returns it's result wrapped in a maybe
    structure, this is a deterministic alternative to search_var_name.  It is
    useful as an argument to list.map

deep_profiler/mdprof_feedback.m:
    When printing messages out to stderr also print the newlines between the
    messages to stderr.

deep_profiler/measurements.m:
    Re-aranged the order of arguments and added a four argument version for
    sub_computation_parallelism.

    Added a new function, some_parallelism/1, that initialises a parallelism
    amount as.

deep_profiler/message.m:
    Added extra messages.

    Pretty-print program locations using the conventional string representation
    for procedures and goal paths.  Export the predicate that does this.

deep_profiler/program_representation_utils.m:
    Export a predicate to format a procedure identifier nicely.

    Add code for calculating and manipulating inst_map_delta objects similar to
    those in the compiler.

deep_profiler/mdprof_fb.automatic_parallelism.m:
    Various code cleanups/simplifications.

    Re-worked the parallelisation algorithm, it can now parallelise across
    cheaper calls and (theoretically) handle parallel conjunctions with any
    number of conjuncts.

    Conform to new candidate parallel conjunction representation.

    Internally use a structure similar to the candidate parallel conjunct
    structure in feedback.m  This makes the maybe_call_conjunct structure
    obsolete, the old structure has been removed.

compiler/implicit_parallelism.m:
    Updated implicit parallelism transformation to conform to the new feedback
    file format.

compiler/goal_util.m:
    Added goal_is_atomic/2
    Modified create_conj_from_list to simply return the only goal in the list
    when the list contains exactly one goal.

library/maybe.m:
    Add a simple predicate (maybe_is_yes/2) that 'opens' a maybe and returns the result or
    fails.

NEWS:
    Announce maybe_is_yes/2
2010-01-09 05:49:41 +00:00
Paul Bone
b1257cbf48 Search for parallelism opportunities in a clique-wise manner.
Estimated hours taken: 25
Branches: main

Search for parallelism opportunities in a clique-wise manner.  Starting at the
root clique traverse expensive calls to find cliques with procedures that
should be parallelised.  This has several advantages, namely it gives a simple
method for calculating an approximation of the cost of a recursive call site.
In the future it will make it easier to perform specialise parallel versions
of procedures.

deep_profiler/mdprof_feedback.m:
    As above.
    Create a logging facility that provides some information about the
    analysis to the user, I'm using this to determine the order of features I
    should implement based on the usefulness of such a feature in analysed
    programs.  This has necessitated changes to the command line interface.

deep_profiler/profile.m:
	Introduce deep_get_progrep_det/2 to retrieve the program representation
	structure from a deep structure or throw an exception.

deep_profiler/report.m:
	Add more information to a comment.

mdbcomp/feedback.m:
	Add more information about a structure field's semantics in the field name
	and comment.
	Incremented the feedback file version number.

deep_profiler/Mercury.options
    Remove some old --no-warn-unused-imports flags.
2009-03-12 03:33:42 +00:00
Paul Bone
0bbb6d07fa Support implicit parallelism in the compiler.
Estimated hours taken: 20
Branches: main

Support implicit parallelism in the compiler.

The compiler now uses the deep profiler feedback information to build a
parallel version of a program.

Changes have also been made to the feedback format for candidate parallel
conjunctions and the analysis that recommends opportunities for parallelism to
the compiler.

compiler/implicit_parallelism.m:
	Mark Tannier's implementation as deprecated (it also crashes the
	compiler).
	Introduce new implicit parallelism transformation.
	apply_implicit_parallelism_transformation now returns maybe_error rather
	than maybe so that errors can be described.

compiler/goal_util.m:
	Add a predicate to transform a goal referenced by a goal path within a
	larger goal structure and rebuild that structure.

compiler/mercury_compile.m:
	Conform to changes in implicit_parallelism.m

deep_profiler/mdprof_feedback.m:
	Return a cord of warnings from many predicates, these warnings are used to
	describe cases where parallelism might be profitable but it is not (yet)
	possible to transform the code into parallel code.
	Fix a bug whereby the wrong deep profiling statistic was used to calculate
	the cost of a call.
	Do not attempt to parallelise calls with other goals between them.

mdbcomp/feedback.m:
	Remove the intermediate goals information from the candidate parallel
	conjunctions feedback data.

mdbcomp/program_representation.m:
	Provide a in-order alternative to the goal_path type so that operations on
	the start of the goal path occur in constant time and goal_path itself
	remains usable as a key in arrays because it doesn't use the cord type
	internally.

library/cord.m:
	Added a di/uo mode to cord.foldl_pred.

library/list.m:
	Added list.find_index_of_match/4 to return the index of the first item in
	a list that satisfies the predicate given in the first argument.

library/pqueue.m:
	Added pqueue.length/1

NEWS:
	Announce standard library changes.
2009-01-30 03:51:45 +00:00
Paul Bone
effa745ab5 Perform implicit parallelism analysis in mdprof_feedback.
Estimated hours taken: 27
Branches: main

Perform implicit parallelism analysis in mdprof_feedback.  This calculates the
amount of parallelism available in dependant conjunctions and advises the
compiler how to parallelise code via the feedback system.

deep_profiler/mdprof_feedback.m:
	Implement implicit parallelisation analysis.

deep_profiler/program_representation_utils.m:
	Add a simple implementation of inst maps which are used by the implicit
	parallelisation analysis.  This implementation also tracks that variables
	that are required in order to instantiate a variable.
	Export some procedures used by the variable use analysis for use in the
	parallelisation analysis in mdprof_feedback.m
	Create an extra predicate to retrieve all the variables used by an atomic
	goal.
	Move utility code in this module to the end.

deep_profiler/report.m:
	Add utility function to convert cost_until_var_use values to raw values
	either since the beginning of the procedure or before the end.

mdbcomp/feedback.m:
	Modified the format of implicit parallelism feedback information.
	Incremented the feedback file format version.

mdbcomp/program_representation.m:
	Added a procedure to search for a variable name in a variable table and
	fail if it cannot find it.
2008-10-20 06:31:28 +00:00
Paul Bone
6a6e81b9e3 Add a new structure to the feedback data type,
Estimated hours taken: 2
Branches: main

Add a new structure to the feedback data type,
candidate_parallel_conjunctions, This produces feedback information about
parallel conjunctions that may be parallelised.

This data is not yet collected by the mdprof_feedback tool, or used by the
compiler.

Make changes to the feedback API and on disk format.  This makes it easier to
query the feedback_info structure for feedback data.

mdbcomp/feedback.m:
	Introduce candidate_parallel_conjunctions feedback information.
	Remove type arguments from feedback predicates.
	Move feedback_type out of this modules interface.
	Use a partially instantiated feedback_data data structure to retrieve
	feedback data, A caller of get_feedback_data no-longer needs to use a
	switch to check that they received the correct data.
	Remove keys from the on disk format, removing the risk that some data
	could be stored against an incorrect key.
	Increment the feedback data file version number.

compiler/implicit_parallelism.m:
	conform to changes in mdbcomp/feedback.m

compiler/options.m:
	Added the --implicit-parallelisation-old compiler option, this will enable
	the old implicit parallelism implementation.

deep_profiler/mdprof_feedback.m:
	Added options for collecting the candidate_parallel_conjunctions feedback
	data.
2008-09-30 02:30:51 +00:00
Zoltan Somogyi
03035ad2e6 Convert Paul's new code to use cords of strings to represent HTML.
Estimated hours taken: 6
Branches: main

Convert Paul's new code to use cords of strings to represent HTML.

deep_profiler/html_format.m:
	Convert to using cords. Restructure the code in a couple of places
	to always put start and end tags around HTML fragments together.

	Fix a missing "=" in a tag.

deep_profiler/interface.m:
deep_profiler/mdprof_cgi.m:
deep_profiler/read_profile.m:
	Provide better diagnostics.

deep_profiler/create_report.m:
deep_profiler/display.m:
deep_profiler/display_report.m:
deep_profiler/mdprof_feedback.m:
deep_profiler/measurement_units.m:
deep_profiler/query.m:
deep_profiler/report.m:
mdbcomp/feedback.m:
	Misc cleanups. They can be considered my post-commit review of Paul's
	diff.

	In mdprof_feedback.m, delete a strange test that prevented the program
	from being used from the command line.

deep_profiler/dump.m:
deep_profiler/mdprof_dump.m:
deep_profiler/timeout.m:
deep_profiler/util.m:
	Misc cleanups of old code.
2008-08-04 03:17:55 +00:00
Paul Bone
01d145ab8f Introduce a feedback system that allows analysis tools to feed information
Estimated hours taken: 8
Branches: main

Introduce a feedback system that allows analysis tools to feed information
back into the compiler.  This can be used with the deep profiler to improve
many optimizations.  Tools update information in the feedback file rather than
clobbering existing un-related information.

Modify the implicit parallelism work to make use of the new feedback system.
mdprof_feedback updates a feedback file and in the future will be able to
collect more information from the deep profiler.

mdbcomp/feedback.m:
	Created a new module for the feedback system, types representing feedback
	information and predicates for reading and writing feedback files, and
	manipulating feedback information are defined here.

mdbcomp/mdbcomp.m:
	Updated to include the mdbcomp/feedback.m in this library.

mdbcomp/program_representation.m:
	Created a new type to describe a call.  This is used by the current
	implicit parallelism implementation.

deep_profiler/mdprof_feedback.m:
	Updated to use the new feedback system.  The old feedback file code has
	been removed.
	--program-name option has been added, a program name must be provided to
	be included in the header of the feedback file.
	Conform to changes in mdbcomp/program_representation.m

compiler/globals.m:
	Added feedback data to globals structure.
	Added predicates to get and set the feedback information stored in the
	globals structure.
	Modified predicates that create the globals structure.

compiler/handle_options.m:
	Set feedback information in globals structure when it is created in
	postprocess_options.
	Read feedback information in from file in check_option_values.
	Code added to postprocess_options2 to check the usage of the
	--implicit-parallelism option.

compiler/implicit_parallelism.m:
	This module no-longer reads the feedback file it's self, this code has
	been removed, as has the IO state.
	Information from the feedback state is retrieved and used to control
	implicit parallelism.

compiler/mercury_compile.m:
	No-longer checks options for implicit parallelization, this is now done in
	compiler/handle_options.m.
	Conform to changes in implicit_parallelism.m

deep_profiler/Mmakefile:
slice/Mmakefile:
	Modified to include mdbcomp/feedback.m for compilation in this directory.
2008-07-23 23:20:35 +00:00