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

Michael Spencer bigcheesegs at gmail.com
Fri Apr 19 22:52:25 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?

  We don't always use a thread pool. getDefaultExecutor() has to have some way of knowing how many threads to use by default. Passing this as a parameter is weird, as it would only have an effect on the first call.

  I went with this design as it gives the user the choice to set the default or not based on the settings of TargetInfo.


================
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();
+}
+
----------------
Sean Silva wrote:
> How is this any different than dumping a global variable into the header file?
It has proper global semantics without a cpp to provide a definition of the global.


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



More information about the llvm-commits mailing list