Ejemplo n.º 1
0
    def __call__(self, definition_ir, options):
        implementation_ir = gt_ir.StencilImplementation(
            name=definition_ir.name,
            api_signature=[],
            domain=definition_ir.domain,
            fields={},
            parameters={},
            multi_stages=[],
            fields_extents={},
            unreferenced=[],
            axis_splitters_var=None,
            externals=definition_ir.externals,
            sources=definition_ir.sources,
            docstring=definition_ir.docstring,
        )
        self.transform_data = TransformData(
            definition_ir=definition_ir,
            implementation_ir=implementation_ir,
            options=options)

        # Initialize auxiliary data
        InitInfoPass.apply(self.transform_data)

        # Turn compute units into atomic execution units
        NormalizeBlocksPass.apply(self.transform_data)

        # Compute stage extents
        ComputeExtentsPass.apply(self.transform_data)

        # Remove HorizontalIf statements that do not have an effect
        RemoveUnreachedStatementsPass.apply(self.transform_data)

        # Merge compatible blocks
        MergeBlocksPass.apply(self.transform_data)

        # Compute used symbols
        ComputeUsedSymbolsPass.apply(self.transform_data)

        # Build IIR
        BuildIIRPass.apply(self.transform_data)

        # Fill in missing dtypes
        DataTypePass.apply(self.transform_data)

        # turn temporary fields that are only written and read within the same function
        # into local scalars
        DemoteLocalTemporariesToVariablesPass.apply(self.transform_data)

        # Replace temporary fields only assigned to scalar literals with the actual values
        ConstantFoldingPass.apply(self.transform_data)

        # prune some stages that don't have effect
        HousekeepingPass.apply(self.transform_data)

        if options.build_info is not None:
            options.build_info["def_ir"] = self.transform_data.definition_ir
            options.build_info["iir"] = self.transform_data.implementation_ir
            options.build_info["symbol_info"] = self.transform_data.symbols

        return self.transform_data.implementation_ir
Ejemplo n.º 2
0
    def __call__(self, definition_ir, options):
        implementation_ir = gt_ir.StencilImplementation(
            name=definition_ir.name,
            api_signature=[],
            domain=definition_ir.domain,
            fields={},
            parameters={},
            multi_stages=[],
            fields_extents={},
            unreferenced=[],
            axis_splitters_var=None,
            externals=definition_ir.externals,
            sources=definition_ir.sources,
            docstring=definition_ir.docstring,
        )
        self.transform_data = TransformData(
            definition_ir=definition_ir,
            implementation_ir=implementation_ir,
            options=options)

        # Initialize auxiliary data
        init_pass = InitInfoPass()
        init_pass.apply(self.transform_data)

        # Turn compute units into atomic execution units
        normalize_blocks_pass = NormalizeBlocksPass()
        normalize_blocks_pass.apply(self.transform_data)

        # Compute stage extents
        compute_extent_pass = ComputeExtentsPass()
        compute_extent_pass.apply(self.transform_data)

        # Merge compatible blocks
        merge_blocks_pass = MergeBlocksPass()
        merge_blocks_pass.apply(self.transform_data)

        # Compute used symbols
        compute_used_symbols_pass = ComputeUsedSymbolsPass()
        compute_used_symbols_pass.apply(self.transform_data)

        # Build IIR
        build_iir_pass = BuildIIRPass()
        build_iir_pass.apply(self.transform_data)

        # Fill in missing dtypes
        data_type_pass = DataTypePass()
        data_type_pass.apply(self.transform_data)

        if options.build_info is not None:
            options.build_info["def_ir"] = self.transform_data.definition_ir
            options.build_info["iir"] = self.transform_data.implementation_ir
            options.build_info["symbol_info"] = self.transform_data.symbols

        return self.transform_data.implementation_ir
Ejemplo n.º 3
0
    def __call__(self, definition_ir, options):
        implementation_ir = gt_ir.StencilImplementation(
            name=definition_ir.name,
            api_signature=[],
            domain=definition_ir.domain,
            fields={},
            parameters={},
            multi_stages=[],
            fields_extents={},
            unreferenced=[],
            axis_splitters_var=None,
            externals=definition_ir.externals,
            sources=definition_ir.sources,
            docstring=definition_ir.docstring,
        )
        self.transform_data = TransformData(
            definition_ir=definition_ir,
            implementation_ir=implementation_ir,
            options=options)

        # Initialize auxiliary data
        init_pass = InitInfoPass()
        init_pass.apply(self.transform_data)

        # Turn compute units into atomic execution units
        normalize_blocks_pass = NormalizeBlocksPass()
        normalize_blocks_pass.apply(self.transform_data)

        # Compute stage extents
        compute_extent_pass = ComputeExtentsPass()
        compute_extent_pass.apply(self.transform_data)

        # Merge compatible blocks
        merge_blocks_pass = MergeBlocksPass()
        merge_blocks_pass.apply(self.transform_data)

        # Compute used symbols
        compute_used_symbols_pass = ComputeUsedSymbolsPass()
        compute_used_symbols_pass.apply(self.transform_data)

        # Build IIR
        build_iir_pass = BuildIIRPass()
        build_iir_pass.apply(self.transform_data)

        # Fill in missing dtypes
        data_type_pass = DataTypePass()
        data_type_pass.apply(self.transform_data)

        # turn temporary fields that are only written and read within the same function
        # into local scalars
        demote_local_temporaries_to_variables_pass = DemoteLocalTemporariesToVariablesPass(
        )
        demote_local_temporaries_to_variables_pass.apply(self.transform_data)

        # prune some stages that don't have effect
        housekeeping_pass = HousekeepingPass()
        housekeeping_pass.apply(self.transform_data)

        if options.build_info is not None:
            options.build_info["def_ir"] = self.transform_data.definition_ir
            options.build_info["iir"] = self.transform_data.implementation_ir
            options.build_info["symbol_info"] = self.transform_data.symbols

        return self.transform_data.implementation_ir