MPQC
3.0.0-alpha
omp.hpp
1
#ifndef MPQC_OMP_HPP
2
#define MPQC_OMP_HPP
3
4
#ifdef _OPENMP
5
#include <omp.h>
6
#endif // _OPENMP
7
8
namespace
mpqc
{
9
namespace
omp {
10
11
inline
bool
master() {
12
int
master =
false
;
13
#pragma omp master
14
master =
true
;
15
return
master;
16
}
17
18
inline
int
max_threads() {
19
#ifndef _OPENMP
20
return
1;
21
#else
22
return
omp_get_max_threads();
23
#endif
24
};
25
26
template
<
typename
T>
27
struct
task
: boost::noncopyable {
28
task
() : value_() {}
29
T operator++(
int
) {
30
T v;
31
#pragma omp critical(mpqc_omp_task)
32
v = value_++;
33
return
v;
34
}
35
private
:
36
T value_;
37
};
38
39
struct
mutex
: boost::noncopyable {
40
#ifndef _OPENMP
41
mutex
() {}
42
void
lock() {}
43
void
unlock() {}
44
#else // _OPENMP
45
mutex
() {
46
omp_init_lock(&lock_);
47
}
48
void
lock() {
49
omp_set_lock(&lock_);
50
}
51
void
unlock() {
52
omp_unset_lock(&lock_);
53
}
54
private
:
55
omp_lock_t lock_;
56
#endif // _OPENMP
57
};
58
59
}
60
}
61
62
#endif
/* MPQC_OMP_HPP */
mpqc
Contains new MPQC code since version 3.
Definition:
integralenginepool.hpp:37
mpqc::omp::task
Definition:
omp.hpp:27
mpqc::omp::mutex
Definition:
omp.hpp:39
Generated at Sun Jan 26 2020 23:24:01 for
MPQC
3.0.0-alpha using the documentation package
Doxygen
1.8.16.