BlueBrain / functionalizer

Create a functional connectome from physical connections between cells
https://functionalizer.readthedocs.io/en/stable/
Apache License 2.0
1 stars 0 forks source link

Ordering edge IDs by a space-filling curve #12

Open matz-e opened 1 week ago

matz-e commented 1 week ago

From JIRA, by @1uc:

Currently, edge IDs are sorted by the tuple (target_gid, source_gid). Which means that a consecutive range of target GIDs has a consecutive range of edge IDs.

edge_ids = population.efferent_edges(gids)
# Perfect access pattern:
population.get_attribute("foo", edge_ids)

However, consecutive source GIDs have edge IDs scattered across the entire available range in small blocks.

edge_ids = population.afferent_edges(gids)
# Very bad access pattern:
population.get_attribute("foo", edge_ids) 

This can be improves by sorting all edges as follows:

sorted(edges, key=lambda edge: space_filling_curve(edge.target_gid, edge.source_gid))

Response by @mgeplf:

This is an interesting trade off to consider; since neurodamus generally reads by target_gid, I think it works well for the 'expensive' case. IIRC, in the original paper, some effort was done to see if different layouts were tried, but I don't think a space filling curve was used: https://journals.plos.org/ploscompbiol/article/file?id=10.1371/journal.pcbi.1007696&type=printable (see pg 19)