Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[CPU] Reuse system conf to retrieve fp16 and dotprod ARM capabilities (#30851)

Arseniy Obolenskiyec03f4281577
diff --git a/cmake/developer_package/cross_compile/cross_compiled_disp_gen.cmake b/cmake/developer_package/cross_compile/cross_compiled_disp_gen.cmake
index 8c3a05b564a..0f5282e6fe4 100644
--- a/cmake/developer_package/cross_compile/cross_compiled_disp_gen.cmake
+++ b/cmake/developer_package/cross_compile/cross_compiled_disp_gen.cmake
@@ -18,6 +18,7 @@ set(_CPU_CHECK_ANY "true")
set(_CPU_CHECK_SSE42 "with_cpu_x86_sse42()")
set(_CPU_CHECK_AVX "with_cpu_x86_avx()")
set(_CPU_CHECK_NEON_FP16 "with_cpu_neon_fp16()")
+set(_CPU_CHECK_ARM_DOTPROD "with_cpu_arm_dotprod()")
set(_CPU_CHECK_SVE "with_cpu_sve()")
set(_CPU_CHECK_AVX2 "with_cpu_x86_avx2()")
set(_CPU_CHECK_AVX512F "with_cpu_x86_avx512f()")
diff --git a/src/inference/dev_api/openvino/runtime/system_conf.hpp b/src/inference/dev_api/openvino/runtime/system_conf.hpp
index 6088f53aa19..515cbadca3d 100644
--- a/src/inference/dev_api/openvino/runtime/system_conf.hpp
+++ b/src/inference/dev_api/openvino/runtime/system_conf.hpp
@@ -83,6 +83,13 @@ OPENVINO_RUNTIME_API bool with_cpu_x86_sse42();
*/
OPENVINO_RUNTIME_API bool with_cpu_neon_fp16();
+/**
+ * @brief Checks whether CPU supports ARM Dot Product capability
+ * @ingroup ov_dev_api_system_conf
+ * @return `True` is ARM Dot Product instructions are available, `false` otherwise
+ */
+OPENVINO_RUNTIME_API bool with_cpu_arm_dotprod();
+
/**
* @brief Checks whether CPU supports ARM SVE capability
* @ingroup ov_dev_api_system_conf
diff --git a/src/inference/src/system_conf.cpp b/src/inference/src/system_conf.cpp
index e7cc1017d9d..bed3bd97c8a 100644
--- a/src/inference/src/system_conf.cpp
+++ b/src/inference/src/system_conf.cpp
@@ -119,6 +119,10 @@ bool with_cpu_sve() {
return false;
}
+bool with_cpu_arm_dotprod() {
+ return false;
+}
+
#else // OPENVINO_ARCH_X86 || OPENVINO_ARCH_X86_64
bool with_cpu_x86_sse42() {
@@ -192,6 +196,26 @@ bool with_cpu_sve() {
return false;
# endif
}
+
+bool with_cpu_arm_dotprod() {
+# if !defined(_WIN64) && !defined(BARE_METAL) && !defined(__APPLE__) && !defined(__OpenBSD__) && \
+ !defined(__arm__) && defined(__aarch64__)
+ const uint32_t hwcaps = getauxval(AT_HWCAP);
+ return hwcaps & HWCAP_ASIMDDP;
+# elif !defined(_WIN64) && !defined(BARE_METAL) && !defined(__APPLE__) && !defined(__OpenBSD__) && \
+ !defined(__aarch64__) && defined(__arm__)
+ return false;
+# elif defined(__aarch64__) && defined(__APPLE__)
+ int64_t result(0);
+ size_t size = sizeof(result);
+ const std::string& cap = "hw.optional.arm.FEAT_DotProd";
+ sysctlbyname(cap.c_str(), &result, &size, NULL, 0);
+ return result > 0;
+# else
+ return false;
+# endif
+}
+
#endif // OPENVINO_ARCH_X86 || OPENVINO_ARCH_X86_64
bool check_open_mp_env_vars(bool include_omp_num_threads) {
diff --git a/src/plugins/intel_cpu/src/utils/precision_support.cpp b/src/plugins/intel_cpu/src/utils/precision_support.cpp
index 622a5580d8f..d7b383cfb2c 100644
--- a/src/plugins/intel_cpu/src/utils/precision_support.cpp
+++ b/src/plugins/intel_cpu/src/utils/precision_support.cpp
@@ -9,10 +9,7 @@
#endif
#include "openvino/core/type/element_type.hpp"
#include "openvino/core/visibility.hpp"
-
-#if defined(OV_CPU_WITH_ACL)
-# include "arm_compute/core/CPP/CPPTypes.h"
-#endif
+#include "openvino/runtime/system_conf.hpp"
namespace ov::intel_cpu {
@@ -20,8 +17,8 @@ static bool hasFP16HardwareSupport() {
#if defined(OPENVINO_ARCH_X86_64)
return dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx512_core_fp16) ||
dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx2_vnni_2);
-#elif defined(OV_CPU_WITH_ACL)
- return arm_compute::CPUInfo::get().has_fp16();
+#elif defined(OPENVINO_ARCH_ARM) || defined(OPENVINO_ARCH_ARM64)
+ return with_cpu_neon_fp16();
#else
return false;
#endif
@@ -58,11 +55,7 @@ ov::element::Type defaultFloatPrecision() {
}
bool hasIntDotProductSupport() {
-#if defined(OV_CPU_WITH_ACL)
- return arm_compute::CPUInfo::get().has_dotprod();
-#else
- return false;
-#endif
+ return with_cpu_arm_dotprod();
}
} // namespace ov::intel_cpu
diff --git a/src/plugins/intel_cpu/tests/functional/CMakeLists.txt b/src/plugins/intel_cpu/tests/functional/CMakeLists.txt
index 4e90eae412f..a13b3939a67 100644
--- a/src/plugins/intel_cpu/tests/functional/CMakeLists.txt
+++ b/src/plugins/intel_cpu/tests/functional/CMakeLists.txt
@@ -21,7 +21,7 @@ add_library(cpuUtils STATIC
$<TARGET_PROPERTY:openvino_intel_cpu_plugin,SOURCE_DIR>/src/utils/precision_support.h
$<TARGET_PROPERTY:openvino_intel_cpu_plugin,SOURCE_DIR>/src/utils/precision_support.cpp
${CPU_ISA_TRAITS_RV64})
-set(CPU_UTILS_LINK_LIBRARIES openvino::runtime)
+set(CPU_UTILS_LINK_LIBRARIES openvino::runtime::dev)
set(CPU_UTILS_INCLUDE_PATHS)
if(OV_CPU_WITH_ACL)
list(APPEND CPU_UTILS_LINK_LIBRARIES arm_compute::arm_compute)