Jean-Luc ARNAUD on Wed, 14 Jun 2023 18:01:17 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Give up with MT, need help!!! |
Hi all,
As a newby to PARI/GP, I'm trying to understand how it works in
MT environment.
And I'm getting a lot of difficulties.
As an example, how could I replace the for ... loop by a parfor ... one in the chudnovsky_parallel(n) function ?
After many and many tries, getting always either "Please export ..." or "Impossible div ..." error message, I give up ...
Would somebody be so kind as to modify the below script in order to use parfor loop instead of for?
chudnovsky_parallel(n) = {
my(k, res, Result);
for(k = 0, ceil(n/14),
Result=pareval([
()-> (-1)^k *(6*k)! * (13591409 +
545140134*k),
()-> (3*k)! *k!^3 * (640320^(3*k + 3 /
2))]); /* +3/2 -> 583 ms, +1.5 -> 18,536 s !!! */
res += Result[1] / Result[2];
);
res = 1 / (res * 12);
};
\\ Example usage: Calculate π with 1000 decimal
places
n=1000;
print_flag=0;
default(realprecision,n); \\ Set precision to n
decimal places
timer = getwalltime();
MyPi = chudnovsky_parallel(n);
timer = getwalltime() - timer;
print("Computed π with ", n, " decimal places in ",
timer, " ms.");
if(print_flag==1,print(strchr(10),"Pi=", MyPi));
Many thanks in advance for any help.
-- Jean-Luc Arnaud