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
/*
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 <vector>
#include <api/dds.h>
#include <moves/moves.hpp>
#include <system/thread_data.hpp>
#ifdef DDS_AB_STATS
#include "ab_stats.hpp"
#endif
#ifdef DDS_TIMING
#include <system/timer_list.hpp>
#endif
/**
* @brief Thread-local memory manager for bridge double dummy solver.
*
* The Memory class manages per-thread resources, including allocation and cleanup
* of thread-local data structures required for double dummy analysis. It provides
* interfaces for resizing, accessing, and reporting memory usage for each thread.
* Memory is an internal component and not part of the public API.
*/
class Memory
{
private:
// Per static_memory_genmove.md step one: ThreadData instances are no
// longer stored in a central Memory::memory vector. ThreadData will be
// owned/allocated by the SolverContext (as a member) and passed down to
// call sites. This header therefore no longer keeps per-thread pointers.
// Keep a lightweight record of configured thread sizes for diagnostics
// and reporting. This replaces the previous `memory` vector which held
// full ThreadData instances.
std::vector<std::string> threadSizes;
public:
/**
* @brief Construct a new Memory object.
*
* Initializes thread-local memory tracking and prepares for allocation.
*/
Memory();
/**
* @brief Destroy the Memory object and clean up resources.
*
* Releases all memory and performs cleanup of thread-local resources.
*/
~Memory();
void ReturnThread(const unsigned thrId);
void Resize(
const unsigned n,
const TTmemory flag,
const int memDefault_MB,
const int memMaximum_MB); // NOLINT(bugprone-easily-swappable-parameters)
unsigned NumThreads() const;
double MemoryInUseMB(const unsigned thrId) const;
std::string ThreadSize(const unsigned thrId) const;
};
#endif