-
Notifications
You must be signed in to change notification settings - Fork 769
[SYCL][ESIMD] Implement compile-time getNextPowerOf2 w/o recursion. #2133
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
Some more info on the problem is here #2104. Simply allowing recursion for constexpr functions does not work as they can be called from non-constexpr context. |
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 do not understand want you are doing here.
You had a recursion before, you have a recursion after...
Are you looking at something like https://github.com/triSYCL/triSYCL/blob/master/include/triSYCL/pipe.hpp#L55 ?
I had a real recursion before, where compiler would leave the recursive function in the IR if is called from non-constexpr context. In the version "after" the expansion is guaranteed to happen at compile-time, and IR is guaranteed not to have recursive 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.
If I understand it correctly, log2 also have real recursion and should be rewritten too?
Will it be done separately?
good catch. It is not used now, hence does not cause compilation errors. Should be removed for now - will do. |
actually it is used in |
Can't have real recursion, even if constexpr - SYCL device compiler does not allow that according to the spec. Signed-off-by: Konstantin S Bobrovsky <[email protected]>
Had to force-push to provide good commit message. Hope this is OK, since the patch is small. |
@keryell, are you OK with the patch? |
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 is a good trade-off while waiting for simplifying all of this with C++20 some day.
Signed-off-by: Lu, John <[email protected]> Original commit: KhronosGroup/SPIRV-LLVM-Translator@e7e8c09
Device code is restricted not to allow recursion.
Signed-off-by: Konstantin S Bobrovsky [email protected]