コード例 #1
0
 /// <summary>
 /// Returns the PTX instruction set to use, based on the PTX architecture and
 /// installed Cuda drivers.
 /// </summary>
 /// <param name="architecture">The PTX architecture</param>
 /// <param name="installedDriverVersion">The Cuda driver version</param>
 /// <returns>The PTX instruction set</returns>
 public static CudaInstructionSet GetInstructionSet(
     CudaArchitecture architecture,
     CudaDriverVersion installedDriverVersion) =>
 TryGetInstructionSet(
     architecture,
     installedDriverVersion,
     out var minDriverVersion,
コード例 #2
0
        /// <summary>
        /// Tries to determine the PTX instruction set to use, based on the PTX
        /// architecture and installed Cuda drivers.
        /// </summary>
        /// <param name="architecture">The PTX architecture</param>
        /// <param name="installedDriverVersion">The Cuda driver version</param>
        /// <param name="minDriverVersion">The minimum driver version.</param>
        /// <param name="instructionSet">The instruction set (if any).</param>
        /// <returns>True, if the instruction set could be determined.</returns>
        public static bool TryGetInstructionSet(
            CudaArchitecture architecture,
            CudaDriverVersion installedDriverVersion,
            out CudaDriverVersion minDriverVersion,
            out CudaInstructionSet instructionSet)
        {
            instructionSet = default;
            var architectureMinDriverVersion = CudaDriverVersionUtils
                                               .GetMinimumDriverVersion(architecture);

            minDriverVersion = architectureMinDriverVersion;

            foreach (var supportedSet in PTXCodeGenerator.SupportedInstructionSets)
            {
                var instructionSetMinDriverVersion = CudaDriverVersionUtils.
                                                     GetMinimumDriverVersion(supportedSet);
                minDriverVersion =
                    architectureMinDriverVersion >= instructionSetMinDriverVersion
                    ? architectureMinDriverVersion
                    : instructionSetMinDriverVersion;
                if (installedDriverVersion >= minDriverVersion)
                {
                    instructionSet = supportedSet;
                    return(true);
                }
            }

            return(false);
        }
コード例 #3
0
        /// <summary>
        /// Returns the PTX instruction set to use, based on the PTX architecture and
        /// installed CUDA drivers.
        /// </summary>
        /// <param name="architecture">The PTX architecture</param>
        /// <param name="installedDriverVersion">The CUDA driver version</param>
        /// <returns>The PTX instruction set</returns>
        public static PTXInstructionSet GetInstructionSet(
            PTXArchitecture architecture,
            CudaDriverVersion installedDriverVersion)
        {
            var architectureMinDriverVersion = CudaDriverVersionUtils
                                               .GetMinimumDriverVersion(architecture);
            var minDriverVersion = architectureMinDriverVersion;

            foreach (var instructionSet in PTXCodeGenerator.SupportedInstructionSets)
            {
                var instructionSetMinDriverVersion = CudaDriverVersionUtils.
                                                     GetMinimumDriverVersion(instructionSet);
                minDriverVersion =
                    architectureMinDriverVersion >= instructionSetMinDriverVersion
                    ? architectureMinDriverVersion
                    : instructionSetMinDriverVersion;
                if (installedDriverVersion >= minDriverVersion)
                {
                    return(instructionSet);
                }
            }

            throw new NotSupportedException(
                      string.Format(
                          RuntimeErrorMessages.NotSupportedDriverVersion,
                          installedDriverVersion,
                          minDriverVersion));
        }
コード例 #4
0
        /// <summary>
        /// Resolves the current driver version.
        /// </summary>
        /// <param name="driverVersion">The resolved driver version.</param>
        /// <returns>The error status.</returns>
        public CudaError GetDriverVersion(out CudaDriverVersion driverVersion)
        {
            var error = cuDriverGetVersion(out var driverVersionValue);

            if (error != CudaError.CUDA_SUCCESS)
            {
                driverVersion = default;
                return(error);
            }
            driverVersion = CudaDriverVersion.FromValue(driverVersionValue);
            return(CudaError.CUDA_SUCCESS);
        }