Skip to content

Commit

Permalink
Merge branch 'main' into fix_batch
Browse files Browse the repository at this point in the history
  • Loading branch information
doichanj authored Dec 19, 2023
2 parents ceb9613 + 766ad5e commit 852c43d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/framework/utils.hpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@
#include <intrin.h>
#endif

#if defined(__linux__) || defined(__APPLE__)
#if defined(__linux__)
#include <unistd.h>
#elif defined(__APPLE__)
#include <sys/sysctl.h>
#include <sys/types.h>
#elif defined(_WIN64) || defined(_WIN32)
// This is needed because windows.h redefine min()/max() so interferes with
// std::min/max
Expand Down Expand Up @@ -1270,10 +1273,13 @@ uint_t (*popcount)(uint_t) = &_naive_weight;

size_t get_system_memory_mb() {
size_t total_physical_memory = 0;
#if defined(__linux__) || defined(__APPLE__)
#if defined(__linux__)
size_t pages = (size_t)sysconf(_SC_PHYS_PAGES);
size_t page_size = (size_t)sysconf(_SC_PAGE_SIZE);
total_physical_memory = pages * page_size;
#elif defined(__APPLE__)
size_t len = sizeof(total_physical_memory);
sysctlbyname("hw.memsize", &total_physical_memory, &len, NULL, 0);
#elif defined(_WIN64) || defined(_WIN32)
MEMORYSTATUSEX status;
status.dwLength = sizeof(status);
Expand Down

0 comments on commit 852c43d

Please sign in to comment.