ORNL-CEES / thermochimica

Computational library for chemical thermodynamics and phase equilibrium calculation. Multiphysics and standalone estimations of chemical state and constitutive and transport properties.
BSD 3-Clause "New" or "Revised" License
43 stars 25 forks source link

Reduce dynamic memory allocations #139

Open parikshitbajpai opened 1 year ago

parikshitbajpai commented 1 year ago

Reason. Dynamic memory allocation such as in PolyRegularQKTO takes a significant amount of time such as in the example below.

Proposed Solution Reserve enough memory at start of program? A proper solution will obviously need more thought and a redesign of the code (or just use Yellowjacket-GEM 😅)

Impact Faster multiphysics

Additional context

image
dschwen commented 1 year ago

Any fortran array with a size that is dependent on a runtime variable will lead to a malloc/free pair. The profile shows that > 30% of the Thermochimica time is spent in either malloc or free. At first glance it looks like those could largely be avoided by reusing buffer space (sized for the maximim number of species in a given phase for example).

parikshitbajpai commented 1 year ago

@markuspiro any suggestions?