Skip to content

[Flang] Add new Integration tests directory to Flang #73141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 24, 2023

Conversation

TIFitis
Copy link
Member

@TIFitis TIFitis commented Nov 22, 2023

As per the RFC: https://discourse.llvm.org/t/rfc-flang-new-directory-for-adding-end-to-end-tests-for-lowering-to-llvm-ir-in-flang/74872/11, this patch adds a new Integration test directory for OpenMP- flang/test/Integration/OpenMP and moves the existing OpenMP integration tests from flang/test/Driver/OpenMP to this directory.

This directory can be used to add Integration tests involving multiple stages of the compiler (for eg. from Fortran to LLVM IR). It should not contain executable tests. We should only add tests here sparingly and only if there is no other way to test. Repeat this message in each test that is added to this directory and sub-directories.

@llvmbot llvmbot added flang Flang issues not falling into any other category flang:openmp labels Nov 22, 2023
@llvmbot
Copy link
Member

llvmbot commented Nov 22, 2023

@llvm/pr-subscribers-flang-driver

@llvm/pr-subscribers-flang-openmp

Author: Akash Banerjee (TIFitis)

Changes

As per the RFC: https://discourse.llvm.org/t/rfc-flang-new-directory-for-adding-end-to-end-tests-for-lowering-to-llvm-ir-in-flang/74872/11, this patch adds a new Integration test directory for OpenMP- flang/test/Integration/OpenMP and moves the existing OpenMP integration tests from flang/test/Driver/OpenMP to this directory.

The tests here are meant for end-to-end testing from Fortran code to llvm IR lowering.


Full diff: https://github.com/llvm/llvm-project/pull/73141.diff

3 Files Affected:

  • (renamed) flang/test/Integration/OpenMP/host-ir-flag.f90 ()
  • (renamed) flang/test/Integration/OpenMP/map-types-and-sizes.f90 ()
  • (added) flang/test/Integration/OpenMP/target-filtering.f90 (+61)
diff --git a/flang/test/Driver/OpenMP/host-ir-flag.f90 b/flang/test/Integration/OpenMP/host-ir-flag.f90
similarity index 100%
rename from flang/test/Driver/OpenMP/host-ir-flag.f90
rename to flang/test/Integration/OpenMP/host-ir-flag.f90
diff --git a/flang/test/Driver/OpenMP/map-types-and-sizes.f90 b/flang/test/Integration/OpenMP/map-types-and-sizes.f90
similarity index 100%
rename from flang/test/Driver/OpenMP/map-types-and-sizes.f90
rename to flang/test/Integration/OpenMP/map-types-and-sizes.f90
diff --git a/flang/test/Integration/OpenMP/target-filtering.f90 b/flang/test/Integration/OpenMP/target-filtering.f90
new file mode 100644
index 0000000000000000..5db5ade6c119bf52
--- /dev/null
+++ b/flang/test/Integration/OpenMP/target-filtering.f90
@@ -0,0 +1,61 @@
+!RUN: %flang_fc1 -emit-llvm -fopenmp %s -o - | FileCheck %s --check-prefixes HOST,ALL
+!RUN: %flang_fc1 -emit-llvm -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefixes DEVICE,ALL
+
+!HOST: define {{.*}}@{{.*}}before{{.*}}(
+!DEVICE-NOT: define {{.*}}@before{{.*}}(
+!DEVICE-NOT: declare {{.*}}@before{{.*}}
+integer function before(x)
+   integer, intent(in) :: x
+   before = x + 200
+end function
+
+!ALL: define {{.*}}@{{.*}}main{{.*}}(
+program main
+   integer :: x, before, after
+   !$omp target map(tofrom : x)
+      x = 100
+   !$omp end target
+   !HOST: call {{.*}}@{{.*}}before{{.*}}(
+   !DEVICE-NOT: call {{.*}}@before{{.*}}(
+   !HOST: call {{.*}}@{{.*}}after{{.*}}(
+   !DEVICE-NOT: call {{.*}}@after{{.*}}(
+   x = x + before(x) + after(x)
+end program
+
+!HOST: define {{.*}}@{{.*}}after{{.*}}(
+!DEVICE-NOT: define {{.*}}@after{{.*}}(
+!DEVICE-NOT: declare {{.*}}@after{{.*}}
+integer function after(x)
+   integer, intent(in) :: x
+   after = x + 300
+end function
+
+!ALL: define {{.*}}@{{.*}}before_target{{.*}}(
+subroutine before_target(x)
+   integer, intent(out) :: x
+   !$omp target map(from: x)
+      x = 1
+   !$omp end target
+end subroutine
+
+!ALL: define {{.*}}@{{.*}}middle{{.*}}(
+subroutine middle()
+   integer :: x
+   !$omp target map(from: x)
+      x = 0
+   !$omp end target
+   !HOST: call {{.*}}@{{.*}}before_target{{.*}}(
+   !DEVICE-NOT: call {{.*}}@{{.*}}before_target{{.*}}(
+   !HOST: call {{.*}}@{{.*}}after_target{{.*}}(
+   !DEVICE-NOT: call {{.*}}@{{.*}}after_target{{.*}}(
+   call before_target(x)
+   call after_target(x)
+end subroutine
+
+!ALL: define {{.*}}@{{.*}}after_target{{.*}}(
+subroutine after_target(x)
+   integer, intent(out) :: x
+   !$omp target map(from:x)
+      x = 2
+   !$omp end target
+end subroutine

@TIFitis TIFitis requested a review from skatrak November 22, 2023 16:01
Copy link
Contributor

@banach-space banach-space left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for driving this!

Please wait for other reviewers to take a look before landing this.

@joker-eph joker-eph removed their request for review November 23, 2023 02:31
@joker-eph
Copy link
Collaborator

Thanks for the CC, I'm not qualified to review though, it's very dependent on what the Flang maintainer think they want to maintain, and how much this should grow.

From a MLIR point of view, we are supporting Flang and we'll support these tests, we may have to revisit this if this gets out-of-hand (hard to maintain / fragile), but this is very hypothetical.

And thanks for caring about better testing for the project!

Copy link
Contributor

@kiranchandramohan kiranchandramohan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM subject to the following. Please add a pointer to this patch in the RFC.

Since you have not added a CMake flag to enable the tests in this directory, it is important to convey that tests here should be used only under particular circumstances.
Please add a Readme file in the flang/test/Integration directory saying that "This directory can be used to add Integration tests involving multiple stages of the compiler (for eg. from Fortran to LLVM IR). It should not contain executable tests. We should only add tests here sparingly and only if there is no other way to test. Repeat this message in each test that is added to this directory and sub-directories."

As per the RFC: https://discourse.llvm.org/t/rfc-flang-new-directory-for-adding-end-to-end-tests-for-lowering-to-llvm-ir-in-flang/74872/11, this patch adds a new Integration test directory for OpenMP- flang/test/Integration/OpenMP and moves the existing OpenMP integration tests from flang/test/Driver/OpenMP to this directory.

This directory can be used to add Integration tests involving multiple stages of the compiler (for eg. from Fortran to LLVM IR). It should not contain executable tests. We should only add tests here sparingly and only if there is no other way to test. Repeat this message in each test that is added to this directory and sub-directories.
@TIFitis
Copy link
Member Author

TIFitis commented Nov 24, 2023

LGTM subject to the following. Please add a pointer to this patch in the RFC.

Since you have not added a CMake flag to enable the tests in this directory, it is important to convey that tests here should be used only under particular circumstances.

Thanks for the review, I have added the message to these places.

@TIFitis TIFitis merged commit c38dbfd into llvm:main Nov 24, 2023
@TIFitis TIFitis deleted the integration-tests branch November 30, 2023 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:driver flang:openmp flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants