[ Predicate Database and Compiler | Reference Manual | Alphabetic Index ]

# parallel +SpecList

Declares the procedure(s) specified by SpecList as parallel.

SpecList
  Comma-separated sequence of expressions of the form Atom/Integer.

## Description

The parallel annotation specifies that the system is allowed to execute the clauses of the annotated predicate in parallel (Or-parallelism), instead of sequentially by backtracking. This has the following consequences:

* the predicate is a source of or-parallelism which will hopefully speed up execution of the program on a parallel machine

* calls to this predicate may return alternative solutions in unpredictable order

* side effects within the parallel execution may happen in unpredictable order

The parallel annotation has simply no effect when the predicate (or a particular call to it) is deterministic or when it is used with a sequential ECLiPSe system.

A procedure can be declared parallel before it is actually defined.

### Modes and Determinism

- parallel(++) is det

### Modules

This predicate is sensitive to its module context (tool predicate, see @/2).

### Exceptions

(4) instantiation fault
  SpecList is not instantiated.
(5) type error
  SpecList is instantiated, but not to a sequence of expressions of the form Atom/Integer.

## Examples

      [eclipse 1]: [user].
       :- parallel p/1.
       p(a).  p(b).  p(c).
      user       compiled traceable 220 bytes in 0.02 seconds
      yes.
      [eclipse 2]: get_flag(p/1, parallel, Flag).
      Flag = on
      yes.
      [eclipse 3]: p(X), use(X).
      % The three clauses of p/1 as well as the resulting goals
      % use(a), use(b) and use(c) may be executed in parallel!

## See Also

compile / 1, get_flag / 3, set_flag / 3