Esempio n. 1
0
 def __call__(self, definition_ir) -> Dict[str, Dict[str, str]]:
     gtir = GtirPipeline(DefIRToGTIR.apply(definition_ir)).full()
     base_oir = gtir_to_oir.GTIRToOIR().visit(gtir)
     oir_pipeline = self.backend.builder.options.backend_opts.get(
         "oir_pipeline", DefaultPipeline(skip=[NoFieldAccessPruning]))
     oir = oir_pipeline.run(base_oir)
     cuir = oir_to_cuir.OIRToCUIR().visit(oir)
     cuir = kernel_fusion.FuseKernels().visit(cuir)
     cuir = extent_analysis.ComputeExtents().visit(cuir)
     cuir = extent_analysis.CacheExtents().visit(cuir)
     format_source = self.backend.builder.options.format_source
     implementation = cuir_codegen.CUIRCodegen.apply(
         cuir, format_source=format_source)
     bindings = GTCCudaBindingsCodegen.apply(cuir,
                                             module_name=self.module_name,
                                             backend=self.backend,
                                             format_source=format_source)
     return {
         "computation": {
             "computation.hpp": implementation
         },
         "bindings": {
             "bindings.cu": bindings
         },
     }
Esempio n. 2
0
def test_compute_extents_with_multiple_loops():
    testee = ProgramFactory(
        kernels__0__vertical_loops=[
            VerticalLoopFactory(
                sections__0__horizontal_executions=[
                    HorizontalExecutionFactory(
                        body=[AssignStmtFactory(right__name="tmp", right__offset__i=1)],
                        extent=None,
                    ),
                ],
            ),
            VerticalLoopFactory(
                sections__0__horizontal_executions=[
                    HorizontalExecutionFactory(
                        body=[
                            AssignStmtFactory(
                                left__name="tmp",
                            )
                        ],
                        extent=None,
                    ),
                ]
            ),
        ],
        params=[TemporaryFactory(name="tmp")],
    )
    transformed = extent_analysis.ComputeExtents().visit(testee)
    hexecs = transformed.iter_tree().if_isinstance(cuir.HorizontalExecution).to_list()
    assert hexecs[0].extent.i == (0, 0)
    assert hexecs[0].extent.j == (0, 0)
    assert hexecs[1].extent.i == (0, 0)
    assert hexecs[1].extent.j == (0, 0)
Esempio n. 3
0
 def __call__(self, definition_ir) -> Dict[str, Dict[str, str]]:
     gtir = DefIRToGTIR.apply(definition_ir)
     gtir_without_unused_params = prune_unused_parameters(gtir)
     dtype_deduced = resolve_dtype(gtir_without_unused_params)
     upcasted = upcast(dtype_deduced)
     oir = gtir_to_oir.GTIRToOIR().visit(upcasted)
     oir = self._optimize_oir(oir)
     cuir = oir_to_cuir.OIRToCUIR().visit(oir)
     cuir = kernel_fusion.FuseKernels().visit(cuir)
     cuir = extent_analysis.ComputeExtents().visit(cuir)
     cuir = extent_analysis.CacheExtents().visit(cuir)
     implementation = cuir_codegen.CUIRCodegen.apply(cuir)
     bindings = GTCCudaBindingsCodegen.apply(cuir, module_name=self.module_name)
     return {
         "computation": {"computation.hpp": implementation},
         "bindings": {"bindings.cu": bindings},
     }
Esempio n. 4
0
 def __call__(self, definition_ir) -> Dict[str, Dict[str, str]]:
     gtir = GtirPipeline(DefIRToGTIR.apply(definition_ir)).full()
     oir = OirPipeline(gtir_to_oir.GTIRToOIR().visit(gtir)).full(
         skip=[NoFieldAccessPruning])
     cuir = oir_to_cuir.OIRToCUIR().visit(oir)
     cuir = kernel_fusion.FuseKernels().visit(cuir)
     cuir = extent_analysis.ComputeExtents().visit(cuir)
     cuir = extent_analysis.CacheExtents().visit(cuir)
     implementation = cuir_codegen.CUIRCodegen.apply(cuir)
     bindings = GTCCudaBindingsCodegen.apply(cuir,
                                             module_name=self.module_name,
                                             backend=self.backend)
     return {
         "computation": {
             "computation.hpp": implementation
         },
         "bindings": {
             "bindings.cu": bindings
         },
     }
Esempio n. 5
0
def test_compute_extents():
    testee = ProgramFactory(
        kernels__0__vertical_loops__0__sections__0__horizontal_executions=[
            HorizontalExecutionFactory(
                body=[AssignStmtFactory(left__name="tmp")],
                extent=None,
            ),
            HorizontalExecutionFactory(
                body=[
                    AssignStmtFactory(right__name="tmp", right__offset__i=1, right__offset__j=-3)
                ],
                extent=None,
            ),
        ],
        temporaries=[TemporaryFactory(name="tmp")],
    )
    transformed = extent_analysis.ComputeExtents().visit(testee)
    hexecs = transformed.kernels[0].vertical_loops[0].sections[0].horizontal_executions
    assert hexecs[0].extent.i == (0, 1)
    assert hexecs[0].extent.j == (-3, 0)
    assert hexecs[1].extent.i == (0, 0)
    assert hexecs[1].extent.j == (0, 0)