Skip to content

Commit af66e5e

Browse files
adegommenicolas-boutonrdolbeau
authored
[BLAS] Add BLAS ARM performance libraries backend. (#629)
Signed-off-by: Augustin Degomme <augustin.degomme@sipearl.com> Co-authored-by: Nicolas Bouton <nicolas.bouton@sipearl.com> Co-authored-by: Romain Dolbeau <romain.dolbeau@sipearl.com>
1 parent 1401716 commit af66e5e

33 files changed

+10707
-12
lines changed

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ if(ENABLE_MKLCPU_BACKEND)
4141
option(ENABLE_MKLCPU_THREAD_TBB "Enable the use of Intel TBB with the oneMath CPU backend" ON)
4242
endif()
4343

44+
option(ENABLE_ARMPL_BACKEND "Enable the ArmPl backend for BLAS/LAPACK interface" OFF)
45+
if(ENABLE_ARMPL_BACKEND)
46+
option(ENABLE_ARMPL_OMP "Enable OpenMP for the ArmPl backend" ON)
47+
endif()
48+
4449
# blas
4550
option(ENABLE_CUBLAS_BACKEND "Enable the cuBLAS backend for the BLAS interface" OFF)
4651
option(ENABLE_ROCBLAS_BACKEND "Enable the rocBLAS backend for the BLAS interface" OFF)
@@ -88,7 +93,8 @@ if(ENABLE_MKLCPU_BACKEND
8893
OR ENABLE_CUBLAS_BACKEND
8994
OR ENABLE_ROCBLAS_BACKEND
9095
OR ENABLE_NETLIB_BACKEND
91-
OR ENABLE_GENERIC_BLAS_BACKEND)
96+
OR ENABLE_GENERIC_BLAS_BACKEND
97+
OR ENABLE_ARMPL_BACKEND)
9298
list(APPEND DOMAINS_LIST "blas")
9399
endif()
94100
if(ENABLE_MKLCPU_BACKEND

README.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ oneMath is part of the [UXL Foundation](http://www.uxlfoundation.org).
1818
</thead>
1919
<tbody>
2020
<tr>
21-
<td rowspan=14 align="center">oneMath</td>
22-
<td rowspan=14 align="center">oneMath selector</td>
21+
<td rowspan=15 align="center">oneMath</td>
22+
<td rowspan=15 align="center">oneMath selector</td>
2323
<td align="center"><a href="https://software.intel.com/en-us/oneapi/onemkl">Intel(R) oneAPI Math Kernel Library (oneMKL)</a></td>
2424
<td align="center">x86 CPU, Intel GPU</td>
2525
</tr>
@@ -45,8 +45,12 @@ oneMath is part of the [UXL Foundation](http://www.uxlfoundation.org).
4545
<td align="center">NVIDIA GPU</td>
4646
</tr>
4747
<tr>
48-
<td align="center"><a href="https://ww.netlib.org"> NETLIB LAPACK</a> </td>
49-
<td align="center">x86 CPU</td>
48+
<td align="center"><a href="https://www.netlib.org"> NETLIB LAPACK</a> </td>
49+
<td align="center">x86 and aarch64 CPU</td>
50+
</tr>
51+
<tr>
52+
<td align="center"><a href="https://www.arm.com/products/development-tools/server-and-hpc/allinea-studio/performance-libraries">Arm Performance Libraries</a></td>
53+
<td align="center">aarch64 CPU</td>
5054
</tr>
5155
<tr>
5256
<td align="center"><a href="https://rocblas.readthedocs.io/en/rocm-4.5.2/"> AMD rocBLAS</a></td>
@@ -180,7 +184,7 @@ Supported compilers include:
180184
</thead>
181185
<tbody>
182186
<tr>
183-
<td rowspan=10 align="center">BLAS</td>
187+
<td rowspan=12 align="center">BLAS</td>
184188
<td rowspan=3 align="center">x86 CPU</td>
185189
<td align="center">Intel(R) oneMKL</td>
186190
<td align="center">Intel DPC++</br>AdaptiveCpp</td>
@@ -196,6 +200,17 @@ Supported compilers include:
196200
<td align="center">Intel DPC++</br>Open DPC++</td>
197201
<td align="center">Dynamic, Static</td>
198202
</tr>
203+
<tr>
204+
<td rowspan=2 align="center">aarch64 CPU</td>
205+
<td align="center">Arm Performance Libraries</td>
206+
<td align="center">Open DPC++</br>AdaptiveCpp</td>
207+
<td align="center">Dynamic, Static</td>
208+
</tr>
209+
<tr>
210+
<td align="center">NETLIB LAPACK</td>
211+
<td align="center">Open DPC++</br>AdaptiveCpp</td>
212+
<td align="center">Dynamic, Static</td>
213+
</tr>
199214
<tr>
200215
<td rowspan=2 align="center">Intel GPU</td>
201216
<td align="center">Intel(R) oneMKL</td>
@@ -432,6 +447,7 @@ Supported compilers include:
432447
- Intel Atom(R) Processors
433448
- Intel(R) Core(TM) Processor Family
434449
- Intel(R) Xeon(R) Processor Family
450+
- Arm Neoverse Processor Family (tested on N1, V1, V2)
435451
- Accelerators
436452
- Intel(R) Arc(TM) A-Series Graphics
437453
- Intel(R) Data Center GPU Max Series
@@ -447,6 +463,7 @@ Supported compilers include:
447463
Backend | Supported Operating System
448464
:--- | :---
449465
x86 CPU | Red Hat Enterprise Linux* 9 (RHEL* 9)
466+
aarch64 CPU| Red Hat Enterprise Linux* 9 (RHEL* 9)
450467
Intel GPU | Ubuntu 24.04 LTS
451468
NVIDIA GPU | Ubuntu 22.04 LTS
452469

@@ -551,6 +568,7 @@ Product | Supported Version | License
551568
[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)
552569
[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)
553570
[portFFT](https://github.com/codeplaysoftware/portFFT) | 0.1 | [Apache License v2.0](https://github.com/codeplaysoftware/portFFT/blob/main/LICENSE)
571+
[Arm Performance Libraries](https://developer.arm.com/downloads/-/arm-performance-libraries) | 22.0.1 or higher | [EULA](https://developer.arm.com/downloads/-/arm-performance-libraries/eula)
554572

555573
---
556574

cmake/FindARMPL.cmake

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#===============================================================================
2+
# Copyright 2025 SiPearl
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing,
11+
# software distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions
14+
# and limitations under the License.
15+
#
16+
#
17+
# SPDX-License-Identifier: Apache-2.0
18+
#===============================================================================
19+
20+
include_guard()
21+
set(ARMPL_SEQ armpl_intp64)
22+
set(ARMPL_OMP armpl_int64_mp)
23+
24+
include(FindPackageHandleStandardArgs)
25+
if(ENABLE_ARMPL_OMP)
26+
message(STATUS "Use OpenMP version of ArmPL")
27+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fopenmp")
28+
find_library(ARMPL_LIBRARY NAMES ${ARMPL_OMP} HINTS ${ARMPL_ROOT} $ENV{ARMPLROOT} PATH_SUFFIXES lib lib64)
29+
else()
30+
message(STATUS "Use Sequential version of ArmPL")
31+
find_library(ARMPL_LIBRARY NAMES ${ARMPL_SEQ} HINTS ${ARMPL_ROOT} $ENV{ARMPLROOT} PATH_SUFFIXES lib lib64)
32+
endif()
33+
find_package_handle_standard_args(ARMPL REQUIRED_VARS ARMPL_LIBRARY)
34+
35+
get_filename_component(ARMPL_LIB_DIR ${ARMPL_LIBRARY} DIRECTORY)
36+
find_path(ARMPL_INCLUDE armpl.h HINTS ${ARMPL_ROOT} $ENV{ARMPLROOT} PATH_SUFFIXES include)
37+
#cmake replaces fullpath to libarmpl by -larmpl (because SONAME is absent) and -Wl,-rpath is not enough for some compilers as hint
38+
#so we need to add -L to compiler, otherwise we need to set LIBRARY_PATH manually when building
39+
if(UNIX)
40+
list(APPEND ARMPL_LINK "-Wl,-rpath,${ARMPL_LIB_DIR} -L${ARMPL_LIB_DIR}")
41+
endif()
42+
list(APPEND ARMPL_LINK ${ARMPL_LIBRARY})
43+
list(APPEND ARMPL_LINK ${ARMPL_LIBRARY})
44+
message(${ARMPL_LINK})
45+
find_package_handle_standard_args(ARMPL REQUIRED_VARS ARMPL_INCLUDE ARMPL_LINK)
46+
47+
# Check ARMPL version (only versions higher or equal to 22.0.1 are supported)
48+
set(ARMPL_MAJOR 22)
49+
set(ARMPL_MINOR 0)
50+
set(ARMPL_BUILD 1)
51+
file(WRITE ${CMAKE_BINARY_DIR}/armplversion.cpp
52+
"#include <stdio.h>\n"
53+
"\n"
54+
"#include \"armpl.h\"\n"
55+
"\n"
56+
"int main(void) {\n"
57+
" int major, minor, build;\n"
58+
" char *tag;\n"
59+
" armplversion(&major, &minor, &build, (const char **)&tag);\n"
60+
" if (major > MAJOR) {\n"
61+
" return 0;\n"
62+
" }\n"
63+
" else if (major == MAJOR && minor > MINOR) {\n"
64+
" return 0;\n"
65+
" }\n"
66+
" else if (major == MAJOR && minor == MINOR && build >= BUILD) {\n"
67+
" return 0;\n"
68+
" }\n"
69+
" printf(\"You are using version %d.%d.%d\\n\", major, minor, build);\n"
70+
" return 1;\n"
71+
"}\n")
72+
execute_process(COMMAND ${CMAKE_CXX_COMPILER} armplversion.cpp -O0 -I${ARMPL_INCLUDE} -Wl,-rpath,${ARMPL_LIB_DIR} -larmpl -DMAJOR=${ARMPL_MAJOR} -DMINOR=${ARMPL_MINOR} -DBUILD=${ARMPL_BUILD} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
73+
execute_process(COMMAND ./a.out WORKING_DIRECTORY ${CMAKE_BINARY_DIR} RESULT_VARIABLE ARMPL_CHECK_VERSION)
74+
execute_process(COMMAND rm ./a.out WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
75+
execute_process(COMMAND rm armplversion.cpp WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
76+
if(ARMPL_CHECK_VERSION)
77+
message(FATAL_ERROR "ARMPL backend does not support ARMPL version prior to version ${ARMPL_MAJOR}.${ARMPL_MINOR}.${ARMPL_BUILD}")
78+
endif()
79+
80+
add_library(ONEMKL::ARMPL::ARMPL UNKNOWN IMPORTED)
81+
set_target_properties(ONEMKL::ARMPL::ARMPL PROPERTIES IMPORTED_LOCATION ${ARMPL_LIBRARY})

docs/building_the_project_with_adaptivecpp.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ The most important supported build options are:
8787
* - ENABLE_NETLIB_BACKEND
8888
- True, False
8989
- False
90+
* - ENABLE_ARMPL_BACKEND
91+
- True, False
92+
- False
9093
* - ENABLE_ROCBLAS_BACKEND
9194
- True, False
9295
- False

docs/building_the_project_with_dpcpp.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ The most important supported build options are:
109109
* - ENABLE_NETLIB_BACKEND
110110
- True, False
111111
- False
112+
* - ENABLE_ARMPL_BACKEND
113+
- True, False
114+
- False
115+
* - ENABLE_ARMPL_OMP
116+
- True, False
117+
- True
112118
* - ENABLE_ROCBLAS_BACKEND
113119
- True, False
114120
- False
@@ -314,6 +320,20 @@ specified. See `DPC++ User Manual
314320
<https://intel.github.io/llvm-docs/UsersManual.html>`_ for more information on
315321
``-fsycl-targets``.
316322

323+
.. _build_for_armpl_dpcpp:
324+
325+
Building for Arm Performance Libraries
326+
--------------------------------------
327+
328+
`Arm Performance Libraries <https://developer.arm.com/Tools%20and%20Software/Arm%20Performance%20Libraries>`_
329+
backend is enabled on aarch64 platform by setting ``-DENABLE_ARMPL_BACKEND=True``.
330+
331+
By default, it will look for the ``ARMPLROOT`` environment variable. If another
332+
ArmPL is to be used, ``-DARMPL_ROOT=<armpl_install_prefix>`` can be used.
333+
334+
Default behavior is to used the OpenMP flavor of ArmPL libraries, this can be
335+
changed using the ``-DENABLE_ARMPL_OMP=True/False`` flag.
336+
317337
.. _build_additional_options_dpcpp:
318338

319339
Additional Build Options

include/oneapi/math/blas.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
#ifdef ONEMATH_ENABLE_NETLIB_BACKEND
5050
#include "oneapi/math/blas/detail/netlib/blas_ct.hpp"
5151
#endif
52+
#ifdef ONEMATH_ENABLE_ARMPL_BACKEND
53+
#include "oneapi/math/blas/detail/armpl/blas_ct.hpp"
54+
#endif
5255
#ifdef ONEMATH_ENABLE_GENERIC_BLAS_BACKEND
5356
#include "oneapi/math/blas/detail/generic/blas_ct.hpp"
5457
#endif
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*******************************************************************************
2+
* Copyright 2025 SiPearl
3+
* Copyright 2020-2021 Intel Corporation
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing,
12+
* software distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions
15+
* and limitations under the License.
16+
*
17+
*
18+
* SPDX-License-Identifier: Apache-2.0
19+
*******************************************************************************/
20+
21+
#ifndef _DETAIL_ARMPL_BLAS_CT_HPP__
22+
#define _DETAIL_ARMPL_BLAS_CT_HPP__
23+
24+
#if __has_include(<sycl/sycl.hpp>)
25+
#include <sycl/sycl.hpp>
26+
#else
27+
#include <CL/sycl.hpp>
28+
#endif
29+
#include <complex>
30+
#include <cstdint>
31+
32+
#include "oneapi/math/types.hpp"
33+
#include "oneapi/math/detail/backend_selector.hpp"
34+
35+
#include "oneapi/math/blas/detail/blas_ct_backends.hpp"
36+
#include "oneapi/math/blas/detail/armpl/onemath_blas_armpl.hpp"
37+
38+
namespace oneapi {
39+
namespace math {
40+
namespace blas {
41+
namespace column_major {
42+
43+
#define MAJOR column_major
44+
#include "blas_ct.hxx"
45+
#undef MAJOR
46+
47+
} //namespace column_major
48+
namespace row_major {
49+
50+
#define MAJOR row_major
51+
#include "blas_ct.hxx"
52+
#undef MAJOR
53+
54+
} //namespace row_major
55+
} //namespace blas
56+
} //namespace math
57+
} //namespace oneapi
58+
59+
#endif //_DETAIL_ARMPL_BLAS_CT_HPP_

0 commit comments

Comments
 (0)