https://mooseframework.inl.gov
RankMap.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include "PerfGraphInterface.h"
13 
14 #include "libmesh/parallel_object.h"
15 
24 {
25 public:
30 
35  unsigned int hardwareID(processor_id_type pid) const
36  {
37  mooseAssert(pid < _communicator.size(), "PID out of range");
38  return _rank_to_hardware_id[pid];
39  }
40 
44  const std::vector<processor_id_type> & ranks(unsigned int hardware_id) const
45  {
46  auto item = _hardware_id_to_ranks.find(hardware_id);
47  if (item == _hardware_id_to_ranks.end())
48  mooseError("hardware_id not found");
49 
50  return item->second;
51  }
52 
56  const std::vector<unsigned int> & rankHardwareIds() const { return _rank_to_hardware_id; }
57 
58 protected:
60  std::unordered_map<unsigned int, std::vector<processor_id_type>> _hardware_id_to_ranks;
61 
63  std::vector<unsigned int> _rank_to_hardware_id;
64 };
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
const std::vector< processor_id_type > & ranks(unsigned int hardware_id) const
Returns the ranks that are on the given hardwareID (phsical node in the job)
Definition: RankMap.h:44
std::vector< unsigned int > _rank_to_hardware_id
Each entry corresponds to the hardware_id for that PID.
Definition: RankMap.h:63
Builds lists and maps that help in knowing which physical hardware nodes each rank is on...
Definition: RankMap.h:23
const Parallel::Communicator & comm() const
std::unordered_map< unsigned int, std::vector< processor_id_type > > _hardware_id_to_ranks
Map of hardware_id -> ranks on that node.
Definition: RankMap.h:60
const Parallel::Communicator & _communicator
processor_id_type size() const
uint8_t processor_id_type
const std::vector< unsigned int > & rankHardwareIds() const
Vector containing the hardware ID for each PID.
Definition: RankMap.h:56
Interface for objects interacting with the PerfGraph.
unsigned int hardwareID(processor_id_type pid) const
Returns the "hardware ID" (a unique ID given to each physical compute node in the job) for a given pr...
Definition: RankMap.h:35
RankMap(const libMesh::Parallel::Communicator &comm, PerfGraph &perf_graph)
Constructs and fills the map.
Definition: RankMap.C:17
The PerfGraph will hold the master list of all registered performance segments and the head PerfNode...
Definition: PerfGraph.h:43