4 ms·
Does anyone know why the clang that comes with macOS does not support OpenMP, even though upstream clang does? I use OpenMP to teach basic parallel programming
by Athas 3y ago
Does anyone know why the clang that comes with macOS does not support OpenMP, even though upstream clang does? I use OpenMP to teach basic parallel programming, and it is really annoying that the macOS users have to install another compiler to get it working.
(The problem is exacerbated by the ridiculous fact that macOS includes a 'gcc' alias that is not in fact GCC, and which risks shadowing a proper GCC that the students install themselves.)
- typesanitizer 3y agoI don't know the answer to your original question, but based on this StackOverflow answer (https://stackoverflow.com/a/60564952/2682729 https://stackoverflow.com/a/60564952/2682729), it seems like a small compiler wrapper should do the trick to get the same experience across platforms without having to install another compiler. Depending on the platforms you need to support, a more heavyweight but more reproducible solution would be to use a fixed LLVM toolchain, say using Bazel.
- cpgxiii 3y agoWhen Apple initially moved to clang instead of GCC, clang did not support OpenMP. Apple chose vendor lock-in with Grand Central Dispatch (in the same way they would chose vendor lock-in with Metal years later) rather than invest the time in the existing work on a competitive clang OpenMP implementation. I think the track record of Apple on supporting anything standardized speaks for itself (see OpenGL, OpenCL, OpenMP, C & C++ features, etc) - Apple gives as few fucks about cross-platform development as possible. Apple sees its platform being so valuable that developers will jump through whatever hoops Apple puts in their way, and largely their developers put up with this.
- trelane 3y ago> Apple chose vendor lock-in with Grand Central Dispatch I will note here that this vendor lock-in is one of the (if not the) main reasons Apple et al. moved away from the GPLed GCC. The ability to lock in users is the central difference between open source and Free Software. As such, this is WAI from the Open Source perspective.
- cpgxiii 3y agoThis isn't necessarily a free software versus open source issue. Apple could have just as easily continued to ship a GCC version with OpenMP disabled. Sure you could build your own with-OpenMP GCC from source, just like you can build MacOS-compatible upstream Clang from source now. But third-party dev tools will always be a pain and an additional barrier to use. There are a couple of notable examples of major software shipping OpenMP-using code on MacOS, namely R and Matlab, but the structure of these projects means that few of their users have to encounter the complexity of getting an OpenMP-supporting toolchain working. Not so easy for a library author where nearly all of your users will need to use a special toolchain.
- trelane 3y ago> Apple could have just as easily continued to ship a GCC version with OpenMP disabled. Sure, and one of their users could have distributed a version that put it back in.
- cornstalks 3y agoOpenMP vs GCD? That’s apples and oranges. They’re not even in the same ballpark. I can’t fathom how GCD fills the same needs OpenMP targets, nor can I see how GCD is Apple’s “no” response to OpenMP. And GCD is open source (not sure when the source was first made available, though). It even supports Linux (thanks to Swift) though that’s recent.
- cpgxiii 3y agoOpenMP and GCD are very different in some ways, yet very similar in others. Both provide threadpool-based parallelism, and both provided "managed" parallelism well before C and C++ gained standardized parallelism via std::async/std::future/std::thread. If you want vendor-supported threadpool parallelism on MacOS, GCD was the singular answer for years. They aren't exactly compatible, but neither are Cilk or TBB to OpenMP, yet all of these approaches can be used to perform a similar subset of parallelized operations. libdispatch is open source, and available on Linux, but I can't see any reason to use it versus the alternatives of TBB and OpenMP, unless you were trying to port an application/library originally written for MacOS/iOS.
- BlackFingolfin 3y agoOpenCL was created by Apple...