1#ifndef MPQC_MPI_TASK_HPP
2#define MPQC_MPI_TASK_HPP
5#include "mpqc/utility/mutex.hpp"
13#if (defined HAVE_MPI) && !(defined HAVE_ARMCI)
14#error mpqc::MPI::Task requires ARMCI if using MPI
22 struct Task : boost::noncopyable {
29 : comm_(comm), data_(0)
32 MPQC_ASSERT(comm == MPI_COMM_WORLD);
34 data_.resize(comm_.size());
35 ARMCI_Malloc(&data_[0],
sizeof(T));
44 ARMCI_Free(data_[comm_.rank()]);
49 void reset(
const T &value = T(0)) {
50 mutex::global::lock();
53 if (comm_.rank() == 0) {
54 ARMCI_PutValueInt(value, this->value(), 0);
61 mutex::global::unlock();
67 mutex::global::lock();
69 ARMCI_Rmw(ARMCI_FETCH_AND_ADD, &
next, this->value(), 1, 0);
73 mutex::global::unlock();
79 int i = block*((*this)++);
83 template<
typename Iterator>
84 Iterator
next(Iterator begin, Iterator end) {
87 for (
int i = 0; i < n; ++i) {
98 std::vector< void* > data_;
Contains new MPQC code since version 3.
Definition integralenginepool.hpp:37
MPI_Comm object wrapper/stub.
Definition comm.hpp:14
Distributed task.
Definition task.hpp:22
Task(const MPI::Comm &comm)
Construct new task.
Definition task.hpp:28
void reset(const T &value=T(0))
Reset task.
Definition task.hpp:49
mpqc::range next(range r, int block=1)
Get next task range.
Definition task.hpp:78
~Task()
Destructor.
Definition task.hpp:42
T operator++(int)
Get next task.
Definition task.hpp:65