[mathicgb] 240/393: It is now possible to set the max number of threads in the library interface.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Fri Apr 3 15:59:10 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch upstream
in repository mathicgb.

commit 852dc36795e66b4df78c97739cdec6fbeb915300
Author: Bjarke Hammersholt Roune <bjarkehr.code at gmail.com>
Date:   Fri Apr 12 16:49:29 2013 -0400

    It is now possible to set the max number of threads in the library interface.
---
 src/mathicgb.cpp | 19 ++++++++++++++++++-
 src/mathicgb.h   |  6 ++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/src/mathicgb.cpp b/src/mathicgb.cpp
index dc723be..e1d310c 100755
--- a/src/mathicgb.cpp
+++ b/src/mathicgb.cpp
@@ -6,6 +6,7 @@
 #include "mathicgb/Poly.hpp"
 #include "mathicgb/Reducer.hpp"
 #include "mathicgb/BuchbergerAlg.hpp"
+#include "mathicgb/mtbb.hpp"
 #include <mathic.h>
 
 namespace {
@@ -311,7 +312,8 @@ namespace mgb {
     Pimpl(Coefficient modulus, VarIndex varCount):
       mModulus(modulus),
       mVarCount(varCount),
-      mReducer(DefaultReducer)
+      mReducer(DefaultReducer),
+      mMaxThreadCount(0)
 #ifdef MATHICGB_DEBUG
       , mHasBeenDestroyed(false)
 #endif
@@ -343,6 +345,7 @@ namespace mgb {
     const Coefficient mModulus;
     const VarIndex mVarCount;
     Reducer mReducer;
+    size_t mMaxThreadCount;
     MATHICGB_IF_DEBUG(bool mHasBeenDestroyed);
   };
 
@@ -398,6 +401,14 @@ namespace mgb {
   auto GroebnerConfiguration::reducer() const -> Reducer {
     return mPimpl->mReducer;
   }
+
+  void GroebnerConfiguration::setMaxThreadCount(size_t maxThreadCount) {
+    mPimpl->mMaxThreadCount = maxThreadCount;
+  }
+
+  size_t GroebnerConfiguration::maxThreadCount() const {
+    return mPimpl->mMaxThreadCount;
+  }
 }
 
 // ** Implementation of class GroebnerInputIdealStream
@@ -629,6 +640,12 @@ namespace mgbi {
     const auto varCount = ring.getNumVars();
     MATHICGB_ASSERT(PimplOf()(conf).debugAssertValid());
 
+    // Tell tbb how many threads to use
+    const auto maxThreadCount = conf.maxThreadCount();
+    const auto tbbMaxThreadCount = maxThreadCount == 0 ?
+      mgb::tbb::task_scheduler_init::automatic : maxThreadCount;
+    mgb::tbb::task_scheduler_init scheduler(tbbMaxThreadCount);
+
     // Make reducer
     typedef GroebnerConfiguration GConf;
     Reducer::ReducerType reducerType;
diff --git a/src/mathicgb.h b/src/mathicgb.h
index bc94fa3..9f2ef0b 100755
--- a/src/mathicgb.h
+++ b/src/mathicgb.h
@@ -44,6 +44,12 @@ namespace mgb { // Part of the public interface of MathicGB
     void setReducer(Reducer reducer);
     Reducer reducer() const;
 
+    /// Sets the maximum number of threads to use. May use fewer threads.
+    /// A value of 0 indicates to let the library decide this value for
+    /// it self, which is also the default value.
+    void setMaxThreadCount(size_t maxThreadCount);
+    size_t maxThreadCount() const;
+
   private:
     friend class mgbi::PimplOf;
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mathicgb.git



More information about the debian-science-commits mailing list