Removed useless continuator functor, replaced with a virtual method into MpiJob.
This commit is contained in:
parent
28ab2004ea
commit
fb871382e0
2 changed files with 13 additions and 68 deletions
|
|
@ -6,41 +6,19 @@
|
|||
# include <eoFunctor.h>
|
||||
# include <vector>
|
||||
|
||||
template< typename EOT >
|
||||
struct ParallelApplyContinuator : public BaseContinuator
|
||||
{
|
||||
ParallelApplyContinuator( int index, int size )
|
||||
{
|
||||
_index = index;
|
||||
_size = size;
|
||||
}
|
||||
|
||||
void index( int i ) { _index = i; }
|
||||
|
||||
bool operator()()
|
||||
{
|
||||
return _index < _size;
|
||||
}
|
||||
|
||||
private:
|
||||
int _index;
|
||||
int _size;
|
||||
};
|
||||
|
||||
template< typename EOT >
|
||||
class ParallelApply : public MpiJob
|
||||
{
|
||||
public:
|
||||
|
||||
ParallelApply( eoUF<EOT&, void> & _proc, std::vector<EOT>& _pop, AssignmentAlgorithm & algo, int _masterRank ) :
|
||||
MpiJob( algo,
|
||||
new ParallelApplyContinuator<EOT>( 0, _pop.size() ),
|
||||
_masterRank ),
|
||||
MpiJob( algo, _masterRank ),
|
||||
func( _proc ),
|
||||
index( 0 ),
|
||||
size( _pop.size() ),
|
||||
data( _pop )
|
||||
{
|
||||
pa_continuator = static_cast<ParallelApplyContinuator<EOT>*>( _continuator );
|
||||
// empty
|
||||
}
|
||||
|
||||
virtual void sendTask( int wrkRank )
|
||||
|
|
@ -48,7 +26,6 @@ class ParallelApply : public MpiJob
|
|||
assignedTasks[ wrkRank ] = index;
|
||||
comm.send( wrkRank, 1, data[ index ] );
|
||||
++index;
|
||||
pa_continuator->index( index );
|
||||
}
|
||||
|
||||
virtual void handleResponse( int wrkRank )
|
||||
|
|
@ -64,11 +41,16 @@ class ParallelApply : public MpiJob
|
|||
comm.send( _masterRank, 1, ind );
|
||||
}
|
||||
|
||||
bool isFinished()
|
||||
{
|
||||
return index = size;
|
||||
}
|
||||
|
||||
protected:
|
||||
vector<EOT> & data;
|
||||
eoUF<EOT&, void>& func;
|
||||
int index;
|
||||
ParallelApplyContinuator<EOT> * pa_continuator;
|
||||
int size;
|
||||
std::map< int /* worker rank */, int /* index in vector */> assignedTasks;
|
||||
};
|
||||
|
||||
|
|
|
|||
Reference in a new issue