Browse Source

fixed a problem were Parallel Invoke and Select where ignoring threading options from Control, there is still an issue with recursively calling invoke.

pull/36/head
Marcus Cuda 16 years ago
parent
commit
39ea72370a
  1. 3
      src/MathNet.Numerics.5.1.ReSharper
  2. 16
      src/Numerics/Threading/CommonParallel.cs

3
src/MathNet.Numerics.5.1.ReSharper

@ -82,7 +82,8 @@ Wikipedia
kronecker
blocksize
ipiv
dll</UserWords>
dll
Silverlight</UserWords>
</CustomDictionary>
</Dictionaries>
</CustomDictionaries>

16
src/Numerics/Threading/CommonParallel.cs

@ -327,11 +327,17 @@ namespace MathNet.Numerics.Threading
/// Executes each of the provided actions inside a discrete, asynchronous task.
/// </summary>
/// <param name="actions">An array of actions to execute.</param>
/// <exception cref="ArgumentException">The actions array contains a null element.</exception>
/// <exception cref="ArgumentException">The actions array contains a <c>null</c> element.</exception>
/// <exception cref="AggregateException">An action threw an exception.</exception>
public static void Invoke(params Action[] actions)
{
Parallel.Invoke(actions);
var maxThreads = Control.DisableParallelization ? 1 : Control.NumberOfParallelWorkerThreads;
Parallel.Invoke(
new ParallelOptions
{
MaxDegreeOfParallelism = maxThreads
},
actions);
}
/// <summary>
@ -361,9 +367,10 @@ namespace MathNet.Numerics.Threading
}
});
#else
var maxThreads = Control.DisableParallelization ? 1 : Control.NumberOfParallelWorkerThreads;
Parallel.ForEach(
Partitioner.Create(fromInclusive, toExclusive),
new ParallelOptions { MaxDegreeOfParallelism = Control.NumberOfParallelWorkerThreads },
new ParallelOptions { MaxDegreeOfParallelism = maxThreads },
() => 0.0,
(range, loop, localData) =>
{
@ -413,9 +420,10 @@ namespace MathNet.Numerics.Threading
}
});
#else
var maxThreads = Control.DisableParallelization ? 1 : Control.NumberOfParallelWorkerThreads;
Parallel.ForEach(
Partitioner.Create(fromInclusive, toExclusive),
new ParallelOptions { MaxDegreeOfParallelism = Control.NumberOfParallelWorkerThreads },
new ParallelOptions { MaxDegreeOfParallelism = maxThreads },
() => 0.0f,
(range, loop, localData) =>
{

Loading…
Cancel
Save