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
\
surf/maxmin.h \
surf/trace_mgr.h \
+ surf/surf.h \
\
gras/core.h \
gras/datadesc.h gras/transport.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 \
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 \
\
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 */
/**************************************/
/* Implementations of resource object */
/**************************************/
-/* Host resource */
+/* Cpu resource */
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;
- 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;
- 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;
- 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;
/* 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)
{
+ 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)
{
- 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 void action_change_state(surf_action_t action, e_surf_action_state_t state)
{
+ surf_action_change_state(action, state);
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;
}
/* 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"
-typedef struct surf_action_host {
+typedef struct surf_action_cpu {
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 */
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;
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) */
#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);
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
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)