Skip to content

Commit

Permalink
Merge branch 'master' into cornu/remove_regexp
Browse files Browse the repository at this point in the history
  • Loading branch information
alkino authored Jan 25, 2024
2 parents 4a24345 + 9db73b4 commit f98ebed
Show file tree
Hide file tree
Showing 50 changed files with 718 additions and 1,672 deletions.
33 changes: 13 additions & 20 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2.1

orbs:
python: circleci/python@0.3.2
python: circleci/python@2.1.1

jobs:
manylinux2014-aarch64:
Expand All @@ -13,7 +13,7 @@ jobs:
type: string

machine:
image: ubuntu-2004:202101-01
image: default

resource_class: arm.medium

Expand Down Expand Up @@ -49,25 +49,18 @@ jobs:
# choose available python versions from pyenv
pyenv_py_ver=""
case << parameters.NRN_PYTHON_VERSION >> in
38) pyenv_py_ver="3.8.7" ;;
39) pyenv_py_ver="3.9.1" ;;
310) pyenv_py_ver="3.10.1" ;;
311) pyenv_py_ver="3.11.0" ;;
38) pyenv_py_ver="3.8" ;;
39) pyenv_py_ver="3.9" ;;
310) pyenv_py_ver="3.10" ;;
311) pyenv_py_ver="3.11" ;;
312) pyenv_py_ver="3.12" ;;
*) echo "Error: pyenv python version not specified!" && exit 1;;
esac
# install python dependencies: .10 is not available pyenv
if [ "<< parameters.NRN_PYTHON_VERSION >>" == "310" ]; then
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:deadsnakes/ppa -y
sudo apt install python3.10 libpython3.10 python3.10-venv
export PYTHON_EXE=$(which python3.10)
else
cd /opt/circleci/.pyenv/plugins/python-build/../.. && git pull && cd -
env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install $pyenv_py_ver --force
pyenv global $pyenv_py_ver
export PYTHON_EXE=$(which python)
fi
cd /opt/circleci/.pyenv/plugins/python-build/../.. && git fetch --all && git checkout -B master origin/master && cd -
env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install $pyenv_py_ver --force
pyenv global $pyenv_py_ver
export PYTHON_EXE=$(which python)
# test wheel
packaging/python/test_wheels.sh $PYTHON_EXE $(ls -t wheelhouse/*.whl)
Expand Down Expand Up @@ -95,7 +88,7 @@ workflows:
- /circleci\/.*/
matrix:
parameters:
NRN_PYTHON_VERSION: ["311"]
NRN_PYTHON_VERSION: ["312"]
NRN_NIGHTLY_UPLOAD: ["false"]

nightly:
Expand All @@ -110,5 +103,5 @@ workflows:
- manylinux2014-aarch64:
matrix:
parameters:
NRN_PYTHON_VERSION: ["38", "39", "310", "311"]
NRN_PYTHON_VERSION: ["38", "39", "310", "311", "312"]
NRN_NIGHTLY_UPLOAD: ["true"]
5 changes: 3 additions & 2 deletions .github/workflows/neuron-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
PY_MIN_VERSION: ${{ matrix.config.python_min_version || '3.8' }}
PY_MAX_VERSION: ${{ matrix.config.python_max_version || '3.11' }}
MUSIC_INSTALL_DIR: /opt/MUSIC
MUSIC_VERSION: 1.2.0
MUSIC_VERSION: 1.2.1

strategy:
matrix:
Expand Down Expand Up @@ -173,7 +173,8 @@ jobs:
curl -L -o MUSIC.zip https://github.com/INCF/MUSIC/archive/refs/tags/${MUSIC_VERSION}.zip
unzip MUSIC.zip && mv MUSIC-* MUSIC && cd MUSIC
./autogen.sh
./configure --with-python-sys-prefix --prefix=$MUSIC_INSTALL_DIR --disable-anysource
# on some systems MPI library detection fails, provide exact flags/compilers
./configure --with-python-sys-prefix --prefix=$MUSIC_INSTALL_DIR --disable-anysource MPI_CXXFLAGS="-g -O3" MPI_CFLAGS="-g -O3" MPI_LDFLAGS=" " CC=mpicc CXX=mpicxx
make -j install
deactivate
working-directory: ${{runner.temp}}
Expand Down
2 changes: 2 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ mac_m1_cmake_build:
- real_python=$(python3 resolve_shim.py)
- echo "python3=$(command -v python3) is really ${real_python}"
- PYTHONEXECUTABLE=${real_python} ${real_python} -mvenv venv
- venv/bin/python3 -m ensurepip --upgrade --default-pip
- venv/bin/pip install --upgrade pip -r nrn_requirements.txt
- git submodule update --init --recursive --force --depth 1 -- external/nmodl
- venv/bin/pip install --upgrade -r external/nmodl/requirements.txt
Expand Down Expand Up @@ -187,6 +188,7 @@ simulation_stack:
bb5_constraint: volta
bb5_cpus_per_task: 2
bb5_partition: prod # assume this is a good source of GPU nodes
bb5_exclusive: user # allocate gpu node exclusively for the CI user (to avoid errors from oversubscription)
.test_neuron:
extends: [.ctest]
variables:
Expand Down
10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ option(NRN_ENABLE_RX3D "Enable rx3d support" ${NRN_ENABLE_RX3D_DEFAULT})
option(NRN_ENABLE_CORENEURON "Enable CoreNEURON support" ${NRN_ENABLE_CORENEURON_DEFAULT})
option(NRN_ENABLE_BACKTRACE "Enable pretty-printed backtraces" ${NRN_ENABLE_BACKTRACE_DEFAULT})
option(NRN_ENABLE_TESTS "Enable unit tests" ${NRN_ENABLE_TESTS_DEFAULT})
option(NRN_ENABLE_MATH_OPT "Enable extra math optimisations (to enable SIMD)"
${NRN_ENABLE_MATH_OPT_DEFAULT})
set(NRN_ENABLE_MODEL_TESTS
"${NRN_ENABLE_MODEL_TESTS_DEFAULT}"
CACHE STRING "Comma-separated list of detailed models to enable tests of.")
Expand All @@ -94,11 +96,11 @@ option(NRN_ENABLE_MOD_COMPATIBILITY "Enable CoreNEURON compatibility for MOD fil
${NRN_ENABLE_MOD_COMPATIBILITY_DEFAULT})
option(NRN_ENABLE_REL_RPATH "Use relative RPATH in binaries. for relocatable installs/Python"
${NRN_ENABLE_REL_RPATH_DEFAULT})
option(NRN_WHEEL_BUILD ${NRN_WHEEL_BUILD_DEFAULT})
option(NRN_BINARY_DIST_BUILD ${NRN_BINARY_DIST_BUILD_DEFAULT})
option(NRN_WHEEL_STATIC_READLINE "Use static readline libraries for the wheels."
${NRN_WHEEL_STATIC_READLINE_DEFAULT})
mark_as_advanced(NRN_ENABLE_REL_RPATH)
mark_as_advanced(NRN_WHEEL_BUILD)
mark_as_advanced(NRN_BINARY_DIST_BUILD)

# =============================================================================
# Build options (string)
Expand Down Expand Up @@ -214,7 +216,7 @@ include(cmake/modules/FindPythonModule.cmake)
include(cmake/Coverage.cmake)

# set CMAKE_BUILD_TYPE and associated flags using allowableBuildTypes and CMAKE_BUILD_TYPE_DEFAULT
set(allowableBuildTypes Custom Debug Release RelWithDebInfo Fast)
set(allowableBuildTypes Custom Debug Release RelWithDebInfo Fast FastDebug)
include(ReleaseDebugAutoFlags)

# Try and emit an intelligent warning if the version number currently set in the CMake project(...)
Expand Down Expand Up @@ -929,7 +931,7 @@ if(BUILD_TYPE_UPPER MATCHES "CUSTOM")
else()
set(COMPILER_FLAGS "${CMAKE_CXX_FLAGS_${BUILD_TYPE_UPPER}}")
endif()
string(JOIN " " COMPILER_FLAGS "${COMPILER_FLAGS}" ${NRN_COMPILE_FLAGS})
string(JOIN " " COMPILER_FLAGS "${COMPILER_FLAGS}" ${NRN_COMPILE_FLAGS} ${CMAKE_CXX_FLAGS})

message(STATUS "")
message(STATUS "Configured NEURON ${PROJECT_VERSION}")
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://dev.azure.com/neuronsimulator/nrn/_apis/build/status/neuronsimulator.nrn?branchName=master)](https://dev.azure.com/neuronsimulator/nrn/_build/latest?definitionId=1&branchName=master) [![Actions Status](https://github.com/neuronsimulator/nrn/workflows/Windows%20Installer/badge.svg)](https://github.com/neuronsimulator/nrn/actions) [![Actions Status](https://github.com/neuronsimulator/nrn/workflows/NEURON%20CI/badge.svg)](https://github.com/neuronsimulator/nrn/actions) [![codecov](https://codecov.io/gh/neuronsimulator/nrn/branch/master/graph/badge.svg?token=T7PIDw6LrC)](https://codecov.io/gh/neuronsimulator/nrn) [![Documentation Status](https://readthedocs.org/projects/nrn/badge/?version=latest)](http://nrn.readthedocs.io/?badge=latest)
[![Build Status](https://dev.azure.com/neuronsimulator/nrn/_apis/build/status/neuronsimulator.nrn?branchName=master)](https://dev.azure.com/neuronsimulator/nrn/_build/latest?definitionId=1&branchName=master) [![Actions Status](https://github.com/neuronsimulator/nrn/actions/workflows/windows.yml/badge.svg?branch=master)](https://github.com/neuronsimulator/nrn/actions) [![Actions Status](https://github.com/neuronsimulator/nrn/workflows/NEURON%20CI/badge.svg)](https://github.com/neuronsimulator/nrn/actions) [![codecov](https://codecov.io/gh/neuronsimulator/nrn/branch/master/graph/badge.svg?token=T7PIDw6LrC)](https://codecov.io/gh/neuronsimulator/nrn) [![Documentation Status](https://readthedocs.org/projects/nrn/badge/?version=latest)](http://nrn.readthedocs.io/?badge=latest)

# NEURON
NEURON is a simulator for models of neurons and networks of neuron. See [http://neuron.yale.edu](http://neuron.yale.edu) for installers, source code, documentation, tutorials, announcements of
Expand Down
3 changes: 2 additions & 1 deletion ci/win_build_cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ cd $BUILD_SOURCESDIRECTORY/build
-DNRN_ENABLE_PYTHON=ON \
-DNRN_ENABLE_RX3D=ON \
-DNRN_RX3D_OPT_LEVEL=2 \
-DNRN_BINARY_DIST_BUILD=ON \
-DPYTHON_EXECUTABLE=/c/Python38/python.exe \
-DNRN_ENABLE_PYTHON_DYNAMIC=ON \
-DNRN_PYTHON_DYNAMIC='c:/Python38/python.exe;c:/Python39/python.exe;c:/Python310/python.exe;c:/Python311/python.exe' \
-DNRN_PYTHON_DYNAMIC='c:/Python38/python.exe;c:/Python39/python.exe;c:/Python310/python.exe;c:/Python311/python.exe;c:/Python312/python.exe' \
-DCMAKE_INSTALL_PREFIX='/c/nrn-install' \
-DMPI_CXX_LIB_NAMES:STRING=msmpi \
-DMPI_C_LIB_NAMES:STRING=msmpi \
Expand Down
1 change: 1 addition & 0 deletions ci/win_download_deps.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pwsh -command Invoke-WebRequest -MaximumRetryCount 4 -OutFile python-3.8.exe htt
pwsh -command Invoke-WebRequest -MaximumRetryCount 4 -OutFile python-3.9.exe https://www.python.org/ftp/python/3.9.0/python-3.9.0-amd64.exe || goto :error
pwsh -command Invoke-WebRequest -MaximumRetryCount 4 -OutFile python-3.10.exe https://www.python.org/ftp/python/3.10.0/python-3.10.0-amd64.exe || goto :error
pwsh -command Invoke-WebRequest -MaximumRetryCount 4 -OutFile python-3.11.exe https://www.python.org/ftp/python/3.11.1/python-3.11.1-amd64.exe || goto :error
pwsh -command Invoke-WebRequest -MaximumRetryCount 4 -OutFile python-3.12.exe https://www.python.org/ftp/python/3.12.1/python-3.12.1-amd64.exe || goto :error

:: mpi
pwsh -command Invoke-WebRequest -MaximumRetryCount 4 -OutFile msmpisetup.exe https://download.microsoft.com/download/a/5/2/a5207ca5-1203-491a-8fb8-906fd68ae623/msmpisetup.exe || goto :error
Expand Down
3 changes: 3 additions & 0 deletions ci/win_install_deps.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ python-3.8.exe /passive Include_pip=1 Include_test=0 PrependPath=1 DefaultJustFo
python-3.9.exe /passive Include_pip=1 Include_test=0 PrependPath=1 DefaultJustForMeTargetDir=C:\Python39 || goto :error
python-3.10.exe /passive Include_pip=1 Include_test=0 PrependPath=1 DefaultJustForMeTargetDir=C:\Python310 || goto :error
python-3.11.exe /passive Include_pip=1 Include_test=0 PrependPath=1 DefaultJustForMeTargetDir=C:\Python311 || goto :error
python-3.12.exe /passive Include_pip=1 Include_test=0 PrependPath=1 DefaultJustForMeTargetDir=C:\Python312 || goto :error

:: fix msvcc version for all python3
pwsh -command "(Get-Content C:\Python38\Lib\distutils\cygwinccompiler.py) -replace 'elif msc_ver == ''1600'':', 'elif msc_ver == ''1916'':' | Out-File C:\Python38\Lib\distutils\cygwinccompiler.py"
Expand All @@ -26,6 +27,8 @@ C:\Python38\python.exe -m pip install numpy==1.17.5 "cython < 3" || goto :error
C:\Python39\python.exe -m pip install numpy==1.19.3 "cython < 3" || goto :error
C:\Python310\python.exe -m pip install numpy==1.21.3 "cython < 3" || goto :error
C:\Python311\python.exe -m pip install numpy==1.23.5 "cython < 3" || goto :error
C:\Python312\python.exe -m pip install numpy==1.26.3 "cython < 3" || goto :error
C:\Python312\python.exe -m pip install setuptools || goto :error

:: install nsis
nsis-3.05-setup.exe /S || goto :error
Expand Down
3 changes: 2 additions & 1 deletion cmake/BuildOptionDefaults.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ set(NRN_ENABLE_REL_RPATH_DEFAULT OFF)
set(NRN_AVOID_ABSOLUTE_PATHS_DEFAULT OFF)
set(NRN_NMODL_CXX_FLAGS_DEFAULT "-O0")
set(NRN_SANITIZERS_DEFAULT "")
set(NRN_ENABLE_MATH_OPT_DEFAULT OFF)

# Some distributions may set the prefix. To avoid errors, unset it
set(NRN_PYTHON_DYNAMIC_DEFAULT "")
Expand All @@ -43,7 +44,7 @@ set(PYTHON_EXECUTABLE_DEFAULT "")
set(IV_LIB_DEFAULT "")

# For wheel deployment
set(NRN_WHEEL_BUILD_DEFAULT OFF)
set(NRN_BINARY_DIST_BUILD_DEFAULT OFF)
set(NRN_WHEEL_STATIC_READLINE_DEFAULT OFF)

# we add some coreneuron options in order to check support like GPU
Expand Down
22 changes: 21 additions & 1 deletion cmake/CompilerFlagsHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ set(SUPPORTED_COMPILER_LANGUAGE_LIST "C;CXX")
foreach(COMPILER_LANGUAGE ${SUPPORTED_COMPILER_LANGUAGE_LIST})
if(CMAKE_${COMPILER_LANGUAGE}_COMPILER_ID STREQUAL "XL")
set(CMAKE_${COMPILER_LANGUAGE}_COMPILER_IS_XLC ON)
elseif(CMAKE_${COMPILER_LANGUAGE}_COMPILER_ID STREQUAL "Intel")
elseif(CMAKE_${COMPILER_LANGUAGE}_COMPILER_ID STREQUAL "Intel"
OR CMAKE_${COMPILER_LANGUAGE}_COMPILER_ID STREQUAL "IntelLLVM")
set(CMAKE_${COMPILER_LANGUAGE}_COMPILER_IS_ICC ON)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(CMAKE_${COMPILER_LANGUAGE}_COMPILER_IS_MSVC)
Expand All @@ -27,6 +28,10 @@ foreach(COMPILER_LANGUAGE ${SUPPORTED_COMPILER_LANGUAGE_LIST})
endif()
endforeach()

set(UNSAFE_MATH_FLAG
"-ffinite-math-only -fno-math-errno -funsafe-math-optimizations -fno-associative-math")
set(FASTDEBUG_FLAG "-g -O1")

# Set optimization flags for each compiler
foreach(COMPILER_LANGUAGE ${SUPPORTED_COMPILER_LANGUAGE_LIST})

Expand All @@ -39,6 +44,7 @@ foreach(COMPILER_LANGUAGE ${SUPPORTED_COMPILER_LANGUAGE_LIST})
set(CMAKE_${COMPILER_LANGUAGE}_OPT_NONE "-O0")
set(CMAKE_${COMPILER_LANGUAGE}_OPT_NORMAL "-O2")
set(CMAKE_${COMPILER_LANGUAGE}_OPT_FAST "-O3")
set(CMAKE_${COMPILER_LANGUAGE}_OPT_FASTDEBUG ${FASTDEBUG_FLAG})
set(CMAKE_${COMPILER_LANGUAGE}_STACK_PROTECTION "-qstackprotect")
set(CMAKE_${COMPILER_LANGUAGE}_POSITION_INDEPENDENT "-qpic=small")
set(CMAKE_${COMPILER_LANGUAGE}_VECTORIZE "-qhot")
Expand All @@ -59,9 +65,11 @@ foreach(COMPILER_LANGUAGE ${SUPPORTED_COMPILER_LANGUAGE_LIST})
set(CMAKE_${COMPILER_LANGUAGE}_OPT_NONE "-O0")
set(CMAKE_${COMPILER_LANGUAGE}_OPT_NORMAL "-O2")
set(CMAKE_${COMPILER_LANGUAGE}_OPT_FAST "-O3")
set(CMAKE_${COMPILER_LANGUAGE}_OPT_FASTDEBUG ${FASTDEBUG_FLAG})
set(CMAKE_${COMPILER_LANGUAGE}_STACK_PROTECTION "-fstack-protector")
set(CMAKE_${COMPILER_LANGUAGE}_POSITION_INDEPENDENT "-fPIC")
set(CMAKE_${COMPILER_LANGUAGE}_VECTORIZE "-ftree-vectorize")
set(CMAKE_${COMPILER_LANGUAGE}_UNSAFE_MATH ${UNSAFE_MATH_FLAG})
set(IGNORE_UNKNOWN_PRAGMA_FLAGS "-Wno-unknown-pragmas")

if(CMAKE_${COMPILER_LANGUAGE}_COMPILER_VERSION VERSION_GREATER "4.7.0")
Expand All @@ -82,6 +90,11 @@ foreach(COMPILER_LANGUAGE ${SUPPORTED_COMPILER_LANGUAGE_LIST})
set(CMAKE_${COMPILER_LANGUAGE}_OPT_NONE "-O0")
set(CMAKE_${COMPILER_LANGUAGE}_OPT_NORMAL "-O2")
set(CMAKE_${COMPILER_LANGUAGE}_OPT_FAST "-O3")
if(CMAKE_${COMPILER_LANGUAGE}_COMPILER_ID STREQUAL "IntelLLVM")
set(CMAKE_${COMPILER_LANGUAGE}_OPT_FASTDEBUG "${FASTDEBUG_FLAG} -fp-model precise")
else()
set(CMAKE_${COMPILER_LANGUAGE}_OPT_FASTDEBUG "${FASTDEBUG_FLAG} -fp-model consistent")
endif()
set(CMAKE_${COMPILER_LANGUAGE}_STACK_PROTECTION "-fstack-protector")
set(CMAKE_${COMPILER_LANGUAGE}_POSITION_INDEPENDENT "-fpic")
set(CMAKE_${COMPILER_LANGUAGE}_VECTORIZE "")
Expand All @@ -94,11 +107,18 @@ foreach(COMPILER_LANGUAGE ${SUPPORTED_COMPILER_LANGUAGE_LIST})
set(CMAKE_${COMPILER_LANGUAGE}_OPT_NONE "-O0")
set(CMAKE_${COMPILER_LANGUAGE}_OPT_NORMAL "-O2")
set(CMAKE_${COMPILER_LANGUAGE}_OPT_FAST "-O3")
set(CMAKE_${COMPILER_LANGUAGE}_OPT_FASTDEBUG "-g -O1")
set(CMAKE_${COMPILER_LANGUAGE}_STACK_PROTECTION "")
set(CMAKE_${COMPILER_LANGUAGE}_POSITION_INDEPENDENT "-fPIC")
set(CMAKE_${COMPILER_LANGUAGE}_VECTORIZE "")
if(CMAKE_${COMPILER_LANGUAGE}_COMPILER_ID STREQUAL "PGI")
set(CMAKE_${COMPILER_LANGUAGE}_WARNING_ALL "")
endif()
if(CMAKE_${COMPILER_LANGUAGE}_COMPILER_ID STREQUAL "Clang")
set(CMAKE_${COMPILER_LANGUAGE}_UNSAFE_MATH ${UNSAFE_MATH_FLAG})
endif()
if(CMAKE_${COMPILER_LANGUAGE}_COMPILER_ID STREQUAL "NVHPC")
set(CMAKE_${COMPILER_LANGUAGE}_OPT_FASTDEBUG "${FASTDEBUG_FLAG} -fno-omit-frame-pointer")
endif()
endif()
endforeach()
5 changes: 2 additions & 3 deletions cmake/NeuronFileLists.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ set(HEADER_FILES_TO_INSTALL
oc/hocparse.h
oc/mcran4.h
oc/mech_api.h
oc/memory.hpp
oc/nrnapi.h
oc/nrnassrt.h
oc/nrnisaac.h
Expand Down Expand Up @@ -68,8 +69,6 @@ set(HEADER_FILES_TO_INSTALL
scopmath/sparse_thread.hpp
scopmath/ssimplic.hpp
scopmath/ssimplic_thread.hpp
sparse13/cspmatrix.h
sparse13/cspredef.h
sparse13/spconfig.h
sparse13/spmatrix.h)

Expand Down Expand Up @@ -103,6 +102,7 @@ set(OC_FILE_LIST
hoc_oop.cpp
list.cpp
math.cpp
memory.cpp
mswinprt.cpp
nonlin.cpp
ocerf.cpp
Expand Down Expand Up @@ -222,7 +222,6 @@ set(NRNIV_FILE_LIST
cxprop.cpp
datapath.cpp
finithnd.cpp
geometry3d.cpp
glinerec.cpp
hocmech.cpp
impedanc.cpp
Expand Down
50 changes: 46 additions & 4 deletions cmake/ReleaseDebugAutoFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ endif()
# Release : Release mode, no debuginfo
# RelWithDebInfo : Distribution mode, basic optimizations for portable code with debuginfos
# Fast : Maximum level of optimization. Target native architecture, not portable code
# FastDebug: Similar to Debug with a bit higher level optimisations (-O1) and other compiler
# flags so that it's faster than -O0 but still produces consistent results for
# testing and debugging purposes.
# ~~~

include(CompilerFlagsHelpers)
Expand All @@ -33,17 +36,56 @@ set(CMAKE_CXX_FLAGS_DEBUG
"${CMAKE_CXX_DEBUGINFO_FLAGS} ${CMAKE_CXX_OPT_NONE} ${CMAKE_CXX_STACK_PROTECTION} ${CMAKE_CXX_IGNORE_WARNINGS}"
)

set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_OPT_NORMAL} ${CMAKE_C_IGNORE_WARNINGS}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_OPT_NORMAL} ${CMAKE_CXX_IGNORE_WARNINGS}")
set(C_UNSAFE_MATH_FLAGS "")
set(CXX_UNSAFE_MATH_FLAGS "")
if(NRN_ENABLE_MATH_OPT)
set(C_UNSAFE_MATH_FLAGS ${CMAKE_C_UNSAFE_MATH})
set(CXX_UNSAFE_MATH_FLAGS ${CMAKE_CXX_UNSAFE_MATH})
endif()

set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_OPT_NORMAL} ${CMAKE_C_IGNORE_WARNINGS} ${C_UNSAFE_MATH_FLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE
"${CMAKE_CXX_OPT_NORMAL} ${CMAKE_CXX_IGNORE_WARNINGS} ${CXX_UNSAFE_MATH_FLAGS}")

set(CMAKE_C_FLAGS_RELWITHDEBINFO
"${CMAKE_C_DEBUGINFO_FLAGS} ${CMAKE_C_OPT_NORMAL} ${CMAKE_C_IGNORE_WARNINGS}")
"${CMAKE_C_DEBUGINFO_FLAGS} ${CMAKE_C_OPT_NORMAL} ${CMAKE_C_IGNORE_WARNINGS} ${C_UNSAFE_MATH_FLAGS}"
)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO
"${CMAKE_CXX_DEBUGINFO_FLAGS} ${CMAKE_CXX_OPT_NORMAL} ${CMAKE_CXX_IGNORE_WARNINGS}")
"${CMAKE_CXX_DEBUGINFO_FLAGS} ${CMAKE_CXX_OPT_NORMAL} ${CMAKE_CXX_IGNORE_WARNINGS} ${CXX_UNSAFE_MATH_FLAGS}"
)

set(CMAKE_C_FLAGS_FAST
"${CMAKE_C_OPT_FAST} ${CMAKE_C_LINK_TIME_OPT} ${CMAKE_C_GEN_NATIVE} ${CMAKE_C_IGNORE_WARNINGS}")
set(CMAKE_CXX_FLAGS_FAST
"${CMAKE_CXX_OPT_FAST} ${CMAKE_CXX_LINK_TIME_OPT} ${CMAKE_CXX_GEN_NATIVE} ${CMAKE_CXX_IGNORE_WARNINGS}"
)

set(CMAKE_C_FLAGS_FASTDEBUG "${CMAKE_C_OPT_FASTDEBUG} ${CMAKE_C_IGNORE_WARNINGS}")
set(CMAKE_CXX_FLAGS_FASTDEBUG "${CMAKE_CXX_OPT_FASTDEBUG} ${CMAKE_CXX_IGNORE_WARNINGS}")
# ~~~

# for binary distributions, avoid addition of OpenMP specific flag as compiler on end-user machine
# may not support it.
if(NOT DEFINED NRN_BINARY_DIST_BUILD OR NOT NRN_BINARY_DIST_BUILD)
include(CheckCXXCompilerFlag)
# Check support for OpenMP SIMD constructs
set(SIMD_FLAGS "")

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
set(SIMD_FLAGS "-qopenmp-simd")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(SIMD_FLAGS "-openmp:experimental")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(SIMD_FLAGS "-openmp-simd")
else() # not ICC, MSVC, or Clang => GCC and others
set(SIMD_FLAGS "-fopenmp-simd")
endif()

check_cxx_compiler_flag("${SIMD_FLAGS}" COMPILER_SUPPORT_SIMD)
if(COMPILER_SUPPORT_SIMD)
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} ${SIMD_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SIMD_FLAGS}")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no support for OpenMP SIMD construct")
endif()
endif()
Loading

0 comments on commit f98ebed

Please sign in to comment.