00001
00002 #ifndef _DATASERVERMPI_H_
00003 #define _DATASERVERMPI_H_
00004
00005 #include "dataserver.h"
00006
00007 class DataServerMPI : public DataServer
00008 {
00009 private:
00010 int comm_dataserver;
00011 int numCPUs;
00012 int procID;
00013 int portNum;
00014 bool isMaster()
00015 { return (procID == 0); }
00016 void Barrier();
00017 void BroadcastData(void *var, int size);
00018 bool isRunningMPI()
00019 { return true; }
00020 int RegisterInternal(char *keyword, RemoteSocket *C, int &error_flag, bool register_flag = false);
00021
00022
00023
00024
00025 public:
00026 DataServerMPI();
00027 DataServerMPI(int port);
00028 int Start(int port = 4096);
00029 ~DataServerMPI();
00030 int Wait(char *key);
00031 int Post(char *key);
00032 int Synchronize(char *filename = NULL);
00033 template <class Etype>
00034 Etype Update(Etype *var);
00035 template <class Etype>
00036 Etype Update(Etype var);
00037 };
00038
00039 template <class Etype>
00040 Etype DataServerMPI::Update(Etype *var)
00041 {
00042 BroadcastVariable(var);
00043
00044 return *var;
00045 }
00046
00047 template <class Etype>
00048 Etype DataServerMPI::Update(Etype var)
00049 {
00050 Etype v = var;
00051 BroadcastVariable(&v);
00052
00053 return v;
00054 }
00055
00056 #endif // _DATASERVERMPI_H_
00057