28 friend V_MODULEEXPORT std::ostream &
operator<<(std::ostream &os,
const Token &tok);
32 Token(
Reader *reader, std::shared_ptr<Token> previous);
34 const Meta &meta()
const;
35 bool wait(
const std::string &port = std::string());
39 unsigned long id()
const;
44 bool waitPortReady(
const std::string &port);
45 void setPortReady(
const std::string &port,
bool ready);
47 Reader *m_reader =
nullptr;
50 bool m_finished =
false;
51 bool m_result =
false;
52 std::shared_ptr<Token> m_previous;
53 std::shared_future<bool> m_future;
54 unsigned long m_id = 0;
57 PortState(): future(promise.get_future().
share()) {}
59 std::promise<bool> promise;
60 std::shared_future<bool> future;
63 std::map<std::string, std::shared_ptr<PortState>> m_ports;
72 Reader(
const std::string &name,
const int moduleID, mpi::communicator comm);
80 virtual bool examine(
const Parameter *param =
nullptr);
86 virtual bool read(
Token &token,
int timestep = -1,
int block = -1) = 0;
88 virtual bool prepareRead();
90 virtual bool finishRead();
93 int timeIncrement()
const;
95 virtual int rankForTimestepAndPartition(
int t,
int p)
const;
98 int numPartitions()
const;
110 void setParallelizationMode(ParallelizationMode mode);
112 void setHandlePartitions(
bool enable);
114 void setAllowTimestepDistribution(
bool allow);
117 void observeParameter(
const Parameter *param);
119 void setTimesteps(
int number);
121 void setPartitions(
int number);
123 bool changeParameters(std::set<const Parameter *> params)
override;
124 bool changeParameter(
const Parameter *param)
override;
125 void prepareQuit()
override;
127 bool checkConvexity()
const;
129 IntParameter *m_first =
nullptr;
130 IntParameter *m_last =
nullptr;
131 IntParameter *m_increment =
nullptr;
132 IntParameter *m_distributeTime =
nullptr;
133 IntParameter *m_firstRank =
nullptr;
134 IntParameter *m_checkConvexity =
nullptr;
137 bool prepare()
override;
138 bool compute()
override;
142 std::deque<std::shared_ptr<Token>> m_tokens;
143 size_t waitForReaders(
size_t maxRunning,
bool &result);
145 std::set<const Parameter *> m_observedParameters;
147 int m_numTimesteps = 0;
148 int m_numPartitions = 0;
149 bool m_readyForRead =
true;
151 bool m_handlePartitions =
true;
152 bool m_allowTimestepDistribution =
false;
154 unsigned long m_tokenCount = 0;
const int m_id
Definition: module.h:260
int id() const
Definition: module.cpp:330
bool addObject(Port *port, vistle::Object::ptr object)
Definition: module.cpp:775
std::shared_ptr< Object > ptr
Definition: object.h:67
Definition: parameter.h:26
base class for Vistle read modules
Definition: reader.h:22
friend class Token
Definition: reader.h:23
ParallelizationMode
Definition: reader.h:102
@ Serial
only one operation at a time, all blocks of a timestep first, then other timesteps
Definition: reader.h:103
@ ParallelizeBlocks
up to 'concurrency' operations at a time, all operations for one timestep have finished before operat...
Definition: reader.h:106
@ ParallelizeTimesteps
up to 'concurrency' operations at a time, but the same block from different timesteps may be schedule...
Definition: reader.h:104
@ ParallelizeTimeAndBlocks
up to 'concurrency' operations at a time
Definition: reader.h:105
virtual bool read(Token &token, int timestep=-1, int block=-1)=0
called for every unit of work to be read
std::string share(const std::string &prefix)
Definition: directory.cpp:74
Definition: allobjects.cpp:30
std::ostream & operator<<(std::ostream &out, const Meta &meta)
Definition: objectmeta.cpp:45