Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@
| theabro | Nathan Luke Abraham | NCAS & University of Cambridge | 2026-04-15 |
| ss421 | Steven Sandbach | Met Office | 2026-04-20 |
| MichaelWhitall | Michael Whitall | Met Office | 2026-04-22 |
| sergisiso | Sergi Siso | UKRI-STFC | 2026-06-09 |
| arporter | Andrew Porter | UKRI-STFC | 2026-06-09 |
| LonelyCat124 | Aidan Chalk | UKRI-STFC | 2026-06-09 |
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from psyclone_tools import (redundant_computation_setval, colour_loops,
view_transformed_schedule)

from psyclone.transformations import (Dynamo0p3OMPLoopTrans,
OMPParallelTrans)
from psyclone.psyir.transformations import OMPParallelTrans
from psyclone.transformations import LFRicOMPLoopTrans
from psyclone.psyGen import InvokeSchedule

# NOTE: Whilst gen_*_lookup_code kernels are called from psy-lite,
Expand Down Expand Up @@ -63,7 +63,7 @@ def openmp_parallelise_loops_adj(psyir):
:param psyir: the PSyIR of the PSy-layer.
:type psyir: :py:class:`psyclone.psyir.nodes.FileContainer`
'''
otrans = Dynamo0p3OMPLoopTrans()
otrans = LFRicOMPLoopTrans()
oregtrans = OMPParallelTrans()

# Loop over all the InvokeSchedule in the PSyIR object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from psyclone_tools import (redundant_computation_setval, colour_loops,
view_transformed_schedule)

from psyclone.transformations import (Dynamo0p3OMPLoopTrans,
OMPParallelTrans)
from psyclone.psyir.transformations import OMPParallelTrans
from psyclone.transformations import LFRicOMPLoopTrans
from psyclone.psyGen import InvokeSchedule

# NOTE: Whilst gen_*_lookup_code kernels are called from psy-lite,
Expand Down Expand Up @@ -63,7 +63,7 @@ def openmp_parallelise_loops_adj(psyir):
:param psyir: the PSyIR of the PSy-layer.
:type psyir: :py:class:`psyclone.psyir.nodes.FileContainer`
'''
otrans = Dynamo0p3OMPLoopTrans()
otrans = LFRicOMPLoopTrans()
oregtrans = OMPParallelTrans()

# Loop over all the InvokeSchedule in the PSyIR object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from psyclone_tools import (redundant_computation_setval, colour_loops,
view_transformed_schedule)

from psyclone.transformations import (Dynamo0p3OMPLoopTrans,
OMPParallelTrans)
from psyclone.psyir.transformations import OMPParallelTrans
from psyclone.transformations import LFRicOMPLoopTrans
from psyclone.psyGen import InvokeSchedule

# NOTE: Whilst gen_*_lookup_code kernels are called from psy-lite,
Expand Down Expand Up @@ -63,7 +63,7 @@ def openmp_parallelise_loops_adj(psyir):
:param psyir: the PSyIR of the PSy-layer.
:type psyir: :py:class:`psyclone.psyir.nodes.FileContainer`
'''
otrans = Dynamo0p3OMPLoopTrans()
otrans = LFRicOMPLoopTrans()
oregtrans = OMPParallelTrans()

# Loop over all the InvokeSchedule in the PSyIR object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from psyclone_tools import (redundant_computation_setval, colour_loops,
view_transformed_schedule)

from psyclone.transformations import (Dynamo0p3OMPLoopTrans,
OMPParallelTrans)
from psyclone.psyir.transformations import OMPParallelTrans
from psyclone.transformations import LFRicOMPLoopTrans
from psyclone.psyGen import InvokeSchedule

# NOTE: Whilst gen_*_lookup_code kernels are called from psy-lite,
Expand Down Expand Up @@ -63,7 +63,7 @@ def openmp_parallelise_loops_adj(psyir):
:param psyir: the PSyIR of the PSy-layer.
:type psyir: :py:class:`psyclone.psyir.nodes.FileContainer`
'''
otrans = Dynamo0p3OMPLoopTrans()
otrans = LFRicOMPLoopTrans()
oregtrans = OMPParallelTrans()

# Loop over all the InvokeSchedule in the PSyIR object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
from psyclone.psyir.nodes import (
Assignment, Reference, Literal, IfBlock, Call)
from psyclone.psyir.symbols import (
INTEGER_TYPE, RoutineSymbol, CHARACTER_TYPE)
ScalarType, RoutineSymbol)

# Transformation Parameters
# =========================
Expand Down Expand Up @@ -97,12 +97,13 @@ def trans(psyir):
if assign.rhs.name == match_rhs:
if chunk_size is not None:
assign.rhs.replace_with(
Literal(str(chunk_size), INTEGER_TYPE))
Literal(str(chunk_size),
ScalarType.integer_type()))
found = assign

# Insert print call
if found:
print_call = Call()
print_call.addchild(Reference(RoutineSymbol("umPrint")))
print_call.addchild(Literal(message_text, CHARACTER_TYPE))
print_call.addchild(Literal(message_text, ScalarType.character_type()))
found.parent.addchild(print_call, index=found.position+1)
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
PSyclone as of version 3.1 is not capable of fully
determining which variables need to be set PRIVATE, since many of these
are arrays (and using `privatise_arrays` has not been found to work). The
suggested fix from STFC is to use `explicitly_private_symbols`, which is
captured in `mark_explicit_privates` from `transmute_functions`.
suggested fix from STFC is to use the `force_private` option.
The workaround is to set anything beginning in `seg_` to PRIVATE, since
these variables are the ones used in the chunking and therefore need to
be private to each thread.
Expand All @@ -42,7 +41,6 @@
from psyclone.psyir.symbols import DataSymbol
from transmute_psytrans.transmute_functions import (
first_priv_red_init,
mark_explicit_privates,
)

OMP_TRANS = OMPParallelLoopTrans()
Expand Down Expand Up @@ -74,7 +72,7 @@ def trans(psyir):
# some non-PURE subroutines called within this loop
"force": True,
# several WRITE statements used for diagnostics
"node-type-check": False,
"node_type_check": False,
}
# For the coarse-grained approach, we have *one* loop we want to work on
# - the loop over segments. This gives almost complete coverage for GLOMAP,
Expand All @@ -84,21 +82,20 @@ def trans(psyir):
# identify the loop in question - the loop over segments
if hasattr(loop.stop_expr, "name") and loop.stop_expr.name in ["nseg"]:
try:
# set some symbols to be PRIVATE
symbols_to_add = get_private_symbols_from_name(loop, "seg_")
# add a few more symbols that don't fit this syntax
symbols_to_add.extend(
["i_end", "i_end_cp", "j", "nbs_index", "y"]
)
# set some symbols to be PRIVATE
mark_explicit_privates(loop, symbols_to_add)
# CCE compiler fix - initialise some FIRSTPRIVATE variables
first_priv_red_init(
loop,
["errcode", "i_start_cp", "iaer", "k", "cmessage"],
insert_at_start=True,
)
OMPParallelLoopTrans(omp_schedule="dynamic").apply(
loop, options=opts
loop, force_private=symbols_to_add, **opts
)

except TransformationError as err:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
DataSymbol,
ImportInterface,
RoutineSymbol,
ScalarType,
Symbol,
)
from psyclone.psyir.transformations.reference2arrayrange_trans import (
Expand Down Expand Up @@ -244,7 +245,7 @@ def trans(psyir):
desired_chunk_size_var = routine.symbol_table.find_or_create_tag(
"desired_chunk_size",
symbol_type=DataSymbol,
datatype=INTEGER_TYPE)
datatype=ScalarType.integer_type())

if desired_chunk_size is None:
assign_desired_chunk_size = Assignment.create(
Expand All @@ -253,7 +254,7 @@ def trans(psyir):
else:
assign_desired_chunk_size = Assignment.create(
Reference(desired_chunk_size_var),
Literal(str(desired_chunk_size), INTEGER_TYPE))
Literal(str(desired_chunk_size), ScalarType.integer_type()))

# Introduce full-domain array for each ASAD array
# -----------------------------------------------
Expand All @@ -266,18 +267,18 @@ def trans(psyir):
bounds.append(IntrinsicCall.create(
IntrinsicCall.Intrinsic.SIZE,
[Reference(Symbol(var_name)),
("dim", Literal(str(i), INTEGER_TYPE))]))
("dim", Literal(str(i), ScalarType.integer_type()))]))
# Create variables
new_var = routine.symbol_table.find_or_create_tag(
"full_" + var_name,
symbol_type=DataSymbol,
datatype=ArrayType(REAL_TYPE, bounds))
datatype=ArrayType(ScalarType.real_type(), bounds))
full_vars[var_name] = (bounds, new_var)
# Add initialiser
if var_name in refs_before:
initialiser = Assignment.create(
ArrayReference.create(new_var, [":" for b in bounds]),
Literal("0.0", REAL_TYPE))
Literal("0.0", ScalarType.real_type()))
routine.addchild(initialiser, index=0)

# Replace each use of ASAD array with full-domain counterpart
Expand Down Expand Up @@ -311,15 +312,15 @@ def trans(psyir):
chunk_begin_var = routine.symbol_table.find_or_create_tag(
"chunk_begin",
symbol_type=DataSymbol,
datatype=INTEGER_TYPE)
datatype=ScalarType.integer_type())
chunk_end_var = routine.symbol_table.find_or_create_tag(
"chunk_end",
symbol_type=DataSymbol,
datatype=INTEGER_TYPE)
datatype=ScalarType.integer_type())
chunk_size_var = routine.symbol_table.find_or_create_tag(
"chunk_size",
symbol_type=DataSymbol,
datatype=INTEGER_TYPE)
datatype=ScalarType.integer_type())

# Create assignment for chunk_end
minop = IntrinsicCall.create(
Expand All @@ -331,15 +332,15 @@ def trans(psyir):
BinaryOperation.create(
BinaryOperation.Operator.SUB,
Reference(desired_chunk_size_var),
Literal("1", INTEGER_TYPE)))])
Literal("1", ScalarType.integer_type())))])
assign_chunk_end = Assignment.create(Reference(chunk_end_var), minop)

# Create assignment for chunk_size
chunk_size = BinaryOperation.create(
BinaryOperation.Operator.SUB,
BinaryOperation.create(
BinaryOperation.Operator.ADD,
Literal("1", INTEGER_TYPE),
Literal("1", ScalarType.integer_type()),
Reference(chunk_end_var)),
Reference(chunk_begin_var))
assign_chunk_size = Assignment.create(Reference(chunk_size_var),
Expand All @@ -348,7 +349,7 @@ def trans(psyir):
# Create chunking loop
loop = Loop(variable=chunk_begin_var)
asad_call.replace_with(loop)
loop.children = [Literal("1", INTEGER_TYPE),
loop.children = [Literal("1", ScalarType.integer_type()),
Reference(array_size_var),
Reference(desired_chunk_size_var),
Schedule(parent=loop, children=[asad_call])]
Expand All @@ -357,7 +358,7 @@ def trans(psyir):
for var_name in refs_before:
(bounds, full_var) = full_vars[var_name]
var_sym = DataSymbol(
var_name, datatype=ArrayType(REAL_TYPE, bounds))
var_name, datatype=ArrayType(ScalarType.real_type(), bounds))
assign_full_var = Assignment.create(
ArrayReference.create(var_sym, [":" for b in bounds]),
ArrayReference.create(full_var, [":" for b in bounds]))
Expand All @@ -367,7 +368,7 @@ def trans(psyir):
for var_name in refs_after:
(bounds, full_var) = full_vars[var_name]
var_sym = DataSymbol(
var_name, datatype=ArrayType(REAL_TYPE, bounds))
var_name, datatype=ArrayType(ScalarType.real_type(), bounds))
assign_full_var = Assignment.create(
ArrayReference.create(full_var, [":" for b in bounds]),
ArrayReference.create(var_sym, [":" for b in bounds]))
Expand All @@ -381,7 +382,7 @@ def trans(psyir):
# Update references to arrays
for ref in loop.loop_body.walk(ArrayReference):
if ref.name in asad_vars.keys():
ref.indices[0].start = Literal("1", INTEGER_TYPE)
ref.indices[0].start = Literal("1", ScalarType.integer_type())
ref.indices[0].stop = Reference(chunk_size_var)
else:
ref.indices[0].start = Reference(chunk_begin_var)
Expand All @@ -396,7 +397,7 @@ def trans(psyir):

print_call = Call()
print_call.addchild(Reference(RoutineSymbol("umPrint")))
print_call.addchild(Literal(message_text, CHARACTER_TYPE))
print_call.addchild(Literal(message_text, ScalarType.character_type()))
loop.parent.addchild(print_call, index=loop.position)

# Assign desired chunk size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@

from psyclone_tools import (redundant_computation_setval, colour_loops,
view_transformed_schedule)
from psyclone.transformations import (Dynamo0p3OMPLoopTrans,
OMPParallelTrans)

from psyclone.psyir.transformations import OMPParallelTrans
from psyclone.transformations import LFRicOMPLoopTrans
from psyclone.psyGen import InvokeSchedule


Expand All @@ -40,7 +41,7 @@ def trans(psyir):
# casim_kernel_type or as psyclone knows is in it's representaion
# invoke_1_casim_kernel_type

otrans = Dynamo0p3OMPLoopTrans()
otrans = LFRicOMPLoopTrans()
oregtrans = OMPParallelTrans()

# Loop over all the InvokeSchedule in the PSyIR object
Expand Down
Loading
Loading