This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Honor `thread_limit` value when choosing grid size
ClosedPublic

Authored by tianshilei1992 on Aug 24 2023, 6:14 PM.

Details

Summary

D152014 introduced an optimization that favors more smaller blocks over
fewer larger blocks, even if user sets thread_limit explicitly. This patch changes
the behavior to honor user value.

Diff Detail

Event Timeline

tianshilei1992 created this revision.Aug 24 2023, 6:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 24 2023, 6:14 PM
tianshilei1992 requested review of this revision.Aug 24 2023, 6:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 24 2023, 6:14 PM
jdoerfert added inline comments.Aug 24 2023, 7:07 PM
openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
379

Just check if the user set anything (ThreadLimit[0] > 0), we might still reduce it before but we should not reduce it further here.

448–449

You don't need the changes above if you add || IsNumThreadsFromUser above. That makes it clear we keep the value and just compute num teams based on it. Rather than having all these intermediate computations we do not use.

471
tianshilei1992 marked 3 inline comments as done.

rebase and fix comments

jdoerfert accepted this revision.Aug 24 2023, 9:53 PM

See comment. LG

openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
471

With the change in the condition above, the old comment was good.

This revision is now accepted and ready to land.Aug 24 2023, 9:53 PM

rebase and fix comment

Thanks. I’ll fix it today. Just need one line of change.