I create two programs which must send each/other the messages. For sample: first program like audio 'Player' with playlist and second program like 'Visualizer'.
I decide make Player and Visualizer as complete separate program because this programs based on different frameworks and I do not want mix it. And I don`t want use standard MS Windows messages.
For example when I run Player, and on Player press button 'Show Visualizer', the Player run 'Visualizer' and when on Player press button 'Play song', player must send message by MPI to 'Visualizer' what we started playing and Visualizer start show nice animation.
Environment: MS Windows
For MPI I use: Boost.MPI + Microsoft HCP MPI
But I found only stupid examples like 'Hello world' where 'parent' program and 'child' program run from one executable file:
#include <boost/mpi.hpp>
#include <iostream>
#include <string>
#include <boost/serialization/string.hpp>
namespace mpi = boost::mpi;
int main()
{
mpi::environment env;
mpi::communicator world;
// Parent, 'root' process
if (world.rank() == 0)
{
world.send(1, 0, std::string("Hello"));
}
else // Child process
{
std::string msg;
world.recv(0, 0, msg);
std::cout << msg << ", world";
std::cout.flush();
}
return 0;
}
I need obtain one 'mpi::communicator world;' on different programs, which started independently.
// Player
int main_Player()
{
mpi::environment env;
mpi::communicator world;
if (world.rank() != 0)
{
std::cout << "Another copy of Player is started..";
return -1
}
}
and
// Visuzalizer
int main_Visuzalizer()
{
mpi::environment env;
mpi::communicator world;
// Receive message from Player
if (world.rank() > 0)
{
std::string msg;
world.recv(0, 0, msg);
}
}