Skip to content

Commit

Permalink
[SYCL][BLAS] Move portBLAS to UXL Foundation as generic SYCL BLAS (#618)
Browse files Browse the repository at this point in the history
Signed-off-by: nscipione <[email protected]>
Co-authored-by: Romain Biessy <[email protected]>
  • Loading branch information
s-Nick and Rbiessy authored Dec 20, 2024
1 parent 044479d commit db520e4
Show file tree
Hide file tree
Showing 36 changed files with 1,839 additions and 1,829 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ jobs:
fail-fast: false
matrix:
include:
- config: portBLAS
- config: generic SYCL BLAS
domain: blas
build_options: -DREF_BLAS_ROOT=${PWD}/lapack/install -DENABLE_PORTBLAS_BACKEND=ON -DENABLE_MKLCPU_BACKEND=OFF -DPORTBLAS_TUNING_TARGET=INTEL_CPU
build_options: -DREF_BLAS_ROOT=${PWD}/lapack/install -DENABLE_GENERIC_BLAS_BACKEND=ON -DENABLE_MKLCPU_BACKEND=OFF -DGENERIC_BLAS_TUNING_TARGET=INTEL_CPU
- config: portFFT
domain: dft
build_options: -DENABLE_PORTFFT_BACKEND=ON -DENABLE_MKLCPU_BACKEND=OFF
Expand Down
13 changes: 9 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ endif()
option(ENABLE_CUBLAS_BACKEND "Enable the cuBLAS backend for the BLAS interface" OFF)
option(ENABLE_ROCBLAS_BACKEND "Enable the rocBLAS backend for the BLAS interface" OFF)
option(ENABLE_NETLIB_BACKEND "Enable the Netlib backend for the BLAS interface" OFF)
option(ENABLE_PORTBLAS_BACKEND "Enable the portBLAS backend for the BLAS interface. Cannot be used with other BLAS backends." OFF)
option(ENABLE_GENERIC_BLAS_BACKEND "Enable the generic BLAS backend for the BLAS interface. Cannot be used with other BLAS backends." OFF)

# rand
option(ENABLE_CURAND_BACKEND "Enable the cuRAND backend for the RNG interface" OFF)
Expand Down Expand Up @@ -76,14 +76,19 @@ option(BUILD_EXAMPLES "" ON)
## Documentation
option(BUILD_DOC "" OFF)

if(DEFINED ENABLE_PORTBLAS_BACKEND)
message(WARNING "PORTBLAS_BACKEND is deprecated, please use ENABLE_GENERIC_BLAS_BACKEND.")
set(ENABLE_GENERIC_BLAS_BACKEND ${ENABLE_PORTBLAS_BACKEND})
endif()

## Supported domains
set(DOMAINS_LIST "")
if(ENABLE_MKLCPU_BACKEND
OR ENABLE_MKLGPU_BACKEND
OR ENABLE_CUBLAS_BACKEND
OR ENABLE_ROCBLAS_BACKEND
OR ENABLE_NETLIB_BACKEND
OR ENABLE_PORTBLAS_BACKEND)
OR ENABLE_GENERIC_BLAS_BACKEND)
list(APPEND DOMAINS_LIST "blas")
endif()
if(ENABLE_MKLCPU_BACKEND
Expand Down Expand Up @@ -112,13 +117,13 @@ if(ENABLE_MKLCPU_BACKEND
list(APPEND DOMAINS_LIST "sparse_blas")
endif()

if(ENABLE_PORTBLAS_BACKEND
if(ENABLE_GENERIC_BLAS_BACKEND
AND (ENABLE_MKLCPU_BACKEND
OR ENABLE_MKLGPU_BACKEND
OR ENABLE_CUBLAS_BACKEND
OR ENABLE_ROCBLAS_BACKEND
OR ENABLE_NETLIB_BACKEND))
message(FATAL_ERROR "ENABLE_PORTBLAS_BACKEND cannot be enabled at the same time as other BLAS backends.")
message(FATAL_ERROR "ENABLE_GENERIC_BLAS_BACKEND cannot be enabled at the same time as other BLAS backends.")
endif()

if (ENABLE_PORTFFT_BACKEND
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ oneMath is part of the [UXL Foundation](http://www.uxlfoundation.org).
<td align="center">AMD GPU</td>
</tr>
<tr>
<td align="center"><a href="https://github.com/codeplaysoftware/portBLAS"> portBLAS </a></td>
<td align="center"><a href="https://github.com/uxlfoundation/generic-sycl-components/tree/main/onemath/sycl/blas"> generic SYCL BLAS </a></td>
<td align="center">x86 CPU, Intel GPU, NVIDIA GPU, AMD GPU, Other SYCL devices (unsupported)</td>
</tr>
<tr>
Expand Down Expand Up @@ -192,7 +192,7 @@ Supported compilers include:
<td align="center">Dynamic, Static</td>
</tr>
<tr>
<td align="center">portBLAS</td>
<td align="center">generic SYCL BLAS</td>
<td align="center">Intel DPC++</br>Open DPC++</td>
<td align="center">Dynamic, Static</td>
</tr>
Expand All @@ -203,7 +203,7 @@ Supported compilers include:
<td align="center">Dynamic, Static</td>
</tr>
<tr>
<td align="center">portBLAS</td>
<td align="center">generic SYCL BLAS</td>
<td align="center">Intel DPC++</br>Open DPC++</td>
<td align="center">Dynamic, Static</td>
</tr>
Expand All @@ -214,7 +214,7 @@ Supported compilers include:
<td align="center">Dynamic, Static</td>
</tr>
<tr>
<td align="center">portBLAS</td>
<td align="center">generic SYCL BLAS</td>
<td align="center">Open DPC++</td>
<td align="center">Dynamic, Static</td>
</tr>
Expand All @@ -225,13 +225,13 @@ Supported compilers include:
<td align="center">Dynamic, Static</td>
</tr>
<tr>
<td align="center">portBLAS</td>
<td align="center">generic SYCL BLAS</td>
<td align="center">Open DPC++</td>
<td align="center">Dynamic, Static</td>
</tr>
<tr>
<td rowspan=1 align="center">Other SYCL devices (unsupported)</td>
<td align="center">portBLAS</td>
<td align="center">generic SYCL BLAS</td>
<td align="center">Intel DPC++</br>Open DPC++</td>
<td align="center">Dynamic, Static</td>
</tr>
Expand Down Expand Up @@ -549,7 +549,7 @@ Product | Supported Version | License
[AMD rocFFT](https://github.com/ROCm/rocFFT) | rocm-5.4.3 | [AMD License](https://github.com/ROCm/rocFFT/blob/rocm-5.4.3/LICENSE.md)
[AMD rocSPARSE](https://github.com/ROCm/rocSPARSE) | 3.1.2 | [AMD License](https://github.com/ROCm/rocSPARSE/blob/develop/LICENSE.md)
[NETLIB LAPACK](https://www.netlib.org/) | [5d4180c](https://github.com/Reference-LAPACK/lapack/commit/5d4180cf8288ae6ad9a771d18793d15bd0c5643c) | [BSD like license](http://www.netlib.org/lapack/LICENSE.txt)
[portBLAS](https://github.com/codeplaysoftware/portBLAS) | 0.1 | [Apache License v2.0](https://github.com/codeplaysoftware/portBLAS/blob/main/LICENSE)
[Generic SYCL BLAS](https://github.com/uxlfoundation/generic-sycl-components/tree/main/onemath/sycl/blas) | 0.1 | [Apache License v2.0](https://github.com/uxlfoundation/generic-sycl-components/blob/main/LICENSE)
[portFFT](https://github.com/codeplaysoftware/portFFT) | 0.1 | [Apache License v2.0](https://github.com/codeplaysoftware/portFFT/blob/main/LICENSE)

---
Expand Down
49 changes: 24 additions & 25 deletions docs/building_the_project_with_dpcpp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ or ``clang++`` and ``clang`` respectively when using the Open DPC++ Compiler.
Backends should be enabled by setting ``-DENABLE_<BACKEND_NAME>_BACKEND=True``
for each desired backend. By default, only the ``MKLGPU`` and ``MKLCPU``
backends are enabled. Multiple backends for multiple device vendors can be
enabled at once (albeit with limitations when using portBLAS and portFFT). The
supported backends for the compilers are given in the table at `oneMath
enabled at once (albeit with limitations when using oneMath generic SYCL BLAS and portFFT).
The supported backends for the compilers are given in the table at `oneMath
supported configurations table
<https://github.com/uxlfoundation/oneMath?tab=readme-ov-file#supported-configurations>`_,
and the CMake option names are given in the table below. Some backends may
Expand Down Expand Up @@ -127,7 +127,7 @@ The most important supported build options are:
* - ENABLE_MKLCPU_THREAD_TBB
- True, False
- True
* - ENABLE_PORTBLAS_BACKEND
* - ENABLE_GENERIC_BLAS_BACKEND
- True, False
- False
* - ENABLE_PORTFFT_BACKEND
Expand Down Expand Up @@ -239,19 +239,19 @@ SYCL enables portable heterogeneous computing on a wide range of accelerators.
Consequently, it is possible to use oneMath with accelerators not anticipated by
the project.

For generic SYCL devices, only portBLAS and portFFT backend are enabled.
For generic SYCL devices, only generic BLAS and portFFT backend are enabled.
The user must set the appropriate ``-fsycl-targets`` for their device, and also
any other option required for performance. See `Building for portBLAS`_ and
any other option required for performance. See `Building for oneMath generic SYCL BLAS`_ and
`Building for portFFT`_. Extensive testing is strongly advised for these
unsupported configurations.

.. _build_for_portlibs_dpcpp:

Pure SYCL backends: portBLAS and portFFT
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Pure SYCL backends: generic BLAS and portFFT
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

`portBLAS <https://github.com/codeplaysoftware/portBLAS>`_ and `portFFT
<https://github.com/codeplaysoftware/portFFT>`_ are experimental pure-SYCL
`Generic SYCL BLAS <https://github.com/uxlfoundation/generic-sycl-components/tree/main/onemath/sycl/blas>`_
and `portFFT <https://github.com/codeplaysoftware/portFFT>`_ are experimental pure-SYCL
backends that work on all SYCL targets supported by the DPC++ compiler. Since
they support multiple targets, they cannot be enabled with other backends in the
same domain, or the ``MKLCPU`` or ``MKLGPU`` backends. Both libraries are
Expand All @@ -260,35 +260,35 @@ experimental and currently only support a subset of operations and features.
For best performance, both libraries must be tuned. See the individual sections
for more details.

Both portBLAS and portFFT are used as header-only libraries, and will be
Both generic SYCL BLAS and portFFT are used as header-only libraries, and will be
downloaded automatically if not found.

.. _build_for_portblas_dpcpp:
.. _build_for_generic_blas_dpcpp:

Building for portBLAS
---------------------
Building for oneMath generic SYCL BLAS
--------------------------------------

`portBLAS <https://github.com/codeplaysoftware/portBLAS>`_ is
enabled by setting ``-DENABLE_PORTBLAS_BACKEND=True``.
`onemath generic SYCL BLAS <https://github.com/uxlfoundation/generic-sycl-components/tree/main/onemath/sycl/blas>`_
is enabled by setting ``-DENABLE_GENERIC_BLAS_BACKEND=True``.

By default, the portBLAS backend is not tuned for any specific device.
By default, the generic BLAS backend is not tuned for any specific device.
This tuning is required to achieve best performance.
portBLAS can be tuned for a specific hardware target by adding compiler
The generic SYCL BLAS backend can be tuned for a specific hardware target by adding compiler
definitions in 2 ways:

#.
Manually specify a tuning target with ``-DPORTBLAS_TUNING_TARGET=<target>``.
The list of portBLAS targets can be found
`here <https://github.com/codeplaysoftware/portBLAS#cmake-options>`_.
Manually specify a tuning target with ``-DGENERIC_BLAS_TUNING_TARGET=<target>``.
The list of oneMath SYCL BLAS targets can be found
`here <https://github.com/uxlfoundation/generic-sycl-components/tree/main/onemath/sycl/blas#cmake-options>`_.
This will automatically set ``-fsycl-targets`` if needed.
#.
If one target is set via ``-fsycl-targets`` the configuration step will
try to automatically detect the portBLAS tuning target. One can manually
try to automatically detect the oneMath SYCL BLAS tuning target. One can manually
specify ``-fsycl-targets`` via ``CMAKE_CXX_FLAGS``. See
`DPC++ User Manual <https://intel.github.io/llvm-docs/UsersManual.html>`_
for more information on ``-fsycl-targets``.

portBLAS relies heavily on JIT compilation. This may cause time-outs on some
OneMath SYCL BLAS relies heavily on JIT compilation. This may cause time-outs on some
systems. To avoid this issue, use ahead-of-time compilation through tuning
targets or ``sycl-targets``.

Expand Down Expand Up @@ -439,11 +439,10 @@ Build oneMath for the BLAS domain on a generic SYCL device:
-DCMAKE_C_COMPILER=clang \
-DENABLE_MKLCPU_BACKEND=False \
-DENABLE_MKLGPU_BACKEND=False \
-DENABLE_PORTBLAS_BACKEND=True
-DENABLE_GENERIC_BLAS_BACKEND=True
Note that this is not a tested configuration. This builds oneMath with the
portBLAS backend only, for a generic SYCL device supported by the Open DPC++
project.
generic SYCL BLAS backend only, for a generic SYCL device.

Build oneMath for the DFT domain on a generic SYCL device:

Expand Down
10 changes: 5 additions & 5 deletions examples/blas/run_time_dispatching/level3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ endif()
if(ENABLE_ROCBLAS_BACKEND)
list(APPEND DEVICE_FILTERS "hip:gpu")
endif()
if(ENABLE_PORTBLAS_BACKEND)
if(PORTBLAS_TUNING_TARGET)
if(PORTBLAS_TUNING_TARGET MATCHES "INTEL_CPU")
if(ENABLE_GENERIC_BLAS_BACKEND)
if(GENERIC_BLAS_TUNING_TARGET)
if(GENERIC_BLAS_TUNING_TARGET MATCHES "INTEL_CPU")
list(APPEND DEVICE_FILTERS "opencl:cpu")
elseif(PORTBLAS_TUNING_TARGET MATCHES "_GPU")
elseif(GENERIC_BLAS_TUNING_TARGET MATCHES "_GPU")
list(APPEND DEVICE_FILTERS "*:gpu")
endif()
else()
# portBLAS default sycl-target is spir64, testing runtime on both supported
# onemath_sycl_blas default sycl-target is spir64, testing runtime on both supported
# devices.
list(APPEND DEVICE_FILTERS "opencl:cpu;level_zero:gpu")
endif()
Expand Down
4 changes: 2 additions & 2 deletions include/oneapi/math/blas.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
#ifdef ONEMATH_ENABLE_NETLIB_BACKEND
#include "oneapi/math/blas/detail/netlib/blas_ct.hpp"
#endif
#ifdef ONEMATH_ENABLE_PORTBLAS_BACKEND
#include "oneapi/math/blas/detail/portblas/blas_ct.hpp"
#ifdef ONEMATH_ENABLE_GENERIC_BLAS_BACKEND
#include "oneapi/math/blas/detail/generic/blas_ct.hpp"
#endif

namespace oneapi {
Expand Down
4 changes: 2 additions & 2 deletions include/oneapi/math/blas/detail/blas_ct_backends.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace column_major {
#define BACKEND netlib
#include "blas_ct_backends.hxx"
#undef BACKEND
#define BACKEND portblas
#define BACKEND generic
#include "blas_ct_backends.hxx"
#undef BACKEND

Expand All @@ -73,7 +73,7 @@ namespace row_major {
#define BACKEND netlib
#include "blas_ct_backends.hxx"
#undef BACKEND
#define BACKEND portblas
#define BACKEND generic
#include "blas_ct_backends.hxx"
#undef BACKEND

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
*
**************************************************************************/

#ifndef _DETAIL_PORTBLAS_BLAS_CT_HPP_
#define _DETAIL_PORTBLAS_BLAS_CT_HPP_
#ifndef _DETAIL_GENERIC_BLAS_BLAS_CT_HPP_
#define _DETAIL_GENERIC_BLAS_BLAS_CT_HPP_

#if __has_include(<sycl/sycl.hpp>)
#include <sycl/sycl.hpp>
Expand All @@ -30,7 +30,7 @@

#include "oneapi/math/types.hpp"
#include "oneapi/math/detail/backend_selector.hpp"
#include "oneapi/math/blas/detail/portblas/onemath_blas_portblas.hpp"
#include "oneapi/math/blas/detail/generic/onemath_blas_generic.hpp"
#include "oneapi/math/blas/detail/blas_ct_backends.hpp"

namespace oneapi {
Expand All @@ -54,4 +54,4 @@ namespace row_major {
} //namespace math
} //namespace oneapi

#endif //_DETAIL_PORTBLAS_BLAS_CT_HPP_
#endif //_DETAIL_GENERIC_BLAS_BLAS_CT_HPP_
Loading

0 comments on commit db520e4

Please sign in to comment.