Enable OpenMP support for CRAN Mac binaries #615
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
At present, CRAN's Mac binary builds of
fixestdon't enable OpenMP support. This is pretty well documented in other issues around the repo, where our current workaround advice is for users to configure their.R/Makevarsand install from source if they want multi-threaded performance.However... it turns out that CRAN has actually supported binary MacOS builds with the OpenMP runtime enabled since R 4.3.0. I know of several packages taking advantage of this service, including
data.table. (See @kevinushey's initial PR here: Rdatatable/data.table#6034)The key thing is to make CRAN's build system aware of OpenMP detection in order to enable the appropriate compiler flags.
This PR
stealsborrows the same basic configuration thatdata.tableuses to enable the same out-of-the-box OpenMP runtime support forfixest. The solution basically involves shipping aconfigurescript that actively detects OpenMP availability. This configure script:src/Makevarsbased on detection resultsTesting
Local testing shows the configure script works correctly:
I would also suggest that we submit a version to CRAN's MacOS builder, but @lrberge should probably do that as the listed maintainer.
Expected Impact
After this change, CRAN's Mac binary builds should include OpenMP support, giving Mac users the same multithreaded performance as other platforms without requiring source installation.
Refs