A Study of High Performance Multiple-Precision Integer Multiplication and Division Using SIMD Instructions
Year: 2023
Type: article
Abstract: Arithmetic operations are the most basic calculations and are versatile enough to be used in all fields.Among arithmetic operations, multiplication and division are relatively expensive due to their complexity.Modern central processing units can quickly perform 64-bit arithmetic operations, even division.However, higher-precision arithmetic operations cannot be performed with a single instruction.Instead, they must be solved in software.These operations are most commonly used in cryptography and computer algebra processing.Single instruction, multiple data (SIMD) instructions process multiple data in parallel with a single instruction.Most modern processors support 128-and 256-bit-wide SIMD instructions.The latest processors support 512-bit-wide instructions, which allows, for example, eight 64-bit integers to be processed simultaneously.Thus, SIMD instructions have the potential to process large integer operations at high speed.However, current SIMD instructions do not hold the carry that occurs when addition is performed.Large integer multiplication and division result in many addition operations, which generate many carries.Therefore, the carry problem cannot be ignored when using SIMD instructions.One way to solve this problem is to pre-convert the numerical representation of the input.Specifically, a large integer can be represented using a smaller number of bits by means of the reduced-radix representation.Reducing the number of bits creates space to accumulate the carries.The accumulated carries are processed at the end of the calculation, allowing the rest of the calculation to be processed in parallel with SIMD instructions.This thesis combines the reduced-radix representation with 512-bit-wide SIMD instructions to speed up large integer multiplication and division.The target instructions are Intel Advanced Vector Extensions-512 (AVX-512) on Intel processors and Arm Scalable Vector Extension (SVE) on Arm processors.Programs implemented for these processors are executed and compared in terms of execution time with the GNU Multiple Precision Arith-metic Library (GMP), a library that performs large integer operations using scalar instructions.For large integer multiplication with AVX-512, the basic instruction set AVX-512F (Foundation) and the integer sum-of-products instruction set AVX-512IFMA (Integer Fused Multiply-Add) are used.The basic multiplication algorithm (Basecase method) and the Karatsuba method are applied to these instructions.Xeon Phi Knights Landing (KNL) processors and Cannon Lake microarchitecture processors are used in the performance evaluation to compare the implemented program and GMP.The results show that the programwith AVX-512F applied to the Basecase method improved performance by up to 2.5x on KNL and that the program with AVX-512IFMA applied to the Karatsuba method improved performance by up to 2.97x on Cannon Lake.Arm's SIMD instruction set, SVE, was similarly applied to large integer multiplication.Since this instruction set has instructions that perform 64-bit multiplication, this study proposes an algorithm to keep the reduced-radix representation consistent.In the performance evaluation, an implementation program that combines this algorithm and the SVE instruction set is run on Fujitsu's A64FX processor.The program is compiled in two modes: one the Fujitsu compiler-based trad mode and the other the Clang/LLVM-based clang mode.The performance gains are up to 36% with trad mode compilation and up to 31% with clang mode compilation compared with GMP.For large integer division, AVX-512IFMA instructions are used.A multiplication-based division algorithm with inverses can be applied for this task.Because AVX-512IFMA takes only 52 bits of the multiplication operand, it is necessary to properly handle the carry to ensure correct calculation.However, handling the carry is not an essential part of the calculation and should be avoided as much as possible.Therefore, this thesis proposes a division algorithm that is more suitable for SIMD instructions.In the performance evaluation, the execution time for large integer division with various operand sizes is measured on a Cannon Lake processor.The results show an average performance improvement of 25% to 35% over GMP.These results demonstrate that SIMD instructions and the reduced-radix representation can be used to accelerate large integer multiplication and division.In the future, highspeed large integer multiplication and division can be performed using SIMD instructions on various computers.
Authors: 枝松, 拓弥, エダマツ, タクヤ, Edamatsu, Takuya
Language: English
Subfield: Information Systems
Field: Computer Science
Domain: Physical Sciences
Open Access status: green
OpenAlex ID: W7024934369
