Exemplo n.º 1
0
 public static bool TryUseNativeMKL(
     MklConsistency consistency = MklConsistency.Auto,
     MklPrecision precision     = MklPrecision.Double,
     MklAccuracy accuracy       = MklAccuracy.High)
 {
     return(LinearAlgebraControl.TryUse(CreateNativeMKL(consistency, precision, accuracy)));
 }
Exemplo n.º 2
0
        /// <summary>
        /// Try to use the Intel MKL native provider for linear algebra.
        /// </summary>
        /// <returns>
        /// True if the provider was found and initialized successfully.
        /// False if it failed and the previous provider is still active.
        /// </returns>
        public static bool TryUseNativeMKL()
        {
            bool linearAlgebra    = LinearAlgebraControl.TryUseNativeMKL();
            bool fourierTransform = FourierTransformControl.TryUseNativeMKL();

            return(linearAlgebra || fourierTransform);
        }
Exemplo n.º 3
0
 public static void UseNativeMKL(
     Providers.Common.Mkl.MklConsistency consistency = Providers.Common.Mkl.MklConsistency.Auto,
     Providers.Common.Mkl.MklPrecision precision     = Providers.Common.Mkl.MklPrecision.Double,
     Providers.Common.Mkl.MklAccuracy accuracy       = Providers.Common.Mkl.MklAccuracy.High)
 {
     LinearAlgebraControl.UseNativeMKL(consistency, precision, accuracy);
     FourierTransformControl.UseNativeMKL();
 }
Exemplo n.º 4
0
        /// <summary>
        /// Try to use the Intel MKL native provider for linear algebra.
        /// </summary>
        /// <returns>
        /// True if the provider was found and initialized successfully.
        /// False if it failed and the previous provider is still active.
        /// </returns>
        public static bool TryUseNativeMKL()
        {
            bool linearAlgebra      = LinearAlgebraControl.TryUseNativeMKL();
            bool fourierTransform   = FourierTransformControl.TryUseNativeMKL();
            bool directSparseSolver = SparseSolverControl.TryUseNativeMKL();

            return(linearAlgebra || fourierTransform || directSparseSolver);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Use the best provider available.
        /// </summary>
        public static void UseBestProviders()
        {
            if (AppSwitches.DisableNativeProviders || AppSwitches.DisableNativeProviderProbing)
            {
                UseManaged();
                return;
            }

            LinearAlgebraControl.UseBest();
            FourierTransformControl.UseBest();
            SparseSolverControl.UseBest();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Try to use any available native provider in an undefined order.
        /// </summary>
        /// <returns>
        /// True if one of the native providers was found and successfully initialized.
        /// False if it failed and the previous provider is still active.
        /// </returns>
        public static bool TryUseNative()
        {
            if (AppSwitches.DisableNativeProviders || AppSwitches.DisableNativeProviderProbing)
            {
                return(false);
            }

            bool linearAlgebra      = LinearAlgebraControl.TryUseNative();
            bool fourierTransform   = FourierTransformControl.TryUseNative();
            bool directSparseSolver = SparseSolverControl.TryUseNative();

            return(linearAlgebra || fourierTransform || directSparseSolver);
        }
        public void ProviderSurvivesFreeResources()
        {
            var samples = Generate.PeriodicMap(16, w => Math.Sin(w), 16, 1.0, Constants.Pi2);

            var result1 = new double[samples.Length];

            LinearAlgebraControl.Provider.ScaleArray(2.5, samples, result1);

            LinearAlgebraControl.FreeResources();

            var result2 = new double[samples.Length];

            LinearAlgebraControl.Provider.ScaleArray(2.5, samples, result2);

            for (var i = 0; i < result1.Length; i++)
            {
                Assert.AreEqual(result1[i], result2[i]);
            }
        }
Exemplo n.º 8
0
        public DenseMatrixProduct()
        {
            foreach (var m in new[] { 8, 64, 128 })
            {
                foreach (var n in new[] { 8, 64, 128 })
                {
                    var key = Key(m, n);
                    _data[key] = Matrix <double> .Build.Random(m, n);
                }
            }

            Control.NativeProviderPath = @"..\..\..\..\out\MKL\Windows\";
            _mathnetMkl     = LinearAlgebraControl.CreateNativeMKL();
            _mathnetManaged = LinearAlgebraControl.CreateManaged();
            //_mathnetExperimental = new ManagedLinearAlgebraProvider(Variation.Experimental);

            _mathnetMkl.InitializeVerify();
            _mathnetManaged.InitializeVerify();
            //_mathnetExperimental.InitializeVerify();
        }
Exemplo n.º 9
0
 public static void UseManagedReference()
 {
     LinearAlgebraControl.UseManagedReference();
     FourierTransformControl.UseManaged();
 }
Exemplo n.º 10
0
 /// <summary>
 /// Use the Intel MKL native provider for linear algebra.
 /// Throws if it is not available or failed to initialize, in which case the previous provider is still active.
 /// </summary>
 public static void UseNativeMKL()
 {
     LinearAlgebraControl.UseNativeMKL();
     FourierTransformControl.UseNativeMKL();
 }
Exemplo n.º 11
0
 public static void UseManaged()
 {
     LinearAlgebraControl.UseManaged();
     FourierTransformControl.UseManaged();
     SparseSolverControl.UseManaged();
 }
Exemplo n.º 12
0
 /// <summary>
 /// Use the OpenBLAS native provider for linear algebra.
 /// Throws if it is not available or failed to initialize, in which case the previous provider is still active.
 /// </summary>
 public static void UseNativeOpenBLAS()
 {
     LinearAlgebraControl.UseNativeOpenBLAS();
 }
Exemplo n.º 13
0
        /// <summary>
        /// Try to use the OpenBLAS native provider for linear algebra.
        /// </summary>
        /// <returns>
        /// True if the provider was found and initialized successfully.
        /// False if it failed and the previous provider is still active.
        /// </returns>
        public static bool TryUseNativeOpenBLAS()
        {
            bool linearAlgebra = LinearAlgebraControl.TryUseNativeOpenBLAS();

            return(linearAlgebra);
        }
Exemplo n.º 14
0
 /// <summary>
 /// Use the Nvidia CUDA native provider for linear algebra.
 /// Throws if it is not available or failed to initialize, in which case the previous provider is still active.
 /// </summary>
 public static void UseNativeCUDA()
 {
     LinearAlgebraControl.UseNativeCUDA();
 }
Exemplo n.º 15
0
 public static bool TryUseNativeOpenBLAS() => LinearAlgebraControl.TryUse(CreateNativeOpenBLAS());
Exemplo n.º 16
0
 /// <summary>
 /// Use the best provider available.
 /// </summary>
 public static void UseBestProviders()
 {
     LinearAlgebraControl.UseBest();
     FourierTransformControl.UseBest();
 }
 public static bool TryUseNativeCUDA() => LinearAlgebraControl.TryUse(CreateNativeCUDA());
Exemplo n.º 18
0
 public static void FreeResources()
 {
     LinearAlgebraControl.FreeResources();
     FourierTransformControl.FreeResources();
 }