diff --git a/Code/Mantid/Algorithms/src/UnaryOperation.cpp b/Code/Mantid/Algorithms/src/UnaryOperation.cpp index 3a0d64fdf5876887016c7c781fd1e74c89ec0e77..1e219d8c6d3f009cfa6033f14dd3bc96c00e131e 100644 --- a/Code/Mantid/Algorithms/src/UnaryOperation.cpp +++ b/Code/Mantid/Algorithms/src/UnaryOperation.cpp @@ -52,8 +52,10 @@ namespace Mantid Progress progress(this,0.0,1.0,numSpec); // Loop over every cell in the workspace, calling the abstract correction function + PARALLEL_FOR2(in_work,out_work) for (int i = 0; i < numSpec; ++i) { + PARALLEL_START_INTERUPT_REGION // Copy the X values over out_work->setX(i,in_work->refX(i)); // Get references to the data @@ -72,8 +74,9 @@ namespace Mantid } progress.report(); + PARALLEL_END_INTERUPT_REGION } - + PARALLEL_CHECK_INTERUPT_REGION return; } diff --git a/Code/Mantid/Geometry/src/Instrument/ParameterMap.cpp b/Code/Mantid/Geometry/src/Instrument/ParameterMap.cpp index 8616ee545ad3adb487c3ce44e359f3dd761a83f6..65ab8b2366bf5649fc369893e464aaa4e43d894f 100644 --- a/Code/Mantid/Geometry/src/Instrument/ParameterMap.cpp +++ b/Code/Mantid/Geometry/src/Instrument/ParameterMap.cpp @@ -246,14 +246,7 @@ void ParameterMap::setCachedLocation(const IComponent* comp, V3D& location) cons /// @returns true if the location is in the map, otherwise false bool ParameterMap::getCachedLocation(const IComponent* comp, V3D& location) const { - bool result; - // Call to getCachedLocation is a needs to be marked as the same critical region as a - // write to the cache - PARALLEL_CRITICAL(positionCache) - { - result = m_cacheLocMap.getCache(comp->getComponentID(),location); - } - return result; + return m_cacheLocMap.getCache(comp->getComponentID(),location); } ///Sets a cached rotation on the rotation cache @@ -274,14 +267,7 @@ void ParameterMap::setCachedRotation(const IComponent* comp, Quat& rotation) con /// @returns true if the rotation is in the map, otherwise false bool ParameterMap::getCachedRotation(const IComponent* comp, Quat& rotation) const { - bool result; - // Call to getCachedRotation is a needs to be marked as the same critical region as a - // write to the cache - PARALLEL_CRITICAL(rotationCache) - { - result = m_cacheRotMap.getCache(comp->getComponentID(),rotation); - } - return result; + return m_cacheRotMap.getCache(comp->getComponentID(),rotation); } diff --git a/Code/Mantid/Kernel/inc/MantidKernel/Cache.h b/Code/Mantid/Kernel/inc/MantidKernel/Cache.h index 608c9bcedf2ed78567301999304a9020144b4e75..e4dca99b5e89b1738d4ff0f8c577021465916cd2 100644 --- a/Code/Mantid/Kernel/inc/MantidKernel/Cache.h +++ b/Code/Mantid/Kernel/inc/MantidKernel/Cache.h @@ -6,6 +6,8 @@ //---------------------------------------------------------------------- #include <map> #include "MantidKernel/System.h" +#include "MantidKernel/MultiThreaded.h" + namespace Mantid { namespace Kernel @@ -74,46 +76,39 @@ namespace Mantid } ///Sets a cached value on the rotation cache - void setCache(const KEYTYPE key, VALUETYPE value) + void setCache(const KEYTYPE& key, const VALUETYPE& value) { - if (getCacheNoStats(key,value)) - { - //remove key - removeCache(key); - } - m_cacheMap.insert(std::make_pair(key,value)); + m_cacheMap[key] = value; } ///Attempts to retreive a value from the cache - bool getCache(const KEYTYPE key, VALUETYPE& value) const + bool getCache(const KEYTYPE& key, VALUETYPE& value) const { bool found = getCacheNoStats(key,value); if (found) { + PARALLEL_ATOMIC m_cacheHit++; } else { + PARALLEL_ATOMIC m_cacheMiss++; } return found; } ///removes the value associated with a key - void removeCache(const KEYTYPE key) + void removeCache(const KEYTYPE& key) { - CacheMapIterator it_found = m_cacheMap.find(key); - if (it_found != m_cacheMap.end()) - { - m_cacheMap.erase(it_found); - } + m_cacheMap.erase(key); } private: ///Attempts to retreive a value from the cache bool getCacheNoStats(const KEYTYPE key, VALUETYPE& value) const { - CacheMapConstIterator it_found = m_cacheMap.find(key); + CacheMapConstIterator it_found = m_cacheMap.find(key); if (it_found == m_cacheMap.end()) { return false; // did not find the component