2

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);
  }
}
Jarikus
  • 774
  • 8
  • 18
  • You realize that connecting two programs makes them no longer "absolutely separate", right – sehe Apr 03 '15 at 14:03
  • sehe> Yes I add to this programs only one point of contact 'MPIDefines.h': `#pragma once // Set song file #define MPI_TAG_SETSONG 1 #define MPI_TAG_STARTPLAY 2 #define MPI_TAG_STOPPLAY 3` – Jarikus Apr 03 '15 at 14:07
  • 2
    Maybe what you are looking for is more Boost Interprocess, although I am not an expert in this. I suggest to check that out, it is fairly complicated, but I think it offers anything you can possibly need in terms of interprocess communication. – Emerald Weapon Apr 03 '15 at 14:30
  • @claudv you are right, I found Boost interprocess messages: http://www.boost.org/doc/libs/1_55_0/doc/html/interprocess/synchronization_mechanisms.html#interprocess.synchronization_mechanisms.message_queue but fanny why MPI do not work same maner – Jarikus Apr 03 '15 at 15:10
  • There are many things that don't work in the same manner. Because if it worked in the same manner, what would be the difference? – sehe Apr 03 '15 at 17:45
  • @sehe "Because if it worked in the same manner, what would be the difference?" Absolutely agree, I learning the Message_queue and not understand why Boost create MPI support, when exists almost same Message_queue. And I spend one day for build Boost.MPI module and as it turns out I do not need ;) – Jarikus Apr 03 '15 at 18:33
  • 1
    Connecting two separate MPI programs requires the client/server model routines that are part of MPI-2 and later. None of them is wrapped by Boost.MPI and you have to use the C API. Anyway, using MPI for such a simple task is an overkill and the client/server model of MPI has its very own drawbacks too. – Hristo Iliev Apr 03 '15 at 19:45

0 Answers0