Skip to content

Commit

Permalink
Merge branch '1uc/update-clang-format' of github.com:BlueBrain/nmodl …
Browse files Browse the repository at this point in the history
…into 1uc/update-clang-format
  • Loading branch information
1uc committed Nov 26, 2024
2 parents e3d98f0 + 977ab5f commit 78aa3eb
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nmodl-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
- release/**

env:
PYTHON_VERSION: 3.8
PYTHON_VERSION: 3.9
DESIRED_CMAKE_VERSION: 3.15.0

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nmodl-doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:

env:
BUILD_TYPE: Release
PYTHON_VERSION: 3.8
PYTHON_VERSION: 3.9
DESIRED_CMAKE_VERSION: 3.15.0

jobs:
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ endif()
# Find required python packages
# =============================================================================
message(STATUS "CHECKING FOR PYTHON")
find_package(Python 3.8 REQUIRED COMPONENTS Interpreter)
find_package(Python 3.9 REQUIRED COMPONENTS Interpreter)
cpp_cc_strip_python_shims(EXECUTABLE "${PYTHON_EXECUTABLE}" OUTPUT PYTHON_EXECUTABLE)

# =============================================================================
Expand Down
2 changes: 1 addition & 1 deletion INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ support is necessary. Make sure you have following packages available:
- flex (>=2.6)
- bison (>=3.0)
- CMake (>=3.15)
- Python (>=3.8)
- Python (>=3.9)
- Python packages : jinja2 (>=2.10), pyyaml (>=3.13), pytest (>=4.0.0),
sympy (>=1.3), textwrap

Expand Down
16 changes: 7 additions & 9 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ stages:
sudo apt-add-repository -y ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install -y g++-9 flex bison libfl-dev cython libx11-dev libxcomposite-dev libncurses-dev mpich
sudo apt-get install -y python3.8 python3.8-dev python3.8-venv ninja-build
sudo apt-get install -y python3.9 python3.9-dev python3.9-venv ninja-build
sudo apt-get remove -y python3-importlib-metadata
python3.8 -m pip install --upgrade pip setuptools
python3.8 -m pip install --user -r requirements.txt
python3.9 -m pip install --upgrade pip setuptools
python3.9 -m pip install --user -r requirements.txt
# we manually get version 3.15.0 to make sure that changes in the cmake
# files do not require unsupported versions of cmake in our package.
wget --quiet --output-document=- "https://github.com/Kitware/CMake/releases/download/$CMAKE_VER/$CMAKE_PKG.tar.gz" | tar xzpf -
Expand All @@ -101,7 +101,7 @@ stages:
mkdir -p $(Build.Repository.LocalPath)/build
cd $(Build.Repository.LocalPath)/build
cmake --version
cmake .. -DPYTHON_EXECUTABLE=$(which python3.8) -DCMAKE_INSTALL_PREFIX=$HOME/nmodl -DCMAKE_BUILD_TYPE=Release
cmake .. -DPYTHON_EXECUTABLE=$(which python3.9) -DCMAKE_INSTALL_PREFIX=$HOME/nmodl -DCMAKE_BUILD_TYPE=Release
make -j 2
if [ $? -ne 0 ]
then
Expand All @@ -121,7 +121,7 @@ stages:
mkdir nrn/build
cd nrn/build
cmake --version
cmake .. -DNRN_ENABLE_CORENEURON=ON -DNRN_ENABLE_INTERVIEWS=OFF -DNRN_ENABLE_RX3D=OFF -DNRN_ENABLE_MPI=ON -DNRN_ENABLE_TESTS=ON -DCORENRN_ENABLE_NMODL=ON -DCORENRN_NMODL_DIR=$HOME/nmodl -DPYTHON_EXECUTABLE=$(which python3.8) -DCORENRN_NMODL_FLAGS="sympy --analytic"
cmake .. -DNRN_ENABLE_CORENEURON=ON -DNRN_ENABLE_INTERVIEWS=OFF -DNRN_ENABLE_RX3D=OFF -DNRN_ENABLE_MPI=ON -DNRN_ENABLE_TESTS=ON -DCORENRN_ENABLE_NMODL=ON -DCORENRN_NMODL_DIR=$HOME/nmodl -DPYTHON_EXECUTABLE=$(which python3.9) -DCORENRN_NMODL_FLAGS="sympy --analytic"
make -j 2
if [ $? -ne 0 ]
then
Expand Down Expand Up @@ -215,7 +215,7 @@ stages:
displayName: "Set wheel tag"
- script: |
echo "##vso[task.setvariable variable=CIBW_BUILD;]cp38* cp312*"
echo "##vso[task.setvariable variable=CIBW_BUILD;]cp39* cp312*"
echo "Build identifiers: $CIBW_BUILD"
condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))
displayName: "Set build identifiers"
Expand Down Expand Up @@ -260,7 +260,7 @@ stages:
displayName: "Set wheel tag"
- script: |
echo "##vso[task.setvariable variable=CIBW_BUILD;]cp38* cp312*"
echo "##vso[task.setvariable variable=CIBW_BUILD;]cp39* cp312*"
echo "Build identifiers: $CIBW_BUILD"
condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))
displayName: "Set build identifiers"
Expand Down Expand Up @@ -291,8 +291,6 @@ stages:
strategy:
matrix:
${{ if eq(variables.buildWheel, True) }}:
Python38:
python.version: '3.8'
Python39:
python.version: '3.9'
Python310:
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies = [
"importlib-resources;python_version<'3.9'",
]
scripts = {nmodl = "nmodl._binwrapper:main"}
requires-python = ">=3.8"
requires-python = ">=3.9"

optional-dependencies.test = ["pytest>=3.3.0", "pytest-cov", "numpy", "scipy"]
optional-dependencies.docs = [
Expand Down Expand Up @@ -76,4 +76,4 @@ environment = { PATH = "/nmodlwheel/flex/bin:/nmodlwheel/bison/bin:$PATH" }
test-command = "true"

[tool.cibuildwheel.windows]
environment = { SKBUILD_CMAKE_ARGS = "-DNMODL_BUILD_WHEEL=ON;-DFLEX_INCLUDE_PATH=C:/ProgramData/chocolatey/lib/winflexbison3/tools" }
environment = { SKBUILD_CMAKE_ARGS = "-DNMODL_BUILD_WHEEL=ON;-DFLEX_INCLUDE_PATH=C:/ProgramData/chocolatey/lib/winflexbison3/tools" }
2 changes: 1 addition & 1 deletion src/codegen/codegen_helper_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ void CodegenHelperVisitor::find_non_range_variables() {

// if model is thread safe and if parameter is being written then
// those variables should be promoted to thread safe variable
if (info.vectorize && info.thread_safe && var->get_write_count() > 0) {
if (info.vectorize && info.declared_thread_safe && var->get_write_count() > 0) {
var->mark_thread_safe();
info.thread_variables.push_back(var);
info.thread_var_data_size += var->get_length();
Expand Down
9 changes: 9 additions & 0 deletions src/codegen/codegen_neuron_cpp_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,7 @@ void CodegenNeuronCppVisitor::print_neuron_includes() {
printer->add_multi_line(R"CODE(
#include "mech_api.h"
#include "neuron/cache/mechanism_range.hpp"
#include "nmodlmutex.h"
#include "nrniv_mf.h"
#include "section_fwd.hpp"
)CODE");
Expand Down Expand Up @@ -3063,6 +3064,14 @@ void CodegenNeuronCppVisitor::visit_for_netcon(const ast::ForNetcon& node) {
printer->pop_block();
}

void CodegenNeuronCppVisitor::visit_protect_statement(const ast::ProtectStatement& node) {
printer->add_line("_NMODLMUTEXLOCK");
printer->add_indent();
node.get_expression()->accept(*this);
printer->add_text(";");
printer->add_line("_NMODLMUTEXUNLOCK");
}


} // namespace codegen
} // namespace nmodl
1 change: 1 addition & 0 deletions src/codegen/codegen_neuron_cpp_visitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,7 @@ class CodegenNeuronCppVisitor: public CodegenCppVisitor {
void visit_for_netcon(const ast::ForNetcon& node) override;
void visit_longitudinal_diffusion_block(const ast::LongitudinalDiffusionBlock& node) override;
void visit_lon_diffuse(const ast::LonDiffuse& node) override;
void visit_protect_statement(const ast::ProtectStatement& node) override;

public:
/****************************************************************************************/
Expand Down
1 change: 1 addition & 0 deletions test/usecases/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ set(NMODL_USECASE_DIRS
point_process
pointer
procedure
protect
random
solve
state
Expand Down
17 changes: 17 additions & 0 deletions test/usecases/protect/shared_counter.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
NEURON {
SUFFIX shared_counter
GLOBAL g_cnt
}

ASSIGNED {
g_cnt
}


INITIAL {
PROTECT g_cnt = 0
}

BREAKPOINT {
PROTECT g_cnt = g_cnt + 1
}
30 changes: 30 additions & 0 deletions test/usecases/protect/test_shared_counter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from neuron import h, gui


def test_shared_counter():
nthreads = 32
nseg = 10
nsteps = 100

sections = [h.Section() for _ in range(nthreads)]
for s in sections:
s.insert("shared_counter")
s.nseg = nseg

pc = h.ParallelContext()

pc.nthread(nthreads)
for k, s in enumerate(sections):
pc.partition(k, h.SectionList([s]))

h.finitialize()
for _ in range(nsteps):
h.step()

expected = nthreads * nseg * nsteps
g_cnt = h.g_cnt_shared_counter
assert h.g_cnt_shared_counter == expected, f"{g_cnt}"


if __name__ == "__main__":
test_shared_counter()

0 comments on commit 78aa3eb

Please sign in to comment.