[PATCH] [lld][Driver] Add maximum concurrency option.

Sean Silva silvas at purdue.edu
Fri Apr 19 20:30:29 PDT 2013


  It's not clear why this patch needs to introduce a global variable for capping the thread count. Can't you just pass the specified thread count directly into the thread pool constructor?


================
Comment at: lib/Driver/Driver.cpp:43-44
@@ -42,1 +42,4 @@
 
+  if (targetInfo.maxConcurrency())
+    setDefaultExecutorMaxConcurrency(targetInfo.maxConcurrency());
+
----------------
The strategy for passing this through the program is "set a global"? Doesn't that completely break any pretense of a library-based design?

================
Comment at: include/lld/Core/Parallel.h:76-89
@@ -75,1 +75,16 @@
 
+namespace detail {
+  inline unsigned &getDefaultExecutorMaxConcurrency() {
+    static unsigned maxCur = std::thread::hardware_concurrency();
+    return maxCur;
+  }
+}
+
+inline void setDefaultExecutorMaxConcurrency(unsigned maxCur) {
+  detail::getDefaultExecutorMaxConcurrency() = maxCur;
+}
+
+inline unsigned getDefaultExecutorMaxConcurrency() {
+  return detail::getDefaultExecutorMaxConcurrency();
+}
+
----------------
How is this any different than dumping a global variable into the header file?


http://llvm-reviews.chandlerc.com/D698



More information about the llvm-commits mailing list