From cb298f3d85ac1bbab6403913e7f77b7387b09b89 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Tue, 30 Nov 2021 09:47:35 +0100 Subject: [PATCH 01/60] Conditionally enable GPU support in build-catalogue. --- cmake/arbor-config.cmake.in | 1 + scripts/build-catalogue.in | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cmake/arbor-config.cmake.in b/cmake/arbor-config.cmake.in index 5ddbc0cc38..c9edecdc53 100644 --- a/cmake/arbor-config.cmake.in +++ b/cmake/arbor-config.cmake.in @@ -45,6 +45,7 @@ function(_append_property target property) endfunction() set(ARB_VECTORIZE @ARB_VECTORIZE@) +set(ARB_WITH_GPU @ARB_WITH_GPU@) set(ARB_ARCH @ARB_ARCH@) set(ARB_MODCC_FLAGS @ARB_MODCC_FLAGS@) set(ARB_CXX @CMAKE_CXX_COMPILER@) diff --git a/scripts/build-catalogue.in b/scripts/build-catalogue.in index e79a45dc4d..d20db1f4c9 100755 --- a/scripts/build-catalogue.in +++ b/scripts/build-catalogue.in @@ -85,9 +85,13 @@ project({name}-cat LANGUAGES CXX) find_package(arbor REQUIRED) +if(ARB_WITH_GPU) + enable_language(CUDA) +endif() + set(CMAKE_BUILD_TYPE release) -set(CMAKE_CXX_COMPILER ${{ARB_CXX}}) -set(CMAKE_CXX_FLAGS ${{ARB_CXX_FLAGS}}) +set(CMAKE_CXX_COMPILER ${{ARB_CXX}}) +set(CMAKE_CXX_FLAGS ${{ARB_CXX_FLAGS}}) include(BuildModules.cmake) From 087842dd5e6e4c7b287755d9a971f3e6f68a3f80 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Tue, 30 Nov 2021 09:58:14 +0100 Subject: [PATCH 02/60] Make GPU support an argument to build-catalogue. --- scripts/build-catalogue.in | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/scripts/build-catalogue.in b/scripts/build-catalogue.in index d20db1f4c9..b08baccd52 100755 --- a/scripts/build-catalogue.in +++ b/scripts/build-catalogue.in @@ -52,6 +52,10 @@ def parse_arguments(): action='store_true', help='Less output.') + parser.add_argument('-g', '--gpu', + metavar='gpu', + help='Enable GPU support, valid options: cuda|hip|cuda-clang.') + parser.add_argument('-d', '--debug', nargs="?", metavar="path", @@ -79,15 +83,26 @@ verbose = args['verbose'] and not args['quiet'] quiet = args['quiet'] debug = args['debug'] +if args['gpu']: + if args['gpu'] == 'cuda': + gpu_support = """set(ARB_WITH_NVCC TRUE) +set(ARB_WITH_GPU TRUE) +set(CMAKE_CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER}) +set(CMAKE_CUDA_ARCHITECTURES 60 70 80) +enable_language(CUDA) +find_package(CUDA 10 REQUIRED)""" + else: + print(f"Unsupported GPU target: {args['gpu']}") +else: + gpu_support = "# NONE" + cmake = f""" cmake_minimum_required(VERSION 3.9) project({name}-cat LANGUAGES CXX) find_package(arbor REQUIRED) -if(ARB_WITH_GPU) - enable_language(CUDA) -endif() +{gpu_support} set(CMAKE_BUILD_TYPE release) set(CMAKE_CXX_COMPILER ${{ARB_CXX}}) From 69b03c4d26c95676d8730c2d20bda2bee8ca6c8e Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Tue, 30 Nov 2021 10:12:30 +0100 Subject: [PATCH 03/60] Disable CUDA arch --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ccdfe0db06..e39d7495f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,7 +114,7 @@ if(ARB_GPU STREQUAL "cuda") # CMake 18 and later set the default CUDA architecture for # each target according to CMAKE_CUDA_ARCHITECTURES. if (NOT DEFINED CMAKE_CUDA_ARCHITECTURES) - set(CMAKE_CUDA_ARCHITECTURES 60 70 80) + # set(CMAKE_CUDA_ARCHITECTURES 60 70 80) endif() # This fixes nvcc picking up a wrong host compiler for linking, causing issues From 568d469403f4cbcaf5bfab6b507855b0a7713e49 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Tue, 30 Nov 2021 14:18:09 +0100 Subject: [PATCH 04/60] Backport ault experimentation. --- CMakeLists.txt | 20 +++++++++++--------- scripts/build-catalogue.in | 13 ++++++------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e39d7495f9..398498d14b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,10 @@ enable_language(CXX) include(GNUInstallDirs) +# Effectively adds '-fpic' flag to CXX_FLAGS. Needed for dynamic catalogues. +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + + # Turn on this option to force the compilers to produce color output when output is # redirected from the terminal (e.g. when using ninja or a pager). @@ -111,12 +115,6 @@ set(THREADS_PREFER_PTHREAD_FLAG OFF) if(ARB_GPU STREQUAL "cuda") set(ARB_WITH_NVCC TRUE) - # CMake 18 and later set the default CUDA architecture for - # each target according to CMAKE_CUDA_ARCHITECTURES. - if (NOT DEFINED CMAKE_CUDA_ARCHITECTURES) - # set(CMAKE_CUDA_ARCHITECTURES 60 70 80) - endif() - # This fixes nvcc picking up a wrong host compiler for linking, causing issues # with outdated libraries, eg libstdc++ and std::filesystem. Must happend before # all calls to enable_language(CUDA) @@ -124,6 +122,13 @@ if(ARB_GPU STREQUAL "cuda") enable_language(CUDA) + # CMake 3.18 and later set the default CUDA architecture for + # each target according to CMAKE_CUDA_ARCHITECTURES. Not setting + # this will constitute an error from now on. + if (NOT DEFINED CMAKE_CUDA_ARCHITECTURES) + set(CMAKE_CUDA_ARCHITECTURES 60 70) # Compatible with CUDA 10. + endif() + # Despite native CUDA support, the CUDA package is still required to export # the cuda library dependencies from the installed target. find_package(CUDA 10 REQUIRED) @@ -301,9 +306,6 @@ if(ARB_WITH_PYTHON) find_package(Python3 ${arb_py_version} COMPONENTS Interpreter Development REQUIRED) endif() - # Required to link the dynamic libraries for python modules. - # Effectively adds '-fpic' flag to CXX_FLAGS. - set(CMAKE_POSITION_INDEPENDENT_CODE ON) else() # If not building the Python module, the interpreter is still required # to build some targets, e.g. when building the documentation. diff --git a/scripts/build-catalogue.in b/scripts/build-catalogue.in index b08baccd52..8408c90b56 100755 --- a/scripts/build-catalogue.in +++ b/scripts/build-catalogue.in @@ -85,12 +85,10 @@ debug = args['debug'] if args['gpu']: if args['gpu'] == 'cuda': - gpu_support = """set(ARB_WITH_NVCC TRUE) -set(ARB_WITH_GPU TRUE) -set(CMAKE_CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER}) -set(CMAKE_CUDA_ARCHITECTURES 60 70 80) -enable_language(CUDA) -find_package(CUDA 10 REQUIRED)""" + gpu_support = """add_compile_definitions(ARB_CUDA) +set(CMAKE_CUDA_HOST_COMPILER @CMAKE_CXX_COMPILER@) +set(CMAKE_CUDA_ARCHITECTURES @CMAKE_CUDA_ARCHITECTURES@) +enable_language(CUDA)""" else: print(f"Unsupported GPU target: {args['gpu']}") else: @@ -100,6 +98,7 @@ cmake = f""" cmake_minimum_required(VERSION 3.9) project({name}-cat LANGUAGES CXX) +set(arbor_DIR @CMAKE_INSTALL_FULL_LIBDIR@/cmake/arbor) find_package(arbor REQUIRED) {gpu_support} @@ -111,7 +110,7 @@ set(CMAKE_CXX_FLAGS ${{ARB_CXX_FLAGS}}) include(BuildModules.cmake) set(ARB_WITH_EXTERNAL_MODCC true) -find_program(modcc NAMES modcc) +find_program(modcc NAMES modcc PATHS @CMAKE_INSTALL_FULL_BINDIR@) make_catalogue( NAME {name} From 4ed96d81c6d55989c2dca82984ea9a31da669839 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Tue, 30 Nov 2021 14:31:16 +0100 Subject: [PATCH 05/60] Admit failure on HIP/CUDA-clang target, refer user to issue. --- CMakeLists.txt | 18 +++++++++--------- scripts/build-catalogue.in | 8 +++++--- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 398498d14b..67212bc0d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,13 +115,6 @@ set(THREADS_PREFER_PTHREAD_FLAG OFF) if(ARB_GPU STREQUAL "cuda") set(ARB_WITH_NVCC TRUE) - # This fixes nvcc picking up a wrong host compiler for linking, causing issues - # with outdated libraries, eg libstdc++ and std::filesystem. Must happend before - # all calls to enable_language(CUDA) - set(CMAKE_CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER}) - - enable_language(CUDA) - # CMake 3.18 and later set the default CUDA architecture for # each target according to CMAKE_CUDA_ARCHITECTURES. Not setting # this will constitute an error from now on. @@ -129,6 +122,13 @@ if(ARB_GPU STREQUAL "cuda") set(CMAKE_CUDA_ARCHITECTURES 60 70) # Compatible with CUDA 10. endif() + # This fixes nvcc picking up a wrong host compiler for linking, causing issues + # with outdated libraries, eg libstdc++ and std::filesystem. Must happend before + # all calls to enable_language(CUDA) + set(CMAKE_CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER}) + + enable_language(CUDA) + # Despite native CUDA support, the CUDA package is still required to export # the cuda library dependencies from the installed target. find_package(CUDA 10 REQUIRED) @@ -224,8 +224,8 @@ install(TARGETS arborio-public-deps EXPORT arborio-targets) # Add scripts and supporting CMake for setting up external catalogues -configure_file(scripts/build-catalogue.in ${CMAKE_CURRENT_BINARY_DIR}/build-catalogue @ONLY) -install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/build-catalogue DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}) +configure_file(scripts/build-catalogue.in ${CMAKE_CURRENT_BINARY_DIR}/arbor-build-catalogue @ONLY) +install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/arbor-build-catalogue DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}) install(FILES mechanisms/BuildModules.cmake DESTINATION ${ARB_INSTALL_DATADIR}) install(FILES mechanisms/generate_catalogue DESTINATION ${ARB_INSTALL_DATADIR} PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) # External libraries in `ext` sub-directory: json, tinyopt and randon123. diff --git a/scripts/build-catalogue.in b/scripts/build-catalogue.in index 8408c90b56..36b627184f 100755 --- a/scripts/build-catalogue.in +++ b/scripts/build-catalogue.in @@ -86,11 +86,13 @@ debug = args['debug'] if args['gpu']: if args['gpu'] == 'cuda': gpu_support = """add_compile_definitions(ARB_CUDA) +add_compile_definitions(ARB_HAVE_GPU) + +enable_language(CUDA) set(CMAKE_CUDA_HOST_COMPILER @CMAKE_CXX_COMPILER@) -set(CMAKE_CUDA_ARCHITECTURES @CMAKE_CUDA_ARCHITECTURES@) -enable_language(CUDA)""" +set(CMAKE_CUDA_ARCHITECTURES @CMAKE_CUDA_ARCHITECTURES@)""" else: - print(f"Unsupported GPU target: {args['gpu']}") + print(f"Unsupported GPU target: {args['gpu']}. If you need support for HIP or Clang-CUDA, please check here: https://github.com/arbor-sim/arbor/issues/1783") else: gpu_support = "# NONE" From 69811241e83e697ccc8db139ebb349a428e66edd Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Wed, 1 Dec 2021 11:42:11 +0100 Subject: [PATCH 06/60] No wheels, but full install. --- pyproject.toml | 2 + setup.py | 112 +++++++------------------------------------------ 2 files changed, 16 insertions(+), 98 deletions(-) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000..75335283e8 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,2 @@ +[build-system] +requires = ["setuptools", "wheel", "scikit-build", "cmake", "ninja"] diff --git a/setup.py b/setup.py index 094837d4a2..cc257f8e01 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,6 @@ import os import sys -import setuptools -import pathlib -from setuptools import Extension -from setuptools.command.build_ext import build_ext -from setuptools.command.install import install +from skbuild import setup import subprocess try: from wheel.bdist_wheel import bdist_wheel @@ -57,14 +53,6 @@ def cl_opt(): with open(os.path.join(here, 'python/readme.md'), encoding='utf-8') as f: long_description = f.read() -def check_cmake(): - try: - out = subprocess.check_output(['cmake', '--version']) - return True - except OSError: - return False - - class _command_template: """ Override a setuptools-like command to augment the command line options. @@ -85,7 +73,6 @@ def initialize_options(self): # Both here and in `mixin1`, a `super` call is required super().initialize_options() # ... - """ def __init_subclass__(cls, **kwargs): super().__init_subclass__(**kwargs) @@ -135,80 +122,8 @@ def run(self): super().run() - -class install_command(_command_template, install): - pass - -if WHEEL_INSTALLED: - class bdist_wheel_command(_command_template, bdist_wheel): - pass - - -class cmake_extension(Extension): - def __init__(self, name): - Extension.__init__(self, name, sources=[]) - - -class cmake_build(build_ext): - def run(self): - if not check_cmake(): - raise RuntimeError('CMake is not available. CMake 3.12 is required.') - - # The path where CMake will be configured and Arbor will be built. - build_directory = os.path.abspath(self.build_temp) - # The path where the package will be copied after building. - lib_directory = os.path.abspath(self.build_lib) - # The path where the Python package will be compiled. - source_path = build_directory + '/python/arbor' - # Where to copy the package after it is built, so that whatever the next phase is - # can copy it into the target 'prefix' path. - dest_path = lib_directory + '/arbor' - - opt = cl_opt() - cmake_args = [ - '-DARB_WITH_PYTHON=on', - '-DPYTHON_EXECUTABLE=' + sys.executable, - '-DARB_WITH_MPI={}'.format( 'on' if opt['mpi'] else 'off'), - '-DARB_VECTORIZE={}'.format('on' if opt['vec'] else 'off'), - '-DARB_ARCH={}'.format(opt['arch']), - '-DARB_GPU={}'.format(opt['gpu']), - '-DARB_WITH_NEUROML={}'.format( 'on' if opt['neuroml'] else 'off'), - '-DARB_USE_BUNDLED_LIBS={}'.format('on' if opt['bundled'] else 'off'), - '-DCMAKE_BUILD_TYPE=Release' # we compile with debug symbols in release mode. - ] - - print('-'*5, 'command line arguments: {}'.format(opt)) - print('-'*5, 'cmake arguments: {}'.format(cmake_args)) - - build_args = ['--config', 'Release'] - - # Assuming Makefiles - build_args += ['--', f'-j{opt["makejobs"]}'] - - env = os.environ.copy() - env['CXXFLAGS'] = '{}'.format(env.get('CXXFLAGS', '')) - if not os.path.exists(self.build_temp): - os.makedirs(self.build_temp) - - # CMakeLists.txt is in the same directory as this setup.py file - cmake_list_dir = os.path.abspath(os.path.dirname(__file__)) - print('-'*20, 'Configure CMake') - subprocess.check_call(['cmake', cmake_list_dir] + cmake_args, - cwd=self.build_temp, env=env) - - print('-'*20, 'Build') - cmake_cmd = ['cmake', '--build', '.'] + build_args - subprocess.check_call(cmake_cmd, - cwd=self.build_temp) - - # Copy from build path to some other place from whence it will later be installed. - # ... or something like that - # ... setuptools is an enigma monkey patched on a mystery - if not os.path.exists(dest_path): - os.makedirs(dest_path, exist_ok=True) - self.copy_tree(source_path, dest_path) - -setuptools.setup( +opt = cl_opt() +setup( name='arbor', version=version_, python_requires='>=3.6', @@ -216,16 +131,17 @@ def run(self): install_requires=['numpy'], setup_requires=[], zip_safe=False, - ext_modules=[cmake_extension('arbor')], - cmdclass={ - 'build_ext': cmake_build, - 'install': install_command, - 'bdist_wheel': bdist_wheel_command, - } if WHEEL_INSTALLED else { - 'build_ext': cmake_build, - 'install': install_command, - }, - + cmake_args = [ + '-DARB_WITH_PYTHON=on', + '-DPYTHON_EXECUTABLE=' + sys.executable, + '-DARB_WITH_MPI={}'.format( 'on' if opt['mpi'] else 'off'), + '-DARB_VECTORIZE={}'.format('on' if opt['vec'] else 'off'), + '-DARB_ARCH={}'.format(opt['arch']), + '-DARB_GPU={}'.format(opt['gpu']), + '-DARB_WITH_NEUROML={}'.format( 'on' if opt['neuroml'] else 'off'), + '-DARB_USE_BUNDLED_LIBS={}'.format('on' if opt['bundled'] else 'off'), + '-DCMAKE_BUILD_TYPE=Release' # we compile with debug symbols in release mode. + ], author='The Arbor dev team.', url='https://github.com/arbor-sim/arbor', description='High performance simulation of networks of multicompartment neurons.', From e8c7b21ae4576f80957f7818b8be814054ad2191 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Wed, 1 Dec 2021 12:46:41 +0100 Subject: [PATCH 07/60] Fix tests. --- .github/workflows/basic.yml | 2 +- python/test/fixtures.py | 2 +- setup.py | 7 ------- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/basic.yml b/.github/workflows/basic.yml index 7fe497c535..e77fd1bb78 100644 --- a/.github/workflows/basic.yml +++ b/.github/workflows/basic.yml @@ -180,5 +180,5 @@ jobs: run: scripts/run_python_examples.sh - name: Build and test a catalogue run: | - build-catalogue -v default mechanisms/default + arbor-build-catalogue -v default mechanisms/default ./scripts/test-catalogue.py ./default-catalogue.so diff --git a/python/test/fixtures.py b/python/test/fixtures.py index 38142fb3e5..a0d90a56b8 100644 --- a/python/test/fixtures.py +++ b/python/test/fixtures.py @@ -79,7 +79,7 @@ class _BuildCatError(Exception): pass def _build_cat_local(name, path): try: - subprocess.run(["build-catalogue", name, str(path)], check=True, stderr=subprocess.PIPE) + subprocess.run(["arbor-build-catalogue", name, str(path)], check=True, stderr=subprocess.PIPE) except subprocess.CalledProcessError as e: raise _BuildCatError("Tests can't build catalogues:\n" + e.stderr.decode()) from None diff --git a/setup.py b/setup.py index cc257f8e01..3eedb4303c 100644 --- a/setup.py +++ b/setup.py @@ -2,13 +2,6 @@ import sys from skbuild import setup import subprocess -try: - from wheel.bdist_wheel import bdist_wheel - WHEEL_INSTALLED = True -except: - #wheel package not installed. - WHEEL_INSTALLED = False - pass # Singleton class that holds the settings configured using command line # options. This information has to be stored in a singleton so that it From 0210ef8394970713efb30a91cabab31a1feb88f1 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Mon, 6 Dec 2021 09:30:56 +0100 Subject: [PATCH 08/60] Use relative paths when configuring a-b-c. --- CMakeLists.txt | 3 +++ mechanisms/default/expsyn.mod | 1 - scripts/build-catalogue.in | 24 +++++++++++++++++++----- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 67212bc0d2..83d5e57fb0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -180,6 +180,9 @@ set(CMAKE_CXX_EXTENSIONS OFF) # Data and internal scripts go here set(ARB_INSTALL_DATADIR ${CMAKE_INSTALL_FULL_DATAROOTDIR}/arbor) +# Derived paths for arbor-build-catalogue +file(RELATIVE_PATH ARB_REL_DATADIR ${CMAKE_INSTALL_FULL_BINDIR} ${CMAKE_INSTALL_FULL_DATAROOTDIR}/arbor) +file(RELATIVE_PATH ARB_REL_PACKAGEDIR ${CMAKE_INSTALL_FULL_BINDIR} ${CMAKE_INSTALL_FULL_LIBDIR}/cmake/arbor) # Interface library `arbor-config-defs` collects configure-time defines # for arbor, arborenv, arborio, of the form ARB_HAVE_XXX. These diff --git a/mechanisms/default/expsyn.mod b/mechanisms/default/expsyn.mod index c1f7d24e9d..1ac2f3e55e 100644 --- a/mechanisms/default/expsyn.mod +++ b/mechanisms/default/expsyn.mod @@ -36,4 +36,3 @@ DERIVATIVE state { NET_RECEIVE(weight) { g = g + weight } - diff --git a/scripts/build-catalogue.in b/scripts/build-catalogue.in index 36b627184f..9d845833ff 100755 --- a/scripts/build-catalogue.in +++ b/scripts/build-catalogue.in @@ -10,6 +10,7 @@ import stat import string import argparse import re + def parse_arguments(): def append_slash(s): return s+'/' if s and not s.endswith('/') else s @@ -96,11 +97,21 @@ set(CMAKE_CUDA_ARCHITECTURES @CMAKE_CUDA_ARCHITECTURES@)""" else: gpu_support = "# NONE" +this = Path(__file__).parent +data_path = (this / "@ARB_REL_DATADIR@").resolve() +pack_path = (this / "@ARB_REL_PACKAGEDIR@").resolve() +exec_path = this.resolve() + +if verbose: + print(f"Expecting generate_catalogue, BuildModules here: {data_path}") + print(f"Expecting arbor.cmake here: {pack_path}") + print(f"Expecting modcc here: {exec_path}") + cmake = f""" cmake_minimum_required(VERSION 3.9) project({name}-cat LANGUAGES CXX) -set(arbor_DIR @CMAKE_INSTALL_FULL_LIBDIR@/cmake/arbor) +set(arbor_DIR {pack_path}) find_package(arbor REQUIRED) {gpu_support} @@ -112,14 +123,14 @@ set(CMAKE_CXX_FLAGS ${{ARB_CXX_FLAGS}}) include(BuildModules.cmake) set(ARB_WITH_EXTERNAL_MODCC true) -find_program(modcc NAMES modcc PATHS @CMAKE_INSTALL_FULL_BINDIR@) +find_program(modcc NAMES modcc PATHS {exec_path}) make_catalogue( NAME {name} SOURCES "${{CMAKE_CURRENT_SOURCE_DIR}}/mod" OUTPUT "CAT_{name.upper()}_SOURCES" MECHS {' '.join(mods)} - PREFIX @ARB_INSTALL_DATADIR@ + PREFIX {data_path} CXX_FLAGS_TARGET ${{ARB_CXX_FLAGS_TARGET}} STANDALONE ON VERBOSE {"ON" if verbose else "OFF"}) @@ -161,8 +172,11 @@ with TemporaryDirectory() as tmp: os.chdir(tmp / 'build') with open(tmp / 'CMakeLists.txt', 'w') as fd: fd.write(cmake) - shutil.copy2(f'@ARB_INSTALL_DATADIR@/BuildModules.cmake', tmp) - shutil.copy2(f'@ARB_INSTALL_DATADIR@/generate_catalogue', tmp) + shutil.copy2(f'{data_path}/BuildModules.cmake', tmp) + shutil.copy2(f'{data_path}/generate_catalogue', tmp) + + print(f"Pulling files from: {data_path}") + cmake_cmd = 'cmake ..' make_cmd = 'make' if verbose: From 46ca36184eb27680476038979ce052e21567900d Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Mon, 6 Dec 2021 09:39:08 +0100 Subject: [PATCH 09/60] Clean-up. --- scripts/build-catalogue.in | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/build-catalogue.in b/scripts/build-catalogue.in index 9d845833ff..aa97b154a6 100755 --- a/scripts/build-catalogue.in +++ b/scripts/build-catalogue.in @@ -97,12 +97,12 @@ set(CMAKE_CUDA_ARCHITECTURES @CMAKE_CUDA_ARCHITECTURES@)""" else: gpu_support = "# NONE" -this = Path(__file__).parent -data_path = (this / "@ARB_REL_DATADIR@").resolve() -pack_path = (this / "@ARB_REL_PACKAGEDIR@").resolve() -exec_path = this.resolve() +this_path = Path(__file__).parent +data_path = (this_path / "@ARB_REL_DATADIR@").resolve() +pack_path = (this_path / "@ARB_REL_PACKAGEDIR@").resolve() +exec_path = this_path.resolve() -if verbose: +if debug: print(f"Expecting generate_catalogue, BuildModules here: {data_path}") print(f"Expecting arbor.cmake here: {pack_path}") print(f"Expecting modcc here: {exec_path}") From 4f4bdb53cb6addf74f3a2c44bf3db6d1f46567d0 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Mon, 6 Dec 2021 09:47:56 +0100 Subject: [PATCH 10/60] Print errors if tools are not found. --- scripts/build-catalogue.in | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/scripts/build-catalogue.in b/scripts/build-catalogue.in index aa97b154a6..b0bf5f54bb 100755 --- a/scripts/build-catalogue.in +++ b/scripts/build-catalogue.in @@ -95,17 +95,21 @@ set(CMAKE_CUDA_ARCHITECTURES @CMAKE_CUDA_ARCHITECTURES@)""" else: print(f"Unsupported GPU target: {args['gpu']}. If you need support for HIP or Clang-CUDA, please check here: https://github.com/arbor-sim/arbor/issues/1783") else: - gpu_support = "# NONE" + gpu_support = "# GPU: Disabled" this_path = Path(__file__).parent data_path = (this_path / "@ARB_REL_DATADIR@").resolve() pack_path = (this_path / "@ARB_REL_PACKAGEDIR@").resolve() exec_path = this_path.resolve() -if debug: - print(f"Expecting generate_catalogue, BuildModules here: {data_path}") - print(f"Expecting arbor.cmake here: {pack_path}") - print(f"Expecting modcc here: {exec_path}") +for i,p in [(exec_path, 'modcc'), + (data_path, 'generate_catalogue'), + (data_path, 'BuildModules.cmake'), + (pack_path, 'arbor-config.cmake'), + ]: + path = p / i + if not path.exists(): + print(f'Could not find required tool: {path}. Please check your installation.') cmake = f""" cmake_minimum_required(VERSION 3.9) @@ -175,8 +179,6 @@ with TemporaryDirectory() as tmp: shutil.copy2(f'{data_path}/BuildModules.cmake', tmp) shutil.copy2(f'{data_path}/generate_catalogue', tmp) - print(f"Pulling files from: {data_path}") - cmake_cmd = 'cmake ..' make_cmd = 'make' if verbose: From ffa967ec29ea31c44ca7bf40ff8b59f0faf6404e Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Mon, 6 Dec 2021 12:29:44 +0100 Subject: [PATCH 11/60] Update docs. --- doc/install/python.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/doc/install/python.rst b/doc/install/python.rst index 766cdab8cb..7a36e00da2 100644 --- a/doc/install/python.rst +++ b/doc/install/python.rst @@ -8,6 +8,9 @@ Arbor's Python API will be the most convenient interface for most users. .. note:: Arbor requires Python version 3.6 and later. It is advised that you update `pip` as well. +.. note:: + We assume ``pip`` is used to install Arbor. See later for using ``setup.py``. + Getting Arbor ------------- @@ -71,6 +74,10 @@ Every time you make changes to the code, you'll have to repeat the second step. Advanced options ^^^^^^^^^^^^^^^^ +.. note:: When installing via ``setup.py install`` directly instead of using + ``pip install .``, you will have to install the build-time dependencies + listed in ``pyproject.toml`` on your own. + By default Arbor is installed with multi-threading enabled. To enable more advanced forms of parallelism, Arbor comes with a few compilation options. These can be used on both local (``pip3 install ./arbor``) and remote (``pip3 install arbor``) copies of Arbor. Below we assume you are working off a local copy. @@ -84,7 +91,7 @@ The following optional flags can be used to configure the installation: See :ref:`install-architecture` for details. * ``--arch``: CPU micro-architecture to target. The advised default is ``native``. See `here `_ for a full list of options. -* ``--makejobs``: Specify the amount of jobs to ``make`` the project with for faster build times on multicore systems. By default set to ``2``. +* ``-j``: Specify the amount of concurrent jobs for building the project with for faster build times on multicore systems. By default set to ``2``. **Vanilla install** with no additional features enabled: From dbd1e2bc6830a7b1d4301b0ad404ef896d78bca0 Mon Sep 17 00:00:00 2001 From: Brent Huisman Date: Mon, 6 Dec 2021 16:47:26 +0100 Subject: [PATCH 12/60] remove stale bits from setup.py --- setup.py | 112 ++++--------------------------------------------------- 1 file changed, 7 insertions(+), 105 deletions(-) diff --git a/setup.py b/setup.py index 3eedb4303c..bcff376a10 100644 --- a/setup.py +++ b/setup.py @@ -1,41 +1,6 @@ import os import sys from skbuild import setup -import subprocess - -# Singleton class that holds the settings configured using command line -# options. This information has to be stored in a singleton so that it -# can be passed between different stages of the build, and because pip -# has strange behavior between different versions. -class CL_opt: - instance = None - def __init__(self): - if not CL_opt.instance: - CL_opt.instance = {'mpi': False, - 'gpu': 'none', - 'vec': False, - 'arch': 'none', - 'neuroml': True, - 'bundled': True, - 'makejobs': 2} - - def settings(self): - return CL_opt.instance - -def cl_opt(): - return CL_opt().settings() - -# extend user_options the same way for all Command()s -user_options_ = [ - ('mpi', None, 'enable mpi support (requires MPI library)'), - ('gpu=', None, 'enable nvidia cuda support (requires cudaruntime and nvcc) or amd hip support. Supported values: ' - 'none, cuda, cuda-clang, hip'), - ('vec', None, 'enable vectorization'), - ('arch=', None, 'cpu architecture, e.g. haswell, skylake, armv8.2-a+sve, znver2 (default native).'), - ('neuroml', None, 'enable parsing neuroml morphologies in Arbor (requires libxml)'), - ('sysdeps', None, 'don\'t use bundled 3rd party C++ dependencies (pybind11 and json). This flag forces use of dependencies installed on the system.'), - ('makejobs=', None, 'the amount of jobs to run `make` with.') - ] # VERSION is in the same path as setup.py here = os.path.abspath(os.path.dirname(__file__)) @@ -46,76 +11,13 @@ def cl_opt(): with open(os.path.join(here, 'python/readme.md'), encoding='utf-8') as f: long_description = f.read() -class _command_template: - """ - Override a setuptools-like command to augment the command line options. - Needs to appear before the command class in the class's argument list for - correct MRO. - - Examples - -------- - - .. code-block: python - - class install_command(_command_template, install): - pass - - - class complex_command(_command_template, mixin1, install): - def initialize_options(self): - # Both here and in `mixin1`, a `super` call is required - super().initialize_options() - # ... - """ - def __init_subclass__(cls, **kwargs): - super().__init_subclass__(**kwargs) - cls.user_options = super().user_options + user_options_ - - - def initialize_options(self): - super().initialize_options() - self.mpi = None - self.gpu = None - self.arch = None - self.vec = None - self.neuroml = None - self.sysdeps = None - self.makejobs = 2 - - def finalize_options(self): - super().finalize_options() - try: - self.makejobs = int(self.makejobs) - except ValueError: - err = True - else: - err = False - if err or self.makejobs < 1: - raise AssertionError('makejobs must be a strictly positive integer') - - def run(self): - # The options are stored in global variables: - opt = cl_opt() - # mpi : build with MPI support (boolean). - opt['mpi'] = self.mpi is not None - # gpu : compile for AMD/NVIDIA GPUs and choose compiler (string). - opt['gpu'] = "none" if self.gpu is None else self.gpu - # vec : generate SIMD vectorized kernels for CPU micro-architecture (boolean). - opt['vec'] = self.vec is not None - # arch : target CPU micro-architecture (string). - opt['arch'] = 'none' if self.arch is None else self.arch - # neuroml : compile with neuroml support for morphologies. - opt['neuroml'] = self.neuroml is not None - # bundled : use bundled/git-submoduled 3rd party libraries. - # By default use bundled libs. - opt['bundled'] = self.sysdeps is None - # makejobs : specify amount of jobs. - # By default 2. - opt['makejobs'] = int(self.makejobs) - - super().run() - -opt = cl_opt() +opt = {'mpi': False, + 'gpu': 'none', + 'vec': False, + 'arch': 'none', + 'neuroml': True, + 'bundled': True, + 'makejobs': 2} setup( name='arbor', version=version_, From e1152e8bd0fa6875dcbf811ebe5bc532e20b5957 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Mon, 6 Dec 2021 16:55:42 +0100 Subject: [PATCH 13/60] Add (temporary) argparse options. --- setup.py | 186 +++++++++++++------------------------------------------ 1 file changed, 43 insertions(+), 143 deletions(-) diff --git a/setup.py b/setup.py index 3eedb4303c..50d3ad4f3e 100644 --- a/setup.py +++ b/setup.py @@ -1,41 +1,18 @@ import os import sys from skbuild import setup -import subprocess +import argparse -# Singleton class that holds the settings configured using command line -# options. This information has to be stored in a singleton so that it -# can be passed between different stages of the build, and because pip -# has strange behavior between different versions. -class CL_opt: - instance = None - def __init__(self): - if not CL_opt.instance: - CL_opt.instance = {'mpi': False, - 'gpu': 'none', - 'vec': False, - 'arch': 'none', - 'neuroml': True, - 'bundled': True, - 'makejobs': 2} +P = argparse.ArgumentParser(description='Arbor build options.') +P.add_argument('--vec', dest='vec', action='store_const', const='on', default='off', help='Enable SIMD.') +P.add_argument('--nml', dest='nml', action='store_const', const='on', default='off', help='Enable NeuroML2 support. Requires libxml2.') +P.add_argument('--mpi', dest='mpi', action='store_const', const='on', default='off', help='Enable MPI.') +P.add_argument('--bundled', metavar='bundled', action='store_const', const='on', default='off', help='Use bundled libs.') +P.add_argument('--gpu', metavar='gpu', default='none', help='Enable GPU support.') +P.add_argument('--arch', metavar='arch', default='', help='Set processor architecture.') +opt = P.parse_known_args() - def settings(self): - return CL_opt.instance - -def cl_opt(): - return CL_opt().settings() - -# extend user_options the same way for all Command()s -user_options_ = [ - ('mpi', None, 'enable mpi support (requires MPI library)'), - ('gpu=', None, 'enable nvidia cuda support (requires cudaruntime and nvcc) or amd hip support. Supported values: ' - 'none, cuda, cuda-clang, hip'), - ('vec', None, 'enable vectorization'), - ('arch=', None, 'cpu architecture, e.g. haswell, skylake, armv8.2-a+sve, znver2 (default native).'), - ('neuroml', None, 'enable parsing neuroml morphologies in Arbor (requires libxml)'), - ('sysdeps', None, 'don\'t use bundled 3rd party C++ dependencies (pybind11 and json). This flag forces use of dependencies installed on the system.'), - ('makejobs=', None, 'the amount of jobs to run `make` with.') - ] +print(f"Options {opt}") # VERSION is in the same path as setup.py here = os.path.abspath(os.path.dirname(__file__)) @@ -46,113 +23,36 @@ def cl_opt(): with open(os.path.join(here, 'python/readme.md'), encoding='utf-8') as f: long_description = f.read() -class _command_template: - """ - Override a setuptools-like command to augment the command line options. - Needs to appear before the command class in the class's argument list for - correct MRO. - - Examples - -------- - - .. code-block: python - - class install_command(_command_template, install): - pass - - - class complex_command(_command_template, mixin1, install): - def initialize_options(self): - # Both here and in `mixin1`, a `super` call is required - super().initialize_options() - # ... - """ - def __init_subclass__(cls, **kwargs): - super().__init_subclass__(**kwargs) - cls.user_options = super().user_options + user_options_ - - - def initialize_options(self): - super().initialize_options() - self.mpi = None - self.gpu = None - self.arch = None - self.vec = None - self.neuroml = None - self.sysdeps = None - self.makejobs = 2 - - def finalize_options(self): - super().finalize_options() - try: - self.makejobs = int(self.makejobs) - except ValueError: - err = True - else: - err = False - if err or self.makejobs < 1: - raise AssertionError('makejobs must be a strictly positive integer') - - def run(self): - # The options are stored in global variables: - opt = cl_opt() - # mpi : build with MPI support (boolean). - opt['mpi'] = self.mpi is not None - # gpu : compile for AMD/NVIDIA GPUs and choose compiler (string). - opt['gpu'] = "none" if self.gpu is None else self.gpu - # vec : generate SIMD vectorized kernels for CPU micro-architecture (boolean). - opt['vec'] = self.vec is not None - # arch : target CPU micro-architecture (string). - opt['arch'] = 'none' if self.arch is None else self.arch - # neuroml : compile with neuroml support for morphologies. - opt['neuroml'] = self.neuroml is not None - # bundled : use bundled/git-submoduled 3rd party libraries. - # By default use bundled libs. - opt['bundled'] = self.sysdeps is None - # makejobs : specify amount of jobs. - # By default 2. - opt['makejobs'] = int(self.makejobs) - - super().run() - -opt = cl_opt() -setup( - name='arbor', - version=version_, - python_requires='>=3.6', - - install_requires=['numpy'], - setup_requires=[], - zip_safe=False, - cmake_args = [ - '-DARB_WITH_PYTHON=on', - '-DPYTHON_EXECUTABLE=' + sys.executable, - '-DARB_WITH_MPI={}'.format( 'on' if opt['mpi'] else 'off'), - '-DARB_VECTORIZE={}'.format('on' if opt['vec'] else 'off'), - '-DARB_ARCH={}'.format(opt['arch']), - '-DARB_GPU={}'.format(opt['gpu']), - '-DARB_WITH_NEUROML={}'.format( 'on' if opt['neuroml'] else 'off'), - '-DARB_USE_BUNDLED_LIBS={}'.format('on' if opt['bundled'] else 'off'), - '-DCMAKE_BUILD_TYPE=Release' # we compile with debug symbols in release mode. - ], - author='The Arbor dev team.', - url='https://github.com/arbor-sim/arbor', - description='High performance simulation of networks of multicompartment neurons.', - long_description=long_description, - long_description_content_type='text/markdown', - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: BSD License', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: C++', - ], - project_urls={ - 'Source': 'https://github.com/arbor-sim/arbor', - 'Documentation': 'https://docs.arbor-sim.org', - 'Bug Reports': 'https://github.com/arbor-sim/arbor/issues', - }, -) +setup(name='arbor', + version=version_, + python_requires='>=3.6', + install_requires=['numpy'], + setup_requires=[], + zip_safe=False, + cmake_args = ['-DARB_WITH_PYTHON=on', + '-DPYTHON_EXECUTABLE=' + sys.executable, + f'-DARB_WITH_MPI={opt["mpi"]}', + f'-DARB_VECTORIZE={opt["vec"]}' + f'-DARB_ARCH={opt["arch"]}', + f'-DARB_GPU={opt["gpu"]}', + f'-DARB_WITH_NEUROML={opt["nml"]}', + f'-DARB_USE_BUNDLED_LIBS={opt["bundled"]}', + '-DCMAKE_BUILD_TYPE=Release'], + author='The Arbor dev team.', + url='https://github.com/arbor-sim/arbor', + description='High performance simulation of networks of multicompartment neurons.', + long_description=long_description, + long_description_content_type='text/markdown', + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Intended Audience :: Science/Research', + 'License :: OSI Approved :: BSD License', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: C++', + ], + project_urls={'Source': 'https://github.com/arbor-sim/arbor', + 'Documentation': 'https://docs.arbor-sim.org', + 'Bug Reports': 'https://github.com/arbor-sim/arbor/issues',},) From acb807e2ab8e821982212999e78c13fbb287a433 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Mon, 6 Dec 2021 20:24:13 +0100 Subject: [PATCH 14/60] Add argparse. --- setup.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index 50d3ad4f3e..4b94cc0e5f 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ P.add_argument('--bundled', metavar='bundled', action='store_const', const='on', default='off', help='Use bundled libs.') P.add_argument('--gpu', metavar='gpu', default='none', help='Enable GPU support.') P.add_argument('--arch', metavar='arch', default='', help='Set processor architecture.') -opt = P.parse_known_args() +opt, _ = P.parse_known_args() print(f"Options {opt}") @@ -31,12 +31,12 @@ zip_safe=False, cmake_args = ['-DARB_WITH_PYTHON=on', '-DPYTHON_EXECUTABLE=' + sys.executable, - f'-DARB_WITH_MPI={opt["mpi"]}', - f'-DARB_VECTORIZE={opt["vec"]}' - f'-DARB_ARCH={opt["arch"]}', - f'-DARB_GPU={opt["gpu"]}', - f'-DARB_WITH_NEUROML={opt["nml"]}', - f'-DARB_USE_BUNDLED_LIBS={opt["bundled"]}', + f'-DARB_WITH_MPI={opt.mpi}', + f'-DARB_VECTORIZE={opt.vec}' + f'-DARB_ARCH={opt.arch}', + f'-DARB_GPU={opt.gpu}', + f'-DARB_WITH_NEUROML={opt.nml}', + f'-DARB_USE_BUNDLED_LIBS={opt.bundled}', '-DCMAKE_BUILD_TYPE=Release'], author='The Arbor dev team.', url='https://github.com/arbor-sim/arbor', From 79a527396c9a101d3d9328523728df1299d957b9 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Mon, 6 Dec 2021 20:46:05 +0100 Subject: [PATCH 15/60] Clean-up. --- setup.py | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/setup.py b/setup.py index 28fe7914dc..ff58458e93 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,9 @@ -import os +from pathlib import Path import sys from skbuild import setup +from argparse import ArgumentParser -import argparse - -P = argparse.ArgumentParser(description='Arbor build options.') +P = ArgumentParser(description='Arbor build options.') P.add_argument('--vec', dest='vec', action='store_const', const='on', default='off', help='Enable SIMD.') P.add_argument('--nml', dest='nml', action='store_const', const='on', default='off', help='Enable NeuroML2 support. Requires libxml2.') P.add_argument('--mpi', dest='mpi', action='store_const', const='on', default='off', help='Enable MPI.') @@ -13,47 +12,45 @@ P.add_argument('--arch', metavar='arch', default='', help='Set processor architecture.') opt, _ = P.parse_known_args() -print(f"Options {opt}") +# Get directory in which this script resides +here = Path(__file__).resolve().parent -# VERSION is in the same path as setup.py -here = os.path.abspath(os.path.dirname(__file__)) -with open(os.path.join(here, 'VERSION')) as version_file: - version_ = version_file.read().strip() +# Read version file +with open(here / 'VERSION') as fd: + arbor_version = fd.read().strip() # Get the contents of the readme -with open(os.path.join(here, 'python/readme.md'), encoding='utf-8') as f: - long_description = f.read() +with open(here / 'python' / 'readme.md', encoding='utf-8') as fd: + long_description = fd.read() setup(name='arbor', - version=version_, + version=arbor_version, python_requires='>=3.6', install_requires=['numpy'], setup_requires=[], zip_safe=False, cmake_args = ['-DARB_WITH_PYTHON=on', - '-DPYTHON_EXECUTABLE=' + sys.executable, + '-DCMAKE_BUILD_TYPE=Release' + f'-DPYTHON_EXECUTABLE={sys.executable}', f'-DARB_WITH_MPI={opt.mpi}', f'-DARB_VECTORIZE={opt.vec}' f'-DARB_ARCH={opt.arch}', f'-DARB_GPU={opt.gpu}', f'-DARB_WITH_NEUROML={opt.nml}', - f'-DARB_USE_BUNDLED_LIBS={opt.bundled}', - '-DCMAKE_BUILD_TYPE=Release'], + f'-DARB_USE_BUNDLED_LIBS={opt.bundled}',], author='The Arbor dev team.', url='https://github.com/arbor-sim/arbor', description='High performance simulation of networks of multicompartment neurons.', long_description=long_description, long_description_content_type='text/markdown', - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: BSD License', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: C++', - ], + classifiers=['Development Status :: 5 - Production/Stable', + 'Intended Audience :: Science/Research', + 'License :: OSI Approved :: BSD License', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: C++',], project_urls={'Source': 'https://github.com/arbor-sim/arbor', 'Documentation': 'https://docs.arbor-sim.org', 'Bug Reports': 'https://github.com/arbor-sim/arbor/issues',},) From 171670a7c5993388e43bf61b2f60f29c04c6e776 Mon Sep 17 00:00:00 2001 From: Brent Huisman Date: Mon, 13 Dec 2021 13:07:35 +0100 Subject: [PATCH 16/60] Update ciwheel workflow for scikitbuild --- .github/workflows/ciwheel.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ciwheel.yml b/.github/workflows/ciwheel.yml index e8078084b6..ef48904c57 100644 --- a/.github/workflows/ciwheel.yml +++ b/.github/workflows/ciwheel.yml @@ -6,6 +6,9 @@ on: tags: - v* + schedule: + - cron: '0 2 * * 0' # run at 2 AM every sunday + jobs: build_binary_wheels: name: Build wheels on ${{ matrix.os }} @@ -22,11 +25,12 @@ jobs: - name: Build wheels Linux if: ${{ startsWith(matrix.os, 'ubuntu') }} - uses: pypa/cibuildwheel@v1.9.0 + uses: pypa/cibuildwheel@v2.3.0 with: output-dir: dist env: - CIBW_BEFORE_BUILD: python -m pip install numpy setuptools + CIBW_BEFORE_ALL: yum -y install libxml2-devel + CIBW_BEFORE_BUILD: python -m pip install numpy setuptools scikit-build ninja cmake CIBW_BUILD: "cp3?-manylinux_x86_64" CIBW_SKIP: "cp35-*" CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 @@ -35,12 +39,12 @@ jobs: - name: Build wheels macos if: ${{ startsWith(matrix.os, 'macos') }} - uses: pypa/cibuildwheel@v1.9.0 + uses: pypa/cibuildwheel@v2.3.0 with: output-dir: dist env: MACOSX_DEPLOYMENT_TARGET: "10.15" #needed to undo some CIBW settings - CIBW_BEFORE_BUILD: python -m pip install numpy setuptools + CIBW_BEFORE_BUILD: python -m pip install numpy setuptools scikit-build ninja cmake CIBW_BUILD: "cp3?-macosx_x86_64" CIBW_SKIP: "cp35-*" CIBW_ARCHS_MACOS: x86_64 universal2 @@ -61,6 +65,8 @@ jobs: steps: - name: Set up Python uses: actions/setup-python@v2 + - name: Get packages + run: python -m pip install numpy setuptools scikit-build ninja cmake - uses: actions/checkout@v2 with: fetch-depth: 0 From 1cde19425c6e7235ff986ac4ec34961765372227 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Thu, 16 Dec 2021 14:04:59 +0100 Subject: [PATCH 17/60] Merge. --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index ff58458e93..6a2d409ce7 100644 --- a/setup.py +++ b/setup.py @@ -38,6 +38,7 @@ f'-DARB_GPU={opt.gpu}', f'-DARB_WITH_NEUROML={opt.nml}', f'-DARB_USE_BUNDLED_LIBS={opt.bundled}',], + packages=['arbor'], author='The Arbor dev team.', url='https://github.com/arbor-sim/arbor', description='High performance simulation of networks of multicompartment neurons.', From 0ca90a2a71490f8132e09eb9a27f2d443e9e5139 Mon Sep 17 00:00:00 2001 From: Brent Huisman Date: Thu, 23 Dec 2021 14:22:08 +0100 Subject: [PATCH 18/60] no more argparse --- setup.py | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/setup.py b/setup.py index 28fe7914dc..0db6a55db0 100644 --- a/setup.py +++ b/setup.py @@ -2,18 +2,15 @@ import sys from skbuild import setup -import argparse - -P = argparse.ArgumentParser(description='Arbor build options.') -P.add_argument('--vec', dest='vec', action='store_const', const='on', default='off', help='Enable SIMD.') -P.add_argument('--nml', dest='nml', action='store_const', const='on', default='off', help='Enable NeuroML2 support. Requires libxml2.') -P.add_argument('--mpi', dest='mpi', action='store_const', const='on', default='off', help='Enable MPI.') -P.add_argument('--bundled', metavar='bundled', action='store_const', const='on', default='off', help='Use bundled libs.') -P.add_argument('--gpu', metavar='gpu', default='none', help='Enable GPU support.') -P.add_argument('--arch', metavar='arch', default='', help='Set processor architecture.') -opt, _ = P.parse_known_args() - -print(f"Options {opt}") +# Hard coded, because scikit-build does not do build options. +# Override by instructing CMAKE, e.g.: +# pip install . -- -DARB_USE_BUNDLED_LIBS=ON -DARB_WITH_MPI=ON -DARB_GPU=cuda +opt = {'mpi': False, + 'gpu': 'none', + 'vec': False, + 'arch': 'none', + 'neuroml': True, + 'bundled': True} # VERSION is in the same path as setup.py here = os.path.abspath(os.path.dirname(__file__)) @@ -32,12 +29,12 @@ zip_safe=False, cmake_args = ['-DARB_WITH_PYTHON=on', '-DPYTHON_EXECUTABLE=' + sys.executable, - f'-DARB_WITH_MPI={opt.mpi}', - f'-DARB_VECTORIZE={opt.vec}' - f'-DARB_ARCH={opt.arch}', - f'-DARB_GPU={opt.gpu}', - f'-DARB_WITH_NEUROML={opt.nml}', - f'-DARB_USE_BUNDLED_LIBS={opt.bundled}', + f'-DARB_WITH_MPI={opt["mpi"]}', + f'-DARB_VECTORIZE={opt["vec"]}' + f'-DARB_ARCH={opt["arch"]}', + f'-DARB_GPU={opt["gpu"]}', + f'-DARB_WITH_NEUROML={opt["neuroml"]}', + f'-DARB_USE_BUNDLED_LIBS={opt["bundled"]}', '-DCMAKE_BUILD_TYPE=Release'], author='The Arbor dev team.', url='https://github.com/arbor-sim/arbor', @@ -52,6 +49,7 @@ 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', 'Programming Language :: C++', ], project_urls={'Source': 'https://github.com/arbor-sim/arbor', From e864fce3b9311abac790d93eb20f35348d4d093c Mon Sep 17 00:00:00 2001 From: Brent Huisman Date: Thu, 23 Dec 2021 14:46:38 +0100 Subject: [PATCH 19/60] run tests on wheel --- .github/workflows/ciwheel.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ciwheel.yml b/.github/workflows/ciwheel.yml index ef48904c57..9dcbf6de8a 100644 --- a/.github/workflows/ciwheel.yml +++ b/.github/workflows/ciwheel.yml @@ -35,7 +35,7 @@ jobs: CIBW_SKIP: "cp35-*" CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 CIBW_ARCHS_LINUX: x86_64 - # CIBW_TEST_COMMAND: TODO + CIBW_TEST_COMMAND: python -m unittest discover -v -s python - name: Build wheels macos if: ${{ startsWith(matrix.os, 'macos') }} @@ -48,7 +48,7 @@ jobs: CIBW_BUILD: "cp3?-macosx_x86_64" CIBW_SKIP: "cp35-*" CIBW_ARCHS_MACOS: x86_64 universal2 - # CIBW_TEST_COMMAND: TODO + CIBW_TEST_COMMAND: python -m unittest discover -v -s python # this action runs auditwheel automatically with the following args: # https://cibuildwheel.readthedocs.io/en/stable/options/#repair-wheel-command From 23284f12c3132910308ef5a7ece116f3585a5968 Mon Sep 17 00:00:00 2001 From: Brent Huisman Date: Fri, 7 Jan 2022 16:17:17 +0100 Subject: [PATCH 20/60] correct path --- .github/workflows/ciwheel.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ciwheel.yml b/.github/workflows/ciwheel.yml index 9dcbf6de8a..66150ab85f 100644 --- a/.github/workflows/ciwheel.yml +++ b/.github/workflows/ciwheel.yml @@ -35,7 +35,7 @@ jobs: CIBW_SKIP: "cp35-*" CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 CIBW_ARCHS_LINUX: x86_64 - CIBW_TEST_COMMAND: python -m unittest discover -v -s python + CIBW_TEST_COMMAND: python -m unittest discover -v -s {project}/python - name: Build wheels macos if: ${{ startsWith(matrix.os, 'macos') }} @@ -48,7 +48,7 @@ jobs: CIBW_BUILD: "cp3?-macosx_x86_64" CIBW_SKIP: "cp35-*" CIBW_ARCHS_MACOS: x86_64 universal2 - CIBW_TEST_COMMAND: python -m unittest discover -v -s python + CIBW_TEST_COMMAND: python -m unittest discover -v -s {project}/python # this action runs auditwheel automatically with the following args: # https://cibuildwheel.readthedocs.io/en/stable/options/#repair-wheel-command From 76fb9128ceac97a002729b2d29f680a453e7b495 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Mon, 10 Jan 2022 10:01:32 +0100 Subject: [PATCH 21/60] Add extra mechanisms to scripts. --- mechanisms/BuildModules.cmake | 11 +++++-- mechanisms/CMakeLists.txt | 3 ++ scripts/build-catalogue.in | 61 ++++++++++++++++++++++++----------- 3 files changed, 55 insertions(+), 20 deletions(-) diff --git a/mechanisms/BuildModules.cmake b/mechanisms/BuildModules.cmake index 38f466f0ab..ae70e89fb7 100644 --- a/mechanisms/BuildModules.cmake +++ b/mechanisms/BuildModules.cmake @@ -58,7 +58,7 @@ function(build_modules) endfunction() function("make_catalogue") - cmake_parse_arguments(MK_CAT "" "NAME;SOURCES;OUTPUT;PREFIX;STANDALONE;VERBOSE" "CXX_FLAGS_TARGET;MECHS" ${ARGN}) + cmake_parse_arguments(MK_CAT "" "NAME;SOURCES;OUTPUT;PREFIX;STANDALONE;VERBOSE" "CXX_FLAGS_TARGET;MECHS;EXTRA" ${ARGN}) set(MK_CAT_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated/${MK_CAT_NAME}") # Need to set ARB_WITH_EXTERNAL_MODCC *and* modcc @@ -70,6 +70,7 @@ function("make_catalogue") if(MK_CAT_VERBOSE) message("Catalogue name: ${MK_CAT_NAME}") message("Catalogue mechanisms: ${MK_CAT_MECHS}") + message("Extra cxx files: ${MK_CAT_EXTRA}") message("Catalogue sources: ${MK_CAT_SOURCES}") message("Catalogue output: ${MK_CAT_OUT_DIR}") message("Build as standalone: ${MK_CAT_STANDALONE}") @@ -102,7 +103,7 @@ function("make_catalogue") add_custom_command( OUTPUT ${catalogue_${MK_CAT_NAME}_source} - COMMAND ${MK_CAT_PREFIX}/generate_catalogue ${catalogue_${MK_CAT_NAME}_options} ${MK_CAT_MECHS} + COMMAND ${MK_CAT_PREFIX}/generate_catalogue ${catalogue_${MK_CAT_NAME}_options} ${MK_CAT_MECHS} ${MK_CAT_EXTRA} COMMENT "Building catalogue ${MK_CAT_NAME}" DEPENDS ${MK_CAT_PREFIX}/generate_catalogue) @@ -116,6 +117,12 @@ function("make_catalogue") list(APPEND catalogue_${MK_CAT_NAME}_source ${MK_CAT_OUT_DIR}/${mech}_gpu.cpp ${MK_CAT_OUT_DIR}/${mech}_gpu.cu) endif() endforeach() + foreach(mech ${MK_CAT_EXTRA}) + list(APPEND catalogue_${MK_CAT_NAME}_source ${MK_CAT_OUT_DIR}/${mech}_cpu.cpp) + if(ARB_WITH_GPU) + list(APPEND catalogue_${MK_CAT_NAME}_source ${MK_CAT_OUT_DIR}/${mech}_gpu.cpp ${MK_CAT_OUT_DIR}/${mech}_gpu.cu) + endif() + endforeach() set(${MK_CAT_OUTPUT} ${catalogue_${MK_CAT_NAME}_source} PARENT_SCOPE) if(${MK_CAT_STANDALONE}) diff --git a/mechanisms/CMakeLists.txt b/mechanisms/CMakeLists.txt index ac69ce9402..bec15813cf 100644 --- a/mechanisms/CMakeLists.txt +++ b/mechanisms/CMakeLists.txt @@ -6,6 +6,7 @@ make_catalogue( SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/bbp" OUTPUT "CAT_BBP_SOURCES" MECHS CaDynamics_E2 Ca_HVA Ca_LVAst Ih Im K_Pst K_Tst Nap_Et2 NaTa_t NaTs2_t SK_E2 SKv3_1 + EXTRA PREFIX "${PROJECT_SOURCE_DIR}/mechanisms" CXX_FLAGS_TARGET "${ARB_CXX_FLAGS_TARGET_FULL}" STANDALONE FALSE @@ -16,6 +17,7 @@ make_catalogue( SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/allen" OUTPUT "CAT_ALLEN_SOURCES" MECHS CaDynamics Ca_HVA Ca_LVA Ih Im Im_v2 K_P K_T Kd Kv2like Kv3_1 NaTa NaTs NaV Nap SK + EXTRA PREFIX "${PROJECT_SOURCE_DIR}/mechanisms" CXX_FLAGS_TARGET "${ARB_CXX_FLAGS_TARGET_FULL}" STANDALONE FALSE @@ -26,6 +28,7 @@ make_catalogue( SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/default" OUTPUT "CAT_DEFAULT_SOURCES" MECHS exp2syn expsyn expsyn_stdp hh kamt kdrmt nax nernst pas gj + EXTRA PREFIX "${PROJECT_SOURCE_DIR}/mechanisms" CXX_FLAGS_TARGET "${ARB_CXX_FLAGS_TARGET_FULL}" STANDALONE FALSE diff --git a/scripts/build-catalogue.in b/scripts/build-catalogue.in index b0bf5f54bb..03ca1d4a11 100755 --- a/scripts/build-catalogue.in +++ b/scripts/build-catalogue.in @@ -6,7 +6,6 @@ from tempfile import mkdtemp, TemporaryDirectory import os from pathlib import Path import shutil -import stat import string import argparse import re @@ -40,6 +39,15 @@ def parse_arguments(): type=str, help='Catalogue name.') + parser.add_argument('extra', + metavar='extra', + nargs='+', + type=str, + help='''Advanced: Extra mechanisms as C++ files. Per the +files .hpp, _cpu.cpp must be present +in the target directory and with GPU support +also _gpu.cpp and _gpu.cu''') + parser.add_argument('modpfx', metavar='modpfx', type=str, @@ -69,23 +77,24 @@ def parse_arguments(): action='help', help='Display this help and exit.') - return vars(parser.parse_args()) args = parse_arguments() pwd = Path.cwd() name = re.sub(r'_+', r'_', re.sub(r'[^a-zA-Z0-9_]', r'_', - args['name'])) - -mod_dir = pwd / Path(args['modpfx']) -mods = [ f[:-4] for f in os.listdir(mod_dir) if f.endswith('.mod') ] -verbose = args['verbose'] and not args['quiet'] -quiet = args['quiet'] -debug = args['debug'] - -if args['gpu']: - if args['gpu'] == 'cuda': + args.name)) + +mod_dir = pwd / Path(args.modpfx) +mods = [f[:-4] for f in os.listdir(mod_dir) if f.endswith('.mod')] +quiet = args.quiet +verbose = args.verbose and not quiet +debug = args.debug +extra = args.extra +gpu = args.gpu + +if gpu: + if gpu == 'cuda': gpu_support = """add_compile_definitions(ARB_CUDA) add_compile_definitions(ARB_HAVE_GPU) @@ -93,7 +102,8 @@ enable_language(CUDA) set(CMAKE_CUDA_HOST_COMPILER @CMAKE_CXX_COMPILER@) set(CMAKE_CUDA_ARCHITECTURES @CMAKE_CUDA_ARCHITECTURES@)""" else: - print(f"Unsupported GPU target: {args['gpu']}. If you need support for HIP or Clang-CUDA, please check here: https://github.com/arbor-sim/arbor/issues/1783") + print(f"Unsupported GPU target: {gpu}. If you need support for HIP or Clang-CUDA, please check here: https://github.com/arbor-sim/arbor/issues/1783") + exit(-1) else: gpu_support = "# GPU: Disabled" @@ -102,14 +112,14 @@ data_path = (this_path / "@ARB_REL_DATADIR@").resolve() pack_path = (this_path / "@ARB_REL_PACKAGEDIR@").resolve() exec_path = this_path.resolve() -for i,p in [(exec_path, 'modcc'), - (data_path, 'generate_catalogue'), - (data_path, 'BuildModules.cmake'), - (pack_path, 'arbor-config.cmake'), - ]: +for i, p in [(exec_path, 'modcc'), + (data_path, 'generate_catalogue'), + (data_path, 'BuildModules.cmake'), + (pack_path, 'arbor-config.cmake'),]: path = p / i if not path.exists(): print(f'Could not find required tool: {path}. Please check your installation.') + exit(-1) cmake = f""" cmake_minimum_required(VERSION 3.9) @@ -134,6 +144,7 @@ make_catalogue( SOURCES "${{CMAKE_CURRENT_SOURCE_DIR}}/mod" OUTPUT "CAT_{name.upper()}_SOURCES" MECHS {' '.join(mods)} + EXTRA {' '.join(extra)} PREFIX {data_path} CXX_FLAGS_TARGET ${{ARB_CXX_FLAGS_TARGET}} STANDALONE ON @@ -179,6 +190,20 @@ with TemporaryDirectory() as tmp: shutil.copy2(f'{data_path}/BuildModules.cmake', tmp) shutil.copy2(f'{data_path}/generate_catalogue', tmp) + out = 'generated' + os.mkdir(out) + sfx = [".hpp", "_cpu.cpp"] + if gpu: + sfx += ["_gpu.cpp", "_gpu.cu"] + for e in extra: + for s in sfx: + fn = mod_dir / (e + s) + if not fn.exists(): + print(f'Could not find required file: {fn}. Please check your C++ mechanisms.') + exit(-1) + else: + shutil.copy2(fn, out / fn) + cmake_cmd = 'cmake ..' make_cmd = 'make' if verbose: From 06230aeb233fd6137f025faa54adc44eccf9f2b8 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Mon, 10 Jan 2022 11:54:39 +0100 Subject: [PATCH 22/60] Add override for static libxml2. --- CMakeLists.txt | 5 +++-- arborio/CMakeLists.txt | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ceaf8d5eab..27ce8f9dae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,8 +77,9 @@ option(ARB_WITH_ASSERTIONS "enable arb_assert() assertions in code" OFF) # NeuroML support library: #---------------------------------------------------------- -option(ARB_WITH_NEUROML "build NeuroML support library" OFF) - +option(ARB_WITH_NEUROML "build NeuroML support library" OFF) +option(ARB_LIBXML "path to XML library to link, use with care" "") +mark_as_advanced(ARB_LIBXML_STATIC) #---------------------------------------------------------- # Python front end for Arbor: #---------------------------------------------------------- diff --git a/arborio/CMakeLists.txt b/arborio/CMakeLists.txt index 104afdacef..ceeb614dae 100644 --- a/arborio/CMakeLists.txt +++ b/arborio/CMakeLists.txt @@ -11,8 +11,10 @@ if(ARB_WITH_NEUROML) neuroml.cpp nml_parse_morphology.cpp xml.cpp - xmlwrap.cpp - ) + xmlwrap.cpp) + if(${ARB_LIBXML} STREQUAL "") + set(LIBXML2_LIBRARY ${ARB_LIBXML}) + endif() find_package(LibXml2 REQUIRED) endif() From 7fc3a5755cc1358d9093251569a2ee4b9c014286 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Mon, 10 Jan 2022 12:04:32 +0100 Subject: [PATCH 23/60] Squash annoying warning. --- lmorpho/lsystem.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lmorpho/lsystem.hpp b/lmorpho/lsystem.hpp index 3130ba6487..9dfc45353a 100644 --- a/lmorpho/lsystem.hpp +++ b/lmorpho/lsystem.hpp @@ -8,7 +8,7 @@ struct lsys_param; using lsys_generator = std::minstd_rand; -class lsys_distribution_param; +struct lsys_distribution_param; arb::segment_tree generate_morphology(const lsys_distribution_param& soma, std::vector Ps, lsys_generator& g); // The distribution parameters used in the specification of the L-system parameters. From 09acb0a3cafceb72efbdbfb7b5bbb73636b6adb3 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Mon, 10 Jan 2022 12:04:55 +0100 Subject: [PATCH 24/60] Make extra arg optional --- scripts/build-catalogue.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/build-catalogue.in b/scripts/build-catalogue.in index 03ca1d4a11..e0d5c5aaf1 100755 --- a/scripts/build-catalogue.in +++ b/scripts/build-catalogue.in @@ -39,9 +39,10 @@ def parse_arguments(): type=str, help='Catalogue name.') - parser.add_argument('extra', + parser.add_argument('--extra', metavar='extra', nargs='+', + default=[], type=str, help='''Advanced: Extra mechanisms as C++ files. Per the files .hpp, _cpu.cpp must be present From 02f60b579acc178dd5f3e70cd668a95d883a0dc7 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Mon, 10 Jan 2022 12:09:26 +0100 Subject: [PATCH 25/60] Set default arch. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index f5c1972dea..8de6d35a4d 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ with_mpi = False with_gpu = 'none' with_vec = False -arch = 'none' +arch = 'native' with_nml = True use_libs = True build_type = 'Release' # this is ok even for debugging, as we always produce info From fea3fec5e993cc4db395c69751ed53e881af6c73 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Mon, 10 Jan 2022 12:22:34 +0100 Subject: [PATCH 26/60] Fix ArgParse. --- scripts/build-catalogue.in | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/build-catalogue.in b/scripts/build-catalogue.in index e0d5c5aaf1..02c83ed4c7 100755 --- a/scripts/build-catalogue.in +++ b/scripts/build-catalogue.in @@ -84,15 +84,15 @@ args = parse_arguments() pwd = Path.cwd() name = re.sub(r'_+', r'_', re.sub(r'[^a-zA-Z0-9_]', r'_', - args.name)) + args['name'])) -mod_dir = pwd / Path(args.modpfx) +mod_dir = pwd / Path(args['modpfx']) mods = [f[:-4] for f in os.listdir(mod_dir) if f.endswith('.mod')] -quiet = args.quiet -verbose = args.verbose and not quiet -debug = args.debug -extra = args.extra -gpu = args.gpu +quiet = args['quiet'] +verbose = args['verbose'] and not quiet +debug = args['debug'] +extra = args['extra'] +gpu = args['gpu'] if gpu: if gpu == 'cuda': From 5dae91419678fdbdd90579404a79c0c43435de79 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Mon, 10 Jan 2022 14:12:58 +0100 Subject: [PATCH 27/60] Fix script, rename extra->raw, add docs. --- doc/concepts/mechanisms.rst | 14 ++++----- doc/internals/extending_catalogues.rst | 6 ++++ doc/internals/mechanism_abi.rst | 42 ++++++++++++++++++++++++++ scripts/build-catalogue.in | 40 +++++++++++++----------- 4 files changed, 78 insertions(+), 24 deletions(-) diff --git a/doc/concepts/mechanisms.rst b/doc/concepts/mechanisms.rst index 445347df7a..11bb5eda7e 100644 --- a/doc/concepts/mechanisms.rst +++ b/doc/concepts/mechanisms.rst @@ -90,17 +90,17 @@ This will produce a catalogue loadable at runtime by calling ``load_catalogue`` with a filename in both C++ and Python. The steps are 1. Prepare a directory containing your NMODL files (.mod suffixes required) -2. Call ``build-catalogue`` installed by arbor +2. Call ``arbor-build-catalogue`` installed by arbor .. code-block :: bash - build-catalogue - -All files with the suffix ``.mod`` located in ```` will be baked into -a catalogue named ``lib-catalogue.so`` and placed into your current working -directory. Note that these files are platform-specific and should only be used -on the combination of OS, compiler, arbor, and machine they were built with. + arbor-build-catalogue +All files with the suffix ``.mod`` located in ```` will be baked +into a catalogue named ``lib-catalogue.so`` and placed into your current +working directory. Note that these files are platform-specific and should only +be used on the combination of OS, compiler, arbor, and machine they were built +with. See our internal documentation for more advanced usage of the builder. Errors might be diagnosable by passing the ``-v`` flag. This catalogue can then be used similarly to the built-in ones diff --git a/doc/internals/extending_catalogues.rst b/doc/internals/extending_catalogues.rst index 1e954d1910..7411f0ffac 100644 --- a/doc/internals/extending_catalogues.rst +++ b/doc/internals/extending_catalogues.rst @@ -32,6 +32,7 @@ produce a catalogue of the same level of integration as the built-in catalogues SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/default" # Directory name (added above) OUTPUT "CAT_DEFAULT_SOURCES" # Variable name to store C++ files into (see below) MECHS exp2syn expsyn expsyn_stdp hh kamt kdrmt nax nernst pas # Space separated list of mechanisms w/o .mod suffix. + EXTRA # Not needed, see below. PREFIX "${PROJECT_SOURCE_DIR}/mechanisms" # where does 'generate_catalogue' live, do not change STANDALONE FALSE # build as shared object, must be OFF VERBOSE OFF) # Print debug info at configuration time @@ -50,3 +51,8 @@ produce a catalogue of the same level of integration as the built-in catalogues 7. Bind this function in ``python/mechanisms.cpp``. All steps can be more or less copied from the surrounding code. + +.. note:: + + If you are sure of your understanding you can write mechanisms in C/C++ + directly against Arbor's ABI. See :ref:`here ` for more. diff --git a/doc/internals/mechanism_abi.rst b/doc/internals/mechanism_abi.rst index df5d4250d3..f344dc44cd 100644 --- a/doc/internals/mechanism_abi.rst +++ b/doc/internals/mechanism_abi.rst @@ -454,3 +454,45 @@ supported. The naming scheme is shown in the example below arb_mechanism_type make_arb_default_catalogue_pas(); arb_mechanism_interface* make_arb_default_catalogue_pas_interface_multicore(); arb_mechanism_interface* make_arb_default_catalogue_pas_interface_gpu(); + +Writing Mechanisms Directly Against the ABI +------------------------------------------- + +.. warning:: + + This is a measure of last resort. Usage is not recommended unless you have a + dire need and a solid understanding of Arbor, its internals, and the ABI. + +If your use case requires features not supported in NMODL, you can write mechanisms +in C++ directly. See the ABI documentation for what callbacks need to be filled in. +These mechanisms can be compiled with ``arbor-build-catalogue`` as well and must be +present in the same folder as the NMODL files. Example + +.. code-block:: + + $> ls mod + A.mod + B.hpp B_cpu.cpp B_gpu.cpp B_gpu.cu + C.hpp C_cpu.cpp C_gpu.cpp C_gpu.cu + $> arbor-build-catalogue my mod --raw B C + Building catalogue 'my' from mechanisms in 'mod' + * NMODL + * A + * Raw + * B + * C + +The ``--raw`` flag must go last due to the argument parsing. + +For this to compile, the following must be upheld: + +- For each mechanism ``M`` these files must be present + - ``M.hpp`` must define the mechanism metadata and declare the used interfaces. + - ``M_cpu.cpp`` must define the CPU interface. + - If GPU support is used + - ``M_gpu.cpp`` must define the GPU interface. + - ``M_gpu.cu`` must defile CUDA kernels. +- The interface names must adhere to the chosen catalogue name, eg here ``make_arb_my_catalogue_B_interface_multicore();`` + - names may only contain alphanumeric characters and underscores. + - names must not contain multiple successive underscores. + - in general, a valid C variable name should be used. diff --git a/scripts/build-catalogue.in b/scripts/build-catalogue.in index 02c83ed4c7..af21fc76f0 100755 --- a/scripts/build-catalogue.in +++ b/scripts/build-catalogue.in @@ -39,12 +39,12 @@ def parse_arguments(): type=str, help='Catalogue name.') - parser.add_argument('--extra', - metavar='extra', + parser.add_argument('--raw', + metavar='raw', nargs='+', default=[], type=str, - help='''Advanced: Extra mechanisms as C++ files. Per the + help='''Advanced: Raw mechanisms as C++ files. Per the files .hpp, _cpu.cpp must be present in the target directory and with GPU support also _gpu.cpp and _gpu.cu''') @@ -91,7 +91,7 @@ mods = [f[:-4] for f in os.listdir(mod_dir) if f.endswith('.mod')] quiet = args['quiet'] verbose = args['verbose'] and not quiet debug = args['debug'] -extra = args['extra'] +raw = args['raw'] gpu = args['gpu'] if gpu: @@ -145,7 +145,7 @@ make_catalogue( SOURCES "${{CMAKE_CURRENT_SOURCE_DIR}}/mod" OUTPUT "CAT_{name.upper()}_SOURCES" MECHS {' '.join(mods)} - EXTRA {' '.join(extra)} + EXTRA {' '.join(raw)} PREFIX {data_path} CXX_FLAGS_TARGET ${{ARB_CXX_FLAGS_TARGET}} STANDALONE ON @@ -156,8 +156,14 @@ if not quiet: print(f"Building catalogue '{name}' from mechanisms in {mod_dir}") if debug: print("Debug mode enabled.") - for m in mods: - print(" *", m) + if mods: + print(" * NMODL") + for m in mods: + print(" *", m) + if raw: + print(" * Raw") + for m in raw: + print(" *", m) if debug: # Overwrite the local reference to `TemporaryDirectory` with a context @@ -191,19 +197,19 @@ with TemporaryDirectory() as tmp: shutil.copy2(f'{data_path}/BuildModules.cmake', tmp) shutil.copy2(f'{data_path}/generate_catalogue', tmp) - out = 'generated' - os.mkdir(out) + out = tmp / 'build' / 'generated' / name + os.makedirs(out, exist_ok=True) sfx = [".hpp", "_cpu.cpp"] if gpu: sfx += ["_gpu.cpp", "_gpu.cu"] - for e in extra: - for s in sfx: - fn = mod_dir / (e + s) - if not fn.exists(): - print(f'Could not find required file: {fn}. Please check your C++ mechanisms.') - exit(-1) - else: - shutil.copy2(fn, out / fn) + for e in raw: + for s in sfx: + fn = mod_dir / (e + s) + if not fn.exists(): + print(f'Could not find required file: {fn}. Please check your C++ mechanisms.') + exit(-1) + else: + shutil.copy2(fn, out / (e + s)) cmake_cmd = 'cmake ..' make_cmd = 'make' From 10fb032fd63e886a0d86a2053764a1e06d7011cc Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Mon, 10 Jan 2022 14:27:47 +0100 Subject: [PATCH 28/60] Fix RST. --- doc/internals/mechanism_abi.rst | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/doc/internals/mechanism_abi.rst b/doc/internals/mechanism_abi.rst index f344dc44cd..c12b60f98c 100644 --- a/doc/internals/mechanism_abi.rst +++ b/doc/internals/mechanism_abi.rst @@ -487,12 +487,21 @@ The ``--raw`` flag must go last due to the argument parsing. For this to compile, the following must be upheld: - For each mechanism ``M`` these files must be present + - ``M.hpp`` must define the mechanism metadata and declare the used interfaces. + - ``M_cpu.cpp`` must define the CPU interface. + - If GPU support is used - - ``M_gpu.cpp`` must define the GPU interface. - - ``M_gpu.cu`` must defile CUDA kernels. + + - ``M_gpu.cpp`` must define the GPU interface. + + - ``M_gpu.cu`` must define CUDA kernels. + - The interface names must adhere to the chosen catalogue name, eg here ``make_arb_my_catalogue_B_interface_multicore();`` + - names may only contain alphanumeric characters and underscores. + - names must not contain multiple successive underscores. + - in general, a valid C variable name should be used. From 0ad62ed8a9455441c3e75c9915af8c366b39162a Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Mon, 10 Jan 2022 14:35:34 +0100 Subject: [PATCH 29/60] Typo. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 27ce8f9dae..5c4c81b709 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,7 +79,7 @@ option(ARB_WITH_ASSERTIONS "enable arb_assert() assertions in code" OFF) option(ARB_WITH_NEUROML "build NeuroML support library" OFF) option(ARB_LIBXML "path to XML library to link, use with care" "") -mark_as_advanced(ARB_LIBXML_STATIC) +mark_as_advanced(ARB_LIBXML) #---------------------------------------------------------- # Python front end for Arbor: #---------------------------------------------------------- From ac60decce163996eb334c695b2e7e7246e561e0a Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Tue, 11 Jan 2022 11:05:47 +0100 Subject: [PATCH 30/60] Fix negation. --- arborio/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arborio/CMakeLists.txt b/arborio/CMakeLists.txt index ceeb614dae..0162a988a0 100644 --- a/arborio/CMakeLists.txt +++ b/arborio/CMakeLists.txt @@ -12,7 +12,7 @@ if(ARB_WITH_NEUROML) nml_parse_morphology.cpp xml.cpp xmlwrap.cpp) - if(${ARB_LIBXML} STREQUAL "") + if(NOT ${ARB_LIBXML} STREQUAL "") set(LIBXML2_LIBRARY ${ARB_LIBXML}) endif() find_package(LibXml2 REQUIRED) From f172d4aafa352bfcd856fed43b12acd49655ae8c Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Tue, 11 Jan 2022 11:15:23 +0100 Subject: [PATCH 31/60] Fix option -> cache variable. --- CMakeLists.txt | 3 ++- arborio/CMakeLists.txt | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c4c81b709..78a4654525 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,7 +78,8 @@ option(ARB_WITH_ASSERTIONS "enable arb_assert() assertions in code" OFF) #---------------------------------------------------------- option(ARB_WITH_NEUROML "build NeuroML support library" OFF) -option(ARB_LIBXML "path to XML library to link, use with care" "") + +set(ARB_LIBXML "" CACHE STRING "path to XML library to link, use with care") mark_as_advanced(ARB_LIBXML) #---------------------------------------------------------- # Python front end for Arbor: diff --git a/arborio/CMakeLists.txt b/arborio/CMakeLists.txt index 0162a988a0..dc011a0ebd 100644 --- a/arborio/CMakeLists.txt +++ b/arborio/CMakeLists.txt @@ -15,6 +15,7 @@ if(ARB_WITH_NEUROML) if(NOT ${ARB_LIBXML} STREQUAL "") set(LIBXML2_LIBRARY ${ARB_LIBXML}) endif() + message("-lxml = ${ARB_LIBXML}") find_package(LibXml2 REQUIRED) endif() From 8d1881292b4fd09475ae133cd97b10a07bb1eb42 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Tue, 11 Jan 2022 11:37:08 +0100 Subject: [PATCH 32/60] Revert native -> none --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 8de6d35a4d..f5c1972dea 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ with_mpi = False with_gpu = 'none' with_vec = False -arch = 'native' +arch = 'none' with_nml = True use_libs = True build_type = 'Release' # this is ok even for debugging, as we always produce info From 3a07d05dcef49f7cde8a0862e228eb375962c9b3 Mon Sep 17 00:00:00 2001 From: Brent Huisman Date: Tue, 11 Jan 2022 11:42:18 +0100 Subject: [PATCH 33/60] pull in libxml2-static in github workflow --- .github/workflows/ciwheel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ciwheel.yml b/.github/workflows/ciwheel.yml index 66150ab85f..510bfc4cf8 100644 --- a/.github/workflows/ciwheel.yml +++ b/.github/workflows/ciwheel.yml @@ -29,7 +29,7 @@ jobs: with: output-dir: dist env: - CIBW_BEFORE_ALL: yum -y install libxml2-devel + CIBW_BEFORE_ALL: yum -y install libxml2-devel libxml2-static CIBW_BEFORE_BUILD: python -m pip install numpy setuptools scikit-build ninja cmake CIBW_BUILD: "cp3?-manylinux_x86_64" CIBW_SKIP: "cp35-*" From a4206d2a8219c74ef985c5b5f19ca8f7401ed4a3 Mon Sep 17 00:00:00 2001 From: Brent Huisman Date: Tue, 11 Jan 2022 12:37:24 +0100 Subject: [PATCH 34/60] static libxml2 for build in PyPA images --- setup.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup.py b/setup.py index f5c1972dea..4c36548ba0 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,7 @@ from pathlib import Path from sys import executable as python from skbuild import setup +import os # Hard coded options, because scikit-build does not do build options. # Override by instructing CMAKE, e.g.: @@ -29,6 +30,8 @@ setup_requires=[], zip_safe=False, cmake_args=['-DARB_WITH_PYTHON=on', + # if env var CIBUILDWHEEL set, then assume in PyPA image building wheels and use static libxml2 + f'-DARB_LIBXML=/usr/lib64/libxml2.a' if os.environ.get('CIBUILDWHEEL') not None else '', f'-DPYTHON_EXECUTABLE={python}', f'-DARB_WITH_MPI={with_mpi}', f'-DARB_VECTORIZE={with_vec}' From 99a9cc331792801dcbd741e44163348daee098a0 Mon Sep 17 00:00:00 2001 From: Brent Huisman Date: Tue, 11 Jan 2022 12:41:38 +0100 Subject: [PATCH 35/60] typo --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 4c36548ba0..90724f254c 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,7 @@ zip_safe=False, cmake_args=['-DARB_WITH_PYTHON=on', # if env var CIBUILDWHEEL set, then assume in PyPA image building wheels and use static libxml2 - f'-DARB_LIBXML=/usr/lib64/libxml2.a' if os.environ.get('CIBUILDWHEEL') not None else '', + f'-DARB_LIBXML=/usr/lib64/libxml2.a' if os.environ.get('CIBUILDWHEEL') is not None else '', f'-DPYTHON_EXECUTABLE={python}', f'-DARB_WITH_MPI={with_mpi}', f'-DARB_VECTORIZE={with_vec}' From faa4395d3e2564183dd4648c32006ec354a7c017 Mon Sep 17 00:00:00 2001 From: Brent Huisman Date: Tue, 11 Jan 2022 14:15:04 +0100 Subject: [PATCH 36/60] clearer cmake_args setting --- setup.py | 72 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/setup.py b/setup.py index 90724f254c..a53cfea97a 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ from pathlib import Path from sys import executable as python from skbuild import setup -import os +import os,platform # Hard coded options, because scikit-build does not do build options. # Override by instructing CMAKE, e.g.: @@ -14,6 +14,20 @@ use_libs = True build_type = 'Release' # this is ok even for debugging, as we always produce info +cmake_args = ['-DARB_WITH_PYTHON=on', + f'-DPYTHON_EXECUTABLE={python}', + f'-DARB_WITH_MPI={with_mpi}', + f'-DARB_VECTORIZE={with_vec}' + f'-DARB_ARCH={arch}', + f'-DARB_GPU={with_gpu}', + f'-DARB_WITH_NEUROML={with_nml}', + f'-DARB_USE_BUNDLED_LIBS={use_libs}', + f'-DCMAKE_BUILD_TYPE={build_type}'] +# For cibuildwheel builds, which build the Python wheels meant for PyPI, we use the static library of libxml2. +# This gets us around this issue with skbuild: https://github.com/pypa/auditwheel/issues/363 +if 'linux' in str(platform.system()).lower() and os.environ.get('CIBUILDWHEEL') is not None: + cmake_args.append(f'-DARB_LIBXML=/usr/lib64/libxml2.a') + # Find our dir; *should* be the arbor checkout here = Path(__file__).resolve().parent # Read version file @@ -24,36 +38,26 @@ long_description = fd.read() setup(name='arbor', - version=arbor_version, - python_requires='>=3.6', - install_requires=['numpy'], - setup_requires=[], - zip_safe=False, - cmake_args=['-DARB_WITH_PYTHON=on', - # if env var CIBUILDWHEEL set, then assume in PyPA image building wheels and use static libxml2 - f'-DARB_LIBXML=/usr/lib64/libxml2.a' if os.environ.get('CIBUILDWHEEL') is not None else '', - f'-DPYTHON_EXECUTABLE={python}', - f'-DARB_WITH_MPI={with_mpi}', - f'-DARB_VECTORIZE={with_vec}' - f'-DARB_ARCH={arch}', - f'-DARB_GPU={with_gpu}', - f'-DARB_WITH_NEUROML={with_nml}', - f'-DARB_USE_BUNDLED_LIBS={use_libs}', - f'-DCMAKE_BUILD_TYPE={build_type}',], - author='The Arbor dev team.', - url='https://github.com/arbor-sim/arbor', - description='High performance simulation of networks of multicompartment neurons.', - long_description=long_description, - long_description_content_type='text/markdown', - classifiers=['Development Status :: 5 - Production/Stable', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: BSD License', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: C++',], - project_urls={'Source': 'https://github.com/arbor-sim/arbor', - 'Documentation': 'https://docs.arbor-sim.org', - 'Bug Reports': 'https://github.com/arbor-sim/arbor/issues',},) + version=arbor_version, + python_requires='>=3.6', + install_requires=['numpy'], + setup_requires=[], + zip_safe=False, + cmake_args=cmake_args, + author='The Arbor dev team.', + url='https://arbor-sim.org', + description='High performance simulation of networks of multicompartment neurons.', + long_description=long_description, + long_description_content_type='text/markdown', + classifiers=['Development Status :: 5 - Production/Stable', + 'Intended Audience :: Science/Research', + 'License :: OSI Approved :: BSD License', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: C++',], + project_urls={'Source': 'https://github.com/arbor-sim/arbor', + 'Documentation': 'https://docs.arbor-sim.org', + 'Bug Reports': 'https://github.com/arbor-sim/arbor/issues',},) From 8934a084049e3f63d86aae4e3e1107b0e4d746a2 Mon Sep 17 00:00:00 2001 From: Brent Huisman Date: Tue, 11 Jan 2022 14:49:10 +0100 Subject: [PATCH 37/60] expand arbor.config() with nml and bundled info; add build-wheels.sh script --- arbor/include/CMakeLists.txt | 4 ++++ python/config.cpp | 10 ++++++++++ scripts/build-wheels.sh | 31 +++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100755 scripts/build-wheels.sh diff --git a/arbor/include/CMakeLists.txt b/arbor/include/CMakeLists.txt index 82415e4f7c..1cfc13b0c0 100644 --- a/arbor/include/CMakeLists.txt +++ b/arbor/include/CMakeLists.txt @@ -46,6 +46,10 @@ if(ARB_WITH_PROFILING) # define ARB_PROFILE_ENABLED in version.hpp list(APPEND arb_features PROFILE) endif() +if(ARB_USE_BUNDLED_LIBS) + # define ARB_BUNDLED_ENABLED in version.hpp + list(APPEND arb_features BUNDLED) +endif() if(ARB_VECTORIZE) list(APPEND arb_features VECTORIZE) endif() diff --git a/python/config.cpp b/python/config.cpp index 3de7f86d7d..efe50545ed 100644 --- a/python/config.cpp +++ b/python/config.cpp @@ -38,6 +38,16 @@ pybind11::dict config() { dict[pybind11::str("profiling")] = pybind11::bool_(true); #else dict[pybind11::str("profiling")] = pybind11::bool_(false); +#endif +#ifdef ARB_NEUROML_ENABLED + dict[pybind11::str("neuroml")] = pybind11::bool_(true); +#else + dict[pybind11::str("neuroml")] = pybind11::bool_(false); +#endif +#ifdef ARB_BUNDLED_ENABLED + dict[pybind11::str("bundled")] = pybind11::bool_(true); +#else + dict[pybind11::str("bundled")] = pybind11::bool_(false); #endif dict[pybind11::str("version")] = pybind11::str(ARB_VERSION); dict[pybind11::str("source")] = pybind11::str(ARB_SOURCE_ID); diff --git a/scripts/build-wheels.sh b/scripts/build-wheels.sh new file mode 100755 index 0000000000..68526a08cd --- /dev/null +++ b/scripts/build-wheels.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# A script that can be ran in the PyPA manywheel containers if you want to produce uploadable wheels for PyPI. +# Steps: +# 1. Prepare a (temporary) working directory (referred to as $LOCAL_WORK_DIR). +# 2. Have the version of Arbor you want to build manylinux compliant wheels for available at $LOCAL_WORK_DIR/arbor +# 3. Start an instance of the docker image with $LOCAL_WORK_DIR mounted at /src_dir +# Then, run /src_dir/arbor/scripts/build-wheels.sh +# Using podman, the follow command can be used: +# podman run -v $LOCAL_WORK_DIR:/src_dir:Z -ti quay.io/pypa/manylinux2014_x86_64 /src_dir/arbor/scripts/build-wheels.sh +# 4. After the run is complete, find in $LOCAL_WORK_DIR/wheelhouse the wheels ready for PyPI. +# $LOCAL_WORK_DIR/builtwheel contains the wheel before auditwheel has processed them. Can be discarded, +# or used for analysis in case of build failure. + +set -e -u -x + +yum -y install libxml2-devel libxml2-static +/opt/python/cp39-cp39/bin/pip install ninja cmake +rm -rf /opt/python/cp35-cp35m #skip building for Python 3.5 + +rm -rf /src_dir/arbor/_skbuild + +export CIBUILDWHEEL=1 #Set condition for cmake + +for PYBIN in /opt/python/cp*/bin; do + "${PYBIN}/python" -m pip install wheel scikit-build auditwheel + export PATH="${PYBIN}":$PATH + "${PYBIN}/python" -m pip wheel --wheel-dir="/src_dir/builtwheel${PYBIN}/" /src_dir/arbor + "${PYBIN}/python" -m auditwheel repair /src_dir/builtwheel${PYBIN}/arbor*.whl -w /src_dir/wheelhouse +done + +# Todo: Install packages and test From 085f77d6b044fa058111de2e4fa07a62783dd8ca Mon Sep 17 00:00:00 2001 From: Brent Huisman Date: Wed, 12 Jan 2022 12:02:47 +0100 Subject: [PATCH 38/60] static libxml dont work, centos builds their package without fPIC --- .github/workflows/ciwheel.yml | 2 +- scripts/build-wheels.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ciwheel.yml b/.github/workflows/ciwheel.yml index 510bfc4cf8..66150ab85f 100644 --- a/.github/workflows/ciwheel.yml +++ b/.github/workflows/ciwheel.yml @@ -29,7 +29,7 @@ jobs: with: output-dir: dist env: - CIBW_BEFORE_ALL: yum -y install libxml2-devel libxml2-static + CIBW_BEFORE_ALL: yum -y install libxml2-devel CIBW_BEFORE_BUILD: python -m pip install numpy setuptools scikit-build ninja cmake CIBW_BUILD: "cp3?-manylinux_x86_64" CIBW_SKIP: "cp35-*" diff --git a/scripts/build-wheels.sh b/scripts/build-wheels.sh index 68526a08cd..eb1cad2503 100755 --- a/scripts/build-wheels.sh +++ b/scripts/build-wheels.sh @@ -13,7 +13,7 @@ set -e -u -x -yum -y install libxml2-devel libxml2-static +yum -y install libxml2-devel /opt/python/cp39-cp39/bin/pip install ninja cmake rm -rf /opt/python/cp35-cp35m #skip building for Python 3.5 From 1fc3b4444bfb84133725cbeaafc7e1a232b5bee6 Mon Sep 17 00:00:00 2001 From: Brent Huisman Date: Wed, 12 Jan 2022 12:10:41 +0100 Subject: [PATCH 39/60] yank static libxml2 stuff from setup.py --- setup.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/setup.py b/setup.py index a53cfea97a..e90105d5fa 100644 --- a/setup.py +++ b/setup.py @@ -23,10 +23,6 @@ f'-DARB_WITH_NEUROML={with_nml}', f'-DARB_USE_BUNDLED_LIBS={use_libs}', f'-DCMAKE_BUILD_TYPE={build_type}'] -# For cibuildwheel builds, which build the Python wheels meant for PyPI, we use the static library of libxml2. -# This gets us around this issue with skbuild: https://github.com/pypa/auditwheel/issues/363 -if 'linux' in str(platform.system()).lower() and os.environ.get('CIBUILDWHEEL') is not None: - cmake_args.append(f'-DARB_LIBXML=/usr/lib64/libxml2.a') # Find our dir; *should* be the arbor checkout here = Path(__file__).resolve().parent From 493a0dbcedcd1b765303a631269a2577ed6202a9 Mon Sep 17 00:00:00 2001 From: Brent Huisman Date: Thu, 13 Jan 2022 13:20:20 +0100 Subject: [PATCH 40/60] Add patchwheel.py, add to workflow and buildwheel.sh --- .github/workflows/ciwheel.yml | 3 +-- scripts/build-wheels.sh | 5 ++-- scripts/patchwheel.py | 44 +++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 scripts/patchwheel.py diff --git a/.github/workflows/ciwheel.yml b/.github/workflows/ciwheel.yml index 66150ab85f..8701a1e8ba 100644 --- a/.github/workflows/ciwheel.yml +++ b/.github/workflows/ciwheel.yml @@ -32,9 +32,9 @@ jobs: CIBW_BEFORE_ALL: yum -y install libxml2-devel CIBW_BEFORE_BUILD: python -m pip install numpy setuptools scikit-build ninja cmake CIBW_BUILD: "cp3?-manylinux_x86_64" - CIBW_SKIP: "cp35-*" CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 CIBW_ARCHS_LINUX: x86_64 + CIBW_REPAIR_WHEEL_COMMAND: 'auditwheel repair -w {dest_dir} {wheel} && python {project}/script/patchwheel.py {dest_dir}' CIBW_TEST_COMMAND: python -m unittest discover -v -s {project}/python - name: Build wheels macos @@ -46,7 +46,6 @@ jobs: MACOSX_DEPLOYMENT_TARGET: "10.15" #needed to undo some CIBW settings CIBW_BEFORE_BUILD: python -m pip install numpy setuptools scikit-build ninja cmake CIBW_BUILD: "cp3?-macosx_x86_64" - CIBW_SKIP: "cp35-*" CIBW_ARCHS_MACOS: x86_64 universal2 CIBW_TEST_COMMAND: python -m unittest discover -v -s {project}/python diff --git a/scripts/build-wheels.sh b/scripts/build-wheels.sh index eb1cad2503..0b881c71b0 100755 --- a/scripts/build-wheels.sh +++ b/scripts/build-wheels.sh @@ -14,8 +14,7 @@ set -e -u -x yum -y install libxml2-devel -/opt/python/cp39-cp39/bin/pip install ninja cmake -rm -rf /opt/python/cp35-cp35m #skip building for Python 3.5 +/opt/python/cp310-cp310/bin/pip install ninja cmake rm -rf /src_dir/arbor/_skbuild @@ -28,4 +27,6 @@ for PYBIN in /opt/python/cp*/bin; do "${PYBIN}/python" -m auditwheel repair /src_dir/builtwheel${PYBIN}/arbor*.whl -w /src_dir/wheelhouse done +/opt/python/cp310-cp310/bin/python /src_dir/arbor/scripts/patchwheel.py /src_dir/wheelhouse + # Todo: Install packages and test diff --git a/scripts/patchwheel.py b/scripts/patchwheel.py new file mode 100644 index 0000000000..911063dcb7 --- /dev/null +++ b/scripts/patchwheel.py @@ -0,0 +1,44 @@ +import shutil,subprocess,argparse +from pathlib import Path + +def parse_arguments(): + parser = argparse.ArgumentParser(description='Patch Arbor wheels build with skbuild and correct by auditwheel. Linux only.') + parser.add_argument('path', type=dir_path, help='The path in which the wheels will be patched.') + parser.add_argument('-ko','--keepold', action='store_true', help='If you want to keep the old wheels in /old') + + return parser.parse_args() + +def dir_path(path): + path = Path(path) + if Path.is_dir(path): + return path + else: + raise argparse.ArgumentTypeError(f"readable_dir:{path} is not a valid path") + +parsed_args = parse_arguments() +Path.mkdir(parsed_args.path / 'old', exist_ok=True) + +for inwheel in parsed_args.path.glob("*.whl"): + zipdir = Path(f"{inwheel}.unzip") + shutil.unpack_archive(inwheel,zipdir,'zip') + + arborn = list(zipdir.glob("**/_arbor.cpython*.so"))[0] + libxml2n = list(zipdir.glob("**/libxml2*.so*"))[0] + try: + subprocess.check_call(f"patchelf --set-rpath '$ORIGIN/../arbor.libs' {arborn}",shell=True) + except subprocess.CalledProcessError as e: + print(f"shit hit the fan executing patchelf on {arborn}") + try: + subprocess.check_call(f"patchelf --set-rpath '$ORIGIN' {libxml2n}",shell=True) + except subprocess.CalledProcessError as e: + print(f"shit hit the fan executing patchelf on {libxml2n}") + + # TODO? correct checksum/bytecounts in *.dist-info/RECORD. + # So far, Python does not report mismatches + + outwheel = Path(shutil.make_archive(inwheel, 'zip', zipdir)) + Path.rename(inwheel, parsed_args.path / 'old' / inwheel.name) + Path.rename(outwheel, parsed_args.path / inwheel.name) + +if not parsed_args.keepold: + Path.rmdir(parsed_args.path / 'old') \ No newline at end of file From b02d6bb5a5a0d5235481ee42de8a1b60edcba04d Mon Sep 17 00:00:00 2001 From: Brent Huisman Date: Thu, 13 Jan 2022 15:10:34 +0100 Subject: [PATCH 41/60] correction to patchwheel.py and ciwheel.yml --- .github/workflows/ciwheel.yml | 2 +- scripts/patchwheel.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ciwheel.yml b/.github/workflows/ciwheel.yml index 8701a1e8ba..1e14936741 100644 --- a/.github/workflows/ciwheel.yml +++ b/.github/workflows/ciwheel.yml @@ -34,7 +34,7 @@ jobs: CIBW_BUILD: "cp3?-manylinux_x86_64" CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 CIBW_ARCHS_LINUX: x86_64 - CIBW_REPAIR_WHEEL_COMMAND: 'auditwheel repair -w {dest_dir} {wheel} && python {project}/script/patchwheel.py {dest_dir}' + CIBW_REPAIR_WHEEL_COMMAND: 'auditwheel repair -w {dest_dir} {wheel} && python {project}/scripts/patchwheel.py {dest_dir}' CIBW_TEST_COMMAND: python -m unittest discover -v -s {project}/python - name: Build wheels macos diff --git a/scripts/patchwheel.py b/scripts/patchwheel.py index 911063dcb7..b09af0a331 100644 --- a/scripts/patchwheel.py +++ b/scripts/patchwheel.py @@ -13,7 +13,7 @@ def dir_path(path): if Path.is_dir(path): return path else: - raise argparse.ArgumentTypeError(f"readable_dir:{path} is not a valid path") + raise argparse.ArgumentTypeError(f"{path} is not a valid path") parsed_args = parse_arguments() Path.mkdir(parsed_args.path / 'old', exist_ok=True) @@ -39,6 +39,7 @@ def dir_path(path): outwheel = Path(shutil.make_archive(inwheel, 'zip', zipdir)) Path.rename(inwheel, parsed_args.path / 'old' / inwheel.name) Path.rename(outwheel, parsed_args.path / inwheel.name) + shutil.rmtree(zipdir) if not parsed_args.keepold: - Path.rmdir(parsed_args.path / 'old') \ No newline at end of file + shutil.rmtree(parsed_args.path / 'old') From 35d5e700ed58c00630ce481a4199f9b5f3a253c1 Mon Sep 17 00:00:00 2001 From: Brent Huisman Date: Fri, 14 Jan 2022 14:47:11 +0100 Subject: [PATCH 42/60] unzip preserves filemodes, while Pythons shutil/zipfile doesnt --- .github/workflows/ciwheel.yml | 2 +- scripts/patchwheel.py | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ciwheel.yml b/.github/workflows/ciwheel.yml index 1e14936741..42b54a3296 100644 --- a/.github/workflows/ciwheel.yml +++ b/.github/workflows/ciwheel.yml @@ -34,7 +34,7 @@ jobs: CIBW_BUILD: "cp3?-manylinux_x86_64" CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 CIBW_ARCHS_LINUX: x86_64 - CIBW_REPAIR_WHEEL_COMMAND: 'auditwheel repair -w {dest_dir} {wheel} && python {project}/scripts/patchwheel.py {dest_dir}' + CIBW_REPAIR_WHEEL_COMMAND: 'auditwheel repair -w {dest_dir} {wheel} && python /project/scripts/patchwheel.py {dest_dir}' CIBW_TEST_COMMAND: python -m unittest discover -v -s {project}/python - name: Build wheels macos diff --git a/scripts/patchwheel.py b/scripts/patchwheel.py index b09af0a331..61225b9903 100644 --- a/scripts/patchwheel.py +++ b/scripts/patchwheel.py @@ -20,18 +20,13 @@ def dir_path(path): for inwheel in parsed_args.path.glob("*.whl"): zipdir = Path(f"{inwheel}.unzip") - shutil.unpack_archive(inwheel,zipdir,'zip') + # shutil.unpack_archive(inwheel,zipdir,'zip') # Disabled, because shutil (and ZipFile) don't preserve filemodes + subprocess.check_call(f"unzip {inwheel} -d {zipdir}",shell=True) arborn = list(zipdir.glob("**/_arbor.cpython*.so"))[0] libxml2n = list(zipdir.glob("**/libxml2*.so*"))[0] - try: - subprocess.check_call(f"patchelf --set-rpath '$ORIGIN/../arbor.libs' {arborn}",shell=True) - except subprocess.CalledProcessError as e: - print(f"shit hit the fan executing patchelf on {arborn}") - try: - subprocess.check_call(f"patchelf --set-rpath '$ORIGIN' {libxml2n}",shell=True) - except subprocess.CalledProcessError as e: - print(f"shit hit the fan executing patchelf on {libxml2n}") + subprocess.check_call(f"patchelf --set-rpath '$ORIGIN/../arbor.libs' {arborn}",shell=True) + subprocess.check_call(f"patchelf --set-rpath '$ORIGIN' {libxml2n}",shell=True) # TODO? correct checksum/bytecounts in *.dist-info/RECORD. # So far, Python does not report mismatches From a5c31d165bbbdb9cf6af6bd0603f107761f832ce Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Tue, 18 Jan 2022 16:33:14 +0100 Subject: [PATCH 43/60] Clean-up --- CMakeLists.txt | 4 +--- arborio/CMakeLists.txt | 4 ---- setup.py | 1 + 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 78a4654525..ceaf8d5eab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,10 +77,8 @@ option(ARB_WITH_ASSERTIONS "enable arb_assert() assertions in code" OFF) # NeuroML support library: #---------------------------------------------------------- -option(ARB_WITH_NEUROML "build NeuroML support library" OFF) +option(ARB_WITH_NEUROML "build NeuroML support library" OFF) -set(ARB_LIBXML "" CACHE STRING "path to XML library to link, use with care") -mark_as_advanced(ARB_LIBXML) #---------------------------------------------------------- # Python front end for Arbor: #---------------------------------------------------------- diff --git a/arborio/CMakeLists.txt b/arborio/CMakeLists.txt index dc011a0ebd..4c1eff4abc 100644 --- a/arborio/CMakeLists.txt +++ b/arborio/CMakeLists.txt @@ -12,10 +12,6 @@ if(ARB_WITH_NEUROML) nml_parse_morphology.cpp xml.cpp xmlwrap.cpp) - if(NOT ${ARB_LIBXML} STREQUAL "") - set(LIBXML2_LIBRARY ${ARB_LIBXML}) - endif() - message("-lxml = ${ARB_LIBXML}") find_package(LibXml2 REQUIRED) endif() diff --git a/setup.py b/setup.py index f5c1972dea..9517649704 100644 --- a/setup.py +++ b/setup.py @@ -28,6 +28,7 @@ install_requires=['numpy'], setup_requires=[], zip_safe=False, + packages=['arbor'], cmake_args=['-DARB_WITH_PYTHON=on', f'-DPYTHON_EXECUTABLE={python}', f'-DARB_WITH_MPI={with_mpi}', From 48019878d8e7c442bf7bad01bdb10396e28a9144 Mon Sep 17 00:00:00 2001 From: Brent Huisman Date: Tue, 18 Jan 2022 16:44:52 +0100 Subject: [PATCH 44/60] Update setup.py with correct website URL --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 7f01882572..911545aabc 100644 --- a/setup.py +++ b/setup.py @@ -40,7 +40,7 @@ f'-DARB_USE_BUNDLED_LIBS={use_libs}', f'-DCMAKE_BUILD_TYPE={build_type}',], author='The Arbor dev team.', - url='https://github.com/arbor-sim/arbor', + url='https://arbor-sim.org', description='High performance simulation of networks of multicompartment neurons.', long_description=long_description, long_description_content_type='text/markdown', From 3e68465b43855ac6afa2769b2aee1249882eed4f Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Tue, 18 Jan 2022 19:33:00 +0100 Subject: [PATCH 45/60] Update docs to sk-build. --- doc/install/python.rst | 99 +++++++++++++++++++++++++----------------- 1 file changed, 58 insertions(+), 41 deletions(-) diff --git a/doc/install/python.rst b/doc/install/python.rst index 7a36e00da2..fe9d94ab55 100644 --- a/doc/install/python.rst +++ b/doc/install/python.rst @@ -7,9 +7,7 @@ Arbor's Python API will be the most convenient interface for most users. .. note:: Arbor requires Python version 3.6 and later. It is advised that you update `pip` as well. - -.. note:: - We assume ``pip`` is used to install Arbor. See later for using ``setup.py``. + We strongly encourage ``pip`` is used to install Arbor. Getting Arbor ------------- @@ -74,78 +72,97 @@ Every time you make changes to the code, you'll have to repeat the second step. Advanced options ^^^^^^^^^^^^^^^^ -.. note:: When installing via ``setup.py install`` directly instead of using - ``pip install .``, you will have to install the build-time dependencies - listed in ``pyproject.toml`` on your own. +By default Arbor is installed with multi-threading enabled. To enable more +advanced forms of parallelism and other features, Arbor comes with a few +compilation options. These are of the form ``-D=``, must be +separated from the actual ``pip`` invocation by a double dash ``--`` and can be +used on both local (``pip3 install ./arbor``) and remote (``pip3 install +arbor``) copies of Arbor. + +.. Note:: + + ``Pip`` compiles the Arbor C++ library and wrapper, as well as dependencies + you might not have had installed yet (e.g. `numpy`). It may take a few + minutes. Pass the ``--verbose`` flag to pip to see the individual steps + being performed if you are concerned that progress is halting. + + If you had Arbor installed already, you may need to remove it first before + you can (re)compile it with the flags you need. + +The following flags can be used to configure the installation: + +* ``-DARB_WITH_NEUROML=``: Enable support for NeuroML2 morphologies, + requires ``libxml2`` library. Default ``OFF`` +* ``-DARB_WITH__MPI=``: Enable MPI support, requires MPI library. + Default ``OF``. +* ``-DARB_GPU=``: Enable GPU support for NVIDIA GPUs + with nvcc using ``cuda``, or with clang using ``cuda-clang`` (both require + cudaruntime). Enable GPU support for AMD GPUs with hipcc using ``hip``. By + default set to ``none``, which disables GPU support. +* ``-DARB_VECTORIZE=``: Enable vectorization. The architecture argument, + documented below, may also have to be set appropriately to generated + vectorized code. See :ref:`install-architecture` for details. +* ``-DARB_ARCH=``: CPU micro-architecture to target. The advised + default is ``native``. See `here + `_ for a full list of + options. + +Finally, some flags must be be passed after a second set of ``--`` -By default Arbor is installed with multi-threading enabled. To enable more advanced forms of parallelism, -Arbor comes with a few compilation options. These can be used on both local (``pip3 install ./arbor``) and -remote (``pip3 install arbor``) copies of Arbor. Below we assume you are working off a local copy. +* ``-j N``: Use ``N`` processes for compilation, used to speed up builds. -The following optional flags can be used to configure the installation: +.. note:: + + There are more, advanced flags that can be set. We are using ``sk-build`` and + ``CMake`` under the hood, so all flags and options valid in ``CMake`` can be + used in this fashion. + + Detailed instructions on how to install using CMake are in the :ref:`Python + configuration ` section of the :ref:`installation guide + `. CMake is recommended if you need more control over + compilation and installation, plan to use Arbor with C++, or if you are + integrating with package managers such as Spack and EasyBuild. -* ``--mpi``: Enable MPI support (requires MPI library). -* ``--gpu``: Enable GPU support for NVIDIA GPUs with nvcc using ``cuda``, or with clang using ``cuda-clang`` (both require cudaruntime). - Enable GPU support for AMD GPUs with hipcc using ``hip``. By default set to ``none``, which disables gpu support. -* ``--vec``: Enable vectorization. The ``--arch`` argument, documented below, may also have to be set appropriately to generated vectorized code. - See :ref:`install-architecture` for details. -* ``--arch``: CPU micro-architecture to target. The advised default is ``native``. - See `here `_ for a full list of options. -* ``-j``: Specify the amount of concurrent jobs for building the project with for faster build times on multicore systems. By default set to ``2``. +In the examples below we assume you are working off a local copy. **Vanilla install** with no additional features enabled: .. code-block:: bash - pip3 install arbor + pip3 install ./arbor **With MPI support**. This might require loading an MPI module or setting the ``CC`` and ``CXX`` :ref:`environment variables `: .. code-block:: bash - pip3 install --install-option='--mpi' ./arbor + pip3 install ./arbor -- -DARB_WITH_MPI=ON **Compile with** :ref:`vectorization ` on a system with a SkyLake :ref:`architecture `: .. code-block:: bash - pip3 install --install-option='--vec' --install-option='--arch=skylake' arbor + pip3 install ./arbor -- -DARB_VECTORIZE=ON -DARB_ARCH=skylake **Enable NVIDIA GPUs (compiled with nvcc)**. This requires the :ref:`CUDA toolkit `: .. code-block:: bash - pip3 install --install-option='--gpu=cuda' ./arbor + pip3 install arbor -- -DARB_GPU=cuda **Enable NVIDIA GPUs (compiled with clang)**. This also requires the :ref:`CUDA toolkit `: .. code-block:: bash - pip3 install --install-option='--gpu=cuda-clang' ./arbor + pip3 install ./arbor -- -DARB_GPU=cuda-clang **Enable AMD GPUs (compiled with hipcc)**. This requires setting the ``CC`` and ``CXX`` :ref:`environment variables ` .. code-block:: bash - pip3 install --install-option='--gpu=hip' ./arbor - -.. Note:: - Setuptools compiles the Arbor C++ library and wrapper, as well as dependencies you did not have installed - yet (e.g. `numpy`). It may take a few minutes. Pass the ``--verbose`` flag to pip - to see the individual steps being performed if you are concerned that progress - is halting. - - If you had Arbor installed already, you may need to remove it first before you can (re)compile - it with the flags you need. - -.. Note:: - Detailed instructions on how to install using CMake are in the - :ref:`Python configuration ` section of the :ref:`installation guide `. - CMake is recommended if you need more control over compilation and installation, plan to use Arbor with C++, - or if you are integrating with package managers such as Spack and EasyBuild. + pip3 install ./arbor -- -DARB_GPU=hip Dependencies ^^^^^^^^^^^^ @@ -158,8 +175,8 @@ with MPI support would add the following to its requirements: .. code-block:: python - arbor >= 0.3 --install-option='--gpu=cuda' \ - --install-option='--mpi' + TODO: Does this work? + arbor >= 0.3 -- -DARB_GPU='cuda' -DARB_WITH_MPI=ON Note on performance ------------------- From f8d9bdfc8ee0540baa60cfefa605eb1d744ca843 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Tue, 18 Jan 2022 19:44:45 +0100 Subject: [PATCH 46/60] Clean-up a-b-c. --- scripts/build-catalogue.in | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/scripts/build-catalogue.in b/scripts/build-catalogue.in index af21fc76f0..fb415c9bf1 100755 --- a/scripts/build-catalogue.in +++ b/scripts/build-catalogue.in @@ -66,6 +66,12 @@ also _gpu.cpp and _gpu.cu''') metavar='gpu', help='Enable GPU support, valid options: cuda|hip|cuda-clang.') + parser.add_argument('-C', '--no-cpu', + metavar='cpu', + action='store_false', + default=True, + help='Disable CPU support.') + parser.add_argument('-d', '--debug', nargs="?", metavar="path", @@ -91,8 +97,9 @@ mods = [f[:-4] for f in os.listdir(mod_dir) if f.endswith('.mod')] quiet = args['quiet'] verbose = args['verbose'] and not quiet debug = args['debug'] -raw = args['raw'] +raw = args['raw'] gpu = args['gpu'] +cpu = args['cpu'] if gpu: if gpu == 'cuda': @@ -113,11 +120,10 @@ data_path = (this_path / "@ARB_REL_DATADIR@").resolve() pack_path = (this_path / "@ARB_REL_PACKAGEDIR@").resolve() exec_path = this_path.resolve() -for i, p in [(exec_path, 'modcc'), - (data_path, 'generate_catalogue'), - (data_path, 'BuildModules.cmake'), - (pack_path, 'arbor-config.cmake'),]: - path = p / i +for path in [exec_path / 'modcc', + data_path / 'generate_catalogue', + data_path / 'BuildModules.cmake', + pack_path / 'arbor-config.cmake',]: if not path.exists(): print(f'Could not find required tool: {path}. Please check your installation.') exit(-1) @@ -199,7 +205,9 @@ with TemporaryDirectory() as tmp: out = tmp / 'build' / 'generated' / name os.makedirs(out, exist_ok=True) - sfx = [".hpp", "_cpu.cpp"] + sfx = [".hpp"] + if cpu: + sfx += ["_cpu.cpp"] if gpu: sfx += ["_gpu.cpp", "_gpu.cu"] for e in raw: From f8f767d82da80cb018d4c6e9ca75c31ea15884b8 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Tue, 18 Jan 2022 19:58:30 +0100 Subject: [PATCH 47/60] Formatting. --- scripts/build-catalogue.in | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/build-catalogue.in b/scripts/build-catalogue.in index fb415c9bf1..e75666ae5d 100755 --- a/scripts/build-catalogue.in +++ b/scripts/build-catalogue.in @@ -103,17 +103,21 @@ cpu = args['cpu'] if gpu: if gpu == 'cuda': - gpu_support = """add_compile_definitions(ARB_CUDA) + gpu_support = """ +add_compile_definitions(ARB_CUDA) add_compile_definitions(ARB_HAVE_GPU) enable_language(CUDA) set(CMAKE_CUDA_HOST_COMPILER @CMAKE_CXX_COMPILER@) -set(CMAKE_CUDA_ARCHITECTURES @CMAKE_CUDA_ARCHITECTURES@)""" +set(CMAKE_CUDA_ARCHITECTURES @CMAKE_CUDA_ARCHITECTURES@) +""" else: print(f"Unsupported GPU target: {gpu}. If you need support for HIP or Clang-CUDA, please check here: https://github.com/arbor-sim/arbor/issues/1783") exit(-1) else: - gpu_support = "# GPU: Disabled" + gpu_support = """ +# GPU: Disabled +""" this_path = Path(__file__).parent data_path = (this_path / "@ARB_REL_DATADIR@").resolve() @@ -134,9 +138,7 @@ project({name}-cat LANGUAGES CXX) set(arbor_DIR {pack_path}) find_package(arbor REQUIRED) - {gpu_support} - set(CMAKE_BUILD_TYPE release) set(CMAKE_CXX_COMPILER ${{ARB_CXX}}) set(CMAKE_CXX_FLAGS ${{ARB_CXX_FLAGS}}) From b6de0f13fef8d12578a73ef200fef4c3d8adc406 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Tue, 18 Jan 2022 20:09:54 +0100 Subject: [PATCH 48/60] Argparse. --- scripts/build-catalogue.in | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/build-catalogue.in b/scripts/build-catalogue.in index e75666ae5d..b599b0926d 100755 --- a/scripts/build-catalogue.in +++ b/scripts/build-catalogue.in @@ -67,7 +67,6 @@ also _gpu.cpp and _gpu.cu''') help='Enable GPU support, valid options: cuda|hip|cuda-clang.') parser.add_argument('-C', '--no-cpu', - metavar='cpu', action='store_false', default=True, help='Disable CPU support.') @@ -99,7 +98,7 @@ verbose = args['verbose'] and not quiet debug = args['debug'] raw = args['raw'] gpu = args['gpu'] -cpu = args['cpu'] +cpu = not args['no_cpu'] if gpu: if gpu == 'cuda': From 5ef4bb824d5ad4caefb0712759faaf6b0e12445c Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Wed, 19 Jan 2022 09:02:08 +0100 Subject: [PATCH 49/60] Better names, polish docs. --- doc/internals/extending_catalogues.rst | 18 +++++++++++------- doc/internals/mechanism_abi.rst | 10 ++++------ mechanisms/BuildModules.cmake | 14 +++++++------- mechanisms/CMakeLists.txt | 12 ++++++------ scripts/build-catalogue.in | 4 ++-- 5 files changed, 30 insertions(+), 28 deletions(-) diff --git a/doc/internals/extending_catalogues.rst b/doc/internals/extending_catalogues.rst index 7411f0ffac..d60182ecc2 100644 --- a/doc/internals/extending_catalogues.rst +++ b/doc/internals/extending_catalogues.rst @@ -12,7 +12,7 @@ all likelihood interested in the former. If you are coming from NEURON and looking for the equivalent of ``nrnivmodl``, please read on :ref:`here `. - Following this path is for developers rather than end-users. + Following the below instructions is for developers rather than end-users. This requires a copy of the Arbor source tree and the compiler toolchain used to build Arbor in addition to the installed library. Following these steps will @@ -21,7 +21,10 @@ produce a catalogue of the same level of integration as the built-in catalogues 1. Go to the Arbor source tree. 2. Create a new directory under *mechanisms*. -3. Add your .mod files. + + 1. Add any ``.mod`` files you wish to integrate. + 2. Add any raw C++ files to be included in the catalogue. + 4. Edit *mechanisms/CMakeLists.txt* to add a definition like this (example from *default* catalogue) @@ -31,8 +34,8 @@ produce a catalogue of the same level of integration as the built-in catalogues NAME default # Name of your catalogue SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/default" # Directory name (added above) OUTPUT "CAT_DEFAULT_SOURCES" # Variable name to store C++ files into (see below) - MECHS exp2syn expsyn expsyn_stdp hh kamt kdrmt nax nernst pas # Space separated list of mechanisms w/o .mod suffix. - EXTRA # Not needed, see below. + MOD exp2syn expsyn expsyn_stdp hh kamt kdrmt nax nernst pas # Space separated list of NMODL mechanism names + CXX # Space separated list of raw C++ mechanism names PREFIX "${PROJECT_SOURCE_DIR}/mechanisms" # where does 'generate_catalogue' live, do not change STANDALONE FALSE # build as shared object, must be OFF VERBOSE OFF) # Print debug info at configuration time @@ -50,9 +53,10 @@ produce a catalogue of the same level of integration as the built-in catalogues 6. Add a ``global_NAME_catalogue`` function in ``mechcat.hpp`` and ``mechcat.cpp`` 7. Bind this function in ``python/mechanisms.cpp``. -All steps can be more or less copied from the surrounding code. +All steps can be directly adapted from the surrounding code. .. note:: - If you are sure of your understanding you can write mechanisms in C/C++ - directly against Arbor's ABI. See :ref:`here ` for more. + If you have special requirements, you can write mechanisms in C/C++ directly + against Arbor's ABI. These need to adhere to the calling convention of the + ABI. See :ref:`here ` for more. diff --git a/doc/internals/mechanism_abi.rst b/doc/internals/mechanism_abi.rst index c12b60f98c..a8c9205900 100644 --- a/doc/internals/mechanism_abi.rst +++ b/doc/internals/mechanism_abi.rst @@ -457,6 +457,7 @@ supported. The naming scheme is shown in the example below Writing Mechanisms Directly Against the ABI ------------------------------------------- +.. _abi_raw: .. warning:: @@ -489,19 +490,16 @@ For this to compile, the following must be upheld: - For each mechanism ``M`` these files must be present - ``M.hpp`` must define the mechanism metadata and declare the used interfaces. - - - ``M_cpu.cpp`` must define the CPU interface. + - ``M_cpu.cpp`` must define the CPU interface. (You can disable this for raw + mechanisms by passing ``-C``.) - If GPU support is used - ``M_gpu.cpp`` must define the GPU interface. - - ``M_gpu.cu`` must define CUDA kernels. - The interface names must adhere to the chosen catalogue name, eg here ``make_arb_my_catalogue_B_interface_multicore();`` - names may only contain alphanumeric characters and underscores. - - names must not contain multiple successive underscores. - - - in general, a valid C variable name should be used. + - in general, a valid ``C++`` variable name should be used. diff --git a/mechanisms/BuildModules.cmake b/mechanisms/BuildModules.cmake index ae70e89fb7..3aadf9fcb4 100644 --- a/mechanisms/BuildModules.cmake +++ b/mechanisms/BuildModules.cmake @@ -58,7 +58,7 @@ function(build_modules) endfunction() function("make_catalogue") - cmake_parse_arguments(MK_CAT "" "NAME;SOURCES;OUTPUT;PREFIX;STANDALONE;VERBOSE" "CXX_FLAGS_TARGET;MECHS;EXTRA" ${ARGN}) + cmake_parse_arguments(MK_CAT "" "NAME;SOURCES;OUTPUT;PREFIX;STANDALONE;VERBOSE" "CXX_FLAGS_TARGET;MOD;CXX" ${ARGN}) set(MK_CAT_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated/${MK_CAT_NAME}") # Need to set ARB_WITH_EXTERNAL_MODCC *and* modcc @@ -69,8 +69,8 @@ function("make_catalogue") if(MK_CAT_VERBOSE) message("Catalogue name: ${MK_CAT_NAME}") - message("Catalogue mechanisms: ${MK_CAT_MECHS}") - message("Extra cxx files: ${MK_CAT_EXTRA}") + message("Catalogue mechanisms: ${MK_CAT_MOD}") + message("Extra cxx files: ${MK_CAT_CXX}") message("Catalogue sources: ${MK_CAT_SOURCES}") message("Catalogue output: ${MK_CAT_OUT_DIR}") message("Build as standalone: ${MK_CAT_STANDALONE}") @@ -87,7 +87,7 @@ function("make_catalogue") endif() build_modules( - ${MK_CAT_MECHS} + ${MK_CAT_MOD} SOURCE_DIR "${MK_CAT_SOURCES}" DEST_DIR "${MK_CAT_OUT_DIR}" ${external_modcc} # NB: expands to 'MODCC ' to add an optional argument @@ -103,7 +103,7 @@ function("make_catalogue") add_custom_command( OUTPUT ${catalogue_${MK_CAT_NAME}_source} - COMMAND ${MK_CAT_PREFIX}/generate_catalogue ${catalogue_${MK_CAT_NAME}_options} ${MK_CAT_MECHS} ${MK_CAT_EXTRA} + COMMAND ${MK_CAT_PREFIX}/generate_catalogue ${catalogue_${MK_CAT_NAME}_options} ${MK_CAT_MOD} ${MK_CAT_CXX} COMMENT "Building catalogue ${MK_CAT_NAME}" DEPENDS ${MK_CAT_PREFIX}/generate_catalogue) @@ -111,13 +111,13 @@ function("make_catalogue") add_dependencies(build_catalogue_${MK_CAT_NAME}_mods ${MK_CAT_NAME}_catalogue_cpp_target) add_dependencies(build_all_mods build_catalogue_${MK_CAT_NAME}_mods) - foreach(mech ${MK_CAT_MECHS}) + foreach(mech ${MK_CAT_MOD}) list(APPEND catalogue_${MK_CAT_NAME}_source ${MK_CAT_OUT_DIR}/${mech}_cpu.cpp) if(ARB_WITH_GPU) list(APPEND catalogue_${MK_CAT_NAME}_source ${MK_CAT_OUT_DIR}/${mech}_gpu.cpp ${MK_CAT_OUT_DIR}/${mech}_gpu.cu) endif() endforeach() - foreach(mech ${MK_CAT_EXTRA}) + foreach(mech ${MK_CAT_CXX}) list(APPEND catalogue_${MK_CAT_NAME}_source ${MK_CAT_OUT_DIR}/${mech}_cpu.cpp) if(ARB_WITH_GPU) list(APPEND catalogue_${MK_CAT_NAME}_source ${MK_CAT_OUT_DIR}/${mech}_gpu.cpp ${MK_CAT_OUT_DIR}/${mech}_gpu.cu) diff --git a/mechanisms/CMakeLists.txt b/mechanisms/CMakeLists.txt index bec15813cf..a219475fac 100644 --- a/mechanisms/CMakeLists.txt +++ b/mechanisms/CMakeLists.txt @@ -5,8 +5,8 @@ make_catalogue( NAME bbp SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/bbp" OUTPUT "CAT_BBP_SOURCES" - MECHS CaDynamics_E2 Ca_HVA Ca_LVAst Ih Im K_Pst K_Tst Nap_Et2 NaTa_t NaTs2_t SK_E2 SKv3_1 - EXTRA + MOD CaDynamics_E2 Ca_HVA Ca_LVAst Ih Im K_Pst K_Tst Nap_Et2 NaTa_t NaTs2_t SK_E2 SKv3_1 + CXX PREFIX "${PROJECT_SOURCE_DIR}/mechanisms" CXX_FLAGS_TARGET "${ARB_CXX_FLAGS_TARGET_FULL}" STANDALONE FALSE @@ -16,8 +16,8 @@ make_catalogue( NAME allen SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/allen" OUTPUT "CAT_ALLEN_SOURCES" - MECHS CaDynamics Ca_HVA Ca_LVA Ih Im Im_v2 K_P K_T Kd Kv2like Kv3_1 NaTa NaTs NaV Nap SK - EXTRA + MOD CaDynamics Ca_HVA Ca_LVA Ih Im Im_v2 K_P K_T Kd Kv2like Kv3_1 NaTa NaTs NaV Nap SK + CXX PREFIX "${PROJECT_SOURCE_DIR}/mechanisms" CXX_FLAGS_TARGET "${ARB_CXX_FLAGS_TARGET_FULL}" STANDALONE FALSE @@ -27,8 +27,8 @@ make_catalogue( NAME default SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/default" OUTPUT "CAT_DEFAULT_SOURCES" - MECHS exp2syn expsyn expsyn_stdp hh kamt kdrmt nax nernst pas gj - EXTRA + MOD exp2syn expsyn expsyn_stdp hh kamt kdrmt nax nernst pas gj + CXX PREFIX "${PROJECT_SOURCE_DIR}/mechanisms" CXX_FLAGS_TARGET "${ARB_CXX_FLAGS_TARGET_FULL}" STANDALONE FALSE diff --git a/scripts/build-catalogue.in b/scripts/build-catalogue.in index b599b0926d..98e94b46e0 100755 --- a/scripts/build-catalogue.in +++ b/scripts/build-catalogue.in @@ -151,8 +151,8 @@ make_catalogue( NAME {name} SOURCES "${{CMAKE_CURRENT_SOURCE_DIR}}/mod" OUTPUT "CAT_{name.upper()}_SOURCES" - MECHS {' '.join(mods)} - EXTRA {' '.join(raw)} + MOD {' '.join(mods)} + CXX {' '.join(raw)} PREFIX {data_path} CXX_FLAGS_TARGET ${{ARB_CXX_FLAGS_TARGET}} STANDALONE ON From 745c029101ce966038fa54359458ef31ca60b619 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Wed, 19 Jan 2022 09:52:25 +0100 Subject: [PATCH 50/60] Fix tests. --- test/unit/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index ef27831330..d7d1954a6a 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -219,7 +219,8 @@ if(${CMAKE_POSITION_INDEPENDENT_CODE}) NAME dummy SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/dummy" OUTPUT "CAT_DUMMY_SOURCES" - MECHS dummy + MOD dummy + CXX PREFIX "${PROJECT_SOURCE_DIR}/mechanisms" CXX_FLAGS_TARGET ${ARB_CXX_FLAGS_TARGET_FULL} STANDALONE ON From 9708139f9b11bb90bb572516885b54d0c21c4674 Mon Sep 17 00:00:00 2001 From: Brent Huisman Date: Wed, 19 Jan 2022 10:44:03 +0100 Subject: [PATCH 51/60] some review, integrate setup.cfg into pyproject.toml --- doc/install/python.rst | 6 +++--- pyproject.toml | 1 + setup.cfg | 2 -- 3 files changed, 4 insertions(+), 5 deletions(-) delete mode 100644 setup.cfg diff --git a/doc/install/python.rst b/doc/install/python.rst index fe9d94ab55..c4a3c8ea62 100644 --- a/doc/install/python.rst +++ b/doc/install/python.rst @@ -81,8 +81,8 @@ arbor``) copies of Arbor. .. Note:: - ``Pip`` compiles the Arbor C++ library and wrapper, as well as dependencies - you might not have had installed yet (e.g. `numpy`). It may take a few + ``pip`` compiles the Arbor C++ library and wrapper, as well as dependencies + you might not have had installed yet (e.g. ``numpy``). It may take a few minutes. Pass the ``--verbose`` flag to pip to see the individual steps being performed if you are concerned that progress is halting. @@ -149,7 +149,7 @@ In the examples below we assume you are working off a local copy. .. code-block:: bash - pip3 install arbor -- -DARB_GPU=cuda + pip3 install ./arbor -- -DARB_GPU=cuda **Enable NVIDIA GPUs (compiled with clang)**. This also requires the :ref:`CUDA toolkit `: diff --git a/pyproject.toml b/pyproject.toml index 75335283e8..5a6f95468e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,3 @@ [build-system] requires = ["setuptools", "wheel", "scikit-build", "cmake", "ninja"] +description-file = "python/readme.md" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index aaac5cf4e6..0000000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[metadata] -description-file = python/readme.md From 3990cc1e7069a254b24e0e51bc510e1713bb458c Mon Sep 17 00:00:00 2001 From: Brent Huisman Date: Wed, 19 Jan 2022 15:10:01 +0100 Subject: [PATCH 52/60] nora review --- doc/install/python.rst | 24 +++++------------------- scripts/patchwheel.py | 4 ++-- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/doc/install/python.rst b/doc/install/python.rst index c4a3c8ea62..b2eef513e3 100644 --- a/doc/install/python.rst +++ b/doc/install/python.rst @@ -7,13 +7,13 @@ Arbor's Python API will be the most convenient interface for most users. .. note:: Arbor requires Python version 3.6 and later. It is advised that you update `pip` as well. - We strongly encourage ``pip`` is used to install Arbor. + We strongly encourage using ``pip`` to install Arbor. Getting Arbor ------------- Every point release of Arbor is pushed to the Python Package Index. -For x86-64 Linux and MacOS plaftorms, we provide binary wheels. +For x86-64 Linux and MacOS platforms, we provide binary wheels. The easiest way to get Arbor is with `pip `_: @@ -94,7 +94,7 @@ The following flags can be used to configure the installation: * ``-DARB_WITH_NEUROML=``: Enable support for NeuroML2 morphologies, requires ``libxml2`` library. Default ``OFF`` * ``-DARB_WITH__MPI=``: Enable MPI support, requires MPI library. - Default ``OF``. + Default ``OFF``. * ``-DARB_GPU=``: Enable GPU support for NVIDIA GPUs with nvcc using ``cuda``, or with clang using ``cuda-clang`` (both require cudaruntime). Enable GPU support for AMD GPUs with hipcc using ``hip``. By @@ -107,7 +107,7 @@ The following flags can be used to configure the installation: `_ for a full list of options. -Finally, some flags must be be passed after a second set of ``--`` +Finally, some flags can be be passed after a second set of ``--`` * ``-j N``: Use ``N`` processes for compilation, used to speed up builds. @@ -123,7 +123,7 @@ Finally, some flags must be be passed after a second set of ``--`` compilation and installation, plan to use Arbor with C++, or if you are integrating with package managers such as Spack and EasyBuild. -In the examples below we assume you are working off a local copy. +In the examples below we assume you are installing from a local copy. **Vanilla install** with no additional features enabled: @@ -164,20 +164,6 @@ In the examples below we assume you are working off a local copy. pip3 install ./arbor -- -DARB_GPU=hip -Dependencies -^^^^^^^^^^^^ - -If a downstream dependency requires Arbor be built with -a specific feature enabled, use ``requirements.txt`` to -`define the constraints `_. -For example, a package that depends on `arbor` version 0.3 or later -with MPI support would add the following to its requirements: - -.. code-block:: python - - TODO: Does this work? - arbor >= 0.3 -- -DARB_GPU='cuda' -DARB_WITH_MPI=ON - Note on performance ------------------- diff --git a/scripts/patchwheel.py b/scripts/patchwheel.py index 61225b9903..4a45d37588 100644 --- a/scripts/patchwheel.py +++ b/scripts/patchwheel.py @@ -2,8 +2,8 @@ from pathlib import Path def parse_arguments(): - parser = argparse.ArgumentParser(description='Patch Arbor wheels build with skbuild and correct by auditwheel. Linux only.') - parser.add_argument('path', type=dir_path, help='The path in which the wheels will be patched.') + parser = argparse.ArgumentParser(description='Patch Arbor wheels built with scikit-build and corrected by auditwheel. Linux only.') + parser.add_argument('path', type=dir_path, help='The path where your wheels are located. They will be patched in place.') parser.add_argument('-ko','--keepold', action='store_true', help='If you want to keep the old wheels in /old') return parser.parse_args() From 59d8a0dde18329efcaa2add2eae21786c896ffdc Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Thu, 20 Jan 2022 09:55:15 +0100 Subject: [PATCH 53/60] Revert CUDA arch, fix docs. --- CMakeLists.txt | 2 +- scripts/build-catalogue.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ceaf8d5eab..b316bf6bac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -119,7 +119,7 @@ if(ARB_GPU STREQUAL "cuda") # each target according to CMAKE_CUDA_ARCHITECTURES. Not setting # this will constitute an error from now on. if (NOT DEFINED CMAKE_CUDA_ARCHITECTURES) - set(CMAKE_CUDA_ARCHITECTURES 60 70) # Compatible with CUDA 10. + set(CMAKE_CUDA_ARCHITECTURES 60 70 80) endif() # This fixes nvcc picking up a wrong host compiler for linking, causing issues diff --git a/scripts/build-catalogue.in b/scripts/build-catalogue.in index 98e94b46e0..de4bcd1ca1 100755 --- a/scripts/build-catalogue.in +++ b/scripts/build-catalogue.in @@ -47,7 +47,7 @@ def parse_arguments(): help='''Advanced: Raw mechanisms as C++ files. Per the files .hpp, _cpu.cpp must be present in the target directory and with GPU support -also _gpu.cpp and _gpu.cu''') +also _gpu.cpp and _gpu.cu (if not given -C).''') parser.add_argument('modpfx', metavar='modpfx', From 19238dd37938a0b475d01399af180dc26672425d Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Thu, 20 Jan 2022 16:23:47 +0100 Subject: [PATCH 54/60] Typos, missed a ",". --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 911545aabc..30cf7453df 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ cmake_args=['-DARB_WITH_PYTHON=on', f'-DPYTHON_EXECUTABLE={python}', f'-DARB_WITH_MPI={with_mpi}', - f'-DARB_VECTORIZE={with_vec}' + f'-DARB_VECTORIZE={with_vec}', f'-DARB_ARCH={arch}', f'-DARB_GPU={with_gpu}', f'-DARB_WITH_NEUROML={with_nml}', From d26039aed97568864d2f46d6c963a1b23cbebfae Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Thu, 20 Jan 2022 16:30:37 +0100 Subject: [PATCH 55/60] Clean-up docs and add warning about _skbuild. --- doc/install/python.rst | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/doc/install/python.rst b/doc/install/python.rst index b2eef513e3..43f500b1b5 100644 --- a/doc/install/python.rst +++ b/doc/install/python.rst @@ -74,10 +74,10 @@ Advanced options By default Arbor is installed with multi-threading enabled. To enable more advanced forms of parallelism and other features, Arbor comes with a few -compilation options. These are of the form ``-D=``, must be -separated from the actual ``pip`` invocation by a double dash ``--`` and can be -used on both local (``pip3 install ./arbor``) and remote (``pip3 install -arbor``) copies of Arbor. +compilation options. These are of the form ``-D=``, must be appended +to the ``pip`` invocation via ``--install-option='-D<...> -D<...> ...'`` and can +be used on both local (``pip3 install ./arbor``) and remote (``pip3 install +arbor``) copies of Arbor. See the examples below. .. Note:: @@ -89,28 +89,29 @@ arbor``) copies of Arbor. If you had Arbor installed already, you may need to remove it first before you can (re)compile it with the flags you need. +.. Warning:: + + If you run into build issues while experimenting with build options, be sure + to remove the ``_skbuild`` directory. + The following flags can be used to configure the installation: -* ``-DARB_WITH_NEUROML=``: Enable support for NeuroML2 morphologies, +* ``ARB_WITH_NEUROML=``: Enable support for NeuroML2 morphologies, requires ``libxml2`` library. Default ``OFF`` -* ``-DARB_WITH__MPI=``: Enable MPI support, requires MPI library. +* ``ARB_WITH__MPI=``: Enable MPI support, requires MPI library. Default ``OFF``. -* ``-DARB_GPU=``: Enable GPU support for NVIDIA GPUs +* ``ARB_GPU=``: Enable GPU support for NVIDIA GPUs with nvcc using ``cuda``, or with clang using ``cuda-clang`` (both require cudaruntime). Enable GPU support for AMD GPUs with hipcc using ``hip``. By default set to ``none``, which disables GPU support. -* ``-DARB_VECTORIZE=``: Enable vectorization. The architecture argument, +* ``ARB_VECTORIZE=``: Enable vectorization. The architecture argument, documented below, may also have to be set appropriately to generated vectorized code. See :ref:`install-architecture` for details. -* ``-DARB_ARCH=``: CPU micro-architecture to target. The advised +* ``ARB_ARCH=``: CPU micro-architecture to target. The advised default is ``native``. See `here `_ for a full list of options. -Finally, some flags can be be passed after a second set of ``--`` - -* ``-j N``: Use ``N`` processes for compilation, used to speed up builds. - .. note:: There are more, advanced flags that can be set. We are using ``sk-build`` and @@ -136,33 +137,33 @@ In the examples below we assume you are installing from a local copy. .. code-block:: bash - pip3 install ./arbor -- -DARB_WITH_MPI=ON + pip3 install ./arbor --install-option='-DARB_WITH_MPI=ON' **Compile with** :ref:`vectorization ` on a system with a SkyLake :ref:`architecture `: .. code-block:: bash - pip3 install ./arbor -- -DARB_VECTORIZE=ON -DARB_ARCH=skylake + pip3 install ./arbor --install-option='-DARB_VECTORIZE=ON -DARB_ARCH=skylake' **Enable NVIDIA GPUs (compiled with nvcc)**. This requires the :ref:`CUDA toolkit `: .. code-block:: bash - pip3 install ./arbor -- -DARB_GPU=cuda + pip3 install ./arbor --install-option='-DARB_GPU=cuda' **Enable NVIDIA GPUs (compiled with clang)**. This also requires the :ref:`CUDA toolkit `: .. code-block:: bash - pip3 install ./arbor -- -DARB_GPU=cuda-clang + pip3 install ./arbor --install-option='-DARB_GPU=cuda-clang' **Enable AMD GPUs (compiled with hipcc)**. This requires setting the ``CC`` and ``CXX`` :ref:`environment variables ` .. code-block:: bash - pip3 install ./arbor -- -DARB_GPU=hip + pip3 install ./arbor --install-option='-DARB_GPU=hip' Note on performance ------------------- From d948b2116fc7c5cd435331d25ccd0d6826304244 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Fri, 21 Jan 2022 08:22:15 +0100 Subject: [PATCH 56/60] Minor fixes in docs. --- doc/install/python.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/install/python.rst b/doc/install/python.rst index 43f500b1b5..12040b010d 100644 --- a/doc/install/python.rst +++ b/doc/install/python.rst @@ -98,7 +98,7 @@ The following flags can be used to configure the installation: * ``ARB_WITH_NEUROML=``: Enable support for NeuroML2 morphologies, requires ``libxml2`` library. Default ``OFF`` -* ``ARB_WITH__MPI=``: Enable MPI support, requires MPI library. +* ``ARB_WITH_MPI=``: Enable MPI support, requires MPI library. Default ``OFF``. * ``ARB_GPU=``: Enable GPU support for NVIDIA GPUs with nvcc using ``cuda``, or with clang using ``cuda-clang`` (both require @@ -114,9 +114,9 @@ The following flags can be used to configure the installation: .. note:: - There are more, advanced flags that can be set. We are using ``sk-build`` and - ``CMake`` under the hood, so all flags and options valid in ``CMake`` can be - used in this fashion. + There are more, advanced flags that can be set. We are using ``scikit-build`` + and ``CMake`` under the hood, so all flags and options valid in ``CMake`` can + be used in this fashion. Detailed instructions on how to install using CMake are in the :ref:`Python configuration ` section of the :ref:`installation guide From 6fe8844643ef182183cda83ab020a830184dac3a Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Fri, 21 Jan 2022 12:38:18 +0100 Subject: [PATCH 57/60] Fix absurd mess made by skbuild/pip/cmake. It's a conspiracy. --- doc/install/python.rst | 18 +++++++++++++----- pyproject.toml | 3 --- 2 files changed, 13 insertions(+), 8 deletions(-) delete mode 100644 pyproject.toml diff --git a/doc/install/python.rst b/doc/install/python.rst index 12040b010d..c2fe505b54 100644 --- a/doc/install/python.rst +++ b/doc/install/python.rst @@ -91,9 +91,17 @@ arbor``) copies of Arbor. See the examples below. .. Warning:: + Before you attempt a build with any options, you will need to install the + following + + ``pip3 install ninja scikit-build wheel setuptools numpy`` + If you run into build issues while experimenting with build options, be sure to remove the ``_skbuild`` directory. + Also, be very careful to pass each option individually via + ``--install-option="..."``. + The following flags can be used to configure the installation: * ``ARB_WITH_NEUROML=``: Enable support for NeuroML2 morphologies, @@ -137,33 +145,33 @@ In the examples below we assume you are installing from a local copy. .. code-block:: bash - pip3 install ./arbor --install-option='-DARB_WITH_MPI=ON' + pip3 install ./arbor --install-option="-DARB_WITH_MPI=ON" **Compile with** :ref:`vectorization ` on a system with a SkyLake :ref:`architecture `: .. code-block:: bash - pip3 install ./arbor --install-option='-DARB_VECTORIZE=ON -DARB_ARCH=skylake' + pip3 install ./arbor --install-option="-DARB_VECTORIZE=ON" --install-option="-DARB_ARCH=skylake" **Enable NVIDIA GPUs (compiled with nvcc)**. This requires the :ref:`CUDA toolkit `: .. code-block:: bash - pip3 install ./arbor --install-option='-DARB_GPU=cuda' + pip3 install ./arbor --install-option="-DARB_GPU=cuda" **Enable NVIDIA GPUs (compiled with clang)**. This also requires the :ref:`CUDA toolkit `: .. code-block:: bash - pip3 install ./arbor --install-option='-DARB_GPU=cuda-clang' + pip3 install ./arbor --install-option="-DARB_GPU=cuda-clang" **Enable AMD GPUs (compiled with hipcc)**. This requires setting the ``CC`` and ``CXX`` :ref:`environment variables ` .. code-block:: bash - pip3 install ./arbor --install-option='-DARB_GPU=hip' + pip3 install ./arbor --install-option="-DARB_GPU=hip" Note on performance ------------------- diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index 5a6f95468e..0000000000 --- a/pyproject.toml +++ /dev/null @@ -1,3 +0,0 @@ -[build-system] -requires = ["setuptools", "wheel", "scikit-build", "cmake", "ninja"] -description-file = "python/readme.md" From ea39a6f0bde06c293a5327d4274f1722b1935364 Mon Sep 17 00:00:00 2001 From: Brent Huisman Date: Fri, 21 Jan 2022 15:20:24 +0100 Subject: [PATCH 58/60] Update arbor.config() documentation --- doc/python/hardware.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/python/hardware.rst b/doc/python/hardware.rst index 33c403ba10..a18dd6a89d 100644 --- a/doc/python/hardware.rst +++ b/doc/python/hardware.rst @@ -27,6 +27,8 @@ Helper functions for checking cmake or environment variables, as well as configu * ``ARB_GPU_ENABLED`` * ``ARB_VECTORIZE`` * ``ARB_WITH_PROFILING`` + * ``ARB_WITH_NEUROML`` + * ``ARB_USE_BUNDLED_LIBS`` * ``ARB_VERSION`` * ``ARB_ARCH`` @@ -37,7 +39,7 @@ Helper functions for checking cmake or environment variables, as well as configu import arbor arbor.config() - {'mpi': True, 'mpi4py': True, 'gpu': False, 'vectorize': True, 'profiling': True, 'version': '0.5.3-dev', 'arch': 'native'} + {'mpi': True, 'mpi4py': True, 'gpu': False, 'vectorize': True, 'profiling': True, 'neuroml': True, 'bundled': True, 'version': '0.5.3-dev', 'arch': 'native'} .. function:: mpi_init() From c3d9380a3af6f5eb5f2f33e4972f74a60d6bc3e6 Mon Sep 17 00:00:00 2001 From: Brent Huisman Date: Fri, 21 Jan 2022 15:32:12 +0100 Subject: [PATCH 59/60] improved and simplified Python install instructions --- doc/install/python.rst | 53 ++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/doc/install/python.rst b/doc/install/python.rst index c2fe505b54..3b931ad38e 100644 --- a/doc/install/python.rst +++ b/doc/install/python.rst @@ -6,8 +6,11 @@ Python Installation Arbor's Python API will be the most convenient interface for most users. .. note:: - Arbor requires Python version 3.6 and later. It is advised that you update `pip` as well. + Arbor requires Python version 3.6 and later. It is advised that you update ``pip`` as well. We strongly encourage using ``pip`` to install Arbor. + + To get help in case of problems installing with pip, run pip with the ``--verbose`` flag, and attach the output + (along with the pip command itself) to a ticket on `Arbor's issues page `_. Getting Arbor ------------- @@ -21,15 +24,6 @@ The easiest way to get Arbor is with pip3 install arbor -.. note:: - For other platforms, `pip` will build Arbor from source. - You will need to have some development packages installed in order to build Arbor this way. - - * Ubuntu/Debian: `git cmake gcc python3-dev python3-pip libxml2-dev` - * Fedora/CentOS/OpenSuse: `git cmake gcc-c++ python3-devel python3-pip libxml2-devel` - * MacOS: get `brew` `here `_ and run `brew install cmake clang python3 libxml2` - * Windows: the simplest way is to use `WSL `_ and then follow the instructions for Ubuntu. - To test that Arbor is available, try the following in a Python interpreter to see information about the version and enabled features: @@ -42,9 +36,20 @@ to see information about the version and enabled features: You are now ready to use Arbor! You can continue reading these documentation pages, have a look at the :ref:`Python API reference`, or visit the :ref:`tutorial`. -.. Note:: - To get help in case of problems installing with pip, run pip with the ``--verbose`` flag, and attach the output - (along with the pip command itself) to a ticket on `Arbor's issues page `_. +.. Warning:: + + For builds from Arbor's source, you will need to have some development packages installed. Installing Arbor + for any other platforms than listed above, ``pip`` will attempt a build from source and thus require these + packages as well. + + * Ubuntu/Debian: `git cmake gcc python3-dev python3-pip libxml2-dev` + * Fedora/CentOS/OpenSuse: `git cmake gcc-c++ python3-devel python3-pip libxml2-devel` + * MacOS: get `brew` `here `_ and run `brew install cmake clang python3 libxml2` + * Windows: the simplest way is to use `WSL `_ and then follow the instructions for Ubuntu. + + In addition, you'll need a few Python packages present: + + ``pip3 install ninja scikit-build wheel setuptools numpy`` .. _in_python_custom: @@ -75,31 +80,17 @@ Advanced options By default Arbor is installed with multi-threading enabled. To enable more advanced forms of parallelism and other features, Arbor comes with a few compilation options. These are of the form ``-D=``, must be appended -to the ``pip`` invocation via ``--install-option='-D<...> -D<...> ...'`` and can +to the ``pip`` invocation via ``--install-option="-D<...>" --install-option="-D<...>" ...`` and can be used on both local (``pip3 install ./arbor``) and remote (``pip3 install arbor``) copies of Arbor. See the examples below. .. Note:: - ``pip`` compiles the Arbor C++ library and wrapper, as well as dependencies - you might not have had installed yet (e.g. ``numpy``). It may take a few - minutes. Pass the ``--verbose`` flag to pip to see the individual steps - being performed if you are concerned that progress is halting. - - If you had Arbor installed already, you may need to remove it first before - you can (re)compile it with the flags you need. - -.. Warning:: - - Before you attempt a build with any options, you will need to install the - following - - ``pip3 install ninja scikit-build wheel setuptools numpy`` - If you run into build issues while experimenting with build options, be sure - to remove the ``_skbuild`` directory. + to remove the ``_skbuild`` directory. If you had Arbor installed already, + you may need to remove it first before you can (re)compile it with the flags you need. - Also, be very careful to pass each option individually via + Also, make sure to pass each option individually via ``--install-option="..."``. The following flags can be used to configure the installation: From 54e7885f7b23a67317ceb7280ee8bf178d2d8714 Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Mon, 24 Jan 2022 13:10:26 +0100 Subject: [PATCH 60/60] Exclude loading catalogue on Daint. Need to figure out containers. --- ci/gitlab-cscs.yml | 2 +- test/unit/test_mechcat.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/ci/gitlab-cscs.yml b/ci/gitlab-cscs.yml index 39392368a5..819c4431e3 100644 --- a/ci/gitlab-cscs.yml +++ b/ci/gitlab-cscs.yml @@ -101,7 +101,7 @@ single_node_release: only: ['master', 'staging', 'trying'] stage: test script: - - unit + - unit --gtest_filter="-mechcat.loading" - unit-local - unit-modcc variables: diff --git a/test/unit/test_mechcat.cpp b/test/unit/test_mechcat.cpp index 05077ca2a1..431dffb08d 100644 --- a/test/unit/test_mechcat.cpp +++ b/test/unit/test_mechcat.cpp @@ -286,7 +286,6 @@ TEST(mechcat, loading) { EXPECT_NO_THROW(cat = &load_catalogue(LIBDIR "/dummy-catalogue.so")); ASSERT_NE(cat, nullptr); EXPECT_EQ(std::vector{"dummy"}, cat->mechanism_names()); - } #endif