Browse Source

remove Control.DisableParallelization

provider
Thomas Ibel 13 years ago
parent
commit
8f0a48354c
  1. 9
      src/Numerics/Control.cs
  2. 8
      src/Numerics/Threading/CommonParallel.cs

9
src/Numerics/Control.cs

@ -61,7 +61,6 @@ namespace MathNet.Numerics
// Parallelization & Threading // Parallelization & Threading
_numberOfThreads = Environment.ProcessorCount; _numberOfThreads = Environment.ProcessorCount;
DisableParallelization = _numberOfThreads < 2;
_blockSize = 512; _blockSize = 512;
_parallelizeOrder = 64; _parallelizeOrder = 64;
_parallelizeElements = 300; _parallelizeElements = 300;
@ -93,7 +92,6 @@ namespace MathNet.Numerics
public static void UseSingleThread() public static void UseSingleThread()
{ {
_numberOfThreads = 1; _numberOfThreads = 1;
DisableParallelization = true;
ThreadSafeRandomNumberGenerators = false; ThreadSafeRandomNumberGenerators = false;
} }
@ -125,11 +123,6 @@ namespace MathNet.Numerics
/// </value> /// </value>
public static bool ThreadSafeRandomNumberGenerators { get; set; } public static bool ThreadSafeRandomNumberGenerators { get; set; }
/// <summary>
/// Gets or sets a value indicating whether parallelization shall be disabled globally.
/// </summary>
public static bool DisableParallelization { get; set; }
/// <summary> /// <summary>
/// Gets or sets the linear algebra provider. Consider to use UseNativeMKL or UseManaged instead. /// Gets or sets the linear algebra provider. Consider to use UseNativeMKL or UseManaged instead.
/// </summary> /// </summary>
@ -197,7 +190,7 @@ namespace MathNet.Numerics
/// <returns><c>true</c> if the operation should be parallelized; <c>false</c> otherwise.</returns> /// <returns><c>true</c> if the operation should be parallelized; <c>false</c> otherwise.</returns>
public static bool ParallelizeOperation(int elements) public static bool ParallelizeOperation(int elements)
{ {
return !DisableParallelization && NumberOfParallelWorkerThreads >= 2 && elements >= ParallelizeElements; return NumberOfParallelWorkerThreads >= 2 && elements >= ParallelizeElements;
} }
/// <summary> /// <summary>

8
src/Numerics/Threading/CommonParallel.cs

@ -90,7 +90,7 @@ namespace MathNet.Numerics.Threading
} }
// Special case: not worth to parallelize, inline // 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); body(fromInclusive, toExclusive);
return; return;
@ -125,7 +125,7 @@ namespace MathNet.Numerics.Threading
} }
// Special case: straight execution without parallelism // Special case: straight execution without parallelism
if (Control.DisableParallelization || Control.NumberOfParallelWorkerThreads < 2) if (Control.NumberOfParallelWorkerThreads < 2)
{ {
for (int i = 0; i < actions.Length; i++) for (int i = 0; i < actions.Length; i++)
{ {
@ -166,7 +166,7 @@ namespace MathNet.Numerics.Threading
} }
// Special case: straight execution without parallelism // Special case: straight execution without parallelism
if (Control.DisableParallelization || Control.NumberOfParallelWorkerThreads < 2) if (Control.NumberOfParallelWorkerThreads < 2)
{ {
var mapped = new T[toExclusive - fromInclusive]; var mapped = new T[toExclusive - fromInclusive];
for (int k = 0; k < mapped.Length; k++) for (int k = 0; k < mapped.Length; k++)
@ -228,7 +228,7 @@ namespace MathNet.Numerics.Threading
} }
// Special case: straight execution without parallelism // Special case: straight execution without parallelism
if (Control.DisableParallelization || Control.NumberOfParallelWorkerThreads < 2) if (Control.NumberOfParallelWorkerThreads < 2)
{ {
var mapped = new TOut[array.Length]; var mapped = new TOut[array.Length];
for (int k = 0; k < mapped.Length; k++) for (int k = 0; k < mapped.Length; k++)

Loading…
Cancel
Save