Skip to content

Commit 81bc7cf

Browse files
committed
[OpenMP][NFC] lit: Allow setting default environment variables for test
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 environment variables if needed as before. Also, this commit adds missing documention about how to run tests in README. Patch provided by t-msn Differential Revision: https://reviews.llvm.org/D122645
1 parent b53e16c commit 81bc7cf

File tree

5 files changed

+64
-0
lines changed

5 files changed

+64
-0
lines changed

openmp/README.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,3 +363,35 @@ Advanced Builds with Various Options
363363
**Footnotes**
364364

365365
.. [*] Other names and brands may be claimed as the property of others.
366+
367+
How to Run Tests
368+
================
369+
370+
There are following check-* make targets for tests.
371+
372+
- ``check-ompt`` (ompt tests under runtime/test/ompt)
373+
- ``check-ompt-multiplex`` (ompt multiplex tests under tools/multiplex/tests)
374+
- ``check-libarcher`` (libarcher tests under tools/archer/tests)
375+
- ``check-libomp`` (libomp tests under runtime/test. This includes check-ompt tests too)
376+
- ``check-libomptarget-*`` (libomptarget tests for specific target under libomptarget/test)
377+
- ``check-libomptarget`` (all check-libomptarget-* tests)
378+
- ``check-openmp`` (combination of all above tests excluding duplicates)
379+
380+
For example, to run all available tests, use ``make check-openmp``.
381+
382+
Options for Tests
383+
------------------
384+
Tests use lit framework.
385+
See `lit documentation <https://llvm.org/docs/CommandGuide/lit.html>`_ for lit options.
386+
387+
**CHECK_OPENMP_ENV** = ``""``
388+
Default environment variables which test process uses for ``check-openmp``
389+
separated by space. This can be used for individual targets (``check-ompt``,
390+
``check-ompt-multiplex``, ``check-libarcher``, ``check-libomp`` and
391+
``check-libomptarget-*``) too. Note that each test still overrides
392+
environment variables if needed. For example, to change barrier pattern to be
393+
used from default hyper barrier to hierarchical barrier, run:
394+
395+
.. code-block:: console
396+
397+
$ CHECK_OPENMP_ENV="KMP_PLAIN_BARRIER_PATTERN=hier,hier KMP_FORKJOIN_BARRIER_PATTERN=hier,hier KMP_REDUCTION_BARRIER_PATTERN=hier,hier" make check-openmp

openmp/libomptarget/test/lit.cfg

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ if 'LIBOMPTARGET_LOCK_MAPPED_HOST_BUFFERS' in os.environ:
3535
if 'OMP_TARGET_OFFLOAD' in os.environ:
3636
config.environment['OMP_TARGET_OFFLOAD'] = os.environ['OMP_TARGET_OFFLOAD']
3737

38+
# set default environment variables for test
39+
if 'CHECK_OPENMP_ENV' in os.environ:
40+
test_env = os.environ['CHECK_OPENMP_ENV'].split()
41+
for env in test_env:
42+
name = env.split('=')[0]
43+
value = env.split('=')[1]
44+
config.environment[name] = value
45+
3846
def append_dynamic_library_path(name, value, sep):
3947
if name in config.environment:
4048
config.environment[name] = value + sep + config.environment[name]

openmp/runtime/test/lit.cfg

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ except NotImplementedError:
134134
if 'INTEL_LICENSE_FILE' in os.environ:
135135
config.environment['INTEL_LICENSE_FILE'] = os.environ['INTEL_LICENSE_FILE']
136136

137+
# set default environment variables for test
138+
if 'CHECK_OPENMP_ENV' in os.environ:
139+
test_env = os.environ['CHECK_OPENMP_ENV'].split()
140+
for env in test_env:
141+
name = env.split('=')[0]
142+
value = env.split('=')[1]
143+
config.environment[name] = value
144+
137145
# substitutions
138146
config.substitutions.append(("%libomp-compile-and-run", \
139147
"%libomp-compile && %libomp-run"))

openmp/tools/archer/tests/lit.cfg

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,14 @@ if config.has_tsan == True:
9090
if 'INTEL_LICENSE_FILE' in os.environ:
9191
config.environment['INTEL_LICENSE_FILE'] = os.environ['INTEL_LICENSE_FILE']
9292

93+
# set default environment variables for test
94+
if 'CHECK_OPENMP_ENV' in os.environ:
95+
test_env = os.environ['CHECK_OPENMP_ENV'].split()
96+
for env in test_env:
97+
name = env.split('=')[0]
98+
value = env.split('=')[1]
99+
config.environment[name] = value
100+
93101
config.environment['ARCHER_OPTIONS'] = "report_data_leak=1"
94102

95103
# Race Tests

openmp/tools/multiplex/tests/lit.cfg

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ config.test_flags = " -I " + config.test_source_root + "/.."\
5454
if 'INTEL_LICENSE_FILE' in os.environ:
5555
config.environment['INTEL_LICENSE_FILE'] = os.environ['INTEL_LICENSE_FILE']
5656

57+
# set default environment variables for test
58+
if 'CHECK_OPENMP_ENV' in os.environ:
59+
test_env = os.environ['CHECK_OPENMP_ENV'].split()
60+
for env in test_env:
61+
name = env.split('=')[0]
62+
value = env.split('=')[1]
63+
config.environment[name] = value
64+
5765
# Allow XFAIL to work
5866
config.target_triple = [ ]
5967
for feature in config.test_compiler_features:

0 commit comments

Comments
 (0)