X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/51f8d73fe7373b7b04bc2727ff9ef61272dce9a9..0841b4cd80e970dd2f13692db9f938e5a8f90317:/src/surf/surf.hpp diff --git a/src/surf/surf.hpp b/src/surf/surf.hpp index d6c462e5f7..31d4a344b4 100644 --- a/src/surf/surf.hpp +++ b/src/surf/surf.hpp @@ -7,43 +7,112 @@ #include #include #include -#include #include -#include -#include #include "surf/trace_mgr.h" +#include "xbt/lib.h" +#include "surf/surf_routing.h" +#include "simgrid/platf_interface.h" +#include "surf/surf.h" +#include "surf/surf_private.h" extern tmgr_history_t history; +#define NO_MAX_DURATION -1.0 using namespace std; +/** \ingroup SURF_simulation + * \brief Return the current time + * + * Return the current time in millisecond. + */ + +/********* + * Utils * + *********/ + +/* user-visible parameters */ +extern double sg_tcp_gamma; +extern double sg_sender_gap; +extern double sg_latency_factor; +extern double sg_bandwidth_factor; +extern double sg_weight_S_parameter; +extern int sg_network_crosstraffic; +#ifdef HAVE_GTNETS +extern double sg_gtnets_jitter; +extern int sg_gtnets_jitter_seed; +#endif +extern xbt_dynar_t surf_path; + +#ifdef __cplusplus +extern "C" { +#endif +XBT_PUBLIC(double) surf_get_clock(void); +#ifdef __cplusplus +} +#endif + +extern double sg_sender_gap; +XBT_PUBLIC(int) SURF_CPU_LEVEL; //Surf cpu level + +int __surf_is_absolute_file_path(const char *file_path); + /*********** * Classes * ***********/ -class Model; +//class Model; typedef Model* ModelPtr; -class Resource; +//class Resource; typedef Resource* ResourcePtr; typedef boost::function ResourceCallback; -class Action; +//class Action; typedef Action* ActionPtr; typedef boost::function ActionCallback; +//class ActionLmm; +typedef ActionLmm* ActionLmmPtr; + +enum heap_action_type{ + LATENCY = 100, + MAX_DURATION, + NORMAL, + NOTSET +}; + +/********* + * Trace * + *********/ +/* For the trace and trace:connect tag (store their content till the end of the parsing) */ +XBT_PUBLIC_DATA(xbt_dict_t) traces_set_list; +XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_host_avail; +XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_power; +XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_link_avail; +XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_bandwidth; +XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_latency; + + /********* * Model * *********/ +XBT_PUBLIC_DATA(xbt_dynar_t) model_list; + class Model { public: - Model(string name) { - m_name = name; - m_resOnCB = m_resOffCB= 0; - m_actSuspendCB = m_actCancelCB = m_actResumeCB = 0; - } - virtual ~Model() {} + Model(string name); + virtual ~Model(); + ResourcePtr createResource(string name); ActionPtr createAction(double _cost, bool _failed); + virtual double shareResources(double now); + virtual double shareResourcesLazy(double now); + virtual double shareResourcesFull(double now); + double shareResourcesMaxMin(xbt_swag_t running_actions, + lmm_system_t sys, + void (*solve) (lmm_system_t)); + virtual void updateActionsState(double now, double delta); + virtual void updateActionsStateLazy(double now, double delta); + virtual void updateActionsStateFull(double now, double delta); string getName() {return m_name;}; @@ -60,16 +129,22 @@ public: void addActionSuspendCallback(ActionCallback ac); void notifyActionSuspend(ActionPtr a); + lmm_system_t p_maxminSystem; + e_UM_t p_updateMechanism; + xbt_swag_t p_modifiedSet; + xbt_heap_t p_actionHeap; + int m_selectiveUpdate; + xbt_swag_t p_readyActionSet; /**< Actions in state SURF_ACTION_READY */ - xbt_swag_t runningActionSet; /**< Actions in state SURF_ACTION_RUNNING */ - xbt_swag_t failedActionSet; /**< Actions in state SURF_ACTION_FAILED */ - xbt_swag_t doneActionSet; /**< Actions in state SURF_ACTION_DONE */ + xbt_swag_t p_runningActionSet; /**< Actions in state SURF_ACTION_RUNNING */ + xbt_swag_t p_failedActionSet; /**< Actions in state SURF_ACTION_FAILED */ + xbt_swag_t p_doneActionSet; /**< Actions in state SURF_ACTION_DONE */ + string m_name; protected: std::vector m_failedActions, m_runningActions; private: - string m_name; ResourceCallback m_resOnCB, m_resOffCB; ActionCallback m_actCancelCB, m_actSuspendCB, m_actResumeCB; }; @@ -77,95 +152,126 @@ private: /************ * Resource * ************/ + +/** + * Resource which have a metric handled by a maxmin system + */ +typedef struct { + double scale; + double peak; + tmgr_trace_event_t event; +} s_surf_metric_t; + class Resource { public: - Resource(ModelPtr model, string name, xbt_dict_t properties): - m_name(name),m_running(true),p_model(model),m_properties(properties) {}; + Resource(); + Resource(ModelPtr model, const char *name, xbt_dict_t properties); virtual ~Resource() {}; + virtual void updateState(tmgr_trace_event_t event_type, double value, double date)=0; + + //private + virtual bool isUsed()=0; + //FIXME:updateActionState(); + //FIXME:updateResourceState(); + //FIXME:finilize(); + bool isOn(); void turnOn(); void turnOff(); void setName(string name); - string getName(); + const char *getName(); + virtual xbt_dict_t getProperties(); + ModelPtr getModel() {return p_model;}; + virtual e_surf_resource_state_t getState(); + virtual void setState(e_surf_resource_state_t state); void printModel() { std::cout << p_model->getName() << "<