-
Notifications
You must be signed in to change notification settings - Fork 809
[SYCL] Improve output emitted in opt-report #3730
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f8f4915
[SYCL] Imrprove output emitted in opt-report
elizabethandrews c3b4c7a
Merge remote-tracking branch 'intel_llvm/sycl' into improve_opt
elizabethandrews f824973
Implement review comments
elizabethandrews 7d2e1bb
Construct description in Sema instead of CodeGen. Also added test
elizabethandrews de37308
Implement review comments
elizabethandrews 7452f9f
Fix compiler warning about reaching end of non-void function
elizabethandrews File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1768,9 +1768,6 @@ class SyclKernelDeclCreator : public SyclKernelFieldHandler { | |
|
|
||
| void addParam(const FieldDecl *FD, QualType FieldTy) { | ||
| ParamDesc newParamDesc = makeParamDesc(FD, FieldTy); | ||
| SemaRef.getDiagnostics().getSYCLOptReportHandler().AddKernelArgs( | ||
| KernelDecl, FD->getName().data(), FieldTy.getAsString(), | ||
| FD->getLocation()); | ||
| addParam(newParamDesc, FieldTy); | ||
| } | ||
|
|
||
|
|
@@ -1781,8 +1778,6 @@ class SyclKernelDeclCreator : public SyclKernelFieldHandler { | |
| StringRef Name = "_arg__base"; | ||
| ParamDesc newParamDesc = | ||
| makeParamDesc(SemaRef.getASTContext(), Name, FieldTy); | ||
| SemaRef.getDiagnostics().getSYCLOptReportHandler().AddKernelArgs( | ||
| KernelDecl, "", FieldTy.getAsString(), BS.getBaseTypeLoc()); | ||
| addParam(newParamDesc, FieldTy); | ||
| } | ||
| // Add a parameter with specified name and type | ||
|
|
@@ -2230,6 +2225,193 @@ class SyclKernelArgsSizeChecker : public SyclKernelFieldHandler { | |
| using SyclKernelFieldHandler::handleSyclHalfType; | ||
| }; | ||
|
|
||
| enum class KernelArgDescription { | ||
elizabethandrews marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| BaseClass, | ||
| DecomposedMember, | ||
| WrappedPointer, | ||
| WrappedArray, | ||
| Accessor, | ||
| AccessorBase, | ||
| Sampler, | ||
| Stream, | ||
| KernelHandler, | ||
| None | ||
| }; | ||
|
|
||
| StringRef getKernelArgDesc(KernelArgDescription Desc) { | ||
AaronBallman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| switch (Desc) { | ||
| case KernelArgDescription::BaseClass: | ||
| return "base class"; | ||
| break; | ||
elizabethandrews marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| case KernelArgDescription::DecomposedMember: | ||
| return "decomposed struct/class"; | ||
| break; | ||
| case KernelArgDescription::WrappedPointer: | ||
| return "nested pointer"; | ||
| break; | ||
| case KernelArgDescription::WrappedArray: | ||
| return "array"; | ||
| break; | ||
| case KernelArgDescription::Accessor: | ||
| return "accessor"; | ||
| break; | ||
| case KernelArgDescription::AccessorBase: | ||
| return "accessor base class"; | ||
| break; | ||
| case KernelArgDescription::Sampler: | ||
| return "sampler"; | ||
| break; | ||
| case KernelArgDescription::Stream: | ||
| return "stream"; | ||
| break; | ||
| case KernelArgDescription::KernelHandler: | ||
| return "SYCL2020 specialization constant"; | ||
| break; | ||
| default: | ||
elizabethandrews marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return ""; | ||
| } | ||
| } | ||
|
|
||
| class SyclOptReportCreator : public SyclKernelFieldHandler { | ||
| SyclKernelDeclCreator &DC; | ||
| SourceLocation KernelInvocationLoc; | ||
|
|
||
| void addParam(const FieldDecl *KernelArg, QualType KernelArgType, | ||
| KernelArgDescription KernelArgDesc) { | ||
| unsigned KernelArgSize = | ||
| SemaRef.getASTContext().getTypeSizeInChars(KernelArgType).getQuantity(); | ||
| const RecordDecl *KernelArgParent = KernelArg->getParent(); | ||
| SemaRef.getDiagnostics().getSYCLOptReportHandler().AddKernelArgs( | ||
| DC.getKernelDecl(), KernelArg->getName().data(), | ||
|
||
| KernelArgType.getAsString(), KernelInvocationLoc, KernelArgSize, | ||
| getKernelArgDesc(KernelArgDesc).data(), | ||
| KernelArgParent ? KernelArgParent->getName().data() : ""); | ||
| } | ||
|
|
||
| void addParam(const FieldDecl *FD, QualType FieldTy) { | ||
| KernelArgDescription Desc = KernelArgDescription::None; | ||
| const RecordDecl *RD = FD->getParent(); | ||
| if (RD && RD->hasAttr<SYCLRequiresDecompositionAttr>()) | ||
| Desc = KernelArgDescription::DecomposedMember; | ||
|
|
||
| addParam(FD, FieldTy, Desc); | ||
| } | ||
|
|
||
| void addParam(QualType KernelArgType, KernelArgDescription KernelArgDesc) { | ||
| unsigned KernelArgSize = | ||
| SemaRef.getASTContext().getTypeSizeInChars(KernelArgType).getQuantity(); | ||
| SemaRef.getDiagnostics().getSYCLOptReportHandler().AddKernelArgs( | ||
| DC.getKernelDecl(), KernelArgType.getAsString(), | ||
| KernelArgType.getAsString(), KernelInvocationLoc, KernelArgSize, | ||
| getKernelArgDesc(KernelArgDesc).data(), ""); | ||
| } | ||
|
|
||
| // Handles SYCL special types - accessor, sampler and stream | ||
| // Also handles modified types - arrays and pointers | ||
elizabethandrews marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| bool handleSpecialType(const FieldDecl *FD, QualType FieldTy, | ||
| KernelArgDescription Desc) { | ||
| llvm::ArrayRef<ParmVarDecl *> KernelParameters = | ||
elizabethandrews marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| DC.getParamVarDeclsForCurrentField(); | ||
| for (auto *Param : KernelParameters) | ||
elizabethandrews marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| addParam(FD, Param->getType(), Desc); | ||
| return true; | ||
| } | ||
|
|
||
| public: | ||
| static constexpr const bool VisitInsideSimpleContainers = false; | ||
| SyclOptReportCreator(Sema &S, SyclKernelDeclCreator &DC, SourceLocation Loc) | ||
| : SyclKernelFieldHandler(S), DC(DC), KernelInvocationLoc(Loc) {} | ||
|
|
||
| bool handleSyclAccessorType(FieldDecl *FD, QualType FieldTy) final { | ||
| return handleSpecialType( | ||
| FD, FieldTy, KernelArgDescription(KernelArgDescription::Accessor)); | ||
| } | ||
|
|
||
| bool handleSyclAccessorType(const CXXRecordDecl *, const CXXBaseSpecifier &BS, | ||
| QualType FieldTy) final { | ||
| llvm::ArrayRef<ParmVarDecl *> KernelParameters = | ||
elizabethandrews marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| DC.getParamVarDeclsForCurrentField(); | ||
| for (auto *Param : KernelParameters) | ||
elizabethandrews marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| addParam(Param->getType(), | ||
| KernelArgDescription(KernelArgDescription::AccessorBase)); | ||
| return true; | ||
| } | ||
|
|
||
| bool handleSyclSamplerType(FieldDecl *FD, QualType FieldTy) final { | ||
| return handleSpecialType( | ||
| FD, FieldTy, KernelArgDescription(KernelArgDescription::Sampler)); | ||
| } | ||
|
|
||
| bool handlePointerType(FieldDecl *FD, QualType FieldTy) final { | ||
| KernelArgDescription Desc = KernelArgDescription::None; | ||
| ParmVarDecl *KernelParameter = DC.getParamVarDeclsForCurrentField()[0]; | ||
| // Compiler generated openCL kernel argument for current pointer field | ||
| // is not a pointer. This means we are processing a nested pointer and | ||
| // the openCL kernel argument is of type __wrapper_class. | ||
| if (!KernelParameter->getType()->isPointerType()) | ||
| Desc = KernelArgDescription::WrappedPointer; | ||
| return handleSpecialType(FD, FieldTy, Desc); | ||
| } | ||
|
|
||
| bool handleScalarType(FieldDecl *FD, QualType FieldTy) final { | ||
| addParam(FD, FieldTy); | ||
| return true; | ||
| } | ||
|
|
||
| bool handleSimpleArrayType(FieldDecl *FD, QualType FieldTy) final { | ||
| // Simple arrays are always wrapped. | ||
| handleSpecialType(FD, FieldTy, | ||
| KernelArgDescription(KernelArgDescription::WrappedArray)); | ||
| return true; | ||
| } | ||
|
|
||
| bool handleNonDecompStruct(const CXXRecordDecl *, FieldDecl *FD, | ||
| QualType Ty) final { | ||
| addParam(FD, Ty); | ||
| return true; | ||
| } | ||
|
|
||
| bool handleNonDecompStruct(const CXXRecordDecl *Base, | ||
| const CXXBaseSpecifier &BS, QualType Ty) final { | ||
| addParam(Ty, KernelArgDescription(KernelArgDescription::BaseClass)); | ||
| return true; | ||
| } | ||
|
|
||
| bool handleUnionType(FieldDecl *FD, QualType FieldTy) final { | ||
| return handleScalarType(FD, FieldTy); | ||
| } | ||
|
|
||
| bool handleSyclHalfType(FieldDecl *FD, QualType FieldTy) final { | ||
| addParam(FD, FieldTy); | ||
| return true; | ||
| } | ||
|
|
||
| bool handleSyclStreamType(FieldDecl *FD, QualType FieldTy) final { | ||
| // For the current implementation of stream class, the Visitor 'handles' | ||
| // stream argument and then visits each accessor field in stream. Therefore | ||
| // handleSpecialType in this case only adds a single argument for stream. | ||
| // The arguments corresponding to accessors in stream are handled in | ||
| // handleSyclAccessorType. The opt-report therefore does not diffrentiate | ||
| // between the accessors in streams and accessors captured by SYCL kernel. | ||
| // Once stream API is modified to use __init(), the visitor will no longer | ||
| // visit the stream object and opt-report output for stream class will be | ||
| // similar to that of other special types. | ||
| return handleSpecialType( | ||
| FD, FieldTy, KernelArgDescription(KernelArgDescription::Stream)); | ||
| } | ||
|
|
||
| void handleSyclKernelHandlerType() { | ||
| ASTContext &Context = SemaRef.getASTContext(); | ||
| if (isDefaultSPIRArch(Context)) | ||
| return; | ||
| addParam(DC.getParamVarDeclsForCurrentField()[0]->getType(), | ||
| KernelArgDescription(KernelArgDescription::KernelHandler)); | ||
| } | ||
| using SyclKernelFieldHandler::handleSyclHalfType; | ||
| using SyclKernelFieldHandler::handleSyclSamplerType; | ||
| using SyclKernelFieldHandler::handleSyclStreamType; | ||
| }; | ||
|
|
||
| static CXXMethodDecl *getOperatorParens(const CXXRecordDecl *Rec) { | ||
| for (auto *MD : Rec->methods()) { | ||
| if (MD->getOverloadedOperator() == OO_Call) | ||
|
|
@@ -3552,18 +3734,20 @@ void Sema::ConstructOpenCLKernel(FunctionDecl *KernelCallerFunc, | |
| StableName, KernelCallerFunc); | ||
|
|
||
| SyclKernelIntFooterCreator int_footer(*this, getSyclIntegrationFooter()); | ||
| SyclOptReportCreator opt_report(*this, kernel_decl, KernelObj->getLocation()); | ||
|
|
||
| KernelObjVisitor Visitor{*this}; | ||
| Visitor.VisitRecordBases(KernelObj, kernel_decl, kernel_body, int_header, | ||
| int_footer); | ||
| int_footer, opt_report); | ||
| Visitor.VisitRecordFields(KernelObj, kernel_decl, kernel_body, int_header, | ||
| int_footer); | ||
| int_footer, opt_report); | ||
|
|
||
| if (ParmVarDecl *KernelHandlerArg = | ||
| getSyclKernelHandlerArg(KernelCallerFunc)) { | ||
| kernel_decl.handleSyclKernelHandlerType(); | ||
| kernel_body.handleSyclKernelHandlerType(KernelHandlerArg); | ||
| int_header.handleSyclKernelHandlerType(KernelHandlerArg->getType()); | ||
| opt_report.handleSyclKernelHandlerType(); | ||
| } | ||
| } | ||
|
|
||
|
|
||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.