Details
-
Type:
Improvement
-
Status: Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Epic Link:
Description
Quite optimizations could be made if we had better control over memory use in the simulation: (1) preallocate all memory and reuse (2) float32 is sufficient for all but large summation operations and (3) use a SIMD friendly stride 1 dimension (e.g. state shape becomes (..., nnode/4, nsvar, nmode, 4)).
Components could request buffers during configure step and then compute with only those buffers issued. Numpy has some facility to track allocations (https://github.com/numpy/numpy/blob/master/tools/allocation_tracking/track_allocations.py) which may be useful. Computations done with numba functions compiled with the nopython mode would also guarantee (iiuc) that no allocations are performed.
This is also a large step towards using native/compiled code in TVB. Such code would be far easier to write if all data structures are already allocated.
A principle choice and challenge is if we keep API (including array shapes) the same, and if so, there's quite some work to make sure it's done correctly. If not, user code needs to change.