src/surf/simgrid_dtd.c
src/surf/storage_interface.hpp
src/surf/storage_n11.hpp
- src/surf/surf.hpp
+ src/surf/surf_interface.hpp
src/surf/surf_private.h
src/surf/surf_routing_private.hpp
src/surf/surf_routing.hpp
src/surf/surf_routing_vivaldi.hpp
src/surf/surfxml_parse.c
src/surf/trace_mgr_private.h
- src/surf/vm_workstation.hpp
- src/surf/workstation.hpp
+ src/surf/vm_workstation_interface.hpp
+ src/surf/vm_workstation_hl13.hpp
+ src/surf/workstation_interface.hpp
+ src/surf/workstation_clm03.hpp
src/surf/workstation_ptask_L07.hpp
src/win32/config.h
src/xbt/automaton/automaton_lexer.yy.c
src/surf/sg_platf.c
src/surf/storage_interface.cpp
src/surf/storage_n11.cpp
- src/surf/surf.cpp
+ src/surf/surf_interface.cpp
src/surf/surf_c_bindings.cpp
src/surf/surf_routing.cpp
src/surf/surf_routing_cluster.cpp
src/surf/surfxml_parse.c
src/surf/surfxml_parseplatf.c
src/surf/trace_mgr.c
- src/surf/workstation.cpp
+ src/surf/workstation_interface.cpp
+ src/surf/workstation_clm03.cpp
src/surf/workstation_ptask_L07.cpp
- src/surf/vm_workstation.cpp
+ src/surf/vm_workstation_interface.cpp
+ src/surf/vm_workstation_hl13.cpp
src/xbt/xbt_sg_stubs.c
)
#include "cpu_cas01.hpp"
#include "cpu_ti.hpp"
-#include "surf.hpp"
#include "maxmin_private.h"
#include "simgrid/sg_config.h"
-#include "surf.hpp"
+#include "surf_interface.hpp"
#include "maxmin_private.h"
-#ifndef SURF_MODEL_CPU_H_
-#define SURF_MODEL_CPU_H_
+#ifndef SURF_CPU_INTERFACE_HPP_
+#define SURF_CPU_INTERFACE_HPP_
/***********
* Classes *
};
-#endif /* SURF_MODEL_CPU_H_ */
+#endif /* SURF_CPU_INTERFACE_HPP_ */
* Created on: Nov 29, 2013
* Author: bedaride
*/
-#include "surf.hpp"
+#include "surf_interface.hpp"
#include "surf_routing.hpp"
#ifndef SURF_NETWORK_INTERFACE_HPP_
-#include "surf.hpp"
+#include "surf_interface.hpp"
#ifndef STORAGE_INTERFACE_HPP_
#define STORAGE_INTERFACE_HPP_
-#include "surf.hpp"
-#include "workstation.hpp"
-#include "vm_workstation.hpp"
+#include "surf_interface.hpp"
+#include "workstation_interface.hpp"
+#include "vm_workstation_interface.hpp"
#include "network_interface.hpp"
#include "surf_routing_cluster.hpp"
#include "instr/instr_private.h"
return dynamic_cast<CpuPtr>(static_cast<ResourcePtr>(surf_cpu_resource_priv(resource)));
}
-static WorkstationCLM03Ptr get_casted_workstation(surf_resource_t resource){
- return dynamic_cast<WorkstationCLM03Ptr>(static_cast<ResourcePtr>(surf_workstation_resource_priv(resource)));
+static WorkstationPtr get_casted_workstation(surf_resource_t resource){
+ return dynamic_cast<WorkstationPtr>(static_cast<ResourcePtr>(surf_workstation_resource_priv(resource)));
}
-static WorkstationVM2013Ptr get_casted_vm_workstation(surf_resource_t resource){
- return dynamic_cast<WorkstationVM2013Ptr>(static_cast<ResourcePtr>(surf_workstation_resource_priv(resource)));
+static WorkstationVMPtr get_casted_vm_workstation(surf_resource_t resource){
+ return dynamic_cast<WorkstationVMPtr>(static_cast<ResourcePtr>(surf_workstation_resource_priv(resource)));
}
char *surf_routing_edge_name(sg_routing_edge_t edge){
}
#ifdef CONTEXT_THREADS
-static xbt_parmap_t surf_parmap = NULL; /* parallel map on models */
+//FIXME:keeporremove static xbt_parmap_t surf_parmap = NULL; /* parallel map on models */
#endif
extern double NOW;
#include "surf_private.h"
-#include "surf.hpp"
+#include "surf_interface.hpp"
#include "network_interface.hpp"
#include "cpu_interface.hpp"
-#include "workstation.hpp"
-#include "vm_workstation.hpp"
+#include "workstation_interface.hpp"
+#include "vm_workstation_interface.hpp"
#include "simix/smx_host_private.h"
#include "surf_routing.hpp"
#include "simgrid/sg_config.h"
static XBT_INLINE void surf_workstation_free(void *r)
{
- delete dynamic_cast<WorkstationCLM03Ptr>(static_cast<ResourcePtr>(r));
+ delete dynamic_cast<WorkstationPtr>(static_cast<ResourcePtr>(r));
}
"SURF_ACTION_NOT_IN_THE_SYSTEM"
};
-Action::Action(){}
-
-Action::Action(ModelPtr model, double cost, bool failed):
- m_priority(1.0),
- m_failed(failed),
- m_start(surf_get_clock()), m_finish(-1.0),
- m_remains(cost),
- m_maxDuration(NO_MAX_DURATION),
- m_cost(cost),
- p_model(model),
- m_refcount(1),
- p_data(NULL)
+Action::Action()
+: m_refcount(1)
+{}
+
+Action::Action(ModelPtr model, double cost, bool failed)
+ : m_priority(1.0)
+ , m_failed(failed)
+ , m_start(surf_get_clock()), m_finish(-1.0)
+ , m_remains(cost)
+ , m_maxDuration(NO_MAX_DURATION)
+ , m_cost(cost)
+ , p_model(model)
+ , m_refcount(1)
+ , p_data(NULL)
{
#ifdef HAVE_TRACING
p_category = NULL;
Model(string name);
virtual ~Model();
- ResourcePtr createResource(string name);
+ //ResourcePtr createResource(string name);
ActionPtr createAction(double _cost, bool _failed);
virtual double shareResources(double now);
virtual double shareResourcesLazy(double now);
-#include "surf.hpp"
+#include "surf_interface.hpp"
#include <float.h>
#ifndef NETWORK_ROUTING_HPP_
#include <float.h>
#include "internal_config.h"
-#include "surf.hpp"
+#include "surf_interface.hpp"
#include "xbt/dynar.h"
#include "xbt/str.h"
#include "xbt/config.h"
+++ /dev/null
-/*
- * vm_workstation.hpp
- *
- * Created on: Nov 12, 2013
- * Author: bedaride
- */
-#include "workstation.hpp"
-
-#ifndef VM_WORKSTATION_HPP_
-#define VM_WORKSTATION_HPP_
-
-#define GUESTOS_NOISE 100 // This value corresponds to the cost of the global action associated to the VM
- // It corresponds to the cost of a VM running no tasks.
-
-void surf_vm_workstation_model_init(void);
-
-/*
- void (*create) (const char *name, void *ind_phys_workstation); // First operation of the VM model
- void (*destroy) (void *ind_vm_ws); // will be vm_ws_destroy(), which destroies the vm-workstation-specific data
-
- void (*suspend) (void *ind_vm_ws);
- void (*resume) (void *ind_vm_ws);
-
- void (*save) (void *ind_vm_ws);
- void (*restore) (void *ind_vm_ws);
-
- void (*migrate) (void *ind_vm_ws, void *ind_vm_ws_dest); // will be vm_ws_migrate()
-
- int (*get_state) (void *ind_vm_ws);
- void (*set_state) (void *ind_vm_ws, int state);
-
- void * (*get_pm) (void *ind_vm_ws); // will be vm_ws_get_pm()
-
- void (*set_vm_bound) (void *ind_vm_ws, double bound); // will be vm_ws_set_vm_bound()
- void (*set_vm_affinity) (void *ind_vm_ws, void *ind_pm_ws, unsigned long mask); // will be vm_ws_set_vm_affinity()
-*/
-
-/***********
- * Classes *
- ***********/
-
-class WorkstationVMModel;
-typedef WorkstationVMModel *WorkstationVMModelPtr;
-
-class WorkstationVM2013;
-typedef WorkstationVM2013 *WorkstationVM2013Ptr;
-
-class WorkstationVM2013Lmm;
-typedef WorkstationVM2013Lmm *WorkstationVM2013LmmPtr;
-
-/*********
- * Tools *
- *********/
-
-/*********
- * Model *
- *********/
-class WorkstationVMModel : public WorkstationModel {
-public:
- WorkstationVMModel();
- ~WorkstationVMModel(){};
- void createResource(const char *name, void *ind_phys_workstation);
- double shareResources(double now);
- void adjustWeightOfDummyCpuActions() {};
-};
-
-/************
- * Resource *
- ************/
-class WorkstationVM2013 : virtual public WorkstationCLM03 {
-public:
- WorkstationVM2013(WorkstationVMModelPtr model, const char* name, xbt_dict_t props, RoutingEdgePtr netElm, CpuPtr cpu)
- : WorkstationCLM03(model, name, props, NULL, netElm, cpu) {};
-
- virtual void suspend()=0;
- virtual void resume()=0;
-
- virtual void save()=0;
- virtual void restore()=0;
-
- virtual void migrate(surf_resource_t ind_vm_ws_dest)=0; // will be vm_ws_migrate()
-
- virtual surf_resource_t getPm()=0; // will be vm_ws_get_pm()
-
- virtual void setBound(double bound)=0;
- virtual void setAffinity(CpuLmmPtr cpu, unsigned long mask)=0;
-
- /* The workstation object of the lower layer */
- WorkstationCLM03Ptr p_subWs; // Pointer to the ''host'' OS
- e_surf_vm_state_t p_currentState;
- CpuActionLmmPtr p_action;
-};
-
-class WorkstationVM2013Lmm : public WorkstationVM2013, public WorkstationCLM03Lmm {
-public:
- WorkstationVM2013Lmm(WorkstationVMModelPtr model, const char* name, xbt_dict_t props, surf_resource_t ind_phys_workstation);
- ~WorkstationVM2013Lmm();
-
- void suspend();
- void resume();
-
- void save();
- void restore();
-
- void migrate(surf_resource_t ind_dst_pm);
-
- e_surf_resource_state_t getState();
- void setState(e_surf_resource_state_t state);
-
- surf_resource_t getPm(); // will be vm_ws_get_pm()
-
- void setBound(double bound);
- void setAffinity(CpuLmmPtr cpu, unsigned long mask);
-
- //FIXME: remove
- void updateState(tmgr_trace_event_t event_type, double value, double date) {
- WorkstationCLM03Lmm::updateState(event_type, value, date);
- }
- bool isUsed() {
- return WorkstationCLM03Lmm::isUsed();
- }
- xbt_dict_t getProperties() {
- return WorkstationCLM03Lmm::getProperties();
- }
- ActionPtr execute(double size);
-
-};
-
-/**********
- * Action *
- **********/
-
-#endif /* VM_WORKSTATION_HPP_ */
* Created on: Nov 12, 2013
* Author: bedaride
*/
-#include "vm_workstation.hpp"
+#include "vm_workstation_hl13.hpp"
#include "cpu_cas01.hpp"
-extern "C" {
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_vm_workstation, surf,
- "Logging specific to the SURF VM workstation module");
-}
-
-WorkstationVMModelPtr surf_vm_workstation_model = NULL;
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_vm_workstation);
void surf_vm_workstation_model_init_current_default(void){
if (surf_cpu_model_vm) {
- surf_vm_workstation_model = new WorkstationVMModel();
+ surf_vm_workstation_model = new WorkstationVMHL13Model();
ModelPtr model = static_cast<ModelPtr>(surf_vm_workstation_model);
xbt_dynar_push(model_list, &model);
* Model *
*********/
-WorkstationVMModel::WorkstationVMModel() : WorkstationModel("Virtual Workstation") {
+WorkstationVMHL13Model::WorkstationVMHL13Model() : WorkstationVMModel() {
p_cpuModel = surf_cpu_model_vm;
}
+xbt_dynar_t WorkstationVMHL13Model::getRoute(WorkstationPtr src, WorkstationPtr dst){
+ return WorkstationCLM03Model::getRoute(src, dst);
+}
+
+ActionPtr WorkstationVMHL13Model::communicate(WorkstationPtr src, WorkstationPtr dst, double size, double rate){
+ return WorkstationCLM03Model::communicate(src, dst, size, rate);
+}
+
/* ind means ''indirect'' that this is a reference on the whole dict_elm
* structure (i.e not on the surf_resource_private infos) */
-void WorkstationVMModel::createResource(const char *name, void *ind_phys_workstation)
+void WorkstationVMHL13Model::createResource(const char *name, void *ind_phys_workstation)
{
- WorkstationVM2013LmmPtr ws = new WorkstationVM2013Lmm(this, name, NULL, static_cast<surf_resource_t>(ind_phys_workstation));
+ WorkstationVMHL13LmmPtr ws = new WorkstationVMHL13Lmm(this, name, NULL, static_cast<surf_resource_t>(ind_phys_workstation));
xbt_lib_set(host_lib, name, SURF_WKS_LEVEL, static_cast<ResourcePtr>(ws));
// const double virt_overhead = 0.95;
const double virt_overhead = 1;
-double WorkstationVMModel::shareResources(double now)
+double WorkstationVMHL13Model::shareResources(double now)
{
/* TODO: udpate action's cost with the total cost of processes on the VM. */
char *key;
void **ind_host;
xbt_lib_foreach(host_lib, cursor, key, ind_host) {
- WorkstationCLM03Ptr ws_clm03 = dynamic_cast<WorkstationCLM03Ptr>(
+ WorkstationPtr ws = dynamic_cast<WorkstationPtr>(
static_cast<ResourcePtr>(ind_host[SURF_WKS_LEVEL]));
- CpuCas01LmmPtr cpu_cas01 = dynamic_cast<CpuCas01LmmPtr>(
+ CpuLmmPtr cpu = dynamic_cast<CpuLmmPtr>(
static_cast<ResourcePtr>(ind_host[SURF_CPU_LEVEL]));
- if (!ws_clm03)
+ if (!ws)
continue;
/* skip if it is not a virtual machine */
- if (ws_clm03->p_model != static_cast<ModelPtr>(surf_vm_workstation_model))
+ if (ws->p_model != static_cast<ModelPtr>(surf_vm_workstation_model))
continue;
- xbt_assert(cpu_cas01, "cpu-less workstation");
+ xbt_assert(cpu, "cpu-less workstation");
/* It is a virtual machine, so we can cast it to workstation_VM2013_t */
- WorkstationVM2013Ptr ws_vm2013 = dynamic_cast<WorkstationVM2013Ptr>(ws_clm03);
+ WorkstationVMPtr ws_vm = dynamic_cast<WorkstationVMPtr>(ws);
- double solved_value = get_solved_value(ws_vm2013->p_action);
+ double solved_value = get_solved_value(reinterpret_cast<CpuActionLmmPtr>(ws_vm->p_action));
XBT_DEBUG("assign %f to vm %s @ pm %s", solved_value,
- ws_clm03->m_name, ws_vm2013->p_subWs->m_name);
+ ws->m_name, ws_vm->p_subWs->m_name);
// TODO: check lmm_update_constraint_bound() works fine instead of the below manual substitution.
// cpu_cas01->constraint->bound = solved_value;
- xbt_assert(cpu_cas01->p_model == static_cast<ModelPtr>(surf_cpu_model_vm));
- lmm_system_t vcpu_system = cpu_cas01->p_model->p_maxminSystem;
- lmm_update_constraint_bound(vcpu_system, cpu_cas01->p_constraint, virt_overhead * solved_value);
+ xbt_assert(cpu->p_model == static_cast<ModelPtr>(surf_cpu_model_vm));
+ lmm_system_t vcpu_system = cpu->p_model->p_maxminSystem;
+ lmm_update_constraint_bound(vcpu_system, cpu->p_constraint, virt_overhead * solved_value);
}
/* 2. Calculate resource share at the virtual machine layer. */
- double ret = WorkstationModel::shareResources(now);
+ double ret = WorkstationCLM03Model::shareResources(now);
/* FIXME: 3. do we have to re-initialize our cpu_action object? */
/************
* Resource *
************/
-WorkstationVM2013Lmm::WorkstationVM2013Lmm(WorkstationVMModelPtr model, const char* name, xbt_dict_t props,
+WorkstationVMHL13Lmm::WorkstationVMHL13Lmm(WorkstationVMModelPtr model, const char* name, xbt_dict_t props,
surf_resource_t ind_phys_workstation)
- : Resource(model, name, props),
- WorkstationCLM03(model, name, props, NULL, NULL, NULL),
- WorkstationVM2013(model, name, props, NULL, NULL),
- WorkstationCLM03Lmm(model, name, props, NULL, NULL, NULL) {
- WorkstationCLM03Ptr sub_ws = dynamic_cast<WorkstationCLM03Ptr>(
+ : Resource(model, name, props)
+ , WorkstationVMLmm(NULL, NULL)
+ , WorkstationCLM03Lmm(model, name, props, NULL, NULL, NULL)
+{
+ WorkstationPtr sub_ws = dynamic_cast<WorkstationPtr>(
static_cast<ResourcePtr>(
surf_workstation_resource_priv(ind_phys_workstation)));
* A physical host does not disapper in the current SimGrid code, but a VM may
* disapper during a simulation.
*/
-WorkstationVM2013Lmm::~WorkstationVM2013Lmm()
+WorkstationVMHL13Lmm::~WorkstationVMHL13Lmm()
{
/* ind_phys_workstation equals to smx_host_t */
surf_resource_t ind_vm_workstation = xbt_lib_get_elm_or_null(host_lib, m_name);
/* Free the workstation resource of the VM. */
}
-e_surf_resource_state_t WorkstationVM2013Lmm::getState()
+e_surf_resource_state_t WorkstationVMHL13Lmm::getState()
{
return (e_surf_resource_state_t) p_currentState;
}
-void WorkstationVM2013Lmm::setState(e_surf_resource_state_t state)
+void WorkstationVMHL13Lmm::setState(e_surf_resource_state_t state)
{
p_currentState = (e_surf_vm_state_t) state;
}
-void WorkstationVM2013Lmm::suspend()
+void WorkstationVMHL13Lmm::suspend()
{
p_action->suspend();
p_currentState = SURF_VM_STATE_SUSPENDED;
}
-void WorkstationVM2013Lmm::resume()
+void WorkstationVMHL13Lmm::resume()
{
p_action->resume();
p_currentState = SURF_VM_STATE_RUNNING;
}
-void WorkstationVM2013Lmm::save()
+void WorkstationVMHL13Lmm::save()
{
p_currentState = SURF_VM_STATE_SAVING;
p_currentState = SURF_VM_STATE_SAVED;
}
-void WorkstationVM2013Lmm::restore()
+void WorkstationVMHL13Lmm::restore()
{
p_currentState = SURF_VM_STATE_RESTORING;
/*
* Update the physical host of the given VM
*/
-void WorkstationVM2013Lmm::migrate(surf_resource_t ind_dst_pm)
+void WorkstationVMHL13Lmm::migrate(surf_resource_t ind_dst_pm)
{
/* ind_phys_workstation equals to smx_host_t */
- WorkstationCLM03Ptr ws_clm03_dst = dynamic_cast<WorkstationCLM03Ptr>(
+ WorkstationPtr ws_dst = dynamic_cast<WorkstationPtr>(
static_cast<ResourcePtr>(
surf_workstation_resource_priv(ind_dst_pm)));
const char *vm_name = m_name;
const char *pm_name_src = p_subWs->m_name;
- const char *pm_name_dst = ws_clm03_dst->m_name;
+ const char *pm_name_dst = ws_dst->m_name;
- xbt_assert(ws_clm03_dst);
+ xbt_assert(ws_dst);
/* do something */
p_netElm = new_net_elm;
xbt_lib_set(host_lib, vm_name, ROUTING_HOST_LEVEL, p_netElm);
- p_subWs = ws_clm03_dst;
+ p_subWs = ws_dst;
/* Update vcpu's action for the new pm */
{
static_cast<ResourcePtr>(
surf_cpu_resource_priv(ind_dst_pm)))->execute(0));
- e_surf_action_state_t state = surf_action_get_state(p_action);
+ e_surf_action_state_t state = p_action->getState();
if (state != SURF_ACTION_DONE)
XBT_CRITICAL("FIXME: may need a proper handling, %d", state);
if (p_action->m_remains > 0)
XBT_DEBUG("migrate VM(%s): change PM (%s to %s)", vm_name, pm_name_src, pm_name_dst);
}
-void WorkstationVM2013Lmm::setBound(double bound){
+void WorkstationVMHL13Lmm::setBound(double bound){
p_action->setBound(bound);
}
-void WorkstationVM2013Lmm::setAffinity(CpuLmmPtr cpu, unsigned long mask){
+void WorkstationVMHL13Lmm::setAffinity(CpuLmmPtr cpu, unsigned long mask){
p_action->setAffinity(cpu, mask);
}
* A surf level object will be useless in the upper layer. Returing the
* dict_elm of the host.
**/
-surf_resource_t WorkstationVM2013Lmm::getPm()
+surf_resource_t WorkstationVMHL13Lmm::getPm()
{
return xbt_lib_get_elm_or_null(host_lib, p_subWs->m_name);
}
/* Adding a task to a VM updates the VCPU task on its physical machine. */
-ActionPtr WorkstationVM2013Lmm::execute(double size)
+ActionPtr WorkstationVMHL13Lmm::execute(double size)
{
double old_cost = p_action->m_cost;
double new_cost = old_cost + size;
p_action->m_cost = new_cost;
- return WorkstationCLM03::execute(size);
+ return WorkstationCLM03Lmm::execute(size);
}
/**********
--- /dev/null
+/*
+ * vm_workstation.hpp
+ *
+ * Created on: Nov 12, 2013
+ * Author: bedaride
+ */
+#include "vm_workstation_interface.hpp"
+#include "workstation_clm03.hpp"
+
+#ifndef VM_WORKSTATION_HPP_
+#define VM_WORKSTATION_HPP_
+
+#define GUESTOS_NOISE 100 // This value corresponds to the cost of the global action associated to the VM
+ // It corresponds to the cost of a VM running no tasks.
+
+void surf_vm_workstation_model_init(void);
+
+/***********
+ * Classes *
+ ***********/
+
+class WorkstationVMHL13Model;
+typedef WorkstationVMHL13Model *WorkstationVMHL13ModelPtr;
+
+class WorkstationVMHL13Lmm;
+typedef WorkstationVMHL13Lmm *WorkstationVMHL13LmmPtr;
+
+/*********
+ * Tools *
+ *********/
+
+/*********
+ * Model *
+ *********/
+class WorkstationVMHL13Model : public WorkstationVMModel, public WorkstationCLM03Model {
+public:
+ WorkstationVMHL13Model();
+ ~WorkstationVMHL13Model(){};
+ void createResource(const char *name, void *ind_phys_workstation);
+ double shareResources(double now);
+ void adjustWeightOfDummyCpuActions() {};
+ xbt_dynar_t getRoute(WorkstationPtr src, WorkstationPtr dst);
+ ActionPtr communicate(WorkstationPtr src, WorkstationPtr dst, double size, double rate);
+};
+
+/************
+ * Resource *
+ ************/
+
+class WorkstationVMHL13Lmm : public WorkstationVMLmm, public WorkstationCLM03Lmm {
+public:
+ WorkstationVMHL13Lmm(WorkstationVMModelPtr model, const char* name, xbt_dict_t props, surf_resource_t ind_phys_workstation);
+ ~WorkstationVMHL13Lmm();
+
+ void suspend();
+ void resume();
+
+ void save();
+ void restore();
+
+ void migrate(surf_resource_t ind_dst_pm);
+
+ e_surf_resource_state_t getState();
+ void setState(e_surf_resource_state_t state);
+
+ surf_resource_t getPm(); // will be vm_ws_get_pm()
+
+ void setBound(double bound);
+ void setAffinity(CpuLmmPtr cpu, unsigned long mask);
+
+ //FIXME: remove
+ void updateState(tmgr_trace_event_t event_type, double value, double date) {
+ WorkstationCLM03Lmm::updateState(event_type, value, date);
+ }
+ bool isUsed() {
+ return WorkstationCLM03Lmm::isUsed();
+ }
+ xbt_dict_t getProperties() {
+ return WorkstationCLM03Lmm::getProperties();
+ }
+ ActionPtr execute(double size);
+
+};
+
+/**********
+ * Action *
+ **********/
+
+#endif /* VM_WORKSTATION_HPP_ */
--- /dev/null
+/*
+ * vm_workstation.cpp
+ *
+ * Created on: Nov 12, 2013
+ * Author: bedaride
+ */
+#include "vm_workstation_interface.hpp"
+#include "cpu_cas01.hpp"
+
+extern "C" {
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_vm_workstation, surf,
+ "Logging specific to the SURF VM workstation module");
+}
+
+WorkstationVMModelPtr surf_vm_workstation_model = NULL;
+
+/*********
+ * Model *
+ *********/
+
+WorkstationVMModel::WorkstationVMModel() : WorkstationModel("Virtual Workstation") {
+ p_cpuModel = surf_cpu_model_vm;
+}
+
+/************
+ * Resource *
+ ************/
+
+
+WorkstationVMLmm::WorkstationVMLmm(RoutingEdgePtr netElm, CpuPtr cpu)
+ : WorkstationVM(netElm, cpu)
+ , WorkstationLmm()
+{}
+
+/*
+ * A physical host does not disapper in the current SimGrid code, but a VM may
+ * disapper during a simulation.
+ */
+WorkstationVM::~WorkstationVM()
+{
+ /* ind_phys_workstation equals to smx_host_t */
+ surf_resource_t ind_vm_workstation = xbt_lib_get_elm_or_null(host_lib, m_name);
+
+ /* Before clearing the entries in host_lib, we have to pick up resources. */
+ CpuCas01LmmPtr cpu = dynamic_cast<CpuCas01LmmPtr>(
+ static_cast<ResourcePtr>(
+ surf_cpu_resource_priv(ind_vm_workstation)));
+
+ /* We deregister objects from host_lib, without invoking the freeing callback
+ * of each level.
+ *
+ * Do not call xbt_lib_remove() here. It deletes all levels of the key,
+ * including MSG_HOST_LEVEL and others. We should unregister only what we know.
+ */
+ xbt_lib_unset(host_lib, m_name, SURF_CPU_LEVEL, 0);
+ xbt_lib_unset(host_lib, m_name, ROUTING_HOST_LEVEL, 0);
+ xbt_lib_unset(host_lib, m_name, SURF_WKS_LEVEL, 0);
+
+ /* TODO: comment out when VM stroage is implemented. */
+ // xbt_lib_unset(host_lib, name, SURF_STORAGE_LEVEL, 0);
+
+
+ /* Free the cpu_action of the VM. */
+ int ret = p_action->unref();
+ xbt_assert(ret == 1, "Bug: some resource still remains");
+
+ /* Free the cpu resource of the VM. If using power_trace, we will have to */
+ delete cpu;
+}
+
+/*
+ * A surf level object will be useless in the upper layer. Returing the
+ * dict_elm of the host.
+ **/
+surf_resource_t WorkstationVM::getPm()
+{
+ return xbt_lib_get_elm_or_null(host_lib, p_subWs->m_name);
+}
+
+/**********
+ * Action *
+ **********/
+
+//FIME:: handle action cancel
+
--- /dev/null
+/*
+ * vm_workstation.hpp
+ *
+ * Created on: Nov 12, 2013
+ * Author: bedaride
+ */
+#include "workstation_interface.hpp"
+
+#ifndef VM_WORKSTATION_INTERFACE_HPP_
+#define VM_WORKSTATION_INTERFACE_HPP_
+
+#define GUESTOS_NOISE 100 // This value corresponds to the cost of the global action associated to the VM
+ // It corresponds to the cost of a VM running no tasks.
+
+void surf_vm_workstation_model_init(void);
+
+/***********
+ * Classes *
+ ***********/
+
+class WorkstationVMModel;
+typedef WorkstationVMModel *WorkstationVMModelPtr;
+
+class WorkstationVM;
+typedef WorkstationVM *WorkstationVMPtr;
+
+class WorkstationVMLmm;
+typedef WorkstationVMLmm *WorkstationVMLmmPtr;
+
+/*********
+ * Model *
+ *********/
+
+class WorkstationVMModel : virtual public WorkstationModel {
+public:
+ WorkstationVMModel();
+ ~WorkstationVMModel(){};
+ virtual void createResource(const char *name, void *ind_phys_workstation)=0;
+ void adjustWeightOfDummyCpuActions() {};
+};
+
+/************
+ * Resource *
+ ************/
+
+class WorkstationVM : virtual public Workstation {
+public:
+ WorkstationVM(RoutingEdgePtr netElm, CpuPtr cpu)
+ : Workstation(NULL, netElm, cpu) {};
+ ~WorkstationVM();
+
+ virtual void suspend()=0;
+ virtual void resume()=0;
+
+ virtual void save()=0;
+ virtual void restore()=0;
+
+ virtual void migrate(surf_resource_t ind_vm_ws_dest)=0; // will be vm_ws_migrate()
+
+ virtual surf_resource_t getPm()=0; // will be vm_ws_get_pm()
+
+ virtual void setBound(double bound)=0;
+ virtual void setAffinity(CpuLmmPtr cpu, unsigned long mask)=0;
+
+ /* The workstation object of the lower layer */
+ CpuActionPtr p_action;
+ WorkstationPtr p_subWs; // Pointer to the ''host'' OS
+ e_surf_vm_state_t p_currentState;
+};
+
+class WorkstationVMLmm : public WorkstationVM, public WorkstationLmm {
+public:
+ WorkstationVMLmm(RoutingEdgePtr netElm, CpuPtr cpu);
+};
+
+/**********
+ * Action *
+ **********/
+
+#endif /* VM_WORKSTATION_INTERFACE_HPP_ */
+++ /dev/null
-#include "workstation.hpp"
-#include "vm_workstation.hpp"
-#include "cpu_cas01.hpp"
-#include "simgrid/sg_config.h"
-
-extern "C" {
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_workstation, surf,
- "Logging specific to the SURF workstation module");
-}
-
-WorkstationModelPtr surf_workstation_model = NULL;
-
-/*************
- * CallBacks *
- *************/
-
-static void workstation_new(sg_platf_host_cbarg_t host){
- surf_workstation_model->createResource(host->id);
-}
-
-/*********
- * Model *
- *********/
-
-void surf_workstation_model_init_current_default(void)
-{
- surf_workstation_model = new WorkstationModel();
- xbt_cfg_setdefault_boolean(_sg_cfg_set, "network/crosstraffic", "yes");
- surf_cpu_model_init_Cas01();
- surf_network_model_init_LegrandVelho();
- surf_workstation_model->p_cpuModel = surf_cpu_model_pm;
-
- ModelPtr model = static_cast<ModelPtr>(surf_workstation_model);
- xbt_dynar_push(model_list, &model);
- xbt_dynar_push(model_list_invoke, &model);
- sg_platf_host_add_cb(workstation_new);
-}
-
-void surf_workstation_model_init_compound()
-{
-
- xbt_assert(surf_cpu_model_pm, "No CPU model defined yet!");
- xbt_assert(surf_network_model, "No network model defined yet!");
- surf_workstation_model = new WorkstationModel();
-
- ModelPtr model = static_cast<ModelPtr>(surf_workstation_model);
- xbt_dynar_push(model_list, &model);
- xbt_dynar_push(model_list_invoke, &model);
- sg_platf_host_add_cb(workstation_new);
-}
-
-WorkstationModel::WorkstationModel() : Model("Workstation") {
- p_cpuModel = surf_cpu_model_pm;
-}
-
-WorkstationModel::~WorkstationModel() {
-}
-
-void WorkstationModel::parseInit(sg_platf_host_cbarg_t host){
- createResource(host->id);
-}
-
-WorkstationCLM03Ptr WorkstationModel::createResource(string name){
-
- WorkstationCLM03Ptr workstation = new WorkstationCLM03(surf_workstation_model, name.c_str(), NULL,
- (xbt_dynar_t)xbt_lib_get_or_null(storage_lib, name.c_str(), ROUTING_STORAGE_HOST_LEVEL),
- (RoutingEdgePtr)xbt_lib_get_or_null(host_lib, name.c_str(), ROUTING_HOST_LEVEL),
- dynamic_cast<CpuPtr>(static_cast<ResourcePtr>(xbt_lib_get_or_null(host_lib, name.c_str(), SURF_CPU_LEVEL))));
- XBT_DEBUG("Create workstation %s with %ld mounted disks", name.c_str(), xbt_dynar_length(workstation->p_storage));
- xbt_lib_set(host_lib, name.c_str(), SURF_WKS_LEVEL, static_cast<ResourcePtr>(workstation));
- return workstation;
-}
-
-/* Each VM has a dummy CPU action on the PM layer. This CPU action works as the
- * constraint (capacity) of the VM in the PM layer. If the VM does not have any
- * active task, the dummy CPU action must be deactivated, so that the VM does
- * not get any CPU share in the PM layer. */
-void WorkstationModel::adjustWeightOfDummyCpuActions()
-{
- /* iterate for all hosts including virtual machines */
- xbt_lib_cursor_t cursor;
- char *key;
- void **ind_host;
-
- xbt_lib_foreach(host_lib, cursor, key, ind_host) {
- WorkstationCLM03Ptr ws_clm03 = dynamic_cast<WorkstationCLM03Ptr>(
- static_cast<ResourcePtr>(ind_host[SURF_WKS_LEVEL]));
- CpuCas01LmmPtr cpu_cas01 = dynamic_cast<CpuCas01LmmPtr>(
- static_cast<ResourcePtr>(ind_host[SURF_CPU_LEVEL]));
-
- if (!ws_clm03)
- continue;
- /* skip if it is not a virtual machine */
- if (ws_clm03->p_model != static_cast<ModelPtr>(surf_vm_workstation_model))
- continue;
- xbt_assert(cpu_cas01, "cpu-less workstation");
-
- /* It is a virtual machine, so we can cast it to workstation_VM2013_t */
- WorkstationVM2013Ptr ws_vm2013 = dynamic_cast<WorkstationVM2013Ptr>(ws_clm03);
-
- int is_active = lmm_constraint_used(cpu_cas01->p_model->p_maxminSystem, cpu_cas01->p_constraint);
- // int is_active_old = constraint_is_active(cpu_cas01);
-
- // {
- // xbt_assert(is_active == is_active_old, "%d %d", is_active, is_active_old);
- // }
-
- if (is_active) {
- /* some tasks exist on this VM */
- XBT_DEBUG("set the weight of the dummy CPU action on PM to 1");
-
- /* FIXME: we shoud use lmm_update_variable_weight() ? */
- /* FIXME: If we assgign 1.05 and 0.05, the system makes apparently wrong values. */
- surf_action_set_priority(ws_vm2013->p_action, 1);
-
- } else {
- /* no task exits on this VM */
- XBT_DEBUG("set the weight of the dummy CPU action on PM to 0");
-
- surf_action_set_priority(ws_vm2013->p_action, 0);
- }
- }
-}
-
-double WorkstationModel::shareResources(double now){
- adjustWeightOfDummyCpuActions();
-
- double min_by_cpu = p_cpuModel->shareResources(now);
- double min_by_net = surf_network_model->shareResources(now);
- double min_by_sto = -1;
- if (p_cpuModel == surf_cpu_model_pm)
- min_by_sto = surf_storage_model->shareResources(now);
-
- XBT_DEBUG("model %p, %s min_by_cpu %f, %s min_by_net %f, %s min_by_sto %f",
- this, surf_cpu_model_pm->m_name.c_str(), min_by_cpu,
- surf_network_model->m_name.c_str(), min_by_net,
- surf_storage_model->m_name.c_str(), min_by_sto);
-
- double res = max(max(min_by_cpu, min_by_net), min_by_sto);
- if (min_by_cpu >= 0.0 && min_by_cpu < res)
- res = min_by_cpu;
- if (min_by_net >= 0.0 && min_by_net < res)
- res = min_by_net;
- if (min_by_sto >= 0.0 && min_by_sto < res)
- res = min_by_sto;
- return res;
-}
-
-void WorkstationModel::updateActionsState(double /*now*/, double /*delta*/){
- return;
-}
-
-ActionPtr WorkstationModel::executeParallelTask(int workstation_nb,
- void **workstation_list,
- double *computation_amount,
- double *communication_amount,
- double rate){
-#define cost_or_zero(array,pos) ((array)?(array)[pos]:0.0)
- if ((workstation_nb == 1)
- && (cost_or_zero(communication_amount, 0) == 0.0))
- return ((WorkstationCLM03Ptr)workstation_list[0])->execute(computation_amount[0]);
- else if ((workstation_nb == 1)
- && (cost_or_zero(computation_amount, 0) == 0.0))
- return communicate((WorkstationCLM03Ptr)workstation_list[0], (WorkstationCLM03Ptr)workstation_list[0],communication_amount[0], rate);
- else if ((workstation_nb == 2)
- && (cost_or_zero(computation_amount, 0) == 0.0)
- && (cost_or_zero(computation_amount, 1) == 0.0)) {
- int i,nb = 0;
- double value = 0.0;
-
- for (i = 0; i < workstation_nb * workstation_nb; i++) {
- if (cost_or_zero(communication_amount, i) > 0.0) {
- nb++;
- value = cost_or_zero(communication_amount, i);
- }
- }
- if (nb == 1)
- return communicate((WorkstationCLM03Ptr)workstation_list[0], (WorkstationCLM03Ptr)workstation_list[1],value, rate);
- }
-#undef cost_or_zero
-
- THROW_UNIMPLEMENTED; /* This model does not implement parallel tasks */
- return NULL;
-}
-
-/* returns an array of network_link_CM02_t */
-xbt_dynar_t WorkstationModel::getRoute(WorkstationCLM03Ptr src, WorkstationCLM03Ptr dst)
-{
- XBT_DEBUG("ws_get_route");
- return surf_network_model->getRoute(src->p_netElm, dst->p_netElm);
-}
-
-ActionPtr WorkstationModel::communicate(WorkstationCLM03Ptr src, WorkstationCLM03Ptr dst, double size, double rate){
- return surf_network_model->communicate(src->p_netElm, dst->p_netElm, size, rate);
-}
-
-
-
-/************
- * Resource *
- ************/
-WorkstationCLM03::WorkstationCLM03(WorkstationModelPtr model, const char* name, xbt_dict_t properties, xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu)
- : Resource(model, name, properties), p_storage(storage), p_netElm(netElm), p_cpu(cpu) {}
-
-bool WorkstationCLM03::isUsed(){
- THROW_IMPOSSIBLE; /* This model does not implement parallel tasks */
- return -1;
-}
-
-void WorkstationCLM03::updateState(tmgr_trace_event_t /*event_type*/, double /*value*/, double /*date*/){
- THROW_IMPOSSIBLE; /* This model does not implement parallel tasks */
-}
-
-ActionPtr WorkstationCLM03::execute(double size) {
- return p_cpu->execute(size);
-}
-
-ActionPtr WorkstationCLM03::sleep(double duration) {
- return p_cpu->sleep(duration);
-}
-
-e_surf_resource_state_t WorkstationCLM03::getState() {
- return p_cpu->getState();
-}
-
-int WorkstationCLM03::getCore(){
- return p_cpu->getCore();
-}
-
-double WorkstationCLM03::getSpeed(double load){
- return p_cpu->getSpeed(load);
-}
-
-double WorkstationCLM03::getAvailableSpeed(){
- return p_cpu->getAvailableSpeed();
-}
-
-double WorkstationCLM03::getCurrentPowerPeak()
-{
- return p_cpu->getCurrentPowerPeak();
-}
-
-double WorkstationCLM03::getPowerPeakAt(int pstate_index)
-{
- return p_cpu->getPowerPeakAt(pstate_index);
-}
-
-int WorkstationCLM03::getNbPstates()
-{
- return p_cpu->getNbPstates();
-}
-
-void WorkstationCLM03::setPowerPeakAt(int pstate_index)
-{
- p_cpu->setPowerPeakAt(pstate_index);
-}
-
-double WorkstationCLM03::getConsumedEnergy()
-{
- return p_cpu->getConsumedEnergy();
-}
-
-
-xbt_dict_t WorkstationCLM03::getProperties()
-{
- return p_cpu->m_properties;
-}
-
-
-StoragePtr WorkstationCLM03::findStorageOnMountList(const char* mount)
-{
- StoragePtr st = NULL;
- s_mount_t mnt;
- unsigned int cursor;
-
- XBT_DEBUG("Search for storage name '%s' on '%s'", mount, m_name);
- xbt_dynar_foreach(p_storage,cursor,mnt)
- {
- XBT_DEBUG("See '%s'",mnt.name);
- if(!strcmp(mount,mnt.name)){
- st = dynamic_cast<StoragePtr>(static_cast<ResourcePtr>(mnt.storage));
- break;
- }
- }
- if(!st) xbt_die("Can't find mount '%s' for '%s'", mount, m_name);
- return st;
-}
-
-xbt_dict_t WorkstationCLM03::getStorageList()
-{
- s_mount_t mnt;
- unsigned int i;
- xbt_dict_t storage_list = xbt_dict_new_homogeneous(NULL);
- char *storage_name = NULL;
-
- xbt_dynar_foreach(p_storage,i,mnt){
- storage_name = (char *)dynamic_cast<StoragePtr>(static_cast<ResourcePtr>(mnt.storage))->m_name;
- xbt_dict_set(storage_list,mnt.name,storage_name,NULL);
- }
- return storage_list;
-}
-
-ActionPtr WorkstationCLM03::open(const char* mount, const char* path) {
- StoragePtr st = findStorageOnMountList(mount);
- XBT_DEBUG("OPEN on disk '%s'", st->m_name);
- return st->open(mount, path);
-}
-
-ActionPtr WorkstationCLM03::close(surf_file_t fd) {
- StoragePtr st = findStorageOnMountList(fd->mount);
- XBT_DEBUG("CLOSE on disk '%s'",st->m_name);
- return st->close(fd);
-}
-
-ActionPtr WorkstationCLM03::read(surf_file_t fd, sg_size_t size) {
- StoragePtr st = findStorageOnMountList(fd->mount);
- XBT_DEBUG("READ on disk '%s'",st->m_name);
- return st->read(fd, size);
-}
-
-ActionPtr WorkstationCLM03::write(surf_file_t fd, sg_size_t size) {
- StoragePtr st = findStorageOnMountList(fd->mount);
- XBT_DEBUG("WRITE on disk '%s'",st->m_name);
- return st->write(fd, size);
-}
-
-int WorkstationCLM03::unlink(surf_file_t fd) {
- if (!fd){
- XBT_WARN("No such file descriptor. Impossible to unlink");
- return 0;
- } else {
-// XBT_INFO("%s %zu", fd->storage, fd->size);
- StoragePtr st = findStorageOnMountList(fd->mount);
- /* Check if the file is on this storage */
- if (!xbt_dict_get_or_null(st->p_content, fd->name)){
- XBT_WARN("File %s is not on disk %s. Impossible to unlink", fd->name,
- st->m_name);
- return 0;
- } else {
- XBT_DEBUG("UNLINK on disk '%s'",st->m_name);
- st->m_usedSize -= fd->size;
-
- // Remove the file from storage
- xbt_dict_remove(st->p_content, fd->name);
-
- free(fd->name);
- free(fd->mount);
- xbt_free(fd);
- return 1;
- }
- }
-}
-
-ActionPtr WorkstationCLM03::ls(const char* mount, const char *path){
- XBT_DEBUG("LS on mount '%s' and file '%s'", mount, path);
- StoragePtr st = findStorageOnMountList(mount);
- return st->ls(path);
-}
-
-sg_size_t WorkstationCLM03::getSize(surf_file_t fd){
- return fd->size;
-}
-
-xbt_dynar_t WorkstationCLM03::getInfo( surf_file_t fd)
-{
- StoragePtr st = findStorageOnMountList(fd->mount);
- sg_size_t *psize = xbt_new(sg_size_t, 1);
- *psize = fd->size;
- xbt_dynar_t info = xbt_dynar_new(sizeof(void*), NULL);
- xbt_dynar_push_as(info, sg_size_t *, psize);
- xbt_dynar_push_as(info, void *, fd->mount);
- xbt_dynar_push_as(info, void *, (void *)st->m_name);
- xbt_dynar_push_as(info, void *, st->p_typeId);
- xbt_dynar_push_as(info, void *, st->p_contentType);
-
- return info;
-}
-
-sg_size_t WorkstationCLM03::fileTell(surf_file_t fd){
- return fd->current_position;
-}
-
-int WorkstationCLM03::fileSeek(surf_file_t fd, sg_size_t offset, int origin){
-
- switch (origin) {
- case SEEK_SET:
- fd->current_position = 0;
- return MSG_OK;
- case SEEK_CUR:
- if(offset > fd->size)
- offset = fd->size;
- fd->current_position = offset;
- return MSG_OK;
- case SEEK_END:
- fd->current_position = fd->size;
- return MSG_OK;
- default:
- return MSG_TASK_CANCELED;
- }
-}
-
-sg_size_t WorkstationCLM03::getFreeSize(const char* name)
-{
- StoragePtr st = findStorageOnMountList(name);
- return st->m_size - st->m_usedSize;
-}
-
-sg_size_t WorkstationCLM03::getUsedSize(const char* name)
-{
- StoragePtr st = findStorageOnMountList(name);
- return st->m_usedSize;
-}
-
-e_surf_resource_state_t WorkstationCLM03Lmm::getState() {
- return WorkstationCLM03::getState();
-}
-
-xbt_dynar_t WorkstationCLM03::getVms()
-{
- xbt_dynar_t dyn = xbt_dynar_new(sizeof(smx_host_t), NULL);
-
- /* iterate for all hosts including virtual machines */
- xbt_lib_cursor_t cursor;
- char *key;
- void **ind_host;
- xbt_lib_foreach(host_lib, cursor, key, ind_host) {
- WorkstationCLM03Ptr ws_clm03 = dynamic_cast<WorkstationCLM03Ptr>(static_cast<ResourcePtr>(ind_host[SURF_WKS_LEVEL]));
- if (!ws_clm03)
- continue;
- /* skip if it is not a virtual machine */
- if (ws_clm03->p_model != static_cast<ModelPtr>(surf_vm_workstation_model))
- continue;
-
- /* It is a virtual machine, so we can cast it to workstation_VM2013_t */
- WorkstationVM2013Ptr ws_vm2013 = dynamic_cast<WorkstationVM2013Ptr>(ws_clm03);
- if (this == ws_vm2013-> p_subWs)
- xbt_dynar_push(dyn, &ws_vm2013->p_subWs);
- }
-
- return dyn;
-}
-
-void WorkstationCLM03::getParams(ws_params_t params)
-{
- memcpy(params, &p_params, sizeof(s_ws_params_t));
-}
-
-void WorkstationCLM03::setParams(ws_params_t params)
-{
- /* may check something here. */
- memcpy(&p_params, params, sizeof(s_ws_params_t));
-}
-/**********
- * Action *
- **********/
+++ /dev/null
-#include "surf.hpp"
-#include "storage_interface.hpp"
-#include "cpu_interface.hpp"
-#include "network_interface.hpp"
-
-#ifndef WORKSTATION_HPP_
-#define WORKSTATION_HPP_
-
-/***********
- * Classes *
- ***********/
-
-class WorkstationModel;
-typedef WorkstationModel *WorkstationModelPtr;
-
-class WorkstationCLM03;
-typedef WorkstationCLM03 *WorkstationCLM03Ptr;
-
-class WorkstationCLM03Lmm;
-typedef WorkstationCLM03Lmm *WorkstationCLM03LmmPtr;
-
-class WorkstationAction;
-typedef WorkstationAction *WorkstationActionPtr;
-
-class WorkstationActionLmm;
-typedef WorkstationActionLmm *WorkstationActionLmmPtr;
-
-/*********
- * Tools *
- *********/
-extern WorkstationModelPtr surf_workstation_model;
-
-/*********
- * Model *
- *********/
-class WorkstationModel : public Model {
-public:
- WorkstationModel(string name): Model(name) {};
- WorkstationModel();
- ~WorkstationModel();
- virtual void parseInit(sg_platf_host_cbarg_t host);
- WorkstationCLM03Ptr createResource(string name);
- double shareResources(double now);
- virtual void adjustWeightOfDummyCpuActions();
-
- void updateActionsState(double now, double delta);
-
- virtual ActionPtr executeParallelTask(int workstation_nb,
- void **workstation_list,
- double *computation_amount,
- double *communication_amount,
- double rate);
- virtual xbt_dynar_t getRoute(WorkstationCLM03Ptr src, WorkstationCLM03Ptr dst);
- virtual ActionPtr communicate(WorkstationCLM03Ptr src, WorkstationCLM03Ptr dst, double size, double rate);
- CpuModelPtr p_cpuModel;
-};
-
-/************
- * Resource *
- ************/
-
-class WorkstationCLM03 : virtual public Resource {
-public:
- WorkstationCLM03(WorkstationModelPtr model, const char* name, xbt_dict_t properties, xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu);
-
- void updateState(tmgr_trace_event_t event_type, double value, double date);
-
- virtual ActionPtr execute(double size);
- virtual ActionPtr sleep(double duration);
- e_surf_resource_state_t getState();
-
- virtual int getCore();
- virtual double getSpeed(double load);
- virtual double getAvailableSpeed();
- virtual double getCurrentPowerPeak();
- virtual double getPowerPeakAt(int pstate_index);
- virtual int getNbPstates();
- virtual void setPowerPeakAt(int pstate_index);
- virtual double getConsumedEnergy();
-
- xbt_dict_t getProperties();
-
- StoragePtr findStorageOnMountList(const char* storage);
- xbt_dict_t getStorageList();
- ActionPtr open(const char* mount, const char* path);
- ActionPtr close(surf_file_t fd);
- int unlink(surf_file_t fd);
- ActionPtr ls(const char* mount, const char *path);
- sg_size_t getSize(surf_file_t fd);
- ActionPtr read(surf_file_t fd, sg_size_t size);
- ActionPtr write(surf_file_t fd, sg_size_t size);
- xbt_dynar_t getInfo( surf_file_t fd);
- sg_size_t fileTell(surf_file_t fd);
- sg_size_t getFreeSize(const char* name);
- sg_size_t getUsedSize(const char* name);
- int fileSeek(surf_file_t fd, sg_size_t offset, int origin);
-
- bool isUsed();
- //bool isShared();
- xbt_dynar_t p_storage;
- RoutingEdgePtr p_netElm;
- CpuPtr p_cpu;
- NetworkLinkPtr p_network;
-
- xbt_dynar_t getVms();
-
- /* common with vm */
- void getParams(ws_params_t params);
- void setParams(ws_params_t params);
- s_ws_params_t p_params;
-};
-
-class WorkstationCLM03Lmm : virtual public WorkstationCLM03, public ResourceLmm {
-public:
- WorkstationCLM03Lmm(WorkstationModelPtr model, const char* name, xbt_dict_t props, xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu):
- WorkstationCLM03(model, name, props, storage, netElm, cpu){};
- e_surf_resource_state_t getState();
-};
-
-/**********
- * Action *
- **********/
-class WorkstationAction : virtual public Action {
-public:
- WorkstationAction(ModelPtr model, double cost, bool failed): Action(model, cost, failed) {};
-};
-
-class WorkstationActionLmm : public ActionLmm, public WorkstationAction {
-public:
- WorkstationActionLmm(ModelPtr model, double cost, bool failed): ActionLmm(model, cost, failed), WorkstationAction(model, cost, failed) {};
-};
-
-
-#endif /* WORKSTATION_HPP_ */
--- /dev/null
+#include "workstation_clm03.hpp"
+#include "vm_workstation_interface.hpp"
+#include "cpu_cas01.hpp"
+#include "simgrid/sg_config.h"
+
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_workstation);
+
+/*************
+ * CallBacks *
+ *************/
+
+static void workstation_new(sg_platf_host_cbarg_t host){
+ reinterpret_cast<WorkstationCLM03ModelPtr>(surf_workstation_model)->createResource(host->id);
+}
+
+/*********
+ * Model *
+ *********/
+
+void surf_workstation_model_init_current_default(void)
+{
+ surf_workstation_model = new WorkstationCLM03Model();
+ xbt_cfg_setdefault_boolean(_sg_cfg_set, "network/crosstraffic", "yes");
+ surf_cpu_model_init_Cas01();
+ surf_network_model_init_LegrandVelho();
+ surf_workstation_model->p_cpuModel = surf_cpu_model_pm;
+
+ ModelPtr model = static_cast<ModelPtr>(surf_workstation_model);
+ xbt_dynar_push(model_list, &model);
+ xbt_dynar_push(model_list_invoke, &model);
+ sg_platf_host_add_cb(workstation_new);
+}
+
+void surf_workstation_model_init_compound()
+{
+
+ xbt_assert(surf_cpu_model_pm, "No CPU model defined yet!");
+ xbt_assert(surf_network_model, "No network model defined yet!");
+ surf_workstation_model = new WorkstationCLM03Model();
+
+ ModelPtr model = static_cast<ModelPtr>(surf_workstation_model);
+ xbt_dynar_push(model_list, &model);
+ xbt_dynar_push(model_list_invoke, &model);
+ sg_platf_host_add_cb(workstation_new);
+}
+
+WorkstationCLM03Model::WorkstationCLM03Model(string name)
+ : WorkstationModel(name)
+{}
+
+
+WorkstationCLM03Model::WorkstationCLM03Model()
+ : WorkstationModel("Workstation")
+{
+}
+
+WorkstationCLM03Model::~WorkstationCLM03Model()
+{}
+
+void WorkstationCLM03Model::parseInit(sg_platf_host_cbarg_t host){
+ createResource(host->id);
+}
+
+WorkstationPtr WorkstationCLM03Model::createResource(string name){
+
+ WorkstationPtr workstation = new WorkstationCLM03Lmm(surf_workstation_model, name.c_str(), NULL,
+ (xbt_dynar_t)xbt_lib_get_or_null(storage_lib, name.c_str(), ROUTING_STORAGE_HOST_LEVEL),
+ (RoutingEdgePtr)xbt_lib_get_or_null(host_lib, name.c_str(), ROUTING_HOST_LEVEL),
+ dynamic_cast<CpuPtr>(static_cast<ResourcePtr>(xbt_lib_get_or_null(host_lib, name.c_str(), SURF_CPU_LEVEL))));
+ XBT_DEBUG("Create workstation %s with %ld mounted disks", name.c_str(), xbt_dynar_length(workstation->p_storage));
+ xbt_lib_set(host_lib, name.c_str(), SURF_WKS_LEVEL, static_cast<ResourcePtr>(workstation));
+ return workstation;
+}
+
+double WorkstationCLM03Model::shareResources(double now){
+ adjustWeightOfDummyCpuActions();
+
+ double min_by_cpu = p_cpuModel->shareResources(now);
+ double min_by_net = surf_network_model->shareResources(now);
+ double min_by_sto = -1;
+ if (p_cpuModel == surf_cpu_model_pm)
+ min_by_sto = surf_storage_model->shareResources(now);
+
+ XBT_DEBUG("model %p, %s min_by_cpu %f, %s min_by_net %f, %s min_by_sto %f",
+ this, surf_cpu_model_pm->m_name.c_str(), min_by_cpu,
+ surf_network_model->m_name.c_str(), min_by_net,
+ surf_storage_model->m_name.c_str(), min_by_sto);
+
+ double res = max(max(min_by_cpu, min_by_net), min_by_sto);
+ if (min_by_cpu >= 0.0 && min_by_cpu < res)
+ res = min_by_cpu;
+ if (min_by_net >= 0.0 && min_by_net < res)
+ res = min_by_net;
+ if (min_by_sto >= 0.0 && min_by_sto < res)
+ res = min_by_sto;
+ return res;
+}
+
+void WorkstationCLM03Model::updateActionsState(double /*now*/, double /*delta*/){
+ return;
+}
+
+ActionPtr WorkstationCLM03Model::executeParallelTask(int workstation_nb,
+ void **workstation_list,
+ double *computation_amount,
+ double *communication_amount,
+ double rate){
+#define cost_or_zero(array,pos) ((array)?(array)[pos]:0.0)
+ if ((workstation_nb == 1)
+ && (cost_or_zero(communication_amount, 0) == 0.0))
+ return ((WorkstationCLM03LmmPtr)workstation_list[0])->execute(computation_amount[0]);
+ else if ((workstation_nb == 1)
+ && (cost_or_zero(computation_amount, 0) == 0.0))
+ return communicate((WorkstationCLM03LmmPtr)workstation_list[0], (WorkstationCLM03LmmPtr)workstation_list[0],communication_amount[0], rate);
+ else if ((workstation_nb == 2)
+ && (cost_or_zero(computation_amount, 0) == 0.0)
+ && (cost_or_zero(computation_amount, 1) == 0.0)) {
+ int i,nb = 0;
+ double value = 0.0;
+
+ for (i = 0; i < workstation_nb * workstation_nb; i++) {
+ if (cost_or_zero(communication_amount, i) > 0.0) {
+ nb++;
+ value = cost_or_zero(communication_amount, i);
+ }
+ }
+ if (nb == 1)
+ return communicate((WorkstationCLM03LmmPtr)workstation_list[0], (WorkstationCLM03LmmPtr)workstation_list[1],value, rate);
+ }
+#undef cost_or_zero
+
+ THROW_UNIMPLEMENTED; /* This model does not implement parallel tasks */
+ return NULL;
+}
+
+/* returns an array of network_link_CM02_t */
+xbt_dynar_t WorkstationCLM03Model::getRoute(WorkstationPtr src, WorkstationPtr dst)
+{
+ XBT_DEBUG("ws_get_route");
+ return surf_network_model->getRoute(src->p_netElm, dst->p_netElm);
+}
+
+ActionPtr WorkstationCLM03Model::communicate(WorkstationPtr src, WorkstationPtr dst, double size, double rate){
+ return surf_network_model->communicate(src->p_netElm, dst->p_netElm, size, rate);
+}
+
+
+
+/************
+ * Resource *
+ ************/
+WorkstationCLM03Lmm::WorkstationCLM03Lmm(WorkstationModelPtr model, const char* name, xbt_dict_t properties, xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu)
+ : Resource(model, name, properties), Workstation(storage, netElm, cpu) {}
+
+bool WorkstationCLM03Lmm::isUsed(){
+ THROW_IMPOSSIBLE; /* This model does not implement parallel tasks */
+ return -1;
+}
+
+void WorkstationCLM03Lmm::updateState(tmgr_trace_event_t /*event_type*/, double /*value*/, double /*date*/){
+ THROW_IMPOSSIBLE; /* This model does not implement parallel tasks */
+}
+
+ActionPtr WorkstationCLM03Lmm::execute(double size) {
+ return p_cpu->execute(size);
+}
+
+ActionPtr WorkstationCLM03Lmm::sleep(double duration) {
+ return p_cpu->sleep(duration);
+}
+
+e_surf_resource_state_t WorkstationCLM03Lmm::getState() {
+ return p_cpu->getState();
+}
+
+
+
+
+
+
+
+
+
+
+/**********
+ * Action *
+ **********/
--- /dev/null
+#include "workstation_interface.hpp"
+#include "storage_interface.hpp"
+#include "cpu_interface.hpp"
+#include "network_interface.hpp"
+
+#ifndef SURF_WORKSTATION_CLM03_HPP_
+#define SURF_WORKSTATION_CLM03_HPP_
+
+/***********
+ * Classes *
+ ***********/
+
+class WorkstationCLM03Model;
+typedef WorkstationCLM03Model *WorkstationCLM03ModelPtr;
+
+class WorkstationCLM03Lmm;
+typedef WorkstationCLM03Lmm *WorkstationCLM03LmmPtr;
+
+class WorkstationCLM03ActionLmm;
+typedef WorkstationCLM03ActionLmm *WorkstationCLM03ActionLmmPtr;
+
+/*********
+ * Model *
+ *********/
+
+class WorkstationCLM03Model : virtual public WorkstationModel {
+public:
+ WorkstationCLM03Model(string name);
+ WorkstationCLM03Model();
+ ~WorkstationCLM03Model();
+ void parseInit(sg_platf_host_cbarg_t host);
+ WorkstationPtr createResource(string name);
+ double shareResources(double now);
+
+ void updateActionsState(double now, double delta);
+
+ ActionPtr executeParallelTask(int workstation_nb,
+ void **workstation_list,
+ double *computation_amount,
+ double *communication_amount,
+ double rate);
+ xbt_dynar_t getRoute(WorkstationPtr src, WorkstationPtr dst);
+ ActionPtr communicate(WorkstationPtr src, WorkstationPtr dst, double size, double rate);
+};
+
+/************
+ * Resource *
+ ************/
+
+class WorkstationCLM03Lmm : public WorkstationLmm {
+public:
+ WorkstationCLM03Lmm(WorkstationModelPtr model, const char* name, xbt_dict_t properties, xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu);
+
+ void updateState(tmgr_trace_event_t event_type, double value, double date);
+
+ virtual ActionPtr execute(double size);
+ virtual ActionPtr sleep(double duration);
+ e_surf_resource_state_t getState();
+
+ bool isUsed();
+
+ xbt_dynar_t getVms();
+
+ /* common with vm */
+ void getParams(ws_params_t params);
+ void setParams(ws_params_t params);
+};
+
+
+/**********
+ * Action *
+ **********/
+
+class WorkstationCLM03ActionLmm : public WorkstationActionLmm {
+public:
+ WorkstationCLM03ActionLmm(ModelPtr model, double cost, bool failed): Action(model, cost, failed), WorkstationActionLmm() {};
+};
+
+
+#endif /* SURF_WORKSTATION_CLM03_HPP_ */
--- /dev/null
+#include "workstation_interface.hpp"
+#include "vm_workstation_interface.hpp"
+#include "cpu_cas01.hpp"
+#include "simgrid/sg_config.h"
+
+extern "C" {
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_workstation, surf,
+ "Logging specific to the SURF workstation module");
+}
+
+WorkstationModelPtr surf_workstation_model = NULL;
+
+/*********
+ * Model *
+ *********/
+WorkstationModel::WorkstationModel(string name)
+ : Model(name)
+{
+ p_cpuModel = surf_cpu_model_pm;
+}
+
+WorkstationModel::WorkstationModel()
+: Model("Workstation") {
+ p_cpuModel = surf_cpu_model_pm;
+}
+
+WorkstationModel::~WorkstationModel() {
+}
+
+
+
+/* Each VM has a dummy CPU action on the PM layer. This CPU action works as the
+ * constraint (capacity) of the VM in the PM layer. If the VM does not have any
+ * active task, the dummy CPU action must be deactivated, so that the VM does
+ * not get any CPU share in the PM layer. */
+void WorkstationModel::adjustWeightOfDummyCpuActions()
+{
+ /* iterate for all hosts including virtual machines */
+ xbt_lib_cursor_t cursor;
+ char *key;
+ void **ind_host;
+
+ xbt_lib_foreach(host_lib, cursor, key, ind_host) {
+ WorkstationPtr ws = dynamic_cast<WorkstationPtr>(
+ static_cast<ResourcePtr>(ind_host[SURF_WKS_LEVEL]));
+ CpuCas01LmmPtr cpu_cas01 = dynamic_cast<CpuCas01LmmPtr>(
+ static_cast<ResourcePtr>(ind_host[SURF_CPU_LEVEL]));
+
+ if (!ws)
+ continue;
+ /* skip if it is not a virtual machine */
+ if (ws->p_model != static_cast<ModelPtr>(surf_vm_workstation_model))
+ continue;
+ xbt_assert(cpu_cas01, "cpu-less workstation");
+
+ /* It is a virtual machine, so we can cast it to workstation_VM2013_t */
+ WorkstationVMLmmPtr ws_vm = dynamic_cast<WorkstationVMLmmPtr>(ws);
+
+ int is_active = lmm_constraint_used(cpu_cas01->p_model->p_maxminSystem, cpu_cas01->p_constraint);
+ // int is_active_old = constraint_is_active(cpu_cas01);
+
+ // {
+ // xbt_assert(is_active == is_active_old, "%d %d", is_active, is_active_old);
+ // }
+
+ if (is_active) {
+ /* some tasks exist on this VM */
+ XBT_DEBUG("set the weight of the dummy CPU action on PM to 1");
+
+ /* FIXME: we shoud use lmm_update_variable_weight() ? */
+ /* FIXME: If we assgign 1.05 and 0.05, the system makes apparently wrong values. */
+ ws_vm->p_action->setPriority(1);
+
+ } else {
+ /* no task exits on this VM */
+ XBT_DEBUG("set the weight of the dummy CPU action on PM to 0");
+
+ ws_vm->p_action->setPriority(0);
+ }
+ }
+}
+
+/************
+ * Resource *
+ ************/
+Workstation::Workstation(xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu)
+ : p_storage(storage), p_netElm(netElm), p_cpu(cpu)
+{}
+
+int Workstation::getCore(){
+ return p_cpu->getCore();
+}
+
+double Workstation::getSpeed(double load){
+ return p_cpu->getSpeed(load);
+}
+
+double Workstation::getAvailableSpeed(){
+ return p_cpu->getAvailableSpeed();
+}
+
+double Workstation::getCurrentPowerPeak()
+{
+ return p_cpu->getCurrentPowerPeak();
+}
+
+double Workstation::getPowerPeakAt(int pstate_index)
+{
+ return p_cpu->getPowerPeakAt(pstate_index);
+}
+
+int Workstation::getNbPstates()
+{
+ return p_cpu->getNbPstates();
+}
+
+void Workstation::setPowerPeakAt(int pstate_index)
+{
+ p_cpu->setPowerPeakAt(pstate_index);
+}
+
+double Workstation::getConsumedEnergy()
+{
+ return p_cpu->getConsumedEnergy();
+}
+
+xbt_dict_t Workstation::getProperties()
+{
+ return p_cpu->m_properties;
+}
+
+
+StoragePtr Workstation::findStorageOnMountList(const char* mount)
+{
+ StoragePtr st = NULL;
+ s_mount_t mnt;
+ unsigned int cursor;
+
+ XBT_DEBUG("Search for storage name '%s' on '%s'", mount, m_name);
+ xbt_dynar_foreach(p_storage,cursor,mnt)
+ {
+ XBT_DEBUG("See '%s'",mnt.name);
+ if(!strcmp(mount,mnt.name)){
+ st = dynamic_cast<StoragePtr>(static_cast<ResourcePtr>(mnt.storage));
+ break;
+ }
+ }
+ if(!st) xbt_die("Can't find mount '%s' for '%s'", mount, m_name);
+ return st;
+}
+
+xbt_dict_t Workstation::getStorageList()
+{
+ s_mount_t mnt;
+ unsigned int i;
+ xbt_dict_t storage_list = xbt_dict_new_homogeneous(NULL);
+ char *storage_name = NULL;
+
+ xbt_dynar_foreach(p_storage,i,mnt){
+ storage_name = (char *)dynamic_cast<StoragePtr>(static_cast<ResourcePtr>(mnt.storage))->m_name;
+ xbt_dict_set(storage_list,mnt.name,storage_name,NULL);
+ }
+ return storage_list;
+}
+
+ActionPtr Workstation::open(const char* mount, const char* path) {
+ StoragePtr st = findStorageOnMountList(mount);
+ XBT_DEBUG("OPEN on disk '%s'", st->m_name);
+ return st->open(mount, path);
+}
+
+ActionPtr Workstation::close(surf_file_t fd) {
+ StoragePtr st = findStorageOnMountList(fd->mount);
+ XBT_DEBUG("CLOSE on disk '%s'",st->m_name);
+ return st->close(fd);
+}
+
+ActionPtr Workstation::read(surf_file_t fd, sg_size_t size) {
+ StoragePtr st = findStorageOnMountList(fd->mount);
+ XBT_DEBUG("READ on disk '%s'",st->m_name);
+ return st->read(fd, size);
+}
+
+ActionPtr Workstation::write(surf_file_t fd, sg_size_t size) {
+ StoragePtr st = findStorageOnMountList(fd->mount);
+ XBT_DEBUG("WRITE on disk '%s'",st->m_name);
+ return st->write(fd, size);
+}
+
+int Workstation::unlink(surf_file_t fd) {
+ if (!fd){
+ XBT_WARN("No such file descriptor. Impossible to unlink");
+ return 0;
+ } else {
+// XBT_INFO("%s %zu", fd->storage, fd->size);
+ StoragePtr st = findStorageOnMountList(fd->mount);
+ /* Check if the file is on this storage */
+ if (!xbt_dict_get_or_null(st->p_content, fd->name)){
+ XBT_WARN("File %s is not on disk %s. Impossible to unlink", fd->name,
+ st->m_name);
+ return 0;
+ } else {
+ XBT_DEBUG("UNLINK on disk '%s'",st->m_name);
+ st->m_usedSize -= fd->size;
+
+ // Remove the file from storage
+ xbt_dict_remove(st->p_content, fd->name);
+
+ free(fd->name);
+ free(fd->mount);
+ xbt_free(fd);
+ return 1;
+ }
+ }
+}
+
+ActionPtr Workstation::ls(const char* mount, const char *path){
+ XBT_DEBUG("LS on mount '%s' and file '%s'", mount, path);
+ StoragePtr st = findStorageOnMountList(mount);
+ return st->ls(path);
+}
+
+sg_size_t Workstation::getSize(surf_file_t fd){
+ return fd->size;
+}
+
+xbt_dynar_t Workstation::getInfo( surf_file_t fd)
+{
+ StoragePtr st = findStorageOnMountList(fd->mount);
+ sg_size_t *psize = xbt_new(sg_size_t, 1);
+ *psize = fd->size;
+ xbt_dynar_t info = xbt_dynar_new(sizeof(void*), NULL);
+ xbt_dynar_push_as(info, sg_size_t *, psize);
+ xbt_dynar_push_as(info, void *, fd->mount);
+ xbt_dynar_push_as(info, void *, (void *)st->m_name);
+ xbt_dynar_push_as(info, void *, st->p_typeId);
+ xbt_dynar_push_as(info, void *, st->p_contentType);
+
+ return info;
+}
+
+sg_size_t Workstation::fileTell(surf_file_t fd){
+ return fd->current_position;
+}
+
+int Workstation::fileSeek(surf_file_t fd, sg_size_t offset, int origin){
+
+ switch (origin) {
+ case SEEK_SET:
+ fd->current_position = 0;
+ return MSG_OK;
+ case SEEK_CUR:
+ if(offset > fd->size)
+ offset = fd->size;
+ fd->current_position = offset;
+ return MSG_OK;
+ case SEEK_END:
+ fd->current_position = fd->size;
+ return MSG_OK;
+ default:
+ return MSG_TASK_CANCELED;
+ }
+}
+
+sg_size_t Workstation::getFreeSize(const char* name)
+{
+ StoragePtr st = findStorageOnMountList(name);
+ return st->m_size - st->m_usedSize;
+}
+
+sg_size_t Workstation::getUsedSize(const char* name)
+{
+ StoragePtr st = findStorageOnMountList(name);
+ return st->m_usedSize;
+}
+
+xbt_dynar_t Workstation::getVms()
+{
+ xbt_dynar_t dyn = xbt_dynar_new(sizeof(smx_host_t), NULL);
+
+ /* iterate for all hosts including virtual machines */
+ xbt_lib_cursor_t cursor;
+ char *key;
+ void **ind_host;
+ xbt_lib_foreach(host_lib, cursor, key, ind_host) {
+ WorkstationPtr ws = dynamic_cast<WorkstationPtr>(static_cast<ResourcePtr>(ind_host[SURF_WKS_LEVEL]));
+ if (!ws)
+ continue;
+ /* skip if it is not a virtual machine */
+ if (ws->p_model != static_cast<ModelPtr>(surf_vm_workstation_model))
+ continue;
+
+ /* It is a virtual machine, so we can cast it to workstation_VM2013_t */
+ WorkstationVMPtr ws_vm = dynamic_cast<WorkstationVMPtr>(ws);
+ if (this == ws_vm-> p_subWs)
+ xbt_dynar_push(dyn, &ws_vm->p_subWs);
+ }
+
+ return dyn;
+}
+
+void Workstation::getParams(ws_params_t params)
+{
+ memcpy(params, &p_params, sizeof(s_ws_params_t));
+}
+
+void Workstation::setParams(ws_params_t params)
+{
+ /* may check something here. */
+ memcpy(&p_params, params, sizeof(s_ws_params_t));
+}
+
+/**********
+ * Action *
+ **********/
--- /dev/null
+#include "surf_interface.hpp"
+#include "storage_interface.hpp"
+#include "cpu_interface.hpp"
+#include "network_interface.hpp"
+
+#ifndef SURF_WORKSTATION_INTERFACE_HPP_
+#define SURF_WORKSTATION_INTERFACE_HPP_
+
+/***********
+ * Classes *
+ ***********/
+
+class WorkstationModel;
+typedef WorkstationModel *WorkstationModelPtr;
+
+class Workstation;
+typedef Workstation *WorkstationPtr;
+
+class WorkstationLmm;
+typedef WorkstationLmm *WorkstationLmmPtr;
+
+class WorkstationAction;
+typedef WorkstationAction *WorkstationActionPtr;
+
+class WorkstationActionLmm;
+typedef WorkstationActionLmm *WorkstationActionLmmPtr;
+
+/*********
+ * Tools *
+ *********/
+extern WorkstationModelPtr surf_workstation_model;
+
+/*********
+ * Model *
+ *********/
+class WorkstationModel : public Model {
+public:
+ WorkstationModel(string name);
+ WorkstationModel();
+ ~WorkstationModel();
+ virtual void adjustWeightOfDummyCpuActions();
+
+ virtual ActionPtr executeParallelTask(int workstation_nb,
+ void **workstation_list,
+ double *computation_amount,
+ double *communication_amount,
+ double rate)=0;
+ virtual xbt_dynar_t getRoute(WorkstationPtr src, WorkstationPtr dst)=0;
+ virtual ActionPtr communicate(WorkstationPtr src, WorkstationPtr dst, double size, double rate)=0;
+
+ CpuModelPtr p_cpuModel;
+};
+
+/************
+ * Resource *
+ ************/
+
+class Workstation : virtual public Resource {
+public:
+ Workstation(){};
+ Workstation(xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu);
+
+ xbt_dict_t getProperties();
+
+ virtual ActionPtr execute(double size)=0;
+ virtual ActionPtr sleep(double duration)=0;
+
+ virtual int getCore();
+ virtual double getSpeed(double load);
+ virtual double getAvailableSpeed();
+ virtual double getCurrentPowerPeak();
+ virtual double getPowerPeakAt(int pstate_index);
+ virtual int getNbPstates();
+ virtual void setPowerPeakAt(int pstate_index);
+ virtual double getConsumedEnergy();
+
+ virtual StoragePtr findStorageOnMountList(const char* storage);
+ virtual xbt_dict_t getStorageList();
+ virtual ActionPtr open(const char* mount, const char* path);
+ virtual ActionPtr close(surf_file_t fd);
+ virtual int unlink(surf_file_t fd);
+ virtual ActionPtr ls(const char* mount, const char *path);
+ virtual sg_size_t getSize(surf_file_t fd);
+ virtual ActionPtr read(surf_file_t fd, sg_size_t size);
+ virtual ActionPtr write(surf_file_t fd, sg_size_t size);
+ virtual xbt_dynar_t getInfo( surf_file_t fd);
+ virtual sg_size_t fileTell(surf_file_t fd);
+ virtual sg_size_t getFreeSize(const char* name);
+ virtual sg_size_t getUsedSize(const char* name);
+ virtual int fileSeek(surf_file_t fd, sg_size_t offset, int origin);
+
+ xbt_dynar_t p_storage;
+ RoutingEdgePtr p_netElm;
+ CpuPtr p_cpu;
+ NetworkLinkPtr p_network;
+
+ xbt_dynar_t getVms();
+
+ /* common with vm */
+ void getParams(ws_params_t params);
+ void setParams(ws_params_t params);
+ s_ws_params_t p_params;
+};
+
+class WorkstationLmm : virtual public Workstation, public ResourceLmm {
+public:
+ WorkstationLmm() {};
+};
+
+/**********
+ * Action *
+ **********/
+class WorkstationAction : virtual public Action {
+public:
+ WorkstationAction() {};
+};
+
+class WorkstationActionLmm : public ActionLmm, public WorkstationAction {
+public:
+ WorkstationActionLmm(): ActionLmm(), WorkstationAction() {};
+};
+
+
+#endif /* SURF_WORKSTATION_INTERFACE_HPP_ */
i++))) {
constraint_id = lmm_constraint_id(cnst);
- if (static_cast<WorkstationCLM03LmmPtr>(constraint_id)->p_stateCurrent == SURF_RESOURCE_OFF) {
+ if (static_cast<WorkstationLmmPtr>(constraint_id)->p_stateCurrent == SURF_RESOURCE_OFF) {
XBT_DEBUG("Action (%p) Failed!!", action);
action->m_finish = surf_get_clock();
action->setState(SURF_ACTION_FAILED);
action->m_suspended = 0; /* Should be useless because of the
calloc but it seems to help valgrind... */
action->m_workstationNb = workstation_nb;
- action->p_workstationList = (WorkstationCLM03Ptr *) workstation_list;
+ action->p_workstationList = (WorkstationPtr *) workstation_list;
action->p_computationAmount = computation_amount;
action->p_communicationAmount = communication_amount;
action->m_latency = latency;
return wk;//FIXME:xbt_lib_get_elm_or_null(host_lib, name);
}
-ActionPtr WorkstationL07Model::communicate(WorkstationCLM03Ptr src, WorkstationCLM03Ptr dst,
+ActionPtr WorkstationL07Model::communicate(WorkstationPtr src, WorkstationPtr dst,
double size, double rate)
{
void **workstation_list = xbt_new0(void *, 2);
return res;
}
-xbt_dynar_t WorkstationL07Model::getRoute(WorkstationCLM03Ptr src, WorkstationCLM03Ptr dst)
+xbt_dynar_t WorkstationL07Model::getRoute(WorkstationPtr src, WorkstationPtr dst)
{
xbt_dynar_t route=NULL;
routing_platf->getRouteAndLatency(src->p_netElm, dst->p_netElm, &route, NULL);
WorkstationL07::WorkstationL07(WorkstationModelPtr model, const char* name, xbt_dict_t props, RoutingEdgePtr netElm, CpuPtr cpu)
: Resource(model, name, props),
- WorkstationCLM03(model, name, props, NULL, netElm, cpu),
- WorkstationCLM03Lmm(model, name, props, NULL, netElm, cpu)
+ Workstation(NULL, netElm, cpu),
+ WorkstationLmm()
{
}
-#include "workstation.hpp"
+#include "workstation_interface.hpp"
#ifndef WORKSTATION_L07_HPP_
#define WORKSTATION_L07_HPP_
double *computation_amount,
double *communication_amount,
double rate);
- xbt_dynar_t getRoute(WorkstationCLM03Ptr src, WorkstationCLM03Ptr dst);
- ActionPtr communicate(WorkstationCLM03Ptr src, WorkstationCLM03Ptr dst, double size, double rate);
+ xbt_dynar_t getRoute(WorkstationPtr src, WorkstationPtr dst);
+ ActionPtr communicate(WorkstationPtr src, WorkstationPtr dst, double size, double rate);
void addTraces();
NetworkModelPtr p_networkModel;
};
e_surf_link_sharing_policy_t
policy, xbt_dict_t properties);
- xbt_dynar_t getRoute(WorkstationCLM03Ptr /*src*/, WorkstationCLM03Ptr /*dst*/) {DIE_IMPOSSIBLE;};
+ xbt_dynar_t getRoute(WorkstationPtr /*src*/, WorkstationPtr /*dst*/) {DIE_IMPOSSIBLE;};
ActionPtr communicate(RoutingEdgePtr /*src*/, RoutingEdgePtr /*dst*/, double /*size*/, double /*rate*/) {DIE_IMPOSSIBLE;};
void addTraces() {DIE_IMPOSSIBLE;};
WorkstationL07ModelPtr p_workstationModel;
* Resource *
************/
-class WorkstationL07 : public WorkstationCLM03Lmm {
+class WorkstationL07 : public WorkstationLmm {
public:
WorkstationL07(WorkstationModelPtr model, const char* name, xbt_dict_t props, RoutingEdgePtr netElm, CpuPtr cpu);
//bool isUsed();
class WorkstationL07ActionLmm : public WorkstationActionLmm {
public:
WorkstationL07ActionLmm(ModelPtr model, double cost, bool failed)
- : Action(model, cost, failed), WorkstationActionLmm(model, cost, failed) {};
+ : Action(model, cost, failed), WorkstationActionLmm() {};
~WorkstationL07ActionLmm();
void updateBound();
double getRemains();
int m_workstationNb;
- WorkstationCLM03Ptr *p_workstationList;
+ WorkstationPtr *p_workstationList;
double *p_computationAmount;
double *p_communicationAmount;
double m_latency;