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

Fixes for building portable wheel : nrnivmodl-core should be usable from wheel #634

Merged
merged 12 commits into from
Oct 21, 2021

Conversation

pramodk
Copy link
Collaborator

@pramodk pramodk commented Sep 8, 2021

  • Do not link to MPI libraries if MPI is not enabled
  • Use CXX compiler set on target machine e.g. via env variable
  • Perl and Python executable may not be exist in same path.
    Check for existence before using them.

Todos:

  • Check is Perl and Python should be set via wrapper?
    Perl is safe. May be only python is worth setting.

CI_BRANCHES:NEURON_BRANCH=epic/gpu_wheel,

pramodk added a commit to neuronsimulator/nrn that referenced this pull request Sep 8, 2021
* do not propogate NEURON MPI flag if CoreNEURON
  MPI option is explicitly specified
* nrnivmodl uses CORENRNHOME env variable instead
  of CNRNHOE variable
* binwrapper.py sets CORENRNHOME same as NRNHOME
* update coreneuron to branch BlueBrain/CoreNeuron#634
@pramodk
Copy link
Collaborator Author

pramodk commented Oct 12, 2021

Still WIP but on BB5 I am testing this with:

   # clone neuron from : https://github.com/neuronsimulator/nrn/pull/1452 i.e. branch `epic/gpu_wheel`

    module load unstable cmake python hpe-mpi flex bison python-dev llvm gcc
    cmake .. -DCMAKE_INSTALL_PREFIX=`pwd`/install \
          -DCORENRN_ENABLE_GPU=OFF -DNRN_ENABLE_INTERVIEWS=OFF -DNRN_ENABLE_RX3D=OFF \
          -DNRN_ENABLE_CORENEURON=ON -DCORENRN_ENABLE_NMODL=OFF -DCORENRN_CLANG_FORMAT=ON \
          -DNRN_ENABLE_MPI_DYNAMIC=ON \
          -DNRN_MPI_DYNAMIC="/gpfs/bbp.cscs.ch/ssd/apps/hpc/jenkins/deploy/externals/2021-01-06/linux-rhel7-x86_64/gcc-9.3.0/intel-mpi-2019.8.254-r
          -DCORENRN_CMAKE_FORMAT=ON -DPYTHON_EXECUTABLE=`which python3.8`
    make -j12
    make install

and it should create

$ tree lib/
lib/
|-- libcoreneuron.so
|-- libcorenrnmpi_mpich.so
|-- libcorenrnmpi_mpt.so
|-- libnrniv.so
|-- libnrnmpi_mpich.so
|-- libnrnmpi_mpt.so
|-- librxdmath.so
|-- libscopmath.a

@alkino : still draft but you can see my ongoing changes in 836267d.

@pramodk pramodk force-pushed the pramodk/wheel-fixes branch 2 times, most recently from 2ac1405 to 7187ac5 Compare October 13, 2021 16:07
@pramodk pramodk requested a review from olupton October 13, 2021 23:45
pramodk added a commit to neuronsimulator/nrn that referenced this pull request Oct 13, 2021
* do not propogate NEURON MPI flag if CoreNEURON
  MPI option is explicitly specified
* nrnivmodl uses CORENRNHOME env variable instead
  of CNRNHOE variable
* binwrapper.py sets CORENRNHOME same as NRNHOME
* update coreneuron to branch BlueBrain/CoreNeuron#634
pramodk added a commit to neuronsimulator/nrn that referenced this pull request Oct 13, 2021
coreneuron/apps/main1.cpp Outdated Show resolved Hide resolved
coreneuron/CMakeLists.txt Outdated Show resolved Hide resolved
* Do not link to MPI libraries if MPI is not enabled
* Use CXX compiler set on target machine e.g. via env variable
* Perl and Python executable may not be exist in same path.
  Check for existence before using them.

Todo:

- [ ] Check is Perl and Python should be set via wrapper?
      Perl is safe. May be only python is worth.
 * this is only supported when build as a submodule of neuron
   to avoid cmake code duplication
 * leverage -DNRN_MPI_DYNAMIC="a;b;" option of neuron
 * MPI distribution specific libcorenrnmpi_<name>.so is built
   and installed under lib folder
 * TODO: still need to inrerface with NEURON side

On BB5 this is tested with:

```
module load unstable cmake python hpe-mpi flex bison python-dev llvm gcc
cmake .. -DCMAKE_INSTALL_PREFIX=`pwd`/install \
      -DCORENRN_ENABLE_GPU=OFF -DNRN_ENABLE_INTERVIEWS=OFF -DNRN_ENABLE_RX3D=OFF \
      -DNRN_ENABLE_CORENEURON=ON -DCORENRN_ENABLE_NMODL=OFF -DCORENRN_CLANG_FORMAT=ON \
      -DNRN_ENABLE_MPI_DYNAMIC=ON \
      -DNRN_MPI_DYNAMIC="/gpfs/bbp.cscs.ch/ssd/apps/hpc/jenkins/deploy/externals/2021-01-06/linux-rhel7-x86_64/gcc-9.3.0/intel-mpi-2019.8.254-rrc5ip/impi/2019.8.254/intel64/include/;/gpfs/bbp.cscs.ch/ssd/apps/hpc/jenkins/deploy/externals/2021-01-06/linux-rhel7-x86_64/gcc-9.3.0/hpe-mpi-2.22.hmpt-r52ypu/include;" \
      -DCORENRN_CMAKE_FORMAT=ON -DPYTHON_EXECUTABLE=`which python3.8`
make -j12
make install
```
 * add new CLI option --corenrn-mpi-lib
 * load & resolve symbols only once
 * is_quite now passed as argument to nrnmpi_init
 * remove usage of [dy]ld_library_path
 * change --corenrn-mpi-lib to --mpi-lib
 * use variable for name of the library and targets
  * do not compile mpi library with -acc -gpu flags because
    it results into nasty segfault
  * to achieve this, do not add OpenACC flags to CMAKE_CXX_FLAGS
    instead use targe_compile_options()
  * Profile interface needs to be updated because some cpp files like
    for mpi library may not have cuda headers because they no longer
    use -acc flag to compile. Check existance of ACC or CUDA active.
Linker should use -acc -cuda instead of just -cuda
Copy link
Contributor

@olupton olupton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a couple of minor things.

re: the error with building too many things with -acc, do we have an issue to follow up on that?

CMake/OpenAccHelper.cmake Show resolved Hide resolved
coreneuron/apps/main1.cpp Outdated Show resolved Hide resolved
@pramodk
Copy link
Collaborator Author

pramodk commented Oct 20, 2021

re: the error with building too many things with -acc, do we have an issue to follow up on that?

I created #674 for this.

@pramodk
Copy link
Collaborator Author

pramodk commented Oct 20, 2021

Retest this please

@pramodk
Copy link
Collaborator Author

pramodk commented Oct 21, 2021

Retest this please

@pramodk pramodk merged commit ec0a4d4 into master Oct 21, 2021
@pramodk pramodk deleted the pramodk/wheel-fixes branch October 21, 2021 23:28
pramodk added a commit to neuronsimulator/nrn that referenced this pull request Nov 2, 2022
…n#634)

* Do not link to MPI libraries if MPI is not enabled
* Use CXX compiler set on target machine e.g. via env variable
* Perl and Python executable may not be exist in same path.
  - Check for existence before using them.
  - Respect CORENRN_PERLEXE and CORENRN_PYTHONEXE env vars set by neuron's wheel wrapper
* neuron cmake option consistency:
   CORENRN_ENABLE_DYNAMIC_MPI -> CORENRN_ENABLE_MPI_DYNAMIC
* Build multiple MPI libraries for dynamic MPI support
  - this is only supported when build as a submodule of neuron
     to avoid cmake code duplication
  - leverage -DNRN_MPI_DYNAMIC="a;b;" option of neuron
  - MPI distribution specific libcorenrnmpi_<name>.so is built
     and installed under lib folder
* Add CLI option --mpi-lib which can accept name of coreneuron MPI
   library to load
* Load & resolve symbols only once
* Cleanup and Update tests
* Fixes for segfault at finalise with dynamic MPI
   - do not compile mpi library with -acc -gpu flags because
     it results into nasty segfault
  - to achieve this, do not add OpenACC flags to CMAKE_CXX_FLAGS
     instead use targe_compile_options()
  - profile interface needs to be updated because some cpp files like
    for mpi library may not have cuda headers because they no longer
    use -acc flag to compile. Check existance of ACC or CUDA active.

CoreNEURON Repo SHA: BlueBrain/CoreNeuron@ec0a4d4
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants