Code parallelization using Pstream: simultaneous send/receive deadlocking
I am trying to write the simplest parallel code that involves simultaneous communication accross processes:
Of course, such code will experience a deadlock. There are multiple solutions for this beginner problem: exchanging the order of Send/Receive based on the process rank, using non-blocking communication, using buffered communication (bSend, bRecv), etc.
Both the problem and possible solutions are explained here (Note: if the links don't work by clicking, copy/paste them):
So. I have tried to use these solutions in OpenFOAM, sending/receiving a scalarField around, and I keep getting errors. I linked the application source below, where you can uncomment parts of the code to get specific solutions (described in the links above). What I find strange is:
I am not sure if I am missing something obvious, but it seems strange that every option I try, fails.
Also: I've switched on the Pstream debugSwitch in etc/controlDict, but I still don't see the debug info comming from the UPstream.C in the Pstream/mpi folder. This looks like my application is using the dummy implementation of UPstream and its children, instead of linking with stuff from Pstream/mpi.
Download link (OpenFOAM 2.0.x):
O.K. , let me rephrase the question: there are two processes available.
How do I use Pstream to exchange the number Pstream::myProcNo() between the processes without deadlocking?
Have you looked at the source code for the OpenFOAM application Test-parallel? It's located at "applications/test/parallel".
It's a very decent example of what you seem to be trying to do!
Browse the other applications in the test folder as well, because I remember there are other very sweet examples of parallel manipulations!
Thanks, I'm on it! :D
What went wrong with the ucsb solution? It seems brilliantly simple...
Added: I wrote it for just 2 processes: 0 is sending/receiving to/from 1, and 1 is sending/receiving to/from 0.
|All times are GMT -4. The time now is 10:52.|