Exemplo n.º 1
0
 /// <summary>
 /// Constructs a new OpenCL source backend.
 /// </summary>
 /// <param name="context">The context to use.</param>
 /// <param name="platform">The target platform.</param>
 /// <param name="vendor">The associated major vendor.</param>
 public CLBackend(
     Context context,
     TargetPlatform platform,
     CLAcceleratorVendor vendor)
     : base(
         context,
         BackendType.OpenCL,
         BackendFlags.RequiresIntrinsicImplementations,
         new CLABI(context.TypeContext, platform),
         abi => new CLArgumentMapper(context, abi))
 {
     Vendor = vendor;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Constructs a new OpenCL source backend.
        /// </summary>
        /// <param name="context">The context to use.</param>
        /// <param name="platform">The target platform.</param>
        /// <param name="vendor">The associated major vendor.</param>
        public CLBackend(
            Context context,
            TargetPlatform platform,
            CLAcceleratorVendor vendor)
            : base(
                context,
                BackendType.OpenCL,
                BackendFlags.None,
                new CLABI(context.TypeContext, platform),
                abi => new CLArgumentMapper(context, abi))
        {
            Vendor = vendor;

            InitializeKernelTransformers(
                new IntrinsicSpecializerConfiguration(context.Flags),
                builder => { });
        }
Exemplo n.º 3
0
        /// <summary>
        /// Constructs a new OpenCL source backend.
        /// </summary>
        /// <param name="context">The context to use.</param>
        /// <param name="vendor">The associated major vendor.</param>
        public CLBackend(Context context, CLAcceleratorVendor vendor)
            : base(
                context,
                BackendType.OpenCL,
                BackendFlags.None,
                new CLArgumentMapper(context))
        {
            Vendor = vendor;

            InitializeKernelTransformers(
                IntrinsicSpecializerFlags.None,
                builder =>
            {
                var transformerBuilder = Transformer.CreateBuilder(
                    TransformerConfiguration.Empty);
                transformerBuilder.AddBackendOptimizations(
                    new CLAcceleratorSpecializer(),
                    context.OptimizationLevel);
                builder.Add(transformerBuilder.ToTransformer());
            });
        }
Exemplo n.º 4
0
        /// <summary>
        /// Constructs a new OpenCL source backend.
        /// </summary>
        /// <param name="context">The context to use.</param>
        /// <param name="capabilities">The supported capabilities.</param>
        /// <param name="vendor">The associated major vendor.</param>
        public CLBackend(
            Context context,
            CLCapabilityContext capabilities,
            CLAcceleratorVendor vendor)
            : base(
                context,
                capabilities,
                BackendType.OpenCL,
                BackendFlags.None,
                new CLArgumentMapper(context))
        {
            Vendor = vendor;

            InitIntrinsicProvider();
            InitializeKernelTransformers(
                IntrinsicSpecializerFlags.None,
                builder =>
            {
                var transformerBuilder = Transformer.CreateBuilder(
                    TransformerConfiguration.Empty);
                transformerBuilder.AddBackendOptimizations(
                    new CLAcceleratorSpecializer(PointerType),
                    context.Flags,
                    context.OptimizationLevel);
                builder.Add(transformerBuilder.ToTransformer());
            });

            // Build a list of extensions to enable for each OpenCL kernel.
            var extensionBuilder = new StringBuilder();

            foreach (var extensionName in Capabilities.Extensions)
            {
                extensionBuilder.Append("#pragma OPENCL EXTENSION ");
                extensionBuilder.Append(extensionName);
                extensionBuilder.AppendLine(" : enable");
            }
            extensions = extensionBuilder.ToString();
        }