diff --git a/openmp/libomptarget/test/jit/empty_kernel.inc b/openmp/libomptarget/test/jit/empty_kernel.inc new file mode 100644 --- /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 --- /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 --- /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 --- a/openmp/libomptarget/test/lit.cfg +++ b/openmp/libomptarget/test/lit.cfg @@ -181,6 +181,8 @@ "%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-" + \