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 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /externals/g4tools/include/toolx/mpi/world (Version 11.3.0) and /externals/g4tools/include/toolx/mpi/world (Version 11.2.2)


  1 // Copyright (C) 2010, Guy Barrand. All rights      1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
  2 // See the file tools.license for terms.            2 // See the file tools.license for terms.
  3                                                     3 
  4 #ifndef toolx_mpi_world                             4 #ifndef toolx_mpi_world
  5 #define toolx_mpi_world                             5 #define toolx_mpi_world
  6                                                     6 
  7 // code to wrap MPI global things by having an      7 // code to wrap MPI global things by having an interface (toolx::mpi).
  8                                                     8 
  9 #include <tools/impi_world>                         9 #include <tools/impi_world>
 10                                                    10 
 11 #include <mpi.h>                                   11 #include <mpi.h>
 12                                                    12 
 13 #ifdef TOOLS_MEM                                   13 #ifdef TOOLS_MEM
 14 #include <tools/mem>                               14 #include <tools/mem>
 15 #endif                                             15 #endif
 16                                                    16 
 17 namespace toolx {                                  17 namespace toolx {
 18 namespace mpi {                                    18 namespace mpi {
 19                                                    19 
 20 class world : public virtual tools::impi_world     20 class world : public virtual tools::impi_world {
 21   typedef tools::impi_world parent;                21   typedef tools::impi_world parent;
 22 #ifdef TOOLS_MEM                                   22 #ifdef TOOLS_MEM
 23 protected:                                         23 protected:
 24   static const std::string& s_class() {            24   static const std::string& s_class() {
 25     static const std::string s_v("toolx::mpi::     25     static const std::string s_v("toolx::mpi::world");
 26     return s_v;                                    26     return s_v;
 27   }                                                27   }
 28 #endif                                             28 #endif
 29 public:                                            29 public:
 30   virtual bool init(int* a_argc,char*** a_argv     30   virtual bool init(int* a_argc,char*** a_argv) {
 31     if(::MPI_Init(a_argc,a_argv)!=MPI_SUCCESS)     31     if(::MPI_Init(a_argc,a_argv)!=MPI_SUCCESS) return false;
 32     return true;                                   32     return true;
 33   }                                                33   }
 34   virtual bool rank(int& a_rank) const {           34   virtual bool rank(int& a_rank) const {
 35     if(::MPI_Comm_rank(MPI_COMM_WORLD,&a_rank)     35     if(::MPI_Comm_rank(MPI_COMM_WORLD,&a_rank)!=MPI_SUCCESS) {a_rank=-1;return false;}
 36     return true;                                   36     return true;
 37   }                                                37   }
 38   virtual bool size(int& a_size) const {           38   virtual bool size(int& a_size) const {
 39     if(::MPI_Comm_size(MPI_COMM_WORLD,&a_size)     39     if(::MPI_Comm_size(MPI_COMM_WORLD,&a_size)!=MPI_SUCCESS) {a_size=0;return false;}
 40     return true;                                   40     return true;
 41   }                                                41   }
 42   virtual bool processor_name(std::string& a_s     42   virtual bool processor_name(std::string& a_s) const {
 43     char name[MPI_MAX_PROCESSOR_NAME];             43     char name[MPI_MAX_PROCESSOR_NAME];
 44     int lname;                                     44     int lname;
 45     if(::MPI_Get_processor_name(name,&lname)!=     45     if(::MPI_Get_processor_name(name,&lname)!=MPI_SUCCESS) {a_s.clear();return false;}
 46     a_s = std::string(name);                       46     a_s = std::string(name);
 47     return true;                                   47     return true;
 48   }                                                48   }
 49 public:                                            49 public:
 50   world() {                                        50   world() {
 51 #ifdef TOOLS_MEM                                   51 #ifdef TOOLS_MEM
 52     tools::mem::increment(s_class().c_str());      52     tools::mem::increment(s_class().c_str());
 53 #endif                                             53 #endif
 54   }                                                54   }
 55   virtual ~world(){                                55   virtual ~world(){
 56 #ifdef TOOLS_MEM                                   56 #ifdef TOOLS_MEM
 57     tools::mem::decrement(s_class().c_str());      57     tools::mem::decrement(s_class().c_str());
 58 #endif                                             58 #endif
 59   }                                                59   }
 60 protected:                                         60 protected:
 61   world(const world& a_from):parent(a_from) {      61   world(const world& a_from):parent(a_from) {
 62 #ifdef TOOLS_MEM                                   62 #ifdef TOOLS_MEM
 63     tools::mem::increment(s_class().c_str());      63     tools::mem::increment(s_class().c_str());
 64 #endif                                             64 #endif
 65   }                                                65   }
 66   world& operator=(const world&) {return *this     66   world& operator=(const world&) {return *this;}
 67 };                                                 67 };
 68                                                    68 
 69 }}                                                 69 }}
 70                                                    70 
 71 #endif                                             71 #endif