This is an archive of the discontinued LLVM Phabricator instance.

[OPENMP] Added option -fopenmp=libiomp5|libgomp
ClosedPublic

Authored by ABataev on Feb 20 2014, 1:15 AM.

Diff Detail

Event Timeline

We just used to link in libgomp for compatibility with gcc, is this correct? (For example, some object files could be compiled with GCC with OpenMP, while the rest of the program could be compiled with clang and linked with 'clang -fopenmp'.)

If it is so, I think the change is good, the users can get the previous behavior by specifying the required libraries manually.

Yes. But currently llvm accepted libiomp5, not libgomp, so I think it is a good time to switch gomp to iomp5. Besides, iomp5 is binary compatible with gomp.

gribozavr accepted this revision.Feb 20 2014, 2:35 AM

LGTM. If you feel like it, maybe add a note in release notes that 'clang -fopenmp' now links a different library.

I don't think it is necessary right now. Besides, -fopenmp option exists only as a frontend option. It is disabled in driver and can be passed to frontend only "-Xclang -fopenmp".

ABataev updated this revision to Unknown Object (????).Feb 27 2014, 3:24 AM

Full patch rework.

gribozavr added inline comments.Feb 27 2014, 3:35 AM
lib/Driver/Tools.cpp
5242–5265

What happens if the user passes -fopenmp -fopenmp=libiomp5?

test/OpenMP/parallel_ast_print.cpp
1–3

If this flag only changes the linker option, then there is no need to update AST tests with it.

gribozavr requested changes to this revision.Feb 27 2014, 3:35 AM
ABataev added inline comments.Feb 27 2014, 3:58 AM
lib/Driver/Tools.cpp
5242–5265

Then only -fopenmp will work and the warning for -fopenmp=libiomp5 will be emitted. I thought that we have to be conservative with -fopenmp option.

test/OpenMP/parallel_ast_print.cpp
1–3

No, it also turns on OpenMP support in front end. You can consider -fopenmp=libiomp5 option as an extension for -fopenmp option. My idea was not only link libiomp5, but also generate the IR for libiomp5 runtime only if -fopenmp=libiomp5 is specified. If -fopenmp is specified, the IR won't be generated (for compatibility).

gribozavr added inline comments.Feb 27 2014, 4:30 AM
lib/Driver/Tools.cpp
5242–5265

OK, please add a test.

ABataev updated this revision to Unknown Object (????).Feb 27 2014, 9:48 PM

Added test which expects warning when both -fopenmp and -fopenmp=libiomp5 are specified

ABataev updated this revision to Unknown Object (????).Mar 3 2014, 8:38 PM

Updated processing of -fopenmp and -fopenmp= options. -fopenmp is used only to link libgomp library, -fopenmp= is used to activate processing of OpenMP constructs and future codegen.

LGTM.

I think it makes sense to have -fopenmp=libgomp work as well. First, for consistency. But also, for users who are depending on the current -fopenmp behavior, this will give them some time to migrate to a stable flag before we switch the default.

lib/Driver/Tools.cpp
5261

This seems somewhat asymmetric: we now have -fopenmp, which links libgomp, and -fopenmp=libiomp5 which links libiomp5. How about having -fopenmp=libgomp link libgomp too?

6874

Same here.

ABataev updated this revision to Unknown Object (????).Mar 5 2014, 1:40 AM

Update after Hal's review

-fopenmp is used only to link libgomp library, -fopenmp= is used to activate processing of OpenMP constructs and future codegen.

This feels surprising, but I see where you are coming from -- codegen will only support libiomp5 interface. Please document this behavior in the user manual.

gribozavr accepted this revision.Mar 5 2014, 4:12 AM

On IRC @ABataev said that we should start advertising OpenMP support in the manual only after we have something actually useful for end users.

This patch does not introduce a backwards compatibility issue, so LGTM.

ABataev closed this revision.Mar 5 2014, 9:51 PM

Committed revision 203081.