This is an archive of the discontinued LLVM Phabricator instance.

[Fortran] Ignore whitespace in FCVS test results
ClosedPublic

Authored by rovka on Jun 21 2022, 5:14 AM.

Details

Summary

Some tests in the FCVS suite use list-directed output, which may
according to the standard introduce arbitrary amounts of whitespace.
This patch adds the "-i" flag to the fpcmp invocation for those tests,
so that it ignores whitespace. The other tests in the suite will
continue to check whitespace strictly.

Diff Detail

Repository
rT test-suite

Event Timeline

rovka created this revision.Jun 21 2022, 5:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 21 2022, 5:14 AM
rovka requested review of this revision.Jun 21 2022, 5:14 AM

Looks OK. Assuming there are no tests that explicitly check for spacing. What is FPCMP usually set to?

rovka added a comment.EditedJun 22 2022, 4:32 AM

Looks OK. Assuming there are no tests that explicitly check for spacing. What is FPCMP usually set to?

I think it is usually set to fpcmp-target, which is built from this source.

I don't know what to say about the spacing. FCVS uses a mix of formatted and list-directed output. If we choose to care about the spacing we should probably move away from list-directed output. I'm not sure how much work that would be.

EDIT: Only FM905 and FM907 use list-directed output. I'll try to migrate them to formatted output.

rovka edited the summary of this revision. (Show Details)Jun 23 2022, 1:20 AM

@rovka Would you know what is the scope of the llvm-testsuite? Is it limited to flang, or is it flang+gfortran, or is it any fortran compiler? And is it possible to have multiple outputs for comparison as @clementval mentioned?

rovka added a comment.Jun 23 2022, 2:06 AM

@rovka Would you know what is the scope of the llvm-testsuite? Is it limited to flang, or is it flang+gfortran, or is it any fortran compiler? And is it possible to have multiple outputs for comparison as @clementval mentioned?

It's not limited to a specific compiler, it "should work" with any compiler. We're currently running it on one of the buildbots with flang-to-external-fc, and I'd like to switch it to use flang-new instead. However, I think it's valuable to be able to run with both flang and gfortran, so we can easily compare/debug things.
At the moment I'm not aware of a way to add multiple outputs for comparison, I don't see that in any of the suites included (but I could be missing something).

rovka added a comment.Jun 23 2022, 2:32 AM

One thing that we could do is to only enable whitespace for the 2 tests that use list-directed output. That's going to require a bit more effort in the CMakeLists.txt, but it would let us be strict about whitespace where specific formatting is used, and more relaxed where it isn't.

One thing that we could do is to only enable whitespace for the 2 tests that use list-directed output. That's going to require a bit more effort in the CMakeLists.txt, but it would let us be strict about whitespace where specific formatting is used, and more relaxed where it isn't.

That sounds fine to me.

And is it possible to have multiple outputs for comparison as @clementval mentioned?

I'm not too fond of the idea - that would require more bookkeeping and code to maintain. My preference would be to avoid this. Unless llvm-test-suite already has some logic for this (I'm not aware of such).

One thing that we could do is to only enable whitespace for the 2 tests that use list-directed output.

You meant "disable" , right?

Either approach sounds fine to me - I would also be happy with updating FM905 and FM907.

rovka updated this revision to Diff 439354.Jun 23 2022, 5:34 AM
rovka edited the summary of this revision. (Show Details)

Right, disable :)
Updated the patch to special-case FM905 and FM907. I think it doesn't hurt to leave a bit of list-directed output in the test suite just to make sure it doesn't randomly explode.

The patch application failed.
Do we need to update the README file with the change?

@rovka Would you know what is the scope of the llvm-testsuite? Is it limited to flang, or is it flang+gfortran, or is it any fortran compiler? And is it possible to have multiple outputs for comparison as @clementval mentioned?

It's not limited to a specific compiler, it "should work" with any compiler. We're currently running it on one of the buildbots with flang-to-external-fc, and I'd like to switch it to use flang-new instead. However, I think it's valuable to be able to run with both flang and gfortran, so we can easily compare/debug things.
At the moment I'm not aware of a way to add multiple outputs for comparison, I don't see that in any of the suites included (but I could be missing something).

Because there are a lot of things that are not standardised in Fortran, we might keep running into these issues. Since ifx/ifort also differs from flang/gfortran, the goal of working with any compiler is probably difficult to achieve in Fortran I think.

And is it possible to have multiple outputs for comparison as @clementval mentioned?

I'm not too fond of the idea - that would require more bookkeeping and code to maintain. My preference would be to avoid this. Unless llvm-test-suite already has some logic for this (I'm not aware of such).

Yes, it might not be worth the trouble if there is no existing support for this. Otherwise, the changes will be localised to the reference file.

cmake/modules/SingleMultiSource.cmake
108–117

I am not pushing for this option. But this bit here seems to allow for reference output based on TARGET, ENDIAN-NESS etc.

rovka set the repository for this revision to rT test-suite.Jun 27 2022, 1:14 AM
rovka updated this revision to Diff 440121.Jun 27 2022, 1:33 AM

Try to fix CI patch application.

rovka updated this revision to Diff 440129.Jun 27 2022, 1:50 AM
rovka set the repository for this revision to rT test-suite.

Try to fix CI patch application - take 2.

rovka added a comment.Jun 27 2022, 2:00 AM

The patch application failed.

Right, not sure why it doesn't find those files, I'll try a few things...

Do we need to update the README file with the change?

I don't think so, since this doesn't affect the FCVS files themselves.

@rovka Would you know what is the scope of the llvm-testsuite? Is it limited to flang, or is it flang+gfortran, or is it any fortran compiler? And is it possible to have multiple outputs for comparison as @clementval mentioned?

It's not limited to a specific compiler, it "should work" with any compiler. We're currently running it on one of the buildbots with flang-to-external-fc, and I'd like to switch it to use flang-new instead. However, I think it's valuable to be able to run with both flang and gfortran, so we can easily compare/debug things.
At the moment I'm not aware of a way to add multiple outputs for comparison, I don't see that in any of the suites included (but I could be missing something).

Because there are a lot of things that are not standardised in Fortran, we might keep running into these issues. Since ifx/ifort also differs from flang/gfortran, the goal of working with any compiler is probably difficult to achieve in Fortran I think.

And is it possible to have multiple outputs for comparison as @clementval mentioned?

I'm not too fond of the idea - that would require more bookkeeping and code to maintain. My preference would be to avoid this. Unless llvm-test-suite already has some logic for this (I'm not aware of such).

Yes, it might not be worth the trouble if there is no existing support for this. Otherwise, the changes will be localised to the reference file.

cmake/modules/SingleMultiSource.cmake
108–117

Right, I guess we could add some logic here based on COMPILER_ID or something of the sort.

awarzynski added inline comments.Jun 27 2022, 3:31 AM
Fortran/UnitTests/fcvs21_f95/CMakeLists.txt
36–42

This is basically splitting the tests into 2 groups, which are processed independently. I think that it would help to have this highlighted a bit more. Perhaps something like this:

# GROUP 1:
# Tests 905 and 907 use list-directed output, for which the standard allows some flexibility with regards to how many white space characters to print. For these tests, we ignore whitespaces when comparing the output. 
set(SPECIAL_CASES "FM905.f" "FM907.f")
set(Source ${SPECIAL_CASES})

set(FP_IGNOREWHITESPACE ON)
llvm_singlesource()

# GROUP 2:
# Generic case.
set(Source)
cmake/modules/SingleMultiSource.cmake
108–117

+1 I'm OK to revisit this once it becomes a problem (as opposed to expanding this patch)

rovka updated this revision to Diff 440507.Jun 28 2022, 12:21 AM

Added more comments.
Hopefully the pre-merge CI will actually run this time...

Fortran/UnitTests/fcvs21_f95/CMakeLists.txt
36–42

Makes sense :)

cmake/modules/SingleMultiSource.cmake
108–117

Cool, thanks!

rovka updated this revision to Diff 440511.Jun 28 2022, 12:49 AM
rovka set the repository for this revision to rT test-suite.

No change, trying to convince the pre-merge to apply the patch...

awarzynski accepted this revision.EditedJun 28 2022, 3:05 AM

No change, trying to convince the pre-merge to apply the patch...

How confident are you that it should work? I mean, perhaps the pre-merge CI has not been configured correctly for llvm-test-suite? I've just tried arc patch D128260 and it worked fine for me locally. This looks like the pre-merge CI issue. Perhaps create a bug?

To me all this makes sense and hence approving as is, thanks! AFAIK, the only buildbots running these tests are managed by Linaro, so you will know if something is broken :)

EDIT Same issue with patch application: https://reviews.llvm.org/D126453 (this is quite recent)

This revision is now accepted and ready to land.Jun 28 2022, 3:05 AM

No change, trying to convince the pre-merge to apply the patch...

How confident are you that it should work? I mean, perhaps the pre-merge CI has not been configured correctly for llvm-test-suite? I've just tried arc patch D128260 and it worked fine for me locally. This looks like the pre-merge CI issue. Perhaps create a bug?

To me all this makes sense and hence approving as is, thanks! AFAIK, the only buildbots running these tests are managed by Linaro, so you will know if something is broken :)

Yep, I'll keep an eye out :)

EDIT Same issue with patch application: https://reviews.llvm.org/D126453 (this is quite recent)

This revision was automatically updated to reflect the committed changes.
rovka added a comment.EditedJun 29 2022, 12:49 AM

No change, trying to convince the pre-merge to apply the patch...

How confident are you that it should work? I mean, perhaps the pre-merge CI has not been configured correctly for llvm-test-suite? I've just tried arc patch D128260 and it worked fine for me locally. This looks like the pre-merge CI issue. Perhaps create a bug?

I commented on https://github.com/google/llvm-premerge-checks/issues/329