Next: Grade modifiers for minimal model tabling, Previous: Grade modifiers for trailing, Up: Grade modifiers [Contents][Index]
In the absence of the .par grade modifier,
the Mercury compiler generates executables
that do not support parallel execution in any form.
.parCompiling programs in a grade that includes the .par grade modifier
generates executables that support parallel execution.
What form of parallel execution is supported depends on the backend.
.par grades support user-managed parallelism,
using whatever thread support is provided by the target language.
Programmers can use the operations
of the thread module of the Mercury standard library
to spawn new threads, and to collect their results once they are done.
.par grades support compiler-managed parallelism.
Programmers can ask the compiler to execute two goals in parallel
simply by replacing the comma (the sequential conjunction operator)
between them with an ampersand ‘&’, the parallel conjunction operator.
The compiler will take care of the rest.
(Note that ‘&’ has this effect only in LLDS .par grades;
in all other grades, the compiler silently converts all ‘&’s into commas.)
Note: due to a code generation bug, at the moment LLDS parallelism does not work.