/// <summary> /// Resolves a PTX code generator for the given math-function configuration. /// </summary> /// <param name="minArchitecture">The target/minimum architecture.</param> /// <returns>The resolved intrinsic representation.</returns> private static PTXIntrinsic GetMathCodeGeneratorIntrinsic( CudaArchitecture minArchitecture) => new PTXIntrinsic( PTXMathType, nameof(PTXMath.GenerateMathIntrinsic), IntrinsicImplementationMode.GenerateCode, minArchitecture);
/// <summary> /// Constructs a new PTX intrinsic that can handle all architectures /// newer or equal to <paramref name="minArchitecture"/>. /// </summary> /// <param name="handlerType">The associated target handler type.</param> /// <param name="mode">The code-generation mode.</param> /// <param name="minArchitecture">The target/minimum architecture.</param> public PTXIntrinsic( Type handlerType, IntrinsicImplementationMode mode, CudaArchitecture minArchitecture) : this(handlerType, mode) { MinArchitecture = minArchitecture; }
/// <summary> /// Creates a new PTX intrinsic. /// </summary> /// <param name="name">The name of the intrinsic.</param> /// <param name="mode">The implementation mode.</param> /// <param name="minArchitecture">The minimum architecture.</param> /// <param name="maxArchitecture">The maximum architecture.</param> /// <returns>The created intrinsic.</returns> private static PTXIntrinsic CreateIntrinsic( string name, IntrinsicImplementationMode mode, CudaArchitecture?minArchitecture, CudaArchitecture maxArchitecture) => new PTXIntrinsic( PTXIntrinsicsType, name, mode, minArchitecture, maxArchitecture);
/// <summary> /// Resolves the minimum CUDA driver version for the PTX architecture /// </summary> /// <param name="architecture">The PTX architecture</param> /// <returns>The minimum driver version</returns> public static CudaDriverVersion GetMinimumDriverVersion( CudaArchitecture architecture) { if (ArchitectureLookup.TryGetValue(architecture, out var result)) { return(result); } // If the architecture is unknown, return the highest driver version that // we support. The user should already have a driver version higher than // this, because they are most likely using a brand new graphics card. return(ArchitectureLookup.OrderByDescending(x => x.Key).First().Value); }
/// <summary> /// Constructs a new PTX intrinsic. /// </summary> /// <param name="handlerType">The associated target handler type.</param> /// <param name="methodName">The target method name (or null).</param> /// <param name="mode">The code-generator mode.</param> /// <param name="minArchitecture">The target/minimum architecture.</param> public PTXIntrinsic( Type handlerType, string methodName, IntrinsicImplementationMode mode, CudaArchitecture minArchitecture) : base( BackendType.PTX, handlerType, methodName, mode) { MinArchitecture = minArchitecture; }
/// <summary> /// Constructs a new Cuda backend. /// </summary> /// <param name="context">The context to use.</param> /// <param name="capabilities">The supported capabilities.</param> /// <param name="architecture">The target GPU architecture.</param> /// <param name="instructionSet">The target GPU instruction set.</param> /// <param name="nvvmAPI">Optional NVVM API instance.</param> public PTXBackend( Context context, CudaCapabilityContext capabilities, CudaArchitecture architecture, CudaInstructionSet instructionSet, NvvmAPI nvvmAPI) : base( context, capabilities, BackendType.PTX, new PTXArgumentMapper(context)) { Architecture = architecture; InstructionSet = instructionSet; NvvmAPI = nvvmAPI; InitIntrinsicProvider(); InitializeKernelTransformers(builder => { var transformerBuilder = Transformer.CreateBuilder( TransformerConfiguration.Empty); transformerBuilder.AddBackendOptimizations <CodePlacement.GroupOperands>( new PTXAcceleratorSpecializer( PointerType, Context.Properties.EnableAssertions, Context.Properties.EnableIOOperations), context.Properties.InliningMode, context.Properties.OptimizationLevel); if (Context.Properties.GetPTXBackendMode() == PTXBackendMode.Enhanced) { // Create an optimized PTX assembler block schedule transformerBuilder.Add(new PTXBlockScheduling()); transformerBuilder.Add(new DeadCodeElimination()); } builder.Add(transformerBuilder.ToTransformer()); }); }