-
Notifications
You must be signed in to change notification settings - Fork 769
[SYCL] Enable host optimization of work-item free functions #2967
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[SYCL] Enable host optimization of work-item free functions #2967
Conversation
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
…ons and checking for any usage to optimize host kernel tasks. Signed-off-by: Chris Perkins <chris.perkins@intel.com>
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
O << (K.FreeFunctionCalls.CallsThisId || | ||
K.FreeFunctionCalls.CallsThisItem || | ||
K.FreeFunctionCalls.CallsThisNDItem || | ||
K.FreeFunctionCalls.CallsThisGroup) | ||
<< "; }\n"; |
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.
It feels that if the final information in the integration header doesn't say which exactly free function is called, we don't need four different flags and four identical handlers (I mean SYCLIntegrationHeader::setCallsThisItem
and others here) in front-end either.
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.
On the other hand I guess the host runtime could be optimized if we knows exactly which one is used...
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.
@intel/llvm-reviewers-runtime , WDYT?
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.
Pre-existing code unrelated to this PR needs to know if this_item
is called and that isn't concerned about the other free functions. The optimization in this PR just needs to know if any of them are called.
My thoughts are that it's best to make a proper record of each free function now. Recording only "this_item" and "anything" seems sloppy.
On the API side, though, the functions match our current needs. The pre-existing callsThisItem()
and callsAnyThisFreeFunction()
are the two affordances, but can be easily expanded in the future if required.
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.
Do you expect it to be required?
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 don't know of anything pending. But I'd wager at even odds on needing to know about this_nd_item
or this_group
usage in the future.
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.
Alright thanks! I'm ok with the FE changes.
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.
You can also update the PR description which is completely cryptic.
Perhaps with "Enable host optimization of work-item free functions" for the title and a few paragraphs of what is happening here and why.
O << (K.FreeFunctionCalls.CallsThisId || | ||
K.FreeFunctionCalls.CallsThisItem || | ||
K.FreeFunctionCalls.CallsThisNDItem || | ||
K.FreeFunctionCalls.CallsThisGroup) | ||
<< "; }\n"; |
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.
On the other hand I guess the host runtime could be optimized if we knows exactly which one is used...
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
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.
FE changes LGTM, other than the unresolved comment. I am alright with keeping the 4 different flags for now, if we expect to differentiate between free functions in the future.
O << (K.FreeFunctionCalls.CallsThisId || | ||
K.FreeFunctionCalls.CallsThisItem || | ||
K.FreeFunctionCalls.CallsThisNDItem || | ||
K.FreeFunctionCalls.CallsThisGroup) | ||
<< "; }\n"; |
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.
Do you expect it to be required?
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.
FE changes LGTM.
O << (K.FreeFunctionCalls.CallsThisId || | ||
K.FreeFunctionCalls.CallsThisItem || | ||
K.FreeFunctionCalls.CallsThisNDItem || | ||
K.FreeFunctionCalls.CallsThisGroup) | ||
<< "; }\n"; |
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.
Alright thanks! I'm ok with the FE changes.
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
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.
FE changes LGTM
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.
Looks Good To Me.
I also did not find any changes that would break backward compatibility.
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.
sycl changes LGTM.
there is a pre-commit fail though.
fail is flaky, @v-klochkov faced the same elsewhere and going to open issue. |
With opaque pointers, this is equivalent to calling `IRBuilder::CreateAddrSpaceCast`. Original commit: KhronosGroup/SPIRV-LLVM-Translator@0d3a1a207dc6dc5
The SYCL free functions (
this_item
,this_id
, etc) are expensive to support on host devices. They cause performance delays because every iteration through one of theparallel_for
routines the various indexing values have to be updated in case the users code might callthis_item
orthis_id
(or the others). But with the newcallsThisItem
method added to the Kernel Information (thanks @rdeodhar !), the host device can avoid paying the performance penalty if the users code doesn't actually callthis_item
.. We can detect at compile time whether or not any of thethis_xxx
free functions are used by the users code, and if not, don't bother storing the indexing data in each loop iteration.In this PR we add further expand the Kernel Information to support a
callsAnyThisFreeFunction
method, and we use it to avoid the sundrystore_item
etc. calls on the host.