Skip to content

Apply workaround in CI for NMODL change #143

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
12 changes: 11 additions & 1 deletion .github/workflows/simulation_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ on:
required: false

env:
NEURON_COMMIT_ID: 'c48d7d5'
NEURON_COMMIT_ID: '0e7570e50'
RDMAV_FORK_SAFE: '1'

jobs:
Expand Down Expand Up @@ -147,6 +147,16 @@ jobs:
else
git clone --branch=${{ env.NEURON_BRANCH }} https://github.com/neuronsimulator/nrn.git --depth=1
fi
if [[ -d ${PWD}/nrn/external/nmodl ]]; then
git -C ${PWD}/nrn submodule update --init --recursive --depth=1 external/nmodl
# apply temp workaround for https://github.com/openbraininstitute/neurodamus/issues/3
patch="${PWD}/ci/0001-Revert-Use-aligned_alloc-as-we-do-in-CoreNEURON-too-.patch"
if git -C ${PWD}/nrn/external/nmodl apply "${patch}" >& /dev/null; then
echo "Successfully applied patch ${patch}"
else
echo "Failed to apply patch ${patch}; CI will continue as-is"
fi
fi
python -m pip install --upgrade pip -r nrn/nrn_requirements.txt
cmake -B nrn/build -S nrn -G Ninja \
-DPYTHON_EXECUTABLE=$(which python) \
Expand Down
34 changes: 34 additions & 0 deletions ci/0001-Revert-Use-aligned_alloc-as-we-do-in-CoreNEURON-too-.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
From 66791fc353535abe0a45ff00e0049e740962fa18 Mon Sep 17 00:00:00 2001
From: Goran Jelic-Cizmek <[email protected]>
Date: Mon, 10 Mar 2025 13:37:09 +0100
Subject: [PATCH] Revert "Use aligned_alloc as we do in CoreNEURON too (#933)"

This reverts commit 3eab851dd4a31e6f8e082faf79d83d69b6482e2b.
---
src/codegen/codegen_coreneuron_cpp_visitor.cpp | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/codegen/codegen_coreneuron_cpp_visitor.cpp b/src/codegen/codegen_coreneuron_cpp_visitor.cpp
index c46ad2e..38e3f08 100644
--- a/src/codegen/codegen_coreneuron_cpp_visitor.cpp
+++ b/src/codegen/codegen_coreneuron_cpp_visitor.cpp
@@ -297,12 +297,11 @@ bool CodegenCoreneuronCppVisitor::optimize_ion_variable_copies() const {

void CodegenCoreneuronCppVisitor::print_memory_allocation_routine() const {
printer->add_newline(2);
- auto args = "size_t num, size_t size, size_t alignment = 64";
+ auto args = "size_t num, size_t size, size_t alignment = 16";
printer->fmt_push_block("static inline void* mem_alloc({})", args);
- printer->add_line(
- "size_t aligned_size = ((num*size + alignment - 1) / alignment) * alignment;");
- printer->add_line("void* ptr = aligned_alloc(alignment, aligned_size);");
- printer->add_line("memset(ptr, 0, aligned_size);");
+ printer->add_line("void* ptr;");
+ printer->add_line("posix_memalign(&ptr, alignment, num*size);");
+ printer->add_line("memset(ptr, 0, size);");
printer->add_line("return ptr;");
printer->pop_block();

--
2.39.3 (Apple Git-145)

10 changes: 4 additions & 6 deletions tests/scientific/test_lfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,11 @@ def test_v5_sonata_lfp(test_file, tmp_path):
nd.run()

# compare results with refs
# t3_data = np.array([0.00027065672, -0.00086610153, 0.0014563566, -0.0046603414])
# t7_data = np.array([0.00029265403, -0.0009364929, 0.001548515, -0.004955248])
t3_data = np.array([0.00027065672, -0.00086610153, 0.0014563566, -0.0046603414])
t7_data = np.array([0.00029265403, -0.0009364929, 0.001548515, -0.004955248])
node_ids = np.array([0, 4])
result_ids, result_data = _read_sonata_lfp_file(Path(output_dir) / "lfp.h5")

# TODO: reenable after: https://github.com/openbraininstitute/neurodamus/issues/3
# is solved
# npt.assert_allclose(result_data.data[3], t3_data)
# npt.assert_allclose(result_data.data[7], t7_data)
npt.assert_allclose(result_data.data[3], t3_data)
npt.assert_allclose(result_data.data[7], t7_data)
npt.assert_allclose(result_ids, node_ids)
Loading