SST  7.1.0
StructuralSimulationToolkit
rankInfo.h
1 // -*- c++ -*-
2 
3 // Copyright 2009-2017 Sandia Corporation. Under the terms
4 // of Contract DE-NA0003525 with Sandia Corporation, the U.S.
5 // Government retains certain rights in this software.
6 //
7 // Copyright (c) 2009-2017, Sandia Corporation
8 // All rights reserved.
9 //
10 // This file is part of the SST software package. For license
11 // information, see the LICENSE file in the top level directory of the
12 // distribution.
13 
14 #ifndef SST_CORE_RANKINFO_H
15 #define SST_CORE_RANKINFO_H
16 
17 #include <sst/core/serialization/serializable.h>
18 
19 namespace SST {
20 
22 public:
23  static const uint32_t UNASSIGNED = (uint32_t)-1;
24  uint32_t rank;
25  uint32_t thread;
26 
27  RankInfo(uint32_t rank, uint32_t thread) :
28  rank(rank), thread(thread)
29  { }
30 
31  RankInfo() : rank(UNASSIGNED), thread(UNASSIGNED)
32  { };
33 
34  bool isAssigned() const {
35  return (rank != UNASSIGNED && thread != UNASSIGNED);
36  }
37 
38  /**
39  * @return true if other's rank and thread are less than ours
40  */
41  bool inRange(const RankInfo& other) const {
42  return ((rank > other.rank) && (thread > other.thread));
43  }
44 
45  bool operator==(const RankInfo& other) const {
46  return (rank == other.rank) && (thread == other.thread);
47  }
48 
49  bool operator!=(const RankInfo& other) const {
50  return !(operator==(other));
51  }
52 
53  bool operator<(const RankInfo& other) const {
54  if ( rank == other.rank ) return thread < other.thread;
55  return rank < other.rank;
56  }
57 
58  bool operator<=(const RankInfo& other) const {
59  if ( rank == other.rank ) return thread <= other.thread;
60  return rank <= other.rank;
61  }
62 
63  bool operator>(const RankInfo& other) const {
64  if ( rank == other.rank ) return thread > other.thread;
65  return rank > other.rank;
66  }
67 
68  bool operator>=(const RankInfo& other) const {
69  if ( rank == other.rank ) return thread >= other.thread;
70  return rank >= other.rank;
71  }
72 
73  void serialize_order(SST::Core::Serialization::serializer &ser) override
74  {
75  ser & rank;
76  ser & thread;
77  }
78 
79 
80 private:
81 
82  ImplementSerializable(SST::RankInfo)
83 };
84 
85 }
86 
87 #endif
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:35
bool inRange(const RankInfo &other) const
Definition: rankInfo.h:41
Definition: action.cc:17
Definition: serializable.h:109
Definition: rankInfo.h:21