QMol_SE_profiler - fmauger1/QMol-grid GitHub Wiki
QMol_SE_profiler
Memory and execution-time profiler for Schrödinger-equation models.
Description
Use QMol_SE_profiler
to estimate the memory footprint and execution time of a Schrödinger-equation (SE) model or component.
Use
Run the memory and execution-time profiling with either
QMol_SE_profiler(QM);
QMol_SE_profiler(QM,'all');
QM
is any of a (TD)SE model or potential objects.- The requirements and side effects as for both memory-only and execution-time-only modes detailed next.
- Note that for TDSE object only the memory footprint, and not the execution time, is estimated.
Run only the memory profiling component with
QMol_SE_profiler(QM,'memory');
- Schrödinger-equation model case: If
QM
is a SE model object (QMol_SE
), it should define a proper discretization domain (explicitly or implicitly) and potential; However, it does not need to be initialized before running the memory profiling. The memory profiling uses the object'sgetMemoryProfile
method and has its side effects: all the Schrödinger-equation-model properties are left unchanged while run-time properties may be altered. Notably, if the object was not initialized (isInitialized = false
),getMemoryProfile
reset
s the object. - Schrödinger-equation component case: If
QM
is a potential object, it must be initialized (with a SE component -- see the respective documentation pages for details). - TDSE propagator case: if QM is a TDSE propagator object, it should define a full Schrödinger-equation model, which is initialized before performing the memory profiling.
- In all cases, not all the listed components may be used in actual simulations and the memory estimate tries to be conservative. On the other hand, it only includes the discretization of member components on the domain grid and ignores other (small) properties.
Run only the execution-time profiling component with
QMol_SE_profiler(QM,'time');
- Schrödinger-equation model case: If
QM
is a SE model object (QMol_SE
), it should define a proper discretization domain (explcitly or implicitly) and potential; However, it does not need to be initialized before running the memory profiling. The execution-time profiling initializes the object and returns it initialized. - Schrödinger-equation component case: If
QM
is a potential object, it must be initialized (with a SE component -- see the respective documentation pages for details). The execution-time profiling initialized the parent SE component (QM.SE.initialize
). - TDSE propagator case: no execution time profiling is available for TDSE propagators. Run an actual TDSE propagation (over a short time interval) to get an estimate.
The execution-time profiling is performed by running each listed operation a certain number of times and returns the average elapsed time to do so. The default number of iterations is defined internally based on the dimension of the model. Overwrite this default values and specify the number of iterations nbIter
with
QMol_SE_profiler(QM,'all',nbIter); % Both memory and time profiling
QMol_SE_profiler(QM,'time',nbIter); % Execution-time profiling only
Examples
Schrödinger-equation model
Create a Schrödinger-equation model with
% Domain
x = -200:.1:150;
% Molecular model
A1 = QMol_Va_softCoulomb('name','atom 1','charge',3,'position',-3);
A2 = QMol_Va_softCoulomb('name','atom 2','charge',3,'position',0);
A3 = QMol_Va_softCoulomb('name','atom 3','charge',3,'position',2);
% Schrodinger-equation model
V = QMol_SE_V('atom',{A1,A2,A2});
SE = QMol_SE( ...
'xspan', x, ...
'numberWavefunction', 4, ...
'potential', V);
Run a full (memory + execution-time) profiling
QMol_SE_profiler(SE);
yielding
=== Memory footprint =====================================================
Components -- Size --
* Domain discretization
> domain 27.4 KB
> gradient 54.7 KB
> Laplacian 27.4 KB
> Laplacian (velocity gauge) 54.7 KB
* Wave function(s) 218.8 KB
* Potential
> potential 27.4 KB
> potential gradient 27.4 KB
----------
TOTAL = 437.6 KB
=== Execution time =======================================================
Operator components -- Time --
* Hamiltonian 4 x 2.23e-04 = 8.92e-04 s
* Kinetic 4 x 2.06e-04 = 8.22e-04 s
* Potential 4 x 2.05e-05 = 8.20e-05 s
----------
TOTAL = 9.04e-04 s
(average times over 500 iterations)
##########################################################################
Test suite
Run the test suite for the class in normal or summary mode respectively with
QMol_test.test('SE_profiler');
QMol_test.test('-summary','SE_profiler');
For developers
QMol_SE_profiler
hard-codes the size of double-precision floats, which seem to be fixed to 8-bits per MATLAB documentation. If this comes to change, the values need be updated in the getMemoryFootprint
method.
Other class methods
The QMol_SE_profiler
class also defines the following static methods restricted to QMol-grid classes (Access=?QMol_suite
)
getMemoryFootprint
Get the memory footprint of an array with N elements with
m = QMol_SE_profiler.getMemoryFootprint(N,'real'); % Real-valued array
m = QMol_SE_profiler.getMemoryFootprint(N,'imag'); % Complex array
- The output m is in bytes
showMemoryFootprint
Print out the estimated memory footprint of a component with
QMol_SE_profiler.showMemoryFootprint(msg,mem,lvl)
msg
is a character array with the description of the component being displayed (see example above).mem
is the estimated memory footprint for the component, in bytes. The value will automatically be converted to KB, MB, GB, or TB as needed. Ifmem
is0
,NaN
, orInf
, no memory values is printed out (just the message, see example above).lvl = 1
orlvl = 2
, specifies the indentation level for the component (see example above). If no level is specified, defaultlvl = 1
is used.
Notes
The results displayed in this documentation page were generated using version 01.21 of the QMol-grid package.
QMol_SE_profiler
was introduced in version 01.20