From e4644fec1acc429a540f358b4e7e15af75aa71a9 Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Mon, 12 Feb 2024 13:09:10 -0500 Subject: ExtensionStructure: first basic test of lookahead task stealing --- include/framework/structure/ExtensionStructure.h | 11 ++++++++++- include/util/types.h | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/framework/structure/ExtensionStructure.h b/include/framework/structure/ExtensionStructure.h index 0e2118e..dbfb543 100644 --- a/include/framework/structure/ExtensionStructure.h +++ b/include/framework/structure/ExtensionStructure.h @@ -275,7 +275,7 @@ public: * */ ReconstructionVector get_reconstruction_tasks(size_t buffer_reccnt, - state_vector scratch_state={}) { + state_vector scratch_state={}) { /* * If no scratch state vector is provided, use a copy of the * current one. The only time an empty vector could be used as @@ -304,6 +304,14 @@ public: */ if (i == 0) { reconstructions = local_recon; + /* + * Quick sanity test of idea: if the next reconstruction + * would be larger than this one, steal the largest + * task from it and run it now instead. + */ + } else if (local_recon.get_total_reccnt() > reconstructions.get_total_reccnt()) { + auto t = local_recon.remove_reconstruction(0); + reconstructions.add_reconstruction(t); } } @@ -312,6 +320,7 @@ public: if (L == LayoutPolicy::TEIRING || scratch_state[0].shardcnt == 0) { scratch_state[0].shardcnt += 1; } + } return std::move(reconstructions); diff --git a/include/util/types.h b/include/util/types.h index e22fd18..bac0246 100644 --- a/include/util/types.h +++ b/include/util/types.h @@ -95,6 +95,10 @@ public: total_reccnt += reccnt; } + void add_reconstruction(ReconstructionTask task) { + m_tasks.push_back(task); + } + ReconstructionTask remove_reconstruction(size_t idx) { assert(idx < m_tasks.size()); auto task = m_tasks[idx]; -- cgit v1.2.3