-
Notifications
You must be signed in to change notification settings - Fork 248
Turn on SPIR-V builtin generation for OpenCL CPP sources #2466
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
Turn on SPIR-V builtin generation for OpenCL CPP sources #2466
Conversation
Signed-off-by: Sudarsanam, Arvind <[email protected]>
| !0 = !{i32 1, !"wchar_size", i32 4} | ||
| !1 = !{i32 1, i32 2} | ||
| !2 = !{i32 4, i32 100000} | ||
| !2 = !{i32 7, i32 100000} |
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 test case was actually derived from SYCL source.
Signed-off-by: Sudarsanam, Arvind <[email protected]>
|
Test fail is not related and an issue has been opened. Thanks |
lib/SPIRV/OCLToSPIRV.cpp
Outdated
| // This is a pre-processing pass, which transform LLVM IR module to a more | ||
| // suitable form for the SPIR-V translation: it is specifically designed to | ||
| // handle OpenCL C built-in functions and shouldn't be launched for other | ||
| // handle OpenCL C/CPP built-in functions and shouldn't be launched for other |
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.
Out of curiosity, what is the reason for only running this transform for these types of sources?
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.
These are the only OpenCL related sources and this particular module deals with OpenCL sources.
| @@ -0,0 +1,24 @@ | |||
| ; RUN: llvm-as %s -o %t.bc | |||
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.
Consider adding a comment describing purpose of this test. I think that looking at the filename or file history is not as clear or convenient.
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.
Done. Thanks
lib/SPIRV/OCLToSPIRV.cpp
Outdated
| // source languages | ||
| if (std::get<0>(Src) != spv::SourceLanguageOpenCL_C) | ||
| if (std::get<0>(Src) != spv::SourceLanguageOpenCL_C && | ||
| std::get<0>(Src) != spv::SourceLanguageOpenCL_CPP) |
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.
There is also a SourceLanguageCPP_for_OpenCL. Should this be allowed?
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.
Yes. Good catch. Thanks. Added.
Signed-off-by: Sudarsanam, Arvind <[email protected]>
Signed-off-by: Sudarsanam, Arvind <[email protected]>
LU-JOHN
left a comment
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
svenvh
left a comment
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.
Thanks for working on this!
lib/SPIRV/OCLToSPIRV.cpp
Outdated
| // handle OpenCL C built-in functions and shouldn't be launched for other | ||
| // source languages | ||
| if (std::get<0>(Src) != spv::SourceLanguageOpenCL_C) | ||
| // handle OpenCL C/CPP and CPP for OpenCL modules and shouldn't be launched |
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.
In comments we can refer to the official language names:
| // handle OpenCL C/CPP and CPP for OpenCL modules and shouldn't be launched | |
| // handle OpenCL C/C++ and C++ for OpenCL modules and shouldn't be launched |
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.
Done in commit
Thanks
lib/SPIRV/OCLTypeToSPIRV.cpp
Outdated
| if (std::get<0>(Src) != spv::SourceLanguageOpenCL_C) | ||
| // This is a pre-processing pass, which transform LLVM IR module to a more | ||
| // suitable form for the SPIR-V translation: it is specifically designed to | ||
| // handle OpenCL C/CPP and CPP for OpenCL types and shouldn't be launched for |
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.
| // handle OpenCL C/CPP and CPP for OpenCL types and shouldn't be launched for | |
| // handle OpenCL C/C++ and C++ for OpenCL types and shouldn't be launched for |
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.
Done in commit. Thanks
Signed-off-by: Arvind Sudarsanam <[email protected]>
…onosGroup#2466)" This reverts commit 80dfd86. The commit break Translator in cases when user supplied function is named with the prefix which, after demangling, is the same as OpenCL builtin. The culprit code is placed in during SPIRWriter OCL pass in OCLToSPIRVBase::visitCallInst(CallInst &). Failing name would be for example atomic_fetch_and_sub_uint32_explicit.
…)" (#2508) This reverts commit 80dfd86. The commit break Translator in cases when user supplied function is named with the prefix which, after demangling, is the same as OpenCL builtin. The culprit code is placed in during SPIRWriter OCL pass in OCLToSPIRVBase::visitCallInst(CallInst &). Failing name would be for example atomic_fetch_and_sub_uint32_explicit.
…ces (KhronosGroup#2466)" (KhronosGroup#2508)" This reverts commit 9e60105.
It seems we currently allow OCL to SPIR-V translation only for OpenCL C sources. This PR tries to extend this to OpenCL C++ and C++ for OpenCL sources as well.
Thanks