Skip to content
Open
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
dba1ab8
Parse part_ref of unresolved symbols as Calls instead of ArrayReferences
sergisiso May 27, 2025
80aa841
Merge remote-tracking branch 'origin/master' into unresolved_as_calls
sergisiso May 27, 2025
e26c5c5
Fix issues with Unresolved as Calls
sergisiso May 27, 2025
5b51132
Merge 2935_lbound_bug
sergisiso May 27, 2025
595941d
Bring to 2935_lbound_bug
sergisiso Jun 3, 2025
9f90894
Fix some tests after switching to unresolved symbols as Calls
sergisiso Jun 4, 2025
e45a130
Modify some tests for the Unknows defaulting to Calls change
sergisiso Jun 16, 2025
91a0d7f
Merge remote-tracking branch 'origin/master' into unresolved_as_calls
sergisiso Jun 25, 2025
3749bca
#2823 Comment out test issues
sergisiso Jun 27, 2025
eae3e6e
#3041 Reuse _find_or_create_unresolved_symbol in the _refine_symbols_…
sergisiso Jun 30, 2025
47e3b18
#3041 Remove unused import
sergisiso Jun 30, 2025
635cdd1
#3041 Add test for call.symbol
sergisiso Jun 30, 2025
c7a5a03
#3041 Add more ARRAY_INTRINSICS
sergisiso Jun 30, 2025
cc0b8f1
Fix issues with ArrayAssignment2Loops
sergisiso Jul 1, 2025
386b1eb
Merge remote-tracking branch 'origin/master' into unresolved_as_calls
sergisiso Jul 9, 2025
8faf03c
Add necessary NEMO imports and other modifications to bring back perf…
sergisiso Jul 9, 2025
b92b637
Recover NEMO performance by improving datatype inference
sergisiso Jul 10, 2025
331f1bd
NEMO works with less exclusions but being very strict about character…
sergisiso Jul 11, 2025
e6ea658
Revert strict character checks
sergisiso Jul 11, 2025
c0e3562
#3041 Clean up PR
sergisiso Jul 11, 2025
6df3dc3
Fix issues in the integration tests
sergisiso Jul 13, 2025
340531f
#3041 Add tests to increase coverage
sergisiso Jul 15, 2025
e2f27ed
Filter problematic NEMO file
sergisiso Jul 17, 2025
b6af656
Merge branch 'master' into unresolved_as_calls
arporter Jul 18, 2025
49891dd
Bring to master
sergisiso Aug 15, 2025
42bf61e
#3041 Bring to master
sergisiso Aug 23, 2025
a447a4b
#3041 Fix typos and add comments
sergisiso Aug 23, 2025
b330b2f
Remove Reference2ArrayRangeTrans verbose option
sergisiso Aug 25, 2025
64a6772
Merge remote-tracking branch 'origin/master' into unresolved_as_calls
sergisiso Aug 26, 2025
55325c1
Changes in omp_gpu_trans
sergisiso Aug 26, 2025
96951a6
Exlude fldread from NEMO
sergisiso Aug 27, 2025
333d478
Merge remote-tracking branch 'origin/master' into unresolved_as_calls
sergisiso Sep 23, 2025
c451530
Bring to master
sergisiso Oct 2, 2025
7c7edc5
Add comments and TODOs
sergisiso Oct 2, 2025
51d5eea
Delete unneeded code
sergisiso Oct 2, 2025
02b9a6f
Remove unused code
sergisiso Oct 3, 2025
4a3448c
Merge remote-tracking branch 'origin/master' into unresolved_as_calls
sergisiso Oct 3, 2025
9c636ef
Fix flake8
sergisiso Oct 3, 2025
8f3bd23
Add a new NEMO import file and new test
sergisiso Oct 6, 2025
84b0a22
Make sure psyclonefc adds a -I with the current_dir
sergisiso Oct 6, 2025
ea1bcee
Merge branch 'master' into unresolved_as_calls
arporter Oct 8, 2025
e57f0f3
#3041 Improve comments and TODOs
sergisiso Oct 13, 2025
a216c53
#3041 Bring to master
sergisiso Oct 13, 2025
21d8c29
#3041 Bring to master
sergisiso Oct 13, 2025
a11fe64
Improve _refine_symbols_with_usage_location implementation and comments
sergisiso Oct 13, 2025
b78e7c0
Improve comments, typehints and transformation options
sergisiso Oct 14, 2025
f46cefb
Refactor and improve testing of _refine_symbols_with_usage_location
sergisiso Oct 14, 2025
8773ddc
#3041 Fix sympywriter reference_node
sergisiso Oct 15, 2025
e5c3573
Merge remote-tracking branch 'origin/master' into unresolved_as_calls
sergisiso Oct 15, 2025
7e55a94
Try to fix NEMO async results (integration test diff is dissabled, th…
sergisiso Oct 17, 2025
ee8afb3
Update NEMO script exclusion list
sergisiso Oct 17, 2025
8a6ac60
Solve issues with psyclonefc and with NEMO async
sergisiso Oct 20, 2025
40f29e1
Add CEILING to the list of supported gpu intrinsics
sergisiso Nov 4, 2025
c28324a
List the files affected by #3112 in omp_cpu_trans.py
sergisiso Nov 5, 2025
ecb902e
Bring to master
sergisiso Nov 5, 2025
202b7f1
Merge remote-tracking branch 'origin/master' into unresolved_as_calls
sergisiso Nov 7, 2025
fc609cb
Try nemo without enhance_tree_information
sergisiso Nov 7, 2025
6632e10
Add some indirect imports to NEMO
sergisiso Nov 7, 2025
4026c97
Bring up to date with new atomatic array privatisation
sergisiso Nov 10, 2025
af704f0
Merge remote-tracking branch 'origin/3188_tighten_privatisation_valid…
sergisiso Nov 10, 2025
138c7ad
Add missing comma
sergisiso Nov 10, 2025
c358f7f
Fixes to NEMO utils.py
sergisiso Nov 11, 2025
59aac22
Merge remote-tracking branch 'origin/master' into unresolved_as_calls
sergisiso Nov 12, 2025
00ee4f2
#2823 Improve comments and testing
sergisiso Nov 12, 2025
1a89942
Remove NEMO script enhance_tree_information now that we do indirect i…
sergisiso Nov 13, 2025
40de2b7
Remove merge leftover
sergisiso Nov 13, 2025
ef8b27a
Attempt to fix NEMO integration test
sergisiso Nov 13, 2025
d17ea86
#2823 Small changes in NEMO scripts
sergisiso Nov 13, 2025
133626f
Fix issue in NEMO utils.py
sergisiso Nov 13, 2025
bfde076
Merge remote-tracking branch 'origin/master' into unresolved_as_calls
sergisiso Nov 14, 2025
706249e
Test NEMOv5 async without no StructureRefs
sergisiso Nov 14, 2025
0efe6ab
Bring to master
sergisiso Nov 14, 2025
7944b23
Merge branch 'master' into unresolved_as_calls
sergisiso Nov 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions examples/nemo/scripts/omp_gpu_trans.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
add_profiling, inline_calls, insert_explicit_loop_parallelism,
normalise_loops, enhance_tree_information, PARALLELISATION_ISSUES,
NEMO_MODULES_TO_IMPORT, PRIVATISATION_ISSUES)
from psyclone.psyir.nodes import Routine
from psyclone.psyir.nodes import Routine, Loop
from psyclone.psyir.transformations import OMPTargetTrans
from psyclone.transformations import (
OMPLoopTrans, OMPDeclareTargetTrans, TransformationError)
Expand All @@ -69,7 +69,10 @@
RESOLVE_IMPORTS = NEMO_MODULES_TO_IMPORT

# List of all files that psyclone will skip processing
FILES_TO_SKIP = []
FILES_TO_SKIP = [
# TODO #2951 NEMOV5 fldread has problem with StructuresRefs
"fldread.f90",
]

NEMOV5_EXCLUSIONS = []

Expand All @@ -83,6 +86,7 @@
"iom_nf90.f90",
"iom_def.f90",
"timing.f90",
"lbclnk.f90",
]

OFFLOADING_ISSUES = [
Expand All @@ -97,10 +101,11 @@
"sedfunc.f90",
"stpmlf.f90",
"trddyn.f90",
"trczdf.f90",
"trcice_pisces.f90",
"dtatsd.f90",
"trcatf.f90",
"trcais.f90",
"zdfiwm.f90",
]


Expand Down Expand Up @@ -158,9 +163,7 @@ def trans(psyir):
subroutine.name.endswith('_init') or
subroutine.name.startswith('Agrif') or
subroutine.name.startswith('dia_') or
subroutine.name == 'dom_msk' or
subroutine.name == 'dom_zgr' or
subroutine.name == 'dom_ngb'):
psyir.name.startswith('dom')):
continue

enhance_tree_information(subroutine)
Expand All @@ -181,8 +184,7 @@ def trans(psyir):
if (
subroutine.name.lower().startswith("sign_")
or subroutine.name.lower() == "solfrac"
# Important for performance but causes SIGNAL 11 in some cases
# or (psyir.name == "sbc_phy.f90" and not subroutine.walk(Loop))
or (psyir.name == "sbc_phy.f90" and not subroutine.walk(Loop))
):
try:
OMPDeclareTargetTrans().apply(subroutine)
Expand Down
182 changes: 50 additions & 132 deletions examples/nemo/scripts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
from psyclone.domain.common.transformations import KernelModuleInlineTrans
from psyclone.psyir.nodes import (
Assignment, Loop, Directive, Node, Reference, CodeBlock, ArrayReference,
Call, Return, IfBlock, Routine, Schedule, IntrinsicCall,
StructureReference)
Call, Return, IfBlock, Routine, Schedule, IntrinsicCall)
from psyclone.psyir.symbols import (
DataSymbol, INTEGER_TYPE, ScalarType, RoutineSymbol)
DataSymbol, INTEGER_TYPE, ScalarType, UnsupportedFortranType,
ArrayType, REAL_TYPE)
from psyclone.psyir.transformations import (
ArrayAssignment2LoopsTrans, HoistLoopBoundExprTrans, HoistLocalArraysTrans,
HoistTrans, InlineTrans, Maxval2LoopTrans, ProfileTrans,
Expand All @@ -52,8 +52,11 @@

# USE statements to chase to gather additional symbol information.
NEMO_MODULES_TO_IMPORT = [
"oce", "par_oce", "par_kind", "dom_oce", "phycst", "ice",
"obs_fbm", "flo_oce", "sbc_ice", "wet_dry"
"oce", "par_oce", "par_kind", "dom_oce", "phycst", "ice", "sbc_oce",
"obs_fbm", "flo_oce", "sbc_ice", "wet_dry", "ldfslp", "zdfiwm", "zdfmxl",
"bdy_oce", "zdf_oce", "zdfdrg", "ldftra", "crs", "sbcapr", "tideini",
"ldfdyn", "sbcapr", "sbctide", "zdfgls", "sbcrnf", "sbcisf", "dynldf_iso",
"stopts", "icb_oce", "domvvl", "sms_pisces", "zdfmfc"
]

# Files that PSyclone could process but would reduce the performance.
Expand All @@ -74,98 +77,6 @@
"sum", "sign_", "ddpdd", "solfrac", "psyclone_cmp_int",
"psyclone_cmp_char", "psyclone_cmp_logical"]

# Currently fparser has no way of distinguishing array accesses from
# function calls if the symbol is imported from some other module.
# We therefore work-around this by keeping a list of known NEMO functions
# from v4 and v5.
NEMO_FUNCTIONS = [
# Internal funtions can be obtained with:
# $ grep -rhi "end function" src/ | awk '{print $3}' | uniq | sort
'abl_alloc', 'add_xxx', 'Agrif_CFixed', 'agrif_external_switch_index',
'Agrif_Fixed', 'agrif_oce_alloc', 'Agrif_Root', 'alfa_charn', 'alngam',
'alpha_sw_sclr', 'alpha_sw_vctr', 'arr_hls', 'arr_lbnd', 'arr_lbnd_2d_dp',
'arr_lbnd_2d_i', 'arr_lbnd_2d_sp', 'arr_lbnd_3d_dp', 'arr_lbnd_3d_i',
'arr_lbnd_3d_sp', 'arr_lbnd_4d_dp', 'arr_lbnd_4d_i', 'arr_lbnd_4d_sp',
'arr_lbnd_5d_dp', 'arr_lbnd_5d_i', 'arr_lbnd_5d_sp', 'atg',
'bdy_oce_alloc', 'bdy_segs_surf', 'Cd_from_z0', 'CdN10_f_LU12',
'CdN10_f_LU13', 'cd_n10_ncar', 'cd_neutral_10m', 'CdN_f_LG15',
'CdN_f_LG15_light', 'CdN_f_LU12_eq36', 'ce_n10_ncar', 'charn_coare3p0',
'charn_coare3p6', 'charn_coare3p6_wave', 'check_hdom', 'ch_n10_ncar',
'cp_air', 'cp_air_sclr', 'cp_air_vctr', 'cpl_freq', 'crs_dom_alloc',
'crs_dom_alloc2', 'dayjul', 'def_newlink', 'delta_skin_layer',
'depth', 'dep_to_p', 'de_sat_dt_ice_sclr', 'de_sat_dt_ice_vctr',
'dia_ar5_alloc', 'diadct_alloc', 'dia_hth_alloc', 'dia_ptr_alloc',
'dia_wri_alloc', 'dom_oce_alloc', 'dom_vvl_alloc', 'dq_sat_dt_ice_sclr',
'dq_sat_dt_ice_vctr', 'dyn_dmp_alloc', 'dyn_ldf_iso_alloc',
'dyn_spg_ts_alloc', 'eos_pt_from_ct', 'e_sat_ice_sclr', 'e_sat_ice_vctr',
'e_sat_sclr', 'e_sat_vctr', 'exa_mpl_alloc', 'f_h_louis_sclr',
'f_h_louis_vctr', 'find_link', 'fintegral', 'fld_filename',
'flo_dom_alloc', 'flo_dstnce', 'flo_oce_alloc', 'flo_rst_alloc',
'flo_wri_alloc', 'f_m_louis_sclr', 'f_m_louis_vctr', 'frac_solar_abs',
'fspott', 'FUNCTION_GLOBMINMAX', 'FUNCTION_GLOBSUM', 'gamain',
'gamma_moist', 'gamma_moist_sclr', 'gamma_moist_vctr', 'get_unit',
'grt_cir_dis', 'grt_cir_dis_saa', 'icb_alloc', 'icb_utl_bilin',
'icb_utl_bilin_2d_h', 'icb_utl_bilin_3d_h', 'icb_utl_bilin_e',
'icb_utl_bilin_h', 'icb_utl_bilin_x', 'icb_utl_count', 'icb_utl_heat',
'icb_utl_mass', 'icb_utl_yearday', 'ice1D_alloc', 'ice_alloc',
'ice_dia_alloc', 'ice_dyn_rdgrft_alloc', 'ice_perm_eff',
'ice_thd_pnd_alloc', 'ice_update_alloc', 'ice_var_sshdyn', 'in_hdom',
'integ_spline', 'interp', 'interp1', 'interp2', 'interp3',
'iom_axis', 'iom_getszuld', 'iom_nf90_varid', 'iom_sdate', 'iom_use',
'iom_varid', 'iom_xios_setid', 'iscpl_alloc', 'is_tile', 'kiss',
'ksec_week', 'lib_mpp_alloc', 'linquad', 'L_vap', 'L_vap_sclr',
'L_vap_vctr', 'm', 'maxdist', 'mynode', 'nblinks', 'nodal_factort',
'oce_alloc', 'oce_SWE_alloc', 'One_on_L', 'p2z_exp_alloc',
'p2z_lim_alloc', 'p2z_prod_alloc', 'p4z_che_alloc', 'p4z_diaz_alloc',
'p4z_flx_alloc', 'p4z_lim_alloc', 'p4z_meso_alloc', 'p4z_opt_alloc',
'p4z_prod_alloc', 'p4z_rem_alloc', 'p4z_sed_alloc', 'p4z_sink_alloc',
'p5z_lim_alloc', 'p5z_meso_alloc', 'p5z_prod_alloc',
'PHI', 'potemp', 'pres_temp_sclr', 'pres_temp_vctr', 'prt_ctl_sum_2d',
'prt_ctl_sum_3d', 'prt_ctl_write_sum', 'psi_h', 'psi_h_andreas',
'psi_h_coare', 'psi_h_ecmwf', 'psi_h_ice', 'psi_h_mfs', 'psi_h_ncar',
'psi_m', 'psi_m_andreas', 'psi_m_coare', 'psi_m_ecmwf', 'psi_m_ice',
'psi_m_mfs', 'psi_m_ncar', 'p_to_dep', 'ptr_ci_2d', 'ptr_sj_2d',
'ptr_sj_3d', 'ptr_sjk', 'q_air_rh', 'qlw_net_sclr', 'qlw_net_vctr',
'q_sat', 'q_sat_sclr', 'q_sat_vctr', 'qsr_ext_lev', 'rho_air',
'rho_air_sclr', 'rho_air_vctr', 'Ri_bulk', 'Ri_bulk_sclr', 'Ri_bulk_vctr',
'rough_leng_m', 'rough_leng_tq', 's', 'sbc_blk_alloc', 'sbc_blk_ice_alloc',
'sbc_cpl_alloc', 'sbc_dcy', 'sbc_dcy_alloc', 'sbc_ice_alloc',
'sbc_ice_cice_alloc', 'sbc_oce_alloc', 'sbc_rnf_alloc',
'sbc_ssr_alloc', 'sed_adv_alloc', 'sed_alloc', 'sed_oce_alloc',
'sms_c14_alloc', 'sms_pisces_alloc', 'snw_ent', 'solfrac',
'sto_par_flt_fac', 'sum2d', 'sw_adtg', 'sw_ptmp', 'theta',
'theta_exner_sclr', 'theta_exner_vctr', 't_imp', 'tra_bbl_alloc',
'tra_dmp_alloc', 'trc_alloc', 'trc_dmp_alloc', 'trc_dmp_sed_alloc',
'trc_oce_alloc', 'trc_oce_ext_lev', 'trc_opt_alloc', 'trc_sms_cfc_alloc',
'trc_sms_my_trc_alloc', 'trc_sub_alloc', 'trd_ken_alloc', 'trd_mxl_alloc',
'trdmxl_oce_alloc', 'trd_mxl_trc_alloc', 'trd_pen_alloc', 'trd_tra_alloc',
'trd_trc_oce_alloc', 'trd_vor_alloc', 'twrk_id', 'UN10_from_CD',
'UN10_from_ustar', 'u_star_andreas', 'virt_temp_sclr', 'virt_temp_vctr',
'visc_air', 'visc_air_sclr', 'visc_air_vctr', 'w1', 'w2', 'z0_from_Cd',
'z0tq_LKB', 'zdf_gls_alloc', 'zdf_iwm_alloc', 'zdf_mfc_alloc',
'zdf_mxl_alloc', 'zdf_oce_alloc', 'zdf_osm_alloc', 'zdf_phy_alloc',
'zdf_tke_alloc', 'zdf_tmx_alloc',
# grep -rh "INTERFACE" src | grep -v "END" | awk '{print $2}' | uniq | sort
'alpha_sw', 'bulk_formula', 'cp_air', 'debug', 'DECAL_FEEDBACK',
'DECAL_FEEDBACK_2D', 'depth_to_e3', 'de_sat_dt_ice', 'dia_ar5_hst',
'dia_ptr_hst', 'div_hor', 'dom_tile_copyin', 'dom_tile_copyout',
'dq_sat_dt_ice', 'dyn_vor', 'e3_to_depth', 'eos', 'eos_fzp',
'eos_rab', 'e_sat', 'e_sat_ice', 'f_h_louis', 'f_m_louis',
'gamma_moist', 'glob_2Dmax', 'glob_2Dmin', 'glob_2Dsum', 'glob_3Dmax',
'glob_3Dmin', 'glob_3Dsum', 'halo_mng_resize', 'icb_utl_bilin_h',
'ice_var_itd', 'ice_var_snwblow', 'ice_var_snwfra', 'iom_get',
'iom_getatt', 'iom_nf90_get', 'iom_put', 'iom_putatt',
'iom_rstput', 'lbc_lnk', 'lbc_lnk_neicoll', 'lbc_lnk_pt2pt',
'lbc_nfd', 'lbnd_ij', 'ldf_eiv_trp', 'local_2Dmax', 'local_2Dmin',
'local_2Dsum', 'local_3Dmax', 'local_3Dmin', 'local_3Dsum',
'L_vap', 'mpp_max', 'mpp_maxloc', 'mpp_min', 'mpp_minloc',
'mpp_nfd', 'mpp_sum', 'pres_temp', 'prt_ctl_sum', 'ptr_mpp_sum',
'ptr_sj', 'ptr_sum', 'qlw_net', 'q_sat', 'rho_air', 'Ri_bulk',
'SIGN', 'sum3x3', 'theta_exner', 'tra_mle_trp', 'trd_vor_zint',
'virt_temp', 'visc_air', 'wAimp', 'wzv', 'zdf_osm_iomput',
'zdf_osm_velocity_rotation',
]

# Currently fparser has no way of distinguishing array accesses from statement
# functions, the following subroutines contains known statement functions
CONTAINS_STMT_FUNCTIONS = ["sbc_dcy"]
Expand All @@ -179,6 +90,7 @@

PRIVATISATION_ISSUES = [
"ldftra.f90", # Wrong runtime results
"zdftke.f90",
]


Expand Down Expand Up @@ -208,41 +120,39 @@ def enhance_tree_information(schedule):
:type schedule: :py:class:`psyclone.psyir.nodes.node`

'''
are_integers = ('jpi', 'jpim1', 'jpj', 'jpjm1', 'jp_tem', 'jp_sal',
'jpkm1', 'jpiglo', 'jpni', 'jpk', 'jpiglo_crs',
'jpmxl_atf', 'jpmxl_ldf', 'jpmxl_zdf', 'jpnij',
'jpts', 'jpvor_bev', 'nleapy', 'nn_ctls', 'jpmxl_npc',
'jpmxl_zdfp', 'npti')
# These are all indirect wildcard imports that psyclone misses but are
# necessary to offload performance-sensitive loops.
are_integers = ('ntsj', 'ntsi', 'ntei', 'ntej', 'jpk', 'jpkm1', 'jpkglo',
'nksr', 'Ni_0', 'Nj_0', 'Ni0glo', 'nn_hls', 'jpiglo',
'Nis0', 'Nie0', 'Njs0', 'Nje0', 'ntei', 'ntej', 'jpi',
'jpj')
are_arrays = {
'tmask': UnsupportedFortranType(
"real(kind = wp), public, allocatable, dimension(:, :, :),"
" target :: tmask",
ArrayType(REAL_TYPE, [ArrayType.Extent.DEFERRED]*3)),
'e3w_1d': ArrayType(REAL_TYPE, [ArrayType.Extent.DEFERRED]*1),
'e3t_1d': ArrayType(REAL_TYPE, [ArrayType.Extent.DEFERRED]*1),
'gdept_1d': ArrayType(REAL_TYPE, [ArrayType.Extent.DEFERRED]*1),
'hmld': ArrayType(REAL_TYPE, [ArrayType.Extent.DEFERRED]*2),
'r3t': ArrayType(REAL_TYPE, [ArrayType.Extent.DEFERRED]*3),
}

for reference in schedule.walk(Reference):
if reference.symbol.name in are_integers:
# Manually set the datatype of some integer scalars that are
# important for performance
_it_should_be(reference.symbol, ScalarType, INTEGER_TYPE)
elif (
# If its an ArrayReference ...
isinstance(reference, ArrayReference) and
# ... with the following name ...
(reference.symbol.name in NEMO_FUNCTIONS or
reference.symbol.name.startswith('local_') or
reference.symbol.name.startswith('glob_') or
reference.symbol.name.startswith('SIGN_') or
reference.symbol.name.startswith('netcdf_') or
reference.symbol.name.startswith('nf90_')) and
# ... and the symbol is unresolved
(reference.symbol.is_import or reference.symbol.is_unresolved)
):
# The parser gets these wrong, they are Calls not ArrayRefs
if not isinstance(reference.symbol, RoutineSymbol):
# We need to specialise the generic Symbol to a Routine
reference.symbol.specialise(RoutineSymbol)
if not (isinstance(reference.parent, Call) and
if reference.symbol.name in are_arrays:
new_type = are_arrays[reference.symbol.name]
if not isinstance(reference.symbol, DataSymbol):
# We need to specialise the generic Symbol with its type
reference.symbol.specialise(DataSymbol, datatype=new_type)
if (isinstance(reference.parent, Call) and
reference.parent.routine is reference):
# We also need to replace the Reference node with a Call
call = Call.create(reference.symbol)
for child in reference.children[:]:
call.addchild(child.detach())
reference.replace_with(call)
# We also need to replace the Call with an ArrayRef
array_ref = ArrayReference.create(reference.symbol, [])
for child in reference.parent.arguments:
array_ref.addchild(child.detach())
reference.parent.replace_with(array_ref)


def inline_calls(schedule):
Expand Down Expand Up @@ -353,9 +263,14 @@ def normalise_loops(
continue
if isinstance(reference.symbol, DataSymbol):
try:
Reference2ArrayRangeTrans().apply(reference)
Reference2ArrayRangeTrans().apply(
reference, options={'verbose': True})
except TransformationError:
pass
# The transformation above brings new symbols from dimension
# expressions, we want these symbols to have all typing information
# possible as these are offloading candidates
enhance_tree_information(schedule)

if loopify_array_intrinsics:
for intr in schedule.walk(IntrinsicCall):
Expand All @@ -369,10 +284,9 @@ def normalise_loops(
# Convert all array implicit loops to explicit loops
explicit_loops = ArrayAssignment2LoopsTrans()
for assignment in schedule.walk(Assignment):
if assignment.walk(StructureReference):
continue # TODO #2951 Fix issues with structure_refs
try:
explicit_loops.apply(assignment)
explicit_loops.apply(
assignment, options={'verbose': True})
except TransformationError:
pass

Expand Down Expand Up @@ -437,7 +351,8 @@ def insert_explicit_loop_parallelism(
with non-reproducible device intrinsics.

'''
if schedule.name == "ts_wgt":
# These are both in "dynstg_ts.f90" and has a big performance impact
if schedule.name in ("ts_wgt", "ts_rst"):
return # TODO #2937 WaW dependency incorrectly considered private
# Add the parallel directives in each loop
for loop in schedule.walk(Loop):
Expand Down Expand Up @@ -486,6 +401,9 @@ def insert_explicit_loop_parallelism(
" 'nlay_i' or 'nlay_s'.")
continue

if routine_name == "tra_zdf_imp":
opts['allow_strings'] = True

try:
# First check that the region_directive is feasible for this region
if region_directive_trans:
Expand Down
2 changes: 1 addition & 1 deletion src/psyclone/core/variables_access_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def __str__(self):
mode = "WRITE"
else:
# The data associated with this signature is not accessed.
mode = "NO_DATA_ACCESS"
mode = "UNKNOWN"
output_list.append(f"{signature}: {mode}")
return ", ".join(output_list)

Expand Down
2 changes: 1 addition & 1 deletion src/psyclone/domain/common/transformations/alg_trans.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def apply(self, psyir, options=None):
'''
self.validate(psyir, options=options)
idx = 0
for call in psyir.walk(Call):
for call in psyir.walk(Call, stop_type=Call):
if call.routine.name.lower() == "invoke":
self._invoke_trans.apply(call, idx, options=options)
idx += 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

from psyclone.psyir.frontend.fortran import FortranReader
from psyclone.psyir.nodes import (
Call, ArrayReference, CodeBlock, Literal, Reference)
Call, CodeBlock, Literal, Reference, Routine)
from psyclone.psyir.symbols import (
Symbol, DataTypeSymbol, StructureType, RoutineSymbol, ScalarType)
from psyclone.domain.common.algorithm import (
Expand Down Expand Up @@ -203,24 +203,23 @@ def validate(self, node, options=None):
f"Problem with invoke name: {err}") from err
if node.argument_names[idx]:
pass
elif isinstance(arg, ArrayReference):
pass
elif isinstance(arg, Call):
if arg.symbol == arg.ancestor(Routine).symbol:
raise TransformationError(
f"The invoke call argument '{arg.symbol.name}' has "
f"been used as the Algorithm routine name. This is not"
f" allowed.")
elif isinstance(arg, CodeBlock):
# pylint: disable=protected-access
for fp2_node in arg._fp2_nodes:
self._validate_fp2_node(fp2_node)
else:
if isinstance(arg, Call):
info = (
f"The invoke call argument '{arg.routine.name}' has "
f"been used as a routine name. This is not allowed.")
else:
info = (
f"The arguments to this invoke call are expected to "
f"be kernel calls which are represented in generic "
f"PSyIR as CodeBlocks or ArrayReferences, but "
f"'{arg.debug_string()}' is of type "
f"'{type(arg).__name__}'.")
info = (
f"The arguments to this invoke call are expected to "
f"be kernel calls which are represented in generic "
f"PSyIR as Calls or Codeblocks, but "
f"'{arg.debug_string()}' is of type "
f"'{type(arg).__name__}'.")
raise TransformationError(
f"Error in {self.name} transformation. {info}")

Expand All @@ -247,10 +246,11 @@ def apply(self, call, index, options=None):
if call.argument_names[idx]:
call_name = f"{call_arg.value}"
continue
elif isinstance(call_arg, ArrayReference):
# kernel misrepresented as ArrayReference
args = call_arg.pop_all_children()
type_symbol = call_arg.symbol
elif isinstance(call_arg, Call):
# Get the symbols and args to reconstruct it as a
# higer-abstraction AlgorithmInvokeCall node
type_symbol = call_arg.routine.symbol
args = call_arg.pop_all_children()[1:]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use call_arg.arguments here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still need the pop_all_children as the arguments returns a slice which is not where I want to remove the items from.
But if you find it more readable I can convert it to two different statements, the .argument and then the .pop_all_children

arg_info.append((type_symbol, args))
else:
# The validates check that this can only be a Codeblock with
Expand Down
Loading
Loading