Skip to content

Commit

Permalink
Merge branch 'master' into 2392_split_+_rename_DynKernMetadata
Browse files Browse the repository at this point in the history
  • Loading branch information
mo-lottieturner authored Dec 11, 2023
2 parents 0614f59 + 0ff8992 commit cc1d237
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 22 deletions.
2 changes: 2 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@

32) PR #2400 for #1508. Add flag/config option to disable backend checks.

33) PR #2428 for #2427. Fixes bug in MaxVal2LoopTrans.

release 2.4.0 29th of September 2023

1) PR #1758 for #1741. Splits the PSyData read functionality into a
Expand Down
Binary file modified psyclone.pdf
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
better than the intrinsic.
'''
from psyclone.psyir.nodes import Reference, IntrinsicCall
from psyclone.psyir.nodes import Reference, IntrinsicCall, UnaryOperation
from psyclone.psyir.transformations.intrinsics.array_reduction_base_trans \
import ArrayReductionBaseTrans

Expand All @@ -63,7 +63,7 @@ class Maxval2LoopTrans(ArrayReductionBaseTrans):
.. code-block:: fortran
R = TINY(R)
R = -HUGE(R)
DO J=LBOUND(ARRAY,2),UBOUND(ARRAY,2)
DO I=LBOUND(ARRAY,1),UBOUND(ARRAY,1)
R = MAX(R, ARRAY(I,J))
Expand All @@ -80,7 +80,7 @@ class Maxval2LoopTrans(ArrayReductionBaseTrans):
.. code-block:: fortran
R = TINY(R)
R = -HUGE(R)
DO J=LBOUND(ARRAY,2),UBOUND(ARRAY,2)
DO I=LBOUND(ARRAY,1),UBOUND(ARRAY,1)
IF (MOD(ARRAY(I,J), 2.0)==1) THEN
Expand Down Expand Up @@ -124,7 +124,7 @@ class Maxval2LoopTrans(ArrayReductionBaseTrans):
integer :: idx
integer :: idx_1
<BLANKLINE>
result = TINY(result)
result = -HUGE(result)
do idx = 1, 10, 1
do idx_1 = 1, 10, 1
result = MAX(result, array(idx_1,idx))
Expand Down Expand Up @@ -166,5 +166,7 @@ def _init_var(self, var_symbol):
:rtype: :py:class:`psyclone.psyir.nodes.IntrinsicCall`
'''
return IntrinsicCall.create(
IntrinsicCall.Intrinsic.TINY, [Reference(var_symbol)])
# Return -HUGE()
huge = IntrinsicCall.create(
IntrinsicCall.Intrinsic.HUGE, [Reference(var_symbol)])
return UnaryOperation.create(UnaryOperation.Operator.MINUS, huge)
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def test_apply(idim1, idim2, rdim11, rdim12, rdim21, rdim22,
f" result = maxval(array)\n"
f"end subroutine\n")
expected = (
f" result = TINY(result)\n"
f" result = -HUGE(result)\n"
f" do idx = {rdim21}, {rdim22}, 1\n"
f" do idx_1 = {rdim11}, {rdim12}, 1\n"
f" result = MAX(result, array(idx_1,idx))\n"
Expand Down Expand Up @@ -295,7 +295,7 @@ def test_apply_multi(fortran_reader, fortran_writer, tmpdir):
" result = value1 + maxval(array) * value2\n"
"end subroutine\n")
expected = (
" result = TINY(result)\n"
" result = -HUGE(result)\n"
" do idx = 1, m, 1\n"
" do idx_1 = 1, n, 1\n"
" result = MAX(result, array(idx_1,idx))\n"
Expand Down Expand Up @@ -349,7 +349,7 @@ def test_mask(fortran_reader, fortran_writer, tmpdir):
" result = maxval(array, mask=MOD(array, 2.0)==1)\n"
"end program\n")
expected = (
" result = TINY(result)\n"
" result = -HUGE(result)\n"
" do idx = 1, 10, 1\n"
" do idx_1 = 1, 10, 1\n"
" if (MOD(array(idx_1,idx), 2.0) == 1) then\n"
Expand Down Expand Up @@ -385,7 +385,7 @@ def test_mask_array_indexed(fortran_reader, fortran_writer, tmpdir):
" result = maxval(a, mask=a(1)>a)\n"
"end program\n")
expected = (
" result = TINY(result)\n"
" result = -HUGE(result)\n"
" do idx = 1, 4, 1\n"
" if (a(1) > a(idx)) then\n"
" result = MAX(result, a(idx))\n"
Expand Down Expand Up @@ -418,7 +418,7 @@ def test_allocate(fortran_reader, fortran_writer, tmpdir):
"end program\n")
expected = (
" ALLOCATE(a(1:4,1:4,1:4))\n"
" result = TINY(result)\n"
" result = -HUGE(result)\n"
" do idx = LBOUND(a, dim=3), UBOUND(a, dim=3), 1\n"
" do idx_1 = LBOUND(a, dim=2), UBOUND(a, dim=2), 1\n"
" do idx_2 = LBOUND(a, dim=1), UBOUND(a, dim=1), 1\n"
Expand Down Expand Up @@ -452,7 +452,7 @@ def test_references(fortran_reader, fortran_writer, tmpdir):
"zmax(1) = MAXVAL(ABS(sshn + ssh_ref * tmask), mask=tmask==1.0)\n"
"end subroutine\n")
expected = (
" zmax(1) = TINY(zmax)\n"
" zmax(1) = -HUGE(zmax)\n"
" do idx = 1, 10, 1\n"
" do idx_1 = 1, 10, 1\n"
" if (tmask(idx_1,idx) == 1.0) then\n"
Expand Down Expand Up @@ -481,7 +481,7 @@ def test_nemo_example(fortran_reader, fortran_writer, tmpdir):
"zmax(1) = MAXVAL(ABS(sshn(:,:) + ssh_ref * tmask(:,:,1)))\n"
"end subroutine\n")
expected = (
" zmax(1) = TINY(zmax)\n"
" zmax(1) = -HUGE(zmax)\n"
" do idx = LBOUND(sshn, dim=2), UBOUND(sshn, dim=2), 1\n"
" do idx_1 = LBOUND(sshn, dim=1), UBOUND(sshn, dim=1), 1\n"
" zmax(1) = MAX(zmax(1), ABS(sshn(idx_1,idx) + ssh_ref * "
Expand Down Expand Up @@ -510,7 +510,7 @@ def test_constant_dims(fortran_reader, fortran_writer, tmpdir):
"x = maxval(a(:,1)+b(10,:), mask=c(:)==1.0)\n"
"end subroutine\n")
expected = (
" x = TINY(x)\n"
" x = -HUGE(x)\n"
" do idx = LBOUND(a, dim=1), UBOUND(a, dim=1), 1\n"
" if (c(idx) == 1.0) then\n"
" x = MAX(x, a(idx,1) + b(10,idx))\n"
Expand Down Expand Up @@ -543,7 +543,7 @@ def test_expression_1d(fortran_reader, fortran_writer, tmpdir):
" real, dimension(10) :: b\n"
" real :: x\n"
" integer :: idx\n\n"
" x = TINY(x)\n"
" x = -HUGE(x)\n"
" do idx = LBOUND(a, dim=1), UBOUND(a, dim=1), 1\n"
" x = MAX(x, a(idx) + b(idx))\n"
" enddo\n\n"
Expand Down Expand Up @@ -576,7 +576,7 @@ def test_expression_3d(fortran_reader, fortran_writer, tmpdir):
" integer :: idx\n"
" integer :: idx_1\n"
" integer :: idx_2\n\n"
" x = TINY(x)\n"
" x = -HUGE(x)\n"
" do idx = LBOUND(a, dim=3), UBOUND(a, dim=3), 1\n"
" do idx_1 = LBOUND(a, dim=2), UBOUND(a, dim=2), 1\n"
" do idx_2 = LBOUND(a, dim=1), UBOUND(a, dim=1), 1\n"
Expand Down Expand Up @@ -607,7 +607,7 @@ def test_multi_intrinsics(fortran_reader, fortran_writer, tmpdir):
"x = maxval(a(:)) + maxval(b(:))\n"
"end subroutine\n")
expected = (
" x = TINY(x)\n"
" x = -HUGE(x)\n"
" do idx = LBOUND(a, dim=1), UBOUND(a, dim=1), 1\n"
" x = MAX(x, a(idx))\n"
" enddo\n"
Expand All @@ -634,7 +634,7 @@ def test_increment(fortran_reader, fortran_writer, tmpdir):
"x = x + maxval(a)\n"
"end subroutine\n")
expected = (
" tmp_var = TINY(tmp_var)\n"
" tmp_var = -HUGE(tmp_var)\n"
" do idx = 1, 10, 1\n"
" tmp_var = MAX(tmp_var, a(idx))\n"
" enddo\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ def test_init_var():
trans = Maxval2LoopTrans()
var_symbol = DataSymbol("var", REAL_TYPE)
result = trans._init_var(var_symbol)
# As 'tiny' is not yet part of an expression, the 'debug_string()'
# method incorrectly assumes it is a call.
assert result.debug_string() == "call TINY(var)\n"
assert result.debug_string() == "-HUGE(var)"


def test_str():
Expand Down Expand Up @@ -125,7 +123,7 @@ def test_apply(fortran_reader, fortran_writer, tmpdir):
" real :: result\n"
" integer :: idx\n"
" integer :: idx_1\n\n"
" result = TINY(result)\n"
" result = -HUGE(result)\n"
" do idx = 1, 20, 1\n"
" do idx_1 = 1, 10, 1\n"
" result = MAX(result, array(idx_1,idx))\n"
Expand Down

0 comments on commit cc1d237

Please sign in to comment.