Browse Source

Control: Describe gives an overview over the current configuration

spatial
Christoph Ruegg 9 years ago
parent
commit
bef1641d69
  1. 61
      src/Numerics/Control.cs
  2. 17
      src/UnitTests/UseLinearAlgebraProvider.cs

61
src/Numerics/Control.cs

@ -28,6 +28,10 @@
// </copyright> // </copyright>
using System; using System;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using MathNet.Numerics.Providers.FourierTransform; using MathNet.Numerics.Providers.FourierTransform;
using MathNet.Numerics.Providers.LinearAlgebra; using MathNet.Numerics.Providers.LinearAlgebra;
@ -40,7 +44,6 @@ namespace MathNet.Numerics
public static class Control public static class Control
{ {
static int _maxDegreeOfParallelism; static int _maxDegreeOfParallelism;
static int _blockSize;
static int _parallelizeOrder; static int _parallelizeOrder;
static int _parallelizeElements; static int _parallelizeElements;
static string _nativeProviderHintPath; static string _nativeProviderHintPath;
@ -58,7 +61,6 @@ namespace MathNet.Numerics
// Parallelization & Threading // Parallelization & Threading
ThreadSafeRandomNumberGenerators = true; ThreadSafeRandomNumberGenerators = true;
_maxDegreeOfParallelism = Environment.ProcessorCount; _maxDegreeOfParallelism = Environment.ProcessorCount;
_blockSize = 512;
_parallelizeOrder = 64; _parallelizeOrder = 64;
_parallelizeElements = 300; _parallelizeElements = 300;
TaskScheduler = TaskScheduler.Default; TaskScheduler = TaskScheduler.Default;
@ -259,17 +261,6 @@ namespace MathNet.Numerics
/// </summary> /// </summary>
public static TaskScheduler TaskScheduler { get; set; } public static TaskScheduler TaskScheduler { get; set; }
/// <summary>
/// Gets or sets the block size to use for
/// the native linear algebra provider.
/// </summary>
/// <value>The block size. Default 512, must be at least 32.</value>
public static int BlockSize
{
get { return _blockSize; }
set { _blockSize = Math.Max(32, value); }
}
/// <summary> /// <summary>
/// Gets or sets the order of the matrix when linear algebra provider /// Gets or sets the order of the matrix when linear algebra provider
/// must calculate multiply in parallel threads. /// must calculate multiply in parallel threads.
@ -291,5 +282,49 @@ namespace MathNet.Numerics
get { return _parallelizeElements; } get { return _parallelizeElements; }
set { _parallelizeElements = Math.Max(3, value); } set { _parallelizeElements = Math.Max(3, value); }
} }
public static string Describe()
{
#if NET40
var versionAttribute = typeof(Control).Assembly
.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false)
.OfType<AssemblyInformationalVersionAttribute>()
.FirstOrDefault();
#else
var versionAttribute = typeof(Control).GetTypeInfo().Assembly.GetCustomAttribute(typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute;
#endif
var sb = new StringBuilder();
sb.AppendLine("Math.NET Numerics Configuration:");
sb.AppendLine($"Version {versionAttribute?.InformationalVersion}");
#if NETSTANDARD1_3
sb.AppendLine("Built for .Net Standard 1.3");
#elif NETSTANDARD2_0
sb.AppendLine("Built for .Net Standard 2.0");
#elif NET40
sb.AppendLine("Built for .Net Framework 4.0");
#endif
#if !NATIVE
sb.AppendLine("No Native Provider Support");
#endif
sb.AppendLine($"Linear Algebra Provider: {LinearAlgebraControl.Provider}");
sb.AppendLine($"Fourier Transform Provider: {FourierTransformControl.Provider}");
sb.AppendLine($"Max Degree of Parallelism: {MaxDegreeOfParallelism}");
sb.AppendLine($"Parallelize Elements: {ParallelizeElements}");
sb.AppendLine($"Parallelize Order: {ParallelizeOrder}");
sb.AppendLine($"Check Distribution Parameters: {CheckDistributionParameters}");
sb.AppendLine($"Thread-Safe RNGs: {ThreadSafeRandomNumberGenerators}");
#if NETSTANDARD1_3 || NETSTANDARD2_0
// This would also work in .Net 4.0, but we don't want the dependency just for that.
sb.AppendLine($"Operating System: {RuntimeInformation.OSDescription}");
sb.AppendLine($"Operating System Architecture: {RuntimeInformation.OSArchitecture}");
sb.AppendLine($"Framework: {RuntimeInformation.FrameworkDescription}");
sb.AppendLine($"Process Architecture: {RuntimeInformation.ProcessArchitecture}");
#else
sb.AppendLine($"Operating System: {Environment.OSVersion}");
sb.AppendLine($"Framework: {Environment.Version}");
#endif
return sb.ToString();
}
} }
} }

17
src/UnitTests/UseLinearAlgebraProvider.cs

@ -28,10 +28,6 @@
// </copyright> // </copyright>
using System; using System;
using System.Runtime.InteropServices;
using MathNet.Numerics.Providers.FourierTransform;
using MathNet.Numerics.Providers.LinearAlgebra;
using NUnit.Framework; using NUnit.Framework;
using NUnit.Framework.Interfaces; using NUnit.Framework.Interfaces;
@ -58,18 +54,7 @@ namespace MathNet.Numerics.UnitTests
// ReSharper disable LocalizableElement // ReSharper disable LocalizableElement
Console.WriteLine(); Console.WriteLine();
Console.WriteLine("Math.NET Numerics Test Configuration:"); Console.WriteLine(Control.Describe());
Console.WriteLine($"Operating System: {RuntimeInformation.OSDescription}");
Console.WriteLine($"Framework: {RuntimeInformation.FrameworkDescription}");
Console.WriteLine($"Operating System Architecture: {RuntimeInformation.OSArchitecture}");
Console.WriteLine($"Process Architecture: {RuntimeInformation.ProcessArchitecture}");
#if !NETCOREAPP1_1
Console.WriteLine($"CLR Version: {Environment.Version}");
Console.WriteLine($"OS Version: {Environment.OSVersion}");
#endif
Console.WriteLine($"Linear Algebra Provider: {LinearAlgebraControl.Provider}");
Console.WriteLine($"Fourier Transform Provider: {FourierTransformControl.Provider}");
Console.WriteLine();
// ReSharper restore LocalizableElement // ReSharper restore LocalizableElement
} }

Loading…
Cancel
Save