Bill Allombert on Sun, 27 Oct 2013 23:10:12 +0100

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

 Branch bill-mt for parallel pari updated again

```Dear PARI developers,

I have updated the GIT branch bill-mt for parallel pari again.
This branch support
- POSIX threads: do
- MPI (for clusters)

The documentation is available at
<http://pari.math.u-bordeaux.fr/~bill/parallel.pdf>

The following parallel GP functions are available:
parapply, pareval, parsum, parvector
and two new experimental parallel function:
parfor and parfirst:

I might decide to remove parfirst and parsum because parfor is more general.

parfor(i = a,b,expr1,j,expr2):

The  sequence  expr2   (dependent on i and j)  is evaluated for i between a
and b,  in random order, with j being substitued for the value of expr1
(dependent on i), computed in parallel. It is allowed fo expr2 to exit the loop
using break/next/return,  however in that case,  expr2 will still be evaluated
for all remaining value of i less than the current one.

Actually, parfor cal be used to emulate all the others.

For performance, it is better to move most code from expr2 to expr1, since only expr1
is evauated in parallel.

An example

findc(p)=
{
parfor(i=0,p-1,
my(E=ellinit([1,i]));ellcard(E,p)
,card
,if(isprime(card),return([i,card])))
}

find an elliptic curve of prime order over F_p, in parallel, stopping at the
first curve found. ("i" will always be the smallest possible).

Assuming the call to isprime take a significant CPU time, it can be moved to expr1 as follow:

findc(p)=
{
parfor(i=0,p-1,
my(c=ellcard(ellinit([1,i]),p));
[c,isprime(c)],
,j
,if(j[2],return([i,j[1]])))
}

Cheers,
Bill.

```