This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Add the `ompx_attribute` clause for target directives
ClosedPublic

Authored by jdoerfert on Jul 24 2023, 4:03 PM.

Details

Summary

CUDA and HIP have kernel attributes to tune the code generation (in the
backend). To reuse this functionality for OpenMP target regions we
introduce the ompx_attribute clause that takes these kernel
attributes and emits code as if they had been attached to the kernel
fuction (which is implicitly generated).

To limit the impact, we only support three kernel attributes:
amdgpu_waves_per_eu, for AMDGPU
amdgpu_flat_work_group_size, for AMDGPU
launch_bounds, for NVPTX

The existing implementations of those attributes are used for error
checking and code generation. ompx_attribute can be attached to any
executable target region and it can hold more than one kernel attribute.

Diff Detail

Event Timeline

jdoerfert created this revision.Jul 24 2023, 4:03 PM
jdoerfert requested review of this revision.Jul 24 2023, 4:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 24 2023, 4:03 PM
jhuber6 accepted this revision.Jul 24 2023, 4:16 PM

Lots of boilerplate, but it's pretty straightforward. LG.

This revision is now accepted and ready to land.Jul 24 2023, 4:16 PM
arsenm added inline comments.Jul 24 2023, 4:34 PM
clang/test/OpenMP/ompx_attributes_messages.cpp
43

Test some cases with nonsense values, like strings and negatives?

ABataev added inline comments.
clang/include/clang/AST/OpenMPClause.h
29

Bad to have Sema dependancy in AST.

9190

Use tail allocation

9214

Drop const modifier

9217

Make this private member function

clang/include/clang/Sema/Sema.h
12355

Drop const

clang/lib/AST/ExprConstant.cpp
4942

Not related change

clang/lib/CodeGen/CodeGenModule.h
1561

handleCUDA....

1567

handle...

1572

handle...

clang/lib/CodeGen/Targets/AMDGPU.cpp
564

Pass by reference what's possible?

clang/lib/Sema/SemaDeclAttr.cpp
49

Sort includes

7941

Use Create member function?

clang/lib/Sema/TreeTransform.h
2384

Drop const

This revision was landed with ongoing or failed builds.Jul 24 2023, 10:06 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 24 2023, 10:06 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript