[flang-commits] [flang] [Flang] Add new Integration tests directory to Flang (PR #73141)
Akash Banerjee via flang-commits
flang-commits at lists.llvm.org
Wed Nov 22 07:57:10 PST 2023
https://github.com/TIFitis created https://github.com/llvm/llvm-project/pull/73141
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](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.
>From a794194c17f84132f6ac72cb869f2ff9ce763915 Mon Sep 17 00:00:00 2001
From: Akash Banerjee <Akash.Banerjee at amd.com>
Date: Wed, 22 Nov 2023 15:49:25 +0000
Subject: [PATCH] [Flang] Add new Integration tests directory to Flang
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.
---
.../OpenMP/host-ir-flag.f90 | 0
.../OpenMP/map-types-and-sizes.f90 | 0
.../Integration/OpenMP/target-filtering.f90 | 61 +++++++++++++++++++
3 files changed, 61 insertions(+)
rename flang/test/{Driver => Integration}/OpenMP/host-ir-flag.f90 (100%)
rename flang/test/{Driver => Integration}/OpenMP/map-types-and-sizes.f90 (100%)
create mode 100644 flang/test/Integration/OpenMP/target-filtering.f90
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
More information about the flang-commits
mailing list