1 /* Copyright (c) 2004-2013. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "surf_interface.hpp"
8 #include "storage_interface.hpp"
9 #include "cpu_interface.hpp"
10 #include "network_interface.hpp"
12 #ifndef SURF_WORKSTATION_INTERFACE_HPP_
13 #define SURF_WORKSTATION_INTERFACE_HPP_
19 class WorkstationModel;
20 typedef WorkstationModel *WorkstationModelPtr;
23 typedef Workstation *WorkstationPtr;
25 class WorkstationAction;
26 typedef WorkstationAction *WorkstationActionPtr;
31 extern WorkstationModelPtr surf_workstation_model;
36 /** @ingroup SURF_workstation_interface
37 * @brief SURF Workstation model interface class
38 * @details A model is an object which handle the interactions between its Resources and its Actions
40 class WorkstationModel : public Model {
43 * @brief WorkstationModel constructor
45 * @param name the name of the model
47 WorkstationModel(const char *name);
50 * @brief WorkstationModel constructor
55 * @brief WorkstationModel destructor
60 * @brief [brief description]
61 * @details [long description]
63 virtual void adjustWeightOfDummyCpuActions();
66 * @brief [brief description]
67 * @details [long description]
69 * @param workstation_nb [description]
70 * @param workstation_list [description]
71 * @param computation_amount [description]
72 * @param communication_amount [description]
73 * @param rate [description]
74 * @return [description]
76 virtual ActionPtr executeParallelTask(int workstation_nb,
77 void **workstation_list,
78 double *computation_amount,
79 double *communication_amount,
83 * @brief [brief description]
84 * @details [long description]
86 * @param src [description]
87 * @param dst [description]
89 * @return [description]
91 virtual xbt_dynar_t getRoute(WorkstationPtr src, WorkstationPtr dst)=0;
94 * @brief [brief description]
95 * @details [long description]
97 * @param src [description]
98 * @param dst [description]
99 * @param size [description]
100 * @param rate [description]
101 * @return [description]
103 virtual ActionPtr communicate(WorkstationPtr src, WorkstationPtr dst, double size, double rate)=0;
105 CpuModelPtr p_cpuModel;
111 /** @ingroup SURF_workstation_interface
112 * @brief SURF Workstation interface class
113 * @details A workstation VM represent an virtual machine with a aggregation of a Cpu, a NetworkLink and a Storage
115 class Workstation : public Resource {
118 * @brief Workstation consrtuctor
119 * @details [long description]
124 * @brief Workstation constructor
126 * @param model WorkstationModel associated to this Workstation
127 * @param name The name of the Workstation
128 * @param props Dictionary of properties associated to this Workstation
129 * @param storage The Storage associated to this Workstation
130 * @param netElm The RoutingEdge associated to this Workstation
131 * @param cpu The Cpu associated to this Workstation
133 Workstation(ModelPtr model, const char *name, xbt_dict_t props,
134 xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu);
137 * @brief Workstation constructor
139 * @param model WorkstationModel associated to this Workstation
140 * @param name The name of the Workstation
141 * @param props Dictionary of properties associated to this Workstation
142 * @param constraint The lmm constraint associated to this Workstation if it is part of a LMM component
143 * @param storage The Storage associated to this Workstation
144 * @param netElm The RoutingEdge associated to this Workstation
145 * @param cpu The Cpu associated to this Workstation
147 Workstation(ModelPtr model, const char *name, xbt_dict_t props, lmm_constraint_t constraint,
148 xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu);
151 * @brief Get the properties of the currenrt Workstation
153 * @return The properties of the current Workstation
155 xbt_dict_t getProperties();
158 * @brief Execute some quantity of computation
160 * @param size The value of the processing amount (in flop) needed to process
161 * @return The CpuAction corresponding to the processing
164 virtual ActionPtr execute(double size)=0;
167 * @brief Make a process sleep for duration seconds
169 * @param duration The number of seconds to sleep
170 * @return The CpuAction corresponding to the sleeping
173 virtual ActionPtr sleep(double duration)=0;
176 * @brief Get the number of cores of the associated Cpu
178 * @return The number of cores of the associated Cpu
181 virtual int getCore();
184 * @brief Get the speed of the associated Cpu
187 * @return The speed of the associated Cpu
190 virtual double getSpeed(double load);
193 * @brief Get the available speed of the associated Cpu
196 * @return The available speed of the associated Cpu
199 virtual double getAvailableSpeed();
202 * @brief Get the associated Cpu power peak
204 * @return The associated Cpu power peak
207 virtual double getCurrentPowerPeak();
209 virtual double getPowerPeakAt(int pstate_index);
210 virtual int getNbPstates();
211 virtual void setPowerPeakAt(int pstate_index);
214 * @brief Return the storage of corresponding mount point
216 * @param storage The mount point
217 * @return The corresponding Storage
219 virtual StoragePtr findStorageOnMountList(const char* storage);
222 * @brief Get the xbt_dict_t of mount_point: Storage
224 * @return The xbt_dict_t of mount_point: Storage
226 virtual xbt_dict_t getStorageList();
231 * @param mount The mount point
232 * @param path The path to the file
234 * @return The StorageAction corresponding to the opening
236 virtual ActionPtr open(const char* mount, const char* path);
239 * @brief Close a file
241 * @param fd The file descriptor to close
242 * @return The StorageAction corresponding to the closing
244 virtual ActionPtr close(surf_file_t fd);
247 * @brief Unlink a file
248 * @details [long description]
250 * @param fd [description]
251 * @return [description]
253 virtual int unlink(surf_file_t fd);
256 * @brief List directory contents of a path
257 * @details [long description]
259 * @param path The path to the directory
260 * @return The StorageAction corresponding to the ls action
262 virtual ActionPtr ls(const char* mount, const char *path);
265 * @brief Get the size in bytes of the file
267 * @param fd The file descriptor to read
268 * @return The size in bytes of the file
270 virtual sg_size_t getSize(surf_file_t fd);
275 * @param fd The file descriptor to read
276 * @param size The size in bytes to read
277 * @return The StorageAction corresponding to the reading
279 virtual ActionPtr read(surf_file_t fd, sg_size_t size);
282 * @brief Write a file
284 * @param fd The file descriptor to write
285 * @param size The size in bytes to write
286 * @return The StorageAction corresponding to the writing
288 virtual ActionPtr write(surf_file_t fd, sg_size_t size);
291 * @brief Get the informations of a file descriptor
292 * @details The returned xbt_dynar_t contains:
293 * - the size of the file,
295 * - the storage name,
296 * - the storage typeId,
297 * - the storage content type
299 * @param fd The file descriptor
300 * @return An xbt_dynar_t with the file informations
302 virtual xbt_dynar_t getInfo(surf_file_t fd);
305 * @brief Get the current position of the file descriptor
307 * @param fd The file descriptor
308 * @return The current position of the file descriptor
310 virtual sg_size_t fileTell(surf_file_t fd);
313 * @brief Get the available space of the storage at the mount point
315 * @param name The mount point
316 * @return The amount of availble space in bytes
318 virtual sg_size_t getFreeSize(const char* name);
321 * @brief Get the used space of the storage at the mount point
323 * @param name The mount point
324 * @return The amount of used space in bytes
326 virtual sg_size_t getUsedSize(const char* name);
329 * @brief Set the position indictator assiociated with the file descriptor to a new position
330 * @details [long description]
332 * @param fd The file descriptor
333 * @param offset The offset from the origin
334 * @param origin Position used as a reference for the offset
335 * - SEEK_SET: beginning of the file
336 * - SEEK_CUR: current position indicator
337 * - SEEK_END: end of the file
338 * @return MSG_OK if successful, otherwise MSG_TASK_CANCELED
340 virtual int fileSeek(surf_file_t fd, sg_size_t offset, int origin);
342 xbt_dynar_t p_storage;
343 RoutingEdgePtr p_netElm;
345 NetworkLinkPtr p_network;
348 * @brief Get the list of virtual machines on the current Workstation
350 * @return The list of VMs
352 xbt_dynar_t getVms();
356 * @brief [brief description]
357 * @details [long description]
359 * @param params [description]
361 void getParams(ws_params_t params);
364 * @brief [brief description]
365 * @details [long description]
367 * @param params [description]
369 void setParams(ws_params_t params);
370 s_ws_params_t p_params;
376 /** @ingroup SURF_workstation_interface
377 * @brief SURF workstation action interface class
379 class WorkstationAction : public Action {
382 * @brief WorkstationAction constructor
384 * @param model The WorkstationModel associated to this WorkstationAction
385 * @param cost The cost of this WorkstationAction in [TODO]
386 * @param failed [description]
388 WorkstationAction(ModelPtr model, double cost, bool failed)
389 : Action(model, cost, failed) {}
392 * @brief WorkstationAction constructor
394 * @param model The WorkstationModel associated to this WorkstationAction
395 * @param cost The cost of this WorkstationAction in [TODO]
396 * @param failed [description]
397 * @param var The lmm variable associated to this StorageAction if it is part of a LMM component
399 WorkstationAction(ModelPtr model, double cost, bool failed, lmm_variable_t var)
400 : Action(model, cost, failed, var) {}
405 #endif /* SURF_WORKSTATION_INTERFACE_HPP_ */