{"slug": "bit-reproducibilty-on-gpu-accelerated-fortran", "title": "Bit-reproducibilty on GPU-accelerated Fortran", "summary": "A developer achieved bit-reproducibility between CPU and GPU calculations for transcendental functions in Fortran by wrapping the bitrep C++ library and adding OpenACC/OpenMP directives, with a performance penalty of approximately 3-4× slowdown compared to standard math libraries. The work, tested on NVIDIA and AMD GPUs, is available on GitHub and has been independently verified by another developer porting a weather model using the NVIDIA HPC SDK and Flang.", "body_md": "While working on an OpenACC GPU port of a CFD solver with OpenACC, I wanted to maintain bit-reproducibility between existing CPU calculations and GPU-accelerated kernels — particularly for mathematical transcendental functions (`sin`\n\n, `cos`\n\n, `exp`\n\n, etc.).\n\nI tested the bitwise-reproducible algorithms from [Arteaga et al. (2014)](https://doi.org/10.1109/IPDPS.2014.127). By wrapping the original `bitrep`\n\nC++ source with a Fortran interface and adding OpenACC/OpenMP directives (plus disabling compilers fused multiply-add optimizations) I achieved reproducibility between CPU and GPU in pure transcendental kernels.\n\nHere a few note:\n\n- Bit-reproducible results have been tested on several architectures of NVIDIA and AMD GPUs.\n- Performance penalty ~3-4× slowdown compared to standard math libraries\n- Equivalent performance on OpenACC/OpenMP with NVHPC SDK compiler (as expected)\n- Haven’t yet tested directly in CUDA/HIP kernels to determine if the performance loss could be reduced by removing the OpenACC/OpenMP overhead\n\nThe GPU Fortran interface and the tests I used are available on: [GitHub - loicreynier/bitrep: Bit-reproducible CPU/GPU math transcendental functions with Fortran interface · GitHub](https://github.com/loicreynier/bitrep)\n\nI’m curious if anyone has explored similar of different approaches for achieving bit-reproducibility in GPU or even CPU codes?\n\n2 Likes\n\n[MetMan](https://fortran-lang.discourse.group/u/MetMan)\n2\nHi, LoicReynier.\n\nI’m also porting a weather model to a GPU platform project, using the bitrep library to achieve bitwise reproducibility verification across CPU and GPU platforms. Tests passed with the NVIDIA HPC SDK (CPU vs GPU) and with Flang (Sugon CPU vs GPU). My bitrep github repo: [qingu/bitrep: reproducible CPU/GPU transcendental functions with Fortran interface](https://github.com/qingu/bitrep)\n\nHave you tested bitwise reproducibility across different compilers on the CPU platform?\n\nCPU IEEE float and GPU IEEE float are different, so a cross-backend mismatch is actually expected. A good way to (kinda) fight it is through same-backend regression and analysis instead.", "url": "https://wpnews.pro/news/bit-reproducibilty-on-gpu-accelerated-fortran", "canonical_source": "https://fortran-lang.discourse.group/t/bit-reproducibilty-on-gpu-accelerated-fortran/11022#post_3", "published_at": "2026-07-28 11:47:58+00:00", "updated_at": "2026-07-28 12:05:48.758455+00:00", "lang": "en", "topics": ["artificial-intelligence", "machine-learning", "ai-infrastructure"], "entities": ["NVIDIA", "AMD", "NVHPC SDK", "Flang", "GitHub", "Arteaga et al. (2014)", "loicreynier/bitrep", "qingu/bitrep"], "alternates": {"html": "https://wpnews.pro/news/bit-reproducibilty-on-gpu-accelerated-fortran", "markdown": "https://wpnews.pro/news/bit-reproducibilty-on-gpu-accelerated-fortran.md", "text": "https://wpnews.pro/news/bit-reproducibilty-on-gpu-accelerated-fortran.txt", "jsonld": "https://wpnews.pro/news/bit-reproducibilty-on-gpu-accelerated-fortran.jsonld"}}