Commit Graph

15 Commits

Author SHA1 Message Date
Zoltan Somogyi
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.
2021-03-06 18:30:50 +11:00
Zoltan Somogyi
409cbcb6a3 Unify getopt.m and getopt_io.m ...
... using an approach proposed by Peter, with an extra twist from Julien.

Instead of having two modules, getopt.m and getopt_io.m, with the former
defining predicates that do not take an I/O state pair, and the latter
defining predicates that do take an I/O state pair, put both kinds of
predicates into a single module. The versions with an I/O state pair
have an "_io" suffix added to their names for disambiguation.
Both versions are a veneer on top of a common infrastructure,
which relies on a simple type class to implement the operation
"give the contents of the file with this name". The predicate versions
with I/O state pairs have a normal implementation of this typeclass,
while the predicate versions that do not have I/O state pairs
have an implementation that always returns an error indication.

The above change just about doubles the number of exported predicates.
We already had two versions of most exported predicates that differed
in whether we returned errors in the form of a string, or in the form
of a structured representation, with names of the latter having
an "_se" suffix. Since we agreed that the structured representation
is the form we want to encourage, this diff deletes the string versions,
and deletes the "_se" suffix from the predicate names that used to have them.
(It still remains at the end of the name of a type.) This "undoubling"
should offset the effect of the doubling in the previous paragraph.

Eventually, we want to have just one module, getopt.m, containing
the updated code described above, but for now, we put the same code
into both getopt_io.m and getopt.m to prevent too big a shock to
people with existing code that uses getopt_io.m.

library/getopt.m:
library/getopt_io.m:
    Make the changes described above.

library/Mmakefile:
    Instead of building both getopt_io.m and getopt.m from getopt_template,
    build getopt.m from getopt_io.m.

tools/bootcheck:
    Delete references to getopt_template.

compiler/typecheck_errors.m:
    When a type error involves one of the getopt/getopt_io predicates
    whose interfaces are changed by this diff, tell the user about
    how these changes could have caused the error, and thus what the
    probable fix is.

compiler/handle_options.m:
browser/parse.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:
profiler/mercury_profile.m:
slice/mcov.m:
slice/mdice.m:
slice/mslice.m:
slice/mtc_diff.m:
slice/mtc_union.m:
tests/hard_coded/space.m:
    Use the updated getopt interface.

compiler/compile_target_code.m:
compiler/compute_grade.m:
compiler/deforest.m:
compiler/det_report.m:
compiler/format_call.m:
compiler/globals.m:
compiler/goal_expr_to_goal.m:
compiler/make.build.m:
compiler/make.m:
compiler/make.module_dep_file.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/mercury_compile_main.m:
compiler/ml_top_gen.m:
compiler/module_cmds.m:
compiler/op_mode.m:
compiler/optimization_options.m:
compiler/options.m:
compiler/write_module_interface_files.m:
tools/make_optimization_options_middle:
tools/make_optimization_options_start:
    Replace references to getopt_io.m with references to getopt.m.

tests/invalid/getopt_io_old.{m,err_exp}:
tests/invalid/getopt_old.{m,err_exp}:
tests/invalid/getopt_old_se.{m, err_exp}:
    New test cases for the extra help

tests/invalid/Mmakefile:
    Enable the new test cases.
2020-10-09 19:30:46 +11:00
Zoltan Somogyi
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.
2017-04-30 15:48:13 +10:00
Zoltan Somogyi
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.
2015-07-15 15:30:22 +02:00
Zoltan Somogyi
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).
2011-01-27 08:03:54 +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
Julien Fischer
705946f63d Fix a typo: s/DUmp/dump/
deep_profiler/mdprof_dump.m:
	Fix a typo: s/DUmp/dump/
2008-03-05 05:05:49 +00:00
Paul Bone
1c64a93ac1 Improved mdprof_dump's command line parsing.
Estimated hours taken: 2

Branch: main

Improved mdprof_dump's command line parsing.  It's behaviour is now more
obvious.  Major changes include The "-D restrict" option is now "--restrict",
and is no-longer affected by other -D options.  Silently ignored -D options
have now been documented as unimplemented.

deep_profiler/dump.m:
	use a structured representation of command line parameters used to control
	deep_dump/4 and deep_initial_dump/4.

deep_profiler/startup.m:
	Conform to changes in dump.m, read_and_startup now takes a deep_options
	type rather than a list of strings.  A new version of read_and_startup has
	been created that doesn't take any deep_options and assumes the defaults.

deep_profiler/mdprof_dump.m:
	Modified command line options, The '-D' option is now only used to specify
	what arrays to dump.  A new option, '--restrict', controls whether to
	print unreferenced call_site_statics and proc_statics.

deep_profiler/mdprof_cgi.m:
deep_profiler/mdprof_feedback.m:
deep_profiler/mdprof_test.m:
	Conform to changes in startup.m, now makes use of dump.m.
2008-02-17 06:48:38 +00:00
Julien Fischer
6f12288feb Fix a typo: s/--D/-D/ in the help message.
Estimated hours taken: 0
Branches: main

deep_profiler/mdprof_dump.m:
	Fix a typo: s/--D/-D/ in the help message.
2006-11-08 05:24:37 +00:00
Zoltan Somogyi
c262737998 Include call sequence numbers in the pages generated by the deep profiler
Estimated hours taken: 16
Branches: main

Include call sequence numbers in the pages generated by the deep profiler
(if the user's preferences ask for this).

NEWS:
	Announce the new capability.

deep_profiler/measurements.m:
	Standardize on one spelling of call sequence numbers (callseqs).

	Add some utility predicates for use in dump.m.

	Fix a bug in the calculation of the number of calls: redos enter
	procedure invocations, not leave them.

deep_profiler/profile.m:
	Fix a bug: the num_callseqs field was in the wrong place.

deep_profiler/html_format.m:
	When generating a line of the clique description, include call sequence
	number information if requested.

	Do likewise when generating other HTML fragments that have to match
	the contents of those lines (e.g. the table headers).

	Generate the links that allow the users to sort rows by call
	sequence numbers.

	Generate the links that allow the users to toggle the switches
	controlling the display of call sequence number information.

	Do not show the toggles relevant to the display of times if times are
	not being displayed.

deep_profiler/interface.m:
	Extend the preferences to allow requests for call sequence number
	information.

	Include the display of call sequence numbers in the default set of
	preferences. However, include the display of time information in the
	default only of the profiling run lasted long enough for this
	information to have some hope of being useful.

	Rename some function symbols to avoid ambiguities.

deep_profiler/query.m:
	Extend the menu to include links for the most expensive
	cliques/procedures as measured by call sequence numbers.

	Include the links for the most expensive cliques/procedures as
	measured by clock ticks in the menu only if the profiling run
	lasted long enough for this to be useful.

	Print out the total number of call sequence numbers with the other
	statistics.

	Use call sequence numbers instead of time to decide where the "action"
	begins, since this works even for short profiling runs.

deep_profiler/top_procs.m:
	Provide the capability of sorting on call sequence numbers.

deep_profiler/dump.m:
	Provide the capability to dump out several more fields of the top level
	structure (profile.deep), including the cliques, the reverse links and
	the propagated measurement information.

deep_profiler/startup.m:
	Dump out the cliques, the reverse links and the propagated measurement
	information when computed.

deep_profiler/mdprof_cgi.m:
	Add an option for setting the hostname in the generated links to
	"localhost". This is useful on laptops temporarily disconnected
	from the Domain Name System (e.g. my laptop).

	Set this option automatically if the name of the file in the initial
	query has a ".localhost" suffix added to it.

	Add some tracing hooks.

deep_profiler/mdprof_test.m:
	Add an option to specify what info to dump during startup.

deep_profiler/mdprof_dump.m:
	Switch to using the compiler's method of specifying what to dump,
	since this is more maintainable.

deep_profiler/exclude.m:
	Rename some function symbols to avoid ambiguities.

deep_profiler/timeout.m:
	Add conditionally compiled code to help debug lock management.

deep_profiler/callgraph.m:
deep_profiler/canonical.m:
deep_profiler/cliques.m:
deep_profiler/conf.m:
deep_profiler/read_profile.m:
	Minor cleanups.
2006-10-12 06:30:23 +00:00
Julien Fischer
4752726c7d Use trace goals to conditionally enable lowlevel debugging traces for the
Estimated hours taken: 0.5
Branches: main

Use trace goals to conditionally enable lowlevel debugging traces for the
code that reads deep profiles.

deep_profiler/read_profile.m:
	Use trace goals to conditionally enable the lowlevel debugging code
	in this module in preference to commenting it out.  (The debugging
	code itself could be more useful than it is but that's a separate
	change - at the moment I'm just using to try and isolate roughly
	where the code in the runtime that writes out profiles is broken.)

	Fix some formatting.

deep_profiler/mdprof_dump.m:
	Fix a typo and a couple of minor formatting fixes.

boehm_gc/Mmakefile:
	Avoid an error from make if realcleaning the libatomic_ops
	directory fails which it will if realclean is run multiple times
	without that directory being reconfigured.
2006-10-09 08:09:04 +00:00
Julien Fischer
459847a064 Move the univ, maybe, pair and unit types from std_util into their own
Estimated hours taken: 18
Branches: main

Move the univ, maybe, pair and unit types from std_util into their own
modules.  std_util still contains the general purpose higher-order programming
constructs.

library/std_util.m:
	Move univ, maybe, pair and unit (plus any other related types
	and procedures) into their own modules.

library/maybe.m:
	New module.  This contains the maybe and maybe_error types and
	the associated procedures.

library/pair.m:
	New module.  This contains the pair type and associated procedures.

library/unit.m:
	New module. This contains the types unit/0 and unit/1.

library/univ.m:
	New module. This contains the univ type and associated procedures.

library/library.m:
	Add the new modules.

library/private_builtin.m:
	Update the declaration of the type_ctor_info struct for univ.

runtime/mercury.h:
	Update the declaration for the type_ctor_info struct for univ.

runtime/mercury_mcpp.h:
runtime/mercury_hlc_types.h:
	Update the definition of MR_Univ.

runtime/mercury_init.h:
	Fix a comment: ML_type_name is now exported from type_desc.m.

compiler/mlds_to_il.m:
	Update the the name of the module that defines univs (which are
	handled specially by the il code generator.)

library/*.m:
compiler/*.m:
browser/*.m:
mdbcomp/*.m:
profiler/*.m:
deep_profiler/*.m:
	Conform to the above changes.  Import the new modules where they
	are needed; don't import std_util where it isn't needed.

	Fix formatting in lots of modules.  Delete duplicate module
	imports.

tests/*:
	Update the test suite to confrom to the above changes.
2006-03-29 08:09:58 +00:00
Julien Fischer
2c686ea193 Convert the rest of the deep profiler to four-space indentation.
Estimated hours taken: 1.5
Branches: main

Convert the rest of the deep profiler to four-space indentation.
There are no changes to any algorithms (other than introducing state
variables in a few spots).

Remove an old bug workaround.

deep_profiler/*.m:
	Convert to four-space indentation where that has not already
	been done.

	Fix some bad line breaks.

	Use state variables in a few places.

	Reposition comments according to our current coding standard.

deep_profiler/Mercury.options:
	Remove some old bug workarounds.
2005-11-08 08:12:40 +00:00
Julien Fischer
4083fe5bf2 Cleanup the deep profiler.
Estimated hours taken: 1
Branches: main

Cleanup the deep profiler.
There are no changes to any algorithms.

deep_profiler/*.m:
	Switch to state variable notation throughout.  Rearrange
	the order of some procedure arguments to facilitate this.

	Remove some unnecessary module imports.

	Reformat comments according to our current coding standard.

	Update comments that refer to modules that no longer exist.
2005-06-23 08:21:29 +00:00
Zoltan Somogyi
d8694dc1aa Significantly enhance the infrastructure for debugging problems with the deep
Estimated hours taken: 8
Branches: main

Significantly enhance the infrastructure for debugging problems with the deep
profiler by providing facilities for dumping out some of the main data
structures. These were needed for my recent fix of mercury_deep_profiling.c
in the runtime.

There are no algorithmic changes in the non-debugging parts of the code.

deep_profiler/dump.m:
	New module for containing predicates that dump data structures.
	The first draft was by Julien.

deep_profiler/mdprof_dump.m:
	New program for dumping out the contents of Deep.data files.
	The first draft was by Julien.

deep_profiler/startup.m:
	Provide a mechanism for dumping out the main data structures at three
	stages.

deep_profiler/mdprof_cgi.m:
deep_profiler/mdprof_test.m:
	Pass the options to startup to control these dumps.

deep_profiler/measurements.m:
	Provide a mechanism for getting all the counts of a measurement at
	once.

deep_profiler/array_util.m:
	Provide extra modes of some predicates for use in the other modules.

deep_profiler/read_profile.m:
	Fix Julien's fix: handle init predicates as well as the other uci
	predicates.

deep_profiler/profile.m:
	Reorder the arguments of predicates as required to enable the use
	of state variable notation in the callers.

deep_profiler/*.m:
	Conform to the change in profile.m, and use state variable notation
	where this is advantageous.

	Convert some modules to four-space indentation where this eliminates
	excessive indentation or bad line breaks.

deep_profiler/Mmakefile:
	Handle the new mdprof_dump program.
2005-04-25 06:51:58 +00:00