Re: [PATCH] Integrate non-TBB serial backend support
Tested x86_64-linux, committed to trunk. Thomas Rodgers writes: > * include/bits/c++config: Adjust TBB detection logic to select serial > PSTL backend if no TBB present. > * testsuite/utils/pstl/test_utils.h: Remove check for > __PSTL_USE_PAR_POLICIES > --- > libstdc++-v3/include/bits/c++config | 8 ++-- > libstdc++-v3/testsuite/util/pstl/test_utils.h | 40 +++ > 2 files changed, 19 insertions(+), 29 deletions(-) > > diff --git a/libstdc++-v3/include/bits/c++config > b/libstdc++-v3/include/bits/c++config > index 4b8574bf433..746e35efbfc 100644 > --- a/libstdc++-v3/include/bits/c++config > +++ b/libstdc++-v3/include/bits/c++config > @@ -656,9 +656,7 @@ namespace std > > #if __cplusplus >= 201703L > // Preserved here so we have some idea which version of upstream we've > pulled in > -// #define PSTL_VERSION 104 > -// #define PSTL_VERSION_MAJOR (PSTL_VERSION/100) > -// #define PSTL_VERSION_MINOR (PSTL_VERSION - PSTL_VERSION_MAJOR * 100) > +// #define PSTL_VERSION 9000 > > // For now this defaults to being based on the presence of Thread Building > Blocks > # ifndef _GLIBCXX_USE_TBB_PAR_BACKEND > @@ -666,7 +664,9 @@ namespace std > # endif > // This section will need some rework when a new (default) backend type is > added > # if _GLIBCXX_USE_TBB_PAR_BACKEND > -# define _PSTL_USE_PAR_POLICIES 1 > +# define _PSTL_PAR_BACKEND_TBB > +# else > +# define _PSTL_PAR_BACKEND_SERIAL > # endif > > # define _PSTL_ASSERT(_Condition) __glibcxx_assert(_Condition) > diff --git a/libstdc++-v3/testsuite/util/pstl/test_utils.h > b/libstdc++-v3/testsuite/util/pstl/test_utils.h > index 9d16fa566e2..6547d931c29 100644 > --- a/libstdc++-v3/testsuite/util/pstl/test_utils.h > +++ b/libstdc++-v3/testsuite/util/pstl/test_utils.h > @@ -10,14 +10,15 @@ > // 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 > #include > -#include > +#include > +#include > > #include "pstl_test_config.h" > > @@ -38,32 +39,30 @@ template > class Sequence; > > // Handy macros for error reporting > -#define EXPECT_TRUE(condition, message) TestUtils::expect(condition, > __FILE__, __LINE__, message) > -#define EXPECT_FALSE(condition, message) TestUtils::expect(condition, > __FILE__, __LINE__, message) > +#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) > +#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) > +::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. > -static void > +inline void > issue_error_message(std::stringstream& outstr) > { > outstr << std::endl; > std::cerr << outstr.str(); > +std::exit(EXIT_FAILURE); > } > > -template > -void > -expect(bool condition, const char* file, int32_t line, const char* message) > +inline void > +expect(bool expected, bool condition, const char* file, int32_t line, const > char* message) > { > -// Templating this function is somewhat silly, but avoids the need to > declare it static > -// or have a separate translation unit. > -if (condition != B) > +if (condition != expected) > { > std::stringstream outstr; > outstr << "error at " << file << ":" << line << " - " << message; > @@ -607,13 +606,6 @@ multiply_matrix(const Matrix2x2& left, const > Matrix2x2& right) > 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. > // > @@ -1052,10 +1044,8 @@ invoke_on_all_policies(Op op, T&&... rest) > // Try static
Re: [PATCH] Integrate non-TBB serial backend support
On 04/06/19 15:47 -0700, Thomas Rodgers wrote: * include/bits/c++config: Adjust TBB detection logic to select serial PSTL backend if no TBB present. * testsuite/utils/pstl/test_utils.h: Remove check for __PSTL_USE_PAR_POLICIES The changelog says __PSTL_USE_PAR_POLICIES with two leading underscores, but the macro is _PSTL_USE_PAR_POLICIES with one. OK for trunk with the changelog corrected, thanks.
[PATCH] Integrate non-TBB serial backend support
* include/bits/c++config: Adjust TBB detection logic to select serial PSTL backend if no TBB present. * testsuite/utils/pstl/test_utils.h: Remove check for __PSTL_USE_PAR_POLICIES --- libstdc++-v3/include/bits/c++config | 8 ++-- libstdc++-v3/testsuite/util/pstl/test_utils.h | 40 +++ 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config index 4b8574bf433..746e35efbfc 100644 --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -656,9 +656,7 @@ namespace std #if __cplusplus >= 201703L // Preserved here so we have some idea which version of upstream we've pulled in -// #define PSTL_VERSION 104 -// #define PSTL_VERSION_MAJOR (PSTL_VERSION/100) -// #define PSTL_VERSION_MINOR (PSTL_VERSION - PSTL_VERSION_MAJOR * 100) +// #define PSTL_VERSION 9000 // For now this defaults to being based on the presence of Thread Building Blocks # ifndef _GLIBCXX_USE_TBB_PAR_BACKEND @@ -666,7 +664,9 @@ namespace std # endif // This section will need some rework when a new (default) backend type is added # if _GLIBCXX_USE_TBB_PAR_BACKEND -# define _PSTL_USE_PAR_POLICIES 1 +# define _PSTL_PAR_BACKEND_TBB +# else +# define _PSTL_PAR_BACKEND_SERIAL # endif # define _PSTL_ASSERT(_Condition) __glibcxx_assert(_Condition) diff --git a/libstdc++-v3/testsuite/util/pstl/test_utils.h b/libstdc++-v3/testsuite/util/pstl/test_utils.h index 9d16fa566e2..6547d931c29 100644 --- a/libstdc++-v3/testsuite/util/pstl/test_utils.h +++ b/libstdc++-v3/testsuite/util/pstl/test_utils.h @@ -10,14 +10,15 @@ // 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 #include -#include +#include +#include #include "pstl_test_config.h" @@ -38,32 +39,30 @@ template class Sequence; // Handy macros for error reporting -#define EXPECT_TRUE(condition, message) TestUtils::expect(condition, __FILE__, __LINE__, message) -#define EXPECT_FALSE(condition, message) TestUtils::expect(condition, __FILE__, __LINE__, message) +#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) +#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) +::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. -static void +inline void issue_error_message(std::stringstream& outstr) { outstr << std::endl; std::cerr << outstr.str(); +std::exit(EXIT_FAILURE); } -template -void -expect(bool condition, const char* file, int32_t line, const char* message) +inline void +expect(bool expected, bool condition, const char* file, int32_t line, const char* message) { -// Templating this function is somewhat silly, but avoids the need to declare it static -// or have a separate translation unit. -if (condition != B) +if (condition != expected) { std::stringstream outstr; outstr << "error at " << file << ":" << line << " - " << message; @@ -607,13 +606,6 @@ multiply_matrix(const Matrix2x2& left, const Matrix2x2& right) 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. // @@ -1052,10 +1044,8 @@ invoke_on_all_policies(Op op, T&&... rest) // 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 }