36 #ifndef MADNESS_WORLD_WORLDTASK_H__INCLUDED
37 #define MADNESS_WORLD_WORLDTASK_H__INCLUDED
63 template <
typename ptrT,
typename memfnT,
typename resT>
71 template <
typename refT,
typename functionT>
83 : ref(ref), func(func),attr(attr) {}
90 template <
typename Archive>
92 serialize_internal<functionT>(ar);
100 template <
typename fnT>
102 static const bool value =
112 template <
typename fnT,
typename Archive>
114 serialize_internal(
const Archive& ar) {
122 template <
typename fnT,
typename Archive>
123 typename disable_if<is_func_ptr<fnT> >::type
124 serialize_internal(
const Archive& ar) {
125 ar & ref & func &
attr;
129 template <
typename fnT>
132 function_traits<fnT>::value || has_result_type<fnT>::value,
133 task_result_type<fnT> >
136 template <
typename memfnT>
139 std::is_member_function_pointer<memfnT>,
140 task_result_type<memfnT> >
143 template <
typename T>
148 template <
typename T>
153 template <
typename ptrT,
typename memfnT,
typename resT>
154 class MemFuncWrapper {
159 friend memfnT get_mem_func_ptr<ptrT, memfnT, resT>(
const MemFuncWrapper<ptrT, memfnT, resT>&);
169 ptr_(other.ptr_), memfn_(other.memfn_)
173 ptr_(ptr), memfn_(memfn)
176 MemFuncWrapper_&
operator=(
const MemFuncWrapper_& other) {
178 memfn_ = other.memfn_;
183 MADNESS_ASSERT(ptr_);
184 return ((*ptr_).*memfn_)();
187 template <
typename a1T>
189 MADNESS_ASSERT(ptr_);
190 return ((*ptr_).*memfn_)(
a1);
193 template <
typename a1T,
typename a2T>
195 MADNESS_ASSERT(ptr_);
196 return ((*ptr_).*memfn_)(
a1,
a2);
199 template <
typename a1T,
typename a2T,
typename a3T>
201 MADNESS_ASSERT(ptr_);
202 return ((*ptr_).*memfn_)(
a1,
a2, a3);
205 template <
typename a1T,
typename a2T,
typename a3T,
typename a4T>
207 MADNESS_ASSERT(ptr_);
208 return ((*ptr_).*memfn_)(
a1,
a2, a3, a4);
211 template <
typename a1T,
typename a2T,
typename a3T,
typename a4T,
214 MADNESS_ASSERT(ptr_);
215 return ((*ptr_).*memfn_)(
a1,
a2, a3, a4, a5);
218 template <
typename a1T,
typename a2T,
typename a3T,
typename a4T,
219 typename a5T,
typename a6T>
221 MADNESS_ASSERT(ptr_);
222 return ((*ptr_).*memfn_)(
a1,
a2, a3, a4, a5, a6);
225 template <
typename a1T,
typename a2T,
typename a3T,
typename a4T,
226 typename a5T,
typename a6T,
typename a7T>
227 resT
operator()(a1T&
a1, a2T&
a2, a3T& a3, a4T& a4, a5T& a5, a6T& a6, a7T& a7)
const {
228 MADNESS_ASSERT(ptr_);
229 return ((*ptr_).*memfn_)(
a1,
a2, a3, a4, a5, a6, a7);
232 template <
typename a1T,
typename a2T,
typename a3T,
typename a4T,
233 typename a5T,
typename a6T,
typename a7T,
typename a8T>
234 resT
operator()(a1T&
a1, a2T&
a2, a3T& a3, a4T& a4, a5T& a5, a6T& a6, a7T& a7, a8T& a8)
const {
235 MADNESS_ASSERT(ptr_);
236 return ((*ptr_).*memfn_)(
a1,
a2, a3, a4, a5, a6, a7, a8);
239 template <
typename a1T,
typename a2T,
typename a3T,
typename a4T,
240 typename a5T,
typename a6T,
typename a7T,
typename a8T,
typename a9T>
241 resT
operator()(a1T&
a1, a2T&
a2, a3T& a3, a4T& a4, a5T& a5, a6T& a6, a7T& a7, a8T& a8, a9T& a9)
const {
242 MADNESS_ASSERT(ptr_);
243 return ((*ptr_).*memfn_)(
a1,
a2, a3, a4, a5, a6, a7, a8, a9);
246 template <
typename Archive>
252 return wrapper.memfn_;
256 template <
typename ptrT,
typename memfnT>
272 ptr_(other.ptr_), memfn_(other.memfn_)
276 ptr_(ptr), memfn_(memfn)
279 MemFuncWrapper_&
operator=(
const MemFuncWrapper_& other) {
281 memfn_ = other.memfn_;
286 MADNESS_ASSERT(ptr_);
290 template <
typename a1T>
292 MADNESS_ASSERT(ptr_);
293 ((*ptr_).*memfn_)(a1);
296 template <
typename a1T,
typename a2T>
298 MADNESS_ASSERT(ptr_);
299 ((*ptr_).*memfn_)(a1, a2);
302 template <
typename a1T,
typename a2T,
typename a3T>
304 MADNESS_ASSERT(ptr_);
305 ((*ptr_).*memfn_)(a1, a2, a3);
308 template <
typename a1T,
typename a2T,
typename a3T,
typename a4T>
310 MADNESS_ASSERT(ptr_);
311 ((*ptr_).*memfn_)(a1, a2, a3, a4);
314 template <
typename a1T,
typename a2T,
typename a3T,
typename a4T,
317 MADNESS_ASSERT(ptr_);
318 ((*ptr_).*memfn_)(a1, a2, a3, a4, a5);
321 template <
typename a1T,
typename a2T,
typename a3T,
typename a4T,
322 typename a5T,
typename a6T>
324 MADNESS_ASSERT(ptr_);
325 ((*ptr_).*memfn_)(a1, a2, a3, a4, a5, a6);
328 template <
typename a1T,
typename a2T,
typename a3T,
typename a4T,
329 typename a5T,
typename a6T,
typename a7T>
330 void operator()(a1T&
a1, a2T&
a2, a3T& a3, a4T& a4, a5T& a5, a6T& a6, a7T& a7)
const {
331 MADNESS_ASSERT(ptr_);
332 ((*ptr_).*memfn_)(a1, a2, a3, a4, a5, a6, a7);
335 template <
typename a1T,
typename a2T,
typename a3T,
typename a4T,
336 typename a5T,
typename a6T,
typename a7T,
typename a8T>
337 void operator()(a1T&
a1, a2T&
a2, a3T& a3, a4T& a4, a5T& a5, a6T& a6, a7T& a7, a8T& a8)
const {
338 MADNESS_ASSERT(ptr_);
339 ((*ptr_).*memfn_)(a1, a2, a3, a4, a5, a6, a7, a8);
342 template <
typename a1T,
typename a2T,
typename a3T,
typename a4T,
343 typename a5T,
typename a6T,
typename a7T,
typename a8T,
typename a9T>
344 void operator()(a1T&
a1, a2T&
a2, a3T& a3, a4T& a4, a5T& a5, a6T& a6, a7T& a7, a8T& a8, a9T& a9)
const {
345 MADNESS_ASSERT(ptr_);
346 ((*ptr_).*memfn_)(a1, a2, a3, a4, a5, a6, a7, a8, a9);
349 template <
typename Archive>
356 template <
typename objT,
typename memfnT>
357 MemFuncWrapper<objT*, memfnT, typename result_of<memfnT>::type>
360 typename memfunc_traits<memfnT>::result_type>(& obj, memfn);
363 template <
typename objT,
typename memfnT>
364 MemFuncWrapper<objT*, memfnT, typename result_of<memfnT>::type>
367 typename memfunc_traits<memfnT>::result_type>(obj, memfn);
370 template <
typename objT,
typename memfnT>
371 MemFuncWrapper<std::shared_ptr<objT>, memfnT,
typename result_of<memfnT>::type>
374 typename memfunc_traits<memfnT>::result_type>(obj, memfn);
377 template <
typename objT,
typename memfnT>
378 MemFuncWrapper<std::shared_ptr<objT>, memfnT,
typename result_of<memfnT>::type>
381 typename memfunc_traits<memfnT>::result_type>(obj, memfn);
384 template <
typename ptrT,
typename memfnT,
typename resT>
386 return wrapper.memfn_;
400 void notify() { nregistered--; }
403 template <
typename resultT,
typename opT>
404 static resultT
sum(
const resultT& left,
const resultT& right,
const opT&
op) {
406 return op(left,right);
409 template <
typename taskT>
410 static void spawn_remote_task_handler(
const AmArg&
arg) {
411 MADNESS_ASSERT(taskT::arity <= 9u);
415 detail::TaskHandlerInfo<
typename taskT::futureT::remote_refT,
418 archive::BufferInputArchive input_arch = arg & info;
421 taskT* task =
new taskT(
typename taskT::futureT(info.ref),
422 info.func, info.attr, input_arch);
425 arg.get_world()->taskq.add(task);
428 template <
typename T>
429 inline const T& am_arg(
const Future<T>&
f) {
430 MADNESS_ASSERT(f.probe());
434 template <
typename T>
inline const T& am_arg(
const T& t) {
return t; }
438 template <
typename taskT,
typename fnT,
typename a1T,
typename a2T,
typename a3T,
439 typename a4T,
typename a5T,
typename a6T,
typename a7T,
440 typename a8T,
typename a9T>
441 inline typename taskT::futureT
443 const a2T&
a2,
const a3T& a3,
const a4T& a4,
const a5T& a5,
444 const a6T& a6,
const a7T& a7,
const a8T& a8,
const a9T& a9,
445 const TaskAttributes& attr)
447 typename taskT::futureT result;
448 typedef detail::TaskHandlerInfo<typename taskT::futureT::remote_refT, typename taskT::functionT> infoT;
449 world.
am.
send(where, & WorldTaskQueue::template spawn_remote_task_handler<taskT>,
450 new_am_arg(infoT(result.remote_ref(world), fn, attr),
451 a1, a2, a3, a4, a5, a6, a7, a8, a9));
461 size_t size()
const {
return nregistered; }
476 t->set_info(&world,
this);
478 if (t->
ndep() == 0) {
482 t->register_submit_callback();
487 template <
typename fnT,
typename a1T,
typename a2T,
typename a3T,
488 typename a4T,
typename a5T,
typename a6T,
typename a7T,
typename a8T,
494 add(static_cast<TaskInterface*>(t));
515 template <
typename resultT,
typename rangeT,
typename opT>
517 if (range.size() <= range.get_chunksize()) {
518 resultT
sum = resultT();
519 for (
typename rangeT::iterator it=range.begin(); it != range.end(); ++it) sum =
op(sum,
op(it));
523 rangeT right(left,
Split());
525 Future<resultT> leftsum =
add(*
this, &WorldTaskQueue::reduce<resultT,rangeT,opT>, left, op);
526 Future<resultT> rightsum =
add(*
this, &WorldTaskQueue::reduce<resultT,rangeT,opT>, right, op);
527 return add(&WorldTaskQueue::sum<resultT,opT>, leftsum, rightsum, op);
555 template <
typename rangeT,
typename opT>
575 template <
typename fnT>
579 return add(
new taskT(
typename taskT::futureT(),
583 template <
typename fnT,
typename a1T>
587 return add(
new taskT(
typename taskT::futureT(),
591 template <
typename fnT,
typename a1T,
typename a2T>
595 return add(
new taskT(
typename taskT::futureT(),
599 template <
typename fnT,
typename a1T,
typename a2T,
typename a3T>
601 add(fnT fn,
const a1T& a1,
const a2T& a2,
const a3T& a3,
605 return add(
new taskT(
typename taskT::futureT(),
606 fn, a1, a2, a3, attr));
609 template <
typename fnT,
typename a1T,
typename a2T,
typename a3T,
typename a4T>
611 add(fnT fn,
const a1T& a1,
const a2T& a2,
const a3T& a3,
const a4T& a4,
615 return add(
new taskT(
typename taskT::futureT(),
616 fn, a1, a2, a3, a4, attr));
619 template <
typename fnT,
typename a1T,
typename a2T,
typename a3T,
typename a4T,
622 add(fnT fn,
const a1T& a1,
const a2T& a2,
const a3T& a3,
const a4T& a4,
626 return add(
new taskT(
typename taskT::futureT(),
627 fn, a1, a2, a3, a4, a5, attr));
630 template <
typename fnT,
typename a1T,
typename a2T,
typename a3T,
typename a4T,
631 typename a5T,
typename a6T>
633 add(fnT fn,
const a1T& a1,
const a2T& a2,
const a3T& a3,
const a4T& a4,
637 return add(
new taskT(
typename taskT::futureT(),
638 fn, a1, a2, a3, a4, a5, a6, attr));
641 template <
typename fnT,
typename a1T,
typename a2T,
typename a3T,
typename a4T,
642 typename a5T,
typename a6T,
typename a7T>
644 add(fnT fn,
const a1T& a1,
const a2T& a2,
const a3T& a3,
const a4T& a4,
645 const a5T& a5,
const a6T& a6,
const a7T& a7,
649 return add(
new taskT(
typename taskT::futureT(),
650 fn, a1, a2, a3, a4, a5, a6, a7, attr));
653 template <
typename fnT,
typename a1T,
typename a2T,
typename a3T,
typename a4T,
654 typename a5T,
typename a6T,
typename a7T,
typename a8T>
656 add(fnT fn,
const a1T& a1,
const a2T& a2,
const a3T& a3,
const a4T& a4,
657 const a5T& a5,
const a6T& a6,
const a7T& a7,
const a8T& a8,
661 return add(
new taskT(
typename taskT::futureT(),
662 fn, a1, a2, a3, a4, a5, a6, a7, a8, attr));
666 template <
typename fnT,
typename a1T,
typename a2T,
typename a3T,
typename a4T,
667 typename a5T,
typename a6T,
typename a7T,
typename a8T,
typename a9T>
669 add(fnT fn,
const a1T& a1,
const a2T& a2,
const a3T& a3,
const a4T& a4,
670 const a5T& a5,
const a6T& a6,
const a7T& a7,
const a8T& a8,
const a9T& a9,
674 return add(
new taskT(
typename taskT::futureT(),
675 fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, attr));
700 template <
typename fnT>
706 return add(fn, attr);
737 template <
typename fnT,
typename a1T>
743 return add(fn, a1, attr);
745 return send_task<taskT>(dest, fn, am_arg(a1),
voidT::value,
754 template <
typename fnT,
typename a1T,
typename a2T>
761 return add(fn, a1, a2, attr);
763 return send_task<taskT>(dest, fn, am_arg(a1), am_arg(a2),
772 template <
typename fnT,
typename a1T,
typename a2T,
typename a3T>
774 add(
ProcessID dest, fnT fn,
const a1T& a1,
const a2T& a2,
const a3T& a3,
779 return add(fn, a1, a2, a3, attr);
781 return send_task<taskT>(dest, fn, am_arg(a1), am_arg(a2),
790 template <
typename fnT,
typename a1T,
typename a2T,
typename a3T,
793 add(
ProcessID dest, fnT fn,
const a1T& a1,
const a2T& a2,
const a3T& a3,
798 return add(fn, a1, a2, a3, a4, attr);
800 return send_task<taskT>(dest, fn, am_arg(a1), am_arg(a2),
809 template <
typename fnT,
typename a1T,
typename a2T,
typename a3T,
810 typename a4T,
typename a5T>
812 add(
ProcessID dest, fnT fn,
const a1T& a1,
const a2T& a2,
const a3T& a3,
817 return add(fn, a1, a2, a3, a4, a5, attr);
819 return send_task<taskT>(dest, fn, am_arg(a1), am_arg(a2),
828 template <
typename fnT,
typename a1T,
typename a2T,
typename a3T,
829 typename a4T,
typename a5T,
typename a6T>
831 add(
ProcessID dest, fnT fn,
const a1T& a1,
const a2T& a2,
const a3T& a3,
832 const a4T& a4,
const a5T& a5,
const a6T& a6,
837 return add(fn, a1, a2, a3, a4, a5, a6, attr);
839 return send_task<taskT>(dest, fn, am_arg(a1), am_arg(a2),
840 am_arg(a3), am_arg(a4), am_arg(a5), am_arg(a6),
848 template <
typename fnT,
typename a1T,
typename a2T,
typename a3T,
849 typename a4T,
typename a5T,
typename a6T,
typename a7T>
851 add(
ProcessID dest, fnT fn,
const a1T& a1,
const a2T& a2,
const a3T& a3,
852 const a4T& a4,
const a5T& a5,
const a6T& a6,
const a7T& a7,
857 return add(fn, a1, a2, a3, a4, a5, a6, a7, attr);
859 return send_task<taskT>(dest, fn, am_arg(a1), am_arg(a2),
860 am_arg(a3), am_arg(a4), am_arg(a5), am_arg(a6),
868 template <
typename fnT,
typename a1T,
typename a2T,
typename a3T,
869 typename a4T,
typename a5T,
typename a6T,
typename a7T,
872 add(
ProcessID dest, fnT fn,
const a1T& a1,
const a2T& a2,
const a3T& a3,
873 const a4T& a4,
const a5T& a5,
const a6T& a6,
const a7T& a7,
878 return add(fn, a1, a2, a3, a4, a5, a6, a7, a8, attr);
880 return send_task<taskT>(dest, fn, am_arg(a1), am_arg(a2),
881 am_arg(a3), am_arg(a4), am_arg(a5), am_arg(a6),
889 template <
typename fnT,
typename a1T,
typename a2T,
typename a3T,
890 typename a4T,
typename a5T,
typename a6T,
typename a7T,
891 typename a8T,
typename a9T>
893 add(
ProcessID dest, fnT fn,
const a1T& a1,
const a2T& a2,
const a3T& a3,
894 const a4T& a4,
const a5T& a5,
const a6T& a6,
const a7T& a7,
899 return add(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, attr);
901 return send_task<taskT>(dest, fn, am_arg(a1), am_arg(a2),
902 am_arg(a3), am_arg(a4), am_arg(a5), am_arg(a6),
903 am_arg(a7), am_arg(a8), am_arg(a9), attr);
907 template <
typename objT,
typename memfnT>
913 template <
typename objT,
typename memfnT,
typename a1T>
915 add(objT& obj, memfnT memfun,
const a1T& a1,
920 template <
typename objT,
typename memfnT,
typename a1T,
typename a2T>
922 add(objT& obj, memfnT memfun,
const a1T& a1,
const a2T& a2,
927 template <
typename objT,
typename memfnT,
typename a1T,
typename a2T,
930 add(objT& obj, memfnT memfun,
const a1T& a1,
const a2T& a2,
const a3T& a3,
935 template <
typename objT,
typename memfnT,
typename a1T,
typename a2T,
936 typename a3T,
typename a4T>
938 add(objT& obj, memfnT memfun,
const a1T& a1,
const a2T& a2,
const a3T& a3,
943 template <
typename objT,
typename memfnT,
typename a1T,
typename a2T,
944 typename a3T,
typename a4T,
typename a5T>
946 add(objT& obj, memfnT memfun,
const a1T& a1,
const a2T& a2,
const a3T& a3,
951 template <
typename objT,
typename memfnT,
typename a1T,
typename a2T,
952 typename a3T,
typename a4T,
typename a5T,
typename a6T>
954 add(objT& obj, memfnT memfun,
const a1T& a1,
const a2T& a2,
const a3T& a3,
955 const a4T& a4,
const a5T& a5,
const a6T& a6,
960 template <
typename objT,
typename memfnT,
typename a1T,
typename a2T,
961 typename a3T,
typename a4T,
typename a5T,
typename a6T,
typename a7T>
963 add(objT& obj, memfnT memfun,
const a1T& a1,
const a2T& a2,
const a3T& a3,
964 const a4T& a4,
const a5T& a5,
const a6T& a6,
const a7T& a7,
969 template <
typename objT,
typename memfnT,
typename a1T,
typename a2T,
970 typename a3T,
typename a4T,
typename a5T,
typename a6T,
typename a7T,
973 add(objT& obj, memfnT memfun,
const a1T& a1,
const a2T& a2,
const a3T& a3,
974 const a4T& a4,
const a5T& a5,
const a6T& a6,
const a7T& a7,
976 {
return add(
detail::wrap_mem_fn(obj,memfun),a1,a2,a3,a4,a5,a6,a7,a8,attr); }
979 template <
typename objT,
typename memfnT,
typename a1T,
typename a2T,
980 typename a3T,
typename a4T,
typename a5T,
typename a6T,
typename a7T,
981 typename a8T,
typename a9T>
983 add(objT& obj, memfnT memfun,
const a1T& a1,
const a2T& a2,
const a3T& a3,
984 const a4T& a4,
const a5T& a5,
const a6T& a6,
const a7T& a7,
986 {
return add(
detail::wrap_mem_fn(obj,memfun),a1,a2,a3,a4,a5,a6,a7,a8,a9,attr); }
989 template <
typename objT,
typename memfnT>
995 template <
typename objT,
typename memfnT,
typename a1T>
997 add(objT* obj, memfnT memfun,
const a1T& a1,
1002 template <
typename objT,
typename memfnT,
typename a1T,
typename a2T>
1004 add(objT* obj, memfnT memfun,
const a1T& a1,
const a2T& a2,
1009 template <
typename objT,
typename memfnT,
typename a1T,
typename a2T,
1012 add(objT* obj, memfnT memfun,
const a1T& a1,
const a2T& a2,
const a3T& a3,
1017 template <
typename objT,
typename memfnT,
typename a1T,
typename a2T,
1018 typename a3T,
typename a4T>
1020 add(objT* obj, memfnT memfun,
const a1T& a1,
const a2T& a2,
const a3T& a3,
1026 template <
typename objT,
typename memfnT,
typename a1T,
typename a2T,
1027 typename a3T,
typename a4T,
typename a5T>
1029 add(objT* obj, memfnT memfun,
const a1T& a1,
const a2T& a2,
const a3T& a3,
1035 template <
typename objT,
typename memfnT,
typename a1T,
typename a2T,
1036 typename a3T,
typename a4T,
typename a5T,
typename a6T>
1038 add(objT* obj, memfnT memfun,
const a1T& a1,
const a2T& a2,
const a3T& a3,
1039 const a4T& a4,
const a5T& a5,
const a6T& a6,
1044 template <
typename objT,
typename memfnT,
typename a1T,
typename a2T,
1045 typename a3T,
typename a4T,
typename a5T,
typename a6T,
typename a7T>
1047 add(objT* obj, memfnT memfun,
const a1T& a1,
const a2T& a2,
const a3T& a3,
1048 const a4T& a4,
const a5T& a5,
const a6T& a6,
const a7T& a7,
1053 template <
typename objT,
typename memfnT,
typename a1T,
typename a2T,
1054 typename a3T,
typename a4T,
typename a5T,
typename a6T,
typename a7T,
1057 add(objT* obj, memfnT memfun,
const a1T& a1,
const a2T& a2,
const a3T& a3,
1058 const a4T& a4,
const a5T& a5,
const a6T& a6,
const a7T& a7,
1060 {
return add(
detail::wrap_mem_fn(obj,memfun),a1,a2,a3,a4,a5,a6,a7,a8,attr); }
1063 template <
typename objT,
typename memfnT,
typename a1T,
typename a2T,
1064 typename a3T,
typename a4T,
typename a5T,
typename a6T,
typename a7T,
1065 typename a8T,
typename a9T>
1067 add(objT* obj, memfnT memfun,
const a1T& a1,
const a2T& a2,
1068 const a3T& a3,
const a4T& a4,
const a5T& a5,
const a6T& a6,
1069 const a7T& a7,
const a8T& a8,
const a9T& a9,
1071 {
return add(
detail::wrap_mem_fn(obj,memfun),a1,a2,a3,a4,a5,a6,a7,a8,a9,attr); }
1075 struct ProbeAllDone {
1078 bool operator()()
const {
return (tq->nregistered == 0); }
1090 printf(
"!!MADNESS ERROR: Exception thrown in WorldTaskQueue::fence() with %i pending task(s)\n",
int(nregistered));
1105 template <
typename rangeT,
typename opT>
1132 while(range_.size() > range_.get_chunksize()) {
1133 rangeT right(range_,
Split());
1135 root_.
world().taskq.add(leaf);
1140 for(
typename rangeT::iterator it = range_.begin(); it != range_.end(); ++it)
1152 virtual void get_id(std::pair<void*,unsigned short>&
id)
const {
1165 template <
typename rangeT,
typename opT>
1166 class ForEachRootTask :
public TaskInterface {
1170 Future<bool> completion_status_;
1182 status_ = - (range.size());
1217 virtual void get_id(std::pair<void*,unsigned short>&
id)
const {
1228 #endif // MADNESS_WORLD_WORLDTASK_H__INCLUDED
detail::function_enabler< fnT >::type add(ProcessID dest, fnT fn, const TaskAttributes &attr=TaskAttributes())
Spawn a remote task.
Definition: worldtask.h:702
MemFuncWrapper(const MemFuncWrapper_ &other)
Definition: worldtask.h:168
detail::memfunc_enabler< memfnT >::type add(objT &obj, memfnT memfun, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const TaskAttributes attr=TaskAttributes())
Invoke "resultT (obj.*memfun)(a1T,a2T,a3,a4,a5)" as a local task.
Definition: worldtask.h:946
Definition: shared_ptr_bits.h:38
resT operator()(a1T &a1, a2T &a2, a3T &a3, a4T &a4) const
Definition: worldtask.h:206
MemFuncWrapper_ & operator=(const MemFuncWrapper_ &other)
Definition: worldtask.h:176
void operator()(a1T &a1, a2T &a2, a3T &a3, a4T &a4, a5T &a5, a6T &a6, a7T &a7, a8T &a8) const
Definition: worldtask.h:337
detail::memfunc_enabler< memfnT >::type add(objT *obj, memfnT memfun, const a1T &a1, const a2T &a2, const a3T &a3, const TaskAttributes &attr=TaskAttributes())
Invoke "resultT (obj.*memfun)(a1T,a2T,a3)" as a local task.
Definition: worldtask.h:1012
void operator()(a1T &a1, a2T &a2, a3T &a3, a4T &a4, a5T &a5, a6T &a6, a7T &a7) const
Definition: worldtask.h:330
static TaskAttributes hipri()
Definition: worldthread.h:277
void inc()
Increment the number of dependencies.
Definition: worlddep.h:108
detail::memfunc_enabler< memfnT >::type add(objT &obj, memfnT memfun, const a1T &a1, const TaskAttributes &attr=TaskAttributes())
Invoke "resultT (obj.*memfun)(a1T)" as a local task.
Definition: worldtask.h:915
detail::function_enabler< fnT >::type add(fnT fn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const a7T &a7, const a8T &a8, const TaskAttributes &attr=TaskAttributes())
Definition: worldtask.h:656
Dummy class a la Intel TBB used to distinguish splitting constructor.
Definition: worldrange.h:45
resT operator()(a1T &a1, a2T &a2, a3T &a3, a4T &a4, a5T &a5) const
Definition: worldtask.h:213
Apply an operation to a range of iterators.
Definition: worldtask.h:65
MemFuncWrapper()
Definition: worldtask.h:166
void notify()
Invoked by callbacks to notifiy of dependencies being satisfied.
Definition: worlddep.h:91
detail::function_enabler< fnT >::type add(fnT fn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const TaskAttributes &attr=TaskAttributes())
Definition: worldtask.h:622
resT operator()(a1T &a1) const
Definition: worldtask.h:188
void operator()(a1T &a1, a2T &a2, a3T &a3, a4T &a4, a5T &a5, a6T &a6) const
Definition: worldtask.h:323
detail::function_enabler< fnT >::type add(fnT fn, const a1T &a1, const a2T &a2, const TaskAttributes &attr=TaskAttributes())
Definition: worldtask.h:593
detail::memfunc_enabler< memfnT >::type add(objT &obj, memfnT memfun, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const a7T &a7, const a8T &a8, const TaskAttributes attr=TaskAttributes())
Invoke "resultT (obj.*memfun)(a1T,a2T,a3,a4,a5,a6,a7,a8)" as a local task.
Definition: worldtask.h:973
void serialize(const Archive &ar)
Definition: worldtask.h:247
Definition: worldtask.h:144
resT operator()(a1T &a1, a2T &a2, a3T &a3, a4T &a4, a5T &a5, a6T &a6, a7T &a7, a8T &a8, a9T &a9) const
Definition: worldtask.h:241
detail::function_enabler< fnT >::type add(ProcessID dest, fnT fn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const a7T &a7, const TaskAttributes &attr=TaskAttributes())
Invoke "resultT (*fn)(a1T,a2T,a3T,a4T,a5T,a6T,a7T)" as a task, local or remote.
Definition: worldtask.h:851
detail::function_enabler< fnT >::type add(fnT fn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const TaskAttributes &attr=TaskAttributes())
Definition: worldtask.h:633
detail::memfunc_enabler< memfnT >::type add(objT &obj, memfnT memfun, const a1T &a1, const a2T &a2, const TaskAttributes &attr=TaskAttributes())
Invoke "resultT (obj.*memfun)(a1T,a2T)" as a local task.
Definition: worldtask.h:922
Future< bool > for_each(const rangeT &range, const opT &op)
Apply op(item) for all items in range.
Definition: worldtask.h:556
detail::memfunc_enabler< memfnT >::type add(objT *obj, memfnT memfun, const TaskAttributes &attr=TaskAttributes())
Invoke "resultT (obj.*memfun)()" as a local task.
Definition: worldtask.h:991
AmArg * new_am_arg(const A &a, const B &b, const C &c, const D &d, const E &e, const F &f, const G &g, const H &h, const I &i, const J &j)
Convenience template for serializing arguments into a new AmArg.
Definition: worldam.h:185
resT operator()(a1T &a1, a2T &a2) const
Definition: worldtask.h:194
Used to pass info about thread environment into users task.
Definition: worldthread.h:289
void serialize(const Archive &ar)
Serialization of object.
Definition: worldtask.h:91
MemFuncWrapper()
Definition: worldtask.h:269
resT operator()(a1T &a1, a2T &a2, a3T &a3) const
Definition: worldtask.h:200
This class used for callbacks (e.g., for dependency tracking)
Definition: worlddep.h:51
resT operator()(a1T &a1, a2T &a2, a3T &a3, a4T &a4, a5T &a5, a6T &a6, a7T &a7, a8T &a8) const
Definition: worldtask.h:234
detail::memfunc_enabler< memfnT >::type add(objT *obj, memfnT memfun, const a1T &a1, const TaskAttributes &attr=TaskAttributes())
Invoke "resultT (obj.*memfun)(a1T)" as a local task.
Definition: worldtask.h:997
detail::function_enabler< fnT >::type add(fnT fn, const a1T &a1, const TaskAttributes &attr=TaskAttributes())
Definition: worldtask.h:585
MemFuncWrapper< ptrT, memfnT, void > MemFuncWrapper_
Definition: worldtask.h:162
detail::memfunc_enabler< memfnT >::type add(objT &obj, memfnT memfun, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const TaskAttributes &attr=TaskAttributes())
Invoke "resultT (obj.*memfun)(a1T,a2T,a3,a4,a5,a6)" as a local task.
Definition: worldtask.h:954
Definition: mpreal.h:3066
functionT func
A task function.
Definition: worldtask.h:74
detail::memfunc_enabler< memfnT >::type add(objT &obj, memfnT memfun, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const a7T &a7, const a8T &a8, const a9T &a9, const TaskAttributes attr=TaskAttributes())
Invoke "resultT (obj.*memfun)(a1T,a2T,a3,a4,a5,a6,a7,a8,a9)" as a local task.
Definition: worldtask.h:983
Implement Range class for parallel iteration.
NDIM & f
Definition: mra.h:2179
memfnT memfn_type
Definition: worldtask.h:267
POD holding excitation energy and response vector for a single excitation.
Definition: tdhf_CIS.h:134
static void await(const Probe &probe, bool dowork=true)
Gracefully wait for a condition to become true ... executes tasks if any in queue.
Definition: worldthread.h:1056
MemFuncWrapper(ptrT ptr, memfnT memfn)
Definition: worldtask.h:172
void result_type
Definition: worldtask.h:266
Tensor< typename Tensor< T >::scalar_type > arg(const Tensor< T > &t)
Return a new tensor holding the argument of each element of t (complex types only) ...
Definition: tensor.h:2429
Multi-threaded queue to manage and run tasks.
Definition: worldtask.h:393
virtual void run(const TaskThreadEnv &)
Task run work.
Definition: worldtask.h:1211
const Future< bool > & result() const
Result accessor.
Definition: worldtask.h:1198
Definition: worldtask.h:59
WorldAmInterface & am
AM interface.
Definition: worldfwd.h:460
detail::function_enabler< fnT >::type add(fnT fn, const a1T &a1, const a2T &a2, const a3T &a3, const TaskAttributes &attr=TaskAttributes())
Definition: worldtask.h:601
virtual void run(const TaskThreadEnv &)
Run the task.
Definition: worldtask.h:1130
detail::function_enabler< fnT >::type add(fnT fn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const a7T &a7, const a8T &a8, const a9T &a9, const TaskAttributes &attr=TaskAttributes())
Definition: worldtask.h:669
size_t size() const
Returns the number of pending tasks.
Definition: worldtask.h:461
detail::function_enabler< fnT >::type add(ProcessID dest, fnT fn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const TaskAttributes &attr=TaskAttributes())
Invoke "resultT (*fn)(a1T,a2T,a3T,a4T)" as a task, local or remote.
Definition: worldtask.h:793
TaskFn< fnT, a1T, a2T, a3T, a4T, a5T, a6T, a7T, a8T, a9T >::futureT add(TaskFn< fnT, a1T, a2T, a3T, a4T, a5T, a6T, a7T, a8T, a9T > *t)
Definition: worldtask.h:491
MemFuncWrapper< ptrT, memfnT, void > MemFuncWrapper_
Definition: worldtask.h:265
Definition: worldtask.h:58
const double a2
Definition: vnucso.cc:91
task_result_type< fnT >::type type
Definition: enable_if.h:88
memfnT memfn_type
Definition: worldtask.h:164
const T1 &f1 return GTEST_2_TUPLE_() T(f0, f1)
resT operator()(a1T &a1, a2T &a2, a3T &a3, a4T &a4, a5T &a5, a6T &a6, a7T &a7) const
Definition: worldtask.h:227
detail::memfunc_enabler< memfnT >::type add(objT *obj, memfnT memfun, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const TaskAttributes &attr=TaskAttributes())
Invoke "resultT (obj.*memfun)(a1T,a2T,a3,a4)" as a local task.
Definition: worldtask.h:1020
void operator()(a1T &a1, a2T &a2, a3T &a3) const
Definition: worldtask.h:303
Definition: worldtask.h:130
Apply an operation to a range of iterators.
Definition: worldtask.h:1106
int ndep() const
Returns the number of unsatisfied dependencies.
Definition: worlddep.h:85
detail::memfunc_enabler< memfnT >::type add(objT &obj, memfnT memfun, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const a7T &a7, const TaskAttributes &attr=TaskAttributes())
Invoke "resultT (obj.*memfun)(a1T,a2T,a3,a4,a5,a6,a7)" as a local task.
Definition: worldtask.h:963
static void add(PoolTaskInterface *task)
Add a new task to the pool.
Definition: worldthread.h:984
resT result_type
Definition: worldtask.h:163
detail::memfunc_enabler< memfnT >::type add(objT *obj, memfnT memfun, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const TaskAttributes attr=TaskAttributes())
Invoke "resultT (obj.*memfun)(a1T,a2T,a3,a4,a5)" as a local task.
Definition: worldtask.h:1029
detail::memfunc_enabler< memfnT >::type add(objT *obj, memfnT memfun, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const a7T &a7, const a8T &a8, const TaskAttributes attr=TaskAttributes())
Invoke "resultT (obj.*memfun)(a1T,a2T,a3,a4,a5,a6,a7,a8)" as a local task.
Definition: worldtask.h:1057
detail::memfunc_enabler< memfnT >::type add(objT *obj, memfnT memfun, const a1T &a1, const a2T &a2, const TaskAttributes &attr=TaskAttributes())
Invoke "resultT (obj.*memfun)(a1T,a2T)" as a local task.
Definition: worldtask.h:1004
void operator()(a1T &a1, a2T &a2, a3T &a3, a4T &a4, a5T &a5, a6T &a6, a7T &a7, a8T &a8, a9T &a9) const
Definition: worldtask.h:344
MemFuncWrapper< objT *, memfnT, typename result_of< memfnT >::type > wrap_mem_fn(objT &obj, memfnT memfn)
Definition: worldtask.h:358
Function< double, 3 > functionT
Definition: chem/corepotential.cc:59
detail::function_enabler< fnT >::type add(ProcessID dest, fnT fn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const TaskAttributes &attr=TaskAttributes())
Invoke "resultT (*fn)(a1T,a2T,a3T,a4T,a5T)" as a task, local or remote.
Definition: worldtask.h:812
detail::memfunc_enabler< memfnT >::type add(objT &obj, memfnT memfun, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const TaskAttributes &attr=TaskAttributes())
Invoke "resultT (obj.*memfun)(a1T,a2T,a3,a4)" as a local task.
Definition: worldtask.h:938
Future< void > voidT
Definition: taskfn.h:222
detail::memfunc_enabler< memfnT >::type add(objT &obj, memfnT memfun, const a1T &a1, const a2T &a2, const a3T &a3, const TaskAttributes &attr=TaskAttributes())
Invoke "resultT (obj.*memfun)(a1T,a2T,a3)" as a local task.
Definition: worldtask.h:930
refT ref
Remote reference for a task result future.
Definition: worldtask.h:73
detail::function_enabler< fnT >::type add(ProcessID dest, fnT fn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const TaskAttributes &attr=TaskAttributes())
Invoke "resultT (*fn)(a1T,a2T,a3T,a4T,a5T,a6T)" as a task, local or remote.
Definition: worldtask.h:831
static T init()
Definition: worldtask.h:145
detail::function_enabler< fnT >::type add(fnT fn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const TaskAttributes &attr=TaskAttributes())
Definition: worldtask.h:611
An integer with atomic set, get, read+inc, read+dec, dec+test operations.
Definition: atomicint.h:73
RMI::Request send(const ProcessID dest, am_handlerT op, const AmArg *arg, const int attr=RMI::ATTR_ORDERED, const bool managed=true)
Sends an unmanaged non-blocking active message.
Definition: worldam.h:386
A parallel world with full functionality wrapping an MPI communicator.
Definition: worldfwd.h:416
lazy_enable_if from Boost for conditionally instantiating templates based on type ...
Definition: enable_if.h:102
MemFuncWrapper_ & operator=(const MemFuncWrapper_ &other)
Definition: worldtask.h:279
resT operator()() const
Definition: worldtask.h:182
World & world() const
World accessor.
Definition: worldtask.h:1193
detail::function_enabler< fnT >::type add(ProcessID dest, fnT fn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const a7T &a7, const a8T &a8, const TaskAttributes &attr=TaskAttributes())
Invoke "resultT (*fn)(a1T,a2T,a3T,a4T,a5T,a6T,a7T,a8T)" as a task, local or remote.
Definition: worldtask.h:872
TaskHandlerInfo()
Definition: worldtask.h:84
void operator()(a1T &a1) const
Definition: worldtask.h:291
void operator()(a1T &a1, a2T &a2, a3T &a3, a4T &a4) const
Definition: worldtask.h:309
int ProcessID
Used to clearly identify process number/rank.
Definition: worldtypes.h:37
ForEachTask(const rangeT range, const opT &op, ForEachRootTask< rangeT, opT > &root)
Constructor.
Definition: worldtask.h:1119
WorldTaskQueue(World &world)
Definition: worldtask.cc:55
TaskAttributes attr
Task attributes.
Definition: worldtask.h:75
detail::function_enabler< fnT >::type add(ProcessID dest, fnT fn, const a1T &a1, const TaskAttributes &attr=TaskAttributes())
Spawn a remote task.
Definition: worldtask.h:739
detail::memfunc_enabler< memfnT >::type add(objT *obj, memfnT memfun, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const TaskAttributes &attr=TaskAttributes())
Invoke "resultT (obj.*memfun)(a1T,a2T,a3,a4,a5,a6)" as a local task.
Definition: worldtask.h:1038
Wrap a callable object and its arguments into a task function.
Definition: taskfn.h:388
const mpreal sum(const mpreal tab[], unsigned long int n, mp_rnd_t rnd_mode)
Definition: mpreal.cc:241
void operator()() const
Definition: worldtask.h:285
void fence()
Returns after all local tasks have completed.
Definition: worldtask.h:1086
archive_array< unsigned char > wrap_opaque(const T *, unsigned int)
Factory function to wrap pointer to contiguous data as opaque (uchar) archive_array.
Definition: archive.h:827
void operator()(a1T &a1, a2T &a2) const
Definition: worldtask.h:297
detail::memfunc_enabler< memfnT >::type add(objT *obj, memfnT memfun, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const a7T &a7, const a8T &a8, const a9T &a9, const TaskAttributes attr=TaskAttributes())
Invoke "resultT (obj.*memfun)(a1T,a2T,a3,a4,a5,a6,a7,a8,a9)" as a local task.
Definition: worldtask.h:1067
void add(TaskInterface *t)
Add a new local task taking ownership of the pointer.
Definition: worldtask.h:473
detail::function_enabler< fnT >::type add(ProcessID dest, fnT fn, const a1T &a1, const a2T &a2, const a3T &a3, const TaskAttributes &attr=TaskAttributes())
Invoke "resultT (*fn)(a1T,a2T,a3T)" as a task, local or remote.
Definition: worldtask.h:774
Definition: worldtask.h:72
Contains attributes of a task.
Definition: worldthread.h:208
const double a1
Definition: vnucso.cc:90
static const Future< void > value
Definition: worldfut.h:602
MemFuncWrapper(const MemFuncWrapper_ &other)
Definition: worldtask.h:271
static enable_if_c< detail::function_traits< fnT >::value||detail::memfunc_traits< fnT >::value >::type make_id(std::pair< void *, unsigned short > &id, fnT fn)
Definition: worldthread.h:680
detail::function_enabler< fnT >::type add(ProcessID dest, fnT fn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const a7T &a7, const a8T &a8, const a9T &a9, const TaskAttributes &attr=TaskAttributes())
Invoke "resultT (*fn)(a1T,a2T,a3T,a4T,a5T,a6T,a7T,a8T,a9T)" as a task, local or remote.
Definition: worldtask.h:893
Future< resultT > reduce(const rangeT &range, const opT &op)
Reduce op(item) for all items in range using op(sum,op(item))
Definition: worldtask.h:516
static std::shared_ptr< T > init()
Definition: worldtask.h:150
void serialize(const Archive &ar)
Definition: worldtask.h:350
A future is a possibly yet unevaluated value.
Definition: ref.h:210
detail::function_enabler< fnT >::type add(fnT fn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const a7T &a7, const TaskAttributes &attr=TaskAttributes())
Definition: worldtask.h:644
void operator()(a1T &a1, a2T &a2, a3T &a3, a4T &a4, a5T &a5) const
Definition: worldtask.h:316
Tensor< double > op(const Tensor< double > &x)
Definition: kain.cc:508
Wrappers around platform dependent timers and performance info.
friend memfnT get_mem_func_ptr(const MemFuncWrapper_ &wrapper)
Definition: worldtask.h:251
Definition: worldtask.h:257
is_function::value is true if T is a function pointer
Definition: type_traits_bits.h:85
detail::function_enabler< fnT >::type add(fnT fn, const TaskAttributes &attr=TaskAttributes())
Spawn a local task.
Definition: worldtask.h:577
Definition: worldtask.h:137
All world tasks must be derived from this public interface.
Definition: taskfn.h:68
MemFuncWrapper(ptrT ptr, memfnT memfn)
Definition: worldtask.h:275
lazy_enable_if_c from Boost for conditionally instantiating templates based on type ...
Definition: enable_if.h:87
const futureT & result() const
Definition: taskfn.h:614
enable_if from Boost for conditionally instantiating templates based on type
Definition: enable_if.h:60
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces.
Definition: chem/atomutil.cc:45
virtual ~ForEachRootTask()
Virtual destructor.
Definition: worldtask.h:1188
is_member_function_pointer::value is true if T is a member function pointer
Definition: type_traits_bits.h:91
resT operator()(a1T &a1, a2T &a2, a3T &a3, a4T &a4, a5T &a5, a6T &a6) const
Definition: worldtask.h:220
detail::memfunc_enabler< memfnT >::type add(objT &obj, memfnT memfun, const TaskAttributes &attr=TaskAttributes())
Invoke "resultT (obj.*memfun)()" as a local task.
Definition: worldtask.h:909
void complete(const int status)
Called by child tasks when they are complete.
Definition: worldtask.h:1203
detail::memfunc_enabler< memfnT >::type add(objT *obj, memfnT memfun, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const a7T &a7, const TaskAttributes &attr=TaskAttributes())
Invoke "resultT (obj.*memfun)(a1T,a2T,a3,a4,a5,a6,a7)" as a local task.
Definition: worldtask.h:1047
detail::function_enabler< fnT >::type add(ProcessID dest, fnT fn, const a1T &a1, const a2T &a2, const TaskAttributes &attr=TaskAttributes())
Invoke "resultT (*fn)(a1T,a2T)" as a task, local or remote.
Definition: worldtask.h:756
memfnT get_mem_func_ptr(const MemFuncWrapper< ptrT, memfnT, resT > &)
Definition: worldtask.h:385
TaskHandlerInfo(const refT &ref, functionT func, const TaskAttributes &attr)
Construct task info object.
Definition: worldtask.h:82
Disables default copy constructor and assignment operators.
Definition: nodefaults.h:49
ForEachRootTask(World &world, const rangeT range, const opT &op)
Constructor.
Definition: worldtask.h:1179
virtual ~ForEachTask()
Virtual destructor.
Definition: worldtask.h:1127