Fix reduce_add functions#3846
Open
zephyr111 wants to merge 6 commits into
Open
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This PR fixes #3834 . More specifically it:
__reduce_add_uint8though the output type is nowuint8instead ofint16for sake of consistency with other functions.__reduce_add_int8and check the unsigned versions.I think it would be great to add more stdlib functions with widened output type later. Indeed, it would be more efficient on x86 CPU for
uint8when the user want aint16/uint16result (nouint8wrap-around). On x86, I think we could also use the instructionpmaddwdfor computingreduce_add(int16) -> int32(AFAIK not yet done previously). AFAIK, RISC and SVE (SVE2?) targets could also provide better implementations than naive ones (though SVE is not supported yet and RISC is certainly used by very few people). It is not critical since SIMD reductions are known to be a bit expensive and they rarely are on a hot path anyway.Please note that I also reorganized the order of some function for sake of clarity. I also added a missing
undef(minor).PS: updating the IR of the 19 targets is pretty tedious and bug prone.
Related Issue
Checklist
clang-format(e.g.,clang-format -i src/ispc.cpp)