Nested pmap() functions don not work as I expect

Hello everyone.

I am using pmap function to calculate and sum a function with different arguments such as:

function gparal(nsubs)
                Gs = pmap(i -> ASPINS1Sub(i, ...), 1:nsubs)
                return sum(Gs)
            end
G = gparal(nsubs)

There is one more pmap code inside of a funciton within ASPINS1Sub .

Assume nsubs = 4 and 4 workers are computing seperatelly.
For example: Worker 2 computes ASPINS1Sub and when it comes to inside pmap, it does not work in parallel. Just worker 2 does the job (it seems there is no internal pmap).

How can I fix that? I want that internal code runs in parallel.

Are you saying that ASPINS1Sub also has a pmap in it, so you have a pmap running a function that also runs a pmap?

Assuming that’s what you mean, that’s not good way to do parallel work; likely the first pmap will allocate work to all workers and your nested process will have none. It’s better to farm bigger jobs (500 ms+ of work) to each worker - maybe there’s another way to organize your task?

If that’s not what you mean, my apologies, and please clarify?

Nested pmap seems to work fine. See my notebook for an example.

Are you saying that ASPINS1Sub also has a pmap in it, so you have a pmap running a function that also runs a pmap?

Assuming that’s what you mean, that’s not good way to do parallel work; likely the first pmap will allocate work to all workers and your nested process will have none. It’s better to farm bigger jobs (500 ms+ of work) to each worker - maybe there’s another way to organize your task?

If that’s not what you mean, my apologies, and please clarify?

Yes, that is what I meant.

Nested pmap seems to work fine. See my notebook3 for an example.

I checked your notebook, it seems its working.

I added println(myid()) on the function within insider pmap. It seems different procs handle the jobs seperately. But still it appears to me that it is not working as it should because when I run it serial, I get nearly same time output using @time.

Thank you for your answers.