2015-09-22 04:41:31 +08:00
|
|
|
# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
|
|
|
|
# Configuration file for the 'lit' test runner.
|
|
|
|
|
|
|
|
import os
|
2016-03-24 20:52:20 +08:00
|
|
|
import re
|
2016-01-20 03:26:43 +08:00
|
|
|
import subprocess
|
2015-09-22 04:41:31 +08:00
|
|
|
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()
|
|
|
|
|
2015-12-01 04:02:59 +08:00
|
|
|
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 = ':'
|
2015-09-22 04:41:31 +08:00
|
|
|
if name in config.environment:
|
2015-12-01 04:02:59 +08:00
|
|
|
config.environment[name] = path + sep + config.environment[name]
|
2015-09-22 04:41:31 +08:00
|
|
|
else:
|
2015-12-01 04:02:59 +08:00
|
|
|
config.environment[name] = path
|
2015-09-22 04:41:31 +08:00
|
|
|
|
|
|
|
# name: The name of this test suite.
|
|
|
|
config.name = 'libomp'
|
|
|
|
|
|
|
|
# suffixes: A list of file extensions to treat as test files.
|
2017-10-21 03:42:32 +08:00
|
|
|
config.suffixes = ['.c', '.cpp']
|
2015-09-22 04:41:31 +08:00
|
|
|
|
|
|
|
# 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
|
2017-11-30 03:31:52 +08:00
|
|
|
config.test_flags = " -I " + config.test_source_root + \
|
2015-09-22 04:41:31 +08:00
|
|
|
" -I " + config.omp_header_directory + \
|
|
|
|
" -L " + config.library_dir + \
|
2017-11-30 03:31:52 +08:00
|
|
|
" " + config.test_extra_flags
|
2015-09-22 04:41:31 +08:00
|
|
|
|
2016-05-24 01:50:32 +08:00
|
|
|
# extra libraries
|
|
|
|
libs = ""
|
|
|
|
if config.has_libm:
|
|
|
|
libs += " -lm"
|
2017-02-25 06:15:24 +08:00
|
|
|
if config.has_libatomic:
|
|
|
|
libs += " -latomic"
|
2016-05-24 01:50:32 +08:00
|
|
|
|
2018-09-05 15:26:00 +08:00
|
|
|
# Allow REQUIRES / UNSUPPORTED / XFAIL to work
|
2017-12-01 01:08:31 +08:00
|
|
|
for feature in config.test_compiler_features:
|
|
|
|
config.available_features.add(feature)
|
2016-03-24 20:52:20 +08:00
|
|
|
|
2015-09-22 04:41:31 +08:00
|
|
|
# Setup environment to find dynamic library at runtime
|
2015-12-01 04:02:59 +08:00
|
|
|
append_dynamic_library_path(config.library_dir)
|
|
|
|
if config.using_hwloc:
|
|
|
|
append_dynamic_library_path(config.hwloc_library_dir)
|
2017-06-01 04:35:22 +08:00
|
|
|
config.available_features.add('hwloc')
|
2015-12-01 04:02:59 +08:00
|
|
|
|
|
|
|
# Rpath modifications for Darwin
|
|
|
|
if config.operating_system == 'Darwin':
|
2017-11-30 03:31:52 +08:00
|
|
|
config.test_flags += " -Wl,-rpath," + config.library_dir
|
2015-12-01 04:02:59 +08:00
|
|
|
if config.using_hwloc:
|
2017-11-30 03:31:52 +08:00
|
|
|
config.test_flags += " -Wl,-rpath," + config.hwloc_library_dir
|
2015-09-22 04:41:31 +08:00
|
|
|
|
2016-01-20 03:26:43 +08:00
|
|
|
# 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:
|
2017-11-30 03:31:52 +08:00
|
|
|
config.test_flags += " -isysroot " + out
|
2016-01-20 03:26:43 +08:00
|
|
|
|
2016-03-22 15:22:49 +08:00
|
|
|
# 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
|
2017-11-30 03:31:52 +08:00
|
|
|
config.test_flags += " -I " + config.test_source_root + "/ompt"
|
2016-03-22 15:22:49 +08:00
|
|
|
|
[OpenMP] Fixes for LIBOMP_OMP_VERSION=45/40
Summary:
I have discovered this because i wanted to experiment with
building static libomp (with openmp-4.0 support only)
for debugging purposes.
There are three kinds of problems here:
1. `__kmp_compare_and_store_acq()` simply does not exist.
It was added in D47903 by @jlpeyton.
I'm guessing `__kmp_atomic_compare_store_acq()` was meant.
2. In `__kmp_is_ticket_lock_initialized()`,
`lck->lk.initialized` is `std::atomic<bool>`,
while `lck` is `kmp_ticket_lock_t *`.
Naturally, they can't be equality-compared.
Either, it should return the value read from `lck->lk.initialized`,
or do what `__kmp_is_queuing_lock_initialized()` does,
compare the passed pointer with the field in the struct
pointed by the pointer. I think the latter is correct-er choice here.
3. Tests were not versioned.
They assume that `LIBOMP_OMP_VERSION` is at the latest version.
This does not touch LIBOMP_OMP_VERSION=30. That is still broken.
Reviewers: jlpeyton, Hahnfeld, AndreyChurbanov
Reviewed By: AndreyChurbanov
Subscribers: guansong, jfb, openmp-commits, jlpeyton
Tags: #openmp
Differential Revision: https://reviews.llvm.org/D55496
llvm-svn: 349260
2018-12-15 17:23:39 +08:00
|
|
|
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")
|
|
|
|
|
2017-11-01 18:08:30 +08:00
|
|
|
if 'Linux' in config.operating_system:
|
|
|
|
config.available_features.add("linux")
|
|
|
|
|
2018-12-14 07:14:24 +08:00
|
|
|
if config.operating_system in ['Linux', 'Windows']:
|
|
|
|
config.available_features.add('affinity')
|
|
|
|
|
2017-10-21 03:45:43 +08:00
|
|
|
# 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']
|
|
|
|
|
2016-03-22 15:22:49 +08:00
|
|
|
|
2017-11-01 18:08:30 +08:00
|
|
|
# substitutions
|
2015-09-22 04:41:31 +08:00
|
|
|
config.substitutions.append(("%libomp-compile-and-run", \
|
2016-02-26 02:04:09 +08:00
|
|
|
"%libomp-compile && %libomp-run"))
|
2017-10-21 03:42:32 +08:00
|
|
|
config.substitutions.append(("%libomp-cxx-compile-and-run", \
|
|
|
|
"%libomp-cxx-compile && %libomp-run"))
|
|
|
|
config.substitutions.append(("%libomp-cxx-compile", \
|
2017-11-30 03:31:52 +08:00
|
|
|
"%clangXX %openmp_flags %flags -std=c++11 %s -o %t" + libs))
|
2016-02-26 02:04:09 +08:00
|
|
|
config.substitutions.append(("%libomp-compile", \
|
2017-11-30 03:31:52 +08:00
|
|
|
"%clang %openmp_flags %flags %s -o %t" + libs))
|
2016-02-26 02:04:09 +08:00
|
|
|
config.substitutions.append(("%libomp-run", "%t"))
|
2017-10-21 03:42:32 +08:00
|
|
|
config.substitutions.append(("%clangXX", config.test_cxx_compiler))
|
2017-11-30 03:31:52 +08:00
|
|
|
config.substitutions.append(("%clang", config.test_c_compiler))
|
|
|
|
config.substitutions.append(("%openmp_flags", config.test_openmp_flags))
|
|
|
|
config.substitutions.append(("%flags", config.test_flags))
|
2015-09-22 04:41:31 +08:00
|
|
|
|
2017-11-01 18:08:30 +08:00
|
|
|
if config.has_ompt:
|
|
|
|
config.substitutions.append(("FileCheck", config.test_filecheck))
|
2018-12-11 23:39:26 +08:00
|
|
|
config.substitutions.append(("%sort-threads", "sort -n -s"))
|
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 ||"))
|
2018-07-05 17:14:06 +08:00
|
|
|
config.substitutions.append(("%no-as-needed-flag", "-Wl,--no-as-needed"))
|
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"))
|
2018-07-05 17:14:06 +08:00
|
|
|
# No such linker flag on Darwin.
|
|
|
|
config.substitutions.append(("%no-as-needed-flag", ""))
|
2017-11-11 21:59:48 +08:00
|
|
|
else:
|
|
|
|
config.substitutions.append(("%preload-tool", "env LD_PRELOAD=%T/tool.so"))
|
2018-07-05 17:14:06 +08:00
|
|
|
config.substitutions.append(("%no-as-needed-flag", "-Wl,--no-as-needed"))
|