cpuInfo.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2016-2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::cpuInfo
28 
29 Description
30  General CPU characteristics.
31 
32  If the machine has multiple cpus/cores, only the characteristics
33  of the first core are used.
34 
35 Note
36  Uses the information from /proc/cpuinfo
37 
38 SourceFiles
39  cpuInfo.C
40 
41 \*---------------------------------------------------------------------------*/
42 
43 #ifndef Foam_cpuInfo_H
44 #define Foam_cpuInfo_H
45 
46 #include <string>
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 // Forward Declarations
54 class word;
55 class Ostream;
56 
57 /*---------------------------------------------------------------------------*\
58  Class cpuInfo Declaration
59 \*---------------------------------------------------------------------------*/
60 
61 class cpuInfo
62 {
63  // Private Data
64 
65  std::string vendor_id;
66  std::string model_name;
67  int cpu_family;
68  int model;
69  float cpu_MHz;
70  int siblings;
71  int cpu_cores;
72 
73  // Private Member Functions
74 
75  //- Populate entries
76  void populate();
77 
78 public:
79 
80  // Constructors
81 
82  //- Construct and populate with information
83  cpuInfo();
84 
85 
86  // Member Functions
87 
88  //- Write cpu-info as dictionary entries
89  void writeEntries(Ostream& os) const;
90 
91  //- Write cpu-info as dictionary
92  void writeEntry(const word& keyword, Ostream& os) const;
93 };
94 
95 
96 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
97 
98 } // End namespace Foam
99 
100 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
101 
102 #endif
103 
104 // ************************************************************************* //
cpuInfo()
Construct and populate with information.
Definition: cpuInfo.C:138
void writeEntry(const word &keyword, Ostream &os) const
Write cpu-info as dictionary.
Definition: cpuInfo.C:173
A class for handling words, derived from Foam::string.
Definition: word.H:63
void writeEntries(Ostream &os) const
Write cpu-info as dictionary entries.
Definition: cpuInfo.C:154
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
General CPU characteristics.
Definition: cpuInfo.H:56
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.