Repository navigation
Conversation
|
I submitted this PR a while ago and would appreciate it if you could trigger the CI and take a look when you have a chance. Thanks! @pablodelara |
| crc16_t10dif_copy(TEST_SEED, dst_buf, buffer, len)); | ||
| crc = crc16_t10dif_copy(TEST_SEED, dst_buf, buffer, len)); | ||
| } | ||
| printf("finish 0x%x\n", crc); |
There was a problem hiding this comment.
is this printf() required?
There was a problem hiding this comment.
is this printf() required?
Yes, the printf() call is used following the same pattern as in crc16_t10dif_copy_perf.c to print the output of crc16_t10dif_copy, thereby preventing LTO from optimizing away the CRC computation.
There was a problem hiding this comment.
Thanks. I see - the printf prevents the code from being optimized out. Would it be possible to explore other options instead of printf? i.e. would declaring crc as volatile help instead?
There was a problem hiding this comment.
Thanks. I see - the
printfprevents the code from being optimized out. Would it be possible to explore other options instead ofprintf? i.e. would declaringcrcasvolatilehelp instead?
I've made the changes as you suggested. Could you please review it again? Thank you!
Under LTO optimization, the crc_funcs_perf benchmark produced anomalous results for crc16_t10dif_copy. The function was inlined by the compiler, but since its return value was unused, the entire CRC computation logic was optimized away. Fix this by storing the returned value into a volatile variable, which prevents the compiler from eliminating the computation. Verification by running ./crc/crc_funcs_perf on Spacemit(R) X100: Before fix: crc16_t10dif_copy : runtime = 3061974 usecs, bandwidth 65783 MB in 3.0620 sec = 21484.12 MB/s After fix: crc16_t10dif_copy : runtime = 3076511 usecs, bandwidth 822 MB in 3.0765 sec = 267.32 MB/s Signed-off-by: zhoulu <zhou.lu1@zte.com.cn>
4922dca to
709b368
Compare
|
Thanks. It's merged now |
Under LTO optimization, the crc_funcs_perf benchmark produced anomalous results for crc16_t10dif_copy. The function was inlined by the compiler, but since its return value was unused, the entire CRC computation logic was optimized away. Fix this by storing the returned value into a volatile variable, which prevents the compiler from eliminating the computation.
Verification by running ./crc/crc_funcs_perf on Spacemit(R) X100:
Before fix:
crc16_t10dif_copy : runtime = 3061974 usecs, bandwidth 65783 MB in 3.0620 sec = 21484.12 MB/s
After fix:
crc16_t10dif_copy : runtime = 3076511 usecs, bandwidth 822 MB in 3.0765 sec = 267.32 MB/s