-
Notifications
You must be signed in to change notification settings - Fork 99
/
Copy pathMemory.h
143 lines (103 loc) · 2.07 KB
/
Memory.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
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_MEMORY_H
#define DDS_MEMORY_H
#include <memory>
#include <vector>
#include "TransTable.h"
#include "TransTableS.h"
#include "TransTableL.h"
#include "Moves.h"
#include "File.h"
#include "debug.h"
#ifdef DDS_AB_STATS
#include "ABstats.h"
#endif
#ifdef DDS_TIMING
#include "TimerList.h"
#endif
using namespace std;
enum TTmemory
{
DDS_TT_SMALL = 0,
DDS_TT_LARGE = 1
};
struct WinnerEntryType
{
int suit;
int winnerRank;
int winnerHand;
int secondRank;
int secondHand;
};
struct WinnersType
{
int number;
WinnerEntryType winner[4];
};
struct ThreadData
{
int nodeTypeStore[DDS_HANDS];
int iniDepth;
bool val;
unsigned short int suit[DDS_HANDS][DDS_SUITS];
int trump;
pos lookAheadPos; // Recursive alpha-beta data
bool analysisFlag;
unsigned short int lowestWin[50][DDS_SUITS];
WinnersType winners[13];
moveType forbiddenMoves[14];
moveType bestMove[50];
moveType bestMoveTT[50];
double memUsed;
int nodes;
int trickNodes;
// Constant for a given hand.
// 960 KB
relRanksType rel[8192];
std::unique_ptr<TransTable> transTable;
Moves moves;
#ifdef DDS_TOP_LEVEL
File fileTopLevel;
#endif
#ifdef DDS_AB_STATS
ABstats ABStats;
File fileABstats;
#endif
#ifdef DDS_AB_HITS
File fileRetrieved;
File fileStored;
#endif
#ifdef DDS_TT_STATS
File fileTTstats;
#endif
#ifdef DDS_TIMING
TimerList timerList;
File fileTimerList;
#endif
#ifdef DDS_MOVES
File fileMoves;
#endif
};
class Memory
{
private:
vector<ThreadData> memory;
vector<string> threadSizes;
public:
void ReturnThread(const unsigned thrId);
void Resize(
const unsigned n,
const TTmemory flag,
const int memDefault_MB,
const int memMaximum_MB);
unsigned NumThreads() const;
ThreadData * GetPtr(const unsigned thrId);
double MemoryInUseMB(const unsigned thrId) const;
string ThreadSize(const unsigned thrId) const;
};
#endif