diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e9fc48d..dccec8b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ env: IMEX_CACHE_NUMBER: 4 # Increase to reset cache jobs: build_and_test: - runs-on: tpi-ubuntu-latest + runs-on: ubuntu-22.04 strategy: fail-fast: false steps: diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 4b09254..9116a5b 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -9,7 +9,7 @@ permissions: read-all jobs: pre-commit: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4.1.1 - uses: actions/setup-python@v5 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index da75dba..4b996a9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: check-ast - id: check-builtin-literals @@ -19,13 +19,13 @@ repos: - id: trailing-whitespace exclude: '.*\.patch' - repo: https://github.com/psf/black - rev: 23.12.0 + rev: 24.3.0 hooks: - id: black args: ["--line-length", "80"] language_version: python3 - repo: https://github.com/PyCQA/bandit - rev: '1.7.7' + rev: '1.7.8' hooks: - id: bandit args: ["-c", ".bandit.yml"] @@ -35,7 +35,7 @@ repos: - id: isort name: isort (python) - repo: https://github.com/pycqa/flake8 - rev: 5.0.4 + rev: 7.0.0 hooks: - id: flake8 - repo: https://github.com/pocc/pre-commit-hooks diff --git a/conda-recipe/build.sh b/conda-recipe/build.sh index 6c7b5ab..c8f4503 100644 --- a/conda-recipe/build.sh +++ b/conda-recipe/build.sh @@ -27,17 +27,28 @@ popd # skip checkout/build of IMEX/LLVM if there is an install if [ ! -d "${INSTALLED_DIR}/imex/lib" ]; then - # FIXME work-around as long dpcpp conda packages are incomplete - export SYCL_DIR="/opt/intel/oneapi/compiler/latest/linux" - if [ ! -d "${SYCL_DIR}" ]; then - export SYCL_DIR="/opt/intel/oneapi/compiler/latest" - if [ ! -d "${SYCL_DIR}" ]; then - echo "Fatal error: SYCL_DIR not found" - exit 1 - fi - fi - # export SYCL_DIR=${CONDA_PREFIX} - echo "Using SYCLDIR=${SYCL_DIR}" + export SYCL_DIR=${CONDA_PREFIX} + echo "Using SYCL_DIR=${SYCL_DIR}" + + # grrrr + # as long as the conda packages differ from system oneAPI installs we need to explicitly provide the include dir for SYCL + # see also below in cmake call + # for root in "${CONDA_PREFIX}" "${BUILD_PREFIX}"; do + # spirvdir=$(find "${root}" -type d -name __spirv | head -n 1) + # if [ -d "${spirvdir}" ]; then + # SPIRV_INC_DIR=$(dirname "${spirvdir}") + # break + # fi + # done + # if [ -d "${SPIRV_INC_DIR}" ]; then + # echo "Using SPIRV_INC_DIR=${SPIRV_INC_DIR}" + # mkdir -p "${SRC_DIR}/grrrr/include" + # ln -s "${SPIRV_INC_DIR}" "${SRC_DIR}/grrrr/include/CL" + # SPIRV_INC_DIR="${SRC_DIR}/grrrr/include" + # else + # echo "Fatal error: SPIRV_INC_DIR not found" + # exit 1 + # fi rm -rf ${INSTALLED_DIR}/imex IMEX_SHA=$(cat imex_version.txt) @@ -83,10 +94,11 @@ if [ ! -d "${INSTALLED_DIR}/imex/lib" ]; then -DLLVM_ENABLE_ZSTD=OFF \ -DLLVM_ENABLE_ZLIB=OFF \ -DLLVM_EXTERNAL_PROJECTS="Imex" \ - -DLLVM_EXTERNAL_IMEX_SOURCE_DIR=. \ - -DLEVEL_ZERO_DIR=${INSTALLED_DIR}/level-zero \ - -DIMEX_ENABLE_SYCL_RUNTIME=1 \ - -DIMEX_ENABLE_L0_RUNTIME=1 + -DLLVM_EXTERNAL_IMEX_SOURCE_DIR=. + # -DLEVEL_ZERO_DIR=${INSTALLED_DIR}/level-zero \ + # -DIMEX_ENABLE_SYCL_RUNTIME=1 \ + # -DIMEX_ENABLE_L0_RUNTIME=1 \ + # -DCMAKE_CXX_FLAGS="-I${SPIRV_INC_DIR}" # grrrr cmake --build build cmake --install build --prefix=${INSTALLED_DIR}/imex popd diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index bef22c2..46a91a5 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -29,9 +29,10 @@ requirements: build: - {{compiler('gxx')}} - - sysroot_linux-64 >=2.28 # [linux] - # - dpcpp_linux-64 # [linux] - # - dpcpp_win-64 # [win] + - sysroot_linux-64 # [linux] +# - sysroot_linux-64 >=2.28 # [linux] + - dpcpp_linux-64 >=2024.1 # [linux] + - dpcpp_win-64 # [win] # - {{compiler('dpcpp')}} >={{required_compiler_and_mkl_version}},!={{excluded_compiler_version1}},!={{excluded_compiler_version2}} # [not osx] run: - numpy x.x diff --git a/examples/black_scholes.py b/examples/black_scholes.py index 6018ce8..ba5f1f7 100644 --- a/examples/black_scholes.py +++ b/examples/black_scholes.py @@ -22,6 +22,7 @@ python black_scholes.py -p M16Gb -b numpy """ + import argparse import os import time as time_mod diff --git a/examples/shallow_water.py b/examples/shallow_water.py index 8352cf5..06ea67b 100644 --- a/examples/shallow_water.py +++ b/examples/shallow_water.py @@ -23,6 +23,7 @@ python shallow_water.py -b numpy ... """ + import argparse import math import os diff --git a/examples/wave_equation.py b/examples/wave_equation.py index 93d86b9..b9dc507 100644 --- a/examples/wave_equation.py +++ b/examples/wave_equation.py @@ -23,6 +23,7 @@ python wave_equation.py -b numpy ... """ + import argparse import math import os diff --git a/sharpy/array_api.py b/sharpy/array_api.py index 956846a..d3c57a2 100644 --- a/sharpy/array_api.py +++ b/sharpy/array_api.py @@ -3,6 +3,7 @@ distributed implementation of the array API as defined here: https://data-apis.org/array-api/latest """ + from collections import OrderedDict api_categories = OrderedDict( diff --git a/sharpy/ndarray.py b/sharpy/ndarray.py index f0d561a..f442677 100644 --- a/sharpy/ndarray.py +++ b/sharpy/ndarray.py @@ -2,6 +2,7 @@ The array class for sharpy, a distributed implementation of the array API as defined here: https://data-apis.org/array-api/latest """ + # # See __init__.py for an implementation overview # diff --git a/src/LinAlgOp.cpp b/src/LinAlgOp.cpp index 1f57887..caa581b 100644 --- a/src/LinAlgOp.cpp +++ b/src/LinAlgOp.cpp @@ -5,7 +5,7 @@ */ #include -//#include +// #include #include "sharpy/Factory.hpp" #include "sharpy/LinAlgOp.hpp" #include "sharpy/NDArray.hpp" diff --git a/src/_sharpy.cpp b/src/_sharpy.cpp index 04ffdd0..2e9e6f4 100644 --- a/src/_sharpy.cpp +++ b/src/_sharpy.cpp @@ -149,7 +149,7 @@ void init(bool cw, const std::string &libidtr) { VT(VT_begin, vtWaitSym); \ py::gil_scoped_release release; \ Service::run(); \ - auto r = (_f).get().get() -> _a(); \ + auto r = (_f).get().get()->_a(); \ VT(VT_end, vtWaitSym); \ return r diff --git a/src/include/sharpy/CppTypes.hpp b/src/include/sharpy/CppTypes.hpp index 518f39e..62eda48 100644 --- a/src/include/sharpy/CppTypes.hpp +++ b/src/include/sharpy/CppTypes.hpp @@ -63,39 +63,17 @@ enum _RANKS : rank_type { }; template struct DTYPE {}; -template <> struct DTYPE { - constexpr static DTypeId value = FLOAT64; -}; -template <> struct DTYPE { - constexpr static DTypeId value = FLOAT32; -}; -template <> struct DTYPE { - constexpr static DTypeId value = INT64; -}; -template <> struct DTYPE { - constexpr static DTypeId value = INT32; -}; -template <> struct DTYPE { - constexpr static DTypeId value = INT16; -}; -template <> struct DTYPE { - constexpr static DTypeId value = INT8; -}; -template <> struct DTYPE { - constexpr static DTypeId value = UINT64; -}; -template <> struct DTYPE { - constexpr static DTypeId value = UINT32; -}; -template <> struct DTYPE { - constexpr static DTypeId value = UINT16; -}; -template <> struct DTYPE { - constexpr static DTypeId value = UINT8; -}; -template <> struct DTYPE { - constexpr static DTypeId value = BOOL; -}; +template <> struct DTYPE { constexpr static DTypeId value = FLOAT64; }; +template <> struct DTYPE { constexpr static DTypeId value = FLOAT32; }; +template <> struct DTYPE { constexpr static DTypeId value = INT64; }; +template <> struct DTYPE { constexpr static DTypeId value = INT32; }; +template <> struct DTYPE { constexpr static DTypeId value = INT16; }; +template <> struct DTYPE { constexpr static DTypeId value = INT8; }; +template <> struct DTYPE { constexpr static DTypeId value = UINT64; }; +template <> struct DTYPE { constexpr static DTypeId value = UINT32; }; +template <> struct DTYPE { constexpr static DTypeId value = UINT16; }; +template <> struct DTYPE { constexpr static DTypeId value = UINT8; }; +template <> struct DTYPE { constexpr static DTypeId value = BOOL; }; template struct TYPE {}; template <> struct TYPE { diff --git a/test/test_spmd.py b/test/test_spmd.py index 2b758ca..7507f50 100644 --- a/test/test_spmd.py +++ b/test/test_spmd.py @@ -1,9 +1,9 @@ import numpy as np import pytest +from mpi4py import MPI from utils import device import sharpy as sp -from mpi4py import MPI from sharpy import _sharpy_cw