mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-14 05:12:33 +00:00
4987cd686e2c2cdf1cb3d320d22a1745cb47b151
5 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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. |
||
|
|
8e3ead5903 |
Reduce the size of the string tables in debuggable executables by encoding
Estimated hours taken: 6 Branches: main Reduce the size of the string tables in debuggable executables by encoding variable names that fit a few standard templates, the most important of which is STATE_VARIABLE_name_number. The effect on the compiler is to reduce the string table size from about 3.1Mb to about 2.1Mb, which is about a 30% reduction. compiler/stack_layout.m: Look for the names fitting the patterns in variable names, and encode them. runtime/mercury_stack_layout.[ch]: Add a function for looking up variable names, decoding them if needed. Since goal paths cannot fit any of the patterns, access them without using that function. mdbcomp/rtti_access.m: Use the new function to retrieve variable names. runtime/mercury_grade.h: Increment the debugging compatibility version number, since debuggable executables in which some modules were produced by a compiler without this diff and some were produced by a compiler with this diff won't work together. |
||
|
|
2dc982cfe4 |
Make a representation of the program available to the deep profiler.
Estimated hours taken: 50 Branches: main Make a representation of the program available to the deep profiler. We do this by letting the user request, via the option "--deep-procrep-file" in MERCURY_OPTIONS, that when the Deep.data file is written, a Deep.procrep file should be written alongside it. The intended use of this information is the discovery of profitable parallelism. When a conjunction contains two expensive calls, e.g. p(...) and q(...) connected by some shared variables, the potential gain from executing them in parallel is limited by how early p produces those variables and how late q consumes them, and knowing this requires access to the code of p and q. Since the debugger and the deep profiler both need access to program representations, put the relevant data structures and the operations on them in mdbcomp. The data structures are significantly expanded, since the deep profiler deals with the whole program, while the debugger was interested only in one procedure at a time. The layout structures have to change as well. In a previous change, I changed proc layout structures to make room for the procedure representation even in non-debugging grades, but this isn't enough, since the procedure representation refers to the module's string table. This diff therefore makes some parts of the module layout structure, including of course the string table, also available in non-debugging grades. configure.in: Check whether the installed compiler can process switches on foreign enums correctly, since this diff depends on that. runtime/mercury_stack_layout.[ch]: runtime/mercury_types.h: Add a new structure, MR_ModuleCommonLayout, that holds the part of the module layout that is common to deep profiling and debugging. runtime/mercury_deep_profiling.[ch]: The old "deep profiling token" enum type was error prone, since at each point in the data file, only a subset was applicable. This diff breaks up the this enum into several enums, each consisting of the choice applicable at a given point. This also allows some of the resulting enums to be used in procrep files. Rename some enums and functions to avoid ambiguities, and in one case to conform to our naming scheme. Make write_out_proc_statics take a second argument. This is a FILE * that (if not NULL) asks write_out_proc_statics to write the representation of the current module to specified stream. These module representations go into the middle part of the program representation file. Add functions to write out the prologue and epilogue of this file. Write out procedure representations if this is requested. Factor out some code that is now used in more than one place. runtime/mercury_deep_profiling_hand.h: Conform to the changes to mercury_deep_profiling.h. runtime/mercury_builtin_types.c: Pass the extra argument in the argument lists of invocations of write_out_proc_statics. runtime/mercury_trace_base.[ch]: Conform to the name change from proc_rep to proc_defn_rep in mdbcomp. runtime/mercury_grade.h: Due to the change to layout structures, increment the binary compatibility version numbers for both debug and deep profiling grades. runtime/mercury_wrapper.[ch]: Provide two new MERCURY_OPTION options. The first --deep-procrep-file, allows the user to ask for the program representation to be generated. The second, --deep-random-write, allows tools/bootcheck to request that only a fraction of all program invocations should generate any deep profiling output. The first option will be documented once it is tested much more fully. The second option is deliberately not documented. Update the type of the variable that holds the address of the (mkinit-generated) write_out_proc_statics function to accept the second argument. util/mkinit.c: Pass the extra argument in the argument list of write_out_proc_statics. mdbcomp/program_representation.m: Extend the existing data structures for representing a procedure body to represent a procedure (complete with name), a module and a program. The name is implemented as string_proc_label, a form of proc_label that can be written out to files. This replaces the old proc_id type the deep profiler. Extend the representation of switches to record the identity of the variable being switched on, and the cons_ids of the arms. Without the former, we cannot be sure when a variable is first used, and the latter is needed for meaningful prettyprinting of procedure bodies. Add code for reading in files of bytecodes, and for making sense of the bytecodes themselves. (It is this code that uses foreign enums.) mdbcomp/prim_data.m: Note the relationship of proc_label with string_proc_label. mdbcomp/rtti_access.m: Add the access operations needed to find module string tables with the new organization of layout structures. Provide operations on bytecodes and string tables generally. trace/mercury_trace_cmd_browsing.c: Conform to the change to mdbcomp/program_representation.m. compiler/layout.m: Add support for a MR_ModuleCommonLayout. Rename some function symbols to avoid ambiguities. compiler/layout_out.m: Handle the new structure. compiler/stack_layout.m: Generate the new structure and the procedure representation bytecode in deep profiling grades. compiler/llds_out.m: Generate the code required to write out the prologue and epilogue of program representation files. Pass the extra argument in the argument lists of invocations of write_out_proc_statics that tells those invocations to write out the module representations between the prologue and the epilogue. compiler/prog_rep.m: When generating bytecodes, include the new information for switches. compiler/continuation_info.m: Replace a bool with a more expressive type. compiler/proc_rep.m: Conform to the change to continuation_info.m. compiler/opt_debug.m: Conform to the change to layout.m. deep_profiler/mdprof_procrep.m: A new test program to test the reading of program representations. deep_profiler/DEEP_FLAGS.in: deep_profiler/Mmakefile: Copy the contents of the mdbcomp module to this directory on demand, instead of linking to it. This is necessary now that the deep profiler depends directly on mdbcomp even if it is compiled in a non-debugging grade. The arrangements for doing this were copied from the slice directory, which has long done the same. Avoid a duplicate include of Mmake.deep.params. Add the new test program to the list of programs in this directory. Mmakefile: Go through deep_profiler/Mmakefile when deciding whether to do "mmake depend" in the deep_profiler directory. The old actions won't work correctly now that we need to copy some files from mdbcomp before we can run "mmake depend". deep_profiler/profile.m: Remove the code that was moved (in cleaned-up form) to mdbcomp. deep_profiler/dump.m: deep_profiler/profile.m: Conform to the changes above. browser/declarative_execution.m: browser/declarative_tree.m: Conform to the changes in mdbcomp. doc/user_guide.texi: Add commented out documentation of the two new options. slice/Mmakefile: Fix formatting, and a bug. library/exception.m: library/par_builtin.m: library/thread.m: library/thread.semaphore.m: Update all the handwritten modules to pass the extra argument now required by write_out_proc_statics. tests/debugger/declarative/dependency.exp: Conform to the change from proc_rep to proc_defn_rep. tools/bootcheck: Write out deep profiling data only from every 25th invocation, since otherwise the time for a bootcheck takes six times as long in deep profiling grades than in asm_fast.gc. However, do test the ability to write out program representations. Use the mkinit from the workspace, not the installed one. Don't disable line wrapping. |
||
|
|
455e1eea75 |
The runtime had two different conventions for naming types.
Estimated hours taken: 2 Branches: main The runtime had two different conventions for naming types. One convention, used mostly in the debugger-related modules, added underscores between capitalized words; example: MR_Label_Layout. The other convention, used in most modules, used capitalized words without underscores (e.g. MR_TypeInfo). This diff standardizes on the second convention. It has no algorithmic changes, only renames of types. runtime/*.[ch]: trace/*.[ch]: compiler/*.m: library/*.m: mdbcomp/*.m: Effect the change described above. The only substantive change is that runtime/mercury_stack_layout.h used to define *two* types for trace levels: MR_TraceLevel and MR_Trace_Level, and this diff standardizes on just one (they had equivalent definitions). runtime/mercury_bootstrap.h: Add a #define from the old name to the new for all the changed type names that the installed compiler can put into .c files. We can delete these #defines some time after this diff has bootstrapped. slice/.mgnuc_opts: Restore the --no-mercury-stdlib-dir option, without which the slice directory won't compile after this change (because it looks for type names in the installed runtime header files, which define the old versions of type names). |
||
|
|
ecafca0605 |
Add a file that Ian forgot to add as part of his
Estimated hours taken: 0.5 Branches: main runtime/Mmakefile: runtime/mercury_stack_layout.c: Add a file that Ian forgot to add as part of his change to subterm dependency tracking. |