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

Add unit tests for the Hines solver. #841

Merged
merged 10 commits into from
Jul 12, 2022
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
4 changes: 2 additions & 2 deletions .github/workflows/coreneuron-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ jobs:
- {cmake_option: "-DCORENRN_ENABLE_MPI_DYNAMIC=ON", flag_warnings: ON}
- {cmake_option: "-DCORENRN_ENABLE_MPI_DYNAMIC=ON -DCORENRN_ENABLE_SHARED=OFF"}
- {cmake_option: "-DCORENRN_ENABLE_MPI=OFF"}
- {use_nmodl: ON, py_version: 3.6.7}
- {use_nmodl: ON, py_version: 3.7}
- {use_nmodl: ON}
- {use_ispc: ON, py_version: 3.6.7}
- {use_ispc: ON, py_version: 3.7}
include:
- os: ubuntu-20.04
config:
Expand Down
2 changes: 2 additions & 0 deletions .sanitizers/undefined.supp
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
unsigned-integer-overflow:_philox4x32bumpkey(r123array2x32)
unsigned-integer-overflow:coreneuron::TNode::mkhash()
unsigned-integer-overflow:std::mersenne_twister_engine
3 changes: 2 additions & 1 deletion coreneuron/mechanism/eion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ void nrn_wrote_conc(int type,
pe[0] = nrn_nernst(pe[1 * _STRIDE], pe[2 * _STRIDE], gimap[type][2], celsius);
}
}
nrn_pragma_omp(end declare target)

static double efun(double x) {
if (fabs(x) < 1e-4) {
Expand All @@ -210,6 +209,8 @@ static double efun(double x) {
}
}

nrn_pragma_omp(end declare target)

double nrn_ghk(double v, double ci, double co, double z) {
double temp = z * v / ktf;
double eco = co * efun(temp);
Expand Down
3 changes: 3 additions & 0 deletions coreneuron/sim/solve_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ static void triang(NrnThread* _nt) {
nrn_pragma_acc(parallel loop seq present(
vec_a [0:i3], vec_b [0:i3], vec_d [0:i3], vec_rhs [0:i3], parent_index [0:i3])
async(_nt->stream_id) if (_nt->compute_gpu))
nrn_pragma_omp(target if (_nt->compute_gpu))
for (int i = i3 - 1; i >= i2; --i) {
double p = vec_a[i] / vec_d[i];
vec_d[parent_index[i]] -= p * vec_b[i];
Expand All @@ -62,13 +63,15 @@ static void bksub(NrnThread* _nt) {

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

nrn_pragma_acc(
parallel loop seq present(vec_b [0:i3], vec_d [0:i3], vec_rhs [0:i3], parent_index [0:i3])
async(_nt->stream_id) if (_nt->compute_gpu))
nrn_pragma_omp(target if (_nt->compute_gpu))
for (int i = i2; i < i3; ++i) {
vec_rhs[i] -= vec_b[i] * vec_rhs[parent_index[i]];
vec_rhs[i] /= vec_d[i];
Expand Down
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ if(Boost_FOUND)
add_subdirectory(unit/interleave_info)
add_subdirectory(unit/alignment)
add_subdirectory(unit/queueing)
add_subdirectory(unit/solver)
# lfp test uses nrnmpi_* wrappers but does not load the dynamic MPI library TODO: re-enable
# after NEURON and CoreNEURON dynamic MPI are merged
if(NOT CORENRN_ENABLE_MPI_DYNAMIC)
Expand Down
20 changes: 20 additions & 0 deletions tests/unit/solver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# =============================================================================
# Copyright (C) 2022 Blue Brain Project
#
# See top-level LICENSE file for details.
# =============================================================================

include_directories(${CMAKE_SOURCE_DIR}/coreneuron ${Boost_INCLUDE_DIRS})
add_executable(test-solver test_solver.cpp)
target_link_libraries(test-solver ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} coreneuron
${corenrn_mech_library})
target_include_directories(test-solver SYSTEM
PRIVATE ${CORENEURON_PROJECT_SOURCE_DIR}/external/CLI11/include)

# Tell CMake *not* to run an explicit device code linker step (which will produce errors); let the
# NVHPC C++ compiler handle this implicitly.
set_target_properties(test-solver PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS OFF)
target_compile_options(test-solver PRIVATE ${CORENEURON_BOOST_UNIT_TEST_COMPILE_FLAGS})
add_dependencies(test-solver nrniv-core)
add_test(NAME test-solver COMMAND $<TARGET_FILE:test-solver>)
cpp_cc_configure_sanitizers(TARGET test-solver TEST test-solver)
Loading