Files
clang-p2996/openmp/tools/archer/tests/lit.cfg
Joachim Protze fdc9dfc8e4 [OpenMP][Tool] Add Archer option to disable data race analysis for sequential part
This introduces the new `ARCHER_OPTIONS` flag `ignore_serial=0|1` to disable
analysis and logging of memory accesses in the sequential part of the OpenMP
application.

In the sequential part of an OpenMP program no data race is possible, unless
there is non-OpenMP concurrency (such as pthreads, MPI, ...). For the latter
reason, this is not active by default.

Besides reducing the runtime overhead for the sequential part of the program,
this reduces the memory overhead for sequential initialization. In combination
with `flush_shadow=1` this can allow analysis of applications, which run close
to the limit of available memory, but only access smaller parts of shared
memory during each OpenMP parallel region.

A problem for this approach is that Archer only gets active, when the OpenMP
runtime gets initialized, which might be after serial initialization of the
application. In such case, it helps to call for example `omp_get_max_threads()`
at the beginning of main.

Differential Revision: https://reviews.llvm.org/D90473
2020-11-16 10:45:21 +01:00

130 lines
5.1 KiB
Python

# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
# Configuration file for the 'lit' test runner.
import os
import re
import subprocess
import lit.formats
# Tell pylint that we know config and lit_config exist somewhere.
if 'PYLINT_IMPORT' in os.environ:
config = object()
lit_config = object()
def append_dynamic_library_path(path):
if config.operating_system == 'Windows':
name = 'PATH'
sep = ';'
elif config.operating_system == 'Darwin':
name = 'DYLD_LIBRARY_PATH'
sep = ':'
else:
name = 'LD_LIBRARY_PATH'
sep = ':'
if name in config.environment:
config.environment[name] = path + sep + config.environment[name]
else:
config.environment[name] = path
# name: The name of this test suite.
config.name = 'libarcher'
# suffixes: A list of file extensions to treat as test files.
config.suffixes = ['.c', '.cpp']
# test_source_root: The root path where tests are located.
config.test_source_root = os.path.dirname(__file__)
# test_exec_root: The root object directory where output is placed
config.test_exec_root = config.libarcher_obj_root
# test format
config.test_format = lit.formats.ShTest()
# compiler flags
config.test_flags = " -I " + config.test_source_root + \
" -I " + config.omp_header_dir + \
" -L " + config.omp_library_dir + \
" -Wl,-rpath," + config.omp_library_dir + \
" " + config.test_archer_flags + \
" " + config.test_extra_flags
config.archer_flags = "-g -O1 -fsanitize=thread"
# extra libraries
libs = ""
if config.has_libatomic:
libs += " -latomic"
# Allow XFAIL to work
config.target_triple = [ ]
for feature in config.test_compiler_features:
config.available_features.add(feature)
# Setup environment to find dynamic library at runtime
append_dynamic_library_path(config.omp_library_dir)
append_dynamic_library_path(config.libarcher_obj_root+"/..")
# Rpath modifications for Darwin
if config.operating_system == 'Darwin':
config.test_flags += " -Wl,-rpath," + config.omp_library_dir
# Find the SDK on Darwin
if config.operating_system == 'Darwin':
cmd = subprocess.Popen(['xcrun', '--show-sdk-path'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = cmd.communicate()
out = out.strip()
res = cmd.wait()
if res == 0 and out:
config.test_flags += " -isysroot " + out
if 'Linux' in config.operating_system:
config.available_features.add("linux")
if config.has_tsan == True:
config.available_features.add("tsan")
# to run with icc INTEL_LICENSE_FILE must be set
if 'INTEL_LICENSE_FILE' in os.environ:
config.environment['INTEL_LICENSE_FILE'] = os.environ['INTEL_LICENSE_FILE']
# Race Tests
config.substitutions.append(("%libarcher-compile-and-run-race-noserial", \
"%libarcher-compile && env ARCHER_OPTIONS=ignore_serial=1 %libarcher-run-race"))
config.substitutions.append(("%libarcher-compile-and-run-race", \
"%libarcher-compile && %libarcher-run-race"))
config.substitutions.append(("%libarcher-compile-and-run-nosuppression", \
"%libarcher-compile && %libarcher-run-nosuppression"))
config.substitutions.append(("%libarcher-compile-and-run", \
"%libarcher-compile && %libarcher-run"))
config.substitutions.append(("%libarcher-cxx-compile-and-run", \
"%libarcher-cxx-compile && %libarcher-run"))
config.substitutions.append(("%libarcher-cxx-compile", \
"%clang-archerXX %openmp_flags %archer_flags %flags -std=c++14 %s -o %t" + libs))
config.substitutions.append(("%libarcher-compile", \
"%clang-archer %openmp_flags %archer_flags %flags %s -o %t" + libs))
config.substitutions.append(("%libarcher-run-race", "%suppression %deflake %t 2>&1 | tee %t.log"))
config.substitutions.append(("%libarcher-run-nosuppression", "%nosuppression %t 2>&1 | tee %t.log"))
config.substitutions.append(("%libarcher-run", "%suppression %t 2>&1 | tee %t.log"))
config.substitutions.append(("%clang-archerXX", config.test_cxx_compiler))
config.substitutions.append(("%clang-archer", config.test_c_compiler))
config.substitutions.append(("%openmp_flags", config.test_openmp_flags))
config.substitutions.append(("%archer_flags", config.archer_flags))
config.substitutions.append(("%flags", config.test_flags))
config.substitutions.append(("%nosuppression", "env TSAN_OPTIONS='ignore_noninstrumented_modules=0:exitcode=0'"))
config.substitutions.append(("%suppression", "env TSAN_OPTIONS='ignore_noninstrumented_modules=0:ignore_noninstrumented_modules=1'"))
config.substitutions.append(("%deflake", os.path.join(os.path.dirname(__file__), "deflake.bash")))
config.substitutions.append(("FileCheck", config.test_filecheck))
config.substitutions.append(("%not", config.test_not))
config.substitutions.append(("%sort-threads", "sort --numeric-sort --stable"))
if config.operating_system == 'Windows':
# No such environment variable on Windows.
config.substitutions.append(("%preload-tool", "true ||"))
elif config.operating_system == 'Darwin':
config.substitutions.append(("%preload-tool", "env DYLD_INSERT_LIBRARIES=%T/tool.so"))
else:
config.substitutions.append(("%preload-tool", "env LD_PRELOAD=%T/tool.so"))