Skip to content

Commit db71fad

Browse files
Change internal storage to quiet msvc warning
1 parent ee12228 commit db71fad

File tree

3 files changed

+18
-31
lines changed

3 files changed

+18
-31
lines changed

Framework/Crystal/inc/MantidCrystal/ConnectedComponentLabeling.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ class MANTID_CRYSTAL_DLL ConnectedComponentLabeling {
6969
virtual ~ConnectedComponentLabeling();
7070

7171
private:
72-
/// Get the number of threads to use.
73-
int getNThreads() const;
74-
7572
/// Calculate the disjoint element tree across the image.
7673
ConnectedComponentMappingTypes::ClusterMap calculateDisjointTree(const Mantid::API::IMDHistoWorkspace_sptr &ws,
7774
BackgroundStrategy *const baseStrategy,
@@ -81,7 +78,7 @@ class MANTID_CRYSTAL_DLL ConnectedComponentLabeling {
8178
size_t m_startId;
8279

8380
/// Run multithreaded
84-
const std::optional<int> m_nThreads;
81+
int m_nThreadsToUse;
8582
};
8683

8784
} // namespace Crystal

Framework/Crystal/src/ConnectedComponentLabeling.cpp

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,15 @@ void memoryCheck(size_t nPoints) {
213213
* @param nThreads : Optional argument of number of threads to use.
214214
*/
215215
ConnectedComponentLabeling::ConnectedComponentLabeling(const size_t &startId, std::optional<int> nThreads)
216-
: m_startId(startId), m_nThreads(std::move(nThreads)) {
217-
if (m_nThreads.has_value() && m_nThreads.value() < 0) {
218-
throw std::invalid_argument("Cannot request that CCL runs with less than one thread!");
216+
: m_startId(startId) {
217+
if (nThreads.has_value()) {
218+
if (nThreads.value() < 0) {
219+
throw std::invalid_argument("Cannot request that CCL runs with less than one thread!");
220+
} else {
221+
m_nThreadsToUse = nThreads.value(); // Follow explicit instructions if provided.
222+
}
223+
} else {
224+
m_nThreadsToUse = API::FrameworkManager::Instance().getNumOMPThreads(); // Figure it out.
219225
}
220226
}
221227

@@ -237,18 +243,6 @@ size_t ConnectedComponentLabeling::getStartLabelId() const { return m_startId; }
237243
*/
238244
ConnectedComponentLabeling::~ConnectedComponentLabeling() = default;
239245

240-
/**
241-
* Get the number of threads available
242-
* @return : Number of available threads
243-
*/
244-
int ConnectedComponentLabeling::getNThreads() const {
245-
if (m_nThreads.has_value()) {
246-
return m_nThreads.value(); // Follow explicit instructions if provided.
247-
} else {
248-
return API::FrameworkManager::Instance().getNumOMPThreads(); // Figure it out.
249-
}
250-
}
251-
252246
/**
253247
* Perform the work of the CCL algorithm
254248
* - Pre filtering of background
@@ -273,20 +267,18 @@ ClusterMap ConnectedComponentLabeling::calculateDisjointTree(const IMDHistoWorks
273267

274268
// For each process maintains pair of index from within process bounds to
275269
// index outside process bounds
276-
const int nThreadsToUse = getNThreads();
277-
278-
if (nThreadsToUse > 1) {
279-
auto iterators = ws->createIterators(nThreadsToUse);
280-
const size_t maxClustersPossible = calculateMaxClusters(ws.get(), nThreadsToUse);
270+
if (m_nThreadsToUse > 1) {
271+
auto iterators = ws->createIterators(m_nThreadsToUse);
272+
const size_t maxClustersPossible = calculateMaxClusters(ws.get(), m_nThreadsToUse);
281273

282-
std::vector<VecEdgeIndexPair> parallelEdgeVec(nThreadsToUse);
274+
std::vector<VecEdgeIndexPair> parallelEdgeVec(m_nThreadsToUse);
283275

284-
std::vector<std::map<size_t, std::shared_ptr<Cluster>>> parallelClusterMapVec(nThreadsToUse);
276+
std::vector<std::map<size_t, std::shared_ptr<Cluster>>> parallelClusterMapVec(m_nThreadsToUse);
285277

286278
// ------------- Stage One. Local CCL in parallel.
287279
g_log.debug("Parallel solve local CCL");
288280
// PARALLEL_FOR_NO_WSP_CHECK()
289-
for (int i = 0; i < nThreadsToUse; ++i) {
281+
for (int i = 0; i < m_nThreadsToUse; ++i) {
290282
API::IMDIterator *iterator = iterators[i].get();
291283
boost::scoped_ptr<BackgroundStrategy> strategy(baseStrategy->clone()); // local strategy
292284
VecEdgeIndexPair &edgeVec = parallelEdgeVec[i]; // local edge indexes
@@ -334,8 +326,8 @@ ClusterMap ConnectedComponentLabeling::calculateDisjointTree(const IMDHistoWorks
334326

335327
for (auto &indexPairVec : parallelEdgeVec) {
336328
for (auto &iit : indexPairVec) {
337-
DisjointElement &a = neighbourElements[iit.get<0>()];
338-
DisjointElement &b = neighbourElements[iit.get<1>()];
329+
const DisjointElement &a = neighbourElements[iit.get<0>()];
330+
const DisjointElement &b = neighbourElements[iit.get<1>()];
339331
clusterRegister.merge(a, b);
340332
}
341333
}

buildconfig/CMake/CppCheck_Suppressions.txt.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,6 @@ constParameterPointer:${CMAKE_SOURCE_DIR}/Framework/API/src/MultiPeriodGroupWork
436436
constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/API/src/MultiPeriodGroupWorker.cpp:191
437437
constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/API/src/MultiPeriodGroupWorker.cpp:261
438438
constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/API/src/MultiPeriodGroupWorker.cpp:268
439-
constVariableReference:${CMAKE_SOURCE_DIR}/Framework/Crystal/src/ConnectedComponentLabeling.cpp:337
440-
constVariableReference:${CMAKE_SOURCE_DIR}/Framework/Crystal/src/ConnectedComponentLabeling.cpp:338
441439
constVariableReference:${CMAKE_SOURCE_DIR}/Framework/Crystal/src/CalculateUMatrix.cpp:65
442440
constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/API/src/WorkspaceGroup.cpp:78
443441
constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/API/src/WorkspaceGroup.cpp:437

0 commit comments

Comments
 (0)