-
Notifications
You must be signed in to change notification settings - Fork 765
[SYCL] Optimize handler::StoreLambda implementation #17669
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
Changes from all commits
717a398
55c9d25
9fdf613
84eaf62
7c6895c
07be10c
3a194f0
312f59c
3ce04a1
9276a8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1112,6 +1112,43 @@ void handler::extractArgsAndReqs() { | |||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
void handler::extractArgsAndReqsFromLambda( | ||||||||||||||
char *LambdaPtr, detail::kernel_param_desc_t (*ParamDescGetter)(int), | ||||||||||||||
size_t NumKernelParams, bool IsESIMD) { | ||||||||||||||
size_t IndexShift = 0; | ||||||||||||||
impl->MArgs.reserve(MaxNumAdditionalArgs * NumKernelParams); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aside from this line, why do we have to move this to the sources? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To me, there is no strict necessity, just desire to move functionality out of public headers and out of templates. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing the templates I don't mind, but the more symbols we have in the library, the less freedom we have due to the ABI it imposes. I could maybe also see some benefit in having this in the header w.r.t. inlining. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This patch isn't based on the latest llvm/sycl/include/sycl/handler.hpp Lines 769 to 774 in 0a406c9
the only other thing we can fold into this library api is the @steffenlarsen , I agree with you in general, but don't see how that is applicable in this particular case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My point here is, it seems like all that is actually forcing us to move this to the library is an optimization for pre-emptive reservation. It means the function we now have in the ABI does a handful of different things. Keeping it in the header and adding another new function in the library that does as little as possible still means we have another symbol, but I would argue that the chance of its signature changing or part of the ABI causing problems decreases with that design. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Am I right that current plan is to have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIUC, yes. @steffenlarsen , can you confirm? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that plan sounds good to me! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @steffenlarsen , what do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes! I like that solution, then we can move it when we promote preview during the next ABI break. ⭐ |
||||||||||||||
|
||||||||||||||
for (size_t I = 0; I < NumKernelParams; ++I) { | ||||||||||||||
detail::kernel_param_desc_t ParamDesc = ParamDescGetter(I); | ||||||||||||||
void *Ptr = LambdaPtr + ParamDesc.offset; | ||||||||||||||
const detail::kernel_param_kind_t &Kind = ParamDesc.kind; | ||||||||||||||
const int &Size = ParamDesc.info; | ||||||||||||||
if (Kind == detail::kernel_param_kind_t::kind_accessor) { | ||||||||||||||
// For args kind of accessor Size is information about accessor. | ||||||||||||||
// The first 11 bits of Size encodes the accessor target. | ||||||||||||||
const access::target AccTarget = | ||||||||||||||
static_cast<access::target>(Size & AccessTargetMask); | ||||||||||||||
if ((AccTarget == access::target::device || | ||||||||||||||
AccTarget == access::target::constant_buffer) || | ||||||||||||||
(AccTarget == access::target::image || | ||||||||||||||
AccTarget == access::target::image_array)) { | ||||||||||||||
detail::AccessorBaseHost *AccBase = | ||||||||||||||
static_cast<detail::AccessorBaseHost *>(Ptr); | ||||||||||||||
Ptr = detail::getSyclObjImpl(*AccBase).get(); | ||||||||||||||
} else if (AccTarget == access::target::local) { | ||||||||||||||
detail::LocalAccessorBaseHost *LocalAccBase = | ||||||||||||||
static_cast<detail::LocalAccessorBaseHost *>(Ptr); | ||||||||||||||
Ptr = detail::getSyclObjImpl(*LocalAccBase).get(); | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
processArg(Ptr, Kind, Size, I, IndexShift, | ||||||||||||||
/*IsKernelCreatedFromSource=*/false, IsESIMD); | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES | ||||||||||||||
// TODO: Those functions are not used anymore, remove it in the next | ||||||||||||||
// ABI-breaking window. | ||||||||||||||
void handler::extractArgsAndReqsFromLambda( | ||||||||||||||
char *LambdaPtr, const std::vector<detail::kernel_param_desc_t> &ParamDescs, | ||||||||||||||
bool IsESIMD) { | ||||||||||||||
|
@@ -1146,14 +1183,14 @@ void handler::extractArgsAndReqsFromLambda( | |||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
// TODO Unused, remove during ABI breaking window | ||||||||||||||
void handler::extractArgsAndReqsFromLambda( | ||||||||||||||
char *LambdaPtr, size_t KernelArgsNum, | ||||||||||||||
const detail::kernel_param_desc_t *KernelArgs, bool IsESIMD) { | ||||||||||||||
std::vector<detail::kernel_param_desc_t> ParamDescs( | ||||||||||||||
KernelArgs, KernelArgs + KernelArgsNum); | ||||||||||||||
extractArgsAndReqsFromLambda(LambdaPtr, ParamDescs, IsESIMD); | ||||||||||||||
} | ||||||||||||||
#endif // __INTEL_PREVIEW_BREAKING_CHANGES | ||||||||||||||
|
||||||||||||||
// Calling methods of kernel_impl requires knowledge of class layout. | ||||||||||||||
// As this is impossible in header, there's a function that calls necessary | ||||||||||||||
|
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'm not sure can we drop it unconditionally.
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 we can, but not sure either. IMO, let's drop and fix if something breaks somewhere.
+ @steffenlarsen , @AlexeySachkov , @sergey-semenov
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.
From what I can find, you removed the only use of this function, so I agree with @aelovikov-intel - drop it! ⭐