news.volyx.in

The radix 2^51 trick (2017) (chosenplaintext.ca)

518 points by mooreds · 2320 days ago · 83 comments on HN

Article summary

The article discusses a technique called the radix 2^51 trick, which can speed up addition and subtraction of large integers on modern CPUs. This trick involves splitting 256-bit numbers into five 51-bit pieces, allowing for parallelized addition and delayed carry propagation. By reducing the need for carry operations, this technique can improve performance. The article explains how this technique works and provides examples of its application.

Main themes

  • radix 2^51 trick
  • parallelized addition
  • carry propagation
  • large integer arithmetic
  • CPU performance
  • cryptographic applications
  • algorithm optimization

What commenters say

  • The performance gain from the radix 2^51 trick comes from parallelizing addition operations, not reducing the total number of carries.
  • The total number of carry operations is conserved, but they are delayed, allowing for parallelized addition.
  • The trick is only useful when adding several large numbers, as it reduces the number of carry operations to a single pass of carry propagation.
  • Using 51-bit limbs instead of 64-bit limbs is more generally useful because it prevents intermediate overflow and allows for more efficient normalization.
  • The choice of 51-bit limbs may be due to specific use cases, such as cryptographic applications where math is performed modulo 2^255-19.
  • The radix 2^51 trick may not be the best approach for all use cases, and alternative methods, such as using FP hardware, may be more suitable for certain applications.
  • The performance gain from the radix 2^51 trick may come at the cost of increased energy usage, although this may not be a significant concern if the processing finishes faster and the core can idle.
  • The article's explanation of the radix 2^51 trick is clear and useful, but may be misleading in some respects, such as the reason for using 52 bits for the most significant limb.