[m-rev.] diff: parallel mmc --make on interface files

Peter Wang novalazy at gmail.com
Fri Jul 31 12:38:52 AEST 2009


Branches: main

Allow parallel mmc --make to build long interface files (.int) and optimisation
interface files (.opt) in parallel.

compiler/make.program_target.m:
        Build private interface files for all modules with sub-modules, then
        long interface files and optimisation interface files can be built in
        parallel.

compiler/make.m:
        Correct a typo.

compiler/make.util.m:
        Update attribution for parallel mmc --make.

diff --git a/compiler/make.m b/compiler/make.m
index ed93ee2..c286ae3 100644
--- a/compiler/make.m
+++ b/compiler/make.m
@@ -557,9 +557,9 @@ make_track_flags_files(ModuleName, Success, !Info, !IO) :-
     (
         Success0 = yes,
         KeepGoing = no,
-        DummyLashHash = last_hash([], ""),
+        DummyLastHash = last_hash([], ""),
         foldl3_maybe_stop_at_error(KeepGoing, make_track_flags_files_2,
-            set.to_sorted_list(Modules), Success, DummyLashHash, _LastHash,
+            set.to_sorted_list(Modules), Success, DummyLastHash, _LastHash,
             !Info, !IO)
     ;
         Success0 = no,
diff --git a/compiler/make.program_target.m b/compiler/make.program_target.m
index b90eb4f..590e5d2 100644
--- a/compiler/make.program_target.m
+++ b/compiler/make.program_target.m
@@ -1,7 +1,7 @@
 %-----------------------------------------------------------------------------%
 % vim: ft=mercury ts=4 sw=4 et
 %-----------------------------------------------------------------------------%
-% Copyright (C) 2002-2008 The University of Melbourne.
+% Copyright (C) 2002-2009 The University of Melbourne.
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
@@ -831,8 +831,12 @@ make_misc_target_builder(MainModuleName - TargetType, _, Succeeded,
     make_info::in, make_info::out, io::di, io::uo) is det.
 
 make_all_interface_files(AllModules, Succeeded, !Info, !IO) :-
+    list.foldl3(collect_modules_with_children, AllModules, [], ParentModules,
+        !Info, !IO),
     ShortInts = make_dependency_list(AllModules,
         module_target_unqualified_short_interface),
+    PrivateInts = make_dependency_list(ParentModules,
+        module_target_private_interface),
     LongInts = make_dependency_list(AllModules,
         module_target_long_interface),
     globals.io_get_any_intermod(AnyIntermod, !IO),
@@ -845,10 +849,41 @@ make_all_interface_files(AllModules, Succeeded, !Info, !IO) :-
         OptFiles = []
     ),
     globals.io_lookup_bool_option(keep_going, KeepGoing, !IO),
+    % Private interfaces (.int0) need to be made before building long interface
+    % files in parallel, otherwise two processes may try to build the same
+    % private interface file.
     foldl2_maybe_stop_at_error(KeepGoing,
         foldl2_maybe_stop_at_error(KeepGoing, make_module_target),
-        [ShortInts, LongInts, OptFiles],
-        Succeeded, !Info, !IO).
+        [ShortInts, PrivateInts], Succeeded0, !Info, !IO),
+    (
+        Succeeded0 = yes,
+        foldl2_maybe_stop_at_error(KeepGoing,
+            foldl2_maybe_stop_at_error_maybe_parallel(KeepGoing,
+                make_module_target),
+            [LongInts, OptFiles], Succeeded, !Info, !IO)
+    ;
+        Succeeded0 = no,
+        Succeeded = no
+    ).
+
+:- pred collect_modules_with_children(module_name::in,
+    list(module_name)::in, list(module_name)::out,
+    make_info::in, make_info::out, io::di, io::uo) is det.
+
+collect_modules_with_children(ModuleName, !ParentModules, !Info, !IO) :-
+    get_module_dependencies(ModuleName, MaybeImports, !Info, !IO),
+    (
+        MaybeImports = yes(Imports),
+        Children = Imports ^ children,
+        (
+            Children = []
+        ;
+            Children = [_ | _],
+            !:ParentModules = [ModuleName | !.ParentModules]
+        )
+    ;
+        MaybeImports = no
+    ).
 
 %-----------------------------------------------------------------------------%
 
diff --git a/compiler/make.util.m b/compiler/make.util.m
index c36abcf..c95e4c0 100644
--- a/compiler/make.util.m
+++ b/compiler/make.util.m
@@ -1,13 +1,13 @@
 %-----------------------------------------------------------------------------%
 % vim: ft=mercury ts=4 sw=4 et
 %-----------------------------------------------------------------------------%
-% Copyright (C) 2002-2008 University of Melbourne.
+% Copyright (C) 2002-2009 University of Melbourne.
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
 %
 % File: make.util.m.
-% Main author: stayl.
+% Authors: stayl, wangp.
 %
 % Assorted predicates used to implement `mmc --make'.
 %

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list