[Hexagon] One more fix for concurrency count (#5589)
authorKrzysztof Parzyszek <kparzysz@quicinc.com>
Thu, 14 May 2020 00:16:14 +0000 (19:16 -0500)
committerGitHub <noreply@github.com>
Thu, 14 May 2020 00:16:14 +0000 (17:16 -0700)
src/runtime/threading_backend.cc

index 2e781ea..e5520ef 100644 (file)
@@ -34,6 +34,9 @@
 #if defined(__linux__)
 #include <sched.h>
 #endif
+#if defined(__hexagon__)
+#include <dlfcn.h>
+#endif
 
 namespace tvm {
 namespace runtime {
@@ -177,6 +180,11 @@ class ThreadGroup::Impl {
 
   void InitSortedOrder() {
     unsigned int threads = std::thread::hardware_concurrency();
+#if defined(__hexagon__)
+    // With unsigned PDs, getting the number of available hardware threads
+    // is not supported in earlier versions of QuRT. In such cases assume 4.
+    if (threads == 0) threads = 4;
+#endif
     std::vector<std::pair<unsigned int, int64_t> > max_freqs;
 
     for (unsigned int i = 0; i < threads; ++i) {