Replace omp atomic with std variant

This commit is contained in:
Patrick Niklaus 2014-05-20 23:58:32 +02:00
parent da1fd96d4e
commit 56d93eb18b
2 changed files with 4 additions and 6 deletions

View File

@ -38,6 +38,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <algorithm> #include <algorithm>
#include <limits> #include <limits>
#include <vector> #include <vector>
#include <atomic>
template <typename EdgeDataT> class DynamicGraph template <typename EdgeDataT> class DynamicGraph
{ {
@ -198,7 +199,6 @@ template <typename EdgeDataT> class DynamicGraph
void DeleteEdge(const NodeIterator source, const EdgeIterator e) void DeleteEdge(const NodeIterator source, const EdgeIterator e)
{ {
Node &node = m_nodes[source]; Node &node = m_nodes[source];
#pragma omp atomic
--m_numEdges; --m_numEdges;
--node.edges; --node.edges;
BOOST_ASSERT(std::numeric_limits<unsigned>::max() != node.edges); BOOST_ASSERT(std::numeric_limits<unsigned>::max() != node.edges);
@ -226,7 +226,6 @@ template <typename EdgeDataT> class DynamicGraph
} }
} }
#pragma omp atomic
m_numEdges -= deleted; m_numEdges -= deleted;
m_nodes[source].edges -= deleted; m_nodes[source].edges -= deleted;
@ -272,7 +271,7 @@ template <typename EdgeDataT> class DynamicGraph
}; };
NodeIterator m_numNodes; NodeIterator m_numNodes;
EdgeIterator m_numEdges; std::atomic_uint m_numEdges;
std::vector<Node> m_nodes; std::vector<Node> m_nodes;
DeallocatingVector<Edge> m_edges; DeallocatingVector<Edge> m_edges;

View File

@ -30,6 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../Util/OpenMPWrapper.h" #include "../Util/OpenMPWrapper.h"
#include <iostream> #include <iostream>
#include <atomic>
class Percent class Percent
{ {
@ -61,20 +62,18 @@ class Percent
void printIncrement() void printIncrement()
{ {
#pragma omp atomic
++m_current_value; ++m_current_value;
printStatus(m_current_value); printStatus(m_current_value);
} }
void printAddition(const unsigned addition) void printAddition(const unsigned addition)
{ {
#pragma omp atomic
m_current_value += addition; m_current_value += addition;
printStatus(m_current_value); printStatus(m_current_value);
} }
private: private:
unsigned m_current_value; std::atomic_uint m_current_value;
unsigned m_max_value; unsigned m_max_value;
unsigned m_percent_interval; unsigned m_percent_interval;
unsigned m_next_threshold; unsigned m_next_threshold;