[offload][OpenMP][NFC] Add a default-grid run to the no-loop tests #229677
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-offload
Author: Nicole Aschenbrenner (nicebert)
<details>
<summary>Changes</summary>
Add a run without OMP_NUM_TEAMS and OMP_TEAMS_THREAD_LIMIT to show the
kernels are promoted with the runtime's default grid as well.
---
Full diff: https://github.com/llvm/llvm-project/pull/229677.diff
2 Files Affected:
````````````diff --git a/offload/test/offloading/fortran/target-no-loop.f90 b/offload/test/offloading/fortran/target-no-loop.f90
index 99c02acdc2567..c5d9ff1fbf9fe 100644
--- a/offload/test/offloading/fortran/target-no-loop.f90
+++ b/offload/test/offloading/fortran/target-no-loop.f90
@@ -3,6 +3,7 @@
! RUN: %libomptarget-compile-fortran-generic -O3 -fopenmp-assume-threads-oversubscription -fopenmp-assume-teams-oversubscription
! RUN: env LIBOMPTARGET_INFO=16 OMP_NUM_TEAMS=16 OMP_TEAMS_THREAD_LIMIT=16 %libomptarget-run-generic 2>&1 | %fcheck-generic
+! RUN: env LIBOMPTARGET_INFO=16 %libomptarget-run-generic 2>&1 | %fcheck-generic --check-prefix=DEFAULT
function check_errors(array) result (errors)
integer, intent(in) :: array(1024)
integer :: errors
@@ -95,3 +96,11 @@ end program main
! CHECK: info: #Args: 4 Teams x Thrds: 16x 16 {{.*}}
! CHECK: number of errors: 0
+! DEFAULT: omptarget device {{[0-9]+}} info: Launching kernel {{.*}} SPMD-No-Loop mode
+! DEFAULT: omptarget device {{[0-9]+}} info: Launching kernel {{.*}} SPMD mode
+! DEFAULT: omptarget device {{[0-9]+}} info: Launching kernel {{.*}} SPMD-No-Loop mode
+! DEFAULT: omptarget device {{[0-9]+}} info: Launching kernel {{.*}} SPMD mode
+! DEFAULT: omptarget device {{[0-9]+}} info: Launching kernel {{.*}} Generic mode
+! DEFAULT: omptarget device {{[0-9]+}} info: Launching kernel {{.*}} SPMD mode
+! DEFAULT: number of errors: 0
+
diff --git a/offload/test/offloading/target-no-loop.c b/offload/test/offloading/target-no-loop.c
index 8407cffc13020..7b056d004ef71 100644
--- a/offload/test/offloading/target-no-loop.c
+++ b/offload/test/offloading/target-no-loop.c
@@ -3,6 +3,7 @@
// RUN: %libomptarget-compile-generic -O3 -fopenmp-assume-threads-oversubscription -fopenmp-assume-teams-oversubscription
// RUN: env LIBOMPTARGET_INFO=16 OMP_NUM_TEAMS=16 OMP_TEAMS_THREAD_LIMIT=16 %libomptarget-run-generic 2>&1 | %fcheck-generic
+// RUN: env LIBOMPTARGET_INFO=16 %libomptarget-run-generic 2>&1 | %fcheck-generic --check-prefix=DEFAULT
// REQUIRES: gpu
// XFAIL: intelgpu
@@ -89,3 +90,11 @@ int main(void) {
// CHECK: omptarget device {{[0-9]+}} info: Launching kernel {{.*}} SPMD mode
// CHECK: info: #Args: 3 Teams x Thrds: 16x 16 {{.*}}
// CHECK: number of errors: 0
+
+// DEFAULT: omptarget device {{[0-9]+}} info: Launching kernel {{.*}} SPMD-No-Loop mode
+// DEFAULT: omptarget device {{[0-9]+}} info: Launching kernel {{.*}} SPMD mode
+// DEFAULT: omptarget device {{[0-9]+}} info: Launching kernel {{.*}} SPMD-No-Loop mode
+// DEFAULT: omptarget device {{[0-9]+}} info: Launching kernel {{.*}} SPMD mode
+// DEFAULT: omptarget device {{[0-9]+}} info: Launching kernel {{.*}} Generic-SPMD mode
+// DEFAULT: omptarget device {{[0-9]+}} info: Launching kernel {{.*}} SPMD mode
+// DEFAULT: number of errors: 0
</details>
can you also add the checklines containing Teams x Thrds for the default case? Otherwise, it's not checked for the num_threads(64) case if it's taking effect correctly (because with OMP_TEAMS_THREAD_LIMIT=16, the 16 takes precedence)
can you also add the checklines containing Teams x Thrds for the default case? Otherwise, it's not checked for the num_threads(64) case if it's taking effect correctly (because with OMP_TEAMS_THREAD_LIMIT=16, the 16 takes precedence)
I added the checks for the cases where specific team or thread counts are expected by the test.
Approved these changes.
I don't think it is testing everything it should. The execution mode is checked. But whether the correct runtime team/thread selection path is taken is not because this test cannot distinguish between the SPMD and the No-Loop paths in the runtime.
I suggest a large enough tripcount for the No-Loop case that over-subscribes a device, e.g. 1M. Then extract the team and thread counts from the debug trace and CHECK that their product >= tripcount.
The existing Fortran test has the same problem.
I added a no-loop kernel with a trip count of 1000000 to both the C and the Fortran test. Both runs now take the team and thread counts from the trace and check that their product covers the trip count, which a plain SPMD launch with the default grid doesn't.
LGTM
ro-i
nicebert
Add a run without OMP_NUM_TEAMS and OMP_TEAMS_THREAD_LIMIT to show the
kernels are promoted with the runtime's default grid as well.