Browse Source

Providers: InitializeVerify

pull/184/head
Christoph Ruegg 13 years ago
parent
commit
cb28a44a61
  1. 4
      MathNet.Numerics.NativeProviders.sln
  2. 1
      MathNet.Numerics.sln.DotSettings
  3. 32
      src/Numerics/Control.cs
  4. 3
      src/Numerics/Numerics.csproj
  5. 4
      src/Numerics/Providers/LinearAlgebra/ILinearAlgebraProvider.cs
  6. 2
      src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs
  7. 2
      src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs
  8. 4
      src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Double.cs
  9. 2
      src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Single.cs
  10. 50
      src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.cs
  11. 4
      src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex.cs
  12. 4
      src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex32.cs
  13. 4
      src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Single.cs
  14. 15
      src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs
  15. 4
      src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.double.cs

4
MathNet.Numerics.NativeProviders.sln

@ -12,9 +12,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{5A0892
src\NativeProviders\Common\wrapper_common.h = src\NativeProviders\Common\wrapper_common.h
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MKLWrapper", "src\NativeProviders\Windows\MKL\MKLWrapper.vcxproj", "{C0B0DBA9-7FB0-4C87-BDB1-3EED19DC2B8F}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MKL", "src\NativeProviders\Windows\MKL\MKLWrapper.vcxproj", "{C0B0DBA9-7FB0-4C87-BDB1-3EED19DC2B8F}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ATLASWrapper", "src\NativeProviders\Windows\ATLAS\ATLASWrapper.vcxproj", "{2362B8AC-C52B-45E4-A1BF-C682A4DB4220}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ATLAS", "src\NativeProviders\Windows\ATLAS\ATLASWrapper.vcxproj", "{2362B8AC-C52B-45E4-A1BF-C682A4DB4220}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

1
MathNet.Numerics.sln.DotSettings

@ -58,6 +58,7 @@ OTHER DEALINGS IN THE SOFTWARE.
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MC/@EntryIndexedValue">MC</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MCMC/@EntryIndexedValue">MCMC</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MILU/@EntryIndexedValue">MILU</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MKL/@EntryIndexedValue">MKL</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MSE/@EntryIndexedValue">MSE</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PDF/@EntryIndexedValue">PDF</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=QR/@EntryIndexedValue">QR</s:String>

32
src/Numerics/Control.cs

@ -38,10 +38,11 @@ namespace MathNet.Numerics
/// </summary>
public static class Control
{
private static int _numberOfThreads;
private static int _blockSize;
private static int _parallelizeOrder;
private static int _parallelizeElements;
static int _numberOfThreads;
static int _blockSize;
static int _parallelizeOrder;
static int _parallelizeElements;
static ILinearAlgebraProvider _linearAlgebraProvider;
static Control()
{
@ -66,10 +67,8 @@ namespace MathNet.Numerics
_parallelizeElements = 300;
// Linear Algebra Provider
#if PORTABLE
// GetEnvironmentVariable is not available in portable!
LinearAlgebraProvider = new ManagedLinearAlgebraProvider();
#else
#if !PORTABLE
try
{
const string name = "MathNetNumericsLAProvider";
@ -81,14 +80,11 @@ namespace MathNet.Numerics
LinearAlgebraProvider = new Providers.LinearAlgebra.Mkl.MklLinearAlgebraProvider();
break;
#endif
default:
LinearAlgebraProvider = new ManagedLinearAlgebraProvider();
break;
}
}
catch
{
// We don't care about any failures here at all
// We don't care about any failures here at all (because "auto")
LinearAlgebraProvider = new ManagedLinearAlgebraProvider();
}
#endif
@ -135,10 +131,20 @@ namespace MathNet.Numerics
public static bool DisableParallelization { get; set; }
/// <summary>
/// Gets or sets the linear algebra provider.
/// Gets or sets the linear algebra provider. Consider to use UseNativeMKL or UseManaged instead.
/// </summary>
/// <value>The linear algebra provider.</value>
public static ILinearAlgebraProvider LinearAlgebraProvider { get; set; }
public static ILinearAlgebraProvider LinearAlgebraProvider
{
get { return _linearAlgebraProvider; }
set
{
value.InitializeVerify();
// only actually set if verification did not throw
_linearAlgebraProvider = value;
}
}
/// <summary>
/// Gets or sets a value indicating how many parallel worker threads shall be used

3
src/Numerics/Numerics.csproj

@ -153,9 +153,10 @@
<Compile Include="Providers\LinearAlgebra\GotoBlas\SafeNativeMethods.cs" />
<Compile Include="Providers\LinearAlgebra\ManagedLinearAlgebraProvider.Complex32.cs" />
<Compile Include="Providers\LinearAlgebra\ManagedLinearAlgebraProvider.Complex.cs" />
<Compile Include="Providers\LinearAlgebra\ManagedLinearAlgebraProvider.Double.cs" />
<Compile Include="Providers\LinearAlgebra\ManagedLinearAlgebraProvider.Single.cs" />
<Compile Include="Providers\LinearAlgebra\ILinearAlgebraProvider.cs" />
<Compile Include="Providers\LinearAlgebra\ManagedLinearAlgebraProvider.Double.cs" />
<Compile Include="Providers\LinearAlgebra\ManagedLinearAlgebraProvider.cs" />
<Compile Include="Providers\LinearAlgebra\Mkl\MklLinearAlgebraProvider.Complex.cs" />
<Compile Include="Providers\LinearAlgebra\Mkl\MklLinearAlgebraProvider.Complex32.cs" />
<Compile Include="Providers\LinearAlgebra\Mkl\MklLinearAlgebraProvider.cs" />

4
src/Numerics/Providers/LinearAlgebra/ILinearAlgebraProvider.cs

@ -94,6 +94,10 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
ILinearAlgebraProvider<Complex>,
ILinearAlgebraProvider<Complex32>
{
/// <summary>
/// Initialize and verify that the provided is indeed available. If not, fall back to alernatives like the managed provider
/// </summary>
void InitializeVerify();
}
/// <summary>

2
src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs

@ -28,11 +28,11 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using System;
using MathNet.Numerics.LinearAlgebra.Complex.Factorization;
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Threading;
using System;
namespace MathNet.Numerics.Providers.LinearAlgebra
{

2
src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs

@ -28,12 +28,12 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using System;
using MathNet.Numerics.LinearAlgebra.Complex32;
using MathNet.Numerics.LinearAlgebra.Complex32.Factorization;
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Threading;
using System;
namespace MathNet.Numerics.Providers.LinearAlgebra
{

4
src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Double.cs

@ -28,10 +28,10 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using System;
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Threading;
using System;
namespace MathNet.Numerics.Providers.LinearAlgebra
{
@ -43,7 +43,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra
/// <summary>
/// The managed linear algebra provider.
/// </summary>
public partial class ManagedLinearAlgebraProvider : ILinearAlgebraProvider
public partial class ManagedLinearAlgebraProvider
{
/// <summary>
/// Adds a scaled vector to another: <c>result = y + alpha*x</c>.

2
src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.Single.cs

@ -28,10 +28,10 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using System;
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Threading;
using System;
namespace MathNet.Numerics.Providers.LinearAlgebra
{

50
src/Numerics/Providers/LinearAlgebra/ManagedLinearAlgebraProvider.cs

@ -0,0 +1,50 @@
// <copyright file="ManagedLinearAlgebraProvider.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
// Copyright (c) 2009-2013 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
namespace MathNet.Numerics.Providers.LinearAlgebra
{
/// <summary>
/// The managed linear algebra provider.
/// </summary>
public partial class ManagedLinearAlgebraProvider : ILinearAlgebraProvider
{
/// <summary>
/// Initialize and verify that the provided is indeed available. If not, fall back to alernatives like the managed provider
/// </summary>
public virtual void InitializeVerify()
{
}
public override string ToString()
{
return "Managed";
}
}
}

4
src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex.cs

@ -30,11 +30,11 @@
#if NATIVEMKL
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using System;
using System.Numerics;
using System.Security;
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
{

4
src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex32.cs

@ -30,10 +30,10 @@
#if NATIVEMKL
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using System;
using System.Security;
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
{

4
src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Single.cs

@ -30,11 +30,11 @@
#if NATIVEMKL
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using System;
using System.Numerics;
using System.Security;
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
{

15
src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs

@ -45,6 +45,21 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
SafeNativeMethods.SetImprovedConsistency();
}
}
/// <summary>
/// Initialize and verify that the provided is indeed available. If not, fall back to alernatives like the managed provider
/// </summary>
public override void InitializeVerify()
{
// TODO: Choose x86 or x64 based on Environment.Is64BitProcess
// TODO: call into MKL to verify
}
public override string ToString()
{
// TODO: query version and platform and add to string
return "Intel MKL";
}
}
}

4
src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.double.cs

@ -30,11 +30,11 @@
#if NATIVEMKL
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using System;
using System.Numerics;
using System.Security;
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
{

Loading…
Cancel
Save