Clang not compiled with OpenMP support
It is impossible to use OpenMP with Clang from scratch, whil GCC still has it.
With the deprecation of GCC, Clang should be built with its support.
@stephenhines any idea what we need to get openmp in clang?
I think it requires us pulling down another external project to build (http://openmp.llvm.org/). This is something of a feature request, because the prior Clang toolchain shipped in the NDK was from a different forked set of sources (that likely included this library).
Okay, tentatively triaged for r12, but that might slip a ways unless I'm seriously underestimating the demand for openmp on mobile devices.
I filed an internal bug for this as well: Bug, so that we can keep track of what is needed (creation of new repos, etc., that can't be easily handled here on the github tracker).
Technically, clang just needs to be compiled with openmp support, if ndk's clang is a direct port of the original project, as stated in its homepage http://openmp.llvm.org/
Also, release notes of r11 state that clang3.8 got introduced, but only 3.6 looks available. When upgrading to post 3.7, openmp support should be straightforward as it should be integral part of clang itself: http://openmp.org/wp/2015/08/clang-37-will-have-full-openmp-31-support/
Just entirely upgrading clang to 3.8 should fix the issue.
Also, release notes of r11 state that clang3.8 got introduced, but only 3.6 looks available.
There are still a number of files that have "3.6" in the name, but that's just cleanup I didn't finish (because it's afaik not in anywhere user visible). It is in fact a 3.8svn release.
$ android-ndk-r11/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --version
clang version 3.8.243773
Target: x86_64-unknown-linux
Thread model: posix
@DanAlbert
underestimating the demand for openmp on mobile devices
OpenMP support is a huge benefit for every heavy computing task. We use it daily together with RenderScript for computer vision problems and really gives a boost in performances. The lack of openmp in clang is not a problem, but as there is the suggestion to switch to it instead of gcc, to have it support all gcc extensions should be a must :)
Also, as it is the 3.8 release, then it just needs to be compiled with openmp support and will work directly out of the box.
In any case, great work you're doing there ;)
It is actually clang 3.8, but not the official release version, since we track TOT LLVM, and not their release branches. Since I am not all that familiar with OpenMP, perhaps you can tell me how this is failing to compile/link. What are the exact error messages/symptoms you are seeing, since you seem to indicate that it should be included as part of Clang/LLVM. I would like to be able to verify that this works before shipping another version that fails.
@stephenhines , I'll give it a try and report about how to add it's support :)
Another vote for the openMP being a must for clang. Hope you will be able to add it to the r14 as planned.
See this link for a potential issue and a workaround related to a thread storage issue. http://www.softwarecoven.com/parallel-computing-with-openmp-in-android/
Quick update here:
@pirama-arumuga-nainar got this mostly up and running (thanks!), but there are actually some issues with the way the Clang driver tries to use openmp. Unlike most Clang runtime libraries, OpenMP actually can't be installed into a multilib toolchain (the libraries ought to be libclang_rt.openmp-$ARCH-android, but are just looking for libomp.
@pirama-arumuga-nainar is working on upstreaming a fix for this, but unfortunately it does mean this isn't likely to be fixed in r14.
Hate +1s and see you guys are working on this, but didn't see it in r14 so just wanted to say it's a blocker for me as well. Finally worked through the kinks in switching to clang for my app, but I'll be stuck on gcc until this is in place.
We're working with the openmp devs to get this working for cross compiling. Discussion here: http://lists.llvm.org/pipermail/openmp-dev/2016-December/001612.html
Lots of the industry slows down over the holidays, so I don't expect we'll see anything move forward until the new year. Assuming they agree to our plans, we should have a patch in with plenty of time for the r15 release.
@pirama-arumuga-nainar: has there been any progress on this upstream?
I didn't have a chance to do this yet. I'll try to get it time for the next Clang update.
Okay, thanks. For people watching this thread: the plan is for that next clang update to be the one used in r15.
Okay, I've tested @pirama-arumuga-nainar's changes locally and we at least have the Clang side of things mostly working now. We have a few changes in flight to fix the rest of the Clang side. Once those are done this should at least be working for standalone toolchains.
Getting this working for ndk-build and cmake (and so on) is going to be a bit trickier. Unlike GNU's, LLVM's openmp depends on a C++ STL, which means we need to guarantee that -lomp appears before -lc++_static (or shared) when linking. Unfortunately since we manually link libc++ but let the driver deal with openmp, this can't actually be done. I'm going to try to think of a way to get that to work short of manually injecting openmp into the command line as well, but that might be the only option.
It's also worth noting that this means we'll only support openmp with libc++ (openmp won't work on anything older than android-o without libandroid_support anyway). Since I still need to get that into better shape before we can really recommend it, that's shifting back to top priority. We'll still try to get this for r15, but it depends on how much more time libc++ takes.
Thanks for the detailed update. When you say Android-O, do you mean the successor to nougat? If so there'll be a gap between gcc end of life and clang support for openmp then? Could you go into a bit more detail (or link) why that gap will exist.
If so there'll be a gap between gcc end of life and clang support for openmp then?
GCC's removal from the NDK is in no way associated with an Android platform release. The platform dropped GCC ~two years ago.
Could you go into a bit more detail (or link) why that gap will exist.
openmp needs libandroid_support because openmp relies on some parts of libc that we've never had. We added them specifically for openmp, but we can't modify old releases, so they're only supported natively in O. libandroid_support is the thing we use to patch holes in libc, but it's only compatible with libc++.
Ok, so if this is a gap in android libc++ it should have applied to gcc openmp support as well then, right?