[m-rev.] for review: parallel mmc --make with processes

Julien Fischer juliensf at csse.unimelb.edu.au
Thu Aug 16 15:27:08 AEST 2007


On Thu, 16 Aug 2007, Peter Wang wrote:

> Make parallel mmc --make work using processes as well as threads.  This means
> the compiler doesn't need to be built in a .par grade for the --jobs option
> to have an effect.
>
> compiler/make.util.m:
> 	Generalise the existing parallel fold code to work with threads and
> 	processes.
>
> compiler/process_util.m:
> 	Add a predicate to start running a child process without waiting for
> 	the child to finish.
>
> 	Add a predicate to wait for a child process to finish.
>
> doc/user_guide.text:
> 	Update the documentation.

You should also announce this in the NEWS file.

Update the TODO list in make.m as well.

...

> +:- typeclass par_fold(PF) where [

Add a comment describing this typeclass.

> +    % run_in_child(Pred, Info, T, Succeeded, !PF, !IO)
> +    %
> +    % Start executing Pred in a child thread/process.  Succeeded is `yes' iff
> +    % the child was successfully spawned.
> +    %
> +    pred run_in_child(
> +        foldl2_pred_with_status(T, Info, io)::in(foldl2_pred_with_status),
> +        Info::in, T::in, bool::out, PF::in, PF::out, io::di, io::uo) is det,
> +
> +    % Block until a child exit code is received.
> +    %
> +    pred wait_for_child_exit(child_exit::out(child_succeeded_or_failed),
> +        PF::in, PF::out, io::di, io::uo) is det
> +].
>
> foldl2_maybe_stop_at_error_maybe_parallel(KeepGoing, MakeTarget, Targets,
>         Success, !Info, !IO) :-
> +    % First pass.
>     globals.io_lookup_int_option(jobs, Jobs, !IO),
> -    (
> -        thread.can_spawn,
> -        Jobs > 1
> -    ->
> -        foldl2_maybe_stop_at_error_parallel(KeepGoing, Jobs,
> -            MakeTarget, Targets, Success0, !.Info, !IO)
> +    ( Jobs > 1 ->
> +        ( process_util.can_fork ->
> +            foldl2_maybe_stop_at_error_parallel_processes(KeepGoing, Jobs,
> +                MakeTarget, Targets, Success0, !.Info, !IO)
> +        ; thread.can_spawn ->
> +            foldl2_maybe_stop_at_error_parallel_threads(KeepGoing, Jobs,
> +                MakeTarget, Targets, Success0, !.Info, !IO)
> +        ;
> +            Success0 = yes
> +        )

I think it is worth adding a comment here that forking is disabled in
threaded grades.

That looks fine otherwise.

Thanks for doing that!
Julien.
--------------------------------------------------------------------------
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