Skip to content

Commit

Permalink
fixed pointer id overflow on MPI (e.g. for gap junctions)
Browse files Browse the repository at this point in the history
  • Loading branch information
vvbragin committed Mar 28, 2024
1 parent a7c06ec commit c8b654d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

- Better handling of exceptions in `importCellParams()` (incl. issue 782)

- Fixed pointer id overflow on MPI (e.g. for gap junctions)

# Version 1.0.6

**New features**
Expand Down
9 changes: 4 additions & 5 deletions netpyne/cell/compartCell.py
Original file line number Diff line number Diff line change
Expand Up @@ -1089,12 +1089,11 @@ def __parsePointerParams(self, params):

def __generatePointerIds(self, pointerParams, params):
from .. import sim

# see comments in `__parsePointerParams()` for more details
if hasattr(sim, 'rank'):
preToPostId = 1e9 * sim.rank + sim.net.lastPointerId # global index for presyn gap junc
else:
preToPostId = sim.net.lastPointerId

if sim.net.lastPointerId > sim.net.maxPointerIdPerNode:
print(f"WARNING: potential overflow of pointer connection id!")
preToPostId = sim.net.lastPointerId
sim.net.lastPointerId += 1 # keep track of num of gap juncs in this node

if pointerParams['bidirectional']:
Expand Down
8 changes: 7 additions & 1 deletion netpyne/network/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class Network(object):
# initialize variables
# -----------------------------------------------------------------------------
def __init__(self, params=None):
from .. import sim

self.params = params

# params that can be expressed using string-based functions in connections
Expand Down Expand Up @@ -62,7 +64,11 @@ def __init__(self, params=None):
{}
) # Empty dict for storing GID -> local index (key = gid; value = local id) -- ~x6 faster than .index()
self.lastGid = 0 # keep track of last cell gid
self.lastPointerId = 0 # keep track of last gap junction gid

# keep track of last gap junction gid
intMax = 2**(32-1) # pointer connection id in NEURON is signed 32-bit int
self.maxPointerIdPerNode = int(intMax / sim.nhosts)
self.lastPointerId = sim.rank * self.maxPointerIdPerNode # to avoid overlap of gids from different nodes

# -----------------------------------------------------------------------------
# Set network params
Expand Down

0 comments on commit c8b654d

Please sign in to comment.