Bill Allombert on Wed, 19 Mar 2025 18:57:14 +0100


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

Re: I need help for parallel optimization


On Wed, Mar 19, 2025 at 06:34:51PM +0100, Jean-Luc Arnaud wrote:
> Hi all,
> 
> I've coded a GP Script calculating Pi digits based en Chudnovski algorithm.
> 
> It works very well and fast (≈ 1 min 43 s for 1 000 000 digits) but I'd like
> to optimize it with parallel calculation.

It is not really possible. There is few part of the algorithm that can run at
the same time.

Also it is not needed, PARI uses the same formula and need less than 1s without
parallelism.

The trick is to use a technique known as binary splitting to compute the sum.

To start with something easier, what you can try to speed it up a bit (without
paralelism) is to keep track of the numerators and denominators of ak, a_sum
and bsum separately.

That is 
num_a_k = num_a_k*(-(6*i-5)*(2*i-1)*(6*i-1)) 
den_a_k = den_a_k* (i^3* C3);

etc.

Cheers,
Bill.