From 9c5b72697ecfe556b974807d0a30e9f5ceb157f9 Mon Sep 17 00:00:00 2001 From: nyoungbq Date: Fri, 26 Jul 2024 09:18:31 -0400 Subject: [PATCH] move free function to an anonymous namespace for specific use case --- .../Algorithms/ComputeArrayStatistics.cpp | 26 ++++++++++++++++++- src/simplnx/Utilities/IParallelAlgorithm.cpp | 10 +++---- src/simplnx/Utilities/IParallelAlgorithm.hpp | 5 ---- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayStatistics.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayStatistics.cpp index 6b803fece6..09875f9fea 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayStatistics.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayStatistics.cpp @@ -12,6 +12,30 @@ using namespace nx::core; namespace { +// ----------------------------------------------------------------------------- +bool CheckArraysInMemory(const nx::core::IParallelAlgorithm::AlgorithmArrays& arrays) +{ + if(arrays.empty()) + { + return true; + } + + for(const auto* arrayPtr : arrays) + { + if(arrayPtr == nullptr) + { + continue; + } + + if(!arrayPtr->getIDataStoreRef().getDataFormat().empty()) + { + return false; + } + } + + return true; +} + template class ComputeArrayStatisticsByIndexImpl { @@ -664,7 +688,7 @@ void FindStatistics(const DataArray& source, const Int32Array* featureIds, co indexAlgArrays.push_back(mostPopulatedBinPtr); #ifdef SIMPLNX_ENABLE_MULTICORE - if(detail::CheckArraysInMemory(indexAlgArrays)) + if(CheckArraysInMemory(indexAlgArrays)) { const tbb::simple_partitioner simplePartitioner; const size_t grainSize = 500; diff --git a/src/simplnx/Utilities/IParallelAlgorithm.cpp b/src/simplnx/Utilities/IParallelAlgorithm.cpp index c3358fb063..dc04752a06 100644 --- a/src/simplnx/Utilities/IParallelAlgorithm.cpp +++ b/src/simplnx/Utilities/IParallelAlgorithm.cpp @@ -27,12 +27,9 @@ bool CheckStoresInMemory(const nx::core::IParallelAlgorithm::AlgorithmStores& st return true; } -} // namespace -namespace nx::core -{ // ----------------------------------------------------------------------------- -bool detail::CheckArraysInMemory(const nx::core::IParallelAlgorithm::AlgorithmArrays& arrays) +bool CheckArraysInMemory(const nx::core::IParallelAlgorithm::AlgorithmArrays& arrays) { if(arrays.empty()) { @@ -54,7 +51,10 @@ bool detail::CheckArraysInMemory(const nx::core::IParallelAlgorithm::AlgorithmAr return true; } +} // namespace +namespace nx::core +{ // ----------------------------------------------------------------------------- IParallelAlgorithm::IParallelAlgorithm() { @@ -83,7 +83,7 @@ void IParallelAlgorithm::setParallelizationEnabled(bool doParallel) // ----------------------------------------------------------------------------- void IParallelAlgorithm::requireArraysInMemory(const AlgorithmArrays& arrays) { - setParallelizationEnabled(detail::CheckArraysInMemory(arrays)); + setParallelizationEnabled(CheckArraysInMemory(arrays)); } // ----------------------------------------------------------------------------- diff --git a/src/simplnx/Utilities/IParallelAlgorithm.hpp b/src/simplnx/Utilities/IParallelAlgorithm.hpp index 07ab720b82..1ec99a1dde 100644 --- a/src/simplnx/Utilities/IParallelAlgorithm.hpp +++ b/src/simplnx/Utilities/IParallelAlgorithm.hpp @@ -47,9 +47,4 @@ class SIMPLNX_EXPORT IParallelAlgorithm bool m_RunParallel = false; #endif }; - -namespace detail -{ -bool CheckArraysInMemory(const nx::core::IParallelAlgorithm::AlgorithmArrays& arrays); -} } // namespace nx::core