Since needed it for one of my research projects, I have created an offspin of the SharedMemory class in my FlexLib2 library.
The created SharedMemory class supports the creation of SharedMemory segments in the OpenMPI context. In the end you will have a shared memory segment on every machine, where the program is executed.
An example code is included. It compiles on gcc 4.8.4 on Ubuntu 14.04 with C++98 and C++11 Standart.
It includes a Makefile and an example program. Checkout the README file for details. And: Have fun 🙂
If you need some more info about how to deal with POSIX shared memory on a Linux system, I can recommend this following article.