amnsbr / cubnm

A toolbox for biophysical network modeling on GPUs
https://cubnm.readthedocs.io
BSD 3-Clause "New" or "Revised" License
7 stars 3 forks source link

[ENH] Skip looping through non-existent connections #1

Open amnsbr opened 9 months ago

amnsbr commented 9 months ago

Currently in the integration loop tmpglobalinput to each node j is calculated by looping through all other nodes k and adding up SC[j,k] * S_E[k] even if SC[j,k] is zero. Skipping non-existent (zero) connections may increase efficiency, particularly in thresholded SCs.

amnsbr commented 2 months ago

As a quick fix I tried this within the global input calculation kernels: if (_SC[k] != 0) { // do calculations }. But it decreased performance for both rWW and Kuramoto.

Therefore the more proper way should be done, by converting the square SC matrix into a 2D array in which 0 connections are removed, and then we keep track of which nodes are connected to which. It is unclear if this will eventually be beneficial for performance since it'll require using additional registers etc. to do this on GPU.