예제 #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>
 /// Tries to get the Cuda architecture for the given major and minor versions.
 /// </summary>
 /// <param name="major">The major version.</param>
 /// <param name="minor">The minor version.</param>
 /// <param name="architecture">The determined architecture (if any).</param>
 /// <returns>True, if the architecture is supported.</returns>
 public static bool TryGetArchitecture(
     int major,
     int minor,
     out CudaArchitecture architecture)
 {
     architecture = new CudaArchitecture(major, minor);
     return(architecture >= CudaArchitecture.SM_30);
 }