Skip to content

Commit

Permalink
#2244 Fix more issues processing LFRic trunk (gungho now compiles, bu…
Browse files Browse the repository at this point in the history
…t fails at runtime)
  • Loading branch information
sergisiso committed Oct 21, 2024
1 parent 1832911 commit bd96a85
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 65 deletions.
4 changes: 2 additions & 2 deletions src/psyclone/domain/lfric/lfric_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ def _upper_bound_fortran(self):
return kernels[0].ntilecolours_var
if self._upper_bound_name == "last_halo_tile_per_colour":
if Config.get().distributed_memory:
return (f"{self._mesh_name}%get_last_halo_tile_per_colour3("
return (f"{self._mesh_name}%get_last_halo_tile_per_colour("
f"{halo_index})")
if self._upper_bound_name == "last_halo_cell_per_colour_and_tile":
if Config.get().distributed_memory:
Expand Down Expand Up @@ -848,7 +848,7 @@ def stop_expr(self):
mesh_sym = sym_table.lookup(self._mesh_name)
sref = StructureReference.create(
mesh_sym,
[("get_last_halo_tile_per_colour4",
[("get_last_halo_tile_per_colour",
[Reference(colour_var)])])
aref = sref.children[0]
else:
Expand Down
93 changes: 49 additions & 44 deletions src/psyclone/dynamo0p3.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,24 +830,24 @@ def initialise(self, parent):
"last_edge_cell_all_colours").name
rhs = f"{mesh}%get_last_edge_cell_all_colours()"
parent.add(AssignGen(parent, lhs=lhs, rhs=rhs))
if need_tilecolour_halo_limits:
lhs = self._symbol_table.find_or_create_tag(
"last_halo_tile_per_colour").name
rhs = f"{mesh}%get_last_halo_tile_per_colour1()"
parent.add(AssignGen(parent, lhs=lhs, rhs=rhs))
lhs = self._symbol_table.find_or_create_tag(
"last_halo_cell_per_colour_and_tiel").name
rhs = f"{mesh}%get_last_halo_cell_per_colour_and_tile()"
parent.add(AssignGen(parent, lhs=lhs, rhs=rhs))
if need_tilecolour_limits:
lhs = self._symbol_table.find_or_create_tag(
"last_edge_tile_per_colour").name
rhs = f"{mesh}%get_last_edge_tile_per_colour()"
parent.add(AssignGen(parent, lhs=lhs, rhs=rhs))
lhs = self._symbol_table.find_or_create_tag(
"last_edge_cell_per_colour_and_tile").name
rhs = f"{mesh}%get_last_edge_cell_per_colour_and_tile()"
parent.add(AssignGen(parent, lhs=lhs, rhs=rhs))
# if need_tilecolour_halo_limits:
# lhs = self._symbol_table.find_or_create_tag(
# "last_halo_tile_per_colour").name
# rhs = f"{mesh}%get_last_halo_tile_per_colour()"
# parent.add(AssignGen(parent, lhs=lhs, rhs=rhs))
# lhs = self._symbol_table.find_or_create_tag(
# "last_halo_cell_per_colour_and_tiel").name
# rhs = f"{mesh}%get_last_halo_cell_per_colour_and_tile()"
# parent.add(AssignGen(parent, lhs=lhs, rhs=rhs))
# if need_tilecolour_limits:
# lhs = self._symbol_table.find_or_create_tag(
# "last_edge_tile_per_colour").name
# rhs = f"{mesh}%get_last_edge_tile_per_colour()"
# parent.add(AssignGen(parent, lhs=lhs, rhs=rhs))
# lhs = self._symbol_table.find_or_create_tag(
# "last_edge_cell_per_colour_and_tile").name
# rhs = f"{mesh}%get_last_edge_cell_per_colour_and_tile()"
# parent.add(AssignGen(parent, lhs=lhs, rhs=rhs))

class DynReferenceElement(LFRicCollection):
'''
Expand Down Expand Up @@ -2389,20 +2389,20 @@ def declarations(self, parent):
parent.add(DeclGen(parent, datatype="integer",
kind=api_config.default_kind["integer"],
entity_decls=[ntilecolours]))
if self._needs_colourtilemap_halo:
last_cell = self._symbol_table.find_or_create_tag(
"last_halo_cell_all_colours")
parent.add(DeclGen(parent, datatype="integer",
kind=api_config.default_kind["integer"],
allocatable=True,
entity_decls=[last_cell.name+"(:,:)"]))
if self._needs_colourtilemap:
last_cell = self._symbol_table.find_or_create_tag(
"last_edge_cell_all_colours")
parent.add(DeclGen(parent, datatype="integer",
kind=api_config.default_kind["integer"],
allocatable=True,
entity_decls=[last_cell.name+"(:)"]))
# if self._needs_colourtilemap_halo:
# last_cell = self._symbol_table.find_or_create_tag(
# "last_halo_cell_all_colours")
# parent.add(DeclGen(parent, datatype="integer",
# kind=api_config.default_kind["integer"],
# allocatable=True,
# entity_decls=[last_cell.name+"(:,:)"]))
# if self._needs_colourtilemap:
# last_cell = self._symbol_table.find_or_create_tag(
# "last_edge_cell_all_colours")
# parent.add(DeclGen(parent, datatype="integer",
# kind=api_config.default_kind["integer"],
# allocatable=True,
# entity_decls=[last_cell.name+"(:)"]))

def initialise(self, parent):
'''
Expand Down Expand Up @@ -2590,17 +2590,17 @@ def initialise(self, parent):
# Colour map itself
parent.add(AssignGen(parent, lhs=dig.tilecolourmap_symbol.name,
pointer=True,
rhs=coarse_mesh + "%get_tilecolour_map()"))
rhs=coarse_mesh + "%get_coloured_tiling_map()"))
# Last halo/edge cell per colour.
sym = dig.last_cell_tile_var_symbol
if len(sym.datatype.shape) == 2:
# Array is 2D so is a halo access.
name = "%get_last_halo_tile_per_colours2()"
else:
# Array is just 1D so go to the last edge cell.
name = "%get_last_edge_tile_per_colours()"
parent.add(AssignGen(parent, lhs=sym.name,
rhs=coarse_mesh + name))
# sym = dig.last_cell_tile_var_symbol
# if len(sym.datatype.shape) == 2:
# # Array is 2D so is a halo access.
# name = "%get_last_halo_tile_per_colour()"
# else:
# # Array is just 1D so go to the last edge cell.
# name = "%get_last_edge_tile_per_colour()"
# parent.add(AssignGen(parent, lhs=sym.name,
# rhs=coarse_mesh + name))

@property
def intergrid_kernels(self):
Expand Down Expand Up @@ -4942,10 +4942,15 @@ def _compute_from_field(self, field):
# anyway. (If the values of the field being modified are
# required, at some later point, in that level of the halo
# then we do a halo swap.)
# import pdb; pdb.set_trace()
self._needs_clean_outer = (
not (field.access == AccessType.INC
and loop.upper_bound_name in ["cell_halo",
"colour_halo"]))
and loop.upper_bound_name in [
"cell_halo",
"colour_halo",
"last_halo_tile_per_colour",
"last_halo_cell_per_colour_and_tile",
]))
# now we have the parent loop we can work out what part of the
# halo this field accesses
if loop.upper_bound_name in const.HALO_ACCESS_LOOP_BOUNDS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def test_colour_trans_tiled(tmpdir, dist_mem):
if not dist_mem:
assert """
do colour = loop0_start, loop0_stop, 1
do tile = loop1_start, mesh%get_last_halo_tile_per_colour4(colour), 1
do tile = loop1_start, mesh%get_last_halo_tile_per_colour(colour), 1
do cell = loop2_start, mesh%get_last_halo_cell_per_colour_and_tile\
(colour,tile), 1
""" in gen
Expand Down
36 changes: 18 additions & 18 deletions src/psyclone/transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1271,16 +1271,16 @@ def _create_tiled_colours_loops(self, node):
colour_loop.field_name = node.field_name
colour_loop.iteration_space = node.iteration_space
colour_loop.set_lower_bound("start")
colour_loop.set_upper_bound("last_halo_tile_per_colour")
colour_loop.kernel = node.kernel
# if node.upper_bound_name in LFRicConstants().HALO_ACCESS_LOOP_BOUNDS:
# # If the original loop went into the halo then this coloured loop
# # must also go into the halo.
# index = node.upper_bound_halo_depth
# colour_loop.set_upper_bound("colour_halo", index)
# else:
# # No halo access.
# colour_loop.set_upper_bound("ncolour")
if node.upper_bound_name in LFRicConstants().HALO_ACCESS_LOOP_BOUNDS:
# If the original loop went into the halo then this coloured loop
# must also go into the halo.
index = node.upper_bound_halo_depth
colour_loop.set_upper_bound("last_halo_tile_per_colour", index)
else:
# No halo access.
colour_loop.set_upper_bound("ncolour")
# colour_loop.set_upper_bound("error")

# Add this loop as a child of our loop over colours
colours_loop.loop_body.addchild(colour_loop)
Expand All @@ -1293,16 +1293,16 @@ def _create_tiled_colours_loops(self, node):
tile_loop.field_name = node.field_name
tile_loop.iteration_space = node.iteration_space
tile_loop.set_lower_bound("start")
tile_loop.set_upper_bound("last_halo_cell_per_colour_and_tile")
tile_loop.kernel = node.kernel
# if node.upper_bound_name in LFRicConstants().HALO_ACCESS_LOOP_BOUNDS:
# # If the original loop went into the halo then this coloured loop
# # must also go into the halo.
# index = node.upper_bound_halo_depth
# tile_loop.set_upper_bound("colour_halo", index)
# else:
# # No halo access.
# tile_loop.set_upper_bound("ncolour")
if node.upper_bound_name in LFRicConstants().HALO_ACCESS_LOOP_BOUNDS:
# If the original loop went into the halo then this coloured loop
# must also go into the halo.
index = node.upper_bound_halo_depth
tile_loop.set_upper_bound("last_halo_cell_per_colour_and_tile",
index)
else:
# No halo access.
tile_loop.set_upper_bound("ncells")

# Add this loop as a child of our loop over colours
colour_loop.loop_body.addchild(tile_loop)
Expand Down

0 comments on commit bd96a85

Please sign in to comment.