-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
using Apple clang with USE_OPENMP=1 #5156
Comments
I'm not entirely sure - according to the R link, one would need to obtain a third-party libomp for linking to work with the Apple version of LLVM, so it is far from a standard environment (and apparently one actively discouraged by Apple for whatever reason). At the very least, I'd need to check if a non-Apple clang would cope with the extra And as I understand it, your initial problem arises from trying to use the pkgconfig file from&for a gcc build to obtain your CFLAGS setting - I think the build would probably work correctly if you would run it as |
Apple wants to push users away from OSS into using their own libraries and tools. Just as the botch Python they ship, etc. I have no idea how much more performance one gets on macOS from openblas by enabling openmp. Current Homebrew openblas is built with GNU OpenMP (libgomp). I have no idea about it being compatible with clang's idea of OpenMP. If it is compatible, one can think of using GNU OpenMP with clang, no need for R Project's implementation of OpenMP on macOS. |
I don't think a change needs to be made here. As described in the linked R doc, the reason it doesn't work is because Apple has disabled OpenMP on purpose and doesn't ship Conda-forge is shipping OpenBLAS built with |
Homebrew does ship libomp, so it might make perfect sense to try using it with openblas Homebrew. I just don't know how flexible openblas cmake build is to accommodate such a setup. |
OK, I am making progress with building openblas with OpenMP support from LLVM's libomp, as installed by Homebrew, There are couple of issues/bugs I encountered in the build, see below. Overcoming them, I ran
I called cmake as follows, in clean
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -105,6 +105,7 @@ message(WARNING "CMake support is experimental. It does not yet support all buil
if (USE_OPENMP)
find_package(OpenMP REQUIRED)
+ include_directories("/opt/homebrew/include")
endif ()
include("${PROJECT_SOURCE_DIR}/cmake/utils.cmake")
Would you be interested in a PR fixing 1 and/or 2? |
PS. There is also one more quirk to be fixed: openblas.pc is not make quite correct, I got
Here Although EDIT - or probably there is nothing to fix here, it's just default values, which can be changed by passing appropriate parameters to cmake. |
I wonder what is the point of getting only libomp from homebrew while continuing to use the Apple-flavored clang, when I guess you could get the entire toolchain from homebrew and solve the include path issue that way ? |
Also, Homebrew does not mandate a full Homebrew toolchain. |
The output of Homebrew builds with GCC, so it will be pulling in |
Thus we see that it's possible to trick openblas' cmake build into producing an incorrect libopenblas, isn't it? |
Currently a macOS toolchain with Apple's clang 16+ and gfortran fails with
make
build ifUSE_OPENMP=1
is set.The 1st reason for this is that clang rejects
-fopenmp
, for it needs-Xclang -fopenmp
option, as written by R Project in https://mac.r-project.org/openmp/This was discovered while I bumped into a Homebrew problem, described in Homebrew/homebrew-core#209091
Is there any interest in looking into it further? In principle, R Project might have a point here.
The text was updated successfully, but these errors were encountered: