Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename 'shared_global'. #1528

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions test/usecases/global/simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
nseg = 1

s0 = h.Section()
s0.insert("shared_global")
s0.insert("threading_effects")
s0.nseg = nseg

s1 = h.Section()
s1.insert("shared_global")
s1.insert("threading_effects")
s1.nseg = nseg

pc = h.ParallelContext()
Expand All @@ -29,34 +29,34 @@
pc.partition(1, h.SectionList([s1]))

t = h.Vector().record(h._ref_t)
y0 = h.Vector().record(s0(0.5).shared_global._ref_y)
y1 = h.Vector().record(s1(0.5).shared_global._ref_y)
y0 = h.Vector().record(s0(0.5).threading_effects._ref_y)
y1 = h.Vector().record(s1(0.5).threading_effects._ref_y)

# Bunch of arbitrary values:
z0, z1 = 3.0, 4.0
g_w0, g_w1 = 7.0, 2.0
g_w_init = 48.0

# Ensure that the two threads will set different value to `g_w`.
s0(0.5).shared_global.z = z0
s1(0.5).shared_global.z = z1
s0(0.5).threading_effects.z = z0
s1(0.5).threading_effects.z = z1

h.g_w_shared_global = g_w0
assert h.g_w_shared_global == g_w0
h.g_w_threading_effects = g_w0
assert h.g_w_threading_effects == g_w0
h.stdinit()
assert h.g_w_shared_global == g_w_init
h.g_w_shared_global = g_w1
assert h.g_w_shared_global == g_w1
assert h.g_w_threading_effects == g_w_init
h.g_w_threading_effects = g_w1
assert h.g_w_threading_effects == g_w1
h.continuerun(1.0 * ms)

# Arguably the value is unspecified, but currently it's the value of
# on thread 0.
assert h.g_w_shared_global == z0
assert h.g_w_threading_effects == z0

t = np.array(t.as_numpy())
y0 = np.array(y0.as_numpy())
y1 = np.array(y1.as_numpy())
w = h.g_w_shared_global
w = h.g_w_threading_effects

# The solution is piecewise constant. These are the pieces:
i0 = [0]
Expand Down
10 changes: 5 additions & 5 deletions test/usecases/global/test_callables.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@

def test_function():
s = h.Section()
s.insert("shared_global")
s.insert("threading_effects")

h.finitialize()

assert s(0.5).shared_global.sum_arr() == 30.3
assert s(0.5).threading_effects.sum_arr() == 30.3


def test_procedure():
s = h.Section()
s.insert("shared_global")
s.insert("threading_effects")

h.finitialize()

s(0.5).shared_global.set_g_w(44.4)
assert h.g_w_shared_global == 44.4
s(0.5).threading_effects.set_g_w(44.4)
assert h.g_w_threading_effects == 44.4


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NEURON {
SUFFIX shared_global
SUFFIX threading_effects
NONSPECIFIC_CURRENT il
RANGE y, z
GLOBAL g_v1, g_w, g_arr
Expand Down
Loading