PaCO++  0.05
PaCO++_operation.h
Go to the documentation of this file.
00001 #ifndef PACO_PLUSPLUS_OPERATION_H_IS_DEFINED
00002 #define PACO_PLUSPLUS_OPERATION_H_IS_DEFINED
00003 
00004 #ifdef PADICO
00005 #include <Padico/Timing.h>
00006 #endif
00007 
00008 #include "PaCO++_types.h"
00009 
00010 #include <string>
00011 #include <map>
00012 #include <iostream>
00013 #include <vector>
00014 
00015 class paco_mutex;
00016 class paco_condition;
00017 class paco_com;
00018 class DistributionLibrary;
00019 class paco_comScheduling;
00020 
00021 class paco_fabrique_manager;
00022 class paco_fabrique_thread;
00023 class paco_fabrique_com;
00024 class paco_fabrique_comScheduling;
00025 
00026 #define PACO_WARN_DISTLIB
00027 
00028 // This class represent a context for a parallel operation
00029 class PaCO_operation
00030 {
00031  public:
00032   PaCO_operation(int _number_arguments);
00033   virtual ~PaCO_operation();
00034   
00035   /* External API */
00036 
00038   virtual void   setFabManager(paco_fabrique_manager* fm);
00039 
00040   /* Advanced libs part **/
00042   virtual void setComFab(paco_fabrique_com* fc);
00044   virtual void setLibCom(const string& LibCom, void * _group);
00045 
00047   virtual void setThreadFab(paco_fabrique_thread* ft);
00049   virtual void setLibThread(const string& LibThread);
00053   virtual void setComSchedulingFab(paco_fabrique_comScheduling* ft);
00055   virtual void setLibComScheduling(const string& LibComScheduling);
00059   virtual void   setDisLibArg(int arg_number, const string& lib_name, const string& way) throw(BadWayString);
00060   // Deprecated
00061   // virtual void setTypeArg(int arg_number, Pattron * temp, const string& lib_name, const string& way) throw(BadWayString);
00062   // virtual void   setMode(PaCO::distLoc_t mode, int param, const string& way) throw(BadWayString);
00063   // virtual void   initArg(PaCO::PacoInitData_t data, int nb_param, const string& way) throw(BadWayString);
00064   // virtual int    setDistribConfig(void * config, int number, const string& way) throw(BadWayString, BadWaySetStringDistribConfig);
00065   // virtual void * getDistribConfig(int number, const string& way) throw(BadWayString);
00066 
00068   virtual void setTypeClient(bool type);
00069   virtual void setClientTopo(PaCO::PacoTopology_t _client_topo, const string& way) throw(BadWayString);
00070   virtual void setClientTopo(PaCO::PacoTopology_t _client_topo);
00071   virtual void setServerTopo(PaCO::PacoTopology_t _serveur_topo, const string& way) throw(BadWayString);
00072   virtual void init(int rank, int total);  
00073 
00074   // Model -> communication matrix
00075   // Effective Schedule is hidden (reset by clearSchedule & set_beta/k)
00076   virtual void noCommunicationMemory(); // by default: compute communication & schedule info
00077   virtual void useCommunicationMemoryId(long id) throw (InvalidArgument); // save communication & scheduling info if it does not exist, use it otherwise -- SHOULD be >= 0
00078   virtual void clearCommunicationMemoryId(long id) throw (InvalidArgument); // clear this entry, nothing if unknown, exception if invalid (<0)
00079   virtual void clearScheduleMemoryId(long id) throw (InvalidArgument); // clear this entry, nothing if unknown, exception if invalid (<0)
00080 
00081   // Internal API
00082   virtual void setClientId(CORBA::Short request_uid);
00083   virtual void init_return_context(PaCO_operation * op);
00084   virtual void init_context(PaCO_operation * op);
00085   virtual void init_context_args(PaCO_operation * op);
00086   virtual void init_context_proxy(PaCO_operation * op);
00087   virtual void init_complete_context(PaCO_operation * op) { cerr << "WARNING : init_complete_context of PaCO_Operation" << endl;}
00088   virtual void configureTopo();
00089   
00090  public:
00091   int return_op;
00092   int number_arguments;
00093   int myRank;
00094   PaCO::PacoTopology_t mytopo;
00095   int number_stubs;
00096   PaCO::distLoc_t _mode;
00097   // Fabrique Manager
00098   paco_fabrique_manager * FabManager;
00099   // Thread
00100   paco_fabrique_thread * FabThread;
00101   paco_mutex * my_mutex;
00102   paco_condition * my_condition;
00103   paco_mutex * my_mutex2;
00104   paco_condition * my_condition2;
00105   paco_mutex * my_mutex3;
00106   // Communication
00107   void * group;
00108   paco_com * my_com;
00109   paco_fabrique_com * FabCom;
00110   // Distribution
00111   DistributionLibrary ** libraries_in;
00112   DistributionLibrary ** libraries_out;
00113 
00114 #ifdef PACO_WARN_DISTLIB
00115   std::vector<char*> libraries_in_name;
00116   std::vector<char*> libraries_out_name;
00117 #endif
00118 
00119   //ComSchedulr
00120   paco_comScheduling* my_comScheduling; // only for the the whole interface !!!
00121   paco_fabrique_comScheduling* FabComScheduling; 
00122   // Misc
00123   bool typeClient; // false : sequentiel, true : parallel defaut : false
00124   PaCO::PacoTopology_t serveur_topo_aller;
00125   PaCO::PacoTopology_t serveur_topo_retour;
00126   bool termine;
00127   bool termine2;
00128   CORBA::Short client_id;
00129 
00130   // Exception handling
00131   bool _exception;
00132   int _level;
00133 
00134   // SHOULD BE PRIVATE !!!
00135 
00136   long _current_id; // -1 means no not use schedule nor scheduling memory
00137 
00138   // Save communication schedule
00139   typedef struct {
00140     unsigned** com_matrix; // matrix of unsigned
00141     void***    info_vector; // vector of void**
00142   } _com_info_t;
00143   typedef map<long, _com_info_t*> _com_info_map_t;
00144   _com_info_map_t _com_info_map;     // The map of predefined communication matrices
00145   
00146   void          clearAllScheduleMemory();
00147   _com_info_t*  getComMemoryId(long id);
00148 
00149 
00150 #ifdef PADICO
00151   // For internal Timing: Padico_Timing
00152   padico_timing_t *_ticks;
00153 #endif
00154 };
00155 
00156 #endif