OrganizerMPI.h (1320B)
1 // File : OrganizerMPI.h 2 // Date : Thu Apr 28 09:53:58 2016 3 // Author : Fabian Wermelinger 4 // Description: MPI Organizer 5 // Copyright 2016 ETH Zurich. All Rights Reserved. 6 #ifndef ORGANIZERMPI_H_8HFBYG90 7 #define ORGANIZERMPI_H_8HFBYG90 8 9 #include <vector> 10 #include <string> 11 #include <mpi.h> 12 13 #include "ArgumentParser.h" 14 15 #ifdef _FLOAT_PRECISION_ 16 #define MPIReal MPI_FLOAT 17 #else 18 #define MPIReal MPI_DOUBLE 19 #endif 20 21 class OrganizerMPI 22 { 23 private: 24 int m_nscenes; 25 std::vector<std::string> m_scenes; 26 int m_argc; 27 const MPI_Comm m_comm; 28 bool m_isroot; 29 30 public: 31 OrganizerMPI(const int argc, char ** const argv, const MPI_Comm comm=MPI_COMM_WORLD); 32 33 inline int size() const 34 { 35 int size; 36 MPI_Comm_size(m_comm, &size); 37 return size; 38 } 39 40 inline int rank() const 41 { 42 int rank; 43 MPI_Comm_rank(m_comm, &rank); 44 return rank; 45 } 46 47 std::vector<std::string> split_work() const; 48 inline int argc() const { return m_argc; } 49 inline bool isroot() const { return m_isroot; } 50 inline void wait() const { MPI_Barrier(m_comm); } 51 inline void allreduce(void* send, void* recv, int count, MPI_Datatype type, MPI_Op op) 52 { 53 MPI_Allreduce(send, recv, count, type, op, m_comm); 54 } 55 }; 56 57 #endif /* ORGANIZERMPI_H_8HFBYG90 */