Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cf5f66dff2894a280547bf212944f812e4c064b9
[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
73   virtual StoragePtr findStorageOnMountList(const char* storage);
74   virtual xbt_dict_t getStorageList();
75   virtual ActionPtr open(const char* mount, const char* path);
76   virtual ActionPtr close(surf_file_t fd);
77   virtual int unlink(surf_file_t fd);
78   virtual ActionPtr ls(const char* mount, const char *path);
79   virtual sg_size_t getSize(surf_file_t fd);
80   virtual ActionPtr read(surf_file_t fd, sg_size_t size);
81   virtual ActionPtr write(surf_file_t fd, sg_size_t size);
82   virtual xbt_dynar_t getInfo( surf_file_t fd);
83   virtual sg_size_t fileTell(surf_file_t fd);
84   virtual sg_size_t getFreeSize(const char* name);
85   virtual sg_size_t getUsedSize(const char* name);
86   virtual int fileSeek(surf_file_t fd, sg_size_t offset, int origin);
87
88   xbt_dynar_t p_storage;
89   RoutingEdgePtr p_netElm;
90   CpuPtr p_cpu;
91   NetworkLinkPtr p_network;
92
93   xbt_dynar_t getVms();
94
95   /* common with vm */
96   void getParams(ws_params_t params);
97   void setParams(ws_params_t params);
98   s_ws_params_t p_params;
99 };
100
101 /**********
102  * Action *
103  **********/
104 class WorkstationAction : public Action {
105 public:
106   WorkstationAction(ModelPtr model, double cost, bool failed)
107   : Action(model, cost, failed) {}
108   WorkstationAction(ModelPtr model, double cost, bool failed, lmm_variable_t var)
109   : Action(model, cost, failed, var) {}
110
111 };
112
113
114 #endif /* SURF_WORKSTATION_INTERFACE_HPP_ */