-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL][ESIMD] Refactor ESIMD kernel support in FE. #2747
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
Conversation
This attribute is to be used by the FE to mark ESIMD kernel arguments originating from buffer accessors, which is then translated to BE-specific metadata needed for correct code generation. Signed-off-by: Konstantin S Bobrovsky <[email protected]>
- Use 'esimd_acc_ptr' attribute to mark ESIMD kernel pointer arguments originating from accessors - Use '__init_esimd' initializer in FE for ESIMD kernel accessors. - Add 'isESIMD()' function to the integration header for the RT to be able to distinguish ESIMD kernels from normal ones for the purpose of proper accessor arg setting. Signed-off-by: Konstantin S Bobrovsky <[email protected]>
clang/lib/Sema/SemaSYCL.cpp
Outdated
SyclKernelArgsSizeChecker ArgsSizeChecker(*this, Args[0]->getExprLoc()); | ||
|
||
const CXXMethodDecl *OpParens = getOperatorParens(KernelObj); | ||
bool IsSIMD = (OpParens != nullptr) && OpParens->hasAttr<SYCLSimdAttr>(); |
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.
nit: Those two lines are repeated multiple times. Maybe create a helper function?
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.
ok
clang/include/clang/Basic/Attr.td
Outdated
// Not supposed to be used directly in the source - SYCL device compiler FE | ||
// automatically adds it for ESIMD kernels. | ||
def SYCLSimdAccessorPtr : InheritableAttr { | ||
let Spellings = [GNU<"esimd_acc_ptr">, Declspec<"esimd_acc_ptr">]; |
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 guess we don't need spelling if this attribute is not supposed to be used in the source.
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.
ok
clang/include/clang/Basic/Attr.td
Outdated
// Used to mark kernel pointer parameters which correspond to the original | ||
// lambda's captured accessor. FE turns it to some metadata required by the | ||
// ESIMD Back-End. | ||
// Not supposed to be used directly in the source - SYCL device compiler FE | ||
// automatically adds it for ESIMD kernels. |
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 move this information to the doc.
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.
ok
clang/include/clang/Sema/Sema.h
Outdated
@@ -375,6 +375,9 @@ class SYCLIntegrationHeader { | |||
|
|||
SourceLocation KernelLocation; | |||
|
|||
/// Whether this kernel is an ESIMD one. | |||
bool IsESIMD; |
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.
How about
bool IsESIMD; | |
bool IsESIMDKernel; |
To make it clear that this flag is about kernel and not language options, for example.
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.
ok
clang/lib/CodeGen/CodeGenModule.cpp
Outdated
|
||
argESIMDAccPtrs.push_back( | ||
llvm::ConstantAsMetadata::get(CGF->Builder.getInt1( | ||
parm->getAttr<SYCLSimdAccessorPtrAttr>() != nullptr))); |
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 it will be a bit more optimal.
parm->getAttr<SYCLSimdAccessorPtrAttr>() != nullptr))); | |
parm->hasAttr<SYCLSimdAccessorPtrAttr>()))); |
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.
not sure. I want 0 or 1 is a clean input for getInt1. Non-null parm->getAttr() is neither
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.
Sorry, I didn't get your statement. I thought that parm->getAttr<SYCLSimdAccessorPtrAttr>() != nullptr
actually gives bool which is 0 or 1 as well as hasAttr
function which also returns bool (https://clang.llvm.org/doxygen/classclang_1_1Decl.html#ae7a63b99398864d86f53afd8a03c359b).
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.
Sorry, you are right. hasAttr is OK - will change
clang/lib/Sema/SemaDeclAttr.cpp
Outdated
case ParsedAttr::AT_SYCLSimdAccessorPtr: | ||
handleSimpleAttribute<SYCLSimdAccessorPtrAttr>(S, D, AL); | ||
break; |
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 guess we won't need this part if we remove spelling.
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.
ok
Co-authored-by: Mariya Podchishchaeva <[email protected]>
Signed-off-by: Konstantin S Bobrovsky <[email protected]>
Signed-off-by: Konstantin S Bobrovsky <[email protected]>
Signed-off-by: Konstantin S Bobrovsky <[email protected]>
Signed-off-by: Konstantin S Bobrovsky <[email protected]>
7bc4c00
to
bb9c41e
Compare
Signed-off-by: Konstantin S Bobrovsky <[email protected]>
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.
Please add tests.
I would expect a codegen IR test and a test for integration header changes.
Yes, tests will be added. |
@Fznamznon, I added 2 tests you to this PR: #2746 |
now part of #2746 |
``` .../SPIRV-LLVM-Translator/lib/SPIRV/SPIRVWriter.cpp:1697:44: warning: private field 'IndexGroupArrayMap' is not used [-Wunused-private-field] 1697 | LLVMToSPIRVBase::LLVMToSPIRVMetadataMap &IndexGroupArrayMap; | ``` IndexGroupArrayMap is used but only during the constructor to validate and build other things. This change happened in 4a7804bc45ada92b8365c82b99387726382b5d7d where code was moved from a separate method, into the constructor. Original commit: KhronosGroup/SPIRV-LLVM-Translator@9a23d54079204ae
This patch adds necessary support in FE to get rid of buffer object wrapping into image1d_buffer -
workaround for ESIMD BE gaps.
This attribute is to be used by the FE to mark ESIMD kernel arguments
originating from buffer accessors, which is then translated to BE-specific
metadata needed for correct code generation.
arguments originating from accessors
be able to distinguish ESIMD kernels from normal ones for the
purpose of proper accessor arg setting.
TODO add tests for the new attrs
The other two PRs needed for this one to work are: