From 8c66b4b66bf2d5c0a4115f2684003de85d12cedb Mon Sep 17 00:00:00 2001 From: Alejandro Saucedo Date: Sat, 17 Oct 2020 12:31:20 +0100 Subject: [PATCH] Added evalOpAwaitDefault and evalOpAsyncDefault --- single_include/kompute/Kompute.hpp | 58 +++++++++++++++++++++--------- src/include/kompute/Manager.hpp | 58 +++++++++++++++++++++--------- 2 files changed, 82 insertions(+), 34 deletions(-) diff --git a/single_include/kompute/Kompute.hpp b/single_include/kompute/Kompute.hpp index 382b8332d..bd7b3a125 100755 --- a/single_include/kompute/Kompute.hpp +++ b/single_include/kompute/Kompute.hpp @@ -1318,8 +1318,7 @@ class Manager uint32_t queueIndex = 0); /** - * Operation that adds extra operations to existing or new created - * sequences. + * Function that evaluates operation against named sequence. * * @param tensors The tensors to be used in the operation recorded * @param sequenceName The name of the sequence to be retrieved or created @@ -1352,8 +1351,23 @@ class Manager } /** - * Operation that adds extra operations to existing or new created - * sequences. + * Function that evaluates operation against default sequence. + * + * @param tensors The tensors to be used in the operation recorded + * @param TArgs Template parameters that will be used to initialise + * Operation to allow for extensible configurations on initialisation + */ + template + void evalOpDefault(std::vector> tensors, + TArgs&&... params) + { + SPDLOG_DEBUG("Kompute Manager evalOp Default triggered"); + this->evalOp( + tensors, KP_DEFAULT_SESSION, std::forward(params)...); + } + + /** + * Function that evaluates operation against named sequence asynchronously. * * @param tensors The tensors to be used in the operation recorded * @param sequenceName The name of the sequence to be retrieved or created @@ -1394,16 +1408,30 @@ class Manager } /** - * Operation that adds extra operations to existing or new created - * sequences. + * Operation that evaluates operation against default sequence asynchronously. + * + * @param tensors The tensors to be used in the operation recorded + * @param params Template parameters that will be used to initialise + * Operation to allow for extensible configurations on initialisation + */ + template + void evalOpAsyncDefault(std::vector> tensors, + TArgs&&... params) + { + SPDLOG_DEBUG("Kompute Manager evalOpAsyncDefault triggered"); + this->evalOpAsync( + tensors, KP_DEFAULT_SESSION, std::forward(params)...); + } + + /** + * Operation that awaits for named sequence to finish. * * @param sequenceName The name of the sequence to wait for termination * @param waitFor The amount of time to wait before timing out */ - template void evalOpAwait(std::string sequenceName, uint64_t waitFor = UINT64_MAX) { - SPDLOG_DEBUG("Kompute Manager evalOpAwait triggered"); + SPDLOG_DEBUG("Kompute Manager evalOpAwait triggered with sequence {}", sequenceName); std::unordered_map>::iterator found = this->mManagedSequences.find(sequenceName); @@ -1423,20 +1451,16 @@ class Manager } /** - * Operation that adds extra operations to existing or new created - * sequences. + * Operation that awaits for default sequence to finish. * * @param tensors The tensors to be used in the operation recorded - * @param TArgs Template parameters that will be used to initialise + * @param params Template parameters that will be used to initialise * Operation to allow for extensible configurations on initialisation */ - template - void evalOpDefault(std::vector> tensors, - TArgs&&... params) + void evalOpAwaitDefault(uint64_t waitFor = UINT64_MAX) { - SPDLOG_DEBUG("Kompute Manager evalOp Default triggered"); - this->evalOp( - tensors, KP_DEFAULT_SESSION, std::forward(params)...); + SPDLOG_DEBUG("Kompute Manager evalOpAwaitDefault triggered"); + this->evalOpAwait(KP_DEFAULT_SESSION, waitFor); } /** diff --git a/src/include/kompute/Manager.hpp b/src/include/kompute/Manager.hpp index 650da5ca0..969af9ac5 100644 --- a/src/include/kompute/Manager.hpp +++ b/src/include/kompute/Manager.hpp @@ -80,8 +80,7 @@ class Manager uint32_t queueIndex = 0); /** - * Operation that adds extra operations to existing or new created - * sequences. + * Function that evaluates operation against named sequence. * * @param tensors The tensors to be used in the operation recorded * @param sequenceName The name of the sequence to be retrieved or created @@ -114,8 +113,23 @@ class Manager } /** - * Operation that adds extra operations to existing or new created - * sequences. + * Function that evaluates operation against default sequence. + * + * @param tensors The tensors to be used in the operation recorded + * @param TArgs Template parameters that will be used to initialise + * Operation to allow for extensible configurations on initialisation + */ + template + void evalOpDefault(std::vector> tensors, + TArgs&&... params) + { + SPDLOG_DEBUG("Kompute Manager evalOp Default triggered"); + this->evalOp( + tensors, KP_DEFAULT_SESSION, std::forward(params)...); + } + + /** + * Function that evaluates operation against named sequence asynchronously. * * @param tensors The tensors to be used in the operation recorded * @param sequenceName The name of the sequence to be retrieved or created @@ -156,16 +170,30 @@ class Manager } /** - * Operation that adds extra operations to existing or new created - * sequences. + * Operation that evaluates operation against default sequence asynchronously. + * + * @param tensors The tensors to be used in the operation recorded + * @param params Template parameters that will be used to initialise + * Operation to allow for extensible configurations on initialisation + */ + template + void evalOpAsyncDefault(std::vector> tensors, + TArgs&&... params) + { + SPDLOG_DEBUG("Kompute Manager evalOpAsyncDefault triggered"); + this->evalOpAsync( + tensors, KP_DEFAULT_SESSION, std::forward(params)...); + } + + /** + * Operation that awaits for named sequence to finish. * * @param sequenceName The name of the sequence to wait for termination * @param waitFor The amount of time to wait before timing out */ - template void evalOpAwait(std::string sequenceName, uint64_t waitFor = UINT64_MAX) { - SPDLOG_DEBUG("Kompute Manager evalOpAwait triggered"); + SPDLOG_DEBUG("Kompute Manager evalOpAwait triggered with sequence {}", sequenceName); std::unordered_map>::iterator found = this->mManagedSequences.find(sequenceName); @@ -185,20 +213,16 @@ class Manager } /** - * Operation that adds extra operations to existing or new created - * sequences. + * Operation that awaits for default sequence to finish. * * @param tensors The tensors to be used in the operation recorded - * @param TArgs Template parameters that will be used to initialise + * @param params Template parameters that will be used to initialise * Operation to allow for extensible configurations on initialisation */ - template - void evalOpDefault(std::vector> tensors, - TArgs&&... params) + void evalOpAwaitDefault(uint64_t waitFor = UINT64_MAX) { - SPDLOG_DEBUG("Kompute Manager evalOp Default triggered"); - this->evalOp( - tensors, KP_DEFAULT_SESSION, std::forward(params)...); + SPDLOG_DEBUG("Kompute Manager evalOpAwaitDefault triggered"); + this->evalOpAwait(KP_DEFAULT_SESSION, waitFor); } /**