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 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  Windows variant only provides the number of cores.
37 
38 SourceFiles
39  cpuInfo.C
40 
41 \*---------------------------------------------------------------------------*/
42 
43 #ifndef cpuInfo_H
44 #define cpuInfo_H
45 
46 #include <string>
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 // Forward declarations
54 class Ostream;
55 
56 /*---------------------------------------------------------------------------*\
57  Class cpuInfo Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 class cpuInfo
61 {
62  // Private data
63 
64  // Various bits from /proc/cpuinfo
65 
66  std::string vendor_id;
67  std::string model_name;
68  int cpu_family;
69  int model;
70  float cpu_MHz;
71  int siblings;
72  int cpu_cores;
73 
74 
75  // Private Member Functions
76 
77  //- Parse /proc/cpuinfo
78  void parse();
79 
80  //- No copy construct
81  cpuInfo(const cpuInfo&) = delete;
82 
83  //- No copy assignment
84  void operator=(const cpuInfo&) = delete;
85 
86 public:
87 
88  // Constructors
89 
90  //- Construct and populate with information
91  cpuInfo();
92 
93  //- Destructor
94  ~cpuInfo() = default;
95 
96 
97  // Member Functions
98 
99  //- Write content as dictionary entries
100  void write(Ostream& os) const;
101 
102 };
103 
104 
105 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
106 
107 } // End namespace Foam
108 
109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
110 
111 #endif
112 
113 // ************************************************************************* //
Foam::cpuInfo::~cpuInfo
~cpuInfo()=default
Destructor.
Foam::cpuInfo
General CPU characteristics.
Definition: cpuInfo.H:59
os
OBJstream os(runTime.globalPath()/outputName)
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::cpuInfo::cpuInfo
cpuInfo()
Construct and populate with information.
Definition: cpuInfo.C:37
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::cpuInfo::write
void write(Ostream &os) const
Write content as dictionary entries.
Definition: cpuInfo.C:51