-
Notifications
You must be signed in to change notification settings - Fork 745
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
[SYCL] Fix host-to-host copy during copyback #1692
Conversation
Copyback is performed unconditionally during buffer destruction, so it's possible for it to perform a copy from and to the same host pointer. This patch adds a check for this scenario so that we don't rely on undefined behaviour of std::memcpy. Signed-off-by: Sergey Semenov <sergey.semenov@intel.com>
Signed-off-by: Sergey Semenov <sergey.semenov@intel.com>
@@ -358,13 +358,15 @@ static void copyH2H(SYCLMemObjI *SYCLMemObj, char *SrcMem, | |||
PI_INVALID_OPERATION); | |||
} | |||
|
|||
DstOffset[0] *= DstElemSize; | |||
SrcOffset[0] *= SrcElemSize; | |||
SrcMem += SrcOffset[0] * SrcElemSize; |
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.
Just curious.
Why only SrcOffset[0]
is involved? Is multidimensional offset "merged" into singledimensional?
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 the checks at lines 353-355 in this file make this line 361 correct. If Dim > 1, then the statement is SrcMem += 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.
Honestly speaking it is hard to believe that std::memcpy() does not check src==dst case and does something wrong in such case.
Why did you decide fixing this, did you really noticed unexpected behavior when src==dst?
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.
@v-klochkov I have indeed encountered such behaviour when linking with Intel's implementation of memcpy (_intel_fast_memcpy).
…_docs * origin/sycl: (1867 commits) [SYCL] Implement USM vars and placeholder accessors passed to reduction (intel#1657) [SYCL] Fix post-commit testing (intel#1705) [SYCL][NFC] Remove multi_ptr<const void, Space>::operator multi_ptr<const void, Space> (intel#1702) [Doc] Readme update. (intel#1701) Support function pointers in cast instructions Adjust FPGA IVDep translation for embedded loops [SYCL] Fix host-to-host copy during copyback (intel#1692) [SYCL] Add information about dependencies used in CI [SYCL] Add runtime support for fsycl-id-queries-fit-in-int (intel#1685) Revert "Revert "[llvm][NFC] Cleanup uses of std::function in Inlining-related APIs"" StoreInst should store Align, not MaybeAlign [clang][slh] Add test for SLH feature checking macro [NFC] Deduplicate comment in PromoteMemoryToRegister.cpp [WebAssembly] Optimize splats of bitcasted vectors [LLD][ELF] Use offset in thin archives to disambiguate thinLTO members [AArch64][SVE] Implement AArch64ISD::SETCC_PRED [SVE] Restore broken LLVM-C ABI compatability IR: Remove extra name mangling from llvm.ptrmask [NFC] Whitespace fix inside OptParserEmitter [compiler-rt][CMAKE] Only add cmake link flags in standalone build ...
Copyback is performed unconditionally during buffer destruction, so
it's possible for it to perform a copy from and to the same host
pointer. This patch adds a check for this scenario so that we don't rely
on undefined behaviour of std::memcpy.
Signed-off-by: Sergey Semenov sergey.semenov@intel.com