-
Notifications
You must be signed in to change notification settings - Fork 769
[DevTSAN] Sync thread clock to global state before kernel exit #18529
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
base: sycl
Are you sure you want to change the base?
[DevTSAN] Sync thread clock to global state before kernel exit #18529
Conversation
We need to sync each thread's clock back to global state before the thread exit to avoid false alarms in some reduction cases.
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.
Pull Request Overview
This PR ensures that each thread synchronizes its clock back to the global state before kernel exit to avoid false alarms, with changes applied to instrumentation logic and sanitizer driver arguments.
- Updated the SPIR-V instrumentation routine to properly handle function entry/exit instrumentation.
- Introduced a new __tsan_func_exit() in the device sanitizer runtime to sync clocks.
- Adjusted sanitizer argument handling for device offloading by removing tsan function entry/exit flags.
Reviewed Changes
Copilot reviewed 3 out of 8 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp | Updated API call and instrumentation logic to force exit instrumentation based on SPIR-V conditions. |
libdevice/sanitizer/tsan_rtl.cpp | Added __tsan_func_exit() to sync thread clocks to global state. |
clang/lib/Driver/SanitizerArgs.cpp | Removed tsan function entry/exit flag for device offloading. |
Files not reviewed (5)
- llvm/test/Instrumentation/ThreadSanitizer/SPIRV/basic.ll: Language not supported
- llvm/test/Instrumentation/ThreadSanitizer/SPIRV/cleanup_private_shadow.ll: Language not supported
- llvm/test/Instrumentation/ThreadSanitizer/SPIRV/instrument_barrier.ll: Language not supported
- llvm/test/Instrumentation/ThreadSanitizer/SPIRV/instrument_device_global.ll: Language not supported
- llvm/test/Instrumentation/ThreadSanitizer/SPIRV/kernel_metadata.ll: Language not supported
Comments suppressed due to low confidence (2)
clang/lib/Driver/SanitizerArgs.cpp:1282
- Removal of tsan function entry/exit instrumentation flags for device offloading should be double-checked to ensure it aligns with the intended behavior of synchronizing thread clocks before exit.
CmdArgs.push_back("-tsan-instrument-func-entry-exit=0");
libdevice/sanitizer/tsan_rtl.cpp:470
- Ensure that using kThreadSlotCount as an index for the global clock array is valid and within expected bounds, as this update affects thread synchronization logic.
TsanLaunchInfo->Clock[kThreadSlotCount].clk_[sid] =
// The tsan function entry/exit builtins are used to record stack | ||
// position, we don't need them in device offloading. | ||
CmdArgs.push_back("-mllvm"); | ||
CmdArgs.push_back("-tsan-instrument-func-entry-exit=0"); |
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.
Kindly remind @jinge90 for this change. Please remember to update the fortran driver.
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.
OK, thanks for the reminder.
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.
OK for driver
We need to sync each thread's clock back to global state before the thread exit to avoid false alarms in some reduction cases.