Disable script application to only iom_put#3429
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3429 +/- ##
=======================================
Coverage 99.96% 99.96%
=======================================
Files 391 391
Lines 54609 54674 +65
=======================================
+ Hits 54590 54655 +65
Misses 19 19 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Some failures after this change can be resolved with a change to reference2arrayrange_trans: instead of |
|
I'm trying building today and it just seems to work, I will test full integration and see if any others fail. |
|
From discussion with sergi the previous direction has potential to produce incorrect code. Instead we should change operation order:
|
We don't have metatransformation support yet for this, but I'll make an issue for this as well. |
…ay reduction base trans. Testing NYI
|
@sergisiso I think this is ready for a first look now. |
sergisiso
left a comment
There was a problem hiding this comment.
Thanks @LonelyCat124, its good to see it has passed all integration tests without making it exclusive for iom_put. Just some extra clarifications and testing needed.
| except Exception as err: | ||
| print(reference, reference.parent.parent.debug_string()) | ||
| raise err |
There was a problem hiding this comment.
What happens here? Is this a leftover?
There was a problem hiding this comment.
Yeah this was debugging.
| # TODO #3412: This is currently limited to iom_put, we want to expand it | ||
| # throughout the code | ||
| if hoist_argument_expressions: | ||
| iom_put_argument_to_temporary(schedule.walk(Call)) |
There was a problem hiding this comment.
This is now no longer limited to iom_put right? So the TODO can be removed and the method name updated?
| DataNodeToTempTrans().apply(arg, verbose=True) | ||
| except TransformationError: | ||
| pass | ||
| # if call.symbol.name == "iom_put": |
| if (isinstance(dtype.elemental_type, ScalarType) | ||
| and dtype.elemental_type.intrinsic == | ||
| ScalarType.Intrinsic.CHARACTER): | ||
| continue |
There was a problem hiding this comment.
Is this an issue with the transformation? I am wondering if it should be inside the validation instead?
There was a problem hiding this comment.
I'm not sure - the transformation does it successfully but there was some error, I don't remember whether compiler or elsewhere in PSyclone. I can have a further look if you want, I just decided to skip it here for strings (not sure if there would be some other valid use case?)
| if (isinstance(dtype, ArrayType) and | ||
| (isinstance(arg, Operation) or | ||
| isinstance(arg, IntrinsicCall))): |
There was a problem hiding this comment.
Maybe a comment explaining the condition: "Only extract expressions that can potentially be loopyfied (e.g. operations over arrays)"
| def test_nemo5_transerror_case(fortran_reader): | ||
| '''Test that the transformation fails correctly if we have nested sums | ||
| as the reference can't be converted to an arrayreference.''' |
There was a problem hiding this comment.
Can you change the name and description of the test to make it generic about the problem tested here, e.g. "the array reference is inside a non-elemental function and therefore won't be converted"?
| integer :: n, m | ||
| real , dimension(:, :) :: array | ||
|
|
||
| result = sum(sum(array, dim=2)) * array(n,m) |
There was a problem hiding this comment.
Since the validation counts ArrayReference, maybe test that expressions with other arrays like:
sum(sum(array + array(:,:), dim=2))
or
sum(sum(array, dim=dimensions(2)))
work as expected.
There was a problem hiding this comment.
So the first one already doesn't work as expected.
code = """subroutine sum_test()
integer :: n, m
real, dimension(:, :) :: array
result = sum(sum(array + array(:,:), dim=2))
end subroutine"""
psyir = fortran_reader.psyir_from_source(code)
intrinsic_node = psyir.children[0].children[0].rhs
trans = Sum2LoopTrans()
with pytest.raises(TransformationError) as err:
trans.apply(intrinsic_node)
print(fortran_writer(psyir))
print(err.value)
assert False
This outputs an error message on the fortran_writer stage, and the err.value is also different (if it were reached):
E psyclone.psyir.backend.visitor.VisitorError: Visitor Error: The following symbols are not explicitly declared or imported from a module and there are no wildcard imports which could be bringing them into scope: 'result'
and
Transformation Error: ArrayAssignment2LoopsTrans could not convert the expression:
array(:,:) = SUM(array(:,:) + array(:,:), 2)
into a loop because:
Transformation Error: ArrayAssignment2LoopsTrans does not support statements containing dependencies that would generate loop-carried dependencies when naively converting them to a loop, but found:
array(:,:) = SUM(array(:,:) + array(:,:), 2)
I'm not sure if this is the right place to fix this - I can make some xfailing tests and an issue?
There was a problem hiding this comment.
@sergisiso I've addressed the other comments but this one is still open if you have any time to let me know how to proceed before another full review.
There was a problem hiding this comment.
Both errors seem correct:
- result is not declared in the example
- And TransformationErrors are fine, what we don't want is to validate and then generate incorrect code.
So I would say no xfail needed?
There was a problem hiding this comment.
Ah thats my mistake in the example, I was concerned the resulting code may be changed but I still get the input so thats fine. I'll check the other example you suggested as well.
There was a problem hiding this comment.
I tested the other examples - the error messages are different, but the transformation does fail as expected.
| dtrans.apply(assign.rhs.operands[1]) | ||
| # Check the tmp symbol is at the routine scope. | ||
| routine = psyir.walk(Routine)[0] | ||
| assert routine.symbol_table.lookup("tmp") is not None |
There was a problem hiding this comment.
assert "tmp" in routine.symbol_table ?
No description provided.