This is a blog post for solutions to technical problems I encounter while working with various technology. By placing the answer here, I hope to remember it the next time I'm faced with it. Maybe I can save you a search too?
This blog post entails a simple client / server example using OpenMPI, the opmi-server, and simple commands to publish a named server, lookup the server using a client, then connect and transceive data between the server and client.
uname -a
Linux hellion 3.19.0-77-generic #85-Ubuntu SMP Fri Dec 2 03:43:54 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
mpicc --version
gcc (Ubuntu 4.9.2-10ubuntu13) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
This post assumes you've got the OpenMPI installed completely and working properly.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You run the ompi-server first, to establish the name server. But to do this you run mpirun with ompi-server and not just run it.
*!
\brief How to execute mpi name server
mpirun -np 1 ompi-server --no-daemonize -r + &
*
* Success looks like this :
*
"server available at 3653042176.0;tcp://192.168.10.191:52434+3653042177.0;tcp://192.168.10.191:48880:300"
*/
Once the ompi-server is running, you can refer to it by file, but you can also refer to it by it's pid if it's local. To get things running with the minimum of overlapping errors, I start with simple local setups.
server available at 3500802048.0;tcp://192.168.10.191:50129+3500802049.0;tcp://192.168.10.191:53693:300
Now you mpirun the client and it looks like this:
mpirun -np 1 --ompi-server pid:14341 ./client
looking up server ...
The server responds like this:
we got a client's data: 25.500000
we got a client's data: 26.500000
we got a client's data: 27.500000
^Cmpirun: killing job...
You can mpirun the client and server from a config file as well instead of informing of the ompi-server location by PID like this:
mpirun -np 1 --ompi-server file:./nameserver.cfg ./server
server available at 2886402048.0;tcp://192.168.10.191:51344+2886402049.0;tcp://192.168.10.191:54857:300