From a0d3bbdd239ead42ef54b1ee57751aeb20933e54 Mon Sep 17 00:00:00 2001 From: Tom Benson Date: Tue, 8 Aug 2023 17:15:33 -0400 Subject: [PATCH] Fix a subtle parameter expansion issue in sync info (#155) It's mildly unfortunate that the function for recording the event on a SyncInfo is called "AddSynchronizationPoint". Thus we need an explicit `if constexpr` to stop the recursion such that the event record is actually avoided when we don't need it. C'est la vie. --- include/hydrogen/SynchronizeAPI.hpp | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/include/hydrogen/SynchronizeAPI.hpp b/include/hydrogen/SynchronizeAPI.hpp index ce3192558..b9261018c 100644 --- a/include/hydrogen/SynchronizeAPI.hpp +++ b/include/hydrogen/SynchronizeAPI.hpp @@ -20,38 +20,19 @@ void AddSynchronizationPoint(SyncInfo const &master, // synchronization points. Skip "other" call recursively with the rest. if (master.Stream() == other.Stream()) { - AddSynchronizationPoint(master, others...); + if constexpr (sizeof...(others) > 0UL) + AddSynchronizationPoint(master, others...); return; } } #endif // HYDROGEN_HAVE_GPU AddSynchronizationPoint(master); - int dummy[] = {(details::AddSyncPoint(master, other), - details::AddSyncPoint(master, others), 0)...}; + int dummy[] = {(details::AddSyncPoint(master, other), 0), + (details::AddSyncPoint(master, others), 0)...}; (void)dummy; } -// Specialization of the above function for two arguments -template -void AddSynchronizationPoint(SyncInfo const &master, - SyncInfo const &other) -{ -#ifdef HYDROGEN_HAVE_GPU - if constexpr (D == Device::GPU && D == D2) - { - // When the two streams are the same, there is no need to create - // synchronization points. - if (master.Stream() == other.Stream()) - { - return; - } - } -#endif // HYDROGEN_HAVE_GPU - - AddSynchronizationPoint(master); -} - template void AllWaitOnMaster(SyncInfo const &master, SyncInfo const &...others) {