This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] [test] Fix target_thread_limit.cpp to not assume 4 or more cores
ClosedPublic

Authored by mstorsjo on Aug 31 2023, 2:39 PM.

Details

Summary

Previously, the test ran a section with

#pragma omp target thread_limit(4)

and expected it to execute exactly 4 times, even though it would
in practice execute min(cores, 4) times.

Increment a counter and check that it executed 1-4 times.

Diff Detail

Event Timeline

mstorsjo created this revision.Aug 31 2023, 2:39 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 31 2023, 2:39 PM
mstorsjo requested review of this revision.Aug 31 2023, 2:39 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 31 2023, 2:39 PM

This does not impact the test in the way you describe. set_num_threads, and thread_limit, are both upper bounds only. We can still pick 1 thread and it is conformant.
Adding the call is fine, but we should instead increment a number, not check for printed lines. The final result should be 1 <= result <= 4.

mstorsjo updated this revision to Diff 555298.Sep 1 2023, 1:33 AM

Check the number of runs with a counter and FileCheck pattern, instead of expecting a certain number of printout lines.

mstorsjo edited the summary of this revision. (Show Details)Sep 1 2023, 1:34 AM
protze.joachim added inline comments.
openmp/runtime/test/target/target_thread_limit.cpp
23–24

Fix the data race on count++

73–76

same here

mstorsjo added inline comments.Sep 1 2023, 8:57 AM
openmp/runtime/test/target/target_thread_limit.cpp
23–24

Thanks! I meant to ask about whether this needed some extra atomic accesses or similar, but forgot to ask when posting the patch.

mstorsjo updated this revision to Diff 555401.Sep 1 2023, 8:57 AM

Fixed the data races

jdoerfert accepted this revision.Sep 1 2023, 11:07 AM
This revision is now accepted and ready to land.Sep 1 2023, 11:07 AM