diff --git a/.github/workflows/test_spack.yml b/.github/workflows/test_spack.yml new file mode 100644 index 00000000..528a4087 --- /dev/null +++ b/.github/workflows/test_spack.yml @@ -0,0 +1,127 @@ +name: Test spack + +on: + push: + pull_request: + branches: + - master + +jobs: + test-spack: + runs-on: ubuntu-22.04 + + permissions: + packages: write + + defaults: + run: + shell: bash + + strategy: + matrix: + config: + - { + backend: 'mpi', + tests: true, + device: '', + } + - { + backend: 'ucx', + tests: true, + device: '', + } + + python-version: ['3.11'] + + spack-version: ['develop'] + + micro-arch: ['x86_64_v3'] + + fail-fast: false + + env: + SHLVL: "1" + OMPI_ALLOW_RUN_AS_ROOT: "1" + OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: "1" + SPACK_DISABLE_LOCAL_CONFIG: "true" + SPACK_USER_CACHE_PATH: "/tmp/spack" + + steps: + + - name: install additional ubuntu packages + run: | + sudo apt-get update -qq + sudo apt-get install -y gfortran libblas-dev + + - name: clone ghex + uses: actions/checkout@v4 + with: + path: ghex + submodules: recursive + + - name: clone ghex spack repo + run: | + git clone --depth=1 --branch add_ghex https://github.com/boeschf/spack-repos.git repos + + - name: clone spack + run: | + git clone -c feature.manyFiles=true --depth 1 \ + --branch ${{ matrix.spack-version }} \ + https://github.com/spack/spack.git \ + spack + + - name: initialize spack and add online buildcache + run: | + cat < spack/etc/spack/config.yaml + config: + install_tree: + padded_length: 128 + build_jobs: 4 + EOF + + cat < spack/etc/spack/packages.yaml + packages: + all: + require: + - 'target=${{ matrix.micro-arch }}' + - '%gcc' + EOF + + + source spack/share/spack/setup-env.sh + spack compiler find + spack mirror add --unsigned local-buildcache oci://ghcr.io/boeschf/spack-buildcache + spack repo add repos + spack reindex + + - name: build and install ghex through spack dev-build (CPU) + if: ${{ !matrix.config.device }} + run: | + source spack/share/spack/setup-env.sh + # print dependencies + spack spec -I --reuse ghex@develop \ + backend=${{ matrix.config.backend }} \ + ^python@${{ matrix.python-version }} + # dev-build does not respect test dependencies - workaround + spack install --reuse googletest + spack load googletest + # need `--dirty` here for environment variables and googletest test dependency to propagate + spack dev-build --test=root --dirty --reuse --source-path ghex ghex@develop \ + backend=${{ matrix.config.backend }} \ + ^python@${{ matrix.python-version }} + + - name: build and install ghex through spack dev-build (GPU) + if: ${{ matrix.config.device }} + run: | + source spack/share/spack/setup-env.sh + # print dependencies + spack spec -I --reuse ghex@develop \ + backend=${{ matrix.config.backend }} \ + ${{ matrix.config.device }} \ + ^python@${{ matrix.python-version }} + # dev-build + spack dev-build --dirty --reuse --source-path ghex ghex@develop \ + backend=${{ matrix.config.backend }} \ + ${{ matrix.config.device }} \ + ^python@${{ matrix.python-version }} + diff --git a/README.md b/README.md index 1fe3a5c0..369de0f9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause) [![CI](https://github.com/ghex-org/GHEX/actions/workflows/CI.yml/badge.svg)](https://github.com/ghex-org/GHEX/actions/workflows/CI.yml) [![Pip](https://github.com/ghex-org/GHEX/actions/workflows/test_pip.yml/badge.svg)](https://github.com/ghex-org/GHEX/actions/workflows/test_pip.yml) +[![Spack](https://github.com/ghex-org/GHEX/actions/workflows/test_spack.yml/badge.svg)](https://github.com/ghex-org/GHEX/actions/workflows/test_spack.yml) # GHEX Generic exascale-ready library for halo-exchange operations on variety of grids/meshes. @@ -76,6 +77,29 @@ python -m pip install 'git+https://github.com/ghex-org/GHEX.git#subdirectory=bin | `GHEX_GPU_ARCH=` | list of archs | `"60;70;75;80"`/ `"gfx900;gfx906"` | GPU architecture | `GHEX_TRANSPORT_BACKEND=` | `{MPI, UCX, LIBFABRIC}` | `MPI` | Choose transport backend +#### Spack Install + +- make sure you have an up-to-date [spack installation](https://github.com/spack/spack) +- clone the ghex spack repo +``` +git clone https://github.com/ghex-org/spack-repos.git +git clone --depth=1 ttps://github.com/boeschf/spack-repos.git path/to/ghex-repos +``` +- add the repo to spack +``` +spack repo add path/to/ghex-repos +spack reindex +``` +- install GHEX using spack +``` +spack install ghex backend=mpi +``` +- for more build/install options, see +``` +spack info ghex +``` + + ### Acknowledgements The development of GHEX was supported partly by The Partnership for Advanced diff --git a/bindings/python/requirements-test.txt b/bindings/python/requirements-test.txt index cf9b925e..62dd1216 100644 --- a/bindings/python/requirements-test.txt +++ b/bindings/python/requirements-test.txt @@ -1,13 +1,4 @@ -# -# This file is autogenerated by pip-compile with Python 3.11 -# by the following command: -# -# pip-compile --annotation-style=line --extra=test --output-file=requirements-test.txt pyproject.toml -# -iniconfig==2.0.0 # via pytest -mpi4py==3.1.5 # via ghex (pyproject.toml) -numpy==1.26.2 # via ghex (pyproject.toml) -packaging==23.2 # via pytest -pluggy==1.3.0 # via pytest -pytest==7.4.3 # via ghex (pyproject.toml), pytest-mpi -pytest-mpi==0.6 # via ghex (pyproject.toml) +mpi4py +numpy +pytest +pytest-mpi diff --git a/cmake/ghex_python.cmake b/cmake/ghex_python.cmake index b51d1d42..572c26f8 100644 --- a/cmake/ghex_python.cmake +++ b/cmake/ghex_python.cmake @@ -12,8 +12,8 @@ if (GHEX_BUILD_PYTHON_BINDINGS) set(venv_bin_dir "${venv}/bin") set(reqs "${PROJECT_SOURCE_DIR}/bindings/python/requirements-test.txt") message("Creating VENV from ${Python3_EXECUTABLE} to ${VENV}") - execute_process(COMMAND_ECHO STDOUT COMMAND ${Python3_EXECUTABLE} -m venv ${venv} ) - execute_process(COMMAND_ECHO STDOUT COMMAND ${venv_bin_dir}/pip install -U pip setuptools wheel pybind11-stubgen) + execute_process(COMMAND_ECHO STDOUT COMMAND ${Python3_EXECUTABLE} -m venv --system-site-packages ${venv} ) + execute_process(COMMAND_ECHO STDOUT COMMAND ${venv_bin_dir}/pip install pip setuptools wheel pybind11-stubgen) execute_process(COMMAND_ECHO STDOUT COMMAND ${venv_bin_dir}/pip install -r ${reqs} ) #execute_process (COMMAND "${Python3_EXECUTABLE}" -m venv ${venv}) @@ -27,10 +27,6 @@ if (GHEX_BUILD_PYTHON_BINDINGS) ## Launch a new search find_package (Python3 REQUIRED COMPONENTS Interpreter Development.Module) else() - #if(DEFINED PYTHON_EXECUTABLE) - # set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE}) - #endif() - #set(Python_FIND_STRATEGY LOCATION) find_package (Python3 REQUIRED COMPONENTS Interpreter Development.Module) endif() diff --git a/test/bindings/python/CMakeLists.txt b/test/bindings/python/CMakeLists.txt index e9dc6c89..f0f907f3 100644 --- a/test/bindings/python/CMakeLists.txt +++ b/test/bindings/python/CMakeLists.txt @@ -14,7 +14,7 @@ function(ghex_reg_pytest t) ${CMAKE_CURRENT_SOURCE_DIR}/test_${t}.py) add_test( NAME py_${t} - COMMAND ${PYTHON_EXECUTABLE} -m pytest -s ${CMAKE_CURRENT_BINARY_DIR}/test_${t}.py + COMMAND ${venv_bin_dir}/python -m pytest -s ${CMAKE_CURRENT_BINARY_DIR}/test_${t}.py WORKING_DIRECTORY ${pyghex_test_workdir}) set_tests_properties(py_${t} PROPERTIES RUN_SERIAL ON) endfunction() @@ -25,7 +25,7 @@ function(ghex_reg_parallel_pytest t n) add_test( NAME py_${t}_parallel COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${n} ${MPIEXEC_PREFLAGS} - ${PYTHON_EXECUTABLE} -m pytest -s --with-mpi ${CMAKE_CURRENT_BINARY_DIR}/test_${t}.py + ${venv_bin_dir}/python -m pytest -s --with-mpi ${CMAKE_CURRENT_BINARY_DIR}/test_${t}.py WORKING_DIRECTORY ${pyghex_test_workdir}) set_tests_properties(py_${t}_parallel PROPERTIES RUN_SERIAL ON) endfunction() @@ -36,5 +36,4 @@ ghex_reg_parallel_pytest(context 4) ghex_reg_parallel_pytest(structured_domain_descriptor 4) ghex_reg_parallel_pytest(structured_pattern 4) -#ghex_reg_pytest(unstructured_domain_descriptor) ghex_reg_parallel_pytest(unstructured_domain_descriptor 4)