This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP][NFC] lit: Allow setting default environment variables for test
ClosedPublic

Authored by t-msn on Mar 29 2022, 4:55 AM.

Details

Summary

Add CHECK_OPENMP_ENV environment variable which will be passed to environment
variables for test (make check-* target). This provides a handy way to
exercise various openmp code with different settings during development.

For example, to change default barrier pattern:
$ env CHECK_OPENMP_ENV="KMP_FORKJOIN_BARRIER_PATTERN=hier,hier \

KMP_PLAIN_BARRIER_PATTERN=hier,hier \
KMP_REDUCTION_BARRIER_PATTERN=hier,hier" \
ninja check-openmp

Even with this, each test can set appropriate envionment variables if needed
as before.

Also, this commit adds missing documention about how to run tests in README.

Diff Detail

Event Timeline

t-msn created this revision.Mar 29 2022, 4:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 29 2022, 4:55 AM
t-msn edited the summary of this revision. (Show Details)Mar 29 2022, 4:58 AM
t-msn added a project: Restricted Project.
t-msn removed a project: Restricted Project.
Herald added a project: Restricted Project. · View Herald TranscriptMar 29 2022, 5:46 AM
t-msn published this revision for review.Mar 29 2022, 5:47 AM

I think, the name of the variable is confusing. The tests triggered and influenced by your example command are not limited to libomp. Currently the LIBOMP_ prefix is mainly used for cmake variables. The make target to run the tests is called check-* rather than test-*.

My suggestion for the variable name would be CHECK_OPENMP_ENV.

t-msn added a comment.Apr 3 2022, 6:50 PM

Thanks for clarifications, I'm ok with CHECK_OPENMP_ENV.
If anyone has a different suggestion, please let me know.

t-msn updated this revision to Diff 420744.Apr 6 2022, 2:11 AM
t-msn edited the summary of this revision. (Show Details)

Update name to use CHECK_OPENMP_ENV and also update README

I realized that check-openmp runs tools tests too, so update
tool's lit.cfg as well

While testing this, I found some minor problems in hier and dist barrier. Here are the patches: D123193, D123194, D123195

I think, in addition to manually selecting the barrier implementation, we should add additional run lines to specific tests that trigger the different barrier implementations. I added a related, OMPT-specific comment to D123193.

t-msn added a comment.Apr 6 2022, 3:07 AM

I think, in addition to manually selecting the barrier implementation, we should add additional run lines to specific tests that trigger the different barrier implementations. I added a related, OMPT-specific comment to D123193.

I agree. The problem is I'm not so sure which tests are needed to run when changing barrier especially for dist which affects thread handling code in kmp_runtime.cpp.
At least, for OMPT part, I believe reduction is only affected tests for different barrier implementation. So, I will update or add patch as suggested.

I checked the runtime tests and found that openmp/runtime/test/barrier/omp_barrier.c already triggers different combinations of barriers. Do the combinations cover all configurations you tried manually?
Regarding reductions, I think it would make sense to add similar run lines to openmp/runtime/test/worksharing/for/omp_for_reduction.c in order to cover different code paths in the runtime.

Probably @AndreyChurbanov has suggestions regarding tests that could be augmented to improve test coverage of the different barrier implementations.

protze.joachim accepted this revision.Apr 6 2022, 5:25 AM

This patch LGTM.

This revision is now accepted and ready to land.Apr 6 2022, 5:25 AM
t-msn added a comment.EditedApr 6 2022, 7:44 PM

I checked the runtime tests and found that openmp/runtime/test/barrier/omp_barrier.c already triggers different combinations of barriers. Do the combinations cover all configurations you tried manually?

Not really.
There are currently 5 barriers in libomp: linear, tree, hyper(default), hier, dist.
With manually changing barriers with this patch, I don't see any problems with linear, tree and hyper while found some in hier and dist (incl. the problems addressed by other patches I submitted).

openmp/runtime/test/barrier/omp_barrier.c does not test linear and tree, so it may better to be added for completeness.
(Also, omp_barrier.c checks barrier with KMP_BLOCKTIME=infinit. I tried changing barrier with this option and It seems KMP_BLOCKTIME=infinit makes problem in env/omp_wait_policy.c test regardless of barrier. I will try to see the reason
EDIT: OMP_WAIT_POLICY=passive simply does not work with KMP_BLOCKTIME=infinit. there is no worry for that)

Regarding reductions, I think it would make sense to add similar run lines to openmp/runtime/test/worksharing/for/omp_for_reduction.c in order to cover different code paths in the runtime.

Ok, I will look that too.

Thanks for the review and comments.