From 44b0a487f90b61e69238ead0aa0816498a95097d Mon Sep 17 00:00:00 2001 From: Joseph Schuchart Date: Tue, 29 Oct 2024 15:30:42 -0400 Subject: [PATCH] Move around type traits for buffer, scratch, and ptr Signed-off-by: Joseph Schuchart --- ttg/ttg/buffer.h | 20 ++++++++++++++++++++ ttg/ttg/device/task.h | 5 +++-- ttg/ttg/devicescratch.h | 19 +++++++++++++++++++ ttg/ttg/parsec/buffer.h | 3 +-- ttg/ttg/ptr.h | 12 ++++++++++++ ttg/ttg/util/meta.h | 24 ++++-------------------- 6 files changed, 59 insertions(+), 24 deletions(-) diff --git a/ttg/ttg/buffer.h b/ttg/ttg/buffer.h index 3de6bcecd..59a926415 100644 --- a/ttg/ttg/buffer.h +++ b/ttg/ttg/buffer.h @@ -4,12 +4,32 @@ #include #include "ttg/fwd.h" +#include "ttg/util/meta.h" namespace ttg { template>> using Buffer = TTG_IMPL_NS::Buffer; +namespace meta { + + /* Specialize some traits */ + + template + struct is_buffer> : std::true_type + { }; + + template + struct is_buffer> : std::true_type + { }; + + /* buffers are const if their value types are const */ + template + struct is_const> : std::is_const + { }; + +} // namespace meta + } // namespace ttg #endif // TTG_buffer_H \ No newline at end of file diff --git a/ttg/ttg/device/task.h b/ttg/ttg/device/task.h index 09ab93750..e6fe365a1 100644 --- a/ttg/ttg/device/task.h +++ b/ttg/ttg/device/task.h @@ -33,11 +33,12 @@ namespace ttg::device { /* extract buffer information from to_device_t */ template auto extract_buffer_data(detail::to_device_t& a, std::index_sequence) { + using arg_types = std::tuple; return std::array{ device_input_data_t{TTG_IMPL_NS::buffer_data(std::get(a.ties)), std::get(a.ties).scope(), - std::is_const_v>, - ttg::meta::is_devicescratch_v>}...}; + ttg::meta::is_const_v>, + ttg::meta::is_devicescratch_v>}...}; } } // namespace detail diff --git a/ttg/ttg/devicescratch.h b/ttg/ttg/devicescratch.h index 9ccb60bce..e4ed692c9 100644 --- a/ttg/ttg/devicescratch.h +++ b/ttg/ttg/devicescratch.h @@ -3,6 +3,7 @@ #include "ttg/devicescope.h" #include "ttg/fwd.h" +#include "ttg/util/meta.h" namespace ttg { @@ -14,6 +15,24 @@ auto make_scratch(T* val, ttg::scope scope, std::size_t count = 1) { return devicescratch(val, scope, count); } +namespace meta { + + /* Specialize some traits */ + + template + struct is_devicescratch> : std::true_type + { }; + + template + struct is_devicescratch> : std::true_type + { }; + + template + struct is_const> : std::is_const + { }; + +} // namespace meta + } // namespace ttg #endif // TTG_DEVICESCRATCH_H \ No newline at end of file diff --git a/ttg/ttg/parsec/buffer.h b/ttg/ttg/parsec/buffer.h index ba0c2a096..075493078 100644 --- a/ttg/ttg/parsec/buffer.h +++ b/ttg/ttg/parsec/buffer.h @@ -11,6 +11,7 @@ #include "ttg/util/iovec.h" #include "ttg/device/device.h" #include "ttg/parsec/device.h" +#include "ttg/devicescope.h" #if defined(PARSEC_HAVE_DEV_CUDA_SUPPORT) #include @@ -457,8 +458,6 @@ struct Buffer : public detail::ttg_parsec_data_wrapper_t } } #endif // TTG_SERIALIZATION_SUPPORTS_MADNESS - - }; namespace detail { diff --git a/ttg/ttg/ptr.h b/ttg/ttg/ptr.h index c6c92006f..f817a5498 100644 --- a/ttg/ttg/ptr.h +++ b/ttg/ttg/ptr.h @@ -3,6 +3,8 @@ #include "ttg/fwd.h" +#include "ttg/util/meta.h" + namespace ttg { template @@ -18,6 +20,16 @@ inline Ptr> get_ptr(T&& obj) { return TTG_IMPL_NS::get_ptr(std::forward(obj)); } +namespace meta { + + /* specialize some traits */ + + template + struct is_ptr> : std::true_type + { }; + +} // namespace ptr + #if 0 namespace detail { diff --git a/ttg/ttg/util/meta.h b/ttg/ttg/util/meta.h index f3af03152..a7334ce56 100644 --- a/ttg/ttg/util/meta.h +++ b/ttg/ttg/util/meta.h @@ -6,9 +6,6 @@ #include "ttg/util/span.h" #include "ttg/util/typelist.h" -#include "ttg/buffer.h" -#include "ttg/ptr.h" -#include "ttg/devicescratch.h" namespace ttg { @@ -302,25 +299,14 @@ namespace ttg { struct is_ptr : std::false_type { }; - template - struct is_ptr> : std::true_type - { }; - template constexpr bool is_ptr_v = is_ptr::value; + /* specialized by the implementation */ template struct is_buffer : std::false_type { }; - template - struct is_buffer> : std::true_type - { }; - - template - struct is_buffer> : std::true_type - { }; - template constexpr bool is_buffer_v = is_buffer::value; @@ -329,16 +315,14 @@ namespace ttg { { }; template - struct is_devicescratch> : std::true_type - { }; + constexpr bool is_devicescratch_v = is_devicescratch::value; template - struct is_devicescratch> : std::true_type + struct is_const : std::is_const { }; template - constexpr bool is_devicescratch_v = is_devicescratch::value; - + constexpr bool is_const_v = is_const::value; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // typelist metafunctions