Skip to content

Commit

Permalink
Loki_transform: Remove obsolete "ecphys" entry point
Browse files Browse the repository at this point in the history
  • Loading branch information
mlange05 committed Sep 6, 2023
1 parent fcdf195 commit d2b4e23
Showing 1 changed file with 0 additions and 119 deletions.
119 changes: 0 additions & 119 deletions scripts/loki_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,124 +384,5 @@ def plan(mode, config, header, source, build, root, cpp, directive, frontend, ca
scheduler.callgraph(callgraph)


@cli.command('ecphys')
@click.option('--mode', '-m', default='sca',
type=click.Choice(['idem', 'sca', 'claw', 'scc', 'scc-hoist']))
@click.option('--config', '-c', type=click.Path(),
help='Path to configuration file.')
@click.option('--header', '-I', type=click.Path(), multiple=True,
help='Path for additional header file(s).')
@click.option('--source', '-s', type=click.Path(), multiple=True,
help='Path to source files to transform.')
@click.option('--build', '-b', type=click.Path(), default=None,
help='Path to build directory for source generation.')
@click.option('--directive', default='openacc', type=click.Choice(['openacc', 'openmp', 'none']),
help='Programming model directives to insert (default openacc)')
@click.option('--cpp/--no-cpp', default=False,
help='Trigger C-preprocessing of source files.')
@click.option('--frontend', default='fp', type=click.Choice(['ofp', 'omni', 'fp']),
help='Frontend parser to use (default FP)')
def ecphys(mode, config, header, source, build, cpp, directive, frontend):
"""
Physics bulk-processing option that employs a :class:`Scheduler`
to apply IFS-specific source-to-source transformations, such as
the SCC ("Single Column Coalesced") transformations, to large sets
of interdependent subroutines.
"""

info('[Loki] Bulk-processing physics using config: %s ', config)
config = SchedulerConfig.from_file(config)

directive = None if directive.lower() == 'none' else directive.lower()

frontend = Frontend[frontend.upper()]
frontend_type = Frontend.OFP if frontend == Frontend.OMNI else frontend

headers = [Sourcefile.from_file(filename=h, frontend=frontend_type) for h in header]
definitions = flatten(h.modules for h in headers)

# Create and setup the scheduler for bulk-processing
paths = [Path(s).resolve() for s in source]
paths += [Path(h).resolve().parent for h in header]
scheduler = Scheduler(
paths=paths, config=config, definitions=definitions,
frontend=frontend, preprocess=cpp
)

# Pick the model dimensions out of the config file
horizontal = scheduler.config.dimensions.get('horizontal', None)
vertical = scheduler.config.dimensions.get('vertical', None)
block_dim = scheduler.config.dimensions.get('block_dim', None)

# Backward insert argument shapes (for surface routines)
scheduler.process(transformation=ArgumentArrayShapeAnalysis())

scheduler.process(transformation=ExplicitArgumentArrayShapeTransformation(), reverse=True)

# Remove DR_HOOK and other utility calls first, so they don't interfere with SCC loop hoisting
if 'scc' in mode:
utility_call_trafo = RemoveCallsTransformation(
routines=['DR_HOOK', 'ABOR1', 'WRITE(NULOUT'], include_intrinsics=True, kernel_only=True
)
else:
utility_call_trafo = DrHookTransformation(mode=mode, remove=False)
scheduler.process(transformation=utility_call_trafo)

# Instantiate transformation pipeline and apply the main changes
transformation = None
if mode == 'idem':
transformation = IdemTransformation()

if mode == 'sca':
# Define the target dimension to strip from kernel and caller
transformation = ExtractSCATransformation(horizontal=horizontal)

if mode in ['scc', 'scc-hoist']:
# Compose the main SCC transformation from core components based on config
transformation = (
SCCBaseTransformation(horizontal=horizontal, directive=directive),
)

# Devectorise the single-column kernels by removing the horizotnal vector loops
transformation += (
SCCDevectorTransformation(horizontal=horizontal, trim_vector_sections=False),
)

# Demote vector temporaries to scalars where possible
transformation += (SCCDemoteTransformation(horizontal=horizontal),)

# Either hoist the vector loops to the driver or re-vectorise the kernels
if 'hoist' in mode:
transformation += (
SCCHoistTransformation(horizontal=horizontal, vertical=vertical, block_dim=block_dim),
)
else:
transformation += (SCCRevectorTransformation(horizontal=horizontal),)

# Add offload annotations depending on the desired programming model directives
transformation += (
SCCAnnotateTransformation(
horizontal=horizontal, vertical=vertical, directive=directive,
block_dim=block_dim, hoist_column_arrays='hoist' in mode
),
)

if transformation:
# Apply the set of trnasformations over the full depency tree in turn
for transform in as_tuple(transformation):
scheduler.process(transformation=transform)
else:
raise RuntimeError('[Loki] Convert could not find specified Transformation!')

# Apply the dependency-injection transformation
dependency = DependencyTransformation(
mode='module', module_suffix='_MOD', suffix=f'_{mode.upper()}'
)
scheduler.process(transformation=dependency)

# Write out all modified source files into the build directory
scheduler.process(transformation=FileWriteTransformation(builddir=build, mode=mode))


if __name__ == "__main__":
cli() # pylint: disable=no-value-for-parameter

0 comments on commit d2b4e23

Please sign in to comment.