Skip to content

Commit

Permalink
Use raw gids only in the complexity file
Browse files Browse the repository at this point in the history
  • Loading branch information
jorblancoa committed Apr 4, 2024
1 parent 975bb11 commit 710c831
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
28 changes: 16 additions & 12 deletions neurodamus/cell_distributor.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ def get_cellref(self, gid):
Returns: Cell object
"""
if self._binfo:
# are we in load balance mode? must replace gid with spgid
gid = self._binfo.thishost_gid(gid - self._local_nodes.offset)
# are we in load balance mode? raw gids are in the binfo
gid_offset = self._local_nodes.offset
gid = self._binfo.thishost_gid(gid - gid_offset) + gid_offset
return self._pc.gid2obj(gid)

# Methods for compat with hoc
Expand Down Expand Up @@ -355,22 +356,24 @@ def _init_cell_network(self):
self._init_rng()
pc = self._pc

for gid, cell in self._gid2cell.items():
for final_gid, cell in self._gid2cell.items():
cell.re_init_rng(self._ionchannel_seed)
nc = cell.connect2target(None) # Netcon doesnt require being stored
raw_gid = gid - self._local_nodes.offset
raw_gid = final_gid - self._local_nodes.offset
if self._binfo:
gid_i = int(self._binfo.gids.indwhere("==", raw_gid))
cb = self._binfo.bilist.object(self._binfo.cbindex.x[gid_i])
# multisplit cells call cb.multisplit() instead
if cb.subtrees.count() > 0:
cb.multisplit(nc, self._binfo.msgid, pc, pc.id())
cell.gid = raw_gid
cell.gid = final_gid
cell.raw_gid = raw_gid
continue

pc.set_gid2node(raw_gid, pc.id())
pc.cell(raw_gid, nc)
cell.gid = raw_gid # update the cell.gid last (RNGs had to use the base gid)
pc.set_gid2node(final_gid, pc.id())
pc.cell(final_gid, nc)
cell.gid = final_gid # update the cell.gid last (RNGs had to use the base gid)
cell.raw_gid = raw_gid

pc.multisplit()

Expand Down Expand Up @@ -487,8 +490,9 @@ def get_cellref(self, gid):
"""
manager = self._find_manager(gid)
if manager._binfo:
# are we in load balance mode? must replace gid with spgid
gid = manager._binfo.thishost_gid(gid - manager.local_nodes.offset)
# are we in load balance mode? raw gids are in the binfo
gid_offset = manager.local_nodes.offset
gid = manager._binfo.thishost_gid(gid - gid_offset) + gid_offset
return self._pc.gid2obj(gid)

def getSpGid(self, gid):
Expand Down Expand Up @@ -768,7 +772,7 @@ def _compute_save_complexities(self, target_str, mcomplex, cell_distributor):

for cell in cell_distributor.cells:
mcomplex.cell_complexity(cell.CellRef)
mcomplex.multisplit(cell.gid, lcx, tmp)
mcomplex.multisplit(cell.raw_gid, lcx, tmp)
ms_list.append(tmp.c())

# To output build independently the contents of the file then append
Expand Down Expand Up @@ -801,7 +805,7 @@ def _cell_complexity_total_max(cx_cells):
def _compute_complexities(cls, mcomplex, cell_distributor):
cx_cell = compat.Vector("f")
pc = cell_distributor.pc
for gid in cell_distributor.local_nodes.raw_gids():
for gid in cell_distributor.local_nodes.final_gids():
cx_cell.append(mcomplex.cell_complexity(pc.gid2cell(gid)))
return cx_cell

Expand Down
3 changes: 2 additions & 1 deletion neurodamus/metype.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class METype(BaseCell):
__slots__ = ('_threshold_current', '_hypAmp_current', '_netcons',
'_synapses', '_syn_helper_list', '_emodel_name',
'exc_mini_frequency', 'inh_mini_frequency',
'extra_attrs')
'extra_attrs', 'raw_gid')

def __init__(self, gid, etype_path, emodel, morpho_path, meinfos=None, detailed_axon=False):
"""Instantite a new Cell from METype
Expand All @@ -70,6 +70,7 @@ def __init__(self, gid, etype_path, emodel, morpho_path, meinfos=None, detailed_
self.exc_mini_frequency = None
self.inh_mini_frequency = None
self.extra_attrs = None
self.raw_gid = None

self._instantiate_cell(gid, etype_path, emodel, morpho_path, meinfos, detailed_axon)

Expand Down

0 comments on commit 710c831

Please sign in to comment.