SST  13.1.0
Structural Simulation Toolkit
rankInfo.h
1 // -*- c++ -*-
2 
3 // Copyright 2009-2023 NTESS. Under the terms
4 // of Contract DE-NA0003525 with NTESS, the U.S.
5 // Government retains certain rights in this software.
6 //
7 // Copyright (c) 2009-2023, NTESS
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 {
23 public:
24  static const uint32_t UNASSIGNED = (uint32_t)-1;
25  uint32_t rank;
26  uint32_t thread;
27 
28  RankInfo(uint32_t rank, uint32_t thread) : rank(rank), thread(thread) {}
29 
30  RankInfo() : rank(UNASSIGNED), thread(UNASSIGNED) {};
31 
32  bool isAssigned() const { return (rank != UNASSIGNED && thread != UNASSIGNED); }
33 
34  /**
35  * @return true if other's rank and thread are less than ours
36  */
37  bool inRange(const RankInfo& other) const { return ((rank > other.rank) && (thread > other.thread)); }
38 
39  bool operator==(const RankInfo& other) const { return (rank == other.rank) && (thread == other.thread); }
40 
41  bool operator!=(const RankInfo& other) const { return !(operator==(other)); }
42 
43  bool operator<(const RankInfo& other) const
44  {
45  if ( rank == other.rank ) return thread < other.thread;
46  return rank < other.rank;
47  }
48 
49  bool operator<=(const RankInfo& other) const
50  {
51  if ( rank == other.rank ) return thread <= other.thread;
52  return rank <= other.rank;
53  }
54 
55  bool operator>(const RankInfo& other) const
56  {
57  if ( rank == other.rank ) return thread > other.thread;
58  return rank > other.rank;
59  }
60 
61  bool operator>=(const RankInfo& other) const
62  {
63  if ( rank == other.rank ) return thread >= other.thread;
64  return rank >= other.rank;
65  }
66 
67  void serialize_order(SST::Core::Serialization::serializer& ser) override
68  {
69  ser& rank;
70  ser& thread;
71  }
72 
73 private:
74  ImplementSerializable(SST::RankInfo)
75 };
76 
77 } // namespace SST
78 
79 #endif // SST_CORE_RANKINFO_H
Definition: serializable.h:119
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:35
Definition: rankInfo.h:22
bool inRange(const RankInfo &other) const
Definition: rankInfo.h:37