Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix a bug
[simgrid.git] / src / surf / workstation_interface.hpp
1 #include "surf_interface.hpp"
2 #include "storage_interface.hpp"
3 #include "cpu_interface.hpp"
4 #include "network_interface.hpp"
5
6 #ifndef SURF_WORKSTATION_INTERFACE_HPP_
7 #define SURF_WORKSTATION_INTERFACE_HPP_
8
9 /***********
10  * Classes *
11  ***********/
12
13 class WorkstationModel;
14 typedef WorkstationModel *WorkstationModelPtr;
15
16 class Workstation;
17 typedef Workstation *WorkstationPtr;
18
19 class WorkstationAction;
20 typedef WorkstationAction *WorkstationActionPtr;
21
22 /*********
23  * Tools *
24  *********/
25 extern WorkstationModelPtr surf_workstation_model;
26
27 /*********
28  * Model *
29  *********/
30 class WorkstationModel : public Model {
31 public:
32   WorkstationModel(const char *name);
33   WorkstationModel();
34   ~WorkstationModel();
35   virtual void adjustWeightOfDummyCpuActions();
36
37   virtual ActionPtr executeParallelTask(int workstation_nb,
38                                         void **workstation_list,
39                                         double *computation_amount,
40                                         double *communication_amount,
41                                         double rate)=0;
42  virtual xbt_dynar_t getRoute(WorkstationPtr src, WorkstationPtr dst)=0;
43  virtual ActionPtr communicate(WorkstationPtr src, WorkstationPtr dst, double size, double rate)=0;
44
45  CpuModelPtr p_cpuModel;
46 };
47
48 /************
49  * Resource *
50  ************/
51
52 class Workstation : public Resource {
53 public:
54   Workstation(){};
55   Workstation(ModelPtr model, const char *name, xbt_dict_t props,
56                       xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu);
57   Workstation(ModelPtr model, const char *name, xbt_dict_t props, lmm_constraint_t constraint,
58                       xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu);
59
60   xbt_dict_t getProperties();
61
62   virtual ActionPtr execute(double size)=0;
63   virtual ActionPtr sleep(double duration)=0;
64
65   virtual int getCore();
66   virtual double getSpeed(double load);
67   virtual double getAvailableSpeed();
68   virtual double getCurrentPowerPeak();
69   virtual double getPowerPeakAt(int pstate_index);
70   virtual int getNbPstates();
71   virtual void setPowerPeakAt(int pstate_index);
72   virtual double getConsumedEnergy();
73
74   virtual StoragePtr findStorageOnMountList(const char* storage);
75   virtual xbt_dict_t getStorageList();
76   virtual ActionPtr open(const char* mount, const char* path);
77   virtual ActionPtr close(surf_file_t fd);
78   virtual int unlink(surf_file_t fd);
79   virtual ActionPtr ls(const char* mount, const char *path);
80   virtual sg_size_t getSize(surf_file_t fd);
81   virtual ActionPtr read(surf_file_t fd, sg_size_t size);
82   virtual ActionPtr write(surf_file_t fd, sg_size_t size);
83   virtual xbt_dynar_t getInfo( surf_file_t fd);
84   virtual sg_size_t fileTell(surf_file_t fd);
85   virtual sg_size_t getFreeSize(const char* name);
86   virtual sg_size_t getUsedSize(const char* name);
87   virtual int fileSeek(surf_file_t fd, sg_size_t offset, int origin);
88
89   xbt_dynar_t p_storage;
90   RoutingEdgePtr p_netElm;
91   CpuPtr p_cpu;
92   NetworkLinkPtr p_network;
93
94   xbt_dynar_t getVms();
95
96   /* common with vm */
97   void getParams(ws_params_t params);
98   void setParams(ws_params_t params);
99   s_ws_params_t p_params;
100 };
101
102 /**********
103  * Action *
104  **********/
105 class WorkstationAction : public Action {
106 public:
107   WorkstationAction(ModelPtr model, double cost, bool failed)
108   : Action(model, cost, failed) {}
109   WorkstationAction(ModelPtr model, double cost, bool failed, lmm_variable_t var)
110   : Action(model, cost, failed, var) {}
111
112 };
113
114
115 #endif /* SURF_WORKSTATION_INTERFACE_HPP_ */