SST  15.1.0
StructuralSimulationToolkit
mempoolAccessor.h
1 // Copyright 2009-2025 NTESS. Under the terms
2 // of Contract DE-NA0003525 with NTESS, the U.S.
3 // Government retains certain rights in this software.
4 //
5 // Copyright (c) 2009-2025, NTESS
6 // All rights reserved.
7 //
8 // This file is part of the SST software package. For license
9 // information, see the LICENSE file in the top level directory of the
10 // distribution.
11 
12 #ifndef SST_CORE_MEMPOOL_ACCESSOR_H
13 #define SST_CORE_MEMPOOL_ACCESSOR_H
14 
15 #include <cstddef>
16 #include <cstdint>
17 #include <string>
18 
19 namespace SST::Core {
20 
21 // Class to access stats/data about the mempools. This is here to
22 // limit exposure to the USE_MEMPOOL #define, which will only be in
23 // core .cc files.
25 {
26 public:
27  // Gets the arena size for the specified pool size on the current
28  // thread. If mempools aren't enabled, it will return 0.
29  static size_t getArenaSize(size_t size);
30 
31  // Gets the number of arenas allocated for the specified pool size
32  // on the current thread. If mempools aren't enabled, it will
33  // return 0.
34  static size_t getNumArenas(size_t size);
35 
36  // Gets the total bytes used for the specified pool size on the
37  // current thread. If mempools aren't enabled, it will return 0.
38  static uint64_t getBytesMemUsedBy(size_t size);
39 
40  // Gets the total mempool usage for the rank. Returns both the
41  // bytes and the number of active entries. Bytes and entries are
42  // added to the value passed into the function. If mempools
43  // aren't enabled, then nothing will be counted.
44  static void getMemPoolUsage(int64_t& bytes, int64_t& active_entries);
45 
46  // Initialize the global mempool data structures
47  static void initializeGlobalData(int num_threads, bool cache_align = false);
48 
49  // Initialize the per thread mempool data structures
50  static void initializeLocalData(int thread);
51 
52  static void printUndeletedMemPoolItems(const std::string& header, Output& out);
53 };
54 
55 } // namespace SST::Core
56 
57 #endif // SST_CORE_MEMPOOL_ACCESSOR_H
Output object provides consistent method for outputting data to stdout, stderr and/or sst debug file...
Definition: output.h:57
Definition: mempoolAccessor.h:24