Intel's Math Kernel Library (MKL) linear algebra provider.
Example #1
0
 public static void UseNativeMKL(
     Providers.LinearAlgebra.Mkl.MklConsistency consistency = Providers.LinearAlgebra.Mkl.MklConsistency.Auto,
     Providers.LinearAlgebra.Mkl.MklPrecision precision     = Providers.LinearAlgebra.Mkl.MklPrecision.Double,
     Providers.LinearAlgebra.Mkl.MklAccuracy accuracy       = Providers.LinearAlgebra.Mkl.MklAccuracy.High)
 {
     LinearAlgebraProvider = new Providers.LinearAlgebra.Mkl.MklLinearAlgebraProvider(consistency, precision, accuracy);
 }
Example #2
0
        public static void ConfigureAuto()
        {
            // Random Numbers & Distributions
            CheckDistributionParameters      = true;
            ThreadSafeRandomNumberGenerators = true;

            // ToString & Formatting
            MaxToStringColumns = 6;
            MaxToStringRows    = 8;

            // Parallelization & Threading
            _numberOfThreads       = Environment.ProcessorCount;
            DisableParallelization = _numberOfThreads < 2;
            _blockSize             = 512;
            _parallelizeOrder      = 64;
            _parallelizeElements   = 300;

            // Linear Algebra Provider
#if PORTABLE
            // GetEnvironmentVariable is not available in portable!
            LinearAlgebraProvider = new ManagedLinearAlgebraProvider();
#else
            try
            {
                const string name  = "MathNetNumericsLAProvider";
                var          value = Environment.GetEnvironmentVariable(name);
                switch (value != null ? value.ToUpperInvariant() : string.Empty)
                {
#if NATIVEMKL
                case "MKL":
                    LinearAlgebraProvider = new Providers.LinearAlgebra.Mkl.MklLinearAlgebraProvider();
                    break;
#endif
                default:
                    LinearAlgebraProvider = new ManagedLinearAlgebraProvider();
                    break;
                }
            }
            catch
            {
                // We don't care about any failures here at all
                LinearAlgebraProvider = new ManagedLinearAlgebraProvider();
            }
#endif
        }
Example #3
0
        public static void ConfigureAuto()
        {
            // Random Numbers & Distributions
            CheckDistributionParameters = true;
            ThreadSafeRandomNumberGenerators = true;

            // ToString & Formatting
            MaxToStringColumns = 6;
            MaxToStringRows = 8;

            // Parallelization & Threading
            _numberOfThreads = Environment.ProcessorCount;
            DisableParallelization = _numberOfThreads < 2;
            _blockSize = 512;
            _parallelizeOrder = 64;
            _parallelizeElements = 300;

            // Linear Algebra Provider
#if PORTABLE
            // GetEnvironmentVariable is not available in portable!
            LinearAlgebraProvider = new ManagedLinearAlgebraProvider();
#else
            try
            {
                const string name = "MathNetNumericsLAProvider";
                var value = Environment.GetEnvironmentVariable(name);
                switch (value != null ? value.ToUpperInvariant() : string.Empty)
                {
#if NATIVEMKL
                    case "MKL":
                        LinearAlgebraProvider = new Providers.LinearAlgebra.Mkl.MklLinearAlgebraProvider();
                        break;
#endif
                    default:
                        LinearAlgebraProvider = new ManagedLinearAlgebraProvider();
                        break;
                }
            }
            catch
            {
                // We don't care about any failures here at all
                LinearAlgebraProvider = new ManagedLinearAlgebraProvider();
            }
#endif
        }
Example #4
0
        public static void ConfigureAuto()
        {
            // Random Numbers & Distributions
            CheckDistributionParameters = true;

            // Parallelization & Threading
            ThreadSafeRandomNumberGenerators = true;
            _maxDegreeOfParallelism          = Environment.ProcessorCount;
            _blockSize           = 512;
            _parallelizeOrder    = 64;
            _parallelizeElements = 300;
            TaskScheduler        = TaskScheduler.Default;

            // Linear Algebra Provider
#if PORTABLE
            LinearAlgebraProvider = new ManagedLinearAlgebraProvider();
#else
            try
            {
                const string name  = "MathNetNumericsLAProvider";
                var          value = Environment.GetEnvironmentVariable(name);
                switch (value != null ? value.ToUpperInvariant() : string.Empty)
                {
#if NATIVE
                case "MKL":
                    LinearAlgebraProvider = new Providers.LinearAlgebra.Mkl.MklLinearAlgebraProvider();
                    break;

                case "CUDA":
                    LinearAlgebraProvider = new Providers.LinearAlgebra.Cuda.CudaLinearAlgebraProvider();
                    break;
#endif
                default:
                    LinearAlgebraProvider = new ManagedLinearAlgebraProvider();
                    break;
                }
            }
            catch
            {
                // We don't care about any failures here at all (because "auto")
                LinearAlgebraProvider = new ManagedLinearAlgebraProvider();
            }
#endif
        }
        public void MklProvider()
        {
            MklLinearAlgebraProvider provider = new MklLinearAlgebraProvider();

            var formatProvider = (CultureInfo)CultureInfo.InvariantCulture.Clone();
            formatProvider.TextInfo.ListSeparator = " ";

            var matrix = _matrices["identity"];
            var a = new Complex32[matrix.RowCount * matrix.RowCount];
            Array.Copy(matrix.Values, a, a.Length);

            var tau = new Complex32[matrix.ColumnCount];
            var q = new Complex32[matrix.ColumnCount * matrix.ColumnCount];
            provider.QRFactor(a, matrix.RowCount, matrix.ColumnCount, q, tau);

            var b = new[] { Complex32.One, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f };
            var x = new Complex32[matrix.ColumnCount * 2];
            provider.QRSolveFactored(q, a, matrix.RowCount, matrix.ColumnCount, tau, b, 2, x);
        }
Example #6
0
        public static void ConfigureAuto()
        {
            // Random Numbers & Distributions
            CheckDistributionParameters = true;

            // Parallelization & Threading
            ThreadSafeRandomNumberGenerators = true;
            _maxDegreeOfParallelism = Environment.ProcessorCount;
            _blockSize = 512;
            _parallelizeOrder = 64;
            _parallelizeElements = 300;
            TaskScheduler = TaskScheduler.Default;

            // Linear Algebra Provider
#if PORTABLE
            LinearAlgebraProvider = new ManagedLinearAlgebraProvider();
#else
            try
            {
                const string name = "MathNetNumericsLAProvider";
                var value = Environment.GetEnvironmentVariable(name);
                switch (value != null ? value.ToUpperInvariant() : string.Empty)
                {
#if NATIVE
                    case "MKL":
                        LinearAlgebraProvider = new Providers.LinearAlgebra.Mkl.MklLinearAlgebraProvider();
                        break;
#endif
                    default:
                        LinearAlgebraProvider = new ManagedLinearAlgebraProvider();
                        break;
                }
            }
            catch
            {
                // We don't care about any failures here at all (because "auto")
                LinearAlgebraProvider = new ManagedLinearAlgebraProvider();
            }
#endif
        }
Example #7
0
 public static void UseNativeMKL()
 {
     LinearAlgebraProvider = new Providers.LinearAlgebra.Mkl.MklLinearAlgebraProvider();
 }
Example #8
0
 public static void UseNativeMKL(
     Providers.LinearAlgebra.Mkl.MklConsistency consistency = Providers.LinearAlgebra.Mkl.MklConsistency.Auto,
     Providers.LinearAlgebra.Mkl.MklPrecision precision = Providers.LinearAlgebra.Mkl.MklPrecision.Double,
     Providers.LinearAlgebra.Mkl.MklAccuracy accuracy = Providers.LinearAlgebra.Mkl.MklAccuracy.High)
 {
     LinearAlgebraProvider = new Providers.LinearAlgebra.Mkl.MklLinearAlgebraProvider(consistency, precision, accuracy);
 }
Example #9
0
 public static void UseNativeMKL()
 {
     LinearAlgebraProvider = new Providers.LinearAlgebra.Mkl.MklLinearAlgebraProvider();
 }