This is an archive of the discontinued LLVM Phabricator instance.

[flang][examples] Add missing CMake dependencies
ClosedPublic

Authored by awarzynski on Jan 11 2022, 5:49 AM.

Details

Summary

Currently everything that includes "flang/Parser/parse-tree.h" in Flang
depends on the gen_acc CMake target (it generates one of the include
files that are used in "parse-tree.h"). The examples in Flang do use
this header file and hence also depend on gen_acc. This patch updates
relevant CMake scripts accordingly.

I've also taken the liberty to rename some of the example files so that
their names follow LLVM's coding guidelines.

Diff Detail

Event Timeline

awarzynski created this revision.Jan 11 2022, 5:49 AM
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: mgorny. · View Herald Transcript
awarzynski requested review of this revision.Jan 11 2022, 5:49 AM

@awarzynski What about omp_gen? Do you know why it is not explicitly required?

@awarzynski What about omp_gen? Do you know why it is not explicitly required?

The dependency on acc_gen comes from this include: https://github.com/llvm/llvm-project/blob/main/flang/include/flang/Parser/parse-tree.h#L28

#include "llvm/Frontend/OpenACC/ACC.h.inc"

There are no TableGen-generated OpenMP headers here. Are there any in other places? I might have missed something!

@awarzynski What about omp_gen? Do you know why it is not explicitly required?

The dependency on acc_gen comes from this include: https://github.com/llvm/llvm-project/blob/main/flang/include/flang/Parser/parse-tree.h#L28

#include "llvm/Frontend/OpenACC/ACC.h.inc"

There are no TableGen-generated OpenMP headers here. Are there any in other places? I might have missed something!

I don't remember the difference. Usually, OpenMP and OpenACC have similar handling. Anyway, further below there are includes for ACC.inc and OMP.inc. Are these includes not affected?

There are no TableGen-generated OpenMP headers here. Are there any in other places? I might have missed something!

I don't remember the difference. Usually, OpenMP and OpenACC have similar handling. Anyway, further below there are includes for ACC.inc and OMP.inc. Are these includes not affected?

Ah, I was looking for "OpenMP.h.inc" rather than "OMP.inc", so didn't find that. Both files are generated by the omp_gen target. It does look identical to acc_gen, so I should probably add it as a dependency too. Any thoughts?

Add omp_gen to the list of dependencies

Ideally, we should avoid depending on these targets directly. For now, this LGTM.

This revision is now accepted and ready to land.Jan 14 2022, 4:48 AM

Ideally, we should avoid depending on these targets directly.

I agree. We'd probably have to remove these *.inc files from all header files. I can't think of any other way.

Ideally, we should avoid depending on these targets directly.

I agree. We'd probably have to remove these *.inc files from all header files. I can't think of any other way.

Why would you remove them? They are necessary. MLIR works on the same principle without any issue.

I agree. We'd probably have to remove these *.inc files from all header files. I can't think of any other way.

Why would you remove them?

So that various CMake targets don't depend on acc_gen or omp_gen. To me it's rather counter-intuitive that everything that includes parse-tree.h depends on acc_gen and omp_gen. But perhaps that's by design?

Anyway, @clementval , are you OK with this change?

I agree. We'd probably have to remove these *.inc files from all header files. I can't think of any other way.

Why would you remove them?

So that various CMake targets don't depend on acc_gen or omp_gen. To me it's rather counter-intuitive that everything that includes parse-tree.h depends on acc_gen and omp_gen. But perhaps that's by design?

Anyway, @clementval , are you OK with this change?

I'm ok with the change. The only solution would be to extract OpenMP and OpenACC specific parts to their own include files but in your example you would need the omp_gen dependency.

Thanks for the comments, @clementval !

I'm ok with the change.

Ta!

The only solution would be to extract OpenMP and OpenACC specific parts to their own include files (...)

Sounds like a good idea.

(...) but in your example you would need the omp_gen dependency.

Only in one of them - FlangOmpReport. But that makes sense - it's for finding OpenMP construct/clauses anyway. The other one, PrintFlangFunctionNames, doesn't need it. And neither of the examples requires OpenACC.

This revision was automatically updated to reflect the committed changes.
flang/examples/FlangOmpReport/requirements.txt