Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Create a cpu resource object for a virtual machine
authorTakahiro Hirofuchi <t.hirofuchi+sg@aist.go.jp>
Mon, 18 Feb 2013 17:41:52 +0000 (18:41 +0100)
committerTakahiro Hirofuchi <t.hirofuchi+sg@aist.go.jp>
Mon, 18 Feb 2013 17:41:52 +0000 (18:41 +0100)
src/surf/cpu_cas01.c
src/surf/cpu_cas01_private.h [new file with mode: 0644]
src/surf/vm_workstation.c

index 0a98541..c63cc19 100644 (file)
@@ -8,6 +8,7 @@
 #include "surf/surf_resource.h"
 #include "maxmin_private.h"
 #include "simgrid/sg_config.h"
+#include "surf/cpu_cas01_private.h"
 
 /* the model objects for physical machines and virtual machines */
 surf_model_t surf_cpu_model_pm = NULL;
@@ -24,18 +25,6 @@ typedef struct surf_action_cpu_cas01 {
   s_surf_action_lmm_t generic_lmm_action;
 } s_surf_action_cpu_Cas01_t, *surf_action_cpu_Cas01_t;
 
-typedef struct cpu_Cas01 {
-  s_surf_resource_t generic_resource;
-  s_xbt_swag_hookup_t modified_cpu_hookup;
-  double power_peak;
-  double power_scale;
-  tmgr_trace_event_t power_event;
-  int core;
-  e_surf_resource_state_t state_current;
-  tmgr_trace_event_t state_event;
-  lmm_constraint_t constraint;
-} s_cpu_Cas01_t, *cpu_Cas01_t;
-
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu, surf,
                                 "Logging specific to the SURF CPU IMPROVED module");
 
@@ -43,8 +32,7 @@ static xbt_swag_t
     cpu_running_action_set_that_does_not_need_being_checked = NULL;
 
 
-/* This function is registered as a callback to sg_platf_new_host() and never called directly */
-static void *cpu_create_resource(const char *name, double power_peak,
+void *cpu_cas01_create_resource(const char *name, double power_peak,
                                  double power_scale,
                                  tmgr_trace_t power_trace,
                                  int core,
@@ -91,7 +79,7 @@ static void parse_cpu_init(sg_platf_host_cbarg_t host)
   /* This function is called when a platform file is parsed. Physical machines
    * are defined there. Thus, we use the cpu model object for the physical
    * machine layer. */
-  cpu_create_resource(host->id,
+  cpu_cas01_create_resource(host->id,
                       host->power_peak,
                       host->power_scale,
                       host->power_trace,
diff --git a/src/surf/cpu_cas01_private.h b/src/surf/cpu_cas01_private.h
new file mode 100644 (file)
index 0000000..5d84572
--- /dev/null
@@ -0,0 +1,33 @@
+
+/* Copyright (c) 2013. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#ifndef _SURF_CPU_CAS01_PRIVATE_H
+#define _SURF_CPU_CAS01_PRIVATE_H
+
+typedef struct cpu_Cas01 {
+  s_surf_resource_t generic_resource;
+  s_xbt_swag_hookup_t modified_cpu_hookup;
+  double power_peak;
+  double power_scale;
+  tmgr_trace_event_t power_event;
+  int core;
+  e_surf_resource_state_t state_current;
+  tmgr_trace_event_t state_event;
+  lmm_constraint_t constraint;
+} s_cpu_Cas01_t, *cpu_Cas01_t;
+
+void *cpu_cas01_create_resource(const char *name,
+    double power_peak,
+    double power_scale,
+    tmgr_trace_t power_trace,
+    int core,
+    e_surf_resource_state_t state_initial,
+    tmgr_trace_t state_trace,
+    xbt_dict_t cpu_properties,
+    surf_model_t cpu_model);
+
+#endif                          /* _SURF_CPU_CAS01_PRIVATE_H */
index 012f96e..5f771d8 100644 (file)
@@ -11,7 +11,7 @@
 #include "surf/surf_resource.h"
 #include "simgrid/sg_config.h"
 #include "workstation_private.h"
-
+#include "surf/cpu_cas01_private.h"
 
 
 /* FIXME: Where should the VM state be defined?
@@ -95,6 +95,25 @@ static void vm_ws_create(const char *name, void *ind_phys_workstation)
    * ws->generic_resouce.model->type first. If it is
    * SURF_MODEL_TYPE_VM_WORKSTATION, cast ws to vm_ws. */
   xbt_lib_set(host_lib, name, SURF_WKS_LEVEL, &vm_ws->ws);
+
+
+
+  cpu_Cas01_t sub_cpu = surf_cpu_resource_priv(ind_phys_workstation);
+
+  /* We can assume one core and cas01 cpu for the first step.
+   * Do xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu) if you get the resource.
+   * */
+  cpu_cas01_create_resource(name, // name
+      sub_cpu->power_peak,        // host->power_peak,
+      1,                          // host->power_scale,
+      NULL,                       // host->power_trace,
+      1,                          // host->core_amount,
+      SURF_RESOURCE_ON,           // host->initial_state,
+      NULL,                       // host->state_trace,
+      NULL,                       // host->properties,
+      surf_cpu_model_vm);
+
+  // void *ind_host = xbt_lib_get_elm_or_null(host_lib, name);
 }
 
 /*