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