Skip to content

Commit

Permalink
Merge pull request #523 from m-a-d-n-e-s-s/evaleev/feature/memory-siz…
Browse files Browse the repository at this point in the history
…e-units

memory size units
  • Loading branch information
evaleev authored Feb 11, 2024
2 parents 10fa2fb + 9bef331 commit 5b38ea4
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 284 deletions.
3 changes: 2 additions & 1 deletion doc/Latex/apps/moldft/manual.tex
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ \subsection{Environment variables}
the build/installation directory.

\verb+MAD_BUFFER_SIZE+ --- Sets the buffer size (in bytes) used by the
active messages (default is 1.5MBytes). Never needed by moldft?
active messages; an integer, with optional units (1KB = 1024, 1MB = 1024^2, etc.); default is 1536KB.
Never needed by moldft?

\verb+MAD_RECV_BUFFERS+ --- Sets the number of receive buffers used by
the communication thread (default is 128 and a minimum of 32 is
Expand Down
4 changes: 2 additions & 2 deletions src/madness/world/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ set(MADWORLD_HEADERS
text_fstream_archive.h worlddc.h mem_func_wrapper.h taskfn.h group.h
dist_cache.h distributed_id.h type_traits.h function_traits.h stubmpi.h
bgq_atomics.h binsorter.h parsec.h meta.h worldinit.h thread_info.h
cloud.h test_utilities.h timing_utilities.h)
cloud.h test_utilities.h timing_utilities.h units.h)
set(MADWORLD_SOURCES
madness_exception.cc world.cc timers.cc future.cc redirectio.cc
archive_type_names.cc debug.cc print.cc worldmem.cc worldrmi.cc
safempi.cc worldpapi.cc worldref.cc worldam.cc worldprofile.cc thread.cc
world_task_queue.cc worldgop.cc deferred_cleanup.cc worldmutex.cc
binary_fstream_archive.cc text_fstream_archive.cc lookup3.c worldmpi.cc
group.cc parsec.cc archive.cc)
group.cc parsec.cc archive.cc units.cc)

if(MADNESS_ENABLE_CEREAL)
set(MADWORLD_HEADERS ${MADWORLD_HEADERS} "cereal_archive.h")
Expand Down
162 changes: 0 additions & 162 deletions src/madness/world/hardware.cc

This file was deleted.

98 changes: 0 additions & 98 deletions src/madness/world/hardware.h

This file was deleted.

48 changes: 48 additions & 0 deletions src/madness/world/units.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// Created by Eduard Valeyev on 2/5/24.
//

#include <madness/world/units.h>

#include <madness/world/madness_exception.h>


#include <sstream>

namespace madness {

std::uint64_t cstr_to_memory_size(const char *str) {
// Convert the string into bytes
std::stringstream ss(str);
std::uint64_t memory = 0;
if (ss >> memory) {
if (memory > 0) {
std::string unit;
if (ss >> unit) { // Failure == assume bytes
if (unit == "KB" || unit == "kB" || unit == "KiB") {
MADNESS_ASSERT(memory <= (1ul << 54));
memory *= 1024ul;
} else if (unit == "MB" || unit == "MiB") {
MADNESS_ASSERT(memory <= (1ul << 44));
memory *= 1024ul * 1024;
} else if (unit == "GB" || unit == "GiB") {
MADNESS_ASSERT(memory <= (1ul << 34));
memory *= 1024ul * 1024 * 1024;
} else if (unit == "TB" || unit == "TiB") {
MADNESS_ASSERT(memory <= (1ul << 24));
memory *= 1024ul * 1024 * 1024 * 1024;
} else if (unit == "PB" || unit == "PiB") {
MADNESS_ASSERT(memory <= (1ul << 14));
memory *= 1024ul * 1024 * 1024 * 1024 * 1024;
} else if (unit == "EB" || unit == "EiB") {
MADNESS_ASSERT(memory <= (1ul << 4));
memory *= 1024ul * 1024 * 1024 * 1024 * 1024 * 1024;
}
}
}
}

return memory;
}

} // namespace madness
Loading

0 comments on commit 5b38ea4

Please sign in to comment.