From 8f0a48354ca4aef9d320ff279bc2554f56fc1209 Mon Sep 17 00:00:00 2001 From: Thomas Ibel Date: Tue, 25 Feb 2014 18:35:07 +0100 Subject: [PATCH] remove Control.DisableParallelization --- src/Numerics/Control.cs | 9 +-------- src/Numerics/Threading/CommonParallel.cs | 8 ++++---- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/Numerics/Control.cs b/src/Numerics/Control.cs index edecd791..54073258 100644 --- a/src/Numerics/Control.cs +++ b/src/Numerics/Control.cs @@ -61,7 +61,6 @@ namespace MathNet.Numerics // Parallelization & Threading _numberOfThreads = Environment.ProcessorCount; - DisableParallelization = _numberOfThreads < 2; _blockSize = 512; _parallelizeOrder = 64; _parallelizeElements = 300; @@ -93,7 +92,6 @@ namespace MathNet.Numerics public static void UseSingleThread() { _numberOfThreads = 1; - DisableParallelization = true; ThreadSafeRandomNumberGenerators = false; } @@ -125,11 +123,6 @@ namespace MathNet.Numerics /// public static bool ThreadSafeRandomNumberGenerators { get; set; } - /// - /// Gets or sets a value indicating whether parallelization shall be disabled globally. - /// - public static bool DisableParallelization { get; set; } - /// /// Gets or sets the linear algebra provider. Consider to use UseNativeMKL or UseManaged instead. /// @@ -197,7 +190,7 @@ namespace MathNet.Numerics /// true if the operation should be parallelized; false otherwise. public static bool ParallelizeOperation(int elements) { - return !DisableParallelization && NumberOfParallelWorkerThreads >= 2 && elements >= ParallelizeElements; + return NumberOfParallelWorkerThreads >= 2 && elements >= ParallelizeElements; } /// diff --git a/src/Numerics/Threading/CommonParallel.cs b/src/Numerics/Threading/CommonParallel.cs index f98575cf..d8c12729 100644 --- a/src/Numerics/Threading/CommonParallel.cs +++ b/src/Numerics/Threading/CommonParallel.cs @@ -90,7 +90,7 @@ namespace MathNet.Numerics.Threading } // Special case: not worth to parallelize, inline - if (Control.DisableParallelization || Control.NumberOfParallelWorkerThreads < 2 || (rangeSize * 2) > length) + if (Control.NumberOfParallelWorkerThreads < 2 || (rangeSize * 2) > length) { body(fromInclusive, toExclusive); return; @@ -125,7 +125,7 @@ namespace MathNet.Numerics.Threading } // Special case: straight execution without parallelism - if (Control.DisableParallelization || Control.NumberOfParallelWorkerThreads < 2) + if (Control.NumberOfParallelWorkerThreads < 2) { for (int i = 0; i < actions.Length; i++) { @@ -166,7 +166,7 @@ namespace MathNet.Numerics.Threading } // Special case: straight execution without parallelism - if (Control.DisableParallelization || Control.NumberOfParallelWorkerThreads < 2) + if (Control.NumberOfParallelWorkerThreads < 2) { var mapped = new T[toExclusive - fromInclusive]; for (int k = 0; k < mapped.Length; k++) @@ -228,7 +228,7 @@ namespace MathNet.Numerics.Threading } // Special case: straight execution without parallelism - if (Control.DisableParallelization || Control.NumberOfParallelWorkerThreads < 2) + if (Control.NumberOfParallelWorkerThreads < 2) { var mapped = new TOut[array.Length]; for (int k = 0; k < mapped.Length; k++)