aboutsummaryrefslogtreecommitdiff
path: root/src/armnn/Utils.cpp
diff options
context:
space:
mode:
authorFrancis Murtagh <francis.murtagh@arm.com>2021-01-25 10:18:10 +0000
committerFrancis Murtagh <francis.murtagh@arm.com>2021-01-25 10:18:20 +0000
commit5dc64fe99227efece77eb7cd14abc47474a48fb8 (patch)
tree09de113127e07707ad8edb20075463696055f736 /src/armnn/Utils.cpp
parent2686849118217ba692439407adb53ec3849d48ac (diff)
downloadarmnn-5dc64fe99227efece77eb7cd14abc47474a48fb8.tar.gz
IVGCVSW-5525 Handle Neon optionality on 32 bit linux platforms
* Add neon detection for linux using HWCAPs * Add test to check for backend throwing BackendUnavailable exception Signed-off-by: Francis Murtagh <francis.murtagh@arm.com> Change-Id: Ib74aeb06abe5f88f21ecdd1edb2a1cd20ee2019d
Diffstat (limited to 'src/armnn/Utils.cpp')
-rw-r--r--src/armnn/Utils.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/armnn/Utils.cpp b/src/armnn/Utils.cpp
index 13bf3025f2..62c8ae6262 100644
--- a/src/armnn/Utils.cpp
+++ b/src/armnn/Utils.cpp
@@ -5,6 +5,13 @@
#include "armnn/Logging.hpp"
#include "armnn/Utils.hpp"
+#if !defined(BARE_METAL) && (defined(__arm__) || defined(__aarch64__))
+
+#include <sys/auxv.h>
+#include <asm/hwcap.h>
+
+#endif
+
namespace armnn
{
void ConfigureLogging(bool printToStandardOutput, bool printToDebugOutput, LogSeverity severity)
@@ -25,4 +32,45 @@ struct DefaultLoggingConfiguration
static DefaultLoggingConfiguration g_DefaultLoggingConfiguration;
+// Detect the presence of Neon on Linux
+bool NeonDetected()
+{
+#if !defined(BARE_METAL) && (defined(__arm__) || defined(__aarch64__))
+ auto hwcaps= getauxval(AT_HWCAP);
+#endif
+
+#if !defined(BARE_METAL) && defined(__aarch64__)
+
+ if (hwcaps & HWCAP_ASIMD)
+ {
+ // On an arm64 device with Neon.
+ return true;
+ }
+ else
+ {
+ // On an arm64 device without Neon.
+ return false;
+ }
+
+#endif
+#if !defined(BARE_METAL) && defined(__arm__)
+
+ if (hwcaps & HWCAP_NEON)
+ {
+ // On an armhf device with Neon.
+ return true;
+ }
+ else
+ {
+ // On an armhf device without Neon.
+ return false;
+ }
+
+#endif
+
+ // This method of Neon detection is only supported on Linux so in order to prevent a false negative
+ // we will return true in cases where detection did not run.
+ return true;
+}
+
} // namespace armnn \ No newline at end of file