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 bugs and improve that about HPX_HAVE_CXX11_AUTO_RETURN_VALUE of CMake. #2821

Merged
merged 6 commits into from Aug 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 26 additions & 13 deletions CMakeLists.txt
Expand Up @@ -7,6 +7,7 @@
# Copyright (c) 2014-2016 Andreas Schaefer
# Copyright (c) 2017 Abhimanyu Rawat
# Copyright (c) 2017 Google
# Copyright (c) 2017 Taeguk Kwon
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand Down Expand Up @@ -1100,27 +1101,39 @@ if(HPX_WITH_CUDA)
endif()
endif()

# Set default for enabling auto-return type workaround to ON for non-clang CUDA
# only
set(HPX_CXX11_AUTO_RETURN_VALUE_VALUE_DEFAULT ON)
if(HPX_WITH_CUDA AND NOT HPX_WITH_CUDA_CLANG)
set(HPX_CXX11_AUTO_RETURN_VALUE_VALUE_DEFAULT OFF)
endif()

hpx_option(HPX_WITH_CXX11_AUTO_RETURN_VALUE BOOL
"Enable the use of auto as a return value in some places. Overriding this flag is only necessary if the C++ compiler is not standard compliant, e.g. nvcc."
${HPX_CXX11_AUTO_RETURN_VALUE_VALUE_DEFAULT} ADVANCED)
if(HPX_WITH_CXX11_AUTO_RETURN_VALUE)
hpx_add_config_define(HPX_HAVE_CXX11_AUTO_RETURN_VALUE)
# Store option value passed by an user for HPX_WITH_CXX14_RETURN_TYPE_DEDUCTION.
if(HPX_WITH_CXX14_RETURN_TYPE_DEDUCTION)
set(HPX_WITH_CXX14_RETURN_TYPE_DEDUCTION_ADVANCED )
set(HPX_WITH_CXX14_RETURN_TYPE_DEDUCTION_GIVEN ON)
else()
set(HPX_WITH_CXX14_RETURN_TYPE_DEDUCTION_ADVANCED ADVANCED)
set(HPX_WITH_CXX14_RETURN_TYPE_DEDUCTION_GIVEN OFF)
endif()

################################################################################
# C++ feature tests
################################################################################

include(HPX_PerformCxxFeatureTests)
hpx_perform_cxx_feature_tests()

# Exceptional handling for non-clang CUDA.
if(HPX_WITH_CXX14_RETURN_TYPE_DEDUCTION)
if(HPX_WITH_CUDA AND NOT HPX_WITH_CUDA_CLANG)
# means using default value (given value).
unset(HPX_WITH_CXX14_RETURN_TYPE_DEDUCTION)
endif()
endif()

# HPX_WITH_CXX14_RETURN_TYPE_DEDUCTION
# Default value is used only when HPX_WITH_CXX14_RETURN_TYPE_DEDUCTION is not defined.
hpx_option(HPX_WITH_CXX14_RETURN_TYPE_DEDUCTION BOOL
"Enable the use of auto as a return value in some places. Overriding this flag is only necessary if the C++ compiler is not standard compliant, e.g. nvcc."
${HPX_WITH_CXX14_RETURN_TYPE_DEDUCTION_GIVEN}
${HPX_WITH_CXX14_RETURN_TYPE_DEDUCTION_ADVANCED})
if(HPX_WITH_CXX14_RETURN_TYPE_DEDUCTION)
hpx_add_config_define(HPX_HAVE_CXX14_RETURN_TYPE_DEDUCTION)
endif()

# HPX_WITH_THREAD_COMPATIBILITY
hpx_option(HPX_WITH_THREAD_COMPATIBILITY BOOL
"Use a compatibility implementation of std::thread, i.e. fall back to Boost.Thread (default: OFF)"
Expand Down
9 changes: 9 additions & 0 deletions cmake/HPX_AddConfigTest.cmake
Expand Up @@ -2,6 +2,7 @@
# Copyright (c) 2014 Thomas Heller
# Copyright (c) 2017 Denis Blank
# Copyright (c) 2017 Google
# Copyright (c) 2017 Taeguk Kwon
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand Down Expand Up @@ -572,6 +573,14 @@ macro(hpx_check_for_cxx14_deprecated_attribute)
FILE ${ARGN})
endmacro()

###############################################################################
macro(hpx_check_for_cxx14_return_type_deduction)
add_hpx_config_test(HPX_WITH_CXX14_RETURN_TYPE_DEDUCTION
SOURCE cmake/tests/cxx14_return_type_deduction.cpp
FILE ${ARGN}
CMAKECXXFEATURE cxx_return_type_deduction)
endmacro()

###############################################################################
macro(hpx_check_for_libfun_std_experimental_optional)
add_hpx_config_test(HPX_WITH_LIBFUN_EXPERIMENTAL_OPTIONAL
Expand Down
3 changes: 3 additions & 0 deletions cmake/HPX_PerformCxxFeatureTests.cmake
@@ -1,6 +1,7 @@
# Copyright (c) 2007-2017 Hartmut Kaiser
# Copyright (c) 2011-2014 Thomas Heller
# Copyright (c) 2013-2016 Agustin Berge
# Copyright (c) 2017 Taeguk Kwon
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand Down Expand Up @@ -162,6 +163,8 @@ macro(hpx_perform_cxx_feature_tests)

hpx_check_for_cxx14_deprecated_attribute(
DEFINITIONS HPX_HAVE_CXX14_DEPRECATED_ATTRIBUTE)

hpx_check_for_cxx14_return_type_deduction()

# check for experimental facilities

Expand Down
30 changes: 30 additions & 0 deletions cmake/tests/cxx14_return_type_deduction.cpp
@@ -0,0 +1,30 @@
////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2017 Taeguk Kwon
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
////////////////////////////////////////////////////////////////////////////////

auto check(int a, int b)
{
int c = a + b;
return c;
}

template <typename T>
auto check2(T num);

template <typename T>
auto check2(T num)
{
return num * num;
}

int main()
{
int a = 10;
int b = 20;
check(a, b);
double c = check2(30.0);
}

16 changes: 8 additions & 8 deletions hpx/parallel/executors/execution_fwd.hpp
Expand Up @@ -73,7 +73,7 @@ namespace hpx { namespace parallel { namespace execution
}
};

#if defined(HPX_HAVE_CXX11_AUTO_RETURN_VALUE)
#if defined(HPX_HAVE_CXX14_RETURN_TYPE_DEDUCTION)
// forward declare customization point implementations
template <>
struct customization_point<post_tag>
Expand Down Expand Up @@ -315,7 +315,7 @@ namespace hpx { namespace parallel { namespace execution

///////////////////////////////////////////////////////////////////////
// async_execute customization point
#if defined(HPX_HAVE_CXX11_AUTO_RETURN_VALUE)
#if defined(HPX_HAVE_CXX14_RETURN_TYPE_DEDUCTION)
template <typename Executor, typename F, typename... Ts>
HPX_FORCEINLINE auto customization_point<async_execute_tag>::
operator()(Executor&& exec, F&& f, Ts&&... ts) const
Expand All @@ -342,7 +342,7 @@ namespace hpx { namespace parallel { namespace execution

///////////////////////////////////////////////////////////////////////
// sync_execute customization point
#if defined(HPX_HAVE_CXX11_AUTO_RETURN_VALUE)
#if defined(HPX_HAVE_CXX14_RETURN_TYPE_DEDUCTION)
template <typename Executor, typename F, typename... Ts>
HPX_FORCEINLINE auto customization_point<sync_execute_tag>::
operator()(Executor&& exec, F&& f, Ts&&... ts) const
Expand All @@ -369,7 +369,7 @@ namespace hpx { namespace parallel { namespace execution

///////////////////////////////////////////////////////////////////////
// then_execute customization point
#if defined(HPX_HAVE_CXX11_AUTO_RETURN_VALUE)
#if defined(HPX_HAVE_CXX14_RETURN_TYPE_DEDUCTION)
template <typename Executor, typename F, typename Future,
typename... Ts>
HPX_FORCEINLINE auto customization_point<then_execute_tag>::
Expand Down Expand Up @@ -402,7 +402,7 @@ namespace hpx { namespace parallel { namespace execution

///////////////////////////////////////////////////////////////////////
// post customization point
#if defined(HPX_HAVE_CXX11_AUTO_RETURN_VALUE)
#if defined(HPX_HAVE_CXX14_RETURN_TYPE_DEDUCTION)
template <typename Executor, typename F, typename... Ts>
HPX_FORCEINLINE auto customization_point<post_tag>::operator()(
Executor&& exec, F&& f, Ts&&... ts) const
Expand All @@ -429,7 +429,7 @@ namespace hpx { namespace parallel { namespace execution

///////////////////////////////////////////////////////////////////////
// bulk_async_execute customization point
#if defined(HPX_HAVE_CXX11_AUTO_RETURN_VALUE)
#if defined(HPX_HAVE_CXX14_RETURN_TYPE_DEDUCTION)
template <typename Executor, typename F, typename Shape,
typename... Ts>
HPX_FORCEINLINE auto customization_point<bulk_async_execute_tag>::
Expand Down Expand Up @@ -459,7 +459,7 @@ namespace hpx { namespace parallel { namespace execution

///////////////////////////////////////////////////////////////////////
// bulk_sync_execute customization point
#if defined(HPX_HAVE_CXX11_AUTO_RETURN_VALUE)
#if defined(HPX_HAVE_CXX14_RETURN_TYPE_DEDUCTION)
template <typename Executor, typename F, typename Shape,
typename... Ts>
HPX_FORCEINLINE auto customization_point<bulk_sync_execute_tag>::
Expand Down Expand Up @@ -489,7 +489,7 @@ namespace hpx { namespace parallel { namespace execution

///////////////////////////////////////////////////////////////////////
// bulk_then_execute customization point
#if defined(HPX_HAVE_CXX11_AUTO_RETURN_VALUE)
#if defined(HPX_HAVE_CXX14_RETURN_TYPE_DEDUCTION)
template <typename Executor, typename F, typename Shape,
typename Future, typename... Ts>
HPX_FORCEINLINE auto customization_point<bulk_then_execute_tag>::
Expand Down
10 changes: 5 additions & 5 deletions hpx/parallel/executors/execution_information_fwd.hpp
Expand Up @@ -30,7 +30,7 @@ namespace hpx { namespace parallel { namespace execution
struct get_pu_mask_tag {};
struct set_scheduler_mode_tag {};

#if defined(HPX_HAVE_CXX11_AUTO_RETURN_VALUE)
#if defined(HPX_HAVE_CXX14_RETURN_TYPE_DEDUCTION)
// forward declare customization point implementations
template <>
struct customization_point<processing_units_count_tag>
Expand Down Expand Up @@ -106,7 +106,7 @@ namespace hpx { namespace parallel { namespace execution
>::call(0, std::forward<Executor>(exec), params);
}

#if defined(HPX_HAVE_CXX11_AUTO_RETURN_VALUE)
#if defined(HPX_HAVE_CXX14_RETURN_TYPE_DEDUCTION)
template <typename Executor, typename Parameters>
HPX_FORCEINLINE auto customization_point<processing_units_count_tag>::
operator()(Executor&& exec, Parameters& params) const
Expand Down Expand Up @@ -145,7 +145,7 @@ namespace hpx { namespace parallel { namespace execution
>::call(0, std::forward<Executor>(exec));
}

#if defined(HPX_HAVE_CXX11_AUTO_RETURN_VALUE)
#if defined(HPX_HAVE_CXX14_RETURN_TYPE_DEDUCTION)
template <typename Executor>
HPX_FORCEINLINE auto customization_point<has_pending_closures_tag>::
operator()(Executor&& exec) const
Expand Down Expand Up @@ -182,7 +182,7 @@ namespace hpx { namespace parallel { namespace execution
>::call(0, std::forward<Executor>(exec), topo, thread_num);
}

#if defined(HPX_HAVE_CXX11_AUTO_RETURN_VALUE)
#if defined(HPX_HAVE_CXX14_RETURN_TYPE_DEDUCTION)
template <typename Executor>
HPX_FORCEINLINE auto customization_point<get_pu_mask_tag>::operator()(
Executor&& exec, threads::topology& topo,
Expand Down Expand Up @@ -221,7 +221,7 @@ namespace hpx { namespace parallel { namespace execution
>::call(0, std::forward<Executor>(exec), mode);
}

#if defined(HPX_HAVE_CXX11_AUTO_RETURN_VALUE)
#if defined(HPX_HAVE_CXX14_RETURN_TYPE_DEDUCTION)
template <typename Executor, typename Mode>
HPX_FORCEINLINE auto customization_point<set_scheduler_mode_tag>::
operator()(Executor&& exec, Mode const& mode) const
Expand Down
14 changes: 7 additions & 7 deletions hpx/parallel/executors/timed_execution_fwd.hpp
Expand Up @@ -97,7 +97,7 @@ namespace hpx { namespace parallel { namespace execution
struct async_execute_at_tag {};
struct async_execute_after_tag {};

#if defined(HPX_HAVE_CXX11_AUTO_RETURN_VALUE)
#if defined(HPX_HAVE_CXX14_RETURN_TYPE_DEDUCTION)
// forward declare customization point implementations
template <>
struct customization_point<post_at_tag>
Expand Down Expand Up @@ -268,7 +268,7 @@ namespace hpx { namespace parallel { namespace execution
std::forward<F>(f), std::forward<Ts>(ts)...);
}

#if defined(HPX_HAVE_CXX11_AUTO_RETURN_VALUE)
#if defined(HPX_HAVE_CXX14_RETURN_TYPE_DEDUCTION)
template <typename Executor, typename F, typename... Ts>
HPX_FORCEINLINE auto customization_point<post_after_tag>::operator()(
Executor&& exec, hpx::util::steady_duration const& rel_time, F&& f,
Expand All @@ -294,7 +294,7 @@ namespace hpx { namespace parallel { namespace execution
};
#endif

#if defined(HPX_HAVE_CXX11_AUTO_RETURN_VALUE)
#if defined(HPX_HAVE_CXX14_RETURN_TYPE_DEDUCTION)
template <typename Executor, typename F, typename... Ts>
HPX_FORCEINLINE auto customization_point<post_at_tag>::operator()(
Executor&& exec, hpx::util::steady_time_point const& abs_time,
Expand All @@ -320,7 +320,7 @@ namespace hpx { namespace parallel { namespace execution
};
#endif

#if defined(HPX_HAVE_CXX11_AUTO_RETURN_VALUE)
#if defined(HPX_HAVE_CXX14_RETURN_TYPE_DEDUCTION)
template <typename Executor, typename F, typename... Ts>
HPX_FORCEINLINE auto customization_point<sync_execute_after_tag>::
operator()(Executor&& exec, hpx::util::steady_duration const& rel_time,
Expand All @@ -346,7 +346,7 @@ namespace hpx { namespace parallel { namespace execution
};
#endif

#if defined(HPX_HAVE_CXX11_AUTO_RETURN_VALUE)
#if defined(HPX_HAVE_CXX14_RETURN_TYPE_DEDUCTION)
template <typename Executor, typename F, typename... Ts>
HPX_FORCEINLINE auto customization_point<sync_execute_at_tag>::
operator()(Executor&& exec,
Expand All @@ -373,7 +373,7 @@ namespace hpx { namespace parallel { namespace execution
};
#endif

#if defined(HPX_HAVE_CXX11_AUTO_RETURN_VALUE)
#if defined(HPX_HAVE_CXX14_RETURN_TYPE_DEDUCTION)
template <typename Executor, typename F, typename... Ts>
HPX_FORCEINLINE auto customization_point<async_execute_at_tag>::
operator()(Executor&& exec,
Expand All @@ -400,7 +400,7 @@ namespace hpx { namespace parallel { namespace execution
};
#endif

#if defined(HPX_HAVE_CXX11_AUTO_RETURN_VALUE)
#if defined(HPX_HAVE_CXX14_RETURN_TYPE_DEDUCTION)
template <typename Executor, typename F, typename... Ts>
HPX_FORCEINLINE auto customization_point<async_execute_after_tag>::
operator()(Executor&& exec, hpx::util::steady_duration const& rel_time,
Expand Down