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

CTAD workaround nvcc problems with C++20 #1775

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions include/gridtools/common/defs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
*/
#pragma once

#if __has_include(<version>)
#include <version>
#endif

namespace gridtools {
using int_t = int;
using uint_t = unsigned int;
Expand Down Expand Up @@ -58,3 +62,9 @@ namespace gridtools {
#else
#define GT_NVCC_WORKAROUND_1766 0
#endif

#if defined(__cpp_deduction_guides) && __cpp_deduction_guides >= 201907L
#define GT_HAS_AGGREGATE_CTAD 1
#else
#define GT_HAS_AGGREGATE_CTAD 0
#endif
3 changes: 3 additions & 0 deletions include/gridtools/fn/column_stage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ namespace gridtools::fn {
struct scan_pass {
F m_f;
Projector m_p;

#if not GT_HAS_AGGREGATE_CTAD
constexpr GT_FUNCTION scan_pass(F f, Projector p = {}) : m_f(f), m_p(p) {}
#endif
};

template <class T>
Expand Down
4 changes: 1 addition & 3 deletions include/gridtools/sid/simple_ptr_holder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ namespace gridtools {
struct simple_ptr_holder {
T m_val;

#if defined(__cpp_deduction_guides) and __cpp_deduction_guides >= 201907
// CTAD for aggregates works
#else
#if not GT_HAS_AGGREGATE_CTAD
// Enables CTAD in C++17.
simple_ptr_holder() = default;
GT_TARGET GT_FORCE_INLINE constexpr simple_ptr_holder(T const &ptr) : m_val{ptr} {}
Expand Down
6 changes: 3 additions & 3 deletions tests/unit_tests/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ if(TARGET _gridtools_cuda)
LIBRARIES _gridtools_cuda
LABELS cuda)
gridtools_add_unit_test(test_int_vector_cuda
SOURCES test_int_vector.cu
LIBRARIES _gridtools_cuda
LABELS cuda)
SOURCES test_int_vector.cu
LIBRARIES _gridtools_cuda
LABELS cuda)
gridtools_add_unit_test(test_tuple_cuda
SOURCES test_tuple.cu
LIBRARIES _gridtools_cuda
Expand Down
Loading