ArmNN
 24.05
Utils.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017, 2024 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #include "armnn/Logging.hpp"
6 #include "armnn/Utils.hpp"
7 #include "armnn/Version.hpp"
8 
9 #if !defined(__APPLE__)
10 #if !defined(ARMNN_BUILD_BARE_METAL) && (defined(__arm__) || defined(__aarch64__))
11 
12 #include <sys/auxv.h>
13 #include <asm/hwcap.h>
14 
15 #endif
16 #endif
17 
18 namespace armnn
19 {
20 void ConfigureLogging(bool printToStandardOutput, bool printToDebugOutput, LogSeverity severity)
21 {
22  SetAllLoggingSinks(printToStandardOutput, printToDebugOutput, false);
23  SetLogFilter(severity);
24 }
25 
26 // Defaults to logging completely disabled.
27 // The user of the library must enable it if they want by calling armnn::ConfigureLogging().
28 struct DefaultLoggingConfiguration
29 {
30  DefaultLoggingConfiguration()
31  {
32  ConfigureLogging(false, false, LogSeverity::Trace);
33  }
34 };
35 
36 static DefaultLoggingConfiguration g_DefaultLoggingConfiguration;
37 
38 // Detect the presence of Neon on Linux
40 {
41 #if !defined(__APPLE__)
42 #if !defined(ARMNN_BUILD_BARE_METAL) && (defined(__arm__) || defined(__aarch64__))
43  auto hwcaps= getauxval(AT_HWCAP);
44 #endif
45 
46 #if !defined(ARMNN_BUILD_BARE_METAL) && defined(__aarch64__)
47 
48  if (hwcaps & HWCAP_ASIMD)
49  {
50  // On an arm64 device with Neon.
51  return true;
52  }
53  else
54  {
55  // On an arm64 device without Neon.
56  return false;
57  }
58 
59 #endif
60 #if !defined(ARMNN_BUILD_BARE_METAL) && defined(__arm__)
61 
62  if (hwcaps & HWCAP_NEON)
63  {
64  // On an armhf device with Neon.
65  return true;
66  }
67  else
68  {
69  // On an armhf device without Neon.
70  return false;
71  }
72 
73 #endif
74 #endif
75 
76  // This method of Neon detection is only supported on Linux so in order to prevent a false negative
77  // we will return true in cases where detection did not run.
78  return true;
79 }
80 
81 const std::string GetVersion()
82 {
83  return ARMNN_VERSION;
84 }
85 
86 } // namespace armnn
armnn::LogSeverity::Trace
@ Trace
armnn::ConfigureLogging
void ConfigureLogging(bool printToStandardOutput, bool printToDebugOutput, LogSeverity severity)
Configures the logging behaviour of the ARMNN library.
Definition: Utils.cpp:20
armnn::SetLogFilter
void SetLogFilter(LogSeverity level)
Definition: Logging.cpp:73
armnn::GetVersion
const std::string GetVersion()
Definition: Utils.cpp:81
Version.hpp
Logging.hpp
Utils.hpp
armnn::SetAllLoggingSinks
void SetAllLoggingSinks(bool standardOut, bool debugOut, bool coloured)
Definition: Logging.cpp:191
ARMNN_VERSION
#define ARMNN_VERSION
ARMNN_VERSION: "X.Y.Z" where: X = Major version number Y = Minor version number Z = Patch version num...
Definition: Version.hpp:22
armnn::NeonDetected
bool NeonDetected()
Definition: Utils.cpp:39
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnn::LogSeverity
LogSeverity
Definition: Utils.hpp:13