From c89a4a07ef4b4c9accdd9cce1c3d86b07d3d0f76 Mon Sep 17 00:00:00 2001 From: Joseph Schuchart Date: Thu, 2 Jun 2022 17:02:53 -0400 Subject: [PATCH 1/3] Make sure that a writer is deferred even if it is the first consumer Signed-off-by: Joseph Schuchart --- ttg/ttg/parsec/ttg.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ttg/ttg/parsec/ttg.h b/ttg/ttg/parsec/ttg.h index 4f2ed6928..e97866089 100644 --- a/ttg/ttg/parsec/ttg.h +++ b/ttg/ttg/parsec/ttg.h @@ -836,7 +836,7 @@ namespace ttg_parsec { * (current task) or there are others, in which we case won't * touch it. */ - if (1 == copy_in->num_readers()) { + if (1 == copy_in->num_readers() && !task->defer_writer) { /** * no other readers, mark copy as mutable and defer the release * of the task @@ -846,11 +846,11 @@ namespace ttg_parsec { assert(nullptr != task); copy_in->push_task = &task->parsec_task; } else { - if (task->defer_writer && !copy_res->is_mutable()) { + if (task->defer_writer && nullptr == copy_in->push_task) { /* we're the first writer and want to wait for all readers to complete */ copy_res->push_task = &task->parsec_task; } else { - /* there are readers of this copy already, make a copy that we can mutate */ + /* there are writers and/or waiting already of this copy already, make a copy that we can mutate */ copy_res = NULL; } } From 253895fdde27d62f23886625cfb1a7bc2bbf5e78 Mon Sep 17 00:00:00 2001 From: Joseph Schuchart Date: Thu, 2 Jun 2022 17:04:00 -0400 Subject: [PATCH 2/3] Swap testing order to enable constness detection This is a hack and needs reconsideration. We probably need a more elaborate way... Signed-off-by: Joseph Schuchart --- ttg/ttg/util/meta/callable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ttg/ttg/util/meta/callable.h b/ttg/ttg/util/meta/callable.h index daced54fc..098c1b104 100644 --- a/ttg/ttg/util/meta/callable.h +++ b/ttg/ttg/util/meta/callable.h @@ -102,7 +102,7 @@ namespace ttg::meta { template struct candidate_argument_bindings && !std::is_void_v>> { using type = std::conditional_t, typelist, - typelist>; }; From 04893eefae0c70c37b079adef39247875f866969 Mon Sep 17 00:00:00 2001 From: Joseph Schuchart Date: Mon, 12 Sep 2022 14:17:26 -0400 Subject: [PATCH 3/3] Callable Test for T&& before const T& and extend tests The tests now check both what the task function sees and what the TT sees. It is important to make sure that the TT correctly sees const arguments. Signed-off-by: Joseph Schuchart --- tests/unit/tt.cc | 38 ++++++++++++++++++++++++++++++++++++ ttg/ttg/madness/ttg.h | 2 ++ ttg/ttg/util/meta/callable.h | 2 +- 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/tests/unit/tt.cc b/tests/unit/tt.cc index b91d6582f..fe03a60fa 100644 --- a/tests/unit/tt.cc +++ b/tests/unit/tt.cc @@ -303,6 +303,32 @@ TEST_CASE("TemplateTask", "[core]") { static_assert(std::is_const_v>, "Const datum expected"); }, ttg::edges(in), ttg::edges())); + { + auto tt = ttg::make_tt( + [](const int &key, const auto &datum, auto &outs) { + static_assert(std::is_lvalue_reference_v, "Lvalue datum expected"); + static_assert(std::is_const_v>, "Const datum expected"); + }, + ttg::edges(in), ttg::edges()); + using tt_t = typename std::remove_reference_t; + static_assert(std::is_const_v>); + } + CHECK_NOTHROW(ttg::make_tt( + [](const int &key, auto &&datum, auto &outs) { + static_assert(std::is_rvalue_reference_v, "Rvalue datum expected"); + static_assert(!std::is_const_v>, "Nonconst datum expected"); + }, + ttg::edges(in), ttg::edges())); + { + auto tt = ttg::make_tt( + [](const int &key, auto &&datum, auto &outs) { + static_assert(std::is_rvalue_reference_v, "Rvalue datum expected"); + static_assert(!std::is_const_v>, "Nonconst datum expected"); + }, + ttg::edges(in), ttg::edges()); + using tt_t = typename std::remove_reference_t; + static_assert(!std::is_const_v>); + } // and without an output terminal CHECK_NOTHROW(ttg::make_tt( @@ -312,6 +338,18 @@ TEST_CASE("TemplateTask", "[core]") { ttg::send(0, std::decay_t{}, std::decay_t{}); }, ttg::edges(in), ttg::edges())); + { + auto tt = ttg::make_tt( + [](const int &key, auto &datum) { + static_assert(std::is_lvalue_reference_v, "Lvalue datum expected"); + static_assert(std::is_const_v>, "Const datum expected"); + ttg::send(0, std::decay_t{}, std::decay_t{}); + }, + ttg::edges(in), ttg::edges()); + using tt_t = typename std::remove_reference_t; + static_assert(std::is_const_v>); + } + } } diff --git a/ttg/ttg/madness/ttg.h b/ttg/ttg/madness/ttg.h index d90bda0a4..315befbc5 100644 --- a/ttg/ttg/madness/ttg.h +++ b/ttg/ttg/madness/ttg.h @@ -228,6 +228,8 @@ namespace ttg_madness { using input_refs_full_tuple_type = ttg::meta::add_glvalue_reference_tuple_t>; + using input_args_type = actual_input_tuple_type; + using input_values_tuple_type = ttg::meta::drop_void_t>; using input_refs_tuple_type = ttg::meta::drop_void_t>; static_assert(!ttg::meta::is_any_void_v); diff --git a/ttg/ttg/util/meta/callable.h b/ttg/ttg/util/meta/callable.h index f63f4c63c..94fc3c91f 100644 --- a/ttg/ttg/util/meta/callable.h +++ b/ttg/ttg/util/meta/callable.h @@ -150,7 +150,7 @@ namespace ttg::meta { template struct candidate_argument_bindings && !std::is_void_v>> { using type = std::conditional_t, typelist, - typelist>; };