Add memory summary.
This commit is contained in:
parent
c5fbc1a182
commit
b772349f69
13 changed files with 23 additions and 1209 deletions
10
src/Mem.h
10
src/Mem.h
|
@ -35,9 +35,9 @@ class Mem
|
|||
{
|
||||
public:
|
||||
enum Flags {
|
||||
HUGEPAGES_AVAILABLE = 1,
|
||||
HUGEPAGES_ENABLED = 2,
|
||||
LOCK = 4
|
||||
HugepagesAvailable = 1,
|
||||
HugepagesEnabled = 2,
|
||||
Lock = 4
|
||||
};
|
||||
|
||||
static bool allocate(int algo, int threads, bool doubleHash);
|
||||
|
@ -45,7 +45,9 @@ public:
|
|||
static void *calloc(size_t num, size_t size);
|
||||
static void release();
|
||||
|
||||
static inline int flags() { return m_flags; }
|
||||
static inline bool isHugepagesAvailable() { return m_flags & HugepagesAvailable; }
|
||||
static inline bool isHugepagesEnabled() { return m_flags & HugepagesEnabled; }
|
||||
static inline int flags() { return m_flags; }
|
||||
|
||||
private:
|
||||
static bool m_doubleHash;
|
||||
|
|
|
@ -147,7 +147,7 @@ bool Mem::allocate(int algo, int threads, bool doubleHash)
|
|||
const size_t size = MEMORY * (threads * ratio + 1);
|
||||
|
||||
if (TrySetLockPagesPrivilege()) {
|
||||
m_flags |= HUGEPAGES_AVAILABLE;
|
||||
m_flags |= HugepagesAvailable;
|
||||
}
|
||||
|
||||
m_memory = static_cast<uint8_t*>(VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE | MEM_LARGE_PAGES, PAGE_READWRITE));
|
||||
|
@ -155,7 +155,7 @@ bool Mem::allocate(int algo, int threads, bool doubleHash)
|
|||
m_memory = static_cast<uint8_t*>(_mm_malloc(size, 16));
|
||||
}
|
||||
else {
|
||||
m_flags |= HUGEPAGES_ENABLED;
|
||||
m_flags |= HugepagesEnabled;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -164,7 +164,7 @@ bool Mem::allocate(int algo, int threads, bool doubleHash)
|
|||
|
||||
void Mem::release()
|
||||
{
|
||||
if (m_flags & HUGEPAGES_ENABLED) {
|
||||
if (m_flags & HugepagesEnabled) {
|
||||
VirtualFree(m_memory, 0, MEM_RELEASE);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include "Console.h"
|
||||
#include "Cpu.h"
|
||||
#include "Mem.h"
|
||||
#include "Options.h"
|
||||
#include "Summary.h"
|
||||
#include "version.h"
|
||||
|
@ -51,6 +52,18 @@ static void print_versions()
|
|||
}
|
||||
|
||||
|
||||
static void print_memory() {
|
||||
if (Options::i()->colors()) {
|
||||
Console::i()->text("\x1B[01;32m * \x1B[01;37mHUGE PAGES: %s, %s",
|
||||
Mem::isHugepagesAvailable() ? "\x1B[01;32mavailable" : "\x1B[01;31munavailable",
|
||||
Mem::isHugepagesEnabled() ? "\x1B[01;32menabled" : "\x1B[01;31mdisabled");
|
||||
}
|
||||
else {
|
||||
Console::i()->text(" * HUGE PAGES: %s, %s", Mem::isHugepagesAvailable() ? "available" : "unavailable", Mem::isHugepagesEnabled() ? "enabled" : "disabled");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void print_cpu()
|
||||
{
|
||||
if (Options::i()->colors()) {
|
||||
|
@ -104,6 +117,7 @@ static void print_threads()
|
|||
void Summary::print()
|
||||
{
|
||||
print_versions();
|
||||
print_memory();
|
||||
print_cpu();
|
||||
print_threads();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue