Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit 9523270

Browse files
authored
Add unit tests for the Hines solver (#841)
* As well as improving test coverage, these aim to demonstrate problems with nvc++ 22.5 at -O0 (#826). * OpenMP target offload support for the `cell_permute=0` solver implementation. * Unrelated: update NMODL submodule, which now requires Python 3.7+
1 parent d6ba964 commit 9523270

File tree

8 files changed

+408
-4
lines changed

8 files changed

+408
-4
lines changed

.github/workflows/coreneuron-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ jobs:
3636
- {cmake_option: "-DCORENRN_ENABLE_MPI_DYNAMIC=ON", flag_warnings: ON}
3737
- {cmake_option: "-DCORENRN_ENABLE_MPI_DYNAMIC=ON -DCORENRN_ENABLE_SHARED=OFF"}
3838
- {cmake_option: "-DCORENRN_ENABLE_MPI=OFF"}
39-
- {use_nmodl: ON, py_version: 3.6.7}
39+
- {use_nmodl: ON, py_version: 3.7}
4040
- {use_nmodl: ON}
41-
- {use_ispc: ON, py_version: 3.6.7}
41+
- {use_ispc: ON, py_version: 3.7}
4242
include:
4343
- os: ubuntu-20.04
4444
config:

.sanitizers/undefined.supp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
unsigned-integer-overflow:_philox4x32bumpkey(r123array2x32)
2+
unsigned-integer-overflow:coreneuron::TNode::mkhash()
3+
unsigned-integer-overflow:std::mersenne_twister_engine

coreneuron/mechanism/eion.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ void nrn_wrote_conc(int type,
200200
pe[0] = nrn_nernst(pe[1 * _STRIDE], pe[2 * _STRIDE], gimap[type][2], celsius);
201201
}
202202
}
203-
nrn_pragma_omp(end declare target)
204203

205204
static double efun(double x) {
206205
if (fabs(x) < 1e-4) {
@@ -210,6 +209,8 @@ static double efun(double x) {
210209
}
211210
}
212211

212+
nrn_pragma_omp(end declare target)
213+
213214
double nrn_ghk(double v, double ci, double co, double z) {
214215
double temp = z * v / ktf;
215216
double eco = co * efun(temp);

coreneuron/sim/solve_core.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ static void triang(NrnThread* _nt) {
4242
nrn_pragma_acc(parallel loop seq present(
4343
vec_a [0:i3], vec_b [0:i3], vec_d [0:i3], vec_rhs [0:i3], parent_index [0:i3])
4444
async(_nt->stream_id) if (_nt->compute_gpu))
45+
nrn_pragma_omp(target if (_nt->compute_gpu))
4546
for (int i = i3 - 1; i >= i2; --i) {
4647
double p = vec_a[i] / vec_d[i];
4748
vec_d[parent_index[i]] -= p * vec_b[i];
@@ -62,13 +63,15 @@ static void bksub(NrnThread* _nt) {
6263

6364
nrn_pragma_acc(parallel loop seq present(vec_d [0:i2], vec_rhs [0:i2])
6465
async(_nt->stream_id) if (_nt->compute_gpu))
66+
nrn_pragma_omp(target if (_nt->compute_gpu))
6567
for (int i = i1; i < i2; ++i) {
6668
vec_rhs[i] /= vec_d[i];
6769
}
6870

6971
nrn_pragma_acc(
7072
parallel loop seq present(vec_b [0:i3], vec_d [0:i3], vec_rhs [0:i3], parent_index [0:i3])
7173
async(_nt->stream_id) if (_nt->compute_gpu))
74+
nrn_pragma_omp(target if (_nt->compute_gpu))
7275
for (int i = i2; i < i3; ++i) {
7376
vec_rhs[i] -= vec_b[i] * vec_rhs[parent_index[i]];
7477
vec_rhs[i] /= vec_d[i];

tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ if(Boost_FOUND)
3131
add_subdirectory(unit/interleave_info)
3232
add_subdirectory(unit/alignment)
3333
add_subdirectory(unit/queueing)
34+
add_subdirectory(unit/solver)
3435
# lfp test uses nrnmpi_* wrappers but does not load the dynamic MPI library TODO: re-enable
3536
# after NEURON and CoreNEURON dynamic MPI are merged
3637
if(NOT CORENRN_ENABLE_MPI_DYNAMIC)

tests/unit/solver/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# =============================================================================
2+
# Copyright (C) 2022 Blue Brain Project
3+
#
4+
# See top-level LICENSE file for details.
5+
# =============================================================================
6+
7+
include_directories(${CMAKE_SOURCE_DIR}/coreneuron ${Boost_INCLUDE_DIRS})
8+
add_executable(test-solver test_solver.cpp)
9+
target_link_libraries(test-solver ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} coreneuron
10+
${corenrn_mech_library})
11+
target_include_directories(test-solver SYSTEM
12+
PRIVATE ${CORENEURON_PROJECT_SOURCE_DIR}/external/CLI11/include)
13+
14+
# Tell CMake *not* to run an explicit device code linker step (which will produce errors); let the
15+
# NVHPC C++ compiler handle this implicitly.
16+
set_target_properties(test-solver PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS OFF)
17+
target_compile_options(test-solver PRIVATE ${CORENEURON_BOOST_UNIT_TEST_COMPILE_FLAGS})
18+
add_dependencies(test-solver nrniv-core)
19+
add_test(NAME test-solver COMMAND $<TARGET_FILE:test-solver>)
20+
cpp_cc_configure_sanitizers(TARGET test-solver TEST test-solver)

0 commit comments

Comments
 (0)