[m-users.] Parallel Mercury

Paul Bone paul at bone.id.au
Tue Nov 29 11:32:51 AEDT 2016


On Tue, Nov 29, 2016 at 11:23:13AM +1100, Julien Fischer wrote:
> 
> Hi,
> 
> On Tue, 29 Nov 2016, Paul Bone wrote:
> 
> >On Mon, Nov 28, 2016 at 07:03:29PM -0200, Eduardo Costa wrote:
> >>Well, I discovered the problem. I need to compile the program with:
> >>
> >>mmc --parallel -j4 --grade=asm_fast.par.gc fibgc.m -o fib.x
> >
> >I was just about to offer this suggestion.  The & parallel conjunction
> >operator is only supported in low level C parallel grades.
> 
> 
> I suggest that programs that _must_ use parallel conjunction (as opposed
> to programs that _could_ use it), include:
> 
>     :- pragma require_feature_set([parallel_conj]).
> 
> somewhere.  That way, the compiler will complain if accidently use a
> compilation model that doesn't support it.
> 
> ...
> >
> >The --parallel option and the par grade component mean the same thing (this
> >may change in the future).  If you give a --grade option, you should avoid
> >giving --parallel or --high-level-code options as they could conflict.
> >
> >the --make option also gives you an easier way to build your programs.
> >Simply:
> >
> >   $ mmc --make --grade=asm_fast.gc.par.stseg -O3 fibgc
> >
> >Should give you good results.
> 
> Although it's not hugely useful for fib, is '--par-loop-control' in a
> usable state?  (i.e. could it be enabled by default, or at least
> documented?)

To the best of my memory, it worked with our tests so far, but it had not
been tested widely.

For anyone who isn't aware, loop control is a transformation that can take a
right-recursive parallel loop, like:

    map(_, Xs, Xs).
    map(P, [X | Xs], [Y | Ys]) :-
        P(X, Y) &
        map(P, Xs, Ys).

Which due to the 'sparking order' of the parallel conjuncts, can hit a
pathological performance problem.  The compiler tries to work-around this
problem but cannot when there is a dependency between the conjuncts.

Loop control is a transformation that the compiler uses to parallelise these
loops in a specialised way, it is much more efficient than the ordinary way,
avoids the pathological problem and is tail recursive when the equential
code is also tail recursive.

> (In passing, I note that options.m names that option --par-loop-control,
> but the commented-out documenation in the user's guide names it
> --loop-control.)

Ah, that's probably a mistake.


-- 
Paul Bone
http://paul.bone.id.au


More information about the users mailing list