Parallel Solver is Slow

Hello,

I’m trying to speed up the time of my solver by solving in parallel. I’ve tried this for the demo ft01_poisson.py with a mesh size of 1000 X 1000-- I ran the command:

mpirun -n 10 python3 ft01_poisson.py

However, this takes longer than running the demo in the usual way:

python3 ft01_poisson.py

As I understand, the “-n 10” flag, splits the domain into 10 pieces, solves them separately, and patches the solutions together somehow. Is there something else I need to do in order to tell my computer to use multiple threads?

In a similar post, it was suggested to set environment variable: set OPT_NUM_THREADS = 1. However, it is still slow after I do this.

I’m new to parallel processing so any help is greatly appreciated.

Thanks,
Trevor

Just to be sure, how many processors do you have available? What does nproc report?

The ‘nproc’ command isn’t available on macs, so I did instead:

sysctl -n hw.ncpu

This returns 4.

It means you’re oversubscribing your CPUs with 2-3 processes each, so you would expect it to run slow. Keep your mpi to the number of processors available.

Be careful regarding the difference between processes and threads.

Should be OMP_NUM_THREADS.

1 Like