Skip to content

Commit 846024e

Browse files
authored
[DFT] Add ArmPl DFT backend for aarch64 CPUs (#702)
1 parent 04abaa4 commit 846024e

File tree

18 files changed

+1384
-7
lines changed

18 files changed

+1384
-7
lines changed

.github/workflows/pr-arm.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ jobs:
3030
- config: ArmPL RNG
3131
domain: rng
3232
test_options: -E 'Device|DEVICE'
33+
- config: ArmPL DFT
34+
domain: dft
3335
name: unit tests ${{ matrix.config }} CPU
3436
steps:
3537
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ if(ENABLE_MKLGPU_BACKEND
115115
OR ENABLE_MKLCPU_BACKEND
116116
OR ENABLE_CUFFT_BACKEND
117117
OR ENABLE_ROCFFT_BACKEND
118-
OR ENABLE_PORTFFT_BACKEND)
118+
OR ENABLE_PORTFFT_BACKEND
119+
OR ENABLE_ARMPL_BACKEND)
119120
list(APPEND DOMAINS_LIST "dft")
120121
endif()
121122
if(ENABLE_MKLCPU_BACKEND

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ Supported compilers include:
330330
<td align="center">Dynamic, Static</td>
331331
</tr>
332332
<tr>
333-
<td rowspan=9 align="center">DFT</td>
333+
<td rowspan=10 align="center">DFT</td>
334334
<td rowspan=2 align="center">x86 CPU</td>
335335
<td align="center">Intel(R) oneMKL</td>
336336
<td align="center">Intel DPC++</td>
@@ -341,6 +341,12 @@ Supported compilers include:
341341
<td align="center">Intel DPC++</td>
342342
<td align="center">Dynamic, Static</td>
343343
</tr>
344+
<tr>
345+
<td align="center">aarch64 CPU</td>
346+
<td align="center">Arm Performance Libraries</td>
347+
<td align="center">Open DPC++</br>AdaptiveCpp</td>
348+
<td align="center">Dynamic, Static</td>
349+
</tr>
344350
<tr>
345351
<td rowspan=2 align="center">Intel GPU</td>
346352
<td align="center">Intel(R) oneMKL</td>

include/oneapi/math/detail/backends_table.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ static std::map<domain, std::map<device, std::vector<const char*>>> libraries =
108108
#endif
109109
#ifdef ONEMATH_ENABLE_PORTFFT_BACKEND
110110
LIB_NAME("dft_portfft")
111+
#endif
112+
} },
113+
{ device::aarch64cpu,
114+
{
115+
#ifdef ONEMATH_ENABLE_ARMPL_BACKEND
116+
LIB_NAME("dft_armpl"),
111117
#endif
112118
} },
113119
{ device::intelgpu,
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
#ifndef _ONEMATH_DFT_ARMPL_HPP_
21+
#define _ONEMATH_DFT_ARMPL_HPP_
22+
23+
#if __has_include(<sycl/sycl.hpp>)
24+
#include <sycl/sycl.hpp>
25+
#else
26+
#include <CL/sycl.hpp>
27+
#endif
28+
29+
#include "oneapi/math/detail/export.hpp"
30+
#include "oneapi/math/dft/detail/types_impl.hpp"
31+
32+
namespace oneapi::math::dft::armpl {
33+
34+
#include "oneapi/math/dft/detail/dft_ct.hxx"
35+
36+
} // namespace oneapi::math::dft::armpl
37+
38+
#endif // _ONEMATH_DFT_ARMPL_HPP_

include/oneapi/math/dft/detail/descriptor_impl.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ class descriptor {
9191
void commit(backend_selector<backend::portfft> selector);
9292
#endif
9393

94+
#ifdef ONEMATH_ENABLE_ARMPL_BACKEND
95+
void commit(backend_selector<backend::armpl> selector);
96+
#endif
97+
9498
const dft_values<prec, dom>& get_values() const noexcept {
9599
return values_;
96100
}

src/dft/backends/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,8 @@ endif()
3939
if(ENABLE_PORTFFT_BACKEND)
4040
add_subdirectory(portfft)
4141
endif()
42+
43+
if(ENABLE_ARMPL_BACKEND)
44+
add_subdirectory(armpl)
45+
endif()
46+
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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+
set(LIB_NAME onemath_dft_armpl)
21+
set(LIB_OBJ ${LIB_NAME}_obj)
22+
23+
include(WarningsUtils)
24+
25+
# Add third-party library
26+
find_package(ARMPL REQUIRED)
27+
28+
add_library(${LIB_NAME})
29+
add_deprecated_library(${LIB_NAME})
30+
add_library(${LIB_OBJ} OBJECT
31+
descriptor.cpp
32+
commit.cpp
33+
forward.cpp
34+
backward.cpp
35+
$<$<BOOL:${BUILD_SHARED_LIBS}>: armpl_wrappers.cpp>
36+
)
37+
add_dependencies(onemath_backend_libs_dft ${LIB_NAME})
38+
39+
target_include_directories(${LIB_OBJ}
40+
PUBLIC ${ONEMATH_INCLUDE_DIRS}
41+
PRIVATE ${PROJECT_SOURCE_DIR}/src/include
42+
${PROJECT_SOURCE_DIR}/src
43+
${CMAKE_BINARY_DIR}/bin
44+
${ARMPL_INCLUDE}
45+
${ONEMATH_GENERATED_INCLUDE_PATH}
46+
)
47+
48+
target_compile_options(${LIB_OBJ} PRIVATE ${ONEMATH_BUILD_COPT} ${ARMPL_COPT})
49+
if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
50+
add_sycl_to_target(TARGET ${LIB_OBJ} SOURCES ${SOURCES})
51+
endif()
52+
53+
target_link_libraries(${LIB_OBJ}
54+
PUBLIC ONEMATH::SYCL::SYCL ${ARMPL_LINK}
55+
PRIVATE onemath_warnings
56+
)
57+
58+
set_target_properties(${LIB_OBJ} PROPERTIES
59+
POSITION_INDEPENDENT_CODE ON
60+
)
61+
target_link_libraries(${LIB_NAME} PRIVATE ${LIB_OBJ})
62+
target_include_directories(${LIB_NAME} PUBLIC ${ONEMATH_INCLUDE_DIRS})
63+
64+
#Set oneMath libraries as not transitive for dynamic
65+
if(BUILD_SHARED_LIBS)
66+
set_target_properties(${LIB_NAME} PROPERTIES
67+
INTERFACE_LINK_LIBRARIES ONEMATH::SYCL::SYCL
68+
)
69+
endif()
70+
71+
# Add major version to the library
72+
set_target_properties(${LIB_NAME} PROPERTIES
73+
SOVERSION ${PROJECT_VERSION_MAJOR}
74+
)
75+
76+
# Add dependencies rpath to the library
77+
list(APPEND CMAKE_BUILD_RPATH $<TARGET_FILE_DIR:${LIB_NAME}>)
78+
79+
# Add the library to install package
80+
install(TARGETS ${LIB_OBJ} EXPORT oneMathTargets)
81+
install(TARGETS ${LIB_NAME} EXPORT oneMathTargets
82+
RUNTIME DESTINATION bin
83+
ARCHIVE DESTINATION lib
84+
LIBRARY DESTINATION lib
85+
)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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+
#ifndef _ONEMATH_DFT_SRC_ARMPL_HELPERS_HPP_
21+
#define _ONEMATH_DFT_SRC_ARMPL_HELPERS_HPP_
22+
23+
#include "oneapi/math/exceptions.hpp"
24+
#include "oneapi/math/dft/detail/types_impl.hpp"
25+
26+
#include "fftw3.h"
27+
28+
namespace oneapi::math::dft::armpl::detail {
29+
30+
template <typename K, typename H, typename F>
31+
static inline auto host_task_internal(H& cgh, F f, int) -> decltype(cgh.host_task(f)) {
32+
return cgh.host_task(f);
33+
}
34+
35+
template <typename K, typename H, typename F>
36+
static inline void host_task_internal([[maybe_unused]] H& cgh, [[maybe_unused]] F f, long) {
37+
#ifndef __SYCL_DEVICE_ONLY__
38+
cgh.template single_task<K>(f);
39+
#endif
40+
}
41+
42+
template <typename K, typename H, typename F>
43+
static inline void host_task(H& cgh, F f) {
44+
(void)host_task_internal<K>(cgh, f, 0);
45+
}
46+
47+
template <typename Desc>
48+
class kernel_name {};
49+
50+
template <typename AccType>
51+
typename AccType::value_type* acc_to_ptr(AccType acc) {
52+
// no need to decorate the pointer with the address space for armpl since its just getting passed to the a host function.
53+
return acc.template get_multi_ptr<sycl::access::decorated::no>().get();
54+
}
55+
56+
} // namespace oneapi::math::dft::armpl::detail
57+
58+
#endif // _ONEMATH_DFT_SRC_ARMPL_HELPERS_HPP_
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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 "oneapi/math/dft/detail/armpl/onemath_dft_armpl.hpp"
21+
#include "dft/function_table.hpp"
22+
23+
#define WRAPPER_VERSION 1
24+
#define BACKEND armpl
25+
26+
extern "C" dft_function_table_t onemath_dft_table = {
27+
WRAPPER_VERSION,
28+
#include "dft/backends/backend_wrappers.cxx"
29+
};

0 commit comments

Comments
 (0)