| Bill Allombert on Fri, 19 May 2023 00:00:15 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: Help running parfor... |
On Thu, May 18, 2023 at 04:25:06PM -0500, wraithx@morpheus.net wrote:
> Hello,
>
> I think I'm having trouble using parfor. I just downloaded and installed
> Pari64-2-15-3-pthread.exe. I'm trying to use parfor, but it seems like it
> is only using a single thread. I've created some test code to use 4
> threads, and it seems to run the first iteration until completion, then it
> starts running the second iteration to completion, and so on until the last
> iteration until completion. I put in print statements hoping to see it
> randomly working on different iterations, depending on which thread executed
> the print statement. But it's printing each iteration in order with no sign
> of parallelism here.
parfor(i = first_n, last_n,
get_fname(p,i),
fname,
parallel_g(fname, p, i, range)
);
When using parfor the first sequence of instructions (3rd arhument, here get_fname(p,i)) is run
in parallel, but not the second one (5th argument, here parallel_g) which is sequentially.
This is on purpose.
So yes, the call to parallel_g are done sequentially in this example.
Maybe you wanted to do simply:
parfor(i = first_n, last_n,
my(fname=get_fname(p,i));
parallel_g(fname, p, i, range)
);
Beware that on Windows Pari64-2-15-3-pthread.exe might be much slower than Pari64-2-15-3.exe
It is better to use the Windows subsystem for Linux.
Cheers,
Bill.