[OpenMP][Tool] Make tests for archer dependent on TSan
If the openmp project is built standalone, the test compiler is feature tested for an available -fsanitize=thread flag.
If the openmp project is built as part of llvm, the target tsan is needed to test archer.
An additional line (requires tsan) was introduced to the tests, this patch updates the line numbers for the race.
Follow-up for 77ad98c
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D71914
This commit is contained in:
parent
7cd429f27d
commit
84637408f2
|
@ -9,6 +9,7 @@ function(write_compiler_information lang)
|
||||||
set(information "${information}\\;${CMAKE_${lang}_COMPILER_ID}")
|
set(information "${information}\\;${CMAKE_${lang}_COMPILER_ID}")
|
||||||
set(information "${information}\\;${CMAKE_${lang}_COMPILER_VERSION}")
|
set(information "${information}\\;${CMAKE_${lang}_COMPILER_VERSION}")
|
||||||
set(information "${information}\\;${${lang}_FLAGS}")
|
set(information "${information}\\;${${lang}_FLAGS}")
|
||||||
|
set(information "${information}\\;${${lang}_HAS_TSAN_FLAG}")
|
||||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${lang}CompilerInformation.txt ${information})
|
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${lang}CompilerInformation.txt ${information})
|
||||||
endfunction(write_compiler_information)
|
endfunction(write_compiler_information)
|
||||||
|
|
||||||
|
@ -39,5 +40,9 @@ if (CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||||
add_experimental_isel_flag(CXX)
|
add_experimental_isel_flag(CXX)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
SET(CMAKE_REQUIRED_FLAGS "-fsanitize=thread")
|
||||||
|
check_c_compiler_flag("" C_HAS_TSAN_FLAG)
|
||||||
|
check_cxx_compiler_flag("" CXX_HAS_TSAN_FLAG)
|
||||||
|
|
||||||
write_compiler_information(C)
|
write_compiler_information(C)
|
||||||
write_compiler_information(CXX)
|
write_compiler_information(CXX)
|
||||||
|
|
|
@ -64,11 +64,13 @@ macro(extract_test_compiler_information lang file)
|
||||||
list(GET information 1 id)
|
list(GET information 1 id)
|
||||||
list(GET information 2 version)
|
list(GET information 2 version)
|
||||||
list(GET information 3 openmp_flags)
|
list(GET information 3 openmp_flags)
|
||||||
|
list(GET information 4 has_tsan_flags)
|
||||||
|
|
||||||
set(OPENMP_TEST_${lang}_COMPILER_PATH ${path})
|
set(OPENMP_TEST_${lang}_COMPILER_PATH ${path})
|
||||||
set(OPENMP_TEST_${lang}_COMPILER_ID ${id})
|
set(OPENMP_TEST_${lang}_COMPILER_ID ${id})
|
||||||
set(OPENMP_TEST_${lang}_COMPILER_VERSION ${version})
|
set(OPENMP_TEST_${lang}_COMPILER_VERSION ${version})
|
||||||
set(OPENMP_TEST_${lang}_COMPILER_OPENMP_FLAGS ${openmp_flags})
|
set(OPENMP_TEST_${lang}_COMPILER_OPENMP_FLAGS ${openmp_flags})
|
||||||
|
set(OPENMP_TEST_${lang}_COMPILER_HAS_TSAN_FLAGS ${has_tsan_flags})
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
# Function to set variables with information about the test compiler.
|
# Function to set variables with information about the test compiler.
|
||||||
|
@ -84,6 +86,7 @@ function(set_test_compiler_information dir)
|
||||||
set(OPENMP_TEST_COMPILER_ID "${OPENMP_TEST_C_COMPILER_ID}" PARENT_SCOPE)
|
set(OPENMP_TEST_COMPILER_ID "${OPENMP_TEST_C_COMPILER_ID}" PARENT_SCOPE)
|
||||||
set(OPENMP_TEST_COMPILER_VERSION "${OPENMP_TEST_C_COMPILER_VERSION}" PARENT_SCOPE)
|
set(OPENMP_TEST_COMPILER_VERSION "${OPENMP_TEST_C_COMPILER_VERSION}" PARENT_SCOPE)
|
||||||
set(OPENMP_TEST_COMPILER_OPENMP_FLAGS "${OPENMP_TEST_C_COMPILER_OPENMP_FLAGS}" PARENT_SCOPE)
|
set(OPENMP_TEST_COMPILER_OPENMP_FLAGS "${OPENMP_TEST_C_COMPILER_OPENMP_FLAGS}" PARENT_SCOPE)
|
||||||
|
set(OPENMP_TEST_COMPILER_HAS_TSAN_FLAGS "${OPENMP_TEST_C_COMPILER_HAS_TSAN_FLAGS}" PARENT_SCOPE)
|
||||||
|
|
||||||
# Determine major version.
|
# Determine major version.
|
||||||
string(REGEX MATCH "[0-9]+" major "${OPENMP_TEST_C_COMPILER_VERSION}")
|
string(REGEX MATCH "[0-9]+" major "${OPENMP_TEST_C_COMPILER_VERSION}")
|
||||||
|
@ -128,6 +131,11 @@ else()
|
||||||
else()
|
else()
|
||||||
set(OPENMP_TEST_COMPILER_THREAD_FLAGS "${CMAKE_THREAD_LIBS_INIT}")
|
set(OPENMP_TEST_COMPILER_THREAD_FLAGS "${CMAKE_THREAD_LIBS_INIT}")
|
||||||
endif()
|
endif()
|
||||||
|
if(TARGET tsan)
|
||||||
|
set(OPENMP_TEST_COMPILER_HAS_TSAN_FLAGS 1)
|
||||||
|
else()
|
||||||
|
set(OPENMP_TEST_COMPILER_HAS_TSAN_FLAGS 0)
|
||||||
|
endif()
|
||||||
# TODO: Implement blockaddress in GlobalISel and remove this flag!
|
# TODO: Implement blockaddress in GlobalISel and remove this flag!
|
||||||
set(OPENMP_TEST_COMPILER_OPENMP_FLAGS "-fopenmp ${OPENMP_TEST_COMPILER_THREAD_FLAGS} -fno-experimental-isel")
|
set(OPENMP_TEST_COMPILER_OPENMP_FLAGS "-fopenmp ${OPENMP_TEST_COMPILER_THREAD_FLAGS} -fno-experimental-isel")
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -16,6 +16,9 @@ endif()
|
||||||
|
|
||||||
set(LIBARCHER_TEST_PATH ${CMAKE_CURRENT_SOURCE_DIR})
|
set(LIBARCHER_TEST_PATH ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
|
set(LIBARCHER_TEST_FLAGS "" CACHE STRING
|
||||||
|
"Extra compiler flags to send to the test compiler.")
|
||||||
|
|
||||||
macro(pythonize_bool var)
|
macro(pythonize_bool var)
|
||||||
if (${var})
|
if (${var})
|
||||||
set(${var} True)
|
set(${var} True)
|
||||||
|
@ -25,8 +28,9 @@ macro(pythonize_bool var)
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
pythonize_bool(LIBARCHER_HAVE_LIBATOMIC)
|
pythonize_bool(LIBARCHER_HAVE_LIBATOMIC)
|
||||||
|
pythonize_bool(OPENMP_TEST_COMPILER_HAS_TSAN_FLAGS)
|
||||||
|
|
||||||
add_openmp_testsuite(check-libarcher "Running libarcher tests" ${CMAKE_CURRENT_BINARY_DIR} DEPENDS archer)
|
add_openmp_testsuite(check-libarcher "Running libarcher tests" ${CMAKE_CURRENT_BINARY_DIR} DEPENDS archer omp)
|
||||||
|
|
||||||
# Configure the lit.site.cfg.in file
|
# Configure the lit.site.cfg.in file
|
||||||
set(AUTO_GEN_COMMENT "## Autogenerated by libarcher configuration.\n# Do not edit!")
|
set(AUTO_GEN_COMMENT "## Autogenerated by libarcher configuration.\n# Do not edit!")
|
||||||
|
|
|
@ -46,7 +46,7 @@ config.test_flags = " -I " + config.test_source_root + \
|
||||||
" -I " + config.omp_header_dir + \
|
" -I " + config.omp_header_dir + \
|
||||||
" -L " + config.omp_library_dir + \
|
" -L " + config.omp_library_dir + \
|
||||||
" -Wl,-rpath," + config.omp_library_dir + \
|
" -Wl,-rpath," + config.omp_library_dir + \
|
||||||
" " + config.test_extra_flags
|
" " + config.test_archer_flags
|
||||||
|
|
||||||
config.archer_flags = "-g -O1 -fsanitize=thread"
|
config.archer_flags = "-g -O1 -fsanitize=thread"
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@ for feature in config.test_compiler_features:
|
||||||
|
|
||||||
# Setup environment to find dynamic library at runtime
|
# Setup environment to find dynamic library at runtime
|
||||||
append_dynamic_library_path(config.omp_library_dir)
|
append_dynamic_library_path(config.omp_library_dir)
|
||||||
|
append_dynamic_library_path(config.libarcher_obj_root+"/..")
|
||||||
|
|
||||||
# Rpath modifications for Darwin
|
# Rpath modifications for Darwin
|
||||||
if config.operating_system == 'Darwin':
|
if config.operating_system == 'Darwin':
|
||||||
|
@ -81,6 +82,9 @@ if config.operating_system == 'Darwin':
|
||||||
if 'Linux' in config.operating_system:
|
if 'Linux' in config.operating_system:
|
||||||
config.available_features.add("linux")
|
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
|
# to run with icc INTEL_LICENSE_FILE must be set
|
||||||
if 'INTEL_LICENSE_FILE' in os.environ:
|
if 'INTEL_LICENSE_FILE' in os.environ:
|
||||||
config.environment['INTEL_LICENSE_FILE'] = os.environ['INTEL_LICENSE_FILE']
|
config.environment['INTEL_LICENSE_FILE'] = os.environ['INTEL_LICENSE_FILE']
|
||||||
|
|
|
@ -10,9 +10,10 @@ config.libomp_obj_root = "@CMAKE_CURRENT_BINARY_DIR@"
|
||||||
config.omp_library_dir = "@LIBOMP_LIBRARY_DIR@"
|
config.omp_library_dir = "@LIBOMP_LIBRARY_DIR@"
|
||||||
config.omp_header_dir = "@LIBOMP_INCLUDE_DIR@"
|
config.omp_header_dir = "@LIBOMP_INCLUDE_DIR@"
|
||||||
config.operating_system = "@CMAKE_SYSTEM_NAME@"
|
config.operating_system = "@CMAKE_SYSTEM_NAME@"
|
||||||
config.has_libatomic = "@LIBARCHER_HAVE_LIBATOMIC@"
|
config.has_libatomic = @LIBARCHER_HAVE_LIBATOMIC@
|
||||||
|
config.has_tsan = @OPENMP_TEST_COMPILER_HAS_TSAN_FLAGS@
|
||||||
|
|
||||||
config.test_archer_flags = "@OPENMP_TEST_ARCHER_FLAGS@"
|
config.test_archer_flags = "@LIBARCHER_TEST_FLAGS@"
|
||||||
config.libarcher_obj_root = "@CMAKE_CURRENT_BINARY_DIR@"
|
config.libarcher_obj_root = "@CMAKE_CURRENT_BINARY_DIR@"
|
||||||
|
|
||||||
# Let the main config do the real work.
|
# Let the main config do the real work.
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
|
||||||
// RUN: %libarcher-compile-and-run-race | FileCheck %s
|
// RUN: %libarcher-compile-and-run-race | FileCheck %s
|
||||||
// REQUIRES: tsan
|
// REQUIRES: tsan
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
|
@ -40,4 +39,3 @@ int main(int argc, char *argv[]) {
|
||||||
// CHECK-NEXT: #0 {{.*}}critical-unrelated.c:29
|
// CHECK-NEXT: #0 {{.*}}critical-unrelated.c:29
|
||||||
// CHECK: DONE
|
// CHECK: DONE
|
||||||
// CHECK: ThreadSanitizer: reported 1 warnings
|
// CHECK: ThreadSanitizer: reported 1 warnings
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
|
||||||
// RUN: %libarcher-compile-and-run-race | FileCheck %s
|
// RUN: %libarcher-compile-and-run-race | FileCheck %s
|
||||||
// REQUIRES: tsan
|
// REQUIRES: tsan
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
|
@ -46,4 +45,3 @@ int main(int argc, char *argv[]) {
|
||||||
// CHECK-NEXT: #0 {{.*}}lock-nested-unrelated.c:33
|
// CHECK-NEXT: #0 {{.*}}lock-nested-unrelated.c:33
|
||||||
// CHECK: DONE
|
// CHECK: DONE
|
||||||
// CHECK: ThreadSanitizer: reported 1 warnings
|
// CHECK: ThreadSanitizer: reported 1 warnings
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
|
||||||
// RUN: %libarcher-compile-and-run-race | FileCheck %s
|
// RUN: %libarcher-compile-and-run-race | FileCheck %s
|
||||||
// REQUIRES: tsan
|
// REQUIRES: tsan
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
|
@ -46,4 +45,3 @@ int main(int argc, char *argv[]) {
|
||||||
// CHECK-NEXT: #0 {{.*}}lock-unrelated.c:31
|
// CHECK-NEXT: #0 {{.*}}lock-unrelated.c:31
|
||||||
// CHECK: DONE
|
// CHECK: DONE
|
||||||
// CHECK: ThreadSanitizer: reported 1 warnings
|
// CHECK: ThreadSanitizer: reported 1 warnings
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
|
||||||
// RUN: %libarcher-compile-and-run-race | FileCheck %s
|
// RUN: %libarcher-compile-and-run-race | FileCheck %s
|
||||||
// REQUIRES: tsan
|
// REQUIRES: tsan
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
|
@ -35,4 +34,3 @@ int main(int argc, char *argv[]) {
|
||||||
// CHECK-NEXT: #0 {{.*}}parallel-simple.c:23
|
// CHECK-NEXT: #0 {{.*}}parallel-simple.c:23
|
||||||
// CHECK: DONE
|
// CHECK: DONE
|
||||||
// CHECK: ThreadSanitizer: reported 1 warnings
|
// CHECK: ThreadSanitizer: reported 1 warnings
|
||||||
|
|
||||||
|
|
|
@ -11,13 +11,12 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
|
||||||
// RUN: %libarcher-compile-and-run-race | FileCheck %s
|
// RUN: %libarcher-compile-and-run-race | FileCheck %s
|
||||||
// REQUIRES: tsan
|
// REQUIRES: tsan
|
||||||
|
#include "ompt/ompt-signal.h"
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "ompt/ompt-signal.h"
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
int var = 0, a = 0;
|
int var = 0, a = 0;
|
||||||
|
@ -59,4 +58,3 @@ int main(int argc, char *argv[]) {
|
||||||
// CHECK-NEXT: #0 {{.*}}task-dependency.c:30
|
// CHECK-NEXT: #0 {{.*}}task-dependency.c:30
|
||||||
// CHECK: DONE
|
// CHECK: DONE
|
||||||
// CHECK: ThreadSanitizer: reported 1 warnings
|
// CHECK: ThreadSanitizer: reported 1 warnings
|
||||||
|
|
||||||
|
|
|
@ -13,10 +13,10 @@
|
||||||
|
|
||||||
// RUN: %libarcher-compile-and-run-race | FileCheck %s
|
// RUN: %libarcher-compile-and-run-race | FileCheck %s
|
||||||
// REQUIRES: tsan
|
// REQUIRES: tsan
|
||||||
|
#include "ompt/ompt-signal.h"
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "ompt/ompt-signal.h"
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
int var = 0, a = 0;
|
int var = 0, a = 0;
|
||||||
|
@ -54,9 +54,8 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
// CHECK: WARNING: ThreadSanitizer: data race
|
// CHECK: WARNING: ThreadSanitizer: data race
|
||||||
// CHECK-NEXT: {{(Write|Read)}} of size 4
|
// CHECK-NEXT: {{(Write|Read)}} of size 4
|
||||||
// CHECK-NEXT: #0 {{.*}}task-taskgroup-unrelated.c:46
|
// CHECK-NEXT: #0 {{.*}}task-taskgroup-unrelated.c:47
|
||||||
// CHECK: Previous write of size 4
|
// CHECK: Previous write of size 4
|
||||||
// CHECK-NEXT: #0 {{.*}}task-taskgroup-unrelated.c:28
|
// CHECK-NEXT: #0 {{.*}}task-taskgroup-unrelated.c:29
|
||||||
// CHECK: DONE
|
// CHECK: DONE
|
||||||
// CHECK: ThreadSanitizer: reported 1 warnings
|
// CHECK: ThreadSanitizer: reported 1 warnings
|
||||||
|
|
||||||
|
|
|
@ -11,13 +11,12 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
|
||||||
// RUN: %libarcher-compile-and-run-race | FileCheck %s
|
// RUN: %libarcher-compile-and-run-race | FileCheck %s
|
||||||
// REQUIRES: tsan
|
// REQUIRES: tsan
|
||||||
|
#include "ompt/ompt-signal.h"
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "ompt/ompt-signal.h"
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
int var = 0, a = 0;
|
int var = 0, a = 0;
|
||||||
|
@ -57,4 +56,3 @@ int main(int argc, char *argv[]) {
|
||||||
// CHECK-NEXT: #0 {{.*}}task-taskwait-nested.c:44
|
// CHECK-NEXT: #0 {{.*}}task-taskwait-nested.c:44
|
||||||
// CHECK: DONE
|
// CHECK: DONE
|
||||||
// CHECK: ThreadSanitizer: reported 1 warnings
|
// CHECK: ThreadSanitizer: reported 1 warnings
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
|
||||||
// RUN: %libarcher-compile-and-run-race | FileCheck %s
|
// RUN: %libarcher-compile-and-run-race | FileCheck %s
|
||||||
// REQUIRES: tsan
|
// REQUIRES: tsan
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
|
@ -24,8 +23,8 @@ int main(int argc, char *argv[]) {
|
||||||
int var = 0;
|
int var = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
#pragma omp parallel for num_threads(NUM_THREADS) shared(var) schedule(static, \
|
#pragma omp parallel for num_threads(NUM_THREADS) shared(var) \
|
||||||
1)
|
schedule(static, 1)
|
||||||
for (i = 0; i < NUM_THREADS; i++) {
|
for (i = 0; i < NUM_THREADS; i++) {
|
||||||
#pragma omp task shared(var) if (0) // the task is inlined an executed locally
|
#pragma omp task shared(var) if (0) // the task is inlined an executed locally
|
||||||
{ var++; }
|
{ var++; }
|
||||||
|
@ -43,4 +42,3 @@ int main(int argc, char *argv[]) {
|
||||||
// CHECK-NEXT: #0 {{.*}}task-two.c:30
|
// CHECK-NEXT: #0 {{.*}}task-two.c:30
|
||||||
// CHECK: DONE
|
// CHECK: DONE
|
||||||
// CHECK: ThreadSanitizer: reported 1 warnings
|
// CHECK: ThreadSanitizer: reported 1 warnings
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue