Skip to content

Commit

Permalink
move free function to an anonymous namespace for specific use case
Browse files Browse the repository at this point in the history
  • Loading branch information
nyoungbq committed Aug 9, 2024
1 parent bd58b47 commit 9c5b726
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename T>
class ComputeArrayStatisticsByIndexImpl
{
Expand Down Expand Up @@ -664,7 +688,7 @@ void FindStatistics(const DataArray<T>& 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;
Expand Down
10 changes: 5 additions & 5 deletions src/simplnx/Utilities/IParallelAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand All @@ -54,7 +51,10 @@ bool detail::CheckArraysInMemory(const nx::core::IParallelAlgorithm::AlgorithmAr

return true;
}
} // namespace

namespace nx::core
{
// -----------------------------------------------------------------------------
IParallelAlgorithm::IParallelAlgorithm()
{
Expand Down Expand Up @@ -83,7 +83,7 @@ void IParallelAlgorithm::setParallelizationEnabled(bool doParallel)
// -----------------------------------------------------------------------------
void IParallelAlgorithm::requireArraysInMemory(const AlgorithmArrays& arrays)
{
setParallelizationEnabled(detail::CheckArraysInMemory(arrays));
setParallelizationEnabled(CheckArraysInMemory(arrays));
}

// -----------------------------------------------------------------------------
Expand Down
5 changes: 0 additions & 5 deletions src/simplnx/Utilities/IParallelAlgorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9c5b726

Please sign in to comment.