Skip to content

Commit 9667e43

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

File tree

6 files changed

+404
-2
lines changed

6 files changed

+404
-2
lines changed

external/nmodl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit 58456d1018a177691ce4d63ac2ef436d1e535000
1+
Subproject commit 7000ff612208ed8b27837438731903c58d1786e3

src/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);

src/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];

test/coreneuron/unit/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)
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)