[R] How to set the correct libomp for R

ger@ophii m@iii@g oii gmx@@et ger@ophii m@iii@g oii gmx@@et
Mon Apr 8 10:29:53 CEST 2024

Hey everyone,

I have some weird issue with using multithreaded data.table in macOS and I am trying to figure out, if it’s connected to my libomp.dylib. I started using libomp as stated here: https://mac.r-project.org/openmp/
Everything worked fine till beginning of this year, but all of a sudden, I get random fatal errors, when using data.table with multithreading. I figured that R (used in RStudio) is not loading this libomp.dylib (located at /usr/local/lib/libomp.dylib), but the one bundled with R (/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libomp.dylib). I sued this command to check for this:

system(paste("lsof -p", Sys.getpid(), "| grep dylib"))
I never checked, which one was used before, but this raised some questions for me:
1. Was libomp.dylib always bundled with R and if yes, what’s the point of this separate libomp.dylib from this page (https://mac.r-project.org/openmp/)?
2. Is there a way to set the libomp.dylib to another path and does this even make sense or should I always use the one bundled with R?
3. Could it be that one of the libraries is used for installing packages by Xcode’s clang and the other is used during usage of the package?
Maybe someone could shed some light onto this topic :).
P.S.: If you need some more details about the actual issue with data.table you can also check here (https://github.com/rstudio/rstudio/issues/14517) and here (https://github.com/Rdatatable/data.table/issues/5957). Or you can of course ask me, but it would be a little overkill to share everything that has been tried yet :).

More information about the R-help mailing list