[R-SIG-Mac] Clarifying the status of OMP in CRAN binaries on Mac
Gavin Simpson
uc|@g|@ @end|ng |rom gm@||@com
Fri Apr 25 11:53:35 CEST 2025
Thanks Simon, that's really helpful - I find the R manuals confusing
on this issue in part because things MacOS X related are bound up in
"Unix-alike" sections and there are often clauses and / or footnotes
relating to MacOS X but it's unclear what relates to CRAN builds /
configuration vs doing things on one's own system. If I were more
knowledgeable about this stuff I would suggest some changes, but
perhaps it's clear once one has gained sufficient knowledge :-)
I've had another close read of data.table's configure script and I
think I understand what is needed so that I can try to help Simon
(Wood) and Ben and Mollie with getting this configured in mgcv and
glmmTMB using the relevant bits from data.table.
And again, thank you for helping me through all this, and - because
I'm sure it doesn't get said enough - for everything you do to support
R on Mac!
FYI: there does seem to be a real problem related to OpenMP with clang
1700 provided in Xcode 16.3 (which got installed when or alongside the
system updates for Sequoia 15.4.1) - I'm seeing the same issue
reported here https://github.com/Rdatatable/data.table/issues/6622 and
down some deep rabbit hole I went digging into the error message I saw
during compilation of mcgv I saw reports that this was a bug in llvm
that was affecting this version of clang, but I can't find the source
for that now. I've downgraded to 16.2 now so I just have one problem
to solve (compile my own R or ditch homebrew).
The other day I said I had R installed from Homebrew and that it was
CRAN's binary. This is true, but I neglected the difference between
installing R as a formula or as a cask. The latter installs CRAN's
binary of R, while installing as a formula would lead to a local
compilation from sources using Homebrew. Sorry about that confusion.
All the best
G
On Thu, 24 Apr 2025 at 23:35, Simon Urbanek <simon.urbanek using r-project.org> wrote:
>
> Gavin,
>
>
> > On Apr 24, 2025, at 9:58 PM, Gavin Simpson <ucfagls using gmail.com> wrote:
> >
> > Dear list,
> >
> > I'm trying to clarify my understanding of what is and is not implemented / expected in terms of openMP support in R and CRAN package *binaries* for MacOS on apple silicon.
> >
> > I have the CRAN's R binary for MacOS X (apple silicon) and also the CRAN binaries for two packages, glmmTMB and mgcv, both of which seem to be instrumented (following WRE) to use OpenMP if available. And from discussions here I understand that thanks to Simon and others, OpenMP support for MacOS X is in R and so should I expect OpenMP to work in these two packages?
> >
>
>
> No, OpenMP is not supported by Apple compilers, so R does not enable OpenMP support. You can see that in the logs, e.g:
>
> https://mac.r-project.org/logs/log-R-4.5-branch.big-sur.arm64.html
> [...]
> checking for clang -arch arm64 -std=gnu2x option to support OpenMP... unsupported
>
> That said, packages are free to run their own tests if they desire, so anything further is package-dependent. Most packages simply use R's settings and thus don't use OpenMP on macOS.
>
> In cases where the package authors decided that OpenMP is critical for the package they can choose to add a check for '-Xclang -fopenmp' which will force Apple compilers to generate OpenMP code *if* a run-time is available (which is not the case for Apple tools) even if it is not supported by Apple. In that case the package's CRAN binary will have OpenMP support, because the run time is available on the CRAN build machines to support such packages. However, that only applies to the CRAN binaries, it is not supported for source installation due to the lack of support by Apple.
>
> Cheers,
> Simon
>
>
> > If I am, neither of them is working on various of my Mac systems; model fitting is single threaded and the test functions that glmmTMB and mgcv use to detect OMP support both return FALSE:
> >
> > R version 4.5.0 (2025-04-11) -- "How About a Twenty-Six"
> > Platform: aarch64-apple-darwin20 (64-bit)
> > r$> glmmTMB::omp_check()
> > [1] FALSE
> > r$> mgcv:::mgcv.omp()
> > [1] FALSE
> >
> > Is this reproducible on other's systems? (Could someone run those two bits of code on their systems if they use the MacOS X R binary from CRAN and the CRAN Mac binaries for the packages - running mgcv's test should be easier as this pkg is shipped with the R binary).
> >
> > I am happy to provide further system details, but at this point I'm mostly hoping to clarify what I should expect and whether what I'm seeing is typical?
> >
> > Thanks in advance
> >
> > Gavin
> >
> > --
> > Gavin Simpson, PhD [he/him/his]
> > [tw] @ucfagls [OrciD] 0000-0002-9084-8413
> > [web] fromthebottomoftheheap.net
> > • Assistant Professor
> > • Department of Animal & Veterinary Sciences, Aarhus University
> > • Adjunct Professor, Department of Biology, University of Regina.
> >
> > _______________________________________________
> > R-SIG-Mac mailing list
> > R-SIG-Mac using r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-mac
> >
>
--
Gavin Simpson, PhD [he/him/his]
[tw] @ucfagls [OrciD] 0000-0002-9084-8413
[web] fromthebottomoftheheap.net
• Assistant Professor
• Department of Animal & Veterinary Sciences, Aarhus University
• Adjunct Professor, Department of Biology, University of Regina.
More information about the R-SIG-Mac
mailing list