Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

SgMpiSynchronizer.h

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 /** @file SgMpiSynchronizer.h */
00003 //----------------------------------------------------------------------------
00004 
00005 #ifndef SG_MPISYNCHRONIZER_H
00006 #define SG_MPISYNCHRONIZER_H
00007 
00008 #include <iostream>
00009 #include <string>
00010 #include <boost/shared_ptr.hpp>
00011 #include "SgMove.h"
00012 #include "SgUctValue.h"
00013 
00014 //----------------------------------------------------------------------------
00015 
00016 class SgUctSearch;
00017 
00018 class SgUctThreadState;
00019 
00020 struct SgUctGameInfo;
00021 
00022 /** Interface for mpi synchronizers.
00023     @note This class and related functions are needed for the way the cluster
00024     version of Fuego, BlueFuego, is currently implemented. The design is under
00025     dispute, because it causes intrusive changes to other classes and breaks
00026     encapsulation of their implementation.
00027     See http://sourceforge.net/apps/trac/fuego/ticket/32 for details. */
00028 class SgMpiSynchronizer 
00029 {
00030 public:
00031     virtual ~SgMpiSynchronizer();
00032 
00033     virtual std::string ToNodeFilename(const std::string &filename) const = 0;
00034 
00035     virtual bool IsRootProcess() const = 0;
00036 
00037     virtual void OnStartSearch(SgUctSearch &search) = 0;
00038     
00039     virtual void OnEndSearch(SgUctSearch &search) = 0;
00040 
00041     virtual void OnThreadStartSearch(SgUctSearch &search, 
00042                                      SgUctThreadState &state) = 0;
00043 
00044     virtual void OnThreadEndSearch(SgUctSearch &search, 
00045                                    SgUctThreadState &state) = 0;
00046 
00047     virtual void OnSearchIteration(SgUctSearch &search, 
00048                                    SgUctValue gameNumber,
00049                                    int threadId, 
00050                                    const SgUctGameInfo& info) = 0;
00051 
00052     virtual void OnStartPonder() = 0;
00053 
00054     virtual void OnEndPonder() = 0;
00055 
00056     virtual void WriteStatistics(std::ostream& out) const = 0;
00057 
00058     virtual void SynchronizeUserAbort(bool &flag) = 0;
00059 
00060     virtual void SynchronizePassWins(bool &flag) = 0;
00061 
00062     virtual void SynchronizeEarlyPassPossible(bool &flag) = 0;
00063 
00064     virtual void SynchronizeMove(SgMove &move) = 0;
00065 
00066     virtual void SynchronizeValue(SgUctValue &value) = 0;
00067 
00068     virtual void SynchronizeSearchStatus(SgUctValue &value, bool &earlyAbort, 
00069                                          SgUctValue &rootMoveCount) = 0;
00070 };
00071 
00072 typedef boost::shared_ptr<SgMpiSynchronizer> SgMpiSynchronizerHandle;
00073 
00074 //----------------------------------------------------------------------------
00075 
00076 /** Synchronizer with empty implementation. */
00077 class SgMpiNullSynchronizer : public SgMpiSynchronizer 
00078 {
00079 public:
00080     SgMpiNullSynchronizer();
00081 
00082     virtual ~SgMpiNullSynchronizer();
00083 
00084     static SgMpiSynchronizerHandle Create();
00085 
00086     virtual std::string ToNodeFilename(const std::string &filename) const;
00087 
00088     virtual bool IsRootProcess() const;
00089 
00090     virtual void OnStartSearch(SgUctSearch &search);
00091     
00092     virtual void OnEndSearch(SgUctSearch &search);
00093 
00094     virtual void OnThreadStartSearch(SgUctSearch &search, 
00095                                      SgUctThreadState &state);
00096 
00097     virtual void OnThreadEndSearch(SgUctSearch &search, 
00098                                    SgUctThreadState &state);
00099 
00100     virtual void OnSearchIteration(SgUctSearch &search, SgUctValue gameNumber,
00101                                    int threadId, const SgUctGameInfo& info);
00102 
00103     virtual void OnStartPonder();
00104 
00105     virtual void OnEndPonder();
00106 
00107     virtual void WriteStatistics(std::ostream& out) const;
00108     
00109     virtual void SynchronizeUserAbort(bool &flag);
00110 
00111     virtual void SynchronizePassWins(bool &flag);
00112 
00113     virtual void SynchronizeEarlyPassPossible(bool &flag);
00114 
00115     virtual void SynchronizeMove(SgMove &move);
00116 
00117     virtual void SynchronizeValue(SgUctValue &value);
00118 
00119     virtual void SynchronizeSearchStatus(SgUctValue &value, bool &earlyAbort, 
00120                                          SgUctValue &rootMoveCount);
00121 
00122 };
00123 
00124 // Ensure forward definitions
00125 // are eventually declared
00126 #include "SgUctSearch.h"
00127 
00128 //----------------------------------------------------------------------------
00129 
00130 #endif // SG_MPISYNCHRONIZER_H


Sun Mar 13 2011 Doxygen 1.7.1