Fix compile errors on Windows
authorRob Hughes <robert.hughes@arm.com>
Wed, 21 Nov 2018 09:55:52 +0000 (09:55 +0000)
committerMatteo Martincigh <matteo.martincigh@arm.com>
Mon, 26 Nov 2018 13:02:31 +0000 (13:02 +0000)
Change-Id: I40acb42360bfcda09485efb2a54144d8e35bdafb

include/armnn/BackendId.hpp
src/armnn/WallClockTimer.hpp

index 72248bc..8de985e 100644 (file)
@@ -132,31 +132,14 @@ private:
     std::string m_Id;
 };
 
-inline std::ostream& operator<<(std::ostream& os, const BackendId& id)
-{
-    os << id.Get();
-    return os;
-}
-
-template <template <class...> class TContainer>
-inline std::ostream& operator<<(std::ostream& os,
-                                const TContainer<BackendId>& ids)
-{
-    os << '[';
-    for (const auto& id : ids) { os << id << " "; }
-    os << ']';
-    return os;
 }
 
-using BackendIdSet = std::unordered_set<BackendId>;
-
-} // namespace armnn
-
 namespace std
 {
 
 // make BackendId compatible with std hashtables by reusing the hash
-// function for strings
+// function for strings.
+// Note this must come *before* the first use of unordered_set<BackendId>.
 template <>
 struct hash<armnn::BackendId>
 {
@@ -168,3 +151,27 @@ struct hash<armnn::BackendId>
 };
 
 } // namespace std
+
+namespace armnn
+{
+
+inline std::ostream& operator<<(std::ostream& os, const BackendId& id)
+{
+    os << id.Get();
+    return os;
+}
+
+template <template <typename...> class TContainer, typename... TContainerTemplateArgs>
+std::ostream& operator<<(std::ostream& os,
+                                const TContainer<BackendId, TContainerTemplateArgs...>& ids)
+{
+    os << '[';
+    for (const auto& id : ids) { os << id << " "; }
+    os << ']';
+    return os;
+}
+
+using BackendIdSet = std::unordered_set<BackendId>;
+
+} // namespace armnn
+
index 88cbb4d..197ad7d 100644 (file)
@@ -11,7 +11,7 @@
 namespace armnn
 {
 
-// Clock class that uses the same timestamp function as the Mali DDK.
+// Clock class that uses the same timestamp function as the Mali DDK where possible.
 class monotonic_clock_raw {
 public:
     using duration = std::chrono::nanoseconds;
@@ -19,9 +19,15 @@ public:
 
     static std::chrono::time_point<monotonic_clock_raw, std::chrono::nanoseconds> now() noexcept
     {
+#if defined(__unix__)
         timespec ts;
         clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
-        return time_point(std::chrono::nanoseconds(ts.tv_sec*1000000000 + ts.tv_nsec));
+        return time_point(std::chrono::nanoseconds(ts.tv_sec * 1000000000 + ts.tv_nsec));
+#else
+        // On other platforms we have to make do with the standard C++ API, which may not exactly match
+        // the Mali DDK.
+        return std::chrono::time_point<monotonic_clock_raw, std::chrono::nanoseconds>();
+#endif
     }
 };