Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -31,11 +31,13 @@ add_library(pstl::ParallelSTL ALIAS ParallelSTL) if (PARALLELSTL_USE_PARALLEL_POLICIES) + message(STATUS "Using Parallel Policies") if (PARALLELSTL_BACKEND STREQUAL "tbb") find_package(TBB 2018 REQUIRED tbb OPTIONAL_COMPONENTS tbbmalloc) message(STATUS "Parallel STL uses TBB ${TBB_VERSION} (interface version: ${TBB_INTERFACE_VERSION})") target_link_libraries(ParallelSTL INTERFACE TBB::tbb) - else() + else() + message(STATUS "Using Parallel Policies, but not tbb") if (TARGET ${PARALLELSTL_BACKEND}) target_link_libraries(ParallelSTL INTERFACE ${PARALLELSTL_BACKEND}) else() Index: include/pstl/internal/parallel_backend_utils.h =================================================================== --- include/pstl/internal/parallel_backend_utils.h +++ include/pstl/internal/parallel_backend_utils.h @@ -12,6 +12,7 @@ #include #include +#include #include "utils.h" namespace __pstl Index: test/CMakeLists.txt =================================================================== --- test/CMakeLists.txt +++ test/CMakeLists.txt @@ -18,16 +18,20 @@ DEPENDS pstl-build-tests COMMENT "Build and run all the unit tests.") -file(GLOB_RECURSE UNIT_TESTS "test_*.cpp") +file(GLOB_RECURSE UNIT_TESTS "*.pass.cpp") foreach(_file IN LISTS UNIT_TESTS) file(RELATIVE_PATH _target "${CMAKE_CURRENT_SOURCE_DIR}" "${_file}") string(REPLACE ".cpp" "" _target "${_target}") + string(REPLACE "/" "-" _target "${_target}") set(_target "pstl-${_target}") add_executable(${_target} EXCLUDE_FROM_ALL "${_file}") + target_include_directories(${_target} PRIVATE "${CMAKE_CURRENT_LIST_DIR}") target_link_libraries(${_target} PRIVATE pstl::ParallelSTL) + target_compile_definitions(${_target} PRIVATE -DPSTL_STANDALONE_TESTS) set_target_properties(${_target} PROPERTIES CXX_EXTENSIONS NO RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") add_test(${_target} "${CMAKE_CURRENT_BINARY_DIR}/${_target}") add_dependencies(pstl-build-tests ${_target}) endforeach() + Index: test/pstl_test_config.h =================================================================== --- /dev/null +++ test/pstl_test_config.h @@ -1,49 +0,0 @@ -// -*- C++ -*- -//===-- pstl_test_config.h ------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef __PSTL_TEST_config_H -#define __PSTL_TEST_config_H - -#if defined(_MSC_VER) && defined(_DEBUG) -#define _SCL_SECURE_NO_WARNINGS //to prevent the compilation warning. Microsoft STL implementation has specific checking of an iterator range in DEBUG mode for the containers from the standard library. -#endif - -#define __PSTL_ICC_16_17_TEST_REDUCTION_BOOL_TYPE_RELEASE_64_BROKEN \ - (__x86_64 && !_DEBUG && __INTEL_COMPILER && __INTEL_COMPILER <= 1700 && !__APPLE__) -#define __PSTL_ICC_16_17_TEST_REDUCTION_RELEASE_BROKEN \ - (!_DEBUG && __INTEL_COMPILER && \ - (__INTEL_COMPILER < 1800 || (__INTEL_COMPILER == 1800 && __INTEL_COMPILER_UPDATE < 1))) -#define __PSTL_ICC_1800_TEST_MONOTONIC_RELEASE_64_BROKEN \ - (__x86_64 && !_DEBUG && __INTEL_COMPILER && __INTEL_COMPILER == 1800 && __INTEL_COMPILER_UPDATE < 1) -#define __PSTL_ICC_17_TEST_MAC_RELEASE_32_BROKEN \ - (__i386__ && !_DEBUG && __INTEL_COMPILER >= 1700 && __INTEL_COMPILER < 1800 && __APPLE__) -#define __PSTL_ICC_18_VC141_TEST_SIMD_LAMBDA_RELEASE_BROKEN \ - (!_DEBUG && __INTEL_COMPILER >= 1800 && __INTEL_COMPILER < 1900 && _MSC_VER == 1910) -#define __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN \ - (_M_IX86 && _DEBUG && __INTEL_COMPILER >= 1700 && __INTEL_COMPILER < 1800 && _MSC_VER >= 1900) -#define __PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN \ - (_M_IX86 && _DEBUG && __INTEL_COMPILER >= 1600 && __INTEL_COMPILER < 1700 && _MSC_VER == 1900) -#define __PSTL_ICC_16_VC14_TEST_PAR_TBB_RT_RELEASE_64_BROKEN \ - (__PSTL_USE_PAR_POLICIES && ((_M_X64 && _MSC_VER == 1900) || __x86_64) && !_DEBUG && __INTEL_COMPILER < 1700) -#define __PSTL_ICC_16_17_TEST_64_TIMEOUT (__x86_64 && __INTEL_COMPILER && __INTEL_COMPILER < 1800 && !__APPLE__) -#define __PSTL_ICC_18_TEST_EARLY_EXIT_MONOTONIC_RELEASE_BROKEN (!_DEBUG && __INTEL_COMPILER && __INTEL_COMPILER == 1800) -#define __PSTL_CLANG_TEST_BIG_OBJ_DEBUG_32_BROKEN \ - (__i386__ && PSTL_USE_DEBUG && __clang__ && __PSTL_CLANG_VERSION <= 90000) -#define __PSTL_ICC_16_17_18_TEST_UNIQUE_MASK_RELEASE_BROKEN \ - (!_DEBUG && __INTEL_COMPILER && \ - (__INTEL_COMPILER < 1800 || (__INTEL_COMPILER == 1800 && __INTEL_COMPILER_UPDATE < 3))) -#define __PSTL_ICC_18_TEST_EARLY_EXIT_AVX_RELEASE_BROKEN \ - (!_DEBUG && __INTEL_COMPILER == 1800 && __AVX__ && !__AVX2__ && !__AVX512__) -#define __PSTL_ICC_19_TEST_IS_PARTITIONED_RELEASE_BROKEN \ - (!PSTL_USE_DEBUG && (__linux__ || __APPLE__) && __INTEL_COMPILER == 1900) -#define __PSTL_ICL_19_VC14_VC141_TEST_SCAN_RELEASE_BROKEN \ - (__INTEL_COMPILER == 1900 && _MSC_VER >= 1900 && _MSC_VER <= 1910) -#define __PSTL_ICC_19_TEST_SIMD_UDS_WINDOWS_RELEASE_BROKEN (__INTEL_COMPILER == 1900 && _MSC_VER && !_DEBUG) - -#endif /* __PSTL_TEST_config_H */ Index: test/std/algorithms/alg.merge/inplace_merge.pass.cpp =================================================================== --- test/std/algorithms/alg.merge/inplace_merge.pass.cpp +++ test/std/algorithms/alg.merge/inplace_merge.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_inplace_merge.cpp --------------------------------------------===// +//===-- inplace_merge.pass.cpp --------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,13 +7,19 @@ // //===----------------------------------------------------------------------===// -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.merge/merge.pass.cpp =================================================================== --- test/std/algorithms/alg.merge/merge.pass.cpp +++ test/std/algorithms/alg.merge/merge.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_merge.cpp ----------------------------------------------------===// +//===-- merge.pass.cpp ----------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,14 +7,20 @@ // //===----------------------------------------------------------------------===// -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include #include #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp =================================================================== --- test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp +++ test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_copy_if.cpp --------------------------------------------------===// +//===-- copy_if.pass.cpp --------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -8,11 +8,17 @@ //===----------------------------------------------------------------------===// // Tests for copy_if and remove_copy_if -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp =================================================================== --- test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp +++ test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_is_partitioned.cpp -------------------------------------------===// +//===-- is_partitioned.pass.cpp -------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,11 +7,17 @@ // //===----------------------------------------------------------------------===// -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.modifying.operations/alg.partitions/partition.pass.cpp =================================================================== --- test/std/algorithms/alg.modifying.operations/alg.partitions/partition.pass.cpp +++ test/std/algorithms/alg.modifying.operations/alg.partitions/partition.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_partition.cpp ------------------------------------------------===// +//===-- partition.pass.cpp ------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -8,11 +8,17 @@ //===----------------------------------------------------------------------===// // Tests for stable_partition and partition -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" #include #include Index: test/std/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp =================================================================== --- test/std/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp +++ test/std/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_partition_copy.cpp -------------------------------------------===// +//===-- partition_copy.pass.cpp -------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -8,11 +8,17 @@ //===----------------------------------------------------------------------===// // Tests for stable_partition and partition_copy -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" #include #include Index: test/std/algorithms/alg.modifying.operations/alg.reverse/reverse.pass.cpp =================================================================== --- test/std/algorithms/alg.modifying.operations/alg.reverse/reverse.pass.cpp +++ test/std/algorithms/alg.modifying.operations/alg.reverse/reverse.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_reverse.cpp --------------------------------------------------===// +//===-- reverse.pass.cpp --------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,13 +7,19 @@ // //===----------------------------------------------------------------------===// -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp =================================================================== --- test/std/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp +++ test/std/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_reverse_copy.cpp ---------------------------------------------===// +//===-- reverse_copy.pass.cpp ---------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,13 +7,19 @@ // //===----------------------------------------------------------------------===// -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.modifying.operations/copy_move.pass.cpp =================================================================== --- test/std/algorithms/alg.modifying.operations/copy_move.pass.cpp +++ test/std/algorithms/alg.modifying.operations/copy_move.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_copy_move.cpp ------------------------------------------------===// +//===-- copy_move.pass.cpp ------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -9,11 +9,17 @@ // Tests for copy, move and copy_n -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.modifying.operations/fill.pass.cpp =================================================================== --- test/std/algorithms/alg.modifying.operations/fill.pass.cpp +++ test/std/algorithms/alg.modifying.operations/fill.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_fill.cpp -----------------------------------------------------===// +//===-- fill.pass.cpp -----------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,11 +7,18 @@ // //===----------------------------------------------------------------------===// -// Tests for fill/fill_n +#include "support/pstl_test_config.h" + +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.modifying.operations/generate.pass.cpp =================================================================== --- test/std/algorithms/alg.modifying.operations/generate.pass.cpp +++ test/std/algorithms/alg.modifying.operations/generate.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_generate.cpp -------------------------------------------------===// +//===-- generate.pass.cpp -------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,12 +7,19 @@ // //===----------------------------------------------------------------------===// -// Tests for generate +#include "support/pstl_test_config.h" + +#ifdef PSTL_STANDALONE_TESTS #include #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.modifying.operations/remove.pass.cpp =================================================================== --- test/std/algorithms/alg.modifying.operations/remove.pass.cpp +++ test/std/algorithms/alg.modifying.operations/remove.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_remove.cpp ---------------------------------------------------===// +//===-- remove.pass.cpp ---------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -8,11 +8,17 @@ //===----------------------------------------------------------------------===// // Test for remove, remove_if -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.modifying.operations/remove_copy.pass.cpp =================================================================== --- test/std/algorithms/alg.modifying.operations/remove_copy.pass.cpp +++ test/std/algorithms/alg.modifying.operations/remove_copy.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_remove_copy.cpp ----------------------------------------------===// +//===-- remove_copy.pass.cpp ----------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,11 +7,18 @@ // //===----------------------------------------------------------------------===// -// Tests for remove_copy +#include "support/pstl_test_config.h" + +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.modifying.operations/replace.pass.cpp =================================================================== --- test/std/algorithms/alg.modifying.operations/replace.pass.cpp +++ test/std/algorithms/alg.modifying.operations/replace.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_replace.cpp --------------------------------------------------===// +//===-- replace.pass.cpp --------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,11 +7,17 @@ // //===----------------------------------------------------------------------===// -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.modifying.operations/replace_copy.pass.cpp =================================================================== --- test/std/algorithms/alg.modifying.operations/replace_copy.pass.cpp +++ test/std/algorithms/alg.modifying.operations/replace_copy.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_replace_copy.cpp ---------------------------------------------===// +//===-- replace_copy.pass.cpp ---------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -9,11 +9,17 @@ // Tests for replace_copy and replace_copy_if -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.modifying.operations/rotate.pass.cpp =================================================================== --- test/std/algorithms/alg.modifying.operations/rotate.pass.cpp +++ test/std/algorithms/alg.modifying.operations/rotate.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_rotate.cpp ---------------------------------------------------===// +//===-- rotate.pass.cpp ---------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,13 +7,19 @@ // //===----------------------------------------------------------------------===// -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.modifying.operations/rotate_copy.pass.cpp =================================================================== --- test/std/algorithms/alg.modifying.operations/rotate_copy.pass.cpp +++ test/std/algorithms/alg.modifying.operations/rotate_copy.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_rotate_copy.cpp ----------------------------------------------===// +//===-- rotate_copy.pass.cpp ----------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,13 +7,19 @@ // //===----------------------------------------------------------------------===// -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.modifying.operations/swap_ranges.pass.cpp =================================================================== --- test/std/algorithms/alg.modifying.operations/swap_ranges.pass.cpp +++ test/std/algorithms/alg.modifying.operations/swap_ranges.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_swap_ranges.cpp ----------------------------------------------===// +//===-- swap_ranges.pass.cpp ----------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,13 +7,19 @@ // //===----------------------------------------------------------------------===// -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.modifying.operations/transform_binary.pass.cpp =================================================================== --- test/std/algorithms/alg.modifying.operations/transform_binary.pass.cpp +++ test/std/algorithms/alg.modifying.operations/transform_binary.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_transform_binary.cpp -----------------------------------------===// +//===-- transform_binary.pass.cpp -----------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,9 +7,17 @@ // //===----------------------------------------------------------------------===// -#include "pstl/execution" +#include "support/pstl_test_config.h" + +#ifdef PSTL_STANDALONE_TESTS #include "pstl/algorithm" -#include "utils.h" +#include "pstl/execution" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.modifying.operations/transform_unary.pass.cpp =================================================================== --- test/std/algorithms/alg.modifying.operations/transform_unary.pass.cpp +++ test/std/algorithms/alg.modifying.operations/transform_unary.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_transform_unary.cpp ------------------------------------------===// +//===-- transform_unary.pass.cpp ------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,9 +7,17 @@ // //===----------------------------------------------------------------------===// -#include "pstl/execution" +#include "support/pstl_test_config.h" + +#ifdef PSTL_STANDALONE_TESTS #include "pstl/algorithm" -#include "utils.h" +#include "pstl/execution" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.modifying.operations/unique.pass.cpp =================================================================== --- test/std/algorithms/alg.modifying.operations/unique.pass.cpp +++ test/std/algorithms/alg.modifying.operations/unique.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_unique.cpp ---------------------------------------------------===// +//===-- unique.pass.cpp ---------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -8,11 +8,17 @@ //===----------------------------------------------------------------------===// // Test for unique -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.modifying.operations/unique_copy_equal.pass.cpp =================================================================== --- test/std/algorithms/alg.modifying.operations/unique_copy_equal.pass.cpp +++ test/std/algorithms/alg.modifying.operations/unique_copy_equal.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_unique_copy_equal.cpp ----------------------------------------===// +//===-- unique_copy_equal.pass.cpp ----------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -8,11 +8,17 @@ //===----------------------------------------------------------------------===// // Tests for unique_copy -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.nonmodifying/adjacent_find.pass.cpp =================================================================== --- test/std/algorithms/alg.nonmodifying/adjacent_find.pass.cpp +++ test/std/algorithms/alg.nonmodifying/adjacent_find.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_adjacent_find.cpp --------------------------------------------===// +//===-- adjacent_find.pass.cpp --------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,11 +7,18 @@ // //===----------------------------------------------------------------------===// -// Tests for adjacent_find +#include "support/pstl_test_config.h" + +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.nonmodifying/all_of.pass.cpp =================================================================== --- test/std/algorithms/alg.nonmodifying/all_of.pass.cpp +++ test/std/algorithms/alg.nonmodifying/all_of.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_all_of.cpp ---------------------------------------------------===// +//===-- all_of.pass.cpp ---------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,11 +7,17 @@ // //===----------------------------------------------------------------------===// -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" /* TODO: consider implementing the following tests for a better code coverage Index: test/std/algorithms/alg.nonmodifying/any_of.pass.cpp =================================================================== --- test/std/algorithms/alg.nonmodifying/any_of.pass.cpp +++ test/std/algorithms/alg.nonmodifying/any_of.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_any_of.cpp ---------------------------------------------------===// +//===-- any_of.pass.cpp ---------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,11 +7,17 @@ // //===----------------------------------------------------------------------===// -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" /* TODO: consider implementing the following tests for a better code coverage Index: test/std/algorithms/alg.nonmodifying/count.pass.cpp =================================================================== --- test/std/algorithms/alg.nonmodifying/count.pass.cpp +++ test/std/algorithms/alg.nonmodifying/count.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_count.cpp ----------------------------------------------------===// +//===-- count.pass.cpp ----------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -8,11 +8,17 @@ //===----------------------------------------------------------------------===// // Tests for count and count_if -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.nonmodifying/equal.pass.cpp =================================================================== --- test/std/algorithms/alg.nonmodifying/equal.pass.cpp +++ test/std/algorithms/alg.nonmodifying/equal.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_equal.cpp ----------------------------------------------------===// +//===-- equal.pass.cpp ----------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,11 +7,17 @@ // //===----------------------------------------------------------------------===// -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.nonmodifying/find.pass.cpp =================================================================== --- test/std/algorithms/alg.nonmodifying/find.pass.cpp +++ test/std/algorithms/alg.nonmodifying/find.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_find.cpp -----------------------------------------------------===// +//===-- find.pass.cpp -----------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -8,11 +8,17 @@ //===----------------------------------------------------------------------===// // Tests for find -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.nonmodifying/find_end.pass.cpp =================================================================== --- test/std/algorithms/alg.nonmodifying/find_end.pass.cpp +++ test/std/algorithms/alg.nonmodifying/find_end.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_find_end.cpp -------------------------------------------------===// +//===-- find_end.pass.cpp -------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,11 +7,17 @@ // //===----------------------------------------------------------------------===// -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.nonmodifying/find_first_of.pass.cpp =================================================================== --- test/std/algorithms/alg.nonmodifying/find_first_of.pass.cpp +++ test/std/algorithms/alg.nonmodifying/find_first_of.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_find_first_of.cpp --------------------------------------------===// +//===-- find_first_of.pass.cpp --------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,11 +7,17 @@ // //===----------------------------------------------------------------------===// -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.nonmodifying/find_if.pass.cpp =================================================================== --- test/std/algorithms/alg.nonmodifying/find_if.pass.cpp +++ test/std/algorithms/alg.nonmodifying/find_if.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_find_if.cpp --------------------------------------------------===// +//===-- find_if.pass.cpp --------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -8,11 +8,17 @@ //===----------------------------------------------------------------------===// // Tests for find_if and find_if_not -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.nonmodifying/for_each.pass.cpp =================================================================== --- test/std/algorithms/alg.nonmodifying/for_each.pass.cpp +++ test/std/algorithms/alg.nonmodifying/for_each.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_for_each.cpp -------------------------------------------------===// +//===-- for_each.pass.cpp -------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,9 +7,17 @@ // //===----------------------------------------------------------------------===// +#include "support/pstl_test_config.h" + +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.nonmodifying/mismatch.pass.cpp =================================================================== --- test/std/algorithms/alg.nonmodifying/mismatch.pass.cpp +++ test/std/algorithms/alg.nonmodifying/mismatch.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_mismatch.cpp -------------------------------------------------===// +//===-- mismatch.pass.cpp -------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,14 +7,21 @@ // //===----------------------------------------------------------------------===// -// Tests for the rest algorithms; temporary approach to check compiling +#include "support/pstl_test_config.h" + +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" #include "pstl/numeric" #include "pstl/memory" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.nonmodifying/none_of.pass.cpp =================================================================== --- test/std/algorithms/alg.nonmodifying/none_of.pass.cpp +++ test/std/algorithms/alg.nonmodifying/none_of.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_none_of.cpp --------------------------------------------------===// +//===-- none_of.pass.cpp --------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,11 +7,17 @@ // //===----------------------------------------------------------------------===// -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" /* TODO: consider implementing the following tests for a better code coverage Index: test/std/algorithms/alg.nonmodifying/nth_element.pass.cpp =================================================================== --- test/std/algorithms/alg.nonmodifying/nth_element.pass.cpp +++ test/std/algorithms/alg.nonmodifying/nth_element.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_nth_element.cpp ----------------------------------------------===// +//===-- nth_element.pass.cpp ----------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,14 +7,20 @@ // //===----------------------------------------------------------------------===// -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include #include #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.nonmodifying/search_n.pass.cpp =================================================================== --- test/std/algorithms/alg.nonmodifying/search_n.pass.cpp +++ test/std/algorithms/alg.nonmodifying/search_n.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_search_n.cpp -------------------------------------------------===// +//===-- search_n.pass.cpp -------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,11 +7,17 @@ // //===----------------------------------------------------------------------===// -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.sorting/alg.heap.operations/is_heap.pass.cpp =================================================================== --- test/std/algorithms/alg.sorting/alg.heap.operations/is_heap.pass.cpp +++ test/std/algorithms/alg.sorting/alg.heap.operations/is_heap.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_is_heap.cpp --------------------------------------------------===// +//===-- is_heap.pass.cpp --------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -8,11 +8,17 @@ //===----------------------------------------------------------------------===// // Tests for is_heap, is_heap_until -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" #include using namespace TestUtils; Index: test/std/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare.pass.cpp =================================================================== --- test/std/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare.pass.cpp +++ test/std/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_lexicographical_compare.cpp ----------------------------------===// +//===-- lexicographical_compare.pass.cpp ----------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,13 +7,19 @@ // //===----------------------------------------------------------------------===// -#include "pstl_test_config.h" -#include +#include "support/pstl_test_config.h" + +#ifdef PSTL_STANDALONE_TESTS #include #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp =================================================================== --- test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp +++ test/std/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_minmax_element.cpp -------------------------------------------===// +//===-- minmax_element.pass.cpp -------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,11 +7,18 @@ // //===----------------------------------------------------------------------===// -// Tests for min_element, max_element, minmax_element +#include "support/pstl_test_config.h" + +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" #include #include Index: test/std/algorithms/alg.sorting/alg.set.operations/includes.pass.cpp =================================================================== --- test/std/algorithms/alg.sorting/alg.set.operations/includes.pass.cpp +++ test/std/algorithms/alg.sorting/alg.set.operations/includes.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_includes.cpp -------------------------------------------------===// +//===-- includes.pass.cpp -------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,13 +7,20 @@ // //===----------------------------------------------------------------------===// -// Tests for partial_sort +#include "support/pstl_test_config.h" + +#ifdef PSTL_STANDALONE_TESTS #include #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.sorting/alg.set.operations/set.pass.cpp =================================================================== --- test/std/algorithms/alg.sorting/alg.set.operations/set.pass.cpp +++ test/std/algorithms/alg.sorting/alg.set.operations/set.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_set.cpp ------------------------------------------------------===// +//===-- set.pass.cpp ------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,14 +7,21 @@ // //===----------------------------------------------------------------------===// -// Tests for partial_sort +#include "support/pstl_test_config.h" + +#ifdef PSTL_STANDALONE_TESTS #include #include #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.sorting/is_sorted.pass.cpp =================================================================== --- test/std/algorithms/alg.sorting/is_sorted.pass.cpp +++ test/std/algorithms/alg.sorting/is_sorted.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_is_sorted.cpp ------------------------------------------------===// +//===-- is_sorted.pass.cpp ------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,11 +7,18 @@ // //===----------------------------------------------------------------------===// -// Tests for is_sorted, is_sorted_until +#include "support/pstl_test_config.h" + +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.sorting/partial_sort.pass.cpp =================================================================== --- test/std/algorithms/alg.sorting/partial_sort.pass.cpp +++ test/std/algorithms/alg.sorting/partial_sort.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_partial_sort.cpp ---------------------------------------------===// +//===-- partial_sort.pass.cpp ---------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,13 +7,20 @@ // //===----------------------------------------------------------------------===// -// Tests for partial_sort +#include "support/pstl_test_config.h" + +#ifdef PSTL_STANDALONE_TESTS #include #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.sorting/partial_sort_copy.pass.cpp =================================================================== --- test/std/algorithms/alg.sorting/partial_sort_copy.pass.cpp +++ test/std/algorithms/alg.sorting/partial_sort_copy.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_partial_sort_copy.cpp ----------------------------------------===// +//===-- partial_sort_copy.pass.cpp ----------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -10,11 +10,17 @@ // Tests for partial_sort_copy #include -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/algorithms/alg.sorting/sort.pass.cpp =================================================================== --- test/std/algorithms/alg.sorting/sort.pass.cpp +++ test/std/algorithms/alg.sorting/sort.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_sort.cpp -----------------------------------------------------===// +//===-- sort.pass.cpp -----------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,11 +7,18 @@ // //===----------------------------------------------------------------------===// -// Tests for sort and stable_sort +#include "support/pstl_test_config.h" + +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; #define _CRT_SECURE_NO_WARNINGS Index: test/std/numerics/numeric.ops/adjacent_difference.pass.cpp =================================================================== --- test/std/numerics/numeric.ops/adjacent_difference.pass.cpp +++ test/std/numerics/numeric.ops/adjacent_difference.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_adjacent_difference.cpp --------------------------------------===// +//===-- adjacent_difference.pass.cpp --------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,14 +7,20 @@ // //===----------------------------------------------------------------------===// -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include #include "pstl/execution" #include "pstl/algorithm" #include "pstl/numeric" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/numerics/numeric.ops/reduce.pass.cpp =================================================================== --- test/std/numerics/numeric.ops/reduce.pass.cpp +++ test/std/numerics/numeric.ops/reduce.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_reduce.cpp ---------------------------------------------------===// +//===-- reduce.pass.cpp ---------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,11 +7,17 @@ // //===----------------------------------------------------------------------===// -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/numeric" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/numerics/numeric.ops/scan.pass.cpp =================================================================== --- test/std/numerics/numeric.ops/scan.pass.cpp +++ test/std/numerics/numeric.ops/scan.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_scan.cpp -----------------------------------------------------===// +//===-- scan.pass.cpp -----------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,10 +7,17 @@ // //===----------------------------------------------------------------------===// +#include "support/pstl_test_config.h" + +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/numeric" -#include "utils.h" -#include "pstl_test_config.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/numerics/numeric.ops/transform_reduce.pass.cpp =================================================================== --- test/std/numerics/numeric.ops/transform_reduce.pass.cpp +++ test/std/numerics/numeric.ops/transform_reduce.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_transform_reduce.cpp -----------------------------------------===// +//===-- transform_reduce.pass.cpp -----------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,11 +7,18 @@ // //===----------------------------------------------------------------------===// -// Tests for inner_product +#include "support/pstl_test_config.h" + +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/numeric" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/numerics/numeric.ops/transform_scan.pass.cpp =================================================================== --- test/std/numerics/numeric.ops/transform_scan.pass.cpp +++ test/std/numerics/numeric.ops/transform_scan.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_transform_scan.cpp -------------------------------------------===// +//===-- transform_scan.pass.cpp -------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,10 +7,17 @@ // //===----------------------------------------------------------------------===// +#include "support/pstl_test_config.h" + +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/numeric" -#include "utils.h" -#include "pstl_test_config.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/utilities/memory/specialized.algorithms/uninitialized_construct.pass.cpp =================================================================== --- test/std/utilities/memory/specialized.algorithms/uninitialized_construct.pass.cpp +++ test/std/utilities/memory/specialized.algorithms/uninitialized_construct.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_uninitialized_construct.cpp ----------------------------------===// +//===-- uninitialized_construct.pass.cpp ----------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -10,11 +10,17 @@ // Tests for uninitialized_default_construct, uninitialized_default_construct_n, // uninitialized_value_construct, uninitialized_value_construct_n -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/memory" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/utilities/memory/specialized.algorithms/uninitialized_copy_move.pass.cpp =================================================================== --- test/std/utilities/memory/specialized.algorithms/uninitialized_copy_move.pass.cpp +++ test/std/utilities/memory/specialized.algorithms/uninitialized_copy_move.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_uninitialized_copy_move.cpp ----------------------------------===// +//===-- uninitialized_copy_move.pass.cpp ----------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -9,11 +9,17 @@ // Tests for uninitialized_copy, uninitialized_copy_n, uninitialized_move, uninitialized_move_n -#include "pstl_test_config.h" +#include "support/pstl_test_config.h" +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/memory" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/std/utilities/memory/specialized.algorithms/uninitialized_fill_destroy.pass.cpp =================================================================== --- test/std/utilities/memory/specialized.algorithms/uninitialized_fill_destroy.pass.cpp +++ test/std/utilities/memory/specialized.algorithms/uninitialized_fill_destroy.pass.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -//===-- test_uninitialized_fill_destroy.cpp -------------------------------===// +//===-- uninitialized_fill_destroy.pass.cpp -------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,12 +7,19 @@ // //===----------------------------------------------------------------------===// -// Tests for the destroy, destroy_n, uninitialized_fill, uninitialized_fill_n algorithms +#include "support/pstl_test_config.h" + +#ifdef PSTL_STANDALONE_TESTS #include "pstl/execution" #include "pstl/memory" #include "pstl/algorithm" -#include "utils.h" +#else +#include +#include +#endif // PSTL_STANDALONE_TESTS + +#include "support/utils.h" using namespace TestUtils; Index: test/utils.h =================================================================== --- /dev/null +++ test/utils.h @@ -1,1247 +0,0 @@ -// -*- C++ -*- -//===-- utils.h -----------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// File contains common utilities that tests rely on - -// Do not #include , because if we do we will not detect accidental dependencies. -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "pstl_test_config.h" - -namespace TestUtils -{ - -typedef double float64_t; -typedef float float32_t; - -template -constexpr size_t -const_size(const T (&array)[N]) noexcept -{ - return N; -} - -template -class Sequence; - -// Handy macros for error reporting -#define EXPECT_TRUE(condition, message) ::TestUtils::expect(true, condition, __FILE__, __LINE__, message) -#define EXPECT_FALSE(condition, message) ::TestUtils::expect(false, condition, __FILE__, __LINE__, message) - -// Check that expected and actual are equal and have the same type. -#define EXPECT_EQ(expected, actual, message) ::TestUtils::expect_equal(expected, actual, __FILE__, __LINE__, message) - -// Check that sequences started with expected and actual and have had size n are equal and have the same type. -#define EXPECT_EQ_N(expected, actual, n, message) \ - ::TestUtils::expect_equal(expected, actual, n, __FILE__, __LINE__, message) - -// Issue error message from outstr, adding a newline. -// Real purpose of this routine is to have a place to hang a breakpoint. -inline void -issue_error_message(std::stringstream& outstr) -{ - outstr << std::endl; - std::cerr << outstr.str(); - std::exit(EXIT_FAILURE); -} - -inline void -expect(bool expected, bool condition, const char* file, int32_t line, const char* message) -{ - if (condition != expected) - { - std::stringstream outstr; - outstr << "error at " << file << ":" << line << " - " << message; - issue_error_message(outstr); - } -} - -// Do not change signature to const T&. -// Function must be able to detect const differences between expected and actual. -template -void -expect_equal(T& expected, T& actual, const char* file, int32_t line, const char* message) -{ - if (!(expected == actual)) - { - std::stringstream outstr; - outstr << "error at " << file << ":" << line << " - " << message << ", expected " << expected << " got " - << actual; - issue_error_message(outstr); - } -} - -template -void -expect_equal(Sequence& expected, Sequence& actual, const char* file, int32_t line, const char* message) -{ - size_t n = expected.size(); - size_t m = actual.size(); - if (n != m) - { - std::stringstream outstr; - outstr << "error at " << file << ":" << line << " - " << message << ", expected sequence of size " << n - << " got sequence of size " << m; - issue_error_message(outstr); - return; - } - size_t error_count = 0; - for (size_t k = 0; k < n && error_count < 10; ++k) - { - if (!(expected[k] == actual[k])) - { - std::stringstream outstr; - outstr << "error at " << file << ":" << line << " - " << message << ", at index " << k << " expected " - << expected[k] << " got " << actual[k]; - issue_error_message(outstr); - ++error_count; - } - } -} - -template -void -expect_equal(Iterator1 expected_first, Iterator2 actual_first, Size n, const char* file, int32_t line, - const char* message) -{ - size_t error_count = 0; - for (size_t k = 0; k < n && error_count < 10; ++k, ++expected_first, ++actual_first) - { - if (!(*expected_first == *actual_first)) - { - std::stringstream outstr; - outstr << "error at " << file << ":" << line << " - " << message << ", at index " << k; - issue_error_message(outstr); - ++error_count; - } - } -} - -// ForwardIterator is like type Iterator, but restricted to be a forward iterator. -// Only the forward iterator signatures that are necessary for tests are present. -// Post-increment in particular is deliberatly omitted since our templates should avoid using it -// because of efficiency considerations. -template -class ForwardIterator -{ - public: - typedef IteratorTag iterator_category; - typedef typename std::iterator_traits::value_type value_type; - typedef typename std::iterator_traits::difference_type difference_type; - typedef typename std::iterator_traits::pointer pointer; - typedef typename std::iterator_traits::reference reference; - - protected: - Iterator my_iterator; - typedef value_type element_type; - - public: - ForwardIterator() = default; - explicit ForwardIterator(Iterator i) : my_iterator(i) {} - reference operator*() const { return *my_iterator; } - Iterator operator->() const { return my_iterator; } - ForwardIterator - operator++() - { - ++my_iterator; - return *this; - } - ForwardIterator operator++(int32_t) - { - auto retval = *this; - my_iterator++; - return retval; - } - friend bool - operator==(const ForwardIterator& i, const ForwardIterator& j) - { - return i.my_iterator == j.my_iterator; - } - friend bool - operator!=(const ForwardIterator& i, const ForwardIterator& j) - { - return i.my_iterator != j.my_iterator; - } - - Iterator - iterator() const - { - return my_iterator; - } -}; - -template -class BidirectionalIterator : public ForwardIterator -{ - typedef ForwardIterator base_type; - - public: - BidirectionalIterator() = default; - explicit BidirectionalIterator(Iterator i) : base_type(i) {} - BidirectionalIterator(const base_type& i) : base_type(i.iterator()) {} - - BidirectionalIterator - operator++() - { - ++base_type::my_iterator; - return *this; - } - BidirectionalIterator - operator--() - { - --base_type::my_iterator; - return *this; - } - BidirectionalIterator operator++(int32_t) - { - auto retval = *this; - base_type::my_iterator++; - return retval; - } - BidirectionalIterator operator--(int32_t) - { - auto retval = *this; - base_type::my_iterator--; - return retval; - } -}; - -template -void -fill_data(Iterator first, Iterator last, F f) -{ - typedef typename std::iterator_traits::value_type T; - for (std::size_t i = 0; first != last; ++first, ++i) - { - *first = T(f(i)); - } -} - -// Sequence is a container of a sequence of T with lots of kinds of iterators. -// Prefixes on begin/end mean: -// c = "const" -// f = "forward" -// No prefix indicates non-const random-access iterator. -template -class Sequence -{ - std::vector m_storage; - - public: - typedef typename std::vector::iterator iterator; - typedef typename std::vector::const_iterator const_iterator; - typedef ForwardIterator forward_iterator; - typedef ForwardIterator const_forward_iterator; - - typedef BidirectionalIterator bidirectional_iterator; - typedef BidirectionalIterator const_bidirectional_iterator; - - typedef T value_type; - explicit Sequence(size_t size) : m_storage(size) {} - - // Construct sequence [f(0), f(1), ... f(size-1)] - // f can rely on its invocations being sequential from 0 to size-1. - template - Sequence(size_t size, Func f) - { - m_storage.reserve(size); - // Use push_back because T might not have a default constructor - for (size_t k = 0; k < size; ++k) - m_storage.push_back(T(f(k))); - } - Sequence(const std::initializer_list& data) : m_storage(data) {} - - const_iterator - begin() const - { - return m_storage.begin(); - } - const_iterator - end() const - { - return m_storage.end(); - } - iterator - begin() - { - return m_storage.begin(); - } - iterator - end() - { - return m_storage.end(); - } - const_iterator - cbegin() const - { - return m_storage.cbegin(); - } - const_iterator - cend() const - { - return m_storage.cend(); - } - forward_iterator - fbegin() - { - return forward_iterator(m_storage.begin()); - } - forward_iterator - fend() - { - return forward_iterator(m_storage.end()); - } - const_forward_iterator - cfbegin() const - { - return const_forward_iterator(m_storage.cbegin()); - } - const_forward_iterator - cfend() const - { - return const_forward_iterator(m_storage.cend()); - } - const_forward_iterator - fbegin() const - { - return const_forward_iterator(m_storage.cbegin()); - } - const_forward_iterator - fend() const - { - return const_forward_iterator(m_storage.cend()); - } - - const_bidirectional_iterator - cbibegin() const - { - return const_bidirectional_iterator(m_storage.cbegin()); - } - const_bidirectional_iterator - cbiend() const - { - return const_bidirectional_iterator(m_storage.cend()); - } - - bidirectional_iterator - bibegin() - { - return bidirectional_iterator(m_storage.begin()); - } - bidirectional_iterator - biend() - { - return bidirectional_iterator(m_storage.end()); - } - - std::size_t - size() const - { - return m_storage.size(); - } - const T* - data() const - { - return m_storage.data(); - } - typename std::vector::reference operator[](size_t j) { return m_storage[j]; } - const T& operator[](size_t j) const { return m_storage[j]; } - - // Fill with given value - void - fill(const T& value) - { - for (size_t i = 0; i < m_storage.size(); i++) - m_storage[i] = value; - } - - void - print() const; - - template - void - fill(Func f) - { - fill_data(m_storage.begin(), m_storage.end(), f); - } -}; - -template -void -Sequence::print() const -{ - std::cout << "size = " << size() << ": { "; - std::copy(begin(), end(), std::ostream_iterator(std::cout, " ")); - std::cout << " } " << std::endl; -} - -// Predicates for algorithms -template -struct is_equal_to -{ - is_equal_to(const DataType& expected) : m_expected(expected) {} - bool - operator()(const DataType& actual) const - { - return actual == m_expected; - } - - private: - DataType m_expected; -}; - -// Low-quality hash function, returns value between 0 and (1<= 8 * sizeof(size_t) ? ~size_t(0) : (size_t(1) << bits) - 1; - return (424157 * i ^ 0x24aFa) & mask; -} - -// Stateful unary op -template -class Complement -{ - int32_t val; - - public: - Complement(T v) : val(v) {} - U - operator()(const T& x) const - { - return U(val - x); - } -}; - -// Tag used to prevent accidental use of converting constructor, even if use is explicit. -struct OddTag -{ -}; - -class Sum; - -// Type with limited set of operations. Not default-constructible. -// Only available operator is "==". -// Typically used as value type in tests. -class Number -{ - int32_t value; - friend class Add; - friend class Sum; - friend class IsMultiple; - friend class Congruent; - friend Sum - operator+(const Sum& x, const Sum& y); - - public: - Number(int32_t val, OddTag) : value(val) {} - friend bool - operator==(const Number& x, const Number& y) - { - return x.value == y.value; - } - friend std::ostream& - operator<<(std::ostream& o, const Number& d) - { - return o << d.value; - } -}; - -// Stateful predicate for Number. Not default-constructible. -class IsMultiple -{ - long modulus; - - public: - // True if x is multiple of modulus - bool - operator()(Number x) const - { - return x.value % modulus == 0; - } - IsMultiple(long modulus_, OddTag) : modulus(modulus_) {} -}; - -// Stateful equivalence-class predicate for Number. Not default-constructible. -class Congruent -{ - long modulus; - - public: - // True if x and y have same remainder for the given modulus. - // Note: this is not quite the same as "equivalent modulo modulus" when x and y have different - // sign, but nonetheless AreCongruent is still an equivalence relationship, which is all - // we need for testing. - bool - operator()(Number x, Number y) const - { - return x.value % modulus == y.value % modulus; - } - Congruent(long modulus_, OddTag) : modulus(modulus_) {} -}; - -// Stateful reduction operation for Number -class Add -{ - long bias; - - public: - explicit Add(OddTag) : bias(1) {} - Number - operator()(Number x, const Number& y) - { - return Number(x.value + y.value + (bias - 1), OddTag()); - } -}; - -// Class similar to Number, but has default constructor and +. -class Sum : public Number -{ - public: - Sum() : Number(0, OddTag()) {} - Sum(long x, OddTag) : Number(x, OddTag()) {} - friend Sum - operator+(const Sum& x, const Sum& y) - { - return Sum(x.value + y.value, OddTag()); - } -}; - -// Type with limited set of operations, which includes an associative but not commutative operation. -// Not default-constructible. -// Typically used as value type in tests involving "GENERALIZED_NONCOMMUTATIVE_SUM". -class MonoidElement -{ - size_t a, b; - - public: - MonoidElement(size_t a_, size_t b_, OddTag) : a(a_), b(b_) {} - friend bool - operator==(const MonoidElement& x, const MonoidElement& y) - { - return x.a == y.a && x.b == y.b; - } - friend std::ostream& - operator<<(std::ostream& o, const MonoidElement& x) - { - return o << "[" << x.a << ".." << x.b << ")"; - } - friend class AssocOp; -}; - -// Stateful associative op for MonoidElement -// It's not really a monoid since the operation is not allowed for any two elements. -// But it's good enough for testing. -class AssocOp -{ - unsigned c; - - public: - explicit AssocOp(OddTag) : c(5) {} - MonoidElement - operator()(const MonoidElement& x, const MonoidElement& y) - { - unsigned d = 5; - EXPECT_EQ(d, c, "state lost"); - EXPECT_EQ(x.b, y.a, "commuted?"); - - return MonoidElement(x.a, y.b, OddTag()); - } -}; - -// Multiplication of matrix is an associative but not commutative operation -// Typically used as value type in tests involving "GENERALIZED_NONCOMMUTATIVE_SUM". -template -struct Matrix2x2 -{ - T a[2][2]; - Matrix2x2() : a{{1, 0}, {0, 1}} {} - Matrix2x2(T x, T y) : a{{0, x}, {x, y}} {} -#if !__PSTL_ICL_19_VC14_VC141_TEST_SCAN_RELEASE_BROKEN - Matrix2x2(const Matrix2x2& m) : a{{m.a[0][0], m.a[0][1]}, {m.a[1][0], m.a[1][1]}} {} - Matrix2x2& - operator=(const Matrix2x2& m) - { - a[0][0] = m.a[0][0], a[0][1] = m.a[0][1], a[1][0] = m.a[1][0], a[1][1] = m.a[1][1]; - return *this; - } -#endif -}; - -template -bool -operator==(const Matrix2x2& left, const Matrix2x2& right) -{ - return left.a[0][0] == right.a[0][0] && left.a[0][1] == right.a[0][1] && left.a[1][0] == right.a[1][0] && - left.a[1][1] == right.a[1][1]; -} - -template -Matrix2x2 -multiply_matrix(const Matrix2x2& left, const Matrix2x2& right) -{ - Matrix2x2 result; - for (int32_t i = 0; i < 2; ++i) - { - for (int32_t j = 0; j < 2; ++j) - { - result.a[i][j] = left.a[i][0] * right.a[0][j] + left.a[i][1] * right.a[1][j]; - } - } - return result; -} - -// Check that Intel(R) Threading Building Blocks header files are not used when parallel policies are off -#if !__PSTL_USE_PAR_POLICIES -#if defined(TBB_INTERFACE_VERSION) -#error The parallel backend is used while it should not (__PSTL_USE_PAR_POLICIES==0) -#endif -#endif - -//============================================================================ -// Adapters for creating different types of iterators. -// -// In this block we implemented some adapters for creating differnet types of iterators. -// It's needed for extending the unit testing of Parallel STL algorithms. -// We have adapters for iterators with different tags (forward_iterator_tag, bidirectional_iterator_tag), reverse iterators. -// The input iterator should be const or non-const, non-reverse random access iterator. -// Iterator creates in "MakeIterator": -// firstly, iterator is "packed" by "IteratorTypeAdapter" (creating forward or bidirectional iterator) -// then iterator is "packed" by "ReverseAdapter" (if it's possible) -// So, from input iterator we may create, for example, reverse bidirectional iterator. -// "Main" functor for testing iterators is named "invoke_on_all_iterator_types". - -// Base adapter -template -struct BaseAdapter -{ - typedef Iterator iterator_type; - iterator_type - operator()(Iterator it) - { - return it; - } -}; - -// Check if the iterator is reverse iterator -// Note: it works only for iterators that created by std::reverse_iterator -template -struct isReverse : std::false_type -{ -}; - -template -struct isReverse> : std::true_type -{ -}; - -// Reverse adapter -template -struct ReverseAdapter -{ - typedef std::reverse_iterator iterator_type; - iterator_type - operator()(Iterator it) - { -#if __PSTL_CPP14_MAKE_REVERSE_ITERATOR_PRESENT - return std::make_reverse_iterator(it); -#else - return iterator_type(it); -#endif - } -}; - -// Non-reverse adapter -template -struct ReverseAdapter : BaseAdapter -{ -}; - -// Iterator adapter by type (by default std::random_access_iterator_tag) -template -struct IteratorTypeAdapter : BaseAdapter -{ -}; - -// Iterator adapter for forward iterator -template -struct IteratorTypeAdapter -{ - typedef ForwardIterator iterator_type; - iterator_type - operator()(Iterator it) - { - return iterator_type(it); - } -}; - -// Iterator adapter for bidirectional iterator -template -struct IteratorTypeAdapter -{ - typedef BidirectionalIterator iterator_type; - iterator_type - operator()(Iterator it) - { - return iterator_type(it); - } -}; - -//For creating iterator with new type -template -struct MakeIterator -{ - typedef IteratorTypeAdapter IterByType; - typedef ReverseAdapter ReverseIter; - - typename ReverseIter::iterator_type - operator()(InputIterator it) - { - return ReverseIter()(IterByType()(it)); - } -}; - -// Useful constant variables -constexpr std::size_t GuardSize = 5; -constexpr std::ptrdiff_t sizeLimit = 1000; - -template // local iterator_traits for non-iterators -struct iterator_traits_ -{ -}; - -template // For iterators -struct iterator_traits_::value, void>::type> -{ - typedef typename Iter::iterator_category iterator_category; -}; - -template // For pointers -struct iterator_traits_ -{ - typedef std::random_access_iterator_tag iterator_category; -}; - -// is iterator Iter has tag Tag -template -using is_same_iterator_category = std::is_same::iterator_category, Tag>; - -// if we run with reverse or const iterators we shouldn't test the large range -template -struct invoke_if_ -{ - template - void - operator()(bool is_allow, Op op, Rest&&... rest) - { - if (is_allow) - op(std::forward(rest)...); - } -}; -template <> -struct invoke_if_ -{ - template - void - operator()(bool is_allow, Op op, Rest&&... rest) - { - op(std::forward(rest)...); - } -}; - -// Base non_const_wrapper struct. It is used to distinguish non_const testcases -// from a regular one. For non_const testcases only compilation is checked. -struct non_const_wrapper -{ -}; - -// Generic wrapper to specify iterator type to execute callable Op on. -// The condition can be either positive(Op is executed only with IteratorTag) -// or negative(Op is executed with every type of iterators except IteratorTag) -template -struct non_const_wrapper_tagged : non_const_wrapper -{ - template - typename std::enable_if::value, void>::type - operator()(Policy&& exec, Iterator iter) - { - Op()(exec, iter); - } - - template - typename std::enable_if::value, - void>::type - operator()(Policy&& exec, InputIterator input_iter, OutputIterator out_iter) - { - Op()(exec, input_iter, out_iter); - } - - template - typename std::enable_if::value, void>::type - operator()(Policy&& exec, Iterator iter) - { - } - - template - typename std::enable_if::value, - void>::type - operator()(Policy&& exec, InputIterator input_iter, OutputIterator out_iter) - { - } -}; - -// These run_for_* structures specify with which types of iterators callable object Op -// should be executed. -template -struct run_for_rnd : non_const_wrapper_tagged -{ -}; - -template -struct run_for_rnd_bi : non_const_wrapper_tagged -{ -}; - -template -struct run_for_rnd_fw : non_const_wrapper_tagged -{ -}; - -// Invoker for different types of iterators. -template -struct iterator_invoker -{ - template - using make_iterator = MakeIterator; - template - using IsConst = typename std::is_const< - typename std::remove_pointer::pointer>::type>::type; - template - using invoke_if = invoke_if_>; - - // A single iterator version which is used for non_const testcases - template - typename std::enable_if::value && - std::is_base_of::value, - void>::type - operator()(Policy&& exec, Op op, Iterator iter) - { - op(std::forward(exec), make_iterator()(iter)); - } - - // A version with 2 iterators which is used for non_const testcases - template - typename std::enable_if::value && - std::is_base_of::value, - void>::type - operator()(Policy&& exec, Op op, InputIterator input_iter, OutputIterator out_iter) - { - op(std::forward(exec), make_iterator()(input_iter), - make_iterator()(out_iter)); - } - - template - typename std::enable_if::value, void>::type - operator()(Policy&& exec, Op op, Iterator begin, Size n, Rest&&... rest) - { - invoke_if()(n <= sizeLimit, op, exec, make_iterator()(begin), n, - std::forward(rest)...); - } - - template - typename std::enable_if::value && - !std::is_base_of::value, - void>::type - operator()(Policy&& exec, Op op, Iterator inputBegin, Iterator inputEnd, Rest&&... rest) - { - invoke_if()(std::distance(inputBegin, inputEnd) <= sizeLimit, op, exec, - make_iterator()(inputBegin), make_iterator()(inputEnd), - std::forward(rest)...); - } - - template - typename std::enable_if::value, - void>::type - operator()(Policy&& exec, Op op, InputIterator inputBegin, InputIterator inputEnd, OutputIterator outputBegin, - Rest&&... rest) - { - invoke_if()(std::distance(inputBegin, inputEnd) <= sizeLimit, op, exec, - make_iterator()(inputBegin), make_iterator()(inputEnd), - make_iterator()(outputBegin), std::forward(rest)...); - } - - template - typename std::enable_if::value, - void>::type - operator()(Policy&& exec, Op op, InputIterator inputBegin, InputIterator inputEnd, OutputIterator outputBegin, - OutputIterator outputEnd, Rest&&... rest) - { - invoke_if()(std::distance(inputBegin, inputEnd) <= sizeLimit, op, exec, - make_iterator()(inputBegin), make_iterator()(inputEnd), - make_iterator()(outputBegin), - make_iterator()(outputEnd), std::forward(rest)...); - } - - template - typename std::enable_if::value, - void>::type - operator()(Policy&& exec, Op op, InputIterator1 inputBegin1, InputIterator1 inputEnd1, InputIterator2 inputBegin2, - InputIterator2 inputEnd2, OutputIterator outputBegin, OutputIterator outputEnd, Rest&&... rest) - { - invoke_if()( - std::distance(inputBegin1, inputEnd1) <= sizeLimit, op, exec, make_iterator()(inputBegin1), - make_iterator()(inputEnd1), make_iterator()(inputBegin2), - make_iterator()(inputEnd2), make_iterator()(outputBegin), - make_iterator()(outputEnd), std::forward(rest)...); - } -}; - -// Invoker for reverse iterators only -// Note: if we run with reverse iterators we shouldn't test the large range -template -struct iterator_invoker -{ - - template - using make_iterator = MakeIterator; - - // A single iterator version which is used for non_const testcases - template - typename std::enable_if::value && - std::is_base_of::value, - void>::type - operator()(Policy&& exec, Op op, Iterator iter) - { - op(std::forward(exec), make_iterator()(iter)); - } - - // A version with 2 iterators which is used for non_const testcases - template - typename std::enable_if::value && - std::is_base_of::value, - void>::type - operator()(Policy&& exec, Op op, InputIterator input_iter, OutputIterator out_iter) - { - op(std::forward(exec), make_iterator()(input_iter), - make_iterator()(out_iter)); - } - - template - typename std::enable_if::value, void>::type - operator()(Policy&& exec, Op op, Iterator begin, Size n, Rest&&... rest) - { - if (n <= sizeLimit) - op(exec, make_iterator()(begin + n), n, std::forward(rest)...); - } - - template - typename std::enable_if::value && - !std::is_base_of::value, - void>::type - operator()(Policy&& exec, Op op, Iterator inputBegin, Iterator inputEnd, Rest&&... rest) - { - if (std::distance(inputBegin, inputEnd) <= sizeLimit) - op(exec, make_iterator()(inputEnd), make_iterator()(inputBegin), - std::forward(rest)...); - } - - template - typename std::enable_if::value, - void>::type - operator()(Policy&& exec, Op op, InputIterator inputBegin, InputIterator inputEnd, OutputIterator outputBegin, - Rest&&... rest) - { - if (std::distance(inputBegin, inputEnd) <= sizeLimit) - op(exec, make_iterator()(inputEnd), make_iterator()(inputBegin), - make_iterator()(outputBegin + (inputEnd - inputBegin)), std::forward(rest)...); - } - - template - typename std::enable_if::value, - void>::type - operator()(Policy&& exec, Op op, InputIterator inputBegin, InputIterator inputEnd, OutputIterator outputBegin, - OutputIterator outputEnd, Rest&&... rest) - { - if (std::distance(inputBegin, inputEnd) <= sizeLimit) - op(exec, make_iterator()(inputEnd), make_iterator()(inputBegin), - make_iterator()(outputEnd), make_iterator()(outputBegin), - std::forward(rest)...); - } - - template - typename std::enable_if::value, - void>::type - operator()(Policy&& exec, Op op, InputIterator1 inputBegin1, InputIterator1 inputEnd1, InputIterator2 inputBegin2, - InputIterator2 inputEnd2, OutputIterator outputBegin, OutputIterator outputEnd, Rest&&... rest) - { - if (std::distance(inputBegin1, inputEnd1) <= sizeLimit) - op(exec, make_iterator()(inputEnd1), make_iterator()(inputBegin1), - make_iterator()(inputEnd2), make_iterator()(inputBegin2), - make_iterator()(outputEnd), make_iterator()(outputBegin), - std::forward(rest)...); - } -}; - -// We can't create reverse iterator from forward iterator -template <> -struct iterator_invoker -{ - template - void - operator()(Rest&&... rest) - { - } -}; - -template -struct reverse_invoker -{ - template - void - operator()(Rest&&... rest) - { - // Random-access iterator - iterator_invoker()(std::forward(rest)...); - - // Forward iterator - iterator_invoker()(std::forward(rest)...); - - // Bidirectional iterator - iterator_invoker()(std::forward(rest)...); - } -}; - -struct invoke_on_all_iterator_types -{ - template - void - operator()(Rest&&... rest) - { - reverse_invoker()(std::forward(rest)...); - reverse_invoker()(std::forward(rest)...); - } -}; -//============================================================================ - -// Invoke op(policy,rest...) for each possible policy. -template -void -invoke_on_all_policies(Op op, T&&... rest) -{ - using namespace __pstl::execution; - - // Try static execution policies - invoke_on_all_iterator_types()(seq, op, std::forward(rest)...); - invoke_on_all_iterator_types()(unseq, op, std::forward(rest)...); -#if __PSTL_USE_PAR_POLICIES - invoke_on_all_iterator_types()(par, op, std::forward(rest)...); - invoke_on_all_iterator_types()(par_unseq, op, std::forward(rest)...); -#endif -} - -template -struct NonConstAdapter -{ - F my_f; - NonConstAdapter(const F& f) : my_f(f) {} - - template - auto - operator()(Types&&... args) -> decltype(std::declval(). - operator()(std::forward(args)...)) - { - return my_f(std::forward(args)...); - } -}; - -template -NonConstAdapter -non_const(const F& f) -{ - return NonConstAdapter(f); -} - -// Wrapper for types. It's need for counting of constructing and destructing objects -template -class Wrapper -{ - public: - Wrapper() - { - my_field = std::shared_ptr(new T()); - ++my_count; - } - Wrapper(const T& input) - { - my_field = std::shared_ptr(new T(input)); - ++my_count; - } - Wrapper(const Wrapper& input) - { - my_field = input.my_field; - ++my_count; - } - Wrapper(Wrapper&& input) - { - my_field = input.my_field; - input.my_field = nullptr; - ++move_count; - } - Wrapper& - operator=(const Wrapper& input) - { - my_field = input.my_field; - return *this; - } - Wrapper& - operator=(Wrapper&& input) - { - my_field = input.my_field; - input.my_field = nullptr; - ++move_count; - return *this; - } - bool - operator==(const Wrapper& input) const - { - return my_field == input.my_field; - } - bool - operator<(const Wrapper& input) const - { - return *my_field < *input.my_field; - } - bool - operator>(const Wrapper& input) const - { - return *my_field > *input.my_field; - } - friend std::ostream& - operator<<(std::ostream& stream, const Wrapper& input) - { - return stream << *(input.my_field); - } - ~Wrapper() - { - --my_count; - if (move_count > 0) - { - --move_count; - } - } - T* - get_my_field() const - { - return my_field.get(); - }; - static size_t - Count() - { - return my_count; - } - static size_t - MoveCount() - { - return move_count; - } - static void - SetCount(const size_t& n) - { - my_count = n; - } - static void - SetMoveCount(const size_t& n) - { - move_count = n; - } - - private: - static std::atomic my_count; - static std::atomic move_count; - std::shared_ptr my_field; -}; - -template -std::atomic Wrapper::my_count = {0}; - -template -std::atomic Wrapper::move_count = {0}; - -template -T -transform_reduce_serial(InputIterator first, InputIterator last, T init, BinaryOperation binary_op, - UnaryOperation unary_op) noexcept -{ - for (; first != last; ++first) - { - init = binary_op(init, unary_op(*first)); - } - return init; -} - -static const char* -done() -{ -#if __PSTL_TEST_SUCCESSFUL_KEYWORD - return "done"; -#else - return "passed"; -#endif -} - -// test_algo_basic_* functions are used to execute -// f on a very basic sequence of elements of type T. - -// Should be used with unary predicate -template -static void -test_algo_basic_single(F&& f) -{ - size_t N = 10; - Sequence in(N, [](size_t v) -> T { return T(v); }); - - invoke_on_all_policies(f, in.begin()); -} - -// Should be used with binary predicate -template -static void -test_algo_basic_double(F&& f) -{ - size_t N = 10; - Sequence in(N, [](size_t v) -> T { return T(v); }); - Sequence out(N, [](size_t v) -> T { return T(v); }); - - invoke_on_all_policies(f, in.begin(), out.begin()); -} - -template -static void -invoke_if(Policy&& p, F f) -{ -#if __PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN - __pstl::internal::invoke_if_not(__pstl::internal::allow_unsequenced(), f); -#else - f(); -#endif -} - -} /* namespace TestUtils */