coin-Bcp
BCP_message_mpi.hpp
Go to the documentation of this file.
1 // BCP_message_mpi.hpp is adeclaration of BCP_message_mpi
2 // Sonya Marcarelli & Igor Vasil'ev (vil@icc.ru)
3 // All Rights Reserved.
4 
5 #ifndef _BCP_MESSAGE_MPI_H
6 #define _BCP_MESSAGE_MPI_H
7 
8 #include "BcpConfig.h"
9 
10 #if defined(COIN_HAS_MPI)
11 
12 #include "BCP_message.hpp"
13 
14 //#############################################################################
15 
16 class BCP_mpi_environment : public BCP_message_environment {
17 private:
18  static int seqproc;
19  static int num_proc;
20  static bool mpi_init_called;
21 
22 private:
23  void check_error(const int code, const char* str) const;
24 
25 public:
29  static int is_mpi(int argc, char *argv[]);
30 
32  BCP_mpi_environment(int argc,char *argv[]);
33  ~BCP_mpi_environment();
34 
35  int num_procs();
36 
37  int register_process(USER_initialize* user_init);
38  int parent_process();
39 
40  bool alive(const int pid);
41  const int* alive(int num, const int* pids);
42 
43  void send(const int target, const BCP_message_tag tag);
44  void send(const int target,
45  const BCP_message_tag tag, const BCP_buffer& buf);
46 
47  void multicast(int num, const int* targets,
48  const BCP_message_tag tag);
49  void multicast(int num, const int* targets,
50  const BCP_message_tag tag, const BCP_buffer& buf);
51 
52  void receive(const int source,
53  const BCP_message_tag tag, BCP_buffer& buf,
54  const double timeout);
55  bool probe(const int source, const BCP_message_tag tag);
56 
57  int start_process(const BCP_string& exe,
58  const bool debug);
59  int start_process(const BCP_string& exe,
60  const BCP_string& machine,
61  const bool debug);
62  bool start_processes(const BCP_string& exe,
63  const int proc_num,
64  const bool debug,
65  int* ids);
66  bool start_processes(const BCP_string& exe,
67  const int proc_num,
68  const BCP_vec<BCP_string>& machines,
69  const bool debug,
70  int* ids);
71 
72 // void stop_process(const int process);
73 // void stop_processes(const BCP_proc_array* processes);
74 };
75 
76 int MPIDI_BGLTS_get_num_messages();
77 
78 #endif /* COIN_HAS_MPI */
79 
80 #endif
BCP_message_tag
This enumerative constant describes the message tags different processes of BCP understand.
virtual void send(const int target, const BCP_message_tag tag)=0
Send an empty message (message tag only) to the process given by the frist argument.
virtual bool start_processes(const BCP_string &exe, const int proc_num, const bool debug, int *ids)=0
Spawn proc_num processes, all with the same executable.
virtual int num_procs()
Return the number of processes.
virtual void receive(const int source, const BCP_message_tag tag, BCP_buffer &buf, const double timeout)=0
Blocking receive with timeout.
This is an abstract base class that describes the message passing environment.
Definition: BCP_message.hpp:30
This class is a very simple impelementation of a constant length string.
Definition: BCP_string.hpp:13
This class is an abstract base class for the initializer class the user has to provide.
Definition: BCP_USER.hpp:160
virtual bool probe(const int source, const BCP_message_tag tag)=0
Probe if there are any messages from the given process with the given message tag.
virtual int start_process(const BCP_string &exe, const bool debug)=0
Spawn a new process.
This class describes the message buffer used for all processes of BCP.
Definition: BCP_buffer.hpp:39
virtual int parent_process()=0
Return the process id of the parent process (the process that spawned the currnet process...
virtual int register_process(USER_initialize *user_init)=0
A process can register (receive its process id) with the message passing environment.
virtual bool alive(const int pid)=0
Test if the process given by the argument is alive or not.
virtual void multicast(int num, const int *targets, const BCP_message_tag tag)=0
Send an empty message (message tag only) to all the processes in the process array.