This is an archive of the discontinued LLVM Phabricator instance.

[OPENMP50]Initial codegen for 'affinity' clauses.
ClosedPublic

Authored by ABataev on May 19 2020, 1:48 PM.

Details

Summary

Added initial codegen for 'affinity' clauses on task directives.
Emits next code:

kmp_task_affinity_info_t affs[<num_elems>];

void *td = __kmpc_task_alloc(..);

affs[<i>].base = &data_i;
affs[<i>].size = sizeof(data_i);
__kmpc_omp_reg_task_with_affinity(&loc, <gtid>, td, <num_elems>, affs);

The result returned by the call of __kmpc_omp_reg_task_with_affinity
function is ignored currently sincethe runtime currently ignores args
and returns 0 uncoditionally.

Diff Detail

Event Timeline

ABataev created this revision.May 19 2020, 1:48 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMay 19 2020, 1:48 PM

Few comments, the alloca question is my only real concern. Parts of this are trivial NFC and can go in to make the patch smaller. Parts won't be needed after D80222 landed :)

clang/lib/CodeGen/CGOpenMPRuntime.cpp
2444

This will clash with D80222. I guess once that one is in you can just remove these parts and it will still work fine :)

5397

Feel free to commit the code movement parts separately as an NFC commit to make the diff cleaner.

clang/lib/CodeGen/CGOpenMPRuntime.h
470

We really need to move these into OMPKinds.def as well. Not in this patch but soon.

clang/test/OpenMP/task_affinity_codegen.cpp
55

I'm not so sure about dynamic allocas (without stack save/restore). If this happens in a loop we can run into problems fast, right?

133

Does it make sense to use the script to auto-generate the check lines? Makes updates way easier and cleaner. We could have the "C-code" explanation as comment above the pragma still.

ABataev marked an inline comment as done.May 29 2020, 1:22 PM
ABataev added inline comments.
clang/test/OpenMP/task_affinity_codegen.cpp
55

There are stack saves and restores for this alloca, see the calls of @llvm.stacksave() and @llvm.stackrestore()

jdoerfert accepted this revision.May 29 2020, 1:48 PM

LGTM. Let's wait until D80222 landed :)

clang/lib/CodeGen/CGOpenMPRuntime.h
470

Just a comment, not necessarily related to this review:
@clementval @DavidTruby @fghanim @jhuber6
We want to have all "internal" struct definitions in OMPKinds.def (as we have now), but also build boilerplate code for each of them once we use TableGen. We want to build a class STRUCT_TY which offers to create a local/global struct value, inspect the members, modify the members, create the IR type for it, etc.

clang/test/OpenMP/task_affinity_codegen.cpp
55

Right, missed them. Thx.

This revision is now accepted and ready to land.May 29 2020, 1:48 PM
This revision was automatically updated to reflect the committed changes.