Wednesday, June 05, 2019

OpenMP for both clang and GCC, part II

TLDR: Multi-core is a thing. Let's do it the OpenMP way. My diffs to come.

I know some devs have thought about this before. I'm looking for comments
or advice on how I can help this along.

The clang in base (and flang in ports) currently support OpenMP directives
with the -fopenmp option. They are missing the runtime. The LLVM OpenMP
runtime could be supplied as a port.

The GNU C, C++ and Fortran in ports (gcc version 8.3) currently support
OpenMP directives and with a small patch can add OpenMP support to their
runtime libraries (gcc-libs). The two OpenMP runtimes (GCC and LLVM)
can coexist this way.

Example ports, compiler, build system, and status/issues:

devel/boost (base-clang gcc-ports, unique build, uncertain support)
devel/cmake (base-clang gcc-ports, simple, fails to correctly find OpenMP)
graphics/lensfun (base-clang gcc-ports, cmake, unswitchable OpenMP)
graphics/GraphicsMagick (base-clang gcc-ports, gnu configure, OpenMP disabled)

Proposed changes:
- identify ports with embedded (hidden) OpenMP support and patch to disable it
(I guess from 10 to 40 such ports aside from the 7 that turn it off now)
- fix cmake (and other build systems) to detect both OpenMP implementations
- add a new port devel/libomp containing the LLVM OpenMP runtime for clang/flang
- patch gcc-libs package to deliver OpenMP runtime support for GNU c/c++/fortran
- help port maintainers build with OpenMP flavors if they want it

(I have patches for cmake, gcc-libs, and a proposed new devel/libomp package).

Eventually ports maintaners will migrate to OpenMP as they can or want to.
Users will adopt flavors such as -withopenmp, or -noopenmp, as they become
available.

Some issues and questions:

- this will work for amd64, but will it work for arm64, sparc? Others?
- should the flavors be -withopenmp or -noopenmp?
- how to successfully detect 90% or more of ports with hidden OpenMP support?
I will do this and am looking for advice on how best to approach it.
Any pre-existing info would be very welcome.

Does anyone have comments? I'll be submitting diffs as I can.



--John

No comments:

Post a Comment