nejeoui/MPA-OpenCl: v1.0.0

Read full text
Authors: Nejeoui Abderrazzak
Cited by: 3

Abstract

MPA-OpenCL v1.0.0 Portable multiple-precision arithmetic for OpenCL 1.2. Fifteen fixed-width big-integer operations at operand widths from 256 to 2048 bits and word sizes of 8, 16 and 32 bits, from one source with no device-specific code path. Correctness Every configuration is checked word-for-word against GMP before it is timed, unconditionally, with no flag to disable it. make test — 35 kernel builds, 298 470 differential cases, 0 failures Directed edge cases constructed from the algebra rather than sampled Test harness itself validated by fault injection CI builds on Ubuntu against PoCL, runs the suite and the Montgomery reachability check, and asserts that mpa_run links neither GMP nor OpenSSL Measured reach Benchmark reports for 26 GPUs across four vendors and five runtimes are now published under reports/ — NVIDIA (CUDA ICD and PoCL), AMD (ROCm), Intel (NEO) and Apple, Pascal through Grace-Blackwell, plus nine CPU devices through PoCL. 10 225 timed configurations, no incorrect result attributable to the library. reports/README.md carries a device index and a per-report validity table, and documents the counting rule so both figures can be reproduced from the CSVs. Changes in this release Repository layout All source moved to src/; binaries still build at the repository root LICENSE renamed LICENSE.txt Kernels are located at run time by searching the working directory, then src/, then ../src/; MPA_KERNEL_DIR overrides. Binaries therefore work from the repository root and from inside src/ alike Kernels Little-endian Montgomery path in the optimised 32-bit kernel: montMulLE, montReduceLE, and a modular exponentiation that stays little-endian throughout, removing per-call operand reversal reduceFastN computes a mod p as MontReduce(MontMul(a, R2)) instead of bit-serial reduction Separated-operand-scanning Montgomery squaring available behind MPA_MONTSQR (default off: it is correct but slower, being register-bound) Benchmark harness (GPU_Host) --cgbn FILE, and the default CGBN results file is now named per device (cgbn_results_ .tsv). The header's device is matched against the report being built, and files containing merge-conflict markers are rejected. This closes a defect where a stale results file could be attributed to the wrong GPU Multi-threaded CPU baseline corrected: one OpenMP fork/join per timed interval with a hand-partitioned range, instead of entering a parallel region inside the repetition loop. The previous form charged region-entry cost to every repetition and understated the multi-threaded figures Section 5 ratios normalise GPU time to the CPU item count when the two differ A lost device is distinguished from an unlaunchable kernel, and launch failures report variant, modulus, operation, error name, code and stage Timed phase is error-checked; failed or timed-out cells are omitted from the CSV rather than written as inf --variants NAME[:N],... runs an ordered subset, optionally at 1/N of the item count, so a budget is spent on the configurations of interest first Tooling src/validate_reports.py — per-report column validity: MPA, CPU and CGBN checked independently, with detection of duplicated CGBN columns, item-count mismatches, pre-fix baselines and zero-second rows src/rebuild_cgbn_column.py — rebuilds a report's CGBN column and recomputes section 5 from the CSV, refusing a results file recorded on other hardware Known limitations Not constant time: conditional subtractions and early-return comparisons are data-dependent, so unsuitable as-is for operations on secret material 2048-bit modular exponentiation is register-bound; a sliding window and a smaller CIOS footprint are the known next steps Odd moduli only, as Montgomery arithmetic requires; even moduli are rejected rather than mishandled Operand width is fixed per build (WORDLENGTH_T) Two platforms return wrong or absent results for reasons outside the library: the Intel Xe integrated GPU refuses to launch in 445 of 485 configurations (CL_INVALID_WORK_ITEM_SIZE), and the Apple M2 silently returns unwritten buffers above a batch-size threshold while reporting success. Both are documented in reports/; unconditional verification is what catches them Requirements OpenCL 1.2 ICD, GMP >= 6.0, OpenSSL >= 1.1. Optionally OpenMP for the multi-threaded CPU baselines, and a CUDA toolkit with CGBN for the reference comparison. Built and tested on Linux, macOS and Windows/WSL2. Apache License 2.0.

Publication details

Journal / source
Zenodo (CERN European Organization for Nuclear Research)
Publication date
15 September 2026