[SYCL] Fix host-to-host copy during copyback#1692
Merged
Merged
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>
s-kanaev
approved these changes
May 15, 2020
|
|
||
| DstOffset[0] *= DstElemSize; | ||
| SrcOffset[0] *= SrcElemSize; | ||
| SrcMem += SrcOffset[0] * SrcElemSize; |
Contributor
There was a problem hiding this comment.
Just curious.
Why only SrcOffset[0] is involved? Is multidimensional offset "merged" into singledimensional?
Contributor
There was a problem hiding this comment.
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;
Contributor
There was a problem hiding this comment.
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?
Contributor
Author
There was a problem hiding this comment.
@v-klochkov I have indeed encountered such behaviour when linking with Intel's implementation of memcpy (_intel_fast_memcpy).
v-klochkov
approved these changes
May 15, 2020
alexbatashev
pushed a commit
to alexbatashev/llvm
that referenced
this pull request
May 18, 2020
…_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 ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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