[Openmp-commits] [openmp] bda7245 - [OpenMP] Add JIT and IR tests

Johannes Doerfert via Openmp-commits openmp-commits at lists.llvm.org
Thu May 18 13:28:15 PDT 2023


Author: Johannes Doerfert
Date: 2023-05-18T13:27:43-07:00
New Revision: bda72457a84a2803d0db99e22babc9dc2391a34c

URL: https://github.com/llvm/llvm-project/commit/bda72457a84a2803d0db99e22babc9dc2391a34c
DIFF: https://github.com/llvm/llvm-project/commit/bda72457a84a2803d0db99e22babc9dc2391a34c.diff

LOG: [OpenMP] Add JIT and IR tests

The OpenMP target JIT needs testing, so does the IR we actually generate
for the device. This is the initial commit with variations of an "empty
OpenMP kernel" that should all result in a empty IR kernel.

Differential revision: https://reviews.llvm.org/D150623

Added: 
    openmp/libomptarget/test/jit/empty_kernel.inc
    openmp/libomptarget/test/jit/empty_kernel_lvl1.c
    openmp/libomptarget/test/jit/empty_kernel_lvl2.c

Modified: 
    openmp/libomptarget/test/lit.cfg

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/test/jit/empty_kernel.inc b/openmp/libomptarget/test/jit/empty_kernel.inc
new file mode 100644
index 0000000000000..43813891ccb64
--- /dev/null
+++ b/openmp/libomptarget/test/jit/empty_kernel.inc
@@ -0,0 +1,41 @@
+int main(int argc, char** argv) {
+  #pragma omp TGT1_DIRECTIVE
+  {
+#ifdef LOOP_DIRECTIVE
+    #pragma omp LOOP_DIRECTIVE
+    for (int i = 0; i < argc; ++i)
+#endif
+    {
+#ifdef BODY_DIRECTIVE
+      #pragma omp BODY_DIRECTIVE
+      {
+      }
+#endif
+    }
+  }
+
+#ifdef TGT2_DIRECTIVE
+#pragma omp TGT2_DIRECTIVE
+  {
+#ifdef LOOP_DIRECTIVE
+    #pragma omp LOOP_DIRECTIVE
+    for (int i = 0; i < argc; ++i)
+#endif
+    {
+#ifdef BODY_DIRECTIVE
+      #pragma omp BODY_DIRECTIVE
+      {
+      }
+#endif
+    }
+  }
+#endif
+}
+
+// Check for an empty kernel (IR level)
+// FIRST:       define weak_odr {{.*}} void @__omp_offloading_{{.*}}_main
+// FIRST-NEXT:    ret void
+
+// Check for two empty kernels (IR level)
+// SECOND:      define weak_odr {{.*}} void @__omp_offloading_{{.*}}_main
+// SECOND-NEXT:   ret void

diff  --git a/openmp/libomptarget/test/jit/empty_kernel_lvl1.c b/openmp/libomptarget/test/jit/empty_kernel_lvl1.c
new file mode 100644
index 0000000000000..22a9d4ba8620d
--- /dev/null
+++ b/openmp/libomptarget/test/jit/empty_kernel_lvl1.c
@@ -0,0 +1,34 @@
+// clang-format off
+// RUN: %libomptarget-compileopt-generic -fopenmp-target-jit \
+// RUN:     -DTGT1_DIRECTIVE="target"
+// RUN: env LIBOMPTARGET_JIT_PRE_OPT_IR_MODULE=%t.pre.ll     \
+// RUN:     LIBOMPTARGET_JIT_SKIP_OPT=true                   \
+// RUN:     %libomptarget-run-generic
+// RUN: %fcheck-plain-generic --input-file %t.pre.ll %S/empty_kernel.inc --check-prefix=FIRST
+// RUN: %libomptarget-compileopt-generic -fopenmp-target-jit \
+// RUN:     -DTGT1_DIRECTIVE="target"                        \
+// RUN:     -DTGT2_DIRECTIVE="target"
+// RUN: env LIBOMPTARGET_JIT_PRE_OPT_IR_MODULE=%t.pre.ll     \
+// RUN:     LIBOMPTARGET_JIT_SKIP_OPT=true                   \
+// RUN:     %libomptarget-run-generic
+// RUN: %fcheck-plain-generic --input-file %t.pre.ll %S/empty_kernel.inc --check-prefixes=FIRST
+//
+// RUN: %libomptarget-compileopt-generic -fopenmp-target-jit \
+// RUN:     -DTGT1_DIRECTIVE="target teams"
+// RUN: env LIBOMPTARGET_JIT_PRE_OPT_IR_MODULE=%t.pre.ll     \
+// RUN:     LIBOMPTARGET_JIT_SKIP_OPT=true                   \
+// RUN:     %libomptarget-run-generic
+// RUN: %fcheck-plain-generic --input-file %t.pre.ll %S/empty_kernel.inc --check-prefix=FIRST
+// RUN: %libomptarget-compileopt-generic -fopenmp-target-jit \
+// RUN:     -DTGT1_DIRECTIVE="target teams"                  \
+// RUN:     -DTGT2_DIRECTIVE="target teams"
+// RUN: env LIBOMPTARGET_JIT_PRE_OPT_IR_MODULE=%t.pre.ll     \
+// RUN:     LIBOMPTARGET_JIT_SKIP_OPT=true                   \
+// RUN:     %libomptarget-run-generic
+// RUN: %fcheck-plain-generic --input-file %t.pre.ll %S/empty_kernel.inc --check-prefixes=FIRST,SECOND
+// clang-format on
+
+// UNSUPPORTED: x86_64-pc-linux-gnu
+// UNSUPPORTED: x86_64-pc-linux-gnu-LTO
+
+#include "empty_kernel.inc"

diff  --git a/openmp/libomptarget/test/jit/empty_kernel_lvl2.c b/openmp/libomptarget/test/jit/empty_kernel_lvl2.c
new file mode 100644
index 0000000000000..58181043e1bab
--- /dev/null
+++ b/openmp/libomptarget/test/jit/empty_kernel_lvl2.c
@@ -0,0 +1,96 @@
+// clang-format off
+// RUN: %libomptarget-compileoptxx-generic -fopenmp-target-jit \
+// RUN:     -DTGT1_DIRECTIVE="target"                          \
+// RUN:     -DLOOP_DIRECTIVE="for"
+// RUN: env LIBOMPTARGET_JIT_PRE_OPT_IR_MODULE=%t.pre.ll     \
+// RUN:     LIBOMPTARGET_JIT_SKIP_OPT=true                   \
+// RUN:     %libomptarget-run-generic
+// TODO:
+// RUN: not %fcheck-plain-generic --input-file %t.pre.ll %S/empty_kernel.inc --check-prefix=FIRST
+// RUN: %libomptarget-compileoptxx-generic -fopenmp-target-jit \
+// RUN:     -DTGT1_DIRECTIVE="target"                          \
+// RUN:     -DTGT2_DIRECTIVE="target"                          \
+// RUN:     -DLOOP_DIRECTIVE="for"
+// RUN: env LIBOMPTARGET_JIT_PRE_OPT_IR_MODULE=%t.pre.ll     \
+// RUN:     LIBOMPTARGET_JIT_SKIP_OPT=true                   \
+// RUN:     %libomptarget-run-generic
+// TODO:
+// RUN: not %fcheck-plain-generic --input-file %t.pre.ll %S/empty_kernel.inc --check-prefixes=FIRST,SECOND
+//
+// RUN: %libomptarget-compileoptxx-generic -fopenmp-target-jit \
+// RUN:     -DTGT1_DIRECTIVE="target"                          \
+// RUN:     -DLOOP_DIRECTIVE="parallel for"
+// RUN: env LIBOMPTARGET_JIT_PRE_OPT_IR_MODULE=%t.pre.ll     \
+// RUN:     LIBOMPTARGET_JIT_SKIP_OPT=true                   \
+// RUN:     %libomptarget-run-generic
+// TODO:
+// RUN: not %fcheck-plain-generic --input-file %t.pre.ll %S/empty_kernel.inc --check-prefix=FIRST
+// RUN: %libomptarget-compileoptxx-generic -fopenmp-target-jit \
+// RUN:     -DTGT1_DIRECTIVE="target"                          \
+// RUN:     -DTGT2_DIRECTIVE="target teams"                    \
+// RUN:     -DLOOP_DIRECTIVE="parallel for"
+// RUN: env LIBOMPTARGET_JIT_PRE_OPT_IR_MODULE=%t.pre.ll     \
+// RUN:     LIBOMPTARGET_JIT_SKIP_OPT=true                   \
+// RUN:     %libomptarget-run-generic
+// TODO:
+// RUN: not %fcheck-plain-generic --input-file %t.pre.ll %S/empty_kernel.inc --check-prefixes=FIRST,SECOND
+//
+// RUN: %libomptarget-compileoptxx-generic -fopenmp-target-jit \
+// RUN:     -DTGT1_DIRECTIVE="target teams"                    \
+// RUN:     -DLOOP_DIRECTIVE="distribute"
+// RUN: env LIBOMPTARGET_JIT_PRE_OPT_IR_MODULE=%t.pre.ll     \
+// RUN:     LIBOMPTARGET_JIT_SKIP_OPT=true                   \
+// RUN:     %libomptarget-run-generic
+// TODO:
+// RUN: not %fcheck-plain-generic --input-file %t.pre.ll %S/empty_kernel.inc --check-prefix=FIRST
+// RUN: %libomptarget-compileoptxx-generic -fopenmp-target-jit \
+// RUN:     -DTGT1_DIRECTIVE="target teams"                    \
+// RUN:     -DTGT2_DIRECTIVE="target teams"                    \
+// RUN:     -DLOOP_DIRECTIVE="distribute"
+// RUN: env LIBOMPTARGET_JIT_PRE_OPT_IR_MODULE=%t.pre.ll     \
+// RUN:     LIBOMPTARGET_JIT_SKIP_OPT=true                   \
+// RUN:     %libomptarget-run-generic
+// TODO:
+// RUN: not %fcheck-plain-generic --input-file %t.pre.ll %S/empty_kernel.inc --check-prefixes=FIRST,SECOND
+//
+// RUN: %libomptarget-compileoptxx-generic -fopenmp-target-jit \
+// RUN:     -DTGT1_DIRECTIVE="target teams"                    \
+// RUN:     -DLOOP_DIRECTIVE="distribute parallel for"
+// RUN: env LIBOMPTARGET_JIT_PRE_OPT_IR_MODULE=%t.pre.ll     \
+// RUN:     LIBOMPTARGET_JIT_SKIP_OPT=true                   \
+// RUN:     %libomptarget-run-generic
+// TODO:
+// RUN: not %fcheck-plain-generic --input-file %t.pre.ll %S/empty_kernel.inc --check-prefix=FIRST
+// RUN: %libomptarget-compileoptxx-generic -fopenmp-target-jit \
+// RUN:     -DTGT1_DIRECTIVE="target teams"                    \
+// RUN:     -DTGT2_DIRECTIVE="target teams"                    \
+// RUN:     -DLOOP_DIRECTIVE="distribute parallel for"
+// RUN: env LIBOMPTARGET_JIT_PRE_OPT_IR_MODULE=%t.pre.ll     \
+// RUN:     LIBOMPTARGET_JIT_SKIP_OPT=true                   \
+// RUN:     %libomptarget-run-generic
+// TODO:
+// RUN: not %fcheck-plain-generic --input-file %t.pre.ll %S/empty_kernel.inc --check-prefixes=FIRST,SECOND
+//
+// RUN: %libomptarget-compileoptxx-generic -fopenmp-target-jit \
+// RUN:     -DTGT1_DIRECTIVE="target teams"                    \
+// RUN:     -DLOOP_DIRECTIVE="distribute parallel for simd"
+// RUN: env LIBOMPTARGET_JIT_PRE_OPT_IR_MODULE=%t.pre.ll     \
+// RUN:     LIBOMPTARGET_JIT_SKIP_OPT=true                   \
+// RUN:     %libomptarget-run-generic
+// TODO:
+// RUN: not %fcheck-plain-generic --input-file %t.pre.ll %S/empty_kernel.inc --check-prefix=FIRST
+// RUN: %libomptarget-compileoptxx-generic -fopenmp-target-jit \
+// RUN:     -DTGT1_DIRECTIVE="target teams"                    \
+// RUN:     -DTGT2_DIRECTIVE="target teams"                    \
+// RUN:     -DLOOP_DIRECTIVE="distribute parallel for simd"
+// RUN: env LIBOMPTARGET_JIT_PRE_OPT_IR_MODULE=%t.pre.ll     \
+// RUN:     LIBOMPTARGET_JIT_SKIP_OPT=true                   \
+// RUN:     %libomptarget-run-generic
+// TODO:
+// RUN: not %fcheck-plain-generic --input-file %t.pre.ll %S/empty_kernel.inc --check-prefixes=FIRST,SECOND
+// clang-format on
+
+// UNSUPPORTED: x86_64-pc-linux-gnu
+// UNSUPPORTED: x86_64-pc-linux-gnu-LTO
+
+#include "empty_kernel.inc"

diff  --git a/openmp/libomptarget/test/lit.cfg b/openmp/libomptarget/test/lit.cfg
index 489d6109649ff..b268e46aeef5a 100644
--- a/openmp/libomptarget/test/lit.cfg
+++ b/openmp/libomptarget/test/lit.cfg
@@ -181,6 +181,8 @@ for libomptarget_target in config.libomptarget_all_targets:
             "%clang-" + libomptarget_target))
         config.substitutions.append(("%fcheck-generic",
             config.libomptarget_filecheck + " %s"))
+        config.substitutions.append(("%fcheck-plain-generic",
+            config.libomptarget_filecheck))
 
 
         config.substitutions.append(("%libomptarget-compilexx-run-and-check-" + \


        


More information about the Openmp-commits mailing list