[Openmp-commits] [openmp] [Libomptarget] Add a test for the `libc` implementation of assert (PR #69518)

Joseph Huber via Openmp-commits openmp-commits at lists.llvm.org
Wed Oct 18 14:04:17 PDT 2023


https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/69518

Summary:
The `libcgpu.a` file provides its own implementation of `__assert_fail`.
This adds a test to make sure it's usable in OpenMP offloading as
expected. Currently this requires linking `libcgpu.a` before the OpenMP
device RTL however. We also disable the test on the CPU as the format of
the string will be different.


>From 0e3cb3eed7ad18b2eeee64956b0437d8f3329143 Mon Sep 17 00:00:00 2001
From: Joseph Huber <jhuber6 at vols.utk.edu>
Date: Wed, 18 Oct 2023 16:02:17 -0500
Subject: [PATCH] [Libomptarget] Add a test for the `libc` implementation of
 assert

Summary:
The `libcgpu.a` file provides its own implementation of `__assert_fail`.
This adds a test to make sure it's usable in OpenMP offloading as
expected. Currently this requires linking `libcgpu.a` before the OpenMP
device RTL however. We also disable the test on the CPU as the format of
the string will be different.
---
 openmp/libomptarget/test/libc/assert.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 openmp/libomptarget/test/libc/assert.c

diff --git a/openmp/libomptarget/test/libc/assert.c b/openmp/libomptarget/test/libc/assert.c
new file mode 100644
index 000000000000000..9a10032f481893d
--- /dev/null
+++ b/openmp/libomptarget/test/libc/assert.c
@@ -0,0 +1,21 @@
+// RUN: %libomptarget-compile-generic && %libomptarget-run-fail-generic 2>&1 | \
+// RUN:   %fcheck-generic --check-prefix=CHECK
+
+// REQUIRES: libc
+
+// UNSUPPORTED: powerpc64-ibm-linux-gnu
+// UNSUPPORTED: powerpc64-ibm-linux-gnu-LTO
+// UNSUPPORTED: aarch64-unknown-linux-gnu
+// UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
+// UNSUPPORTED: x86_64-pc-linux-gnu
+// UNSUPPORTED: x86_64-pc-linux-gnu-LTO
+
+#include <assert.h>
+
+int main() {
+  // CHECK: Assertion failed: '0 && "Trivial failure"' in function: 'int main()'
+  // CHECK-NOT: Assertion failed:
+#pragma omp target
+#pragma omp parallel
+  { assert(0 && "Trivial failure"); }
+}



More information about the Openmp-commits mailing list