Only include <atomic> if needed.

This commit is contained in:
Rasmus Munk Larsen 2021-12-02 23:55:25 +00:00
parent 4ee2e9b340
commit 3ffefcb95c
2 changed files with 6 additions and 7 deletions

View File

@ -67,6 +67,7 @@
#endif
#ifdef EIGEN_HAS_OPENMP
#include <atomic>
#include <omp.h>
#endif

View File

@ -10,8 +10,6 @@
#ifndef EIGEN_PARALLELIZER_H
#define EIGEN_PARALLELIZER_H
#include <atomic>
#include "../InternalHeaderCheck.h"
namespace Eigen {
@ -78,14 +76,14 @@ namespace internal {
template<typename Index> struct GemmParallelInfo
{
GemmParallelInfo() : sync(-1), users(0), lhs_start(0), lhs_length(0) {}
// volatile is not enough on all architectures (see bug 1572)
// to guarantee that when thread A says to thread B that it is
// done with packing a block, then all writes have been really
// carried out... C++11 memory model+atomic guarantees this.
#ifdef EIGEN_HAS_OPENMP
GemmParallelInfo() : sync(-1), users(0), lhs_start(0), lhs_length(0) {}
std::atomic<Index> sync;
std::atomic<int> users;
#else
GemmParallelInfo() : lhs_start(0), lhs_length(0) {}
#endif
Index lhs_start;
Index lhs_length;