MPCR: Multi-Precision Computations Package in R
Mary Lai O. Salvana, Sameh Abdulah, Minwoo Kim, David Helmy, Ying Sun, Marc G. Genton
TL;DR
A new R package that supports arithmetic operations at 16-, 32-, and 64-bit precision, and delivers highly optimized multi-precision computations on both CPU and GPU, enabling seamless low-precision operations is introduced.
Abstract
In the early days of computing, severe memory constraints made it necessary to use lower floating-point precision. As hardware capabilities have advanced, modern systems, particularly in computational statistics and scientific computing, have widely adopted 64-bit precision to reduce numerical errors and support complex calculations. However, in some applications, double-precision accuracy exceeds practical requirements, prompting interest in lower-precision alternatives that decrease computational complexity while maintaining adequate accuracy. This trend has accelerated with the advent of hardware optimized for low-precision computations, such as leveraging Tensor Cores technology in recent NVIDIA GPUs. Although lower precision can introduce numerical and accuracy challenges, many applications demonstrate robustness under these conditions. Consequently, new multi-precision algorithms have been developed to balance accuracy and computational cost. To facilitate the adoption of these approaches in statistical computing, this article introduces MPCR, a new R package that supports arithmetic operations at 16-, 32-, and 64-bit precision. Written in C++ and integrated with Rcpp, MPCR delivers highly optimized multi-precision computations on both CPU and GPU, enabling seamless low-precision operations. Several examples demonstrate the benefits of MPCR across both performance and accuracy.
