# ifndef __EO_PARALLEL_APPLY_H__ # define __EO_PARALLEL_APPLY_H__ # include "eompi.h" # include # include template< typename EOT > class ParallelApply : public MpiJob< EOT > { public: ParallelApply( eoUF & _proc, std::vector& _pop ) : MpiJob( _pop ), func( _proc ) { // empty } virtual void sendTask( int wrkRank, int index ) { MpiJob::comm.send( wrkRank, 1, MpiJob::data[ index ] ); } virtual void handleResponse( int wrkRank, int index ) { MpiJob::comm.recv( wrkRank, 1, MpiJob::data[ index ] ); } virtual void processTask( ) { EOT ind; cout << "Receiving individual." << endl; MpiJob::comm.recv( 0, 1, ind ); cout << "Applying function." << endl; func( ind ); cout << "Sending result." << endl; MpiJob::comm.send( 0, 1, ind ); cout << "Leaving processTask" << endl; } protected: eoUF& func; }; # endif // __EO_PARALLEL_APPLY_H__