REVIEW 2 major objections 5 minor 45 references
RISC-V Word-Size Modular Instructions for Residue Number Systems
T0 review · 2 major / 5 minor · reviewed 2026-08-12 · deepseek-v4-flash
Pith's one-line read This paper claims that adding word-size mulmod, addmod, and submod instructions to RISC-V makes software RNS modular multiplication up to 2.76x faster in-order and 3.06x out-of-order than pseudo-Mersenne moduli, and 4.5x to 8x faster than…
desk verdict Solid simulation study, but the headline speedups depend on unvalidated 2/4-cycle latencies for the custom modular instructions. read the letter →
The pith
A machine-rendered reading of the paper's core claim, the machinery that carries it, and where it could break.
The reading
What carries the argument
The load-bearing mechanism is a three-input, one-output instruction format in the RISC-V custom-opcode space: mulmod rd, rs1, rs2, rs3 computes rd = (rs1 × rs2) mod rs3; addmod and submod do the same for addition and subtraction, using the third operand as the modulus. This turns the word-size modular reduction, normally a full division, into a single operation with fixed simulated latency (2 cycles for addmod, 4 for mulmod, or 4/9 in the long-delay case). The evaluation wraps these instructions around Algorithm 1, an RNS Montgomery modular multiplication with base extensions: the first conversion uses the approximate method from [9], and the second uses either Szabo-Tanaka or Kawamura's base extension, the latter estimating the CRT quotient k with O(n) word-size operations.
What would settle it
Measure a real 64-bit RISC-V implementation of mulmod/addmod/submod and rerun the 64-channel Kawamura-base-extension software: if the actual latencies approach or exceed the long-delay case (9 and 4 cycles) or force a pipeline stall for the extra register operand, the 2.76x/3.06x advantages over pseudo-Mersenne will not reproduce. A cheaper test is to re-run the same simulations with mulmod delay set above 9 cycles and addmod above 4 and observe the crossover point where pseudo-Mersenne wins.
Extended reading notes
Core claim
The paper's central claim is that dedicated word-size modular arithmetic instructions change which RNS algorithm is best. With such instructions, the fastest implementation is RNS Montgomery modular multiplication that uses an approximate first base extension and Kawamura's approximate-quotient base extension for the second conversion: for 64 channels (4096-bit moduli) it runs in about 135,700 cycles in-order and 43,900 cycles out-of-order on the simulated RISC-V, versus about 342,400 and 134,100 cycles for pseudo-Mersenne moduli with the same base extension. The speedups are 2.76x and 3.06x, and the instruction version beats the simulated x86 baseline by 4.5x in-order and 8x out-of-order. The gain survives longer operator delays: with mulmod at 9 cycles and addmod at 4, the instruction version is still about 1.9x to 2.7x faster than pseudo-Mersenne in the configurations tested.
Load-bearing premise
The entire comparison rests on the assumption that the new instructions can be implemented with the simulated latencies—4 cycles for mulmod and 2 for addmod—and that the four-operand encoding costs no extra pipeline delays; the paper acknowledges these delays could be longer in a real implementation.
Editorial extensions
If this is right
- On an in-order RISC-V core, the instruction-based implementation with Kawamura's base extension is 2.76x faster than the fastest pseudo-Mersenne implementation, making it the best configuration among those compared.
- Out-of-order cores extract more from the instructions, reaching 3.06x, because independent RNS channels can issue in parallel.
- Even if the modular units are slow (mulmod 9 cycles, addmod 4), the instruction version remains about 1.9x faster in-order and 2.3x to 2.7x faster out-of-order than pseudo-Mersenne reduction.
- Against x86 with the same memory hierarchy and frequency, the simulated RISC-V with the new instructions needs 4.5x fewer cycles in-order and 8x fewer out-of-order for the 64-channel case.
Reading between the lines
- The paper does not quantify end-to-end cryptographic workloads, only the modular-multiplication kernel; applying the same instructions to the surrounding RNS conversions could shift the overall speedup for full RSA or ECC computations.
- A real four-operand instruction needs an extra register-read port on the pipeline; if that port lengthens the cycle time or adds bypass delays, the cycle-count ratios shrink even though the instruction counts stay the same. A three-operand variant (e.g., reusing rd as the modulus) is a testable alternative the authors list as future work.
- Because the gain is largest out-of-order, the results suggest RNS-friendly custom instructions are most valuable on superscalar RISC-V cores, and that a vector version of mulmod/addmod would let several RNS channels reduce simultaneously—an extension the paper plans but does not simulate.
Editorial analysis
A structured set of objections, weighed in public.
Referee Report
Summary. The paper proposes three custom RISC-V instructions (addmod, submod, mulmod) for word-size modular arithmetic and evaluates their impact on sequential software implementations of RNS modular multiplication using the GEM5 simulator. It compares three word-size modulo methods (C compiled modulo, pseudo-Mersenne reduction, custom instructions) and two base-extension algorithms (Szabo-Tanaka and Kawamura) across in-order (Minor) and out-of-order (O3) models and channel counts from 8 to 64. The headline results are a 2.76x (in-order) and 3.06x (out-of-order) cycle-time speedup of the custom-instruction version over the best software-only implementation (pseudo-Mersenne with Kawamura base extension) and a 4.5x/8x advantage over x86, with a long-delay sensitivity case (mulmod=9, addmod=4) reducing those ratios to 1.92x/2.30x.
Significance. The paper addresses a real bottleneck in software RNS implementations and proposes a concrete, well-scoped ISA extension. Its strengths are the large simulation matrix, the inclusion of a long-delay sensitivity case, and the honest statement that the delays are assumed, not measured. If the assumed latencies are representative, the results strongly motivate future hardware support for word-size modular instructions. However, the central quantitative claims rest on unvalidated microarchitectural assumptions, and the paper does not model the full cost of the four-operand encoding or of a fused multiply-and-reduce datapath. The study is a useful simulation exploration, but the headline speedups should be treated as upper-bound estimates rather than validated performance.
major comments (2)
- [§4.4, §5.4, and Abstract] The assumed latencies (mulmod=4, addmod=2; long-delay variant 9 and 4) are load-bearing for the headline speedups. As the paper itself notes in §5.4, 'they could be much longer in a real implementations.' The long-delay case in Table 1 shows the in-order speedup over pseudo-Mersenne falling from 2.76 to 1.92 and the out-of-order from 3.06 to 2.30. The manuscript does not model the extra pipeline costs of the four-operand encoding, such as an additional register-file read port, wider bypass network, or possible issue-width restrictions, and it does not provide a microarchitectural sketch of how a 64-bit multiply-and-reduce modulo an arbitrary runtime modulus could be completed in 4 cycles. Please add a more thorough sensitivity analysis, including a break-even latency, and qualify the abstract's numbers with the long-delay results or an explicit statement that the latency figures are optimistic assumptions.
- [§4.1–§4.4] The manuscript does not describe how the custom instructions were integrated into GEM5. It mentions adding them to gcc and checking with Spike, but no details are given about the GEM5 ISA description changes, execution unit configuration, and the timing model for the four-operand format. Without this information, the simulation results are not reproducible. Please include the relevant GEM5 modifications or provide a link to an artifact repository, so that the reported cycle counts can be independently verified.
minor comments (5)
- [§4.3] The description of the 'Modulo' baseline is ambiguous. The text says 'In case of processors without DIV instruction, i.e. our situation,' but it does not clarify whether the simulated RISC-V core implements the M extension. If DIV/REM is available, the C modulo operation would use a single REM instruction, which would make the large speedups over 'Modulo' harder to interpret. Please state the exact RISC-V ISA extensions enabled in the simulation.
- [§5.3] There is a typo in §5.3: 'Kaxamura' should be 'Kawamura'.
- [§5.2 and §5.3] The cross-references to 'Table 2' appear before the table is presented, and the table numbering is confusing because the first table in the text is also called 'Table 1.' Please renumber or restructure the table references for clarity.
- [Abstract and §5.4] The abstract says '8 less' cycles; this should be '8 times fewer cycles.' In §5.4, 'in a real implementations' is a grammatical error.
- [Figure 1] Figure 1, showing the proposed instruction encodings, is difficult to read because the field boundaries and bit labels are small. A table or a more detailed figure with each field clearly labeled would improve readability.
Circularity Check
No significant circularity: the speedups are simulation measurements comparing newly proposed instructions against independent baselines, with instruction latencies stated as assumptions rather than fitted to the results.
full rationale
The paper's central claims are empirical GEM5 simulation ratios between RNS modular multiplication using proposed mulmod/addmod instructions and baseline software reductions (C modulo and pseudo-Mersenne moduli). The baseline pseudo-Mersenne reduction is an independent algorithm from Plantard's work, and the RNS algorithm variants (Szabo-Tanaka and Kawamura base extensions) are standard external methods. The instruction latencies (mulmod=4, addmod=2, with a long-delay variant of 9 and 4) are openly declared simulation parameters, not quantities fitted to make the claimed speedups come out; the paper also reports the reduced speedups in the long-delay case, so the result is not defined by its input. Reuse of the authors' earlier RNS library and evaluation protocol [14] provides tooling, not the conclusion, and no load-bearing step reduces by construction to a self-citation or to the measured outputs. The only substantive weakness is that the assumed instruction delays may not hold in real hardware, which is a correctness/risk concern, not circularity.
Assumptions & free parameters
free parameters (3)
- mulmod instruction latency =
4 cycles (default), 9 (long-delay case)
- addmod instruction latency =
2 cycles (default), 4 (long-delay case)
- integer multiplier delay =
3 to 4 cycles
assumptions (3)
- standard math Correctness of the RNS base extension and Montgomery multiplication algorithms.
- domain assumption GEM5 simulator faithfully models the performance of the underlying processor and the proposed instructions.
- ad hoc to paper The proposed 4-operand instruction encoding can be implemented without additional pipeline costs beyond the stated ALU latencies.
invented entities (1)
-
addmod, submod, mulmod custom RISC-V instructions
Cite this review
Pith. "Pith review of RISC-V Word-Size Modular Instructions for Residue Number Systems." pith.science (2026). https://pith.science/paper/PM2SYPUN
@misc{pith2026241205286,
author = {Pith},
title = {Pith review of: RISC-V Word-Size Modular Instructions for Residue Number Systems},
year = {2026},
howpublished = {\url{https://pith.science/paper/PM2SYPUN}},
note = {Machine review of arXiv:2412.05286}
}
read the original abstract
Residue Number Systems (RNS) are parallel number systems that allow the computation on large numbers. They are used in high performance digital signal processing devices and cryptographic applications. However, the rigidity of instruction set architectures of the market-dominant microprocessors limits the use of such number systems in software applications. This article presents the impact of word-size modular arithmetic specific RISC-V instructions on the software implementation of Residue Number Systems. We evaluate this impact on several RNS modular multiplication sequential algorithms. We observe that the fastest implementation uses the Kawamura et. al. base extension. Simulations of architectures with GEM5 simulator show that RNS modular multiplication with Kawamura's base extension is 2.76 times faster using specific word-size modular arithmetic instructions than pseudo-Mersenne moduli for In Order processors. It is more than 3 times for Out of Order processors. Compared to x86 architectures, RISC-V simulations show that using specific instructions requires 4.5 times less cycles in In Order processors and 8 less in Out of Order ones.
Figures
Figures from the paper (3 more)
Reference graph
Works this paper leans on
-
[1]
Validation of the gem5 simulator for x86 architec- tures
Ayaz Akram and Lina Sawalha. Validation of the gem5 simulator for x86 architec- tures. In2019 IEEE/ACM Performance Modeling, Benchmarking and Simulation of High Performance Computer Systems (PMBS), pages 53–58. IEEE, 2019
work page 2019
-
[2]
ISA extensions for finite field arithmetic accelerating kyber and newhope on RISC-V
Erdem Alkim, Hülya Evkan, Norman Lahr, Ruben Niederhagen, and Richard Petri. ISA extensions for finite field arithmetic accelerating kyber and newhope on RISC-V. IACR Transactions on Cryptographic Hardware and Embedded Systems, 2020(3), 2020
work page 2020
-
[3]
S. Antão, J.-C. Bajard, and L. Sousa. RNS based elliptic curve point multiplication for massive parallel architectures.The Computer Journal, 55(5):629–647, 2012
work page 2012
-
[4]
Ef- ficient word size modular multiplication over signed integers
Daichi Aoki, Kazuhiko Minematsu, Toshihiko Okamura, and Tsuyoshi Takagi. Ef- ficient word size modular multiplication over signed integers. In2022 IEEE 29th Symposium on Computer Arithmetic (ARITH), pages 94–101. IEEE, 2022
work page 2022
-
[5]
RISC-V "V" Vector Extension, Version 0.9-draft-1535cc0
Krste Asanovi. RISC-V "V" Vector Extension, Version 0.9-draft-1535cc0. EECS Department, University of California, Berkeley, 2019
work page 2019
-
[6]
An RNS montgomery modular mul- tiplication algorithm
J-C Bajard, L-S Didier, and Peter Kornerup. An RNS montgomery modular mul- tiplication algorithm. IEEE Transactions on Computers, 47(7):766–776, 1998
work page 1998
- [7]
-
[8]
Bajard, Julien Eynard, Anwar Hasan, and Vincent Zucca
J.-C. Bajard, Julien Eynard, Anwar Hasan, and Vincent Zucca. A full RNS variant of fv like somewhat homomorphic encryption schemes. InSAC 2016, Selected Areas in Cryptography, St. John’s, Newfoundland and Labrador, Canada, 2016. 18 Laurent-Stéphane Didier and Jean-Marc Robert
work page 2016
Show all 45 references
-
[9]
Bajard and L
J.-C. Bajard and L. Imbert. A full RNS implementation of RSA.IEEE Transac- tions on Computers, 53(6):769–774, 2004
2004
-
[10]
The gem5 simulator.ACM SIGARCH computer architecture news, 39(2):1–7, 2011
Nathan Binkert, Bradford Beckmann, Gabriel Black, Steven K Reinhardt, Ali Saidi, Arkaprava Basu, Joel Hestness, Derek R Hower, Tushar Krishna, Somayeh Sardashti, et al. The gem5 simulator.ACM SIGARCH computer architecture news, 39(2):1–7, 2011
2011
-
[11]
Accuracy evaluation of gem5 simulator system
Anastasiia Butko, Rafael Garibotti, Luciano Ost, and Gilles Sassatelli. Accuracy evaluation of gem5 simulator system. In7th International workshop on reconfig- urable and communication-centric systems-on-chip (ReCoSoC), pages 1–7. IEEE, 2012
2012
-
[12]
Residue number systems: A new paradigm to datapath opti- mizationforlow-powerandhigh-performancedigitalsignalprocessingapplications
Chip-Hong Chang, Amir Sabbagh Molahosseini, Azadeh Alsadat Emrani Zarandi, and Tian Fatt Tay. Residue number systems: A new paradigm to datapath opti- mizationforlow-powerandhigh-performancedigitalsignalprocessingapplications. IEEE Circuits and Systems Magazine, 15(4):26–44, 2015
2015
-
[13]
RISC-V instruction set architecture extensions: A survey.IEEE Access, 11:24696–24711, 2023
Enfang Cui, Tianzheng Li, and Qian Wei. RISC-V instruction set architecture extensions: A survey.IEEE Access, 11:24696–24711, 2023
2023
-
[14]
A software comparison of RNS and PMNS
Laurent-Stéphane Didier, Jean-Marc Robert, Fangan Yssouf Dosso, and Nadia El Mrabet. A software comparison of RNS and PMNS. In2022 IEEE 29th Sym- posium on Computer Arithmetic (ARITH), pages 86–93. IEEE, 2022
2022
-
[15]
Micro- architectural simulation of in-order and out-of-order arm microprocessors with gem5
Fernando A Endo, Damien Couroussé, and Henri-Pierre Charles. Micro- architectural simulation of in-order and out-of-order arm microprocessors with gem5. In 2014 international conference on embedded computer systems: Archi- tectures, modeling, and simulation (SAMOS XIV), pages ...
2014
-
[16]
Extending the RISC-V in- struction set for hardware acceleration of the post-quantum scheme LAC
Tim Fritzmann, Georg Sigl, and Johanna Sepúlveda. Extending the RISC-V in- struction set for hardware acceleration of the post-quantum scheme LAC. In2020 Design, Automation & Test in Europe Conference & Exhibition (DATE), pages 1420–1425. IEEE, 2020
2020
-
[17]
RISQ-V: Tightly coupled RISC-V accelerators for post-quantum cryptography.IACR Transactions on Cryp- tographic Hardware and Embedded Systems, pages 239–280, 2020
Tim Fritzmann, Georg Sigl, and Johanna Sepúlveda. RISQ-V: Tightly coupled RISC-V accelerators for post-quantum cryptography.IACR Transactions on Cryp- tographic Hardware and Embedded Systems, pages 239–280, 2020
2020
-
[18]
H. L. Garner. The residue number system.IRE Transactions on Electronic Com- puters, EL 8(6):140–147, 1959
1959
-
[19]
GNUmultipleprecisionarithmeticlibrary6.1.2
TorbjörnGranlundandal. GNUmultipleprecisionarithmeticlibrary6.1.2. https: //gmplib.org/
-
[20]
Improved plantard arithmetic for lattice- basedcryptography
Junhao Huang, Jipeng Zhang, Haosong Zhao, Zhe Liu, Ray CC Cheung, Çetin Kaya Koç, and Donglong Chen. Improved plantard arithmetic for lattice- basedcryptography. IACR Transactions on Cryptographic Hardware and Embedded Systems, 2022(4):614–636, 2022
2022
-
[21]
Yet another improvement of plan- tard arithmetic for faster kyber on low-end 32-bit iot devices
Junhao Huang, Haosong Zhao, Jipeng Zhang, Wangchen Dai, Lu Zhou, Ray CC Cheung, Cetin Kaya Koc, and Donglong Chen. Yet another improvement of plan- tard arithmetic for faster kyber on low-end 32-bit iot devices. arXiv preprint arXiv:2309.00440, 2023
2023 arXiv
-
[22]
RANTT: A RISC-V architecture extension for the number theoretic transform
Emre Karabulut and Aydin Aysu. RANTT: A RISC-V architecture extension for the number theoretic transform. In2020 30th International Conference on Field- Programmable Logic and Applications (FPL), pages 26–32. IEEE, 2020
2020
-
[23]
Cox- rower architecture for fast parallel montgomery multiplication
Shinichi Kawamura, Masanobu Koike, Fumihiko Sano, and Atsushi Shimbo. Cox- rower architecture for fast parallel montgomery multiplication. In Bart Preneel, editor, Advances in Cryptology — EUROCRYPT 2000, pages 523–538, Berlin, Heidelberg, 2000. Springer Berlin Heidelberg. RIS...
2000
-
[24]
Architecture support for bitslicing
Pantea Kiaei, Thomas Conroy, and Patrick Schaumont. Architecture support for bitslicing. IEEE Transactions on Emerging Topics in Computing, 11(2):497–510, 2023
2023
-
[25]
Art of computer programming, volume 2: Seminumerical algo- rithms
Donald E Knuth. Art of computer programming, volume 2: Seminumerical algo- rithms. Addison-Wesley Professional, 2014
2014
-
[26]
Efficient leak resis- tant modular exponentiation in rns
Andrea Lesavourey, Christophe Negre, and Thomas Plantard. Efficient leak resis- tant modular exponentiation in rns. In2017 IEEE 24th Symposium on Computer Arithmetic (ARITH), pages 156–163. IEEE, 2017
2017
-
[27]
PERCIVAL: open-source posit RISC-V core with quire capability
David Mallasén, Raul Murillo, Alberto A Del Barrio, Guillermo Botella, Luis Piñuel, and Manuel Prieto-Matias. PERCIVAL: open-source posit RISC-V core with quire capability. IEEE Transactions on Emerging Topics in Computing, 10(3):1241–1252, 2022
2022
-
[28]
Handbook of applied cryptography
Alfred J Menezes, Paul C Van Oorschot, and Scott A Vanstone. Handbook of applied cryptography. CRC press, 2018
2018
-
[29]
Arithmetic circuits for DSP applications, chapter RNS-Based arithmetic circuits and applications, pages 186–
PV Ananda Mohan, PK Meher, and T Stouraitis. Arithmetic circuits for DSP applications, chapter RNS-Based arithmetic circuits and applications, pages 186–
-
[30]
Montgomery
Peter L. Montgomery. Modular multiplication without trial division.Mathematics of Computation, 44(170):519–521, 1985
1985
-
[31]
Efficient word size modular arithmetic.IEEE Transactions on Emerging Topics in Computing, 9(3):1506–1518, 2021
Thomas Plantard. Efficient word size modular arithmetic.IEEE Transactions on Emerging Topics in Computing, 9(3):1506–1518, 2021
2021
-
[32]
Modulo reduction in residue number systems
Karl C Posch and Reinhard Posch. Modulo reduction in residue number systems. IEEE Transactions on Parallel and Distributed Systems, 6(5):449–454, 1995
1995
-
[33]
Gem5tune: A parameter auto-tuning framework for gem5 simulator to reduce errors.IEEE Transactions on Computers, 2023
Yudi Qiu, Tao Huang, Yuxin Tang, Yanwei Liu, Yang Kong, Xulin Yu, Xiaoyang Zeng, and Yibo Fan. Gem5tune: A parameter auto-tuning framework for gem5 simulator to reduce errors.IEEE Transactions on Computers, 2023
2023
-
[34]
Vector instruction set extensions for efficient computation of keccak.IEEE Transactions on Computers, 66(10):1778– 1789, 2017
Hemendra Rawat and Patrick Schaumont. Vector instruction set extensions for efficient computation of keccak.IEEE Transactions on Computers, 66(10):1778– 1789, 2017
2017
-
[35]
RISC-V GNU compiler toolchain
riscv collab. RISC-V GNU compiler toolchain. https://github.com/ riscv-collab/riscv-gnu-toolchain, 2022
2022
-
[36]
Risc5: Implementing the RISC-V ISA in gem5
Alec Roelke and Mircea R Stan. Risc5: Implementing the RISC-V ISA in gem5. In First Workshop on Computer Architecture Research with RISC-V (CARRV), volume 7, 2017
2017
-
[37]
Shenoy and R
A.P. Shenoy and R. Kumaresan. Fast base extension using a redundant modulus in RNS. IEEE Transactions on Computers, 38(2):292–297, 1989
1989
-
[38]
New York: McGraw-Hill, 1967
Nicholas S Szabo and Richard I Tanaka.Residue arithmetic and its applications to computer technology. New York: McGraw-Hill, 1967
1967
-
[39]
Embedded systems design with special arithmetic and number systems, chapter Fault-tolerant computing in redundant residue number system, pages 65–88
Thian Fatt Tay and Chip-Hong Chang. Embedded systems design with special arithmetic and number systems, chapter Fault-tolerant computing in redundant residue number system, pages 65–88. Springer, 2017
2017
-
[40]
Residue arithmetic a tutorial with examples.Computer, 17(5):50–62, 1984
Taylor. Residue arithmetic a tutorial with examples.Computer, 17(5):50–62, 1984
1984
-
[41]
PERI: A con- figurable posit enabled risc-v core.ACM Transactions on Architecture and Code Optimization (TACO), 18(3):1–26, 2021
Sugandha Tiwari, Neel Gala, Chester Rebeiro, and V Kamakoti. PERI: A con- figurable posit enabled risc-v core.ACM Transactions on Architecture and Code Optimization (TACO), 18(3):1–26, 2021
2021
-
[42]
Application of the residue number system to reduce hardware costs of the convolutional neural network implementation.Mathematics and computers in simulation, 177:232–243, 2020
Maria V Valueva, NN Nagornov, Pavel Alekseevich Lyakhov, Georgii V Valuev, and Nikolay I Chervyakov. Application of the residue number system to reduce hardware costs of the convolutional neural network implementation.Mathematics and computers in simulation, 177:232–243, 2020....
2020
-
[43]
Hardware-validated CPU performance and energy modelling
Matthew Walker, Sascha Bischoff, Stephan Diestelhorst, Geoff Merrett, and Bashir Al-Hashimi. Hardware-validated CPU performance and energy modelling. In2018 IEEE International Symposium on Performance Analysis of Systems and Software (ISPASS), pages 44–53. IEEE, 2018
2018
-
[44]
EECS Department, University of Cal- ifornia, Berkeley, 2019
Andrew Waterman and Krste Asanovi.The RISC-V Instruction Set Manual Vol- ume I: Unprivileged ISA version 20191213. EECS Department, University of Cal- ifornia, Berkeley, 2019
2019
-
[236]
John Wiley & Sons, 2017
2017
Reviewed August 12, 2026 · model on record in the stance chip above.
Discussion (0). Continue with ORCID to comment.