-
Notifications
You must be signed in to change notification settings - Fork 754
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][NFC] Move SYCL Module Splitting to library. Part 1 #13054
[SYCL][NFC] Move SYCL Module Splitting to library. Part 1 #13054
Conversation
This patch is a part 1 of moving sycl-post-link functionality to library for New Offloading initiative. This patch consist of introducing LazyMemoryBuffer that allows to keep MemoryBuffer on the Disk for RAM economy.
Hi @maksimsab Can you please provide a high-level description of why we need LazyMemoryBuffer and how it will be used in the SYCL compilation flow? Thanks |
Sure. |
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.
Overall, it seems like something that should maybe go directly to the upstream
Btw, I could try to add Lazy mode to MemoryBuffer apart from the work of upstreaming. |
Don't we want to unify the paths taken for both SYCL and non-SYCL offloading? I mean, it is possible to maybe switch existing linker-wrapper code to use lazy buffers? Would it make sense? |
Probably, we could accept usual llvm/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp Lines 1555 to 1559 in 70cca70
Because, MemoryBuffer uses mmap and file's content is not loaded in the beginning. |
To clarify here what I mean: my idea was to introduce |
My concern is that llvm/llvm/lib/Support/MemoryBuffer.cpp Lines 484 to 486 in 70cca70
And this is how CUDA and HIP flows are potentially do not experience RAM issues. |
Just me speculating as I don't know for sure. |
@asudarsa @AlexeySachkov |
@@ -30,7 +31,20 @@ enum class SYCLBinaryImageFormat { | |||
}; | |||
|
|||
struct SYCLImage { |
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.
Is it possible to reuse or extend llvm::OffloadBinary::OffloadingImage data structure for this? On cursory look, it seems feasible. ImageKind is the same as Format here. OffloadKind is OFK_SYCL. Entries and Properties could be moved into StringData.
https://llvm.org/docs/doxygen/structllvm_1_1object_1_1OffloadBinary_1_1OffloadingImage.html
I am Ok with adding a TODO here and doing this in part 2 of changes.
Thanks
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 is a good idea. I will think through it after this patch.
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. Just a couple of clarifications requested. Please check the comment about 'assert' before merging this change.
Thanks
Test failures not due to this change. Merging this. Thanks |
This patch is a part 1 of moving sycl-post-link functionality to library for New Offloading initiative.
This patch replaces
std::vector<char>
withMemoryBuffer
as a container for accessing device image in theSYCLImage
class.MemoryBuffer
usesmmap
that allows not to hold the whole device image in the RAM.