-
Notifications
You must be signed in to change notification settings - Fork 99
/
Copy pathSystem.h
114 lines (79 loc) · 2.19 KB
/
System.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
DDS, a bridge double dummy solver.
Copyright (C) 2006-2014 by Bo Haglund /
2014-2018 by Bo Haglund & Soren Hein.
See LICENSE and README.
*/
#ifndef DDS_SYSTEM_H
#define DDS_SYSTEM_H
/*
This class encapsulates all the system-dependent stuff.
*/
#include <string>
#include <vector>
#include "dds.h"
using namespace std;
typedef void (*fptrType)(const int thid);
typedef void (*fduplType)(
const boards& bds, vector<int>& uniques, vector<int>& crossrefs);
typedef void (*fsingleType)(const int thid, const int bno);
typedef void (*fcopyType)(const vector<int>& crossrefs);
class System
{
private:
RunMode runCat; // SOLVE / CALC / PLAY
int numThreads;
int sysMem_MB;
int thrDef_MB;
int thrMax_MB;
unsigned preferredSystem;
vector<bool> availableSystem;
vector<fptrType> CallbackSimpleList;
vector<fduplType> CallbackDuplList;
vector<fsingleType> CallbackSingleList;
vector<fcopyType> CallbackCopyList;
typedef int (System::*RunPtr)();
vector<RunPtr> RunPtrList;
fptrType fptr;
boards const * bop;
int RunThreadsBasic();
int RunThreadsBoost();
int RunThreadsOpenMP();
int RunThreadsGCD();
int RunThreadsWinAPI();
int RunThreadsSTL();
int RunThreadsTBB();
int RunThreadsSTLIMPL();
int RunThreadsPPLIMPL();
string GetVersion(
int& major,
int& minor,
int& patch) const;
string GetSystem(int& sys) const;
string GetBits(int& bits) const;
string GetCompiler(int& comp) const;
string GetCores(int& comp) const;
string GetConstructor(int& cons) const;
string GetThreading(int& thr) const;
string GetThreadSizes(char * c) const;
public:
System();
~System() = default;
void Reset();
int RegisterParams(
const int nThreads,
const int mem_usable_MB);
int RegisterRun(
const RunMode r,
const boards& bop);
bool IsSingleThreaded() const;
bool IsIMPL() const;
bool ThreadOK(const int thrId) const;
void GetHardware(
int& ncores,
unsigned long long& kilobytesFree) const;
int PreferThreading(const unsigned code);
int RunThreads();
string str(DDSInfo * info) const;
};
#endif