/// <summary> /// Initialize and verify that the provided is indeed available. /// If calling this method fails, consider to fall back to alternatives like the managed provider. /// </summary> public override void InitializeVerify() { CudaProvider.Load(minRevision: 1, hintPath: _hintPath); 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("Cuda Native Provider not compatible. Expecting linear algebra v1 but provider implements v{0}.", linearAlgebra)); } BLAS(SafeNativeMethods.createBLASHandle(ref _blasHandle)); Solver(SafeNativeMethods.createSolverHandle(ref _solverHandle)); }
/// <summary> /// Initialize and verify that the provided is indeed available. /// If calling this method fails, consider to fall back to alternatives like the managed provider. /// </summary> public override void InitializeVerify() { int revision = CudaProvider.Load(hintPath: _hintPath); if (revision < MinimumCompatibleRevision) { throw new NotSupportedException($"Cuda 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(string.Format("Cuda Native Provider not compatible. Expecting linear algebra v1 but provider implements v{0}.", linearAlgebra)); } BLAS(SafeNativeMethods.createBLASHandle(ref _blasHandle)); Solver(SafeNativeMethods.createSolverHandle(ref _solverHandle)); }
/// <summary> /// Initialize and verify that the provided is indeed available. /// If calling this method fails, consider to fall back to alternatives like the managed provider. /// </summary> 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(8) > 0; _nativeX64 = SafeNativeMethods.query_capability(9) > 0; _nativeIA64 = SafeNativeMethods.query_capability(10) > 0; _nativeRevision = SafeNativeMethods.query_capability(64); linearAlgebra = SafeNativeMethods.query_capability(128); } catch (DllNotFoundException e) { throw new NotSupportedException("Cuda Native Provider not found.", e); } catch (BadImageFormatException e) { throw new NotSupportedException("Cuda 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("Cuda 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("Cuda Native Provider too old or not compatible. Consider upgrading to a newer version."); } BLAS(SafeNativeMethods.createBLASHandle(ref _blasHandle)); Solver(SafeNativeMethods.createSolverHandle(ref _solverHandle)); }