Skip to content
Snippets Groups Projects
Unverified Commit 27ff4163 authored by Nora Abi Akar's avatar Nora Abi Akar Committed by GitHub
Browse files

optimize model-init runtime (#985)

`model-init` run-times have been observed to be too high when running systems with many synapses.
 
The main culprit is the `sort_by` function (fvm_layout:723). When testing on a model with 1024 cells and 10000 synapses, 65% of model-init is spent in this function. 

Comparing two `std::map<std::string, double>` is really expensive. We can replace the string map `synapse_instance.param_value` with a sorted `std::vector<std::pair<unsigned, double>>`, and have an additional `std::map<std::string, unsigned> param_map`  to keep track of all the param_name -> unsigned mappings.

`model-init` run-time is 2.5x faster (tested on my 4 core  i7-7600U laptop):
```
10000 synapses/cell 
--------------------------------------------------------------------
|  num cells       | model-init before  (s) | model-init after (s) |
--------------------------------------------------------------------
|       1024       |          12            |       5              |
|       2048       |          25.5          |       10.8           |
|       4096       |          55.5          |       23.2           |
|       8192       |          121.8         |       49             |
--------------------------------------------------------------------
```
parent 6008f78b
No related branches found
No related tags found
No related merge requests found
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment