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

Commit 5b079c5

Browse files
authored
Minor improvements and clarifications for GPU build (#452)
* Minor improvements and clarifications for GPU build - Fix pthread link error (#428) - Error if GPU support is enabled without PGI compiler Currently GPU support is only enabled via OpenACC and tested only with PGI compiler only. - Change CUDA to 9.0 as we are no longer testing/developing with old CUDA. And PGI compilers are also shipping newer CUDA libraries. - Build internal mod files in serial fashion to avoid mixing parallllel builds (see neuronsimulator/nrn/issues/889) fixes #428
1 parent ea242eb commit 5b079c5

File tree

5 files changed

+18
-13
lines changed

5 files changed

+18
-13
lines changed

CMake/OpenAccHelper.cmake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ if(CORENRN_ENABLE_GPU)
3434
set(CMAKE_CXX11_STANDARD_COMPILE_OPTION --c++11)
3535
set(CMAKE_CXX14_STANDARD_COMPILE_OPTION --c++14)
3636
else()
37-
message(WARNING "Non-PGI compiler : make sure to add required compiler flags to enable OpenACC")
37+
message(FATAL_ERROR "GPU support is available via OpenACC using PGI/NVIDIA compilers."
38+
" Use NVIDIA HPC SDK with -DCMAKE_C_COMPILER=nvc -DCMAKE_CXX_COMPILER=nvc++")
3839
endif()
3940

4041
# set property for neuron to link with coreneuron libraries
@@ -49,7 +50,7 @@ if(CORENRN_ENABLE_GPU)
4950
if(POLICY CMP0074)
5051
cmake_policy(SET CMP0074 NEW)
5152
endif()
52-
find_package(CUDA 5.0 REQUIRED)
53+
find_package(CUDA 9.0 REQUIRED)
5354
set(CUDA_SEPARABLE_COMPILATION ON)
5455
set(CUDA_PROPAGATE_HOST_FLAGS OFF)
5556
add_definitions(-DCUDA_PROFILING)

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ CoreNEURON is a compute engine for the [NEURON](https://www.neuron.yale.edu/neur
1010
CoreNEURON is designed as a library within the NEURON simulator and can transparently handle all spiking network simulations including gap junction coupling with the **fixed time step method**. In order to run a NEURON model with CoreNEURON:
1111

1212
* MOD files should be THREADSAFE
13-
* MOD files must use the Random123 random number generator (instead of MCellRan4)
13+
* If random number generator is used then Random123 should be used instead of MCellRan4
1414
* POINTER variables need to be converted to BBCOREPOINTER ([details here](http://bluebrain.github.io/CoreNeuron/index.html))
1515

1616
## Dependencies
1717
* [CMake 3.7+](https://cmake.org)
18-
* [MPI 2.0+](http://mpich.org) [Optional]
19-
* [PGI OpenACC Compiler >=19.0](https://www.pgroup.com/resources/accel.htm) [Optional, for GPU support]
20-
* [CUDA Toolkit >=6.0](https://developer.nvidia.com/cuda-toolkit-60) [Optional, for GPU support]
18+
* MPI Library [Optional, for MPI support]
19+
* [PGI OpenACC Compiler / NVIDIA HPC SDK](https://developer.nvidia.com/hpc-sdk) [Optional, for GPU support]
20+
* [CUDA Toolkit >=9.0](https://developer.nvidia.com/cuda-downloads) [Optional, for GPU support]
2121

2222
In addition to this, you will need other [NEURON dependencies](https://github.com/neuronsimulator/nrn) such as Python, Flex, Bison etc.
2323

@@ -64,7 +64,8 @@ Note that if you are building on Cray system with the GNU toolchain, you have to
6464
-DNRN_ENABLE_RX3D=OFF \
6565
-DCMAKE_INSTALL_PREFIX=$HOME/install
6666
```
67-
If you would like to enable GPU support with OpenACC, make sure to use `-DCORENRN_ENABLE_GPU=ON` option and use the PGI compiler with CUDA.
67+
If you would like to enable GPU support with OpenACC, make sure to use `-DCORENRN_ENABLE_GPU=ON` option and use the PGI/NVIDIA HPC SDK compilers with CUDA.
68+
6869
> NOTE : if the CMake command files, please make sure to delete temporary CMake cache files (`CMakeCache.txt`) before rerunning CMake.
6970
7071
4. Build and Install : once the configure step is done, you can build and install the project as:
@@ -161,6 +162,8 @@ nrn_spike_gids = nrn_spike_gids.to_python()
161162
# now run CoreNEURON
162163
from neuron import coreneuron
163164
coreneuron.enable = True
165+
# for GPU support
166+
# coreneuron.gpu = True
164167
coreneuron.verbose = 0
165168
h.stdinit()
166169
corenrn_all_spike_t = h.Vector()
@@ -214,6 +217,8 @@ cmake .. -DCMAKE_CXX_FLAGS="-O2 -Minline=size:1000,levels:100,totalsize:40000,ma
214217
-DCORENRN_ENABLE_GPU=ON -DCMAKE_INSTALL_PREFIX=$HOME/install
215218
```
216219

220+
For other errors, please [open an issue](https://github.com/BlueBrain/CoreNeuron/issues).
221+
217222

218223
## Developer Build
219224

coreneuron/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ add_custom_target(
169169
nrniv-core ALL
170170
COMMAND ${CMAKE_BINARY_DIR}/bin/nrnivmodl-core -b STATIC
171171
-m ${CORENRN_MOD2CPP_BINARY}
172+
-p 1
172173
${CORENEURON_PROJECT_SOURCE_DIR}/tests/integration/ring_gap/mod
173174
WORKING_DIRECTORY
174175
${CMAKE_BINARY_DIR}/bin

coreneuron/gpu/nrn_acc_manager.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,6 @@ void update_net_send_buffer_on_host(NrnThread* nt, NetSendBuffer_t* nsb) {
566566
void update_nrnthreads_on_host(NrnThread* threads, int nthreads) {
567567
#ifdef _OPENACC
568568

569-
printf("\n --- Copying to Host! --- \n");
570-
571569
for (int i = 0; i < nthreads; i++) {
572570
NrnThread* nt = threads + i;
573571

@@ -662,8 +660,6 @@ void update_nrnthreads_on_host(NrnThread* threads, int nthreads) {
662660
void update_nrnthreads_on_device(NrnThread* threads, int nthreads) {
663661
#ifdef _OPENACC
664662

665-
printf("\n --- Copying to Device! --- \n");
666-
667663
for (int i = 0; i < nthreads; i++) {
668664
NrnThread* nt = threads + i;
669665

@@ -820,7 +816,6 @@ void update_matrix_to_gpu(NrnThread* _nt) {
820816
/* while discussion with Michael we found that RHS is also needed on
821817
* gpu because nrn_cap_jacob uses rhs which is being updated on GPU
822818
*/
823-
// printf("\n Copying voltage to GPU ... ");
824819
double* v = _nt->_actual_v;
825820
double* rhs = _nt->_actual_rhs;
826821
int ne = nrn_soa_padded_size(_nt->end, 0);

extra/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ endif()
2222
# imported target to link line
2323
# ~~~
2424
list(REMOVE_ITEM CORENRN_LINK_LIBS "Threads::Threads")
25-
2625
# replicate CMake magic to transform system libs to -l<libname>
2726
foreach(link_lib ${CORENRN_LINK_LIBS})
27+
if(${link_lib} MATCHES "\-l.*")
28+
string(APPEND CORENRN_LINK_DEFS " ${link_lib}")
29+
continue()
30+
endif()
2831
get_filename_component(path ${link_lib} DIRECTORY)
2932
if(NOT path)
3033
string(APPEND CORENRN_LINK_DEFS " -l${link_lib}")

0 commit comments

Comments
 (0)