/// <summary>
        /// Initialize and verify that the provided is indeed available.
        /// If not, fall back to alternatives like the managed provider
        /// </summary>
        public override void InitializeVerify()
        {
            OpenBlasProvider.Load(minRevision: 1);

            int linearAlgebra = SafeNativeMethods.query_capability((int)ProviderCapability.LinearAlgebraMajor);

            // we only support exactly one major version, since major version changes imply a breaking change.
            if (linearAlgebra != 1)
            {
                throw new NotSupportedException(string.Format("OpenBLAS Native Provider not compatible. Expecting linear algebra v1 but provider implements v{0}.", linearAlgebra));
            }
        }
Exemple #2
0
        /// <summary>
        /// Initialize and verify that the provided is indeed available.
        /// If not, fall back to alternatives like the managed provider
        /// </summary>
        public override void InitializeVerify()
        {
            int revision = OpenBlasProvider.Load(hintPath: _hintPath);

            if (revision < MinimumCompatibleRevision)
            {
                throw new NotSupportedException(FormattableString.Invariant($"OpenBLAS Native Provider revision r{revision} is too old. Consider upgrading to a newer version. Revision r{MinimumCompatibleRevision} and newer are supported."));
            }

            int linearAlgebra = SafeNativeMethods.query_capability((int)ProviderCapability.LinearAlgebraMajor);

            // we only support exactly one major version, since major version changes imply a breaking change.
            if (linearAlgebra != 1)
            {
                throw new NotSupportedException(FormattableString.Invariant($"OpenBLAS Native Provider not compatible. Expecting linear algebra v1 but provider implements v{linearAlgebra}."));
            }
        }
Exemple #3
0
        public override void InitializeVerify()
        {
            int a, b, linearAlgebra;

            try
            {
                // Load the native library
                NativeProviderLoader.TryLoad(SafeNativeMethods.DllName);

                a = SafeNativeMethods.query_capability(0);
                b = SafeNativeMethods.query_capability(1);

                _nativeIX86 = SafeNativeMethods.query_capability((int)ProviderPlatform.x86) > 0;
                _nativeX64  = SafeNativeMethods.query_capability((int)ProviderPlatform.x64) > 0;
                _nativeIA64 = SafeNativeMethods.query_capability((int)ProviderPlatform.ia64) > 0;
                _nativeARM  = SafeNativeMethods.query_capability((int)ProviderPlatform.arm) > 0;

                _nativeRevision = SafeNativeMethods.query_capability((int)ProviderConfig.Revision);
                linearAlgebra   = SafeNativeMethods.query_capability((int)ProviderCapability.LinearAlgebra);
            }
            catch (DllNotFoundException e)
            {
                throw new NotSupportedException("OpenBLAS Native Provider not found.", e);
            }
            catch (BadImageFormatException e)
            {
                throw new NotSupportedException("OpenBLAS Native Provider found but failed to load. Please verify that the platform matches (x64 vs x32, Windows vs Linux).", e);
            }
            catch (EntryPointNotFoundException e)
            {
                throw new NotSupportedException("OpenBLAS Native Provider does not support capability querying and is therefore not compatible. Consider upgrading to a newer version.", e);
            }

            if (a != 0 || b != -1 || linearAlgebra <= 0 || _nativeRevision < 1)
            {
                throw new NotSupportedException("OpenBLAS Native Provider too old or not compatible. Consider upgrading to a newer version.");
            }

            // set threading settings, if supported
            if (SafeNativeMethods.query_capability((int)ProviderConfig.Threading) > 0)
            {
                SafeNativeMethods.set_max_threads(Control.MaxDegreeOfParallelism);
            }
        }