Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Renamed host to cpu. That was really confusing.
authoralegrand <alegrand@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 16 Nov 2004 22:04:45 +0000 (22:04 +0000)
committeralegrand <alegrand@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 16 Nov 2004 22:04:45 +0000 (22:04 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@518 48e7efb5-ca39-0410-a469-dd3cf9ba447f

ChangeLog
include/Makefile.am
src/Makefile.am
src/include/surf/surf.h
src/surf/cpu.c
src/surf/cpu_private.h
src/surf/surf.c
src/surf/surf_private.h
testsuite/Makefile.am

index 235a129..aa8cc5a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,8 +4,8 @@
     to 'make check' overthere yet.
 
 2004-11-15 Arnaud Legrand
     to 'make check' overthere yet.
 
 2004-11-15 Arnaud Legrand
-  - Trace manager now written. It uses a heap structure and is therfore
-    expected to be efficient. It may however be speed up (particularly
+  - Trace manager now written. It uses a heap structure and is therefore
+    expected to be efficient. It may however be speeded up (particularly
     when many events occur at the same date) by using red and black
     trees. One day maybe... 
   - Max-min linear system solver written. It uses a sparse matrix
     when many events occur at the same date) by using red and black
     trees. One day maybe... 
   - Max-min linear system solver written. It uses a sparse matrix
index ab8858f..66af137 100644 (file)
@@ -12,6 +12,7 @@ nobase_include_HEADERS = \
        \
        surf/maxmin.h \
        surf/trace_mgr.h \
        \
        surf/maxmin.h \
        surf/trace_mgr.h \
+       surf/surf.h \
        \
        gras/core.h \
        gras/datadesc.h gras/transport.h \
        \
        gras/core.h \
        gras/datadesc.h gras/transport.h \
index 7e681b1..d8c507b 100644 (file)
@@ -23,6 +23,8 @@ EXTRA_DIST= \
         \
        surf/maxmin_private.h \
        surf/trace_mgr_private.h \
         \
        surf/maxmin_private.h \
        surf/trace_mgr_private.h \
+       surf/surf_private.h \
+       surf/cpu_private.h \
        \
        gras/Transport/transport_interface.h \
        gras/Virtu/virtu_interface.h \
        \
        gras/Transport/transport_interface.h \
        gras/Virtu/virtu_interface.h \
@@ -92,8 +94,10 @@ COMMON_S=\
   xbt/module.c                                                                 \
   xbt/config.c                                                                 \
   \
   xbt/module.c                                                                 \
   xbt/config.c                                                                 \
   \
-  surf/maxmin.c                                                                \
-  surf/trace_mgr.c                                                             \
+  surf/maxmin.c                                                              \
+  surf/trace_mgr.c                                                           \
+  surf/surf.c                                                                \
+  surf/cpu.c                                                                 \
   \
   gras/Transport/transport.c          gras/Transport/transport_private.h   gras/Transport/transport_plugin_buf.c  \
   \
   \
   gras/Transport/transport.c          gras/Transport/transport_private.h   gras/Transport/transport_plugin_buf.c  \
   \
index c998d3e..536a63e 100644 (file)
@@ -47,8 +47,13 @@ typedef struct surf_action {
 typedef struct surf_resource {
   void (*parse_file)(const char *file);
   void *(*name_service)(const char *name);
 typedef struct surf_resource {
   void (*parse_file)(const char *file);
   void *(*name_service)(const char *name);
+  const char *(*get_resource_name)(void *resource_id);
+
+  /*   surf_action_t (*action_new)(void *callback);  */
+  /* Not defined here. Actions have to be created by actually
+     performing it and prototype may therefore vary with the resource
+     implementation */
 
 
-  surf_action_t (*action_new)(void *callback);
   e_surf_action_state_t (*action_get_state)(surf_action_t action);
   void (*action_free)(surf_action_t * action); /* Call it when you're done with this action */
   void (*action_cancel)(surf_action_t action); /* remove the variables from the linear system if needed */
   e_surf_action_state_t (*action_get_state)(surf_action_t action);
   void (*action_free)(surf_action_t * action); /* Call it when you're done with this action */
   void (*action_cancel)(surf_action_t action); /* remove the variables from the linear system if needed */
@@ -65,32 +70,30 @@ typedef struct surf_resource {
 /**************************************/
 /* Implementations of resource object */
 /**************************************/
 /**************************************/
 /* Implementations of resource object */
 /**************************************/
-/* Host resource */
+/* Cpu resource */
 typedef enum {
 typedef enum {
-  SURF_HOST_ON = 1,            /* Ready        */
-  SURF_HOST_OFF = 0,           /* Running      */
-} e_surf_host_state_t;
+  SURF_CPU_ON = 1,             /* Ready        */
+  SURF_CPU_OFF = 0,            /* Running      */
+} e_surf_cpu_state_t;
 
 
-typedef struct surf_host_resource {
+typedef struct surf_cpu_resource {
   s_surf_resource_t resource;
   s_surf_resource_t resource;
-  void (*execute)(void *host, xbt_maxmin_float_t size, surf_action_t action);
-  e_surf_host_state_t (*get_state)(void *host);
-} s_surf_host_resource_t, *surf_host_resource_t;
-extern surf_host_resource_t surf_host_resource;
+  surf_action_t (*execute)(void *cpu, xbt_maxmin_float_t size);
+  e_surf_cpu_state_t (*get_state)(void *cpu);
+} s_surf_cpu_resource_t, *surf_cpu_resource_t;
+extern surf_cpu_resource_t surf_cpu_resource;
 
 /* Network resource */
 typedef struct surf_network_resource {
   s_surf_resource_t resource;
 
 /* Network resource */
 typedef struct surf_network_resource {
   s_surf_resource_t resource;
-  surf_action_t (*communicate)(void *src, void *dst, xbt_maxmin_float_t size,
-                              surf_action_t action);
+  surf_action_t (*communicate)(void *src, void *dst, xbt_maxmin_float_t size);
 } s_surf_network_resource_t, surf_network_resource_t;
 extern surf_network_resource_t surf_network_resource;
 
 /* Timer resource */
 typedef struct surf_timer_resource {
   s_surf_resource_t resource;
 } s_surf_network_resource_t, surf_network_resource_t;
 extern surf_network_resource_t surf_network_resource;
 
 /* Timer resource */
 typedef struct surf_timer_resource {
   s_surf_resource_t resource;
-  surf_action_t (*wait)(void *host, void *dst, xbt_maxmin_float_t size,
-                       surf_action_t surf);
+  surf_action_t (*wait)(void *cpu, void *dst, xbt_maxmin_float_t size);
 } s_surf_timer_resource_t, surf_timer_resource_t;
 extern surf_timer_resource_t surf_timer_resource;
 
 } s_surf_timer_resource_t, surf_timer_resource_t;
 extern surf_timer_resource_t surf_timer_resource;
 
index 9b63b8d..3f4c510 100644 (file)
@@ -3,17 +3,67 @@
 /* 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. */
 
 /* 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. */
 
-#include "host_private.h"
+#include "cpu_private.h"
+#include "xbt/dict.h"
+
+surf_cpu_resource_t surf_cpu_resource = NULL;
+static xbt_dict_t cpu_set = NULL;
+static lmm_system_t sys = NULL;
+
+typedef struct cpu {
+  const char *name;
+  xbt_maxmin_float_t power_scale;
+  xbt_maxmin_float_t current_power;
+  tmgr_trace_t power_trace;
+  e_surf_action_state_t current_state;
+  tmgr_trace_t state_trace;
+  lmm_constraint_t constraint;
+} s_cpu_t, *cpu_t;
+
+/* power_scale is the basic power of the cpu when the cpu is
+   completely available. initial_power is therefore expected to be
+   comprised between 0.0 and 1.0, just as the values of power_trace.
+   state_trace values mean SURF_CPU_ON if >0 and SURF_CPU_OFF
+   otherwise.
+*/
+
+static void *new_cpu(const char *name, xbt_maxmin_float_t power_scale,
+                     xbt_maxmin_float_t initial_power, tmgr_trace_t power_trace,
+                     e_surf_cpu_state_t initial_state, tmgr_trace_t state_trace)
+{
+  cpu_t cpu = xbt_new0(s_cpu_t,1);
+
+  cpu->name = name;
+  cpu->power_scale = power_scale;
+  cpu->current_power = initial_power;
+  cpu->power_trace = power_trace;
+  cpu->current_state = initial_state;
+  cpu->state_trace = state_trace;
+  cpu->constraint = lmm_constraint_new(sys, cpu, cpu->current_power);
 
 
-surf_host_resource_t surf_host_resource = NULL;
+  xbt_dict_set(cpu_set, name, cpu, NULL);
+
+  return cpu;
+}
 
 static void parse_file(const char *file)
 {
 
 static void parse_file(const char *file)
 {
+  new_cpu("Cpu A", 200.0, 1.0, NULL, SURF_CPU_ON, NULL);
+  new_cpu("Cpu B", 100.0, 1.0, NULL, SURF_CPU_ON, NULL);
 }
 
 static void *name_service(const char *name)
 {
 }
 
 static void *name_service(const char *name)
 {
-  return NULL;
+  void *cpu=NULL;
+  
+  xbt_dict_get(cpu_set, name, &cpu);
+
+  return cpu;
+}
+
+static const char *get_resource_name(void *resource_id)
+{
+  return ((cpu_t) resource_id)->name;
 }
 
 static surf_action_t action_new(void *callback)
 }
 
 static surf_action_t action_new(void *callback)
@@ -43,6 +93,7 @@ static void action_recycle(surf_action_t action)
 
 static void action_change_state(surf_action_t action, e_surf_action_state_t state)
 {
 
 static void action_change_state(surf_action_t action, e_surf_action_state_t state)
 {
+  surf_action_change_state(action, state);
   return;
 }
 
   return;
 }
 
@@ -56,33 +107,38 @@ static void solve(xbt_heap_float_t date)
   return;
 }
 
   return;
 }
 
-static void execute(void *host, xbt_maxmin_float_t size, surf_action_t action)
+static surf_action_t execute(void *cpu, xbt_maxmin_float_t size)
 {
 {
+  return NULL;
 }
 
 }
 
-static e_surf_host_state_t get_state(void *host)
+static e_surf_cpu_state_t get_state(void *cpu)
 {
 {
-  return SURF_HOST_OFF;
+  return SURF_CPU_OFF;
 }
 
 
 }
 
 
-surf_host_resource_t surf_host_resource_init(void)
+surf_cpu_resource_t surf_cpu_resource_init(void)
 {
 {
-  surf_host_resource = xbt_new0(s_surf_host_resource_t,1);
-
-  surf_host_resource->resource.parse_file = parse_file;
-  surf_host_resource->resource.name_service = name_service;
-  surf_host_resource->resource.action_new=action_new;
-  surf_host_resource->resource.action_get_state=surf_action_get_state;
-  surf_host_resource->resource.action_free = action_free;
-  surf_host_resource->resource.action_cancel = action_cancel;
-  surf_host_resource->resource.action_recycle = action_recycle;
-  surf_host_resource->resource.action_change_state = action_change_state;
-  surf_host_resource->resource.share_resources = share_resources;
-  surf_host_resource->resource.solve = solve;
-
-  surf_host_resource->execute = execute;
-  surf_host_resource->get_state = get_state;
-
-  return surf_host_resource;
+  surf_cpu_resource = xbt_new0(s_surf_cpu_resource_t,1);
+
+  surf_cpu_resource->resource.parse_file = parse_file;
+  surf_cpu_resource->resource.name_service = name_service;
+  surf_cpu_resource->resource.get_resource_name = get_resource_name;
+  surf_cpu_resource->resource.action_get_state=surf_action_get_state;
+  surf_cpu_resource->resource.action_free = action_free;
+  surf_cpu_resource->resource.action_cancel = action_cancel;
+  surf_cpu_resource->resource.action_recycle = action_recycle;
+  surf_cpu_resource->resource.action_change_state = action_change_state;
+  surf_cpu_resource->resource.share_resources = share_resources;
+  surf_cpu_resource->resource.solve = solve;
+
+  surf_cpu_resource->execute = execute;
+  surf_cpu_resource->get_state = get_state;
+
+  cpu_set = xbt_dict_new();
+
+  sys = lmm_system_new();
+
+  return surf_cpu_resource;
 }
 }
index f5ee3c3..7315b42 100644 (file)
@@ -3,17 +3,17 @@
 /* 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. */
 
 /* 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_HOST_PRIVATE_H
-#define _SURF_HOST_PRIVATE_H
+#ifndef _SURF_CPU_PRIVATE_H
+#define _SURF_CPU_PRIVATE_H
 
 #include "surf/surf.h"
 #include "surf/surf_private.h"
 
 
 #include "surf/surf.h"
 #include "surf/surf_private.h"
 
-typedef struct surf_action_host {
+typedef struct surf_action_cpu {
   s_surf_action_t generic_action;
   lmm_variable_t variable;
   s_surf_action_t generic_action;
   lmm_variable_t variable;
-} s_surf_action_host_t, *surf_action_host_t;
+} s_surf_action_cpu_t, *surf_action_cpu_t;
 
 
-surf_host_resource_t surf_host_resource_init(void);
+surf_cpu_resource_t surf_cpu_resource_init(void);
 
 #endif                         /* _SURF_SURF_PRIVATE_H */
 
 #endif                         /* _SURF_SURF_PRIVATE_H */
index bc0667d..8783348 100644 (file)
@@ -4,7 +4,7 @@
    under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "surf_private.h"
    under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "surf_private.h"
-#include "host_private.h"
+#include "cpu_private.h"
 
 s_surf_global_t surf_global;
 
 
 s_surf_global_t surf_global;
 
@@ -46,7 +46,7 @@ void surf_action_change_state(surf_action_t action, e_surf_action_state_t state)
 
 void surf_init(void)
 {
 
 void surf_init(void)
 {
-  surf_host_resource = surf_host_resource_init();
+  surf_cpu_resource = surf_cpu_resource_init();
 }
 
 /* xbt_heap_float_t surf_solve(void) */
 }
 
 /* xbt_heap_float_t surf_solve(void) */
index c22887c..3be6b80 100644 (file)
@@ -9,7 +9,7 @@
 #include "surf/surf.h"
 #include "surf/maxmin.h"
 #include "surf/trace_mgr.h"
 #include "surf/surf.h"
 #include "surf/maxmin.h"
 #include "surf/trace_mgr.h"
-#include "host_private.h"
+#include "cpu_private.h"
 
 /* Generic functions common to all ressources */
 e_surf_action_state_t surf_action_get_state(surf_action_t action);
 
 /* Generic functions common to all ressources */
 e_surf_action_state_t surf_action_get_state(surf_action_t action);
index cf25ec8..e49653f 100644 (file)
@@ -29,7 +29,7 @@ RL_tests =                                              \
        gras/datadesc_usage
 
 SG_tests =                                              \
        gras/datadesc_usage
 
 SG_tests =                                              \
-       surf/maxmin_usage surf/trace_usage
+       surf/maxmin_usage surf/trace_usage surf/surf_usage
 
 check_PROGRAMS = $(xbt_tests) $(RL_tests) $(SG_tests)
 check_SCRIPTS = run_tests gras/trp_tcp_usage
 
 check_PROGRAMS = $(xbt_tests) $(RL_tests) $(SG_tests)
 check_SCRIPTS = run_tests gras/trp_tcp_usage
@@ -63,6 +63,7 @@ xbt_heap_bench_LDADD=         $(LDADD_UTILS)
 
 surf_maxmin_usage_LDADD=      $(LDADD_UTILS)
 surf_trace_usage_LDADD=       $(LDADD_UTILS)
 
 surf_maxmin_usage_LDADD=      $(LDADD_UTILS)
 surf_trace_usage_LDADD=       $(LDADD_UTILS)
+surf_surf_usage_LDADD=        $(LDADD_UTILS)
 
 gras_trp_tcp_client_LDADD=     $(LDADD_RL)
 gras_trp_tcp_server_LDADD=     $(LDADD_RL)
 
 gras_trp_tcp_client_LDADD=     $(LDADD_RL)
 gras_trp_tcp_server_LDADD=     $(LDADD_RL)