-
Notifications
You must be signed in to change notification settings - Fork 738
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
[DeviceSanitizer] Support detecting out-of-bounds error on DeviceGlobals #12753
Conversation
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.
LGTM.
Please modify UNIFIED_RUNTIME_REPO
and UNIFIED_RUNTIME_TAG
in "llvm/sycl/plugins/unified_runtime/CMakeLists.txt" to enable integration test.
Hi, @zhaomaosu |
*Remove attribute of device globals in libdevice
Hi, @zhaomaosu |
Ok, I'll add tests for it. |
Done |
Hi @steffenlarsen, the PR in UR repo has been merged. I updated the UR tag. May I get your approval? |
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.
LGTM!
Review still required from @intel/unified-runtime-reviewers & @intel/dpcpp-tools-reviewers. Friendly ping. |
SmallVector<Constant *, 8> DeviceGlobalMetadata; | ||
|
||
constexpr uint64_t MaxRZ = 1 << 18; | ||
const uint64_t MinRZ = 32; |
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.
const uint64_t MinRZ = 32; | |
constexpr uint64_t MinRZ = 32; |
Nit, for uniformity
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.
Done
const uint64_t MinRZ = 32; | ||
|
||
Type *IntptrTy = | ||
Type::getIntNTy(M.getContext(), M.getDataLayout().getPointerSizeInBits()); |
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.
Type::getIntNTy(M.getContext(), M.getDataLayout().getPointerSizeInBits()); | |
Type::getIntNTy(M.getContext(), DL.getPointerSizeInBits()); |
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.
Done
constexpr uint64_t MaxRZ = 1 << 18; | ||
const uint64_t MinRZ = 32; | ||
|
||
Type *IntptrTy = |
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.
Type *IntptrTy = | |
Type *IntTy = |
Or maybe SizeTTy
. That type is not a pointer, so ptr
is definitely confusing here
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.
Changed to IntTy
// Non image scope device globals are implemented by device USM, and the | ||
// out-of-bounds check for them will be done by sanitizer USM part. So we | ||
// exclude them here. | ||
if (isDeviceGlobalVariable(G) && hasDeviceImageScopeProperty(G)) { |
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 should be turned into an early exit instead
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.
Done
|
||
assert((RZ + SizeInBytes) % MinRZ == 0); | ||
return RZ; | ||
}(); |
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.
Formatting seems to be broken
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.
Re-run clang-format
} else { | ||
// Calculate RZ, where MinRZ <= RZ <= MaxRZ, and RZ ~ 1/4 * | ||
// SizeInBytes. | ||
RZ = std::clamp((SizeInBytes / MinRZ / 4) * MinRZ, MinRZ, MaxRZ); |
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.
Am I right that (SizeInBytes / MinRZ / 4) * MinRZ
is written this way on purpose, to ensure certain rounding during calculation? If so, a comment would be welcome about that.
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 code is coming from https://github.com/intel/llvm/blob/sycl/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp#L2767.
I traced back the git histories. It seems that this code initially started out like this. So, I also don't know if it's written this way for some reason. Sorry for this.
But we do this instrumentation for device global in sycl-post-link tool temporarily. When unified runtime implemented the API urProgramGetGlobalVariablePointer, I'll move this instrumentation code back to AddressSanitizer pass.
@maksimsab, any other comments? |
@maksimsab if the changes you requested are sufficient please approve the PR. @intel/dpcpp-esimd-reviewers please review this ASAP, this PR is blocking any progress of merging other UR changes. This is affecting multiple teams. Any help to expedite the approval and merging of this PR would be greatly appriciated. |
I am OK to let this PR go in order to unblock other teams. |
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.
LGTM
Sure, I'll do this later. Thank you. |
Can anyone help merge this PR? Thanks a lot. |
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.
esimd lgtm, leaving tools for others
Tests HIP Support for Graph from oneapi-src/unified-runtime#1254 and updates documentation. Depends on #12753. --------- Co-authored-by: Andrey Alekseenko <andrey.alekseenko@scilifelab.se> Co-authored-by: Ewan Crawford <ewan@codeplay.com>
UR part: oneapi-src/unified-runtime#1354