00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00055 #ifndef __vtkMultiProcessController_h
00056 #define __vtkMultiProcessController_h
00057
00058 #include "vtkObject.h"
00059 #include "vtkDataObject.h"
00060 class vtkDataSet;
00061 class vtkImageData;
00062 class vtkCollection;
00063
00064
00065 #define VTK_MP_CONTROLLER_MAX_PROCESSES 1024
00066 #define VTK_MP_CONTROLLER_ANY_SOURCE -1
00067 #define VTK_MP_CONTROLLER_INVALID_SOURCE -2
00068
00069
00070 #define VTK_MP_CONTROLLER_RMI_TAG 315167
00071 #define VTK_MP_CONTROLLER_RMI_ARG_TAG 315168
00072
00073
00074
00075 #define VTK_BREAK_RMI_TAG 239954
00076
00077
00078 class vtkMultiProcessController;
00079
00080
00081
00082
00083 typedef void (*vtkProcessFunctionType)(vtkMultiProcessController *controller,
00084 void *userData);
00085
00086
00087 typedef void (*vtkRMIFunctionType)(void *localArg,
00088 void *remoteArg, int remoteArgLength,
00089 int remoteProcessId);
00090
00091
00092
00093 class VTK_EXPORT vtkMultiProcessController : public vtkObject
00094 {
00095 public:
00096 static vtkMultiProcessController *New();
00097 vtkTypeMacro(vtkMultiProcessController,vtkObject);
00098 void PrintSelf(ostream& os, vtkIndent indent);
00099
00103 virtual void Initialize(int vtkNotUsed(argc), char *arcv[]) {arcv=arcv;}
00104
00108 virtual void SetNumberOfProcesses(int num);
00109 vtkGetMacro( NumberOfProcesses, int );
00110
00111
00115 void SetSingleMethod(vtkProcessFunctionType, void *data);
00116
00117
00121 virtual void SingleMethodExecute() = 0;
00122
00123
00128 void SetMultipleMethod(int index, vtkProcessFunctionType, void *data);
00129
00130
00134 virtual void MultipleMethodExecute() = 0;
00135
00137 virtual int GetLocalProcessId() { return this->LocalProcessId; }
00138
00143 static vtkMultiProcessController *GetGlobalController();
00144
00145
00146
00149 virtual int Send(vtkDataObject *data, int remoteProcessId, int tag);
00150
00152 virtual int Send(int *data, int length, int remoteProcessId, int tag) = 0;
00153 virtual int Send(unsigned long *data, int length,
00154 int remoteProcessId, int tag) = 0;
00155 virtual int Send(char *data, int length,
00156 int remoteProcessId, int tag) = 0;
00157 virtual int Send(float *data, int length,
00158 int remoteProcessId, int tag) = 0;
00159
00162 virtual int Receive(vtkDataObject *data, int remoteProcessId, int tag);
00163
00167 virtual int Receive(int *data, int length, int remoteProcessId, int tag) = 0;
00168 virtual int Receive(unsigned long *data, int length,
00169 int remoteProcessId, int tag) = 0;
00170 virtual int Receive(char *data, int length,
00171 int remoteProcessId, int tag) = 0;
00172 virtual int Receive(float *data, int length,
00173 int remoteProcessId, int tag) = 0;
00174
00180 vtkSetMacro(ForceDeepCopy, int);
00181 vtkGetMacro(ForceDeepCopy, int);
00182 vtkBooleanMacro(ForceDeepCopy, int);
00183
00184
00185
00191 void AddRMI(vtkRMIFunctionType, void *localArg, int tag);
00192
00194 void RemoveRMI(vtkRMIFunctionType f, void *arg, int tag)
00195 {f = f; arg = arg; tag = tag; vtkErrorMacro("RemoveRMI Not Implemented Yet");};
00196
00197
00199 void TriggerRMI(int remoteProcessId, void *arg, int argLength, int tag);
00200
00202 void TriggerRMI(int remoteProcessId, char *arg, int tag)
00203 { this->TriggerRMI(remoteProcessId, (void*)arg, strlen(arg)+1, tag); }
00204
00206 void TriggerRMI(int remoteProcessId, int tag)
00207 { this->TriggerRMI(remoteProcessId, NULL, 0, tag); }
00208
00211 void ProcessRMIs();
00212
00216 vtkSetMacro(BreakFlag, int);
00217 vtkGetMacro(BreakFlag, int);
00218
00219
00222 vtkGetMacro(WriteTime, float);
00223 vtkGetMacro(ReadTime, float);
00224 vtkGetMacro(SendWaitTime, float);
00225 vtkGetMacro(SendTime, float);
00226 vtkGetMacro(ReceiveWaitTime, float);
00227 vtkGetMacro(ReceiveTime, float);
00228
00229 protected:
00230 vtkMultiProcessController();
00231 ~vtkMultiProcessController();
00232 vtkMultiProcessController(const vtkMultiProcessController&) {};
00233 void operator=(const vtkMultiProcessController&) {};
00234
00235 int MaximumNumberOfProcesses;
00236 int NumberOfProcesses;
00237
00238
00239 int LocalProcessId;
00240
00241 vtkProcessFunctionType SingleMethod;
00242 void *SingleData;
00243 vtkProcessFunctionType MultipleMethod[VTK_MP_CONTROLLER_MAX_PROCESSES];
00244 void *MultipleData[VTK_MP_CONTROLLER_MAX_PROCESSES];
00245
00246 vtkCollection *RMIs;
00247
00248 char *MarshalString;
00249 int MarshalStringLength;
00250
00251 int MarshalDataLength;
00252
00253
00254
00255 int BreakFlag;
00256
00257
00258 void DeleteAndSetMarshalString(char *str, int strLength);
00259
00260
00261
00262 int WriteObject(vtkDataObject *object);
00263 int ReadObject(vtkDataObject *object);
00264
00265 int WriteDataSet(vtkDataSet *object);
00266 int ReadDataSet(vtkDataSet *object);
00267
00268 int WriteImageData(vtkImageData *object);
00269 int ReadImageData(vtkImageData *object);
00270
00271 void ProcessRMI(int remoteProcessId, void *arg, int argLength, int rmiTag);
00272
00273
00274
00275 virtual vtkMultiProcessController *GetLocalController();
00276
00277
00278 virtual void SetGlobalController(vtkMultiProcessController *controller);
00279
00280 float ReadTime;
00281 float WriteTime;
00282
00283 float SendWaitTime;
00284 float SendTime;
00285 float ReceiveWaitTime;
00286 float ReceiveTime;
00287
00288
00289 int ForceDeepCopy;
00290 };
00291
00292
00293 #endif
00294
00295
00296
00297
00298
00299
00300
00301
00302