Gavin,

> On Apr 24, 2025, at 9:58 PM, Gavin Simpson <ucfa...@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@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
> 

_______________________________________________
R-SIG-Mac mailing list
R-SIG-Mac@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-mac

Reply via email to