Skip to content
Merged
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
5 changes: 4 additions & 1 deletion changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
9) PR #3406 for # 3406. Fix issue with comment before a subroutine that
10) PR #3413 for #3411. Remove OpenMP SUB reduction operator and relpace
with ADD as is required by OpenMP 5.2.

9) PR #3406 for #3406. Fix issue with comment before a subroutine that
turns into a CodeBlock.

8) PR #3371 towards #3012. Add workaround to bypass psyclonefc fixed-from
Expand Down
1 change: 0 additions & 1 deletion src/psyclone/psyir/backend/fortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -1636,7 +1636,6 @@ def operatorclause_node(self, node):
OMPDependClause.DependClauseTypes.OUT: "out",
OMPDependClause.DependClauseTypes.INOUT: "inout",
OMPReductionClause.ReductionClauseTypes.ADD: "+",
OMPReductionClause.ReductionClauseTypes.SUB: "-",
OMPReductionClause.ReductionClauseTypes.MUL: "*",
OMPReductionClause.ReductionClauseTypes.AND: ".AND.",
OMPReductionClause.ReductionClauseTypes.OR: ".OR.",
Expand Down
21 changes: 10 additions & 11 deletions src/psyclone/psyir/nodes/omp_clauses.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,19 +508,18 @@ class ReductionClauseTypes(Enum):
supported in PSyclone.'''
# Arithmetic operators
ADD = 0
SUB = 1
MUL = 2
MUL = 1
# Logical operators
AND = 3
OR = 4
EQV = 5 # Fortran specific
NEQV = 6 # Fortran specific
AND = 2
OR = 3
EQV = 4 # Fortran specific
NEQV = 5 # Fortran specific
# Intrinsic procedures
MAX = 7
MIN = 8
IAND = 9
IOR = 10
IEOR = 11
MAX = 6
MIN = 7
IAND = 8
IOR = 9
IEOR = 10

def __init__(self, operator: ReductionClauseTypes, **kwargs):
if not isinstance(operator, OMPReductionClause.ReductionClauseTypes):
Expand Down
3 changes: 2 additions & 1 deletion src/psyclone/psyir/nodes/omp_directives.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@
MAP_REDUCTION_OP_TO_OMP = {
BinaryOperation.Operator.ADD:
OMPReductionClause.ReductionClauseTypes.ADD,
# From OpenMP 5.2 the - reduction is not supported, use + instead
BinaryOperation.Operator.SUB:
OMPReductionClause.ReductionClauseTypes.SUB,
OMPReductionClause.ReductionClauseTypes.ADD,
BinaryOperation.Operator.MUL:
OMPReductionClause.ReductionClauseTypes.MUL,
BinaryOperation.Operator.AND:
Expand Down
3 changes: 3 additions & 0 deletions src/psyclone/tests/psyir/nodes/omp_directives_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4871,6 +4871,9 @@ def test_reduction_arith_ops(op, fortran_reader, fortran_writer):
loop = psyir.walk(Loop)[0]
omplooptrans.apply(loop, enable_reductions=True)
output = fortran_writer(psyir)
# The + and - operators are equivalent, from OpenMP 5.2 the - is deprecated
if op == "-":
op = "+"
assert f"reduction({op}: acc)" in output


Expand Down
Loading