Skip to content

Commit a2450db

Browse files
committed
LOKI: use configurable custom pipeline
1 parent 031bd6c commit a2450db

3 files changed

Lines changed: 172 additions & 3 deletions

File tree

src/ecwam/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,14 +504,12 @@ endif()
504504
if( HAVE_LOKI )
505505

506506
set( LOKI_FRONTEND "fp" CACHE STRING "Frontend parser for Loki source transformations" )
507-
set( SCC_ARGS "")
508507

509508
if( LOKI_MODE MATCHES "idem|idem-stack" )
510509
set( LOKI_CONFIG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/ecwam_loki.config )
511510
else()
512511
set( LOKI_CONFIG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/ecwam_loki_gpu.config )
513512
target_compile_definitions( ${ecwam} PRIVATE WAM_GPU )
514-
set( SCC_ARGS "TRIM_VECTOR_SECTIONS;GLOBAL_VAR_OFFLOAD")
515513
endif()
516514

517515
# Apply Loki source file transformation to lib target
@@ -521,7 +519,6 @@ if( HAVE_LOKI )
521519
FRONTEND ${LOKI_FRONTEND}
522520
CONFIG ${LOKI_CONFIG_FILE}
523521
PLAN ${CMAKE_CURRENT_BINARY_DIR}/loki_plan_ecwam.cmake
524-
${SCC_ARGS}
525522
CPP
526523
DEFINITIONS WAM_GPU
527524
INCLUDES ${ecwam_intfb_includes}

src/ecwam/ecwam_loki.config

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,58 @@ block = ['ec_parkind', 'parkind_wave']
3131
intrinsic_names = ['write(iu06']
3232
kernel_only = true
3333

34+
# Inline transformation
35+
[transformations.InlineTransformation]
36+
module = "loki.transformations"
37+
[transformations.InlineTransformation.options]
38+
allowed_aliases = "IJ"
39+
inline_elementals = false
40+
41+
# Split-read-write transformation
42+
[transformations.SplitReadWriteTransformation]
43+
module = "loki.transformations"
44+
[transformations.SplitReadWriteTransformation.options]
45+
dimensions = "%dimensions.horizontal%"
46+
47+
# TemporariesPoolAllocatorTransformation
48+
[transformations.TemporariesPoolAllocatorTransformation]
49+
module = "loki.transformations"
50+
[transformations.TemporariesPoolAllocatorTransformation.options]
51+
horizontal = "%dimensions.horizontal%"
52+
directive = "openmp"
53+
block_dim = "%dimensions.block_dim%"
54+
check_bounds = true
55+
56+
# ModuleWrap transformation
57+
[transformations.ModuleWrapTransformation]
58+
module = "loki.transformations"
59+
[transformations.ModuleWrapTransformation.options]
60+
module_suffix = "_MOD"
61+
62+
# Dependency transformation
63+
[transformations.DependencyTransformation]
64+
module = "loki.transformations"
65+
[transformations.DependencyTransformation.options]
66+
module_suffix = "_MOD"
67+
suffix = "_LOKI"
68+
69+
# Idem transformation
70+
[transformations.IdemTransformation]
71+
module = "loki.transformations"
72+
73+
# loki pipelines
74+
[pipelines.idem]
75+
transformations = [
76+
'RemoveCodeTransformation', 'SplitReadWriteTransformation', 'InlineTransformation',
77+
'IdemTransformation', 'ModuleWrapTransformation', 'DependencyTransformation'
78+
]
79+
80+
[pipelines.idem-stack]
81+
transformations = [
82+
'RemoveCodeTransformation', 'SplitReadWriteTransformation', 'InlineTransformation', 'IdemTransformation',
83+
'TemporariesPoolAllocatorTransformation', 'ModuleWrapTransformation', 'DependencyTransformation'
84+
]
85+
3486
# Define entry point for call-tree transformation
3587
[routines.wamintgr]
3688
role = "driver"
@@ -46,6 +98,40 @@ block = ['ec_parkind', 'parkind_wave']
4698
[routines.transf]
4799
[routines.aki_ice]
48100

101+
# we add loki inlined routines here to force them to be created
102+
[routines.femeanws]
103+
[routines.frcutindex]
104+
[routines.omegagc]
105+
[routines.tau_phi_hf]
106+
[routines.stresso]
107+
[routines.wsigstar]
108+
[routines.sinput]
109+
[routines.sinput_ard]
110+
[routines.sinput_jan]
111+
[routines.taut_z0]
112+
[routines.z0wave]
113+
[routines.airsea]
114+
[routines.femean]
115+
[routines.meansqs_lf]
116+
[routines.halphap]
117+
[routines.wnfluxes]
118+
[routines.sdiwbk]
119+
[routines.sbottom]
120+
[routines.fkmean]
121+
[routines.imphftail]
122+
[routines.setice]
123+
[routines.stokestrn]
124+
[routines.stokesdrift]
125+
[routines.cimsstrn]
126+
[routines.semean]
127+
[routines.sdepthlim]
128+
[routines.ciwabr]
129+
[routines.sinflx]
130+
[routines.sdissip_ard]
131+
[routines.sdissip_jan]
132+
[routines.sdissip]
133+
[routines.peak_ang]
134+
49135
# Define indices and bounds for array dimensions
50136
[dimensions.horizontal]
51137
size = "KIJL"

src/ecwam/ecwam_loki_gpu.config

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,92 @@ block = ['ec_parkind', 'parkind_wave', 'yowdrvtype']
3535
intrinsic_names = ['write(iu06']
3636
kernel_only = true
3737

38+
# Inline transformation
39+
[transformations.InlineTransformation]
40+
module = "loki.transformations"
41+
[transformations.InlineTransformation.options]
42+
allowed_aliases = "IJ"
43+
inline_elementals = false
44+
45+
# Split-read-write transformation
46+
[transformations.SplitReadWriteTransformation]
47+
module = "loki.transformations"
48+
[transformations.SplitReadWriteTransformation.options]
49+
dimensions = "%dimensions.horizontal%"
50+
51+
# GlobalVariableAnalysis
52+
[transformations.GlobalVariableAnalysis]
53+
module = "loki.transformations"
54+
[transformations.GlobalVariableAnalysis.options]
55+
56+
# GlobalVarOffloadTransformation
57+
[transformations.GlobalVarOffloadTransformation]
58+
module = "loki.transformations"
59+
[transformations.GlobalVarOffloadTransformation.options]
60+
61+
# SCC transformations
62+
[transformations.SCCVectorPipeline]
63+
module = "loki.transformations.single_column"
64+
[transformations.SCCVectorPipeline.options]
65+
horizontal = "%dimensions.horizontal%"
66+
directive = "openacc"
67+
trim_vector_sections = true
68+
69+
[transformations.SCCStackPipeline]
70+
module = "loki.transformations.single_column"
71+
[transformations.SCCStackPipeline.options]
72+
horizontal = "%dimensions.horizontal%"
73+
directive = "openacc"
74+
trim_vector_sections = true
75+
block_dim = "%dimensions.block_dim%"
76+
check_bounds = false
77+
78+
[transformations.SCCHoistPipeline]
79+
module = "loki.transformations.single_column"
80+
[transformations.SCCHoistPipeline.options]
81+
horizontal = "%dimensions.horizontal%"
82+
directive = "openacc"
83+
trim_vector_sections = true
84+
block_dim = "%dimensions.block_dim%"
85+
86+
# ModuleWrap transformation
87+
[transformations.ModuleWrapTransformation]
88+
module = "loki.transformations"
89+
[transformations.ModuleWrapTransformation.options]
90+
module_suffix = "_MOD"
91+
92+
# Dependency transformation
93+
[transformations.DependencyTransformation]
94+
module = "loki.transformations"
95+
[transformations.DependencyTransformation.options]
96+
module_suffix = "_MOD"
97+
suffix = "_LOKI"
98+
99+
# FileWrite transformation
100+
[transformations.FileWriteTransformation]
101+
module = "loki.transformations"
102+
[transformations.FileWriteTransformation.options]
103+
include_module_var_imports = true
104+
105+
# loki pipelines
106+
[pipelines.scc]
107+
transformations = [
108+
'RemoveCodeTransformation', 'SplitReadWriteTransformation', 'InlineTransformation', 'GlobalVariableAnalysis',
109+
'GlobalVarOffloadTransformation', 'SCCVectorPipeline', 'ModuleWrapTransformation', 'DependencyTransformation'
110+
]
111+
112+
[pipelines.scc-stack]
113+
transformations = [
114+
'RemoveCodeTransformation', 'SplitReadWriteTransformation', 'InlineTransformation', 'GlobalVariableAnalysis',
115+
'GlobalVarOffloadTransformation', 'SCCStackPipeline', 'ModuleWrapTransformation', 'DependencyTransformation'
116+
]
117+
118+
[pipelines.scc-hoist]
119+
transformations = [
120+
'RemoveCodeTransformation', 'SplitReadWriteTransformation', 'InlineTransformation', 'GlobalVariableAnalysis',
121+
'GlobalVarOffloadTransformation', 'SCCHoistPipeline', 'ModuleWrapTransformation', 'DependencyTransformation'
122+
]
123+
38124
# Define entry point for call-tree transformation
39125
[routines.wamintgr_loki_gpu]
40126
role = "driver"

0 commit comments

Comments
 (0)