This is an archive of the discontinued LLVM Phabricator instance.

[OPENMP50]Add device/isa context selector support.
AbandonedPublic

Authored by ABataev on Nov 26 2019, 11:54 AM.

Details

Summary

Added basic support for device/isa context selector.

Diff Detail

Event Timeline

ABataev created this revision.Nov 26 2019, 11:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 26 2019, 11:54 AM
Herald added a subscriber: guansong. · View Herald Transcript

Thanks for working on this! One nit and one concern below.

clang/include/clang/Sema/Sema.h
9320

I would like to avoid the Any type here and I hope we can if we don't allow "strings". See also my last comment.

clang/lib/CodeGen/CGOpenMPRuntime.cpp
11147

should we normalize the names here? at least .lower might be useful.

clang/test/OpenMP/nvptx_declare_variant_device_isa_codegen.cpp
48

I'm not sure we want these to be strings. I would have assumed isa(nvptx64), similar to vendor(arm), or kind(host) and kind(gpu)

ABataev marked an inline comment as done.Nov 27 2019, 6:28 AM
ABataev added inline comments.
clang/test/OpenMP/nvptx_declare_variant_device_isa_codegen.cpp
48

Here is the message from Joachim Protze:

vendor and kind are special, because we define the kind-name and 
vendor-name in the context definition side document. (We could change 
that to "kind-name" or define kind-name as any of "cpu", "gpu", "fpga" ???)

For the others, according to the syntax diagram in the OpenMP Context 
section, the content of the () can only be string or const-int-exp.

- Joachim

That's why we need to represent them as strings, this is per OpenMP standard.

ABataev updated this revision to Diff 231265.Nov 27 2019, 8:12 AM

Address comments.

ABataev marked 2 inline comments as done.Nov 27 2019, 8:14 AM
ABataev added inline comments.
clang/include/clang/Sema/Sema.h
9320

The only possible solution I see here is to convert kind/vendor strings into exprs and store all data as Expr *

clang/lib/CodeGen/CGOpenMPRuntime.cpp
11147

Done + added check for possibly used vendor/os/env

Build result: pass - 60340 tests passed, 0 failed and 732 were skipped.

Log files: console-log.txt, CMakeCache.txt

jdoerfert added inline comments.Nov 27 2019, 12:37 PM
clang/include/clang/Sema/Sema.h
9320

Should we define a struct to be used as variant here maybe? If we only have <5 different types we might not want to go to Any or Expr directly.

clang/test/OpenMP/nvptx_declare_variant_device_isa_codegen.cpp
48

While you say it, I wanted to mention that we moved the discussion on the openmp-lang list.

ABataev marked an inline comment as done.Nov 27 2019, 12:39 PM
ABataev added inline comments.
clang/include/clang/Sema/Sema.h
9320

What is the difference between using Any and a struct?

jdoerfert added inline comments.Nov 27 2019, 3:12 PM
clang/include/clang/Sema/Sema.h
9320

Any is generic (anything).
Having a variant (std::variant or self build struct with 2 constructors) specifies what the components can be.

ABataev marked an inline comment as done.Nov 27 2019, 3:16 PM
ABataev added inline comments.
clang/include/clang/Sema/Sema.h
9320

It is not quite so. Anyway, I'm going to switch to Expr* since it is the only possible way to represent traits as identifiers/string literals.

ABataev abandoned this revision.Feb 11 2021, 5:11 AM