Replies: 18 comments 13 replies
-
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 |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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? |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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 ? |
Beta Was this translation helpful? Give feedback.
-
Also, Homebrew does not mandate a full Homebrew toolchain. |
Beta Was this translation helpful? Give feedback.
-
The output of Homebrew builds with GCC, so it will be pulling in |
Beta Was this translation helpful? Give feedback.
-
Thus we see that it's possible to trick openblas' cmake build into producing an incorrect libopenblas, isn't it? |
Beta Was this translation helpful? Give feedback.
-
I'm not sure what the last comment means - you can always "trick" builds of complex packages to have a non-optimal or non-functional outcome. I think this issue should be resolved by either closing without a change, or adding a note to the Install section of the docs, something like: "Apple discourages use of OpenMP when using the Apple Clang compiler; if you use that compiler then prefer building with the default |
Beta Was this translation helpful? Give feedback.
-
@rgommers can one use gfortan with libomp? If so, we could have a functional build of openblas with Apple clang and gfortan. It does not seem to work the other way around, using only libgomp with Apple clang (and gfortan), as there is some kind of incompatibility - it doesn't seem to be possible to build a working executable (say, of a standard OpenMP example) using Apple clang and libgomp. |
Beta Was this translation helpful? Give feedback.
-
I'm not sure, I can't remember anyone trying or any project shipping binaries built this way. I am still unclear on why you're so interested in this, it just seems like a bad idea to do this kind of mixing. |
Beta Was this translation helpful? Give feedback.
-
We do in conda-forge. Just need a symlink from libgomp.so to libomp.so. |
Beta Was this translation helpful? Give feedback.
-
because mixing different C/C++ toolchains in one project is not much better than mixing different OpenMP libraries. For Homebrew, and on *BSDs, clang+gfortran is the usual toolchain. Using libgomp, as the current Homebrew package does, does not allow any OpenMP use on the C side. |
Beta Was this translation helpful? Give feedback.
-
that's a hack. Is there a nice, proper way to call cmake to achieve the same effect? |
Beta Was this translation helpful? Give feedback.
-
converting this topic to a discussion - I do not get the impression that there is anything here that OpenBLAS could or should be changing |
Beta Was this translation helpful? Give feedback.
-
Thanks, @martin-frbg for keeping this open. I still think that OpenBLAS should build on macOS (or other clang+gfortran toolchains - e.g. that's the normal toolchain on FreeBSD and OpenBSD, as well as on Android, ChromeOS, OpenMandriva, and Chimera Linux) without any drastic measures like patching config files or making And at least as far as the Would you consider a PR implementing changes to the |
Beta Was this translation helpful? Give feedback.
-
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.
Beta Was this translation helpful? Give feedback.
All reactions