https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
15namespace MemoryUtils
16{
17
19std::string getMPIProcessorName();
20
21struct Stats
22{
23 std::size_t _physical_memory;
24 std::size_t _virtual_memory;
25 std::size_t _page_faults;
26};
27
28enum class MemUnits
29{
30 Bytes,
33 Gibibytes = 3,
36 Gigabytes = 6,
37};
38
41
43std::size_t getTotalRAM();
44
48bool getMemoryStats(Stats & stats);
49
51std::size_t convertBytes(std::size_t bytes, MemUnits unit);
52
53} // namespace MemoryUtils
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
std::size_t convertBytes(std::size_t bytes, MemUnits unit)
convert bytes to selected unit prefix
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 getTotalRAM()
get the total amount of physical RAM available
Definition MemoryUtils.C:59
MooseEnum getMemUnitsEnum()
get the moose enum for the mem_unit_prefix parameter
Definition MemoryUtils.C:52
std::size_t _virtual_memory
Definition MemoryUtils.h:24
std::size_t _physical_memory
Definition MemoryUtils.h:23
std::size_t _page_faults
Definition MemoryUtils.h:25