From 43c361dd87c0293ff46b0df7442f120e589c5952 Mon Sep 17 00:00:00 2001 From: Christoph Ruegg Date: Fri, 13 Mar 2015 13:05:26 +0100 Subject: [PATCH] Native: replace NATIVEMKL build constant with NATIVE as it can be used by other native providers as well #296 --- README.md | 6 +++--- src/Numerics/Control.cs | 10 +++++++--- src/Numerics/Numerics.csproj | 6 +++--- .../Mkl/MklLinearAlgebraProvider.Complex.cs | 2 +- .../Mkl/MklLinearAlgebraProvider.Complex32.cs | 2 +- .../Mkl/MklLinearAlgebraProvider.Double.cs | 2 +- .../Mkl/MklLinearAlgebraProvider.Single.cs | 2 +- .../LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs | 2 +- .../Providers/LinearAlgebra/Mkl/SafeNativeMethods.cs | 2 +- src/Numerics/Providers/NativeProviderLoader.cs | 2 +- src/Performance/LinearAlgebra/DenseMatrixProduct.cs | 2 +- src/Performance/LinearAlgebra/DenseVectorAdd.cs | 2 +- src/Performance/Performance.csproj | 2 +- src/UnitTests/UnitTests-MKL.csproj | 12 ++++++------ src/UnitTests/UseLinearAlgebraProvider.cs | 2 +- 15 files changed, 30 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 5be15dcb..0595af45 100644 --- a/README.md +++ b/README.md @@ -80,10 +80,10 @@ Compilation symbols used to deal with platform differences: * **PORTABLE** - Some framework attributes are not available and we provide our own parallelization routines and partitioning using TPL Tasks. Reduced globalization and serialization support. Work around some missing routines like `Math.DivRem`, `Array.FindIndex` and `BitConverter`. There is no `ICloneable`. The crypto random source is not available; simpler random seeding. * **NOSYSNUMERICS** - The `System.Numerics` framework assembly is not available. We provide our own double-precision complex number type and disable all arbitrary precision numbers support (BigInteger, BigRational). * **NET45REFLECTION** - we use the new .Net 4.5 reflection API where type information is split into `Type` and `TypeInfo`. -* **NATIVEMKL** - we can support the Intel MKL native provider. +* **NATIVE** - we can support native providers like Intel MKL. -Configuration | Net35 | Portable | NoSysNumerics | Net45Reflection | NativeMKL -------------- | ----- | -------- | ------------- | --------------- | --------- +Configuration | Net35 | Portable | NoSysNumerics | Net45Reflection | Native +------------- | ----- | -------- | ------------- | --------------- | ------ .Net 4.0 | - | - | - | - | Yes .Net 3.5 | Yes | - | Yes | - | - Portable 7 | - | Yes | - | Yes | - diff --git a/src/Numerics/Control.cs b/src/Numerics/Control.cs index 65fade82..1632b53c 100644 --- a/src/Numerics/Control.cs +++ b/src/Numerics/Control.cs @@ -64,19 +64,23 @@ namespace MathNet.Numerics TaskScheduler = TaskScheduler.Default; // Linear Algebra Provider +#if PORTABLE LinearAlgebraProvider = new ManagedLinearAlgebraProvider(); -#if !PORTABLE && NATIVEMKL +#else try { const string name = "MathNetNumericsLAProvider"; var value = Environment.GetEnvironmentVariable(name); switch (value != null ? value.ToUpperInvariant() : string.Empty) { -#if NATIVEMKL +#if NATIVE case "MKL": LinearAlgebraProvider = new Providers.LinearAlgebra.Mkl.MklLinearAlgebraProvider(); break; #endif + default: + LinearAlgebraProvider = new ManagedLinearAlgebraProvider(); + break; } } catch @@ -108,7 +112,7 @@ namespace MathNet.Numerics LinearAlgebraProvider = new ManagedLinearAlgebraProvider(); } -#if NATIVEMKL +#if NATIVE public static void UseNativeMKL() { LinearAlgebraProvider = new Providers.LinearAlgebra.Mkl.MklLinearAlgebraProvider(); diff --git a/src/Numerics/Numerics.csproj b/src/Numerics/Numerics.csproj index 440d8d54..b783234e 100644 --- a/src/Numerics/Numerics.csproj +++ b/src/Numerics/Numerics.csproj @@ -39,7 +39,7 @@ pdbonly true - TRACE;NATIVEMKL + TRACE;NATIVE prompt 4 AllRules.ruleset @@ -53,7 +53,7 @@ true full false - TRACE;DEBUG;NATIVEMKL + TRACE;DEBUG;NATIVE prompt 4 AllRules.ruleset @@ -68,7 +68,7 @@ pdbonly AnyCPU true - TRACE;NATIVEMKL;STRONGNAME + TRACE;NATIVE;STRONGNAME prompt 4 AllRules.ruleset diff --git a/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex.cs b/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex.cs index e53f2303..126f6285 100644 --- a/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex.cs +++ b/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex.cs @@ -28,7 +28,7 @@ // OTHER DEALINGS IN THE SOFTWARE. // -#if NATIVEMKL +#if NATIVE using System; using System.Numerics; diff --git a/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex32.cs b/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex32.cs index 9941d8e9..715522f6 100644 --- a/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex32.cs +++ b/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex32.cs @@ -28,7 +28,7 @@ // OTHER DEALINGS IN THE SOFTWARE. // -#if NATIVEMKL +#if NATIVE using System; using System.Numerics; diff --git a/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Double.cs b/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Double.cs index cde810ff..8054efc4 100644 --- a/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Double.cs +++ b/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Double.cs @@ -28,7 +28,7 @@ // OTHER DEALINGS IN THE SOFTWARE. // -#if NATIVEMKL +#if NATIVE using System; using System.Numerics; diff --git a/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Single.cs b/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Single.cs index 02ab1b83..46222bfa 100644 --- a/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Single.cs +++ b/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Single.cs @@ -28,7 +28,7 @@ // OTHER DEALINGS IN THE SOFTWARE. // -#if NATIVEMKL +#if NATIVE using System; using System.Numerics; diff --git a/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs b/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs index 5d0555e4..5fe07ce2 100644 --- a/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs +++ b/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs @@ -30,7 +30,7 @@ using System; -#if NATIVEMKL +#if NATIVE namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl { diff --git a/src/Numerics/Providers/LinearAlgebra/Mkl/SafeNativeMethods.cs b/src/Numerics/Providers/LinearAlgebra/Mkl/SafeNativeMethods.cs index 7ed01c20..1bd150f9 100644 --- a/src/Numerics/Providers/LinearAlgebra/Mkl/SafeNativeMethods.cs +++ b/src/Numerics/Providers/LinearAlgebra/Mkl/SafeNativeMethods.cs @@ -26,7 +26,7 @@ // OTHER DEALINGS IN THE SOFTWARE. // -#if NATIVEMKL +#if NATIVE using System.Numerics; using System.Runtime.InteropServices; diff --git a/src/Numerics/Providers/NativeProviderLoader.cs b/src/Numerics/Providers/NativeProviderLoader.cs index ba81a1b2..c0c50511 100644 --- a/src/Numerics/Providers/NativeProviderLoader.cs +++ b/src/Numerics/Providers/NativeProviderLoader.cs @@ -35,7 +35,7 @@ using System.Reflection; using System.Runtime.InteropServices; using System.Security; -#if NATIVEMKL +#if NATIVE namespace MathNet.Numerics.Providers { diff --git a/src/Performance/LinearAlgebra/DenseMatrixProduct.cs b/src/Performance/LinearAlgebra/DenseMatrixProduct.cs index e62c782d..8f06a07c 100644 --- a/src/Performance/LinearAlgebra/DenseMatrixProduct.cs +++ b/src/Performance/LinearAlgebra/DenseMatrixProduct.cs @@ -32,7 +32,7 @@ namespace Performance.LinearAlgebra _unsafeProvider.InitializeVerify(); _experimentalProvider.InitializeVerify(); -#if NATIVEMKL +#if NATIVE _mkl.InitializeVerify(); #endif } diff --git a/src/Performance/LinearAlgebra/DenseVectorAdd.cs b/src/Performance/LinearAlgebra/DenseVectorAdd.cs index c4ce38f0..b6163301 100644 --- a/src/Performance/LinearAlgebra/DenseVectorAdd.cs +++ b/src/Performance/LinearAlgebra/DenseVectorAdd.cs @@ -28,7 +28,7 @@ namespace Performance.LinearAlgebra _managed.InitializeVerify(); Control.LinearAlgebraProvider = _managed; -#if NATIVEMKL +#if NATIVE _mkl.InitializeVerify(); #endif } diff --git a/src/Performance/Performance.csproj b/src/Performance/Performance.csproj index 27f5ce88..80df016d 100644 --- a/src/Performance/Performance.csproj +++ b/src/Performance/Performance.csproj @@ -27,7 +27,7 @@ pdbonly true bin\Release\ - TRACE;NATIVEMKL + TRACE;NATIVE prompt 4 x64 diff --git a/src/UnitTests/UnitTests-MKL.csproj b/src/UnitTests/UnitTests-MKL.csproj index f6e03efb..2430ead3 100644 --- a/src/UnitTests/UnitTests-MKL.csproj +++ b/src/UnitTests/UnitTests-MKL.csproj @@ -16,7 +16,7 @@ ..\..\ - TRACE;NATIVEMKL + TRACE;NATIVE ..\..\out\MKL\Windows\AnyCPU\ ..\..\obj\MKL\Windows\x86\ ..\..\obj\MKL\Windows\x86\ @@ -28,7 +28,7 @@ AnyCPU - TRACE;DEBUG;NATIVEMKL + TRACE;DEBUG;NATIVE ..\..\out\MKL\Windows\AnyCPU\ ..\..\obj\MKL\Windows\x86\ ..\..\obj\MKL\Windows\x86\ @@ -44,7 +44,7 @@ ..\..\out\MKL\Windows\x86\ ..\..\obj\MKL\Windows\x86\ ..\..\obj\MKL\Windows\x86\ - TRACE;NATIVEMKL + TRACE;NATIVE true 1591 pdbonly @@ -57,7 +57,7 @@ ..\..\out\MKL\Windows\x86\ ..\..\obj\MKL\Windows\x86\ ..\..\obj\MKL\Windows\x86\ - TRACE;DEBUG;NATIVEMKL + TRACE;DEBUG;NATIVE 1591 full x86 @@ -68,7 +68,7 @@ ..\..\out\MKL\Windows\x64\ ..\..\obj\MKL\Windows\x64\ ..\..\obj\MKL\Windows\x64\ - TRACE;NATIVEMKL + TRACE;NATIVE true 1591 pdbonly @@ -81,7 +81,7 @@ ..\..\out\MKL\Windows\x64\ ..\..\obj\MKL\Windows\x64\ ..\..\obj\MKL\Windows\x64\ - TRACE;DEBUG;NATIVEMKL + TRACE;DEBUG;NATIVE 1591 full x64 diff --git a/src/UnitTests/UseLinearAlgebraProvider.cs b/src/UnitTests/UseLinearAlgebraProvider.cs index d585aaf1..fc4a42d6 100644 --- a/src/UnitTests/UseLinearAlgebraProvider.cs +++ b/src/UnitTests/UseLinearAlgebraProvider.cs @@ -38,7 +38,7 @@ namespace MathNet.Numerics.UnitTests { public void BeforeTest(TestDetails testDetails) { -#if !NET35 && NATIVEMKL +#if !NET35 && NATIVE Control.UseNativeMKL(); #endif }