[libc-commits] [libc] 9bcf9dc - [libc] Fix missing warp sync for the NVPTX assert

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Tue Oct 10 10:50:51 PDT 2023


Author: Joseph Huber
Date: 2023-10-10T12:50:37-05:00
New Revision: 9bcf9dc98a6829ae3b0b18aa82368def394af7f4

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

LOG: [libc] Fix missing warp sync for the NVPTX assert

Summary:
The implementation of `assert` has an if statement so that only the
first thread in the warp prints the assertion. On modern NVPTX
architecture, this can be printed out of order with the abort call. This
would lead to only a portion of the message being printed and then
exiting the program. By adding a mandatory warp sync we force the full
string to be printed before we continue to the abort.

Added: 
    

Modified: 
    libc/src/assert/gpu/__assert_fail.cpp

Removed: 
    


################################################################################
diff  --git a/libc/src/assert/gpu/__assert_fail.cpp b/libc/src/assert/gpu/__assert_fail.cpp
index b239088df69b01f..7621c0803a00d8d 100644
--- a/libc/src/assert/gpu/__assert_fail.cpp
+++ b/libc/src/assert/gpu/__assert_fail.cpp
@@ -33,6 +33,7 @@ LLVM_LIBC_FUNCTION(void, __assert_fail,
   // Only a single line should be printed if an assertion is hit.
   if (gpu::is_first_lane(mask))
     LIBC_NAMESPACE::report_assertion_failure(assertion, file, line, function);
+  gpu::sync_lane(mask);
   LIBC_NAMESPACE::abort();
 }
 


        


More information about the libc-commits mailing list