https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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{
25public:
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
58protected:
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:311
Interface for objects interacting with the PerfGraph.
The PerfGraph will hold the master list of all registered performance segments and the head PerfNode.
Definition PerfGraph.h:44
Builds lists and maps that help in knowing which physical hardware nodes each rank is on.
Definition RankMap.h:24
const std::vector< unsigned int > & rankHardwareIds() const
Vector containing the hardware ID for each PID.
Definition RankMap.h:56
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
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
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
processor_id_type size() const
const Parallel::Communicator & _communicator
const Parallel::Communicator & comm() const