I am writing a quantum chemistry program and in the course of its development, I come to a point where I have to decide between memory consumption and execution time. To put it briefly, if I choose the execution time, the run can become significantly faster because some big matrices need be computed once and stored in memory for later purposes. If I chose to preserve the memory, these matrices will be calculated at each iteration and the execution time increases quickly. Now I want to make my program to automatically detect how much memory my system has and use that information to automatically decide whether to preserve memory or chose a faster execution. I want something that goes in the line where I specify a fraction of the total memory that my program is allowed to use. How to achieve this using C++?
The program runs on a computer cluster and the minimum memory per core it has is 32 GB. Is there some kind of suggested memory consumption good programs usually have? I have access to a similar program and the output of a certain run is the following,
Memory information
------------------
heap = 13107198 doubles = 100.0 Mbytes
stack = 13107195 doubles = 100.0 Mbytes
global = 26214400 doubles = 200.0 Mbytes (distinct from heap & stack)
total = 52428793 doubles = 400.0 Mbytes
verify = yes
hardfail = no
I am wondering why it has division of memory usage into heap, stack, and global. Does it mean that I can actually specify in my program which part of memory certain data are to be stored?