Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix C++20 macro in parallel_for_each + fix concepts macro definition #1611

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
13 changes: 7 additions & 6 deletions include/oneapi/tbb/detail/_config.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2005-2024 Intel Corporation
Copyright (c) 2005-2025 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -233,10 +233,8 @@
#if __INTEL_COMPILER && (!_MSC_VER || __INTEL_CXX11_MOVE__)
#define __TBB_CPP14_VARIABLE_TEMPLATES_PRESENT (__TBB_LANG >= 201402L)
#define __TBB_CPP17_DEDUCTION_GUIDES_PRESENT (__INTEL_COMPILER > 2021 && __TBB_LANG >= 201703L)
#define __TBB_CPP20_CONCEPTS_PRESENT 0 // TODO: add a mechanism for future addition
#elif __clang__
#define __TBB_CPP14_VARIABLE_TEMPLATES_PRESENT (__has_feature(cxx_variable_templates))
#define __TBB_CPP20_CONCEPTS_PRESENT 0 // TODO: add a mechanism for future addition
#ifdef __cpp_deduction_guides
#define __TBB_CPP17_DEDUCTION_GUIDES_PRESENT (__cpp_deduction_guides >= 201611L)
#else
Expand All @@ -245,15 +243,12 @@
#elif __GNUC__
#define __TBB_CPP14_VARIABLE_TEMPLATES_PRESENT (__TBB_LANG >= 201402L && __TBB_GCC_VERSION >= 50000)
#define __TBB_CPP17_DEDUCTION_GUIDES_PRESENT (__cpp_deduction_guides >= 201606L)
#define __TBB_CPP20_CONCEPTS_PRESENT (__TBB_LANG >= 201709L && __TBB_GCC_VERSION >= 100201)
#elif _MSC_VER
#define __TBB_CPP14_VARIABLE_TEMPLATES_PRESENT (_MSC_FULL_VER >= 190023918 && (!__INTEL_COMPILER || __INTEL_COMPILER >= 1700))
#define __TBB_CPP17_DEDUCTION_GUIDES_PRESENT (_MSC_VER >= 1914 && __TBB_LANG >= 201703L && (!__INTEL_COMPILER || __INTEL_COMPILER > 2021))
#define __TBB_CPP20_CONCEPTS_PRESENT (_MSC_VER >= 1923 && __TBB_LANG >= 202002L) // TODO: INTEL_COMPILER?
#else
#define __TBB_CPP14_VARIABLE_TEMPLATES_PRESENT (__TBB_LANG >= 201402L)
#define __TBB_CPP17_DEDUCTION_GUIDES_PRESENT (__TBB_LANG >= 201703L)
#define __TBB_CPP20_CONCEPTS_PRESENT (__TBB_LANG >= 202002L)
#endif

// GCC4.8 on RHEL7 does not support std::get_new_handler
Expand All @@ -268,6 +263,12 @@
#define __TBB_CPP17_ALLOCATOR_IS_ALWAYS_EQUAL_PRESENT (__TBB_LANG >= 201703L)
#define __TBB_CPP17_IS_SWAPPABLE_PRESENT (__TBB_LANG >= 201703L)

#if defined(__cpp_concepts) && defined(__cpp_lib_concepts)
#define __TBB_CPP20_CONCEPTS_PRESENT ((__cpp_concepts >= 201907L) && (__cpp_lib_concepts >= 202002L))
#else
#define __TBB_CPP20_CONCEPTS_PRESENT 0
#endif

#if defined(__cpp_impl_three_way_comparison) && defined(__cpp_lib_three_way_comparison)
#define __TBB_CPP20_COMPARISONS_PRESENT ((__cpp_impl_three_way_comparison >= 201907L) && (__cpp_lib_three_way_comparison >= 201907L))
#else
Expand Down
6 changes: 3 additions & 3 deletions include/oneapi/tbb/flow_graph.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2005-2024 Intel Corporation
Copyright (c) 2005-2025 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -85,7 +85,7 @@ class continue_msg {};
} // namespace d2

#if __TBB_CPP20_CONCEPTS_PRESENT
namespace d0 {
inline namespace d0 {

template <typename ReturnType, typename OutputType>
concept node_body_return_type = std::same_as<OutputType, tbb::detail::d2::continue_msg> ||
Expand Down Expand Up @@ -127,7 +127,7 @@ template <typename Body, typename Input, typename GatewayType>
concept async_node_body = std::copy_constructible<Body> &&
std::invocable<Body&, const Input&, GatewayType&>;

} // namespace d0
} // inline namespace d0
#endif // __TBB_CPP20_CONCEPTS_PRESENT

namespace d2 {
Expand Down
6 changes: 3 additions & 3 deletions include/oneapi/tbb/parallel_for_each.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2005-2024 Intel Corporation
Copyright (c) 2005-2025 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -409,7 +409,7 @@ class parallel_for_body_wrapper {
template<typename It>
using tag = typename std::iterator_traits<It>::iterator_category;

#if __TBB_CPP20_PRESENT
#if __TBB_CPP20_CONCEPTS_PRESENT
template <typename It>
struct move_iterator_dispatch_helper {
using type = It;
Expand Down Expand Up @@ -448,7 +448,7 @@ using iterator_tag_dispatch = typename
std::input_iterator_tag
>::type
>::type;
#endif // __TBB_CPP20_PRESENT
#endif // __TBB_CPP20_CONCEPTS_PRESENT

template <typename Body, typename Iterator, typename Item>
using feeder_is_required = tbb::detail::void_t<decltype(tbb::detail::invoke(std::declval<const Body>(),
Expand Down
4 changes: 2 additions & 2 deletions include/oneapi/tbb/parallel_scan.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2005-2024 Intel Corporation
Copyright (c) 2005-2025 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -52,7 +52,7 @@ struct sum_node;

#if __TBB_CPP20_CONCEPTS_PRESENT
} // namespace d1
namespace d0 {
inline namespace d0 {

template <typename Body, typename Range>
concept parallel_scan_body = splittable<Body> &&
Expand Down
4 changes: 2 additions & 2 deletions test/common/concepts_common.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2021 Intel Corporation
Copyright (c) 2021-2025 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -385,7 +385,7 @@ struct ParallelScanFunction {
T operator()( Dummy, const T& a, bool ) const requires (EnableFunctionCallOperator == State::incorrect_first_input) { return a; }
T operator()( const Range&, Dummy, bool ) const requires (EnableFunctionCallOperator == State::incorrect_second_input) { return T{}; }
T operator()( const Range&, const T& a, Dummy ) const requires (EnableFunctionCallOperator == State::incorrect_third_input) { return a; }
Dummy operator()( const Range&, const T& a, bool ) const requires (EnableFunctionCallOperator == State::incorrect_return_type) { return Dummy{}; }
Dummy operator()( const Range&, const T&, bool ) const requires (EnableFunctionCallOperator == State::incorrect_return_type) { return Dummy{}; }
};

template <typename R, typename T> using Correct = ParallelScanFunction<R, T, /*() = */State::correct>;
Expand Down
Loading