Пример #1
0
        /// <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());
            });
        }
Пример #2
0
 /// <summary>
 /// Resolves the minimum CUDA driver version for the PTX instruction set
 /// </summary>
 /// <param name="instructionSet">The PTX instruction set</param>
 /// <returns>The minimum driver version</returns>
 public static CudaDriverVersion GetMinimumDriverVersion(
     CudaInstructionSet instructionSet) =>
 InstructionSetLookup.TryGetValue(instructionSet, out var result)
     ? result
     : throw new NotSupportedException(
           RuntimeErrorMessages.NotSupportedPTXInstructionSet);