diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml new file mode 100644 index 000000000..e682bf9e9 --- /dev/null +++ b/.github/workflows/linux-ci.yml @@ -0,0 +1,17 @@ +name: Linux CI - oneMKL backend + +on: + push: + branches: [ "develop" ] + pull_request: + branches: [ "develop" ] + workflow_dispatch: + +jobs: + CI: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build oneMKL + run: | + docker build . --file Dockerfile.ci --tag onemkl_0.2 diff --git a/.github/workflows/linux-nightly.yml b/.github/workflows/linux-nightly.yml new file mode 100644 index 000000000..cefc3b3e8 --- /dev/null +++ b/.github/workflows/linux-nightly.yml @@ -0,0 +1,15 @@ +name: Linux Nightly - oneMKL backend + +on: + schedule: + - cron: '00 7 * * 0,1,2,3,4,5,6' + workflow_dispatch: + +jobs: + Nightly: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build oneMKL + run: | + docker build . --file Dockerfile.nightly --tag onemkl_nightly_0.2:$(date +%Y%m%d) diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml new file mode 100644 index 000000000..5687dd8b5 --- /dev/null +++ b/.github/workflows/windows-ci.yml @@ -0,0 +1,75 @@ +name: Windows CI - oneMKL backend + +on: + push: + branches: [ "develop" ] + pull_request: + branches: [ "develop" ] + +jobs: + CI: + runs-on: ["${{ matrix.os }}"] + strategy: + # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. + fail-fast: false + matrix: + os: [windows-latest] + build_type: [Release] + include: + - os: windows-latest + cpp_compiler: icx + + steps: + - name: Install oneMKL and Intel C++/DPC++ compiler + id: basekit-install + shell: cmd + run: | + curl -o C:\oneapi_installer.exe https://registrationcenter-download.intel.com/akdlm/IRC_NAS/f96c71db-2c6c-45d9-8c1f-0348ef5885cf/w_BaseKit_p_2023.2.0.49396_offline.exe + dir C: + call "C:\oneapi_installer.exe" -s -a --silent --eula accept --install-dir "C:\Program Files (x86)\Intel\oneAPI" + + - name: Setup oneAPI environment + id: env-setup + shell: cmd + run: | + call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat" + echo "oneapi_libpath=%LIBRARY_PATH%" >> "%GITHUB_ENV%" + echo "oneapi_path=%PATH%" >> "%GITHUB_ENV%" + echo "oneapi_cpath=%CPATH%" >> "%GITHUB_ENV%" + echo "oneapi_mklroot=%MKLROOT%" >> "%GITHUB_ENV%" + + - uses: actions/checkout@v3 + - name: Set reusable strings + # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. + id: strings + run: | + echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" + + - uses: seanmiddleditch/gha-setup-ninja@master + - name: Configure and Build + id: build-step + env: + PATH: ${{ env.oneapi_path }} + CPATH: ${{ env.oneapi_cpath }} + LIBRARY_PATH: ${{ env.oneapi_libpath }} + LD_LIBRARY_PATH: ${{ env.oneapi_ld_libpath }} + MKLROOT: ${{ env.oneapi_mklroot }} + shell: cmd + run: | + ${{ matrix.cpp_compiler }} --version + cmake -B ${{ steps.strings.outputs.build-output-dir }} -G "Ninja" -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DBUILD_FUNCTIONAL_TESTS=OFF -S ${{ github.workspace }} + cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} +# Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). + + - name: Test + working-directory: ${{ steps.strings.outputs.build-output-dir }} + shell: cmd + env: + PATH: ${{ env.oneapi_path }} + CPATH: ${{ env.oneapi_cpath }} + LIBRARY_PATH: ${{ env.oneapi_libpath }} + LD_LIBRARY_PATH: ${{ env.oneapi_ld_libpath }} + # Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + # Github actions does not provide GPU-accelerated hosts, so run cpu only + run: ctest -V -R cpu --build-config ${{ matrix.build_type }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 41d799873..83e16526e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -284,8 +284,8 @@ else() endif() if(DEFINED REF_BLAS_ROOT) - find_file(REF_BLAS_LIBNAME NAMES blas.dll libblas.so HINTS ${REF_BLAS_ROOT} PATH_SUFFIXES lib lib64) - find_file(REF_CBLAS_LIBNAME NAMES cblas.dll libcblas.so HINTS ${REF_BLAS_ROOT} PATH_SUFFIXES lib lib64) + find_file(REF_BLAS_LIBNAME NAMES blas.dll libblas64.so HINTS ${REF_BLAS_ROOT} PATH_SUFFIXES lib lib64) + find_file(REF_CBLAS_LIBNAME NAMES cblas.dll libcblas64.so HINTS ${REF_BLAS_ROOT} PATH_SUFFIXES lib lib64) endif() # Add source directory and output to bin/ diff --git a/Dockerfile.ci b/Dockerfile.ci new file mode 100644 index 000000000..ab4d5e49c --- /dev/null +++ b/Dockerfile.ci @@ -0,0 +1,54 @@ +#=============================================================================== +# Copyright 2023 Intel Corporation +# Copyright (C) 2022 Heidelberg University, Engineering Mathematics and Computing Lab (EMCL) and Computing Centre (URZ) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# +# SPDX-License-Identifier: Apache-2.0 +#=============================================================================== + +# Get oneAPI BaseKit image from the Docker Hub Intel repo +FROM intel/oneapi-basekit:2023.2.1-devel-ubuntu22.04 AS BACKEND_MKL + +ARG DEBIAN_FRONTEND=noninteractive +ARG APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 + +# Make space in the docker image +RUN echo "Removing large directories" +# deleting 15GB +RUN rm -rf /usr/share/dotnet/ +RUN df -h + +RUN apt-get install -y gpg-agent +RUN wget -qO - https://repositories.intel.com/graphics/intel-graphics.key | gpg --dearmor --output /usr/share/keyrings/intel-graphics.gpg +RUN echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/graphics/ubuntu focal main' | tee -a /etc/apt/sources.list.d/intel.list + +# Install build essentials +RUN apt-get update -y && \ + apt-get install -y -o=Dpkg::Use-Pty=0 \ + cmake ninja-build + +# Setup Working Directory +COPY . /home/oneMKL +RUN mkdir -p /home/oneMKL/BUILD +WORKDIR /home/oneMKL/BUILD + +# Build +RUN cmake -G "Ninja" .. -DBUILD_FUNCTIONAL_TESTS=OFF -DCMAKE_CXX_COMPILER=icpx +RUN ninja + +# Run cpu device only +# Known Intel GPU support issue in docker https://github.com/docker/cli/issues/2063. +# Test +RUN ctest -R cpu diff --git a/Dockerfile.nightly b/Dockerfile.nightly new file mode 100644 index 000000000..67cdd4794 --- /dev/null +++ b/Dockerfile.nightly @@ -0,0 +1,61 @@ +#=============================================================================== +# Copyright 2023 Intel Corporation +# Copyright (C) 2022 Heidelberg University, Engineering Mathematics and Computing Lab (EMCL) and Computing Centre (URZ) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# +# SPDX-License-Identifier: Apache-2.0 +#=============================================================================== + +# Get oneAPI BaseKit image from the Docker Hub Intel repo +FROM intel/oneapi-basekit:2023.2.1-devel-ubuntu22.04 AS BACKEND_MKL + +ARG DEBIAN_FRONTEND=noninteractive +ARG APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 +ARG NETLIB_VERSION_TAG=3.11.0 + +# Make space in the docker image +RUN echo "Removing large directories" +# deleting 15GB +RUN rm -rf /usr/share/dotnet/ +RUN df -h + +# Install build essentials +RUN apt-get update -y && \ + apt-get install -y -o=Dpkg::Use-Pty=0 \ + cmake ninja-build gcc gfortran + +# Setup Reference BLAS and LAPACK Implementation for functional testing +RUN mkdir -p /home/Reference-LAPACK +WORKDIR /home/Reference-LAPACK +RUN wget https://github.com/Reference-LAPACK/lapack/archive/refs/tags/v${NETLIB_VERSION_TAG}.tar.gz && tar -xf v${NETLIB_VERSION_TAG}.tar.gz + +# Build Reference BLAS and LAPACK +WORKDIR /home/Reference-LAPACK/lapack-${NETLIB_VERSION_TAG}/BUILD +RUN cmake -G "Ninja" -DBUILD_INDEX64=ON -DCBLAS=ON -DLAPACKE=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_LIBDIR=/home/Reference-LAPACK/OUTPUT/lib .. +RUN ninja install + +# Setup Working Directory +COPY . /home/oneMKL +RUN mkdir -p /home/oneMKL/BUILD +WORKDIR /home/oneMKL/BUILD + +# Build +RUN cmake -G "Ninja" .. -DBUILD_EXAMPLES=OFF -DCMAKE_CXX_COMPILER=icpx -DREF_BLAS_ROOT=/home/Reference-LAPACK/OUTPUT -DREF_LAPACK_ROOT=/home/Reference-LAPACK/OUTPUT +RUN ninja + +# Run cpu device only +# Known Intel GPU support issue in docker https://github.com/docker/cli/issues/2063. +# Test +RUN ctest -R cpu diff --git a/README.md b/README.md index 37a753166..2327f9c3c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # oneAPI Math Kernel Library (oneMKL) Interfaces +|Linux|Windows +|---|---| +|[![oneMKL backend](https://github.com/virajmalia/oneMKL/actions/workflows/linux-ci.yml/badge.svg)](https://github.com/virajmalia/oneMKL/actions/workflows/linux-ci.yml)|[![oneMKL backend](https://github.com/virajmalia/oneMKL/actions/workflows/windows-ci.yml/badge.svg)](https://github.com/virajmalia/oneMKL/actions/workflows/windows-ci.yml)| + oneAPI logo oneMKL Interfaces is an open-source implementation of the oneMKL Data Parallel C++ (DPC++) interface according to the [oneMKL specification](https://spec.oneapi.com/versions/latest/elements/oneMKL/source/index.html). It works with multiple devices (backends) using device-specific libraries underneath. diff --git a/tests/unit_tests/CMakeLists.txt b/tests/unit_tests/CMakeLists.txt index 464d8841c..11dc10069 100644 --- a/tests/unit_tests/CMakeLists.txt +++ b/tests/unit_tests/CMakeLists.txt @@ -17,11 +17,7 @@ # SPDX-License-Identifier: Apache-2.0 #=============================================================================== -if("blas" IN_LIST TARGET_DOMAINS) - find_package(CBLAS REQUIRED) -endif() - -if("lapack" IN_LIST TARGET_DOMAINS) +if("blas" IN_LIST TARGET_DOMAINS OR "lapack" IN_LIST TARGET_DOMAINS) find_package(LAPACKE REQUIRED) endif()