llvm-project/openmp/runtime/test/lit.cfg

142 lines
4.9 KiB
INI
Raw Normal View History

# -*- 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 = 'libomp'
# 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.libomp_obj_root
# test format
config.test_format = lit.formats.ShTest()
# compiler flags
config.test_flags = " -I " + config.test_source_root + \
" -I " + config.omp_header_directory + \
" -L " + config.library_dir + \
" " + config.test_extra_flags
# extra libraries
libs = ""
if config.has_libm:
libs += " -lm"
if config.has_libatomic:
libs += " -latomic"
# Allow REQUIRES / UNSUPPORTED / XFAIL to work
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.library_dir)
if config.using_hwloc:
append_dynamic_library_path(config.hwloc_library_dir)
config.available_features.add('hwloc')
# Rpath modifications for Darwin
if config.operating_system == 'Darwin':
config.test_flags += " -Wl,-rpath," + config.library_dir
if config.using_hwloc:
config.test_flags += " -Wl,-rpath," + config.hwloc_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
# Disable OMPT tests if FileCheck was not found
if config.has_ompt and config.test_filecheck == "":
lit_config.note("Not testing OMPT because FileCheck was not found")
config.has_ompt = False
if config.has_ompt:
config.available_features.add("ompt")
# for callback.h
config.test_flags += " -I " + config.test_source_root + "/ompt"
if config.libomp_omp_version >= 50:
config.available_features.add("openmp-5.0")
if config.libomp_omp_version >= 45:
config.available_features.add("openmp-4.5")
if config.libomp_omp_version >= 40:
config.available_features.add("openmp-4.0")
if 'Linux' in config.operating_system:
config.available_features.add("linux")
[OpenMP] Implement OpenMP 5.0 affinity format functionality This patch adds the affinity format functionality introduced in OpenMP 5.0. This patch adds: Two new environment variables: OMP_DISPLAY_AFFINITY=TRUE|FALSE OMP_AFFINITY_FORMAT=<string> and Four new API: 1) omp_set_affinity_format() 2) omp_get_affinity_format() 3) omp_display_affinity() 4) omp_capture_affinity() The affinity format functionality has two ICV's associated with it: affinity-display-var (bool) and affinity-format-var (string). The affinity-display-var enables/disables the functionality through the envirable OMP_DISPLAY_AFFINITY. The affinity-format-var is a formatted string with the special field types beginning with a '%' character similar to printf For example, the affinity-format-var could be: "OMP: host:%H pid:%P OStid:%i num_threads:%N thread_num:%n affinity:{%A}" The affinity-format-var is displayed by every thread implicitly at the beginning of a parallel region when any thread's affinity has changed (including a brand new thread being spawned), or explicitly using the omp_display_affinity() API. The omp_capture_affinity() function can capture the affinity-format-var in a char buffer. And omp_set|get_affinity_format() allow the user to set|get the affinity-format-var explicitly at runtime. omp_capture_affinity() and omp_get_affinity_format() both return the number of characters needed to hold the entire string it tried to make (not including NULL character). If not enough buffer space is available, both these functions truncate their output. Differential Revision: https://reviews.llvm.org/D55148 llvm-svn: 349089
2018-12-14 07:14:24 +08:00
if config.operating_system in ['Linux', 'Windows']:
config.available_features.add('affinity')
# 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']
# substitutions
config.substitutions.append(("%libomp-compile-and-run", \
"%libomp-compile && %libomp-run"))
config.substitutions.append(("%libomp-cxx-compile-and-run", \
"%libomp-cxx-compile && %libomp-run"))
config.substitutions.append(("%libomp-cxx-compile", \
"%clangXX %openmp_flags %flags -std=c++11 %s -o %t" + libs))
config.substitutions.append(("%libomp-compile", \
"%clang %openmp_flags %flags %s -o %t" + libs))
config.substitutions.append(("%libomp-run", "%t"))
config.substitutions.append(("%clangXX", config.test_cxx_compiler))
config.substitutions.append(("%clang", config.test_c_compiler))
config.substitutions.append(("%openmp_flags", config.test_openmp_flags))
config.substitutions.append(("%flags", config.test_flags))
if config.has_ompt:
config.substitutions.append(("FileCheck", config.test_filecheck))
config.substitutions.append(("%sort-threads", "sort -n -s"))
[OMPT] Provide initialization for Mac OS X Traditionally, the library had a weak symbol for ompt_start_tool() that served as fallback and disabled OMPT if called. Tools could provide their own version and replace the default implementation to register callbacks and lookup functions. This mechanism has worked reasonably well on Linux systems where this interface was initially developed. On Darwin / Mac OS X the situation is a bit more complicated and the weak symbol doesn't work out-of-the-box. In my tests, the library with the tool needed to link against the OpenMP runtime to make the process work. This would effectively mean that a tool needed to choose a runtime library whereas one design goal of the interface was to allow tools that are agnostic of the runtime. The solution is to use dlsym() with the argument RTLD_DEFAULT so that static implementations of ompt_start_tool() are found in the main executable. This works because the linker on Mac OS X includes all symbols of an executable in the global symbol table by default. To use the same code path on Linux, the application would need to be built with -Wl,--export-dynamic. To avoid this restriction, we continue to use weak symbols on Linux systems as before. Finally this patch extends the existing test to cover all possible ways of initializing the tool as described by the standard. It also fixes ompt_finalize() to not call omp_get_thread_num() when the library is shut down which resulted in hangs on Darwin. The changes have been tested on Linux to make sure that it passes the current tests as well as the newly extended one. Differential Revision: https://reviews.llvm.org/D39801 llvm-svn: 317980
2017-11-11 21:59:48 +08:00
if config.operating_system == 'Windows':
# No such environment variable on Windows.
config.substitutions.append(("%preload-tool", "true ||"))
config.substitutions.append(("%no-as-needed-flag", "-Wl,--no-as-needed"))
[OMPT] Provide initialization for Mac OS X Traditionally, the library had a weak symbol for ompt_start_tool() that served as fallback and disabled OMPT if called. Tools could provide their own version and replace the default implementation to register callbacks and lookup functions. This mechanism has worked reasonably well on Linux systems where this interface was initially developed. On Darwin / Mac OS X the situation is a bit more complicated and the weak symbol doesn't work out-of-the-box. In my tests, the library with the tool needed to link against the OpenMP runtime to make the process work. This would effectively mean that a tool needed to choose a runtime library whereas one design goal of the interface was to allow tools that are agnostic of the runtime. The solution is to use dlsym() with the argument RTLD_DEFAULT so that static implementations of ompt_start_tool() are found in the main executable. This works because the linker on Mac OS X includes all symbols of an executable in the global symbol table by default. To use the same code path on Linux, the application would need to be built with -Wl,--export-dynamic. To avoid this restriction, we continue to use weak symbols on Linux systems as before. Finally this patch extends the existing test to cover all possible ways of initializing the tool as described by the standard. It also fixes ompt_finalize() to not call omp_get_thread_num() when the library is shut down which resulted in hangs on Darwin. The changes have been tested on Linux to make sure that it passes the current tests as well as the newly extended one. Differential Revision: https://reviews.llvm.org/D39801 llvm-svn: 317980
2017-11-11 21:59:48 +08:00
elif config.operating_system == 'Darwin':
config.substitutions.append(("%preload-tool", "env DYLD_INSERT_LIBRARIES=%T/tool.so"))
# No such linker flag on Darwin.
config.substitutions.append(("%no-as-needed-flag", ""))
[OMPT] Provide initialization for Mac OS X Traditionally, the library had a weak symbol for ompt_start_tool() that served as fallback and disabled OMPT if called. Tools could provide their own version and replace the default implementation to register callbacks and lookup functions. This mechanism has worked reasonably well on Linux systems where this interface was initially developed. On Darwin / Mac OS X the situation is a bit more complicated and the weak symbol doesn't work out-of-the-box. In my tests, the library with the tool needed to link against the OpenMP runtime to make the process work. This would effectively mean that a tool needed to choose a runtime library whereas one design goal of the interface was to allow tools that are agnostic of the runtime. The solution is to use dlsym() with the argument RTLD_DEFAULT so that static implementations of ompt_start_tool() are found in the main executable. This works because the linker on Mac OS X includes all symbols of an executable in the global symbol table by default. To use the same code path on Linux, the application would need to be built with -Wl,--export-dynamic. To avoid this restriction, we continue to use weak symbols on Linux systems as before. Finally this patch extends the existing test to cover all possible ways of initializing the tool as described by the standard. It also fixes ompt_finalize() to not call omp_get_thread_num() when the library is shut down which resulted in hangs on Darwin. The changes have been tested on Linux to make sure that it passes the current tests as well as the newly extended one. Differential Revision: https://reviews.llvm.org/D39801 llvm-svn: 317980
2017-11-11 21:59:48 +08:00
else:
config.substitutions.append(("%preload-tool", "env LD_PRELOAD=%T/tool.so"))
config.substitutions.append(("%no-as-needed-flag", "-Wl,--no-as-needed"))