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