https://mooseframework.inl.gov
MemoryUtils.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 "Moose.h"
13 #include "MooseEnum.h"
14 
15 namespace MemoryUtils
16 {
17 
19 std::string getMPIProcessorName();
20 
21 struct Stats
22 {
23  std::size_t _physical_memory;
24  std::size_t _virtual_memory;
25  std::size_t _page_faults;
26 };
27 
28 enum class MemUnits
29 {
30  Bytes,
31  Kibibytes,
32  Mebibytes,
33  Gibibytes = 3,
34  Kilobytes,
35  Megabytes,
36  Gigabytes = 6,
37 };
38 
41 
43 std::size_t getTotalRAM();
44 
48 bool getMemoryStats(Stats & stats);
49 
51 std::size_t convertBytes(std::size_t bytes, MemUnits unit);
52 
53 } // namespace MemoryUtils
std::string getMPIProcessorName()
get the MPI hostname
Definition: MemoryUtils.C:39
bool getMemoryStats(Stats &stats)
get all memory stats for the current process stats The Stats object to fill with the data ...
Definition: MemoryUtils.C:79
std::size_t _physical_memory
Definition: MemoryUtils.h:23
std::size_t _virtual_memory
Definition: MemoryUtils.h:24
std::size_t _page_faults
Definition: MemoryUtils.h:25
MooseEnum getMemUnitsEnum()
get the moose enum for the mem_unit_prefix parameter
Definition: MemoryUtils.C:52
std::size_t getTotalRAM()
get the total amount of physical RAM available
Definition: MemoryUtils.C:59
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
std::size_t convertBytes(std::size_t bytes, MemUnits unit)
convert bytes to selected unit prefix
Definition: MemoryUtils.C:174