hhr293 commented on code in PR #12299:
URL: https://github.com/apache/gluten/pull/12299#discussion_r3412251359
##########
cpp/core/utils/tac/ffor.hpp:
##########
@@ -335,15 +343,55 @@ inline constexpr size_t compress64Bound(size_t num) {
return (nBlocks + 1) * kHeaderSize + num * sizeof(uint64_t);
}
+// Encode one block: write header + bit-packed payload into `out`.
+// Returns the number of bytes written. `out` must be 8-byte aligned;
+// callers whose output buffer is unaligned stage through a local scratch.
+// Shared by the 64-bit and 128-bit codecs.
+inline size_t encodeBlock(const uint64_t* src, size_t blockVals, uint64_t*
out) {
+ uint64_t base;
+ unsigned bw;
+ analyze(src, blockVals, base, bw);
+ writeHeader(reinterpret_cast<uint8_t*>(out), static_cast<uint8_t>(bw),
+ static_cast<uint8_t>(blockVals / kLanes), base);
Review Comment:
kMaxValuesPerBlock is 256 and kLanes is 4, so blockVals / kLanes is at most
64 —
well within uint8_t range. All callers cap blockVals to kMaxValuesPerBlock
before calling encodeBlock; this is an invariant enforced by the compress
loop.
No overflow is possible here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]