Skip to content

Commit 1ebd5ef

Browse files
committed
[CPU] Reuse system conf to retrieve fp16 and dotprod ARM capabilities
1 parent 368274e commit 1ebd5ef

File tree

5 files changed

+37
-13
lines changed

5 files changed

+37
-13
lines changed

cmake/developer_package/cross_compile/cross_compiled_disp_gen.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ set(_CPU_CHECK_ANY "true")
1818
set(_CPU_CHECK_SSE42 "with_cpu_x86_sse42()")
1919
set(_CPU_CHECK_AVX "with_cpu_x86_avx()")
2020
set(_CPU_CHECK_NEON_FP16 "with_cpu_neon_fp16()")
21+
set(_CPU_CHECK_ARM_DOTPROD "with_cpu_arm_dotprod()")
2122
set(_CPU_CHECK_SVE "with_cpu_sve()")
2223
set(_CPU_CHECK_AVX2 "with_cpu_x86_avx2()")
2324
set(_CPU_CHECK_AVX512F "with_cpu_x86_avx512f()")

src/inference/dev_api/openvino/runtime/system_conf.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ OPENVINO_RUNTIME_API bool with_cpu_x86_sse42();
8383
*/
8484
OPENVINO_RUNTIME_API bool with_cpu_neon_fp16();
8585

86+
/**
87+
* @brief Checks whether CPU supports ARM Dot Product capability
88+
* @ingroup ov_dev_api_system_conf
89+
* @return `True` is ARM Dot Product instructions are available, `false` otherwise
90+
*/
91+
OPENVINO_RUNTIME_API bool with_cpu_arm_dotprod();
92+
8693
/**
8794
* @brief Checks whether CPU supports ARM SVE capability
8895
* @ingroup ov_dev_api_system_conf

src/inference/src/system_conf.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ bool with_cpu_sve() {
119119
return false;
120120
}
121121

122+
bool with_cpu_arm_dotprod() {
123+
return false;
124+
}
125+
122126
#else // OPENVINO_ARCH_X86 || OPENVINO_ARCH_X86_64
123127

124128
bool with_cpu_x86_sse42() {
@@ -192,6 +196,25 @@ bool with_cpu_sve() {
192196
return false;
193197
# endif
194198
}
199+
200+
bool with_cpu_arm_dotprod() {
201+
# if !defined(_WIN64) && !defined(BARE_METAL) && !defined(__APPLE__) && !defined(__OpenBSD__) && \
202+
!defined(__arm__) && defined(__aarch64__)
203+
const uint32_t hwcaps = getauxval(AT_HWCAP);
204+
return hwcaps & HWCAP_ASIMDDP;
205+
# elif !defined(_WIN64) && !defined(BARE_METAL) && !defined(__APPLE__) && !defined(__OpenBSD__) && \
206+
!defined(__aarch64__) && defined(__arm__)
207+
return false;
208+
# elif defined(__aarch64__) && defined(__APPLE__)
209+
int64_t result(0);
210+
size_t size = sizeof(result);
211+
const std::string& cap = "hw.optional.arm.FEAT_DotProd";
212+
sysctlbyname(cap.c_str(), &result, &size, NULL, 0);
213+
# else
214+
return false;
215+
# endif
216+
}
217+
195218
#endif // OPENVINO_ARCH_X86 || OPENVINO_ARCH_X86_64
196219

197220
bool check_open_mp_env_vars(bool include_omp_num_threads) {

src/plugins/intel_cpu/src/utils/precision_support.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,16 @@
99
#endif
1010
#include "openvino/core/type/element_type.hpp"
1111
#include "openvino/core/visibility.hpp"
12-
13-
#if defined(OV_CPU_WITH_ACL)
14-
# include "arm_compute/core/CPP/CPPTypes.h"
15-
#endif
12+
#include "openvino/runtime/system_conf.hpp"
1613

1714
namespace ov::intel_cpu {
1815

1916
static bool hasFP16HardwareSupport() {
2017
#if defined(OPENVINO_ARCH_X86_64)
2118
return dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx512_core_fp16) ||
2219
dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx2_vnni_2);
23-
#elif defined(OV_CPU_WITH_ACL)
24-
return arm_compute::CPUInfo::get().has_fp16();
20+
#elif defined(OPENVINO_ARCH_ARM)
21+
return with_cpu_neon_fp16();
2522
#else
2623
return false;
2724
#endif
@@ -58,11 +55,7 @@ ov::element::Type defaultFloatPrecision() {
5855
}
5956

6057
bool hasIntDotProductSupport() {
61-
#if defined(OV_CPU_WITH_ACL)
62-
return arm_compute::CPUInfo::get().has_dotprod();
63-
#else
64-
return false;
65-
#endif
58+
return with_cpu_arm_dotprod();
6659
}
6760

6861
} // namespace ov::intel_cpu

src/plugins/intel_cpu/tests/functional/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ add_library(cpuUtils STATIC
2121
$<TARGET_PROPERTY:openvino_intel_cpu_plugin,SOURCE_DIR>/src/utils/precision_support.h
2222
$<TARGET_PROPERTY:openvino_intel_cpu_plugin,SOURCE_DIR>/src/utils/precision_support.cpp
2323
${CPU_ISA_TRAITS_RV64})
24-
set(CPU_UTILS_LINK_LIBRARIES openvino::runtime)
25-
set(CPU_UTILS_INCLUDE_PATHS)
24+
set(CPU_UTILS_LINK_LIBRARIES openvino::runtime openvino::core::dev)
25+
set(CPU_UTILS_INCLUDE_PATHS ${OpenVINO_SOURCE_DIR}/src/inference/dev_api/)
2626
if(OV_CPU_WITH_ACL)
2727
list(APPEND CPU_UTILS_LINK_LIBRARIES arm_compute::arm_compute)
2828
list(APPEND CPU_UTILS_INCLUDE_PATHS $<TARGET_PROPERTY:arm_compute::arm_compute,SOURCE_DIR>)

0 commit comments

Comments
 (0)