Skip to content

Commit

Permalink
[OpenMP][NFC] lit: Allow setting default environment variables for test
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jprotze committed Jul 11, 2023
1 parent b53e16c commit 81bc7cf
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 0 deletions.
32 changes: 32 additions & 0 deletions openmp/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,35 @@ Advanced Builds with Various Options
**Footnotes**

.. [*] Other names and brands may be claimed as the property of others.
How to Run Tests
================

There are following check-* make targets for tests.

- ``check-ompt`` (ompt tests under runtime/test/ompt)
- ``check-ompt-multiplex`` (ompt multiplex tests under tools/multiplex/tests)
- ``check-libarcher`` (libarcher tests under tools/archer/tests)
- ``check-libomp`` (libomp tests under runtime/test. This includes check-ompt tests too)
- ``check-libomptarget-*`` (libomptarget tests for specific target under libomptarget/test)
- ``check-libomptarget`` (all check-libomptarget-* tests)
- ``check-openmp`` (combination of all above tests excluding duplicates)

For example, to run all available tests, use ``make check-openmp``.

Options for Tests
------------------
Tests use lit framework.
See `lit documentation <https://llvm.org/docs/CommandGuide/lit.html>`_ for lit options.

**CHECK_OPENMP_ENV** = ``""``
Default environment variables which test process uses for ``check-openmp``
separated by space. This can be used for individual targets (``check-ompt``,
``check-ompt-multiplex``, ``check-libarcher``, ``check-libomp`` and
``check-libomptarget-*``) too. Note that each test still overrides
environment variables if needed. For example, to change barrier pattern to be
used from default hyper barrier to hierarchical barrier, run:

.. code-block:: console
$ CHECK_OPENMP_ENV="KMP_PLAIN_BARRIER_PATTERN=hier,hier KMP_FORKJOIN_BARRIER_PATTERN=hier,hier KMP_REDUCTION_BARRIER_PATTERN=hier,hier" make check-openmp
8 changes: 8 additions & 0 deletions openmp/libomptarget/test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ if 'LIBOMPTARGET_LOCK_MAPPED_HOST_BUFFERS' in os.environ:
if 'OMP_TARGET_OFFLOAD' in os.environ:
config.environment['OMP_TARGET_OFFLOAD'] = os.environ['OMP_TARGET_OFFLOAD']

# set default environment variables for test
if 'CHECK_OPENMP_ENV' in os.environ:
test_env = os.environ['CHECK_OPENMP_ENV'].split()
for env in test_env:
name = env.split('=')[0]
value = env.split('=')[1]
config.environment[name] = value

def append_dynamic_library_path(name, value, sep):
if name in config.environment:
config.environment[name] = value + sep + config.environment[name]
Expand Down
8 changes: 8 additions & 0 deletions openmp/runtime/test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ except NotImplementedError:
if 'INTEL_LICENSE_FILE' in os.environ:
config.environment['INTEL_LICENSE_FILE'] = os.environ['INTEL_LICENSE_FILE']

# set default environment variables for test
if 'CHECK_OPENMP_ENV' in os.environ:
test_env = os.environ['CHECK_OPENMP_ENV'].split()
for env in test_env:
name = env.split('=')[0]
value = env.split('=')[1]
config.environment[name] = value

# substitutions
config.substitutions.append(("%libomp-compile-and-run", \
"%libomp-compile && %libomp-run"))
Expand Down
8 changes: 8 additions & 0 deletions openmp/tools/archer/tests/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ if config.has_tsan == True:
if 'INTEL_LICENSE_FILE' in os.environ:
config.environment['INTEL_LICENSE_FILE'] = os.environ['INTEL_LICENSE_FILE']

# set default environment variables for test
if 'CHECK_OPENMP_ENV' in os.environ:
test_env = os.environ['CHECK_OPENMP_ENV'].split()
for env in test_env:
name = env.split('=')[0]
value = env.split('=')[1]
config.environment[name] = value

config.environment['ARCHER_OPTIONS'] = "report_data_leak=1"

# Race Tests
Expand Down
8 changes: 8 additions & 0 deletions openmp/tools/multiplex/tests/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ config.test_flags = " -I " + config.test_source_root + "/.."\
if 'INTEL_LICENSE_FILE' in os.environ:
config.environment['INTEL_LICENSE_FILE'] = os.environ['INTEL_LICENSE_FILE']

# set default environment variables for test
if 'CHECK_OPENMP_ENV' in os.environ:
test_env = os.environ['CHECK_OPENMP_ENV'].split()
for env in test_env:
name = env.split('=')[0]
value = env.split('=')[1]
config.environment[name] = value

# Allow XFAIL to work
config.target_triple = [ ]
for feature in config.test_compiler_features:
Expand Down

0 comments on commit 81bc7cf

Please sign in to comment.