00001
00002
00003
00004
00005 #ifndef _BCP_MESSAGE_MPI_H
00006 #define _BCP_MESSAGE_MPI_H
00007
00008 #include "BcpConfig.h"
00009
00010 #if defined(COIN_HAS_MPI)
00011
00012 #include "BCP_message.hpp"
00013
00014
00015
00016 class BCP_mpi_id : public BCP_proc_id {
00017 public:
00018 int _pid;
00019 public:
00020 BCP_mpi_id(int id = 0) : _pid(id) {}
00021
00022 ~BCP_mpi_id() {}
00023
00024 bool is_same_process(const BCP_proc_id* other_process) const;
00025 inline int pid() const { return _pid; }
00026 inline BCP_proc_id* clone() const { return new BCP_mpi_id(_pid); }
00027 };
00028
00029
00030
00031 class BCP_mpi_environment : public BCP_message_environment {
00032 private:
00033 int seqproc;
00034 static bool mpi_init_called;
00035
00036 private:
00037 void check_error(const int code, const char* str) const;
00038
00039 public:
00043 static int is_mpi(int argc, char *argv[]);
00044
00046 BCP_mpi_environment(int argc,char *argv[]);
00047 ~BCP_mpi_environment();
00048
00049 int num_procs();
00050
00051 BCP_proc_id* register_process(USER_initialize* user_init);
00052 BCP_proc_id* parent_process();
00053
00054 bool alive(const BCP_proc_id* pid);
00055 BCP_vec<BCP_proc_id*>::iterator alive(const BCP_proc_array& parray);
00056
00057 void send(const BCP_proc_id* const target, const BCP_message_tag tag);
00058 void send(const BCP_proc_id* const target,
00059 const BCP_message_tag tag, const BCP_buffer& buf);
00060
00061 void multicast(const BCP_proc_array* const target,
00062 const BCP_message_tag tag);
00063 void multicast(const BCP_proc_array* const target,
00064 const BCP_message_tag tag, const BCP_buffer& buf);
00065 void multicast(BCP_vec<BCP_proc_id*>::const_iterator beg,
00066 BCP_vec<BCP_proc_id*>::const_iterator end,
00067 const BCP_message_tag tag);
00068 void multicast(BCP_vec<BCP_proc_id*>::const_iterator beg,
00069 BCP_vec<BCP_proc_id*>::const_iterator end,
00070 const BCP_message_tag tag,
00071 const BCP_buffer& buf);
00072
00073 void receive(const BCP_proc_id* const source,
00074 const BCP_message_tag tag, BCP_buffer& buf,
00075 const double timeout);
00076 bool probe(const BCP_proc_id* const source,
00077 const BCP_message_tag tag);
00078
00079 BCP_proc_id* unpack_proc_id(BCP_buffer& buf);
00080 void pack_proc_id(BCP_buffer& buf, const BCP_proc_id* pid);
00081
00082 BCP_proc_id* start_process(const BCP_string& exe,
00083 const bool debug);
00084 BCP_proc_id* start_process(const BCP_string& exe,
00085 const BCP_string& machine,
00086 const bool debug);
00087 BCP_proc_array* start_processes(const BCP_string& exe,
00088 const int proc_num,
00089 const bool debug);
00090 BCP_proc_array* start_processes(const BCP_string& exe,
00091 const int proc_num,
00092 const BCP_vec<BCP_string>& machines,
00093 const bool debug);
00094
00095
00096
00097 };
00098
00099
00100
00101 int BCP_is_mpi_id(const BCP_proc_id* pid, const char* str);
00102
00103
00104
00105 int* BCP_process_array_2_int(const BCP_proc_array* const target,
00106 const char* str);
00107
00108 #endif
00109
00110 #endif