XMLIOSERVER 0.4
Serveur d'Entrées/Sorties parallèles
|
00001 /* ************************************************************************** * 00002 * Copyright © IPSL/LSCE, XMLIOServer, Avril 2010 - Octobre 2011 * 00003 * ************************************************************************** */ 00004 00005 #ifndef __MPI_INTERFACE_HPP__ 00006 #define __MPI_INTERFACE_HPP__ 00007 00016 #ifndef __XIOS_NO_EXTERN 00017 00018 // M(essage) P(assing) I(nterface) headers 00019 #include <mpi.h> 00020 00021 // C++ standard headers 00022 #include <vector> 00023 00024 #endif //__XIOS_NO_EXTERN 00025 00026 // XMLIOServer headers 00027 #include "xmlioserver_spl.hpp" 00028 00029 // ////////////////////////////// Déclarations ///////////////////////////// // 00030 00031 namespace xmlioserver 00032 { 00034 namespace comm 00035 { 00036 typedef MPI_Fint MPI_F_Comm; 00037 typedef MPI_Fint MPI_F_Group; 00038 typedef MPI_Fint MPI_F_Request; 00039 typedef MPI_Fint *MPI_F_Status; 00040 typedef MPI_Fint MPI_F_DataType; 00046 class CMPIManager 00047 { 00048 public : // Initialisation & Finalisation 00049 00050 static void Initialise(int * argc, char *** argv); 00051 static void Finalize(void); 00052 00053 public : // Communicateurs 00054 00055 static int GetCommRank(MPI_Comm _comm = CMPIManager::GetCommWorld()); 00056 static int GetCommSize(MPI_Comm _comm = CMPIManager::GetCommWorld()); 00057 static MPI_Comm CreateComm(MPI_Group _group, MPI_Comm _pcomm = CMPIManager::GetCommWorld()); 00058 static MPI_Comm GetCommWorld(void); 00059 00060 public : // Autre 00061 00062 static void Barrier(MPI_Comm _comm = CMPIManager::GetCommWorld()); 00063 00064 static bool DispatchClient(bool _is_server, 00065 MPI_Comm & _comm_client, 00066 MPI_Comm & _comm_client_server, 00067 MPI_Comm & _comm_server, 00068 MPI_Comm _comm_parent = CMPIManager::GetCommWorld()); 00069 00070 public : // Groupes 00071 00072 static MPI_Group GetGroupWorld(void); 00073 static MPI_Group CreateSubGroup(MPI_Group _pgroup, const std::vector<int> & _ranks); 00074 static MPI_Group CreateSubGroup(MPI_Group _pgroup, int _min_rank, int _max_rank, int _intval = 1); 00075 00076 public : // Tests 00077 00078 static bool IsMaster(MPI_Comm _comm = CMPIManager::GetCommWorld()); 00079 static bool IsRank(int _rank, MPI_Comm _comm = CMPIManager::GetCommWorld()); 00080 00081 public : // Communication simple 00082 00083 static void Send (MPI_Comm _comm, int _dest_rank, char * _data, 00084 std::size_t _size, MPI_Request & _request); 00085 static void Wait (MPI_Request & _request); 00086 static bool Test (MPI_Request & _request); 00087 00088 static bool HasReceivedData(MPI_Comm _comm, int _src_rank); 00089 static std::size_t GetReceivedDataSize(MPI_Comm _comm, int _src_rank); 00090 static void Receive(MPI_Comm _comm, int _src_rank, char * _data); 00091 00092 static void AllGather(int _indata, std::vector<int> & _outdata, 00093 MPI_Comm _comm = CMPIManager::GetCommWorld()); 00094 00095 static void AllGather(const std::vector<int> & _indata, 00096 std::vector<int> & _outdata, 00097 MPI_Comm _comm = CMPIManager::GetCommWorld()); 00098 00099 00100 public : // Communication 'complexe' 00101 00102 // static void SendLinearBuffer(MPIComm comm, int dest_rank, CLinearBuffer & buff, MPIRequest & request); 00103 // static void ReceiveLinearBuffer(MPIComm comm, int src_rank, CLinearBuffer & buff); 00104 // static boost::shared_ptr<CLinearBuffer> ReceiveLinearBuffer(MPIComm comm, int src_rank); 00105 // static void ReceiveCircularBuffer(MPIComm comm, int src_rank, CCircularBuffer & buff); 00106 00107 public : // Mémoire (non fonctionnel ....) 00108 00109 static void AllocMemory(void * _data, std::size_t _size); 00110 static void FreeMemory (void * _data); 00111 00112 }; // class CMPIManager 00113 00114 } // namespace comm 00115 } // namespace xmlioserver 00116 00117 #endif //__MPI_INTERFACE_HPP__