Pari/GP Reference Documentation | Contents - Global index - GP keyboard shortcuts |
parapply pareval parfor parforprime parforvec parselect parsum parvector | |
These function are only available if PARI was configured using
* POSIX threads * Message passing interface (MPI) As a rule, POSIX threads are well-suited for single systems, while MPI is used by most clusters. However the parallel GP interface does not depend on the chosen multithread interface: a properly written GP program will work identically with both.
| |
parapply | |
Parallel evaluation of
parapply(factor,[2^256 + 1, 2^193 - 1]) factors 2^{256} + 1 and 2^{193} - 1 in parallel.
{ my(E = ellinit([1,3]), V = vector(12,i,randomprime(2^200))); parapply(p->ellcard(E,p), V) } computes the order of E(𝔽_p) for 12 random primes of 200 bits.
The library syntax is
| |
pareval | |
Parallel evaluation of the elements of
The library syntax is
| |
parfor | |
Evaluates in parallel the expression
The computations of
The following example computes the sum of the squares of the integers
from 1 to 10 by computing the squares in parallel and is equivalent
to
? s=0; ? parfor (i=1, 10, i^2, r, s=s+r) ? s %3 = 385
More precisely, apart from a potentially different order of evaluation
due to the parallelism, the line containing
? my (r); for (i=1, 10, r=i^2; s=s+r)
The sequentiality of the evaluation of
It is allowed for
? parfor (i=1000, , isprime (i), r, if (r, return (i))) %1 = 1009
| |
parforprime | |
Behaves exactly as
It is allowed fo
| |
parforvec | |
Evaluates the sequence
It is allowed fo
| |
parselect | |
Selects elements of A according to the selection function f, done in
parallel. If flag is 1, return the indices of those elements (indirect
selection) The function
The library syntax is
| |
parsum | |
Sum of expression expr, initialized at x, the formal parameter
going from a to b, evaluated in parallel in random order.
The expression
parsum(i=1,1000,ispseudoprime(2^prime(i)-1)) returns the numbers of prime numbers among the first 1000 Mersenne numbers.
| |
parvector | |
As
parvector(10,i,quadclassunit(2^(100+i)+1).no) computes the class numbers in parallel.
| |