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

Commit 5126c53

Browse files
committed
Merge remote-tracking branch 'origin/olupton/reenable-ci' into magkanar/hackathon_openmp_async
2 parents a0197ad + 9f8da7c commit 5126c53

25 files changed

Lines changed: 456 additions & 223 deletions
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: clang-cmake-format-check
2+
3+
concurrency:
4+
group: ${{ github.workflow }}#${{ github.ref }}
5+
cancel-in-progress: true
6+
7+
on:
8+
push:
9+
10+
jobs:
11+
build:
12+
name: clang-cmake-format-check
13+
runs-on: ubuntu-20.04
14+
steps:
15+
- name: Fetch repository
16+
uses: actions/checkout@v2
17+
- name: Install clang-format 11
18+
run: |
19+
sudo apt-get update
20+
sudo apt-get install clang-format-11 python3-pip libboost-all-dev libopenmpi-dev openmpi-bin
21+
- name: Install cmake-format 0.6.13
22+
run: python3 -m pip install cmake-format==0.6.13
23+
- name: Configure
24+
shell: bash
25+
working-directory: ${{runner.workspace}}/CoreNeuron
26+
run: |
27+
export PATH=/home/runner/.local/bin:$PATH
28+
mkdir BUILD && cd BUILD
29+
cmake -DCORENRN_CLANG_FORMAT=ON -DCORENRN_CMAKE_FORMAT=ON -DCORENRN_ENABLE_MPI=ON -DCORENRN_ENABLE_OPENMP=OFF -DClangFormat_EXECUTABLE=$(which clang-format-11) -DCMakeFormat_EXECUTABLE=$(which cmake-format) ..
30+
- name: Run clang-format
31+
shell: bash
32+
working-directory: ${{runner.workspace}}/CoreNeuron/BUILD
33+
run: make check-clang-format VERBOSE=1
34+
- name: Run cmake-format
35+
shell: bash
36+
working-directory: ${{runner.workspace}}/CoreNeuron/BUILD
37+
run: make check-cmake-format

.gitlab-ci.yml

Lines changed: 130 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,31 @@ spack_setup:
3535
- git diff
3636
- fi
3737

38+
.spack_intel:
39+
variables:
40+
SPACK_PACKAGE_COMPILER: intel
3841
.spack_nvhpc:
3942
variables:
4043
SPACK_PACKAGE_COMPILER: nvhpc
4144
.spack_neuron:
4245
variables:
4346
SPACK_PACKAGE: neuron
4447
SPACK_PACKAGE_REF: ''
45-
SPACK_PACKAGE_SPEC: +coreneuron+debug+tests~legacy-unit
48+
SPACK_PACKAGE_SPEC: +coreneuron+debug+tests~legacy-unit model_tests=channel-benchmark,olfactory
4649
.gpu_node:
4750
variables:
4851
bb5_constraint: volta
4952

53+
build:nmodl:intel:
54+
stage: build_nmodl
55+
variables:
56+
SPACK_PACKAGE: nmodl
57+
SPACK_PACKAGE_REF: ''
58+
SPACK_PACKAGE_SPEC: ~legacy-unit
59+
extends:
60+
- .spack_build
61+
- .spack_intel
62+
5063
build:nmodl:gpu:
5164
stage: build_nmodl
5265
variables:
@@ -58,21 +71,92 @@ build:nmodl:gpu:
5871
- .spack_build
5972
- .spack_nvhpc
6073

74+
build:coreneuron+nmodl:intel:
75+
variables:
76+
SPACK_PACKAGE: coreneuron
77+
SPACK_PACKAGE_SPEC: +nmodl+tests~legacy-unit build_type=Debug
78+
extends:
79+
- .spack_build
80+
- .spack_intel
81+
needs: ["build:nmodl:intel"]
82+
83+
build:coreneuron:intel:
84+
variables:
85+
SPACK_PACKAGE: coreneuron
86+
SPACK_PACKAGE_SPEC: +tests~legacy-unit build_type=Debug
87+
extends:
88+
- .spack_build
89+
- .spack_intel
90+
6191
build:coreneuron+nmodl:gpu:
6292
variables:
6393
SPACK_PACKAGE: coreneuron
6494
# +report pulls in a lot of dependencies and the tests fail.
6595
# See https://github.com/BlueBrain/CoreNeuron/issues/518 re: build_type
66-
SPACK_PACKAGE_SPEC: +nmodl+openmp+gpu+tests~legacy-unit~report build_type=RelWithDebInfo
96+
SPACK_PACKAGE_SPEC: +nmodl+openmp+gpu+tests~legacy-unit~report~sympy build_type=RelWithDebInfo
6797
extends:
6898
- .spack_build
6999
- .spack_nvhpc
70100
needs: ["build:nmodl:gpu"]
71101

102+
build:coreneuron+nmodl~openmp:gpu:
103+
variables:
104+
SPACK_PACKAGE: coreneuron
105+
# +report pulls in a lot of dependencies and the tests fail.
106+
# See https://github.com/BlueBrain/CoreNeuron/issues/518 re: build_type
107+
# Sympy + OpenMP target offload does not currently work with NVHPC
108+
SPACK_PACKAGE_SPEC: +nmodl~openmp+gpu+tests~legacy-unit~report+sympy build_type=RelWithDebInfo
109+
extends:
110+
- .spack_build
111+
- .spack_nvhpc
112+
needs: ["build:nmodl:gpu"]
113+
114+
build:coreneuron:gpu:
115+
variables:
116+
SPACK_PACKAGE: coreneuron
117+
# +report pulls in a lot of dependencies and the tests fail.
118+
# See https://github.com/BlueBrain/CoreNeuron/issues/518 re: build_type
119+
SPACK_PACKAGE_SPEC: +gpu+openmp+tests~legacy-unit~report build_type=RelWithDebInfo
120+
extends:
121+
- .spack_build
122+
- .spack_nvhpc
123+
124+
test:coreneuron+nmodl:intel:
125+
extends: [.ctest]
126+
needs: ["build:coreneuron+nmodl:intel"]
127+
128+
test:coreneuron:intel:
129+
extends: [.ctest]
130+
needs: ["build:coreneuron:intel"]
131+
72132
test:coreneuron+nmodl:gpu:
73133
extends: [.ctest, .gpu_node]
74134
needs: ["build:coreneuron+nmodl:gpu"]
75135

136+
test:coreneuron+nmodl~openmp:gpu:
137+
extends: [.ctest, .gpu_node]
138+
needs: ["build:coreneuron+nmodl~openmp:gpu"]
139+
140+
test:coreneuron:gpu:
141+
extends: [.ctest, .gpu_node]
142+
needs: ["build:coreneuron:gpu"]
143+
144+
build:neuron+nmodl:intel:
145+
stage: build_neuron
146+
extends:
147+
- .spack_build
148+
- .spack_neuron
149+
- .spack_intel
150+
needs: ["build:coreneuron+nmodl:intel"]
151+
152+
build:neuron:intel:
153+
stage: build_neuron
154+
extends:
155+
- .spack_build
156+
- .spack_neuron
157+
- .spack_intel
158+
needs: ["build:coreneuron:intel"]
159+
76160
build:neuron+nmodl:gpu:
77161
stage: build_neuron
78162
extends:
@@ -85,7 +169,51 @@ build:neuron+nmodl:gpu:
85169
- !reference [.spack_build, before_script]
86170
needs: ["build:coreneuron+nmodl:gpu"]
87171

172+
build:neuron+nmodl~openmp:gpu:
173+
stage: build_neuron
174+
extends:
175+
- .spack_build
176+
- .spack_neuron
177+
- .spack_nvhpc
178+
before_script:
179+
# Build py-cython and py-numpy with GCC instead of NVHPC.
180+
- SPACK_PACKAGE_DEPENDENCIES="${SPACK_PACKAGE_DEPENDENCIES}^py-cython%gcc^py-numpy%gcc"
181+
- !reference [.spack_build, before_script]
182+
needs: ["build:coreneuron+nmodl~openmp:gpu"]
183+
184+
build:neuron:gpu:
185+
stage: build_neuron
186+
extends:
187+
- .spack_build
188+
- .spack_neuron
189+
- .spack_nvhpc
190+
before_script:
191+
# Build py-cython and py-numpy with GCC instead of NVHPC.
192+
- SPACK_PACKAGE_DEPENDENCIES="${SPACK_PACKAGE_DEPENDENCIES}^py-cython%gcc^py-numpy%gcc"
193+
- !reference [.spack_build, before_script]
194+
needs: ["build:coreneuron:gpu"]
195+
196+
test:neuron+nmodl:intel:
197+
stage: test_neuron
198+
extends: [.ctest]
199+
needs: ["build:neuron+nmodl:intel"]
200+
201+
test:neuron:intel:
202+
stage: test_neuron
203+
extends: [.ctest]
204+
needs: ["build:neuron:intel"]
205+
88206
test:neuron+nmodl:gpu:
89207
stage: test_neuron
90208
extends: [.ctest, .gpu_node]
91209
needs: ["build:neuron+nmodl:gpu"]
210+
211+
test:neuron+nmodl~openmp:gpu:
212+
stage: test_neuron
213+
extends: [.ctest, .gpu_node]
214+
needs: ["build:neuron+nmodl~openmp:gpu"]
215+
216+
test:neuron:gpu:
217+
stage: test_neuron
218+
extends: [.ctest, .gpu_node]
219+
needs: ["build:neuron:gpu"]

CMake/OpenAccHelper.cmake

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,26 @@ if(CORENRN_ENABLE_GPU)
5555
# due to e.g. __CUDACC__ being defined. See https://github.com/BlueBrain/CoreNeuron/issues/607 for
5656
# more information about this. -gpu=cudaX.Y ensures that OpenACC code is compiled with the same
5757
# CUDA version as is used for the explicit CUDA code.
58-
set(NVHPC_ACC_COMP_FLAGS "-acc -Minfo=accel -gpu=cuda${CORENRN_CUDA_VERSION_SHORT},lineinfo")
59-
set(NVHPC_ACC_LINK_FLAGS "-acc -cuda")
58+
set(NVHPC_ACC_COMP_FLAGS "-Minfo=accel -gpu=cuda${CORENRN_CUDA_VERSION_SHORT},lineinfo")
59+
set(NVHPC_ACC_LINK_FLAGS "-cuda")
6060
# Make sure that OpenACC code is generated for the same compute capabilities as the explicit CUDA
6161
# code. Otherwise there may be confusing linker errors. We cannot rely on nvcc and nvc++ using the
6262
# same default compute capabilities as each other, particularly on GPU-less build machines.
6363
foreach(compute_capability ${CMAKE_CUDA_ARCHITECTURES})
6464
string(APPEND NVHPC_ACC_COMP_FLAGS ",cc${compute_capability}")
6565
endforeach()
66-
if(CORENRN_ENABLE_OPENMP AND CORENRN_ENABLE_OPENMP_OFFLOAD)
66+
if(CORENRN_ACCELERATOR_OFFLOAD STREQUAL "OpenMP")
6767
# Enable OpenMP target offload to GPU and if both OpenACC and OpenMP directives are available
6868
# for a region then prefer OpenMP.
6969
add_compile_definitions(CORENEURON_PREFER_OPENMP_OFFLOAD)
7070
string(APPEND NVHPC_ACC_COMP_FLAGS " -mp=gpu -Minfo=mp")
7171
string(APPEND NVHPC_ACC_LINK_FLAGS " -mp=gpu")
72+
elseif(CORENRN_ACCELERATOR_OFFLOAD STREQUAL "OpenACC")
73+
# Only enable OpenACC offload for GPU
74+
string(APPEND NVHPC_ACC_COMP_FLAGS " -acc")
75+
string(APPEND NVHPC_ACC_LINK_FLAGS " -acc")
76+
else()
77+
message(FATAL_ERROR "${CORENRN_ACCELERATOR_OFFLOAD} not supported with NVHPC compilers")
7278
endif()
7379
# avoid PGI adding standard compliant "-A" flags
7480
set(CMAKE_CXX14_STANDARD_COMPILE_OPTION --c++14)

CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ else()
121121
set(CORENRN_HAVE_NVHPC_COMPILER OFF)
122122
endif()
123123

124+
set(CORENRN_ACCELERATOR_OFFLOAD "Disabled")
124125
if(CORENRN_ENABLE_GPU)
125126
# Older CMake versions than 3.15 have not been tested for GPU/CUDA/OpenACC support after
126127
# https://github.com/BlueBrain/CoreNeuron/pull/609.
@@ -189,6 +190,18 @@ if(CORENRN_ENABLE_GPU)
189190
set(CMAKE_CUDA_FLAGS
190191
"${CMAKE_CUDA_FLAGS} --expt-relaxed-constexpr -Xcudafe --diag_suppress=3057,--diag_suppress=3085"
191192
)
193+
194+
if(CORENRN_ENABLE_NMODL)
195+
# NMODL supports both OpenACC and OpenMP target offload
196+
if(CORENRN_ENABLE_OPENMP AND CORENRN_ENABLE_OPENMP_OFFLOAD)
197+
set(CORENRN_ACCELERATOR_OFFLOAD "OpenMP")
198+
else()
199+
set(CORENRN_ACCELERATOR_OFFLOAD "OpenACC")
200+
endif()
201+
else()
202+
# MOD2C only supports OpenACC offload
203+
set(CORENRN_ACCELERATOR_OFFLOAD "OpenACC")
204+
endif()
192205
endif()
193206

194207
# =============================================================================
@@ -530,6 +543,7 @@ message(STATUS "MOD2CPP PATH | ${CORENRN_MOD2CPP_BINARY}")
530543
message(STATUS "GPU Support | ${CORENRN_ENABLE_GPU}")
531544
if(CORENRN_ENABLE_GPU)
532545
message(STATUS " CUDA | ${CUDAToolkit_LIBRARY_DIR}")
546+
message(STATUS " Offload | ${CORENRN_ACCELERATOR_OFFLOAD}")
533547
message(STATUS " Unified Memory | ${CORENRN_ENABLE_CUDA_UNIFIED_MEMORY}")
534548
endif()
535549
message(STATUS "Auto Timeout | ${CORENRN_ENABLE_TIMEOUT}")

coreneuron/CMakeLists.txt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -321,13 +321,15 @@ if(EXISTS "${CORENRN_EXTERNAL_BENCHMARK_DATA}")
321321
COMMENT "Running nrnivmodl-core for channel-benchmark mechanisms")
322322
list(APPEND all_output_binaries ${output_binaries})
323323
string(
324-
CONCAT
325-
benchmark_command
326-
"'${CMAKE_BINARY_DIR}/benchmark/${CMAKE_SYSTEM_PROCESSOR}/special-core'"
327-
" --datpath '${CORENRN_EXTERNAL_BENCHMARK_DATA}/channel-benchmark-all-440-cells-2-ranks'"
328-
" --tstop 1 --gpu &&"
329-
"diff out.dat '${CORENRN_EXTERNAL_BENCHMARK_DATA}/channel-benchmark-all-440-cells-2-ranks.gpu.spikes'"
330-
)
324+
CONCAT benchmark_command
325+
"'${CMAKE_BINARY_DIR}/benchmark/${CMAKE_SYSTEM_PROCESSOR}/special-core'"
326+
" --datpath '${CORENRN_EXTERNAL_BENCHMARK_DATA}/channel-benchmark-all-440-cells-2-ranks'"
327+
" --tstop 1 --mpi")
328+
if(CORENRN_ENABLE_GPU)
329+
string(APPEND benchmark_command " --gpu")
330+
endif()
331+
string(APPEND benchmark_command " && diff out.dat "
332+
"'${CORENRN_EXTERNAL_BENCHMARK_DATA}/channel-benchmark-all-440-cells-2-ranks.gpu.spikes'")
331333
add_test(NAME benchmark COMMAND sh -c "${benchmark_command}")
332334
endif()
333335
set(modfile_directory "${CORENEURON_PROJECT_SOURCE_DIR}/tests/integration/ring_gap/mod")

coreneuron/apps/main1.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,11 @@ void nrn_init_and_load_data(int argc,
193193
// precedence is: set by user, globals.dat, 34.0
194194
celsius = corenrn_param.celsius;
195195

196-
#if _OPENACC
196+
#if CORENEURON_ENABLE_GPU
197197
if (!corenrn_param.gpu && corenrn_param.cell_interleave_permute == 2) {
198198
fprintf(stderr,
199-
"compiled with _OPENACC does not allow the combination of --cell-permute=2 and "
199+
"compiled with CORENEURON_ENABLE_GPU does not allow the combination of "
200+
"--cell-permute=2 and "
200201
"missing --gpu\n");
201202
exit(1);
202203
}
@@ -497,7 +498,7 @@ extern "C" void mk_mech_init(int argc, char** argv) {
497498
}
498499
#endif
499500

500-
#ifdef _OPENACC
501+
#ifdef CORENEURON_ENABLE_GPU
501502
if (corenrn_param.gpu) {
502503
init_gpu();
503504
}
@@ -558,8 +559,8 @@ extern "C" int run_solve_core(int argc, char** argv) {
558559
#endif
559560
bool compute_gpu = corenrn_param.gpu;
560561

561-
nrn_pragma_acc(update device(celsius, secondorder, pi) if(compute_gpu))
562-
nrn_pragma_omp(target update to(celsius, secondorder, pi) if(compute_gpu))
562+
nrn_pragma_acc(update device(celsius, secondorder, pi) if (compute_gpu))
563+
nrn_pragma_omp(target update to(celsius, secondorder, pi) if (compute_gpu))
563564
{
564565
double v = corenrn_param.voltage;
565566
double dt = corenrn_param.dt;

0 commit comments

Comments
 (0)