-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[OpenMP] Do not define '__assert_fail' if we have the GPU libc #100409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Summary: The C library is intended to provide `__assert_fail`, so in the cases that we have both we should defer to that. This means that if you build the C library for GPUs you'll get the RPC based asser, and if not you'll get the trap based one.
@llvm/pr-subscribers-offload Author: Joseph Huber (jhuber6) ChangesSummary: Full diff: https://github.com/llvm/llvm-project/pull/100409.diff 2 Files Affected:
diff --git a/offload/DeviceRTL/src/Debug.cpp b/offload/DeviceRTL/src/Debug.cpp
index 4e16591cc6c51..5a2c84c7ee38a 100644
--- a/offload/DeviceRTL/src/Debug.cpp
+++ b/offload/DeviceRTL/src/Debug.cpp
@@ -26,10 +26,13 @@ using namespace ompx;
extern "C" {
void __assert_assume(bool condition) { __builtin_assume(condition); }
+#ifndef OMPTARGET_HAS_LIBC
[[gnu::weak]] void __assert_fail(const char *expr, const char *file,
unsigned line, const char *function) {
__assert_fail_internal(expr, nullptr, file, line, function);
}
+#endif
+
void __assert_fail_internal(const char *expr, const char *msg, const char *file,
unsigned line, const char *function) {
if (msg) {
diff --git a/offload/test/libc/assert.c b/offload/test/libc/assert.c
index 0501e36329024..bf155b6f463bf 100644
--- a/offload/test/libc/assert.c
+++ b/offload/test/libc/assert.c
@@ -2,10 +2,6 @@
// RUN: %fcheck-generic --check-prefix=CHECK
// REQUIRES: libc
-
-// AMDGPU and NVPTX without LTO uses the implementation in OpenMP currently.
-// UNSUPPORTED: nvptx64-nvidia-cuda
-// UNSUPPORTED: amdgcn-amd-amdhsa
// REQUIRES: gpu
#include <assert.h>
|
@@ -26,10 +26,13 @@ using namespace ompx; | |||
extern "C" { | |||
void __assert_assume(bool condition) { __builtin_assume(condition); } | |||
|
|||
#ifndef OMPTARGET_HAS_LIBC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No OMPTARGET
anymore I suggest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a lot of other stuff we'd need to clean up so it'd be easier to do that all at once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though we have a lot but they are "legacy". I don't think it's a good idea to introduce more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an existing macro, so if I wanted to use something else I'd need to rename it which would make the patch more complicated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh didn't notice that. It is indeed an existing one. Okay. Renaming belongs to a separate patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we should probably do it all at once.
Summary:
The C library is intended to provide
__assert_fail
, so in the casesthat we have both we should defer to that. This means that if you build
the C library for GPUs you'll get the RPC based asser, and if not you'll
get the trap based one.