This is an archive of the discontinued LLVM Phabricator instance.

[Fortran/UnitTests] add 10 type finalization unit tests
ClosedPublic

Authored by zbeekman on Apr 7 2023, 12:26 PM.

Details

Summary

This suite of tests was created originally by Wileam Phan, Damian Rouson,
and Brad Richardson as part of the Smart-Pointers library's test suite.

The original adaptation for inclusion in the llvm-test-suite can be found here:

The test suite was then adapted to be made appropriate for inclusion
in a compiler test suite by Izaak Beekman.

A summary of the tests can be found in the README.md file added in the
Fortran/UnitTests/finalization subdirectory.

Co-Authored-by: Damian Rouson <rouson@lbl.gov>

Diff Detail

Repository
rT test-suite

Event Timeline

zbeekman created this revision.Apr 7 2023, 12:26 PM
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: jdoerfert. · View Herald Transcript
zbeekman requested review of this revision.Apr 7 2023, 12:26 PM
clementval added inline comments.Apr 7 2023, 12:32 PM
Fortran/UnitTests/finalization/README.md
156–165

Is this the actual status for flang? I'm confused because on the PR you mentioned all tests were passing.

Shoot, yes I need to update this.

zbeekman updated this revision to Diff 513361.Apr 13 2023, 2:23 PM

I have now updated the README.md file to reflect LLVM-flan's current status: All tests are passing.

clementval accepted this revision.Apr 13 2023, 2:31 PM

LGTM but I was not really involved with the Fortran test suite integration so it would be good to have a reviewer to accept it before landing.

Is there any plan to increase the coverage of the finalization tests? I remember that couple of cases are not tested currently like finalization of polymorphic entities or finalization on automatic deallocation.

This revision is now accepted and ready to land.Apr 13 2023, 2:31 PM

LGTM but I was not really involved with the Fortran test suite integration so it would be good to have a reviewer to accept it before landing.

Great! I looked at git blame to try to suggest who might make a good reviewer, only one name came up though. I added them when initially submitting the patch to phabricator, but I'm not sure how to go about getting another reviewer to take a look. I can try asking on the flang slack tomorrow if that would help.

Is there any plan to increase the coverage of the finalization tests? I remember that couple of cases are not tested currently like finalization of polymorphic entities or finalization on automatic deallocation.

Within the scope of the present work there is not currently a plan to add additional finalization tests, as far as I know. I will touch base with Damian Rouson and report back, however I think we should assume that this work is complete (pending any further reviewer feedback) and table the addition of further finalization tests for the future.

Within the scope of the present work there is not currently a plan to add additional finalization tests, as far as I know. I will touch base with Damian Rouson and report back, however I think we should assume that this work is complete (pending any further reviewer feedback) and table the addition of further finalization tests for the future.

Any additional tests can be added later. No need to change this patch.

Tested on AArch64 and everything passes with llvm-flang. I have a couple of comments regarding other compilers.

Fortran/UnitTests/finalization/README.md
15

Could you add the Arm Compiler as well? It is available from https://developer.arm.com/downloads/-/arm-compiler-for-linux.

I see the following passes:
PASS: test-suite :: Fortran/UnitTests/finalization/finalize_on_deallocate.test (5 of 192)
PASS: test-suite :: Fortran/UnitTests/finalization/rhs_function_reference.test (72 of 192)
PASS: test-suite :: Fortran/UnitTests/finalization/lhs_object.test (114 of 192)
PASS: test-suite :: Fortran/UnitTests/finalization/allocatable_component.test (115 of 192)
PASS: test-suite :: Fortran/UnitTests/finalization/target_deallocation.test (137 of 192)
PASS: test-suite :: Fortran/UnitTests/finalization/block_end.test (182 of 192)
PASS: test-suite :: Fortran/UnitTests/finalization/finalize_on_end.test (184 of 192)

and the following failures:

test-suite :: Fortran/UnitTests/finalization/allocated_allocatable_lhs.test
test-suite :: Fortran/UnitTests/finalization/intent_out.test
test-suite :: Fortran/UnitTests/finalization/specification_expression_finalization.test

I guess one of the failures is due to the error message mismatch (i.e Fortran ERROR STOP vs ERROR STOP).

145–148

The AMD compiler uses the Classic Flang frontend (https://github.com/flang-compiler/flang) that the Arm compiler uses. Hence I am surprised that everything fails here.

Fortran/UnitTests/finalization/specification_expression_finalization.reference_output
1 ↗(On Diff #513361)

Isn't the Fortran prefix specific to llvm/flang ? This would cause other compilers to mismatch this output. Is it possible to remove the Fortran prefix ?

kiranchandramohan requested changes to this revision.Apr 17 2023, 6:16 AM

Having the same module name object_type_m compiling in the same directory from different files is problematic, since the module file contents can be overwritten. Is it possible to either rename the modules in different files or have a common module compiling only once?

This revision now requires changes to proceed.Apr 17 2023, 6:16 AM

Having the same module name object_type_m compiling in the same directory from different files is problematic, since the module file contents can be overwritten. Is it possible to either rename the modules in different files or have a common module compiling only once?

Ah, yes, I temporarily forgot about this CMake idiosyncrasy: There is a race condition when compiling/producing the same module .mod file in parallel. To keep things simple is it OK if I continue to use the same approach (with include "object_type_m.f90") to inject common code at the top of each source file, but then give the module a unique name by declaring the module with module <test_name_m> so each test has a unique module? Or I could just eliminate the common code that gets included and retype it as a unique module in the source file for each test. What is your preference?

zbeekman marked an inline comment as done.Apr 20 2023, 10:02 AM

@clementval and @kiranchandramohan What do you think of my proposed approach outlined in the inlined comments and the comment I just added above responding to @kiranchandramohan?

I don't have access to all the compilers listed in the README and the support info per-compiler will get stale as new versions are released. Is it even worth including this information in the README? Maybe I should just get rid of the README. What do you think?

Thanks,
Zaak

Fortran/UnitTests/finalization/README.md
15

I will add this to the README.

145–148

Yeah, these are also out of date. I don't have access to the compiler at the moment to update it. If you want to run the tests I would be happy to report your findings in the README.

Fortran/UnitTests/finalization/object_type_m.f90
2

I will give this module a unique name based on the test name. Is it OK if I continue to keep common code in a file that gets included? Or should I inline the entire module with a unique name in each test, copying the common code by hand?

Fortran/UnitTests/finalization/specification_expression_finalization.reference_output
1 ↗(On Diff #513361)

The only obvious way I can think of to accomplish this is to use CMake to configure the specification_expression_finalization.reference_output file based on the detected CMAKE_Fortran_COMPILER_ID. Would this be an acceptable approach?

@clementval and @kiranchandramohan What do you think of my proposed approach outlined in the inlined comments and the comment I just added above responding to @kiranchandramohan?

I don't have access to all the compilers listed in the README and the support info per-compiler will get stale as new versions are released. Is it even worth including this information in the README? Maybe I should just get rid of the README. What do you think?

Thanks,
Zaak

The README is not necessary for me. At least the different results. It would make sense if it was updated regularly but we know that it will fall behind quickly.

@clementval and @kiranchandramohan What do you think of my proposed approach outlined in the inlined comments and the comment I just added above responding to @kiranchandramohan?

I don't have access to all the compilers listed in the README and the support info per-compiler will get stale as new versions are released. Is it even worth including this information in the README? Maybe I should just get rid of the README. What do you think?

Thanks,
Zaak

The README is not necessary for me. At least the different results. It would make sense if it was updated regularly but we know that it will fall behind quickly.

Yes, I think we can skip reporting on the status of various compilers. The Readme can contain a summary of the tests with a reference to the section in the standard.

Please add more details about the tests to the commit message or Summary.
Please add Damian as co-author by using the following format in the commit message or Summary.
Co-Authored-by: Damian Rouson <rouson@lbl.gov>

Fortran/UnitTests/finalization/object_type_m.f90
2

Do you mean that you move the line module object_type_m to the test files and rename it there and this file will only contain the contents of the module or its common part? Then that sounds fine to me.

Fortran/UnitTests/finalization/specification_expression_finalization.reference_output
1 ↗(On Diff #513361)

Sounds OK to me. If this proves to be difficult then you skip this for the first patch.

I have made the requested changes and am uploading the patch now.

Fortran/UnitTests/finalization/object_type_m.f90
2

Yes

Fortran/UnitTests/finalization/specification_expression_finalization.reference_output
1 ↗(On Diff #513361)

I have used cmake's configure_file() to accomplish this. It seems that the testing infrastructure expects a *.reference_output file in the source tree so *.reference_output.in gets configured by CMake to inject the leading "Fortran " when CMAKE_Fortran_COMPILER_ID matches LLVMFlang and the result (*.reference_output) gets placed in the source tree. I've added a .gitignore file so that it's not accidentally committed to the repository at a later date. I tried having the configured file put directly into the CMAKE_CURRENT_BINARY_DIR but the test infrastructure complained that it couldn't find a corresponding *.reference_output in the source tree.

zbeekman updated this revision to Diff 519165.May 3 2023, 10:49 AM
zbeekman retitled this revision from Fortran Finalization tests added to llvm to [Fortran/UnitTests] add 10 type finalization unit tests.
zbeekman edited the summary of this revision. (Show Details)
  • Overhauled the README
  • Configured the specification expression reference output to only include the leading Fortran when the CMAKE_Fortran_COMPILER_ID matches LLVMFlang (other compilers don't have this text in their error stop statements)
  • Ensured that parallel builds won't fail due to a CMake race condition when multiple .mod module files with the same name are produced (each test now has a unique module name).

@kiranchandramohan

I think I've addressed all of your points. I'm new to phabricator--does the commit message come from the summary that I type in? Please let me know how this looks. It would be great to land this patch soon.

Thanks,
Zaak

@clementval and @kiranchandramohan What do you think of my proposed approach outlined in the inlined comments and the comment I just added above responding to @kiranchandramohan?

I don't have access to all the compilers listed in the README and the support info per-compiler will get stale as new versions are released. Is it even worth including this information in the README? Maybe I should just get rid of the README. What do you think?

Thanks,
Zaak

The README is not necessary for me. At least the different results. It would make sense if it was updated regularly but we know that it will fall behind quickly.

Yes, I think we can skip reporting on the status of various compilers. The Readme can contain a summary of the tests with a reference to the section in the standard.

Please add more details about the tests to the commit message or Summary.
Please add Damian as co-author by using the following format in the commit message or Summary.
Co-Authored-by: Damian Rouson <rouson@lbl.gov>

rouson edited the summary of this revision. (Show Details)May 3 2023, 11:53 AM
kiranchandramohan accepted this revision.May 3 2023, 4:14 PM

@kiranchandramohan

I think I've addressed all of your points. I'm new to phabricator--does the commit message come from the summary that I type in? Please let me know how this looks. It would be great to land this patch soon.

Thanks,
Zaak

Thanks for making the changes.

Yes, the commit message comes from the summary if you fetch the patch using arc patch D147804. At the moment, the summary is quite big. Given that the info is contained in the Readme, you could consider shortening it.

I think the ERROR STOP issue is probably not fully solved. See inline for concern. But as I said in my previous reply, this is not important for a first patch. So you may choose to skip this.

LGTM.

Fortran/UnitTests/finalization/CMakeLists.txt
12

Gfortran error stop:
ERROR STOP finalize: intentional error termination to verify finalization
Classic Flang error stop:
ERROR STOP finalize: intentional error termination to verify finalization
llvm/flang error stop:
Fortran ERROR STOP: finalize: intentional error termination to verify finalization

As can be seen from the above, Flang also adds a colon after STOP. So not sure whether this will work fine for other compilers.

This revision is now accepted and ready to land.May 3 2023, 4:14 PM
zbeekman updated this revision to Diff 519841.May 5 2023, 6:45 AM
zbeekman marked an inline comment as done.
zbeekman edited the summary of this revision. (Show Details)

@kiranchandramohan @clementval I tweaked the configured test reference output so that the colon is also inject when LLVMFlang is detected but omitted otherwise. I have also shortened the commit message. Damian also pointed out that the NAG compiler was initially passing all of tests and amended the readme/commit message to reflect this.

I do not believe I have push access. If you approve these final changes please let me know what needs to happen next to land the patch.

Thanks!

@kiranchandramohan @clementval I tweaked the configured test reference output so that the colon is also inject when LLVMFlang is detected but omitted otherwise. I have also shortened the commit message. Damian also pointed out that the NAG compiler was initially passing all of tests and amended the readme/commit message to reflect this.

I do not believe I have push access. If you approve these final changes please let me know what needs to happen next to land the patch.

Thanks!

@tarunprabhu Could you help with this?

zbeekman edited the summary of this revision. (Show Details)May 5 2023, 9:28 AM

@tarunprabhu Could you help with this?

Sure.

@zbeekman, should I just use the patch summary as-is for the commit message or did you have anything else in mind?

zbeekman added a comment.EditedMay 8 2023, 9:22 AM

@tarunprabhu Could you help with this?

Sure.

@zbeekman, should I just use the patch summary as-is for the commit message or did you have anything else in mind?

@tarunprabhu I'm happy with the patch summary as-is for the commit message. LMK if there's anything else I can//should do to get this wrapped up and merged.

zbeekman added inline comments.May 8 2023, 11:59 AM
Fortran/UnitTests/finalization/CMakeLists.txt
22

@kiranchandramohan @tarunprabhu @clementval I just noticed this duplicate line can be deleted. Should I updated the patch or can you do that while merging?

tarunprabhu added inline comments.May 8 2023, 12:06 PM
Fortran/UnitTests/finalization/CMakeLists.txt
22

Please update the patch. It may be minor, but it's probably better to not have discrepancies between what is reviewed and what gets merged.

zbeekman updated this revision to Diff 520465.May 8 2023, 12:34 PM
zbeekman marked an inline comment as done.
zbeekman added inline comments.
Fortran/UnitTests/finalization/CMakeLists.txt
22
This revision was automatically updated to reflect the committed changes.