SST  15.1.0
StructuralSimulationToolkit
rankInfo.h
1 // -*- c++ -*-
2 
3 // Copyright 2009-2025 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-2025, 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 #include <cstdint>
20 
21 namespace SST {
22 
24 {
25 public:
26  static const uint32_t UNASSIGNED = (uint32_t)-1;
27  uint32_t rank;
28  uint32_t thread;
29 
30  RankInfo(uint32_t rank, uint32_t thread) :
31  rank(rank),
32  thread(thread)
33  {}
34 
35  RankInfo() :
36  rank(UNASSIGNED),
37  thread(UNASSIGNED) {};
38 
39  bool isAssigned() const { return (rank != UNASSIGNED && thread != UNASSIGNED); }
40 
41  /**
42  * @return true if other's rank and thread are less than ours
43  */
44  bool inRange(const RankInfo& other) const { return ((rank > other.rank) && (thread > other.thread)); }
45 
46  bool operator==(const RankInfo& other) const { return (rank == other.rank) && (thread == other.thread); }
47 
48  bool operator!=(const RankInfo& other) const { return !(operator==(other)); }
49 
50  bool operator<(const RankInfo& other) const
51  {
52  if ( rank == other.rank ) return thread < other.thread;
53  return rank < other.rank;
54  }
55 
56  bool operator<=(const RankInfo& other) const
57  {
58  if ( rank == other.rank ) return thread <= other.thread;
59  return rank <= other.rank;
60  }
61 
62  bool operator>(const RankInfo& other) const
63  {
64  if ( rank == other.rank ) return thread > other.thread;
65  return rank > other.rank;
66  }
67 
68  bool operator>=(const RankInfo& other) const
69  {
70  if ( rank == other.rank ) return thread >= other.thread;
71  return rank >= other.rank;
72  }
73 
74  void serialize_order(SST::Core::Serialization::serializer& ser) override
75  {
76  SST_SER(rank);
77  SST_SER(thread);
78  }
79 
80 private:
81  ImplementSerializable(SST::RankInfo)
82 };
83 
84 } // namespace SST
85 
86 #endif // SST_CORE_RANKINFO_H
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:42
bool inRange(const RankInfo &other) const
Definition: rankInfo.h:44
Definition: action.cc:18
Definition: serializable.h:23
Definition: rankInfo.h:23