40#ifndef SRC_MADNESS_MRA_MACROTASKQ_H_
41#define SRC_MADNESS_MRA_MACROTASKQ_H_
81 gaxpy(1.0, x, 1.0,
true);
86 void gaxpy(
const double a,
const T& right,
double b,
const bool fence=
true) {
93 template<
typename Archive>
115template<
typename T=
double>
133 void set_impl(
const std::shared_ptr<implT>& newimpl) {
142 void gaxpy(
const double a,
const T& right,
double b,
const bool fence=
true) {
143 impl->gaxpy(
a,right,
b,fence);
146 template<
typename Archive>
158 return impl->get_local();
166 std::vector<ScalarResult<T>>
v;
219template<
typename>
struct is_tuple : std::false_type { };
220template<
typename ...T>
struct is_tuple<
std::tuple<T...>> : std::true_type { };
223template<
typename tupleT, std::
size_t I>
226 typedef decay_tuple <tupleT> argtupleT;
228 if constexpr(
I >= std::tuple_size_v<tupleT>) {
232 using typeT =
typename std::tuple_element<I, argtupleT>::type;
233 if constexpr (not is_valid_task_result_v<typeT>) {
237 return check_tuple_is_valid_task_result<tupleT,I+1>();
247 left.
gaxpy(
a, right,
b, fence);
250template <
class Archive,
typename T>
253 bool exists=(ptr) ?
true :
false;
255 if (exists) ar & ptr->id();
260template <
class Archive,
typename T>
272 MADNESS_EXCEPTION(
"ScalarResultImpl: remote operation attempting to use a locally uninitialized object",0);
275 MADNESS_EXCEPTION(
"ScalarResultImpl<T> operation attempting to use an unregistered object",0);
287 typedef std::vector<std::shared_ptr<MacroTaskBase> >
taskqT;
307 printf(
"this is task with priority %4.1f\n",
priority);
310 print(
"nothing to print");
313 std::stringstream ss;
331template<
typename macrotaskT>
353 std::shared_ptr< WorldDCPmapInterface< Key<1> > >
pmap1;
354 std::shared_ptr< WorldDCPmapInterface< Key<2> > >
pmap2;
355 std::shared_ptr< WorldDCPmapInterface< Key<3> > >
pmap3;
356 std::shared_ptr< WorldDCPmapInterface< Key<4> > >
pmap4;
357 std::shared_ptr< WorldDCPmapInterface< Key<5> > >
pmap5;
358 std::shared_ptr< WorldDCPmapInterface< Key<6> > >
pmap6;
394 std::shared_ptr<World> all_worlds;
395 all_worlds.reset(
new World(comm));
406 print(
"number of tasks in taskq",
taskq.size());
407 print(
"redirecting output to files task.#####");
434 if (element<0)
break;
435 std::shared_ptr<MacroTaskBase>
task=
taskq[element];
442 tasktime+=(cpu1-cpu0);
443 if (
printdebug()) printf(
"completed task %3ld after %6.1fs at time %6.1fs\n",element,cpu1-cpu0,
wall_time());
446 const std::size_t ntask=
taskq.size();
448 auto in_percentile = [&ntask](
const long element) {
449 return std::floor(element/(0.1*(ntask+1)));
451 auto is_first_in_percentile = [&](
const long element) {
452 return (in_percentile(element)!=in_percentile(element-1));
455 std::cout << int(in_percentile(element)*10) <<
" " << std::flush;
465 printf(
"completed taskqueue after %4.1fs at time %4.1fs\n", cpu11 - cpu00,
wall_time());
466 printf(
" total cpu time / per world %4.1fs %4.1fs\n", tasktime, tasktime /
universe.
size());
486 for (
const auto& t : vtask) {
496 print(
"total number of tasks: ",
taskq.size());
497 print(
" task batch priority status");
498 for (
const auto& t :
taskq) t->print_me_as_table();
511 if (subworld.
rank()==0) {
525 auto is_Waiting = [](
const std::shared_ptr<MacroTaskBase>& mtb_ptr) {
return mtb_ptr->is_waiting();};
526 auto it=std::find_if(
taskq.begin(),
taskq.end(),is_Waiting);
527 if (it!=
taskq.end()) {
528 it->get()->set_running();
529 long element=it-
taskq.begin();
544 taskq[task_number]->set_complete();
566template<
typename taskT>
590 constexpr std::size_t
bufsize=256;
592 std::snprintf(cfilename,
bufsize,
"%s.%5.5ld",
filename.c_str(),task_number);
593 ofile=std::ofstream(cfilename);
594 if (
debug) std::cout <<
"redirecting to file " << cfilename << std::endl;
596 std::cout.sync_with_stdio(
true);
602 std::cout.sync_with_stdio(
true);
603 if (
debug) std::cout <<
"redirecting back to cout" << std::endl;
629 template<
typename ... Ts>
632 const bool immediate_execution = (not
taskq_ptr);
636 auto argtuple = std::tie(args...);
637 static_assert(std::is_same<
decltype(argtuple),
argtupleT>::value,
"type or number of arguments incorrect");
640 auto partitioner=
task.partitioner;
642 partitioner->set_nsubworld(
world.
size());
643 partitionT partition = partitioner->partition_tasks(argtuple);
652 for (
const auto& batch_prio : partition) {
654 std::shared_ptr<MacroTaskBase>(
new MacroTaskInternal(
task, batch_prio, inputrecords, outputrecords)));
658 if (immediate_execution)
taskq_ptr->run_all();
673 static_assert(check_tuple_is_valid_task_result<resultT,0>(),
674 "tuple has invalid result type in prepare_output_records");
676 static_assert(is_valid_task_result_v<resultT>,
"unknown result type in prepare_output_records");
679 if (
debug)
print(
"storing pointers to output in cloud");
681 auto store_output_records = [&](
const auto& result) {
683 typedef std::decay_t<
decltype(result)> argT;
685 outputrecords += cloud.
store(
world, result.get_impl().get());
689 outputrecords += cloud.
store(
world, result.get_impl());
693 std::vector<std::shared_ptr<typename argT::value_type::implT>>
v;
694 for (
const auto& ptr : result)
v.push_back(ptr.get_impl());
702 return outputrecords;
708 std::apply([&](
auto &&... args) {
709 (( outputrecords+=store_output_records(args) ), ...);
712 outputrecords=store_output_records(result);
714 return outputrecords;
727 if (
task.name==
"unknown_task")
return typeid(
task).
name();
735 static_assert(check_tuple_is_valid_task_result<resultT,0>(),
736 "tuple has invalid result type in prepare_output_records");
738 static_assert(is_valid_task_result_v<resultT>,
"unknown result type in prepare_output_records");
740 this->task.batch=batch_prio.first;
746 print(
"this is task",
get_name(),
"with batch",
task.batch,
"priority",this->get_priority());
750 std::stringstream ss;
752 std::size_t namesize=std::min(std::size_t(28),
name.size());
753 name += std::string(28-namesize,
' ');
755 std::stringstream ssbatch;
756 ssbatch <<
task.batch;
757 std::string strbatch=ssbatch.str();
758 int nspaces=std::max(
int(0),35-
int(ssbatch.str().size()));
759 strbatch+=std::string(nspaces,
' ');
762 << std::setw(10) << strbatch
768 template<
typename tupleT,
typename tupleR,
typename opT, std::
size_t I=0>
770 if constexpr(I < std::tuple_size_v<tupleT>) {
771 auto& element1=std::get<I>(tuple1);
772 auto& element2=std::get<I>(tuple2);
773 op(element1,element2);
774 binary_tuple_loop<tupleT, tupleR, opT, I+1>(tuple1,tuple2,
op);
778 template<
typename tupleT,
typename opT, std::
size_t I=0>
780 if constexpr(I < std::tuple_size_v<tupleT>) {
781 auto& element1=std::get<I>(tuple);
783 unary_tuple_loop<tupleT,opT, I+1>(tuple,
op);
788 template<
typename resultT1, std::
size_t I=0>
789 typename std::enable_if<is_tuple<resultT1>::value,
void>
::type
791 if constexpr(I < std::tuple_size_v<resultT1>) {
792 using elementT =
typename std::tuple_element<I, resultT>::type;
793 auto element_final=std::get<I>(final_result);
794 auto element_tmp=std::get<I>(tmp_result);
795 accumulate_into_final_result<elementT>(subworld, element_final, element_tmp, argtuple);
796 accumulate_into_final_result<resultT1,I+1>(subworld, final_result, tmp_result, argtuple);
801 template<
typename resultT1>
802 typename std::enable_if<not is_tuple<resultT1>::value,
void>
::type
805 result_tmp.compress();
806 gaxpy(1.0,result,1.0, result_tmp);
811 gaxpy(1.0,result,1.0,result_tmp,
false);
815 gaxpy(1.0, result, 1.0, result_tmp.get_local(),
false);
819 std::size_t sz=result.size();
820 for (
int i=0; i<sz; ++i) {
821 gaxpy(1.0, result[i], 1.0, result_tmp[i].get_local(),
false);
831 const argtupleT batched_argtuple =
task.batch.template copy_input_batch(argtuple);
835 resultT result_batch = std::apply(
task, batched_argtuple);
839 std::snprintf(buffer,
bufsize,
"completed task %3ld after %6.1fs at time %6.1fs\n",element,cpu1-cpu0,
wall_time());
840 print(std::string(buffer));
843 auto insert_batch = [&](
auto& element1,
auto& element2) {
844 typedef std::decay_t<
decltype(element1)> decay_type;;
846 element1=
task.batch.template insert_result_batch(element1,element2);
848 std::swap(element1,element2);
851 resultT result_subworld=
task.allocator(subworld,argtuple);
855 insert_batch(result_subworld,result_batch);
861 accumulate_into_final_result<resultT>(subworld, result_universe, result_subworld, argtuple);
863 }
catch (std::exception&
e) {
864 print(
"failing task no",element,
"in subworld",subworld.
id(),
"at time",
wall_time());
873 template<
typename T, std::
size_t NDIM>
880 template<
typename T, std::
size_t NDIM>
882 std::vector<Function<T,NDIM>> vresult;
883 vresult.resize(v_impl.size());
895 std::vector<ScalarResult<T>> vresult(v_sr_impl.size());
896 for (
auto i=0; i<v_sr_impl.size(); ++i) {
897 vresult[i].set_impl(v_sr_impl[i]);
913 auto doit = [&](
auto& element) {
914 typedef std::decay_t<
decltype(element)> elementT;
918 typedef typename elementT::value_type::implT implT;
919 auto ptr_element = cloud.
consuming_load<std::vector<std::shared_ptr<implT>>>(
920 subworld, outputrecords1);
924 typedef typename elementT::implT implT;
925 auto ptr_element = cloud.
consuming_load<std::shared_ptr<implT>>(subworld, outputrecords1);
929 typedef typename elementT::value_type ScalarResultT;
930 typedef typename ScalarResultT::implT implT;
931 typedef std::vector<std::shared_ptr<implT>> vptrT;
932 auto ptr_element = cloud.
consuming_load<vptrT>(subworld, outputrecords1);
938 auto ptr_element = cloud.
consuming_load<std::shared_ptr<typename elementT::implT>>(subworld, outputrecords1);
946 static_assert(check_tuple_is_valid_task_result<resultT, 0>(),
947 "invalid tuple task result -- must be vectors of functions");
972 std::string
name=
"unknown_task";
Wrapper around MPI_Comm. Has a shallow copy constructor; use Create(Get_group()) for deep copy.
Definition safempi.h:490
Intracomm Split(int Color, int Key=0) const
Definition safempi.h:635
a batch consists of a 2D-input batch and a 1D-output batch: K-batch <- (I-batch, J-batch)
Definition macrotaskpartitioner.h:139
cloud class
Definition cloud.h:147
void clear()
Definition cloud.h:258
recordlistT store(madness::World &world, const T &source)
Definition cloud.h:314
Recordlist< keyT > recordlistT
Definition cloud.h:160
void replicate(const std::size_t chunk_size=INT_MAX)
Definition cloud.h:337
void print_size(World &universe)
Definition cloud.h:193
T load(madness::World &world, const recordlistT recordlist) const
Definition cloud.h:274
void clear_cache(World &subworld)
Definition cloud.h:252
void print_timings(World &universe) const
Definition cloud.h:230
T consuming_load(madness::World &world, recordlistT &recordlist) const
similar to load, but will consume the recordlist
Definition cloud.h:287
static void set_default_pmap(World &world)
Sets the default process map.
Definition mraimpl.h:3574
static std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > & get_pmap()
Returns the default process map.
Definition funcdefaults.h:389
static void set_pmap(const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > &value)
Sets the default process map (does not redistribute existing functions)
Definition funcdefaults.h:405
FunctionImpl holds all Function state to facilitate shallow copy semantics.
Definition funcimpl.h:945
A multiresolution adaptive numerical function.
Definition mra.h:139
void set_impl(const std::shared_ptr< FunctionImpl< T, NDIM > > &impl)
Replace current FunctionImpl with provided new one.
Definition mra.h:646
A future is a possibly yet unevaluated value.
Definition future.h:373
T & get(bool dowork=true) &
Gets the value, waiting if necessary.
Definition future.h:574
base class
Definition macrotaskq.h:284
void set_running()
Definition macrotaskq.h:296
virtual ~MacroTaskBase()
Definition macrotaskq.h:290
void set_waiting()
Definition macrotaskq.h:297
MacroTaskBase()
Definition macrotaskq.h:289
virtual void print_me(std::string s="") const
Definition macrotaskq.h:306
std::string print_priority_and_status_to_string() const
Definition macrotaskq.h:312
void set_complete()
Definition macrotaskq.h:295
double priority
Definition macrotaskq.h:292
bool is_complete() const
Definition macrotaskq.h:299
Status
Definition macrotaskq.h:293
@ Complete
Definition macrotaskq.h:293
@ Running
Definition macrotaskq.h:293
@ Unknown
Definition macrotaskq.h:293
@ Waiting
Definition macrotaskq.h:293
bool is_running() const
Definition macrotaskq.h:300
enum madness::MacroTaskBase::Status stat
double get_priority() const
Definition macrotaskq.h:318
void set_priority(const double p)
Definition macrotaskq.h:319
virtual void print_me_as_table(std::string s="") const
Definition macrotaskq.h:309
std::vector< std::shared_ptr< MacroTaskBase > > taskqT
Definition macrotaskq.h:287
virtual void run(World &world, Cloud &cloud, taskqT &taskq, const long element, const bool debug)=0
friend std::ostream & operator<<(std::ostream &os, const MacroTaskBase::Status s)
Definition macrotaskq.h:321
bool is_waiting() const
Definition macrotaskq.h:301
Definition macrotaskq.h:969
MacroTaskOperationBase()
Definition macrotaskq.h:974
Batch batch
Definition macrotaskq.h:971
std::shared_ptr< MacroTaskPartitioner > partitioner
Definition macrotaskq.h:973
std::string name
Definition macrotaskq.h:972
partition one (two) vectors into 1D (2D) batches.
Definition macrotaskpartitioner.h:197
std::list< std::pair< Batch, double > > partitionT
Definition macrotaskpartitioner.h:201
Definition macrotaskq.h:345
long nsubworld
Definition macrotaskq.h:352
std::mutex taskq_mutex
Definition macrotaskq.h:350
bool printdebug() const
Definition macrotaskq.h:360
static void set_pmap(World &world)
Definition macrotaskq.h:548
void run_all()
run all tasks
Definition macrotaskq.h:402
void set_complete(const long task_number) const
scheduler is located on rank==0
Definition macrotaskq.h:537
World & universe
Definition macrotaskq.h:347
std::shared_ptr< WorldDCPmapInterface< Key< 1 > > > pmap1
Definition macrotaskq.h:353
std::shared_ptr< WorldDCPmapInterface< Key< 3 > > > pmap3
Definition macrotaskq.h:355
MacroTaskBase::taskqT taskq
Definition macrotaskq.h:349
void add_tasks(MacroTaskBase::taskqT &vtask)
Definition macrotaskq.h:485
long get_scheduled_task_number(World &subworld)
scheduler is located on universe.rank==0
Definition macrotaskq.h:509
void set_complete_local(const long task_number) const
scheduler is located on rank==0
Definition macrotaskq.h:542
World & get_subworld()
Definition macrotaskq.h:367
MacroTaskQ(World &universe, int nworld, const long printlevel=0)
create an empty taskq and initialize the subworlds
Definition macrotaskq.h:372
std::shared_ptr< WorldDCPmapInterface< Key< 4 > > > pmap4
Definition macrotaskq.h:356
std::size_t size() const
Definition macrotaskq.h:557
std::shared_ptr< WorldDCPmapInterface< Key< 5 > > > pmap5
Definition macrotaskq.h:357
void print_taskq() const
Definition macrotaskq.h:492
std::shared_ptr< World > subworld_ptr
Definition macrotaskq.h:348
bool printtimings() const
Definition macrotaskq.h:362
std::shared_ptr< WorldDCPmapInterface< Key< 2 > > > pmap2
Definition macrotaskq.h:354
bool printprogress() const
Definition macrotaskq.h:361
std::shared_ptr< WorldDCPmapInterface< Key< 6 > > > pmap6
Definition macrotaskq.h:358
void set_printlevel(const long p)
Definition macrotaskq.h:369
long printlevel
Definition macrotaskq.h:351
madness::Cloud cloud
Definition macrotaskq.h:366
long get_nsubworld() const
Definition macrotaskq.h:368
void add_replicated_task(const std::shared_ptr< MacroTaskBase > &task)
Definition macrotaskq.h:504
~MacroTaskQ()
Definition macrotaskq.h:385
static std::shared_ptr< World > create_worlds(World &universe, const std::size_t nsubworld)
Definition macrotaskq.h:389
long get_scheduled_task_number_local()
Definition macrotaskq.h:521
Definition macrotaskq.h:718
taskT task
Definition macrotaskq.h:725
MacroTaskInternal(const taskT &task, const std::pair< Batch, double > &batch_prio, const recordlistT &inputrecords, const recordlistT &outputrecords)
Definition macrotaskq.h:731
std::enable_if< notis_tuple< resultT1 >::value, void >::type accumulate_into_final_result(World &subworld, resultT1 &result, const resultT1 &result_tmp, const argtupleT &argtuple)
accumulate the result of the task into the final result living in the universe
Definition macrotaskq.h:803
static ScalarResult< T > pointer2WorldObject(const std::shared_ptr< ScalarResultImpl< T > > sr_impl)
Definition macrotaskq.h:889
decay_tuple< typename taskT::argtupleT > argtupleT
Definition macrotaskq.h:720
static std::vector< Function< T, NDIM > > pointer2WorldObject(const std::vector< std::shared_ptr< FunctionImpl< T, NDIM > > > v_impl)
Definition macrotaskq.h:881
virtual void print_me_as_table(std::string s="") const
Definition macrotaskq.h:749
taskT::resultT resultT
Definition macrotaskq.h:721
void run(World &subworld, Cloud &cloud, MacroTaskBase::taskqT &taskq, const long element, const bool debug)
Definition macrotaskq.h:828
recordlistT outputrecords
Definition macrotaskq.h:723
std::string get_name() const
Definition macrotaskq.h:726
void binary_tuple_loop(tupleT &tuple1, tupleR &tuple2, opT &op) const
loop over the tuple elements of both tuples and execute the operation op on each element pair
Definition macrotaskq.h:769
resultT get_output(World &subworld, Cloud &cloud)
return the WorldObjects or the result functions living in the universe
Definition macrotaskq.h:906
static Function< T, NDIM > pointer2WorldObject(const std::shared_ptr< FunctionImpl< T, NDIM > > impl)
Definition macrotaskq.h:874
static std::vector< ScalarResult< T > > pointer2WorldObject(const std::vector< std::shared_ptr< ScalarResultImpl< T > > > v_sr_impl)
Definition macrotaskq.h:894
virtual void print_me(std::string s="") const
Definition macrotaskq.h:745
void unary_tuple_loop(tupleT &tuple, opT &op) const
Definition macrotaskq.h:779
std::enable_if< is_tuple< resultT1 >::value, void >::type accumulate_into_final_result(World &subworld, resultT1 &final_result, const resultT1 &tmp_result, const argtupleT &argtuple)
accumulate the result of the task into the final result living in the universe
Definition macrotaskq.h:790
recordlistT inputrecords
Definition macrotaskq.h:722
Definition macrotaskq.h:567
taskT::resultT resultT
Definition macrotaskq.h:577
std::shared_ptr< MacroTaskQ > taskq_ptr
Definition macrotaskq.h:666
taskT::argtupleT argtupleT
Definition macrotaskq.h:578
MacroTask(World &world, taskT &task, std::shared_ptr< MacroTaskQ > taskq_ptr=0)
constructor takes the actual task
Definition macrotaskq.h:611
World & world
Definition macrotaskq.h:665
resultT operator()(const Ts &... args)
this mimicks the original call to the task functor, called from the universe
Definition macrotaskq.h:630
bool debug
Definition macrotaskq.h:581
taskT task
Definition macrotaskq.h:580
MacroTaskPartitioner::partitionT partitionT
Definition macrotaskq.h:568
Cloud::recordlistT recordlistT
Definition macrotaskq.h:579
void set_debug(const bool value)
Definition macrotaskq.h:620
recordlistT prepare_output_records(Cloud &cloud, resultT &result)
store pointers to the result WorldObject in the cloud and return the recordlist
Definition macrotaskq.h:671
helper class for returning the result of a task, which is not a madness Function, but a simple scalar
Definition macrotaskq.h:55
void gaxpy(const double a, const T &right, double b, const bool fence=true)
accumulate, optional fence
Definition macrotaskq.h:86
void serialize(Archive &ar)
Definition macrotaskq.h:94
T get()
after completion of the taskq get the final value
Definition macrotaskq.h:99
ScalarResultImpl< T > & operator=(const T &x)
simple assignment of the scalar value
Definition macrotaskq.h:75
ScalarResultImpl(const ScalarResultImpl &other)=delete
Disable the default copy constructor.
ScalarResultImpl< T > & operator=(const ScalarResultImpl< T > &other)=delete
disable assignment operator
ScalarResultImpl< T > & operator+=(const T &x)
Definition macrotaskq.h:80
~ScalarResultImpl()
Definition macrotaskq.h:69
T value
the scalar value
Definition macrotaskq.h:112
T get_local() const
Definition macrotaskq.h:106
T value_type
Definition macrotaskq.h:57
ScalarResultImpl(World &world)
Definition macrotaskq.h:58
Definition macrotaskq.h:116
void serialize(Archive &ar)
Definition macrotaskq.h:147
ScalarResult(const std::shared_ptr< implT > &impl)
Definition macrotaskq.h:123
void gaxpy(const double a, const T &right, double b, const bool fence=true)
accumulate, optional fence
Definition macrotaskq.h:142
ScalarResultImpl< T > implT
Definition macrotaskq.h:118
T get()
after completion of the taskq get the final value
Definition macrotaskq.h:152
ScalarResult(World &world)
Definition macrotaskq.h:122
std::shared_ptr< implT > impl
Definition macrotaskq.h:119
ScalarResult & operator=(const T &x)
Definition macrotaskq.h:124
std::shared_ptr< implT > get_impl() const
Definition macrotaskq.h:129
void set_impl(const std::shared_ptr< implT > &newimpl)
Definition macrotaskq.h:133
T get_local() const
after completion of the taskq get the final value
Definition macrotaskq.h:157
uniqueidT id() const
Definition macrotaskq.h:137
void broadcast_serializable(objT &obj, ProcessID root)
Broadcast a serializable object.
Definition worldgop.h:754
void fence(bool debug=false)
Synchronizes all processes in communicator AND globally ensures no pending AM or tasks.
Definition worldgop.cc:161
bool set_forbid_fence(bool value)
Set forbid_fence flag to new value and return old value.
Definition worldgop.h:674
void sum(T *buf, size_t nelem)
Inplace global sum while still processing AM & tasks.
Definition worldgop.h:870
SafeMPI::Intracomm & comm()
Returns the associated SafeMPI communicator.
Definition worldmpi.h:286
Implements most parts of a globally addressable object (via unique ID).
Definition world_object.h:364
World & get_world() const
Returns a reference to the world.
Definition world_object.h:717
World & world
The World this object belongs to. (Think globally, act locally).
Definition world_object.h:381
void process_pending()
To be called from derived constructor to process pending messages.
Definition world_object.h:656
detail::task_result_type< memfnT >::futureT send(ProcessID dest, memfnT memfn) const
Definition world_object.h:731
detail::task_result_type< memfnT >::futureT task(ProcessID dest, memfnT memfn, const TaskAttributes &attr=TaskAttributes()) const
Sends task to derived class method returnT (this->*memfn)().
Definition world_object.h:1005
A parallel world class.
Definition world.h:132
static World * world_from_id(std::uint64_t id)
Convert a World ID to a World pointer.
Definition world.h:492
ProcessID rank() const
Returns the process rank in this World (same as MPI_Comm_rank()).
Definition world.h:320
WorldMpiInterface & mpi
MPI interface.
Definition world.h:204
ProcessID size() const
Returns the number of processes in this World (same as MPI_Comm_size()).
Definition world.h:330
unsigned long id() const
Definition world.h:315
WorldGopInterface & gop
Global operations.
Definition world.h:207
std::optional< T * > ptr_from_id(uniqueidT id) const
Look up a local pointer from a world-wide unique ID.
Definition world.h:416
Class for unique global IDs.
Definition uniqueid.h:53
Declares the Cloud class for storing data and transfering them between worlds.
char * p(char *buf, const char *name, int k, int initial_level, double thresh, int order)
Definition derivatives.cc:72
const std::size_t bufsize
Definition derivatives.cc:16
static bool debug
Definition dirac-hatom.cc:16
auto T(World &world, response_space &f) -> response_space
Definition global_functions.cc:34
static const double v
Definition hatom_sf_dirac.cc:20
Tensor< double > op(const Tensor< double > &x)
Definition kain.cc:508
#define MADNESS_CHECK(condition)
Check a condition — even in a release build the condition is always evaluated so it can have side eff...
Definition madness_exception.h:182
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition madness_exception.h:119
#define MADNESS_ASSERT(condition)
Assert a condition that should be free of side-effects since in release builds this might be a no-op.
Definition madness_exception.h:134
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
std::vector< ScalarResult< T > > scalar_result_vector(World &world, std::size_t n)
helper function to create a vector of ScalarResultImpl, circumventing problems with the constructors
Definition macrotaskq.h:165
static const char * filename
Definition legendre.cc:96
static double cpu_time()
Returns the cpu time in seconds relative to an arbitrary origin.
Definition timers.h:127
void set_impl(std::vector< Function< T, NDIM > > &v, const std::vector< std::shared_ptr< FunctionImpl< T, NDIM > > > vimpl)
Definition vmra.h:645
std::vector< std::shared_ptr< FunctionImpl< T, NDIM > > > get_impl(const std::vector< Function< T, NDIM > > &v)
Definition vmra.h:638
void compress(World &world, const std::vector< Function< T, NDIM > > &v, bool fence=true)
Compress a vector of functions.
Definition vmra.h:145
constexpr bool check_tuple_is_valid_task_result()
given a tuple check recursively if all elements are valid task results
Definition macrotaskq.h:224
static const Slice _(0,-1, 1)
void print(const T &t, const Ts &... ts)
Print items to std::cout (items separated by spaces) and terminate with a new line.
Definition print.h:225
constexpr bool is_valid_task_result_v
check if type is a valid task result: it must be a WorldObject and must implement gaxpy
Definition macrotaskq.h:210
decltype(decay_types(std::declval< T >())) decay_tuple
Definition macrotaskpartitioner.h:22
double wall_time()
Returns the wall time in seconds relative to an arbitrary origin.
Definition timers.cc:48
std::string type(const PairType &n)
Definition PNOParameters.h:18
std::string name(const FuncType &type, const int ex=-1)
Definition ccpairfunction.h:28
void gaxpy(const double a, ScalarResult< T > &left, const double b, const T &right, const bool fence=true)
the result type of a macrotask must implement gaxpy
Definition macrotaskq.h:246
static const double b
Definition nonlinschro.cc:119
static const double a
Definition nonlinschro.cc:118
RAII class to redirect cout to a file.
Definition macrotaskq.h:584
io_redirect(const long task_number, std::string filename, bool debug=false)
Definition macrotaskq.h:589
std::streambuf * stream_buffer_cout
Definition macrotaskq.h:585
~io_redirect()
Definition macrotaskq.h:599
bool debug
Definition macrotaskq.h:587
std::ofstream ofile
Definition macrotaskq.h:586
Definition macrotaskq.h:571
Default load of an object via serialize(ar, t).
Definition archive.h:666
Default store of an object via serialize(ar, t).
Definition archive.h:611
Definition macrotaskpartitioner.h:25
Definition macrotaskq.h:195
Definition macrotaskq.h:180
Definition macrotaskq.h:174
Definition macrotaskq.h:201
Definition macrotaskq.h:189
Definition macrotaskq.h:219
static void load(const Archive &ar, std::shared_ptr< ScalarResultImpl< T > > &ptr)
Definition macrotaskq.h:262
static void store(const Archive &ar, const std::shared_ptr< ScalarResultImpl< T > > &ptr)
Definition macrotaskq.h:252
static const double_complex I
Definition tdse1d.cc:164
void doit(World &world)
Definition tdse.cc:921
void e()
Definition test_sig.cc:75
Declares the World class for the parallel runtime environment.
int ProcessID
Used to clearly identify process number/rank.
Definition worldtypes.h:43