SparseLibrary  Version 1.6.0
MachineInfo.hpp
1 /*
2  * Copyright (c) 2007-2014, A. N. Yzelman, Utrecht University 2007-2011;
3  * KU Leuven 2011-2014.
4  * R. H. Bisseling, Utrecht University 2007-2014.
5  *
6  * This file is part of the Sparse Library.
7  *
8  * This library was developed under supervision of Prof. dr. Rob H. Bisseling at
9  * Utrecht University, from 2007 until 2011. From 2011-2014, development continued
10  * at KU Leuven, where Prof. dr. Dirk Roose contributed significantly to the ideas
11  * behind the newer parts of the library code.
12  *
13  * The Sparse Library is free software: you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by the
15  * Free Software Foundation, either version 3 of the License, or (at your
16  * option) any later version.
17  *
18  * The Sparse Library is distributed in the hope that it will be useful, but
19  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20  * or 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 along
24  * with the Sparse Library. If not, see <http://www.gnu.org/licenses/>.
25  */
26 
27 
28 /*
29  * File created by:
30  * A. N. Yzelman, Dept. of Computer Science, KU Leuven, 2011.
31  */
32 
33 
34 #include <string>
35 #include <fstream>
36 #include <iostream>
37 #include <pthread.h>
38 #include <limits.h>
39 
40 #ifndef _H_MACHINEINFO
41 #define _H_MACHINEINFO
42 
44 class MachineInfo {
45 
46  private:
48  static MachineInfo instance;
49 
51  static pthread_mutex_t mutex;
52 
54  static bool initialised;
55 
57  MachineInfo();
58 
59  protected:
61  unsigned long int P;
62 
64  static void load();
65 
66  public:
68  static const MachineInfo& getInstance();
69 
71  unsigned long int cores() const;
72 
73 };
74 
75 #endif
76 
unsigned long int cores() const
The number of available cores.
Definition: MachineInfo.cpp:77
static const MachineInfo & getInstance()
Gets a singleton instance.
Definition: MachineInfo.cpp:38
unsigned long int P
The number of available cores on this machine.
Definition: MachineInfo.hpp:61
Singleton class to get info on the current system.
Definition: MachineInfo.hpp:44
static void load()
Intialises the singleton instance.
Definition: MachineInfo.cpp:54