From: alegrand Date: Sat, 11 Dec 2004 00:12:07 +0000 (+0000) Subject: No more xbt_maxmin_float_t not xbt_heap_float_t. I use double everywhere. In X-Git-Tag: v3.3~4730 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d25ee31741e8dd64436721b11fe82a0969f369cf No more xbt_maxmin_float_t not xbt_heap_float_t. I use double everywhere. In SimGrid 2 I had to use long double for precision reason. Probably because of the trace integration but I should not need it anymore since there is no more trace integration. The real question is "is double sufficient for time values". The answer is yes since for values larger than 272 years, you still have a precision of 1e-6 s. float is clearly not sufficient however. Let's use doubles then ! git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@620 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/include/xbt/heap.h b/include/xbt/heap.h index 4226968f3f..0daea05021 100644 --- a/include/xbt/heap.h +++ b/include/xbt/heap.h @@ -16,10 +16,10 @@ xbt_heap_t xbt_heap_new(int num, void_f_pvoid_t free_func); void xbt_heap_free(xbt_heap_t H); int xbt_heap_size(xbt_heap_t H); -void xbt_heap_push(xbt_heap_t H, void *content, xbt_heap_float_t key); +void xbt_heap_push(xbt_heap_t H, void *content, double key); void *xbt_heap_pop(xbt_heap_t H); -xbt_heap_float_t xbt_heap_maxkey(xbt_heap_t H); +double xbt_heap_maxkey(xbt_heap_t H); void *xbt_heap_maxcontent(xbt_heap_t H); #endif /* _XBT_HEAP_H */ diff --git a/include/xbt/misc.h b/include/xbt/misc.h index 0ec724cec5..33f15d0247 100644 --- a/include/xbt/misc.h +++ b/include/xbt/misc.h @@ -53,15 +53,6 @@ typedef struct { typedef void (void_f_ppvoid_t)(void**); typedef void (void_f_pvoid_t) (void*); -/* The following two definitions concern the type of the keys used for - the heaps. That should be handled via configure (FIXME). */ -typedef long double xbt_heap_float_t; -#define XBT_HEAP_FLOAT_T "%Lg" /* for printing purposes */ - -typedef long double xbt_maxmin_float_t; -#define XBT_MAXMIN_FLOAT_T "%Lg" /* for printing purposes */ - - END_DECL #endif /* XBT_MISC_H */ diff --git a/src/include/surf/maxmin.h b/src/include/surf/maxmin.h index b75ded8685..279b8ba2a8 100644 --- a/src/include/surf/maxmin.h +++ b/src/include/surf/maxmin.h @@ -18,36 +18,37 @@ void lmm_system_free(lmm_system_t sys); void lmm_variable_disable(lmm_system_t sys, lmm_variable_t var); lmm_constraint_t lmm_constraint_new(lmm_system_t sys, void *id, - xbt_maxmin_float_t bound_value); + double bound_value); void lmm_constraint_free(lmm_system_t sys, lmm_constraint_t cnst); lmm_variable_t lmm_variable_new(lmm_system_t sys, void *id, - xbt_maxmin_float_t weight_value, - xbt_maxmin_float_t bound, - int number_of_constraints); + double weight_value, + double bound, int number_of_constraints); void lmm_variable_free(lmm_system_t sys, lmm_variable_t var); -xbt_maxmin_float_t lmm_variable_getvalue(lmm_variable_t var); +double lmm_variable_getvalue(lmm_variable_t var); void lmm_expand(lmm_system_t sys, lmm_constraint_t cnst, - lmm_variable_t var, xbt_maxmin_float_t value); + lmm_variable_t var, double value); -lmm_constraint_t lmm_get_cnst_from_var(lmm_system_t sys, lmm_variable_t var, int num); +lmm_constraint_t lmm_get_cnst_from_var(lmm_system_t sys, + lmm_variable_t var, int num); int lmm_get_number_of_cnst_from_var(lmm_system_t sys, lmm_variable_t var); -lmm_variable_t lmm_get_var_from_cnst(lmm_system_t sys, lmm_constraint_t cnst, - lmm_variable_t *var); +lmm_variable_t lmm_get_var_from_cnst(lmm_system_t sys, + lmm_constraint_t cnst, + lmm_variable_t * var); void *lmm_constraint_id(lmm_constraint_t cnst); void *lmm_variable_id(lmm_variable_t var); void lmm_update(lmm_system_t sys, lmm_constraint_t cnst, - lmm_variable_t var, xbt_maxmin_float_t value); + lmm_variable_t var, double value); void lmm_update_variable_bound(lmm_system_t sys, lmm_variable_t var, - xbt_maxmin_float_t bound); + double bound); void lmm_update_variable_weight(lmm_system_t sys, lmm_variable_t var, - xbt_maxmin_float_t weight); + double weight); void lmm_update_constraint_bound(lmm_system_t sys, lmm_constraint_t cnst, - xbt_maxmin_float_t bound); + double bound); int lmm_constraint_used(lmm_system_t sys, lmm_constraint_t cnst); diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 66e7041eec..5786c385c8 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -38,13 +38,13 @@ typedef struct surf_action_state { typedef struct surf_action { s_xbt_swag_hookup_t state_hookup; xbt_swag_t state_set; - xbt_maxmin_float_t cost; /* cost */ - xbt_maxmin_float_t max_duration; /* max_duration (may fluctuate until - the task is completed) */ - xbt_maxmin_float_t remains; /* How much of that cost remains to + double cost; /* cost */ + double max_duration; /* max_duration (may fluctuate until + the task is completed) */ + double remains; /* How much of that cost remains to * be done in the currently running task */ - xbt_heap_float_t start; /* start time */ - xbt_heap_float_t finish; /* finish time : this is modified during the run + double start; /* start time */ + double finish; /* finish time : this is modified during the run * and fluctuates until the task is completed */ void *callback; /* for your convenience */ surf_resource_t resource_type; @@ -90,8 +90,8 @@ typedef enum { typedef struct surf_cpu_resource_extension_private *surf_cpu_resource_extension_private_t; typedef struct surf_cpu_resource_extension_public { - surf_action_t(*execute) (void *cpu, xbt_maxmin_float_t size); - surf_action_t(*sleep) (void *cpu, xbt_maxmin_float_t duration); + surf_action_t(*execute) (void *cpu, double size); + surf_action_t(*sleep) (void *cpu, double duration); void (*suspend) (surf_action_t action); void (*resume) (surf_action_t action); e_surf_cpu_state_t(*get_state) (void *cpu); @@ -110,8 +110,7 @@ void surf_cpu_resource_init(const char *filename); typedef struct surf_network_resource_extension_private *surf_network_resource_extension_private_t; typedef struct surf_network_resource_extension_public { - surf_action_t(*communicate) (void *src, void *dst, - xbt_maxmin_float_t size); + surf_action_t(*communicate) (void *src, void *dst, double size); } s_surf_network_resource_extension_public_t, *surf_network_resource_extension_public_t; @@ -128,14 +127,13 @@ void surf_network_resource_init(const char *filename); typedef struct surf_workstation_resource_extension_private *surf_workstation_resource_extension_private_t; typedef struct surf_workstation_resource_extension_public { - surf_action_t(*execute) (void *workstation, xbt_maxmin_float_t size); - surf_action_t(*sleep) (void *workstation, xbt_maxmin_float_t duration); + surf_action_t(*execute) (void *workstation, double size); + surf_action_t(*sleep) (void *workstation, double duration); void (*suspend) (surf_action_t action); void (*resume) (surf_action_t action); e_surf_cpu_state_t(*get_state) (void *workstation); surf_action_t(*communicate) (void *workstation_src, - void *workstation_dst, - xbt_maxmin_float_t size); + void *workstation_dst, double size); } s_surf_workstation_resource_extension_public_t, *surf_workstation_resource_extension_public_t; @@ -156,10 +154,10 @@ void surf_init(int *argc, char **argv); /* initialize common structures */ extern xbt_dynar_t resource_list; /* list of initialized resources */ -xbt_heap_float_t surf_solve(void); /* update all states and returns - the time elapsed since last - event */ -xbt_heap_float_t surf_get_clock(void); +double surf_solve(void); /* update all states and returns + the time elapsed since last + event */ +double surf_get_clock(void); void surf_finalize(void); /* clean everything */ #endif /* _SURF_SURF_H */ diff --git a/src/include/surf/surf_parse.h b/src/include/surf/surf_parse.h index c656cc5c60..d7347cd991 100644 --- a/src/include/surf/surf_parse.h +++ b/src/include/surf/surf_parse.h @@ -31,29 +31,29 @@ extern int char_pos; extern int tok_num; e_surf_token_t surf_parse(void); -void find_section(const char* file, const char* section_name); -void close_section(const char* section_name); -void surf_parse_float(xbt_maxmin_float_t *value); -void surf_parse_trace(tmgr_trace_t *trace); +void find_section(const char *file, const char *section_name); +void close_section(const char *section_name); +void surf_parse_double(double *value); +void surf_parse_trace(tmgr_trace_t * trace); /* Should not be called if you use the previous "section" functions */ -void surf_parse_open(const char *file); -void surf_parse_close(void); +void surf_parse_open(const char *file); +void surf_parse_close(void); /* Prototypes of the functions offered by flex */ int surf_parse_lex(void); -int surf_parse_get_lineno (void); -FILE *surf_parse_get_in (void); -FILE *surf_parse_get_out (void); -int surf_parse_get_leng (void); -char *surf_parse_get_text (void); -void surf_parse_set_lineno (int line_number ); -void surf_parse_set_in (FILE * in_str ); -void surf_parse_set_out (FILE * out_str ); -int surf_parse_get_debug (void); -void surf_parse_set_debug (int bdebug ); -int surf_parse_lex_destroy (void); +int surf_parse_get_lineno(void); +FILE *surf_parse_get_in(void); +FILE *surf_parse_get_out(void); +int surf_parse_get_leng(void); +char *surf_parse_get_text(void); +void surf_parse_set_lineno(int line_number); +void surf_parse_set_in(FILE * in_str); +void surf_parse_set_out(FILE * out_str); +int surf_parse_get_debug(void); +void surf_parse_set_debug(int bdebug); +int surf_parse_lex_destroy(void); #endif diff --git a/src/include/surf/trace_mgr.h b/src/include/surf/trace_mgr.h index 86a45b9997..bcb8ef81f1 100644 --- a/src/include/surf/trace_mgr.h +++ b/src/include/surf/trace_mgr.h @@ -23,16 +23,17 @@ void tmgr_history_free(tmgr_history_t history); tmgr_trace_t tmgr_trace_new(const char *filename); void tmgr_trace_free(tmgr_trace_t trace); -tmgr_trace_event_t tmgr_history_add_trace(tmgr_history_t history, tmgr_trace_t trace, - xbt_heap_float_t start_time, int offset, +tmgr_trace_event_t tmgr_history_add_trace(tmgr_history_t history, + tmgr_trace_t trace, + double start_time, int offset, void *resource); /* Access functions */ -xbt_heap_float_t tmgr_history_next_date(tmgr_history_t history); +double tmgr_history_next_date(tmgr_history_t history); tmgr_trace_event_t tmgr_history_get_next_event_leq(tmgr_history_t history, - xbt_heap_float_t date, - xbt_maxmin_float_t * value, - void **resource); + double date, + double *value, + void **resource); void tmgr_finalize(void); diff --git a/src/surf/cpu.c b/src/surf/cpu.c index 768df15f91..bafeea79bf 100644 --- a/src/surf/cpu.c +++ b/src/surf/cpu.c @@ -29,8 +29,8 @@ static void cpu_free(void *CPU) state_trace values mean SURF_CPU_ON if >0 and SURF_CPU_OFF otherwise. */ -static cpu_t cpu_new(const char *name, xbt_maxmin_float_t power_scale, - xbt_maxmin_float_t power_initial, +static cpu_t cpu_new(const char *name, double power_scale, + double power_initial, tmgr_trace_t power_trace, e_surf_cpu_state_t state_initial, tmgr_trace_t state_trace) @@ -66,23 +66,23 @@ static cpu_t cpu_new(const char *name, xbt_maxmin_float_t power_scale, power trace state trace Token: TOKEN_WORD TOKEN_WORD TOKEN_WORD TOKEN_WORD TOKEN_WORD TOKEN_WORD - Type: string float float string ON/OFF string + Type: string double double string ON/OFF string */ static void parse_cpu(void) { e_surf_token_t token; char *name = NULL; - xbt_maxmin_float_t power_scale = 0.0; - xbt_maxmin_float_t power_initial = 0.0; + double power_scale = 0.0; + double power_initial = 0.0; tmgr_trace_t power_trace = NULL;; e_surf_cpu_state_t state_initial = SURF_CPU_OFF; tmgr_trace_t state_trace = NULL; name = xbt_strdup(surf_parse_text); - surf_parse_float(&power_scale); - surf_parse_float(&power_initial); + surf_parse_double(&power_scale); + surf_parse_double(&power_initial); surf_parse_trace(&power_trace); token = surf_parse(); /* state_initial */ @@ -176,7 +176,7 @@ static void action_change_state(surf_action_t action, return; } -static xbt_heap_float_t share_resources(xbt_heap_float_t now) +static double share_resources(double now) { s_surf_action_cpu_t action; return generic_maxmin_share_resources(surf_cpu_resource->common_public-> @@ -184,8 +184,7 @@ static xbt_heap_float_t share_resources(xbt_heap_float_t now) xbt_swag_offset(action, variable)); } -static void update_actions_state(xbt_heap_float_t now, - xbt_heap_float_t delta) +static void update_actions_state(double now, double delta) { surf_action_cpu_t action = NULL; surf_action_cpu_t next_action = NULL; @@ -234,12 +233,12 @@ static void update_actions_state(xbt_heap_float_t now, static void update_resource_state(void *id, tmgr_trace_event_t event_type, - xbt_maxmin_float_t value) + double value) { cpu_t cpu = id; -/* printf("[" XBT_HEAP_FLOAT_T "] Asking to update CPU \"%s\" with value " */ -/* XBT_MAXMIN_FLOAT_T " for event %p\n", surf_get_clock(), cpu->name, */ +/* printf("[" "%lg" "] Asking to update CPU \"%s\" with value " */ +/* "%lg" " for event %p\n", surf_get_clock(), cpu->name, */ /* value, event_type); */ if (event_type == cpu->power_event) { @@ -259,7 +258,7 @@ static void update_resource_state(void *id, return; } -static surf_action_t execute(void *cpu, xbt_maxmin_float_t size) +static surf_action_t execute(void *cpu, double size) { surf_action_cpu_t action = NULL; cpu_t CPU = cpu; @@ -291,7 +290,7 @@ static surf_action_t execute(void *cpu, xbt_maxmin_float_t size) return (surf_action_t) action; } -static surf_action_t action_sleep(void *cpu, xbt_maxmin_float_t duration) +static surf_action_t action_sleep(void *cpu, double duration) { surf_action_cpu_t action = NULL; diff --git a/src/surf/cpu_private.h b/src/surf/cpu_private.h index 506cdcb08c..17715ee9b7 100644 --- a/src/surf/cpu_private.h +++ b/src/surf/cpu_private.h @@ -20,8 +20,8 @@ typedef struct cpu { surf_resource_t resource; /* Any such object, added in a trace should start by this field!!! */ const char *name; - xbt_maxmin_float_t power_scale; - xbt_maxmin_float_t power_current; + double power_scale; + double power_current; tmgr_trace_event_t power_event; e_surf_cpu_state_t state_current; tmgr_trace_event_t state_event; diff --git a/src/surf/maxmin.c b/src/surf/maxmin.c index ba4b5c8dd2..ff9998267f 100644 --- a/src/surf/maxmin.c +++ b/src/surf/maxmin.c @@ -84,7 +84,7 @@ static void lmm_cnst_free(lmm_system_t sys, lmm_constraint_t cnst) } lmm_constraint_t lmm_constraint_new(lmm_system_t sys, void *id, - xbt_maxmin_float_t bound_value) + double bound_value) { lmm_constraint_t cnst = NULL; s_lmm_element_t elem; @@ -110,9 +110,8 @@ void lmm_constraint_free(lmm_system_t sys, lmm_constraint_t cnst) } lmm_variable_t lmm_variable_new(lmm_system_t sys, void *id, - xbt_maxmin_float_t weight, - xbt_maxmin_float_t bound, - int number_of_constraints) + double weight, + double bound, int number_of_constraints) { lmm_variable_t var = NULL; @@ -135,13 +134,13 @@ void lmm_variable_free(lmm_system_t sys, lmm_variable_t var) lmm_var_free(sys, var); } -xbt_maxmin_float_t lmm_variable_getvalue(lmm_variable_t var) +double lmm_variable_getvalue(lmm_variable_t var) { return (var->value); } void lmm_expand(lmm_system_t sys, lmm_constraint_t cnst, - lmm_variable_t var, xbt_maxmin_float_t value) + lmm_variable_t var, double value) { lmm_element_t elem = NULL; @@ -161,22 +160,28 @@ void lmm_expand(lmm_system_t sys, lmm_constraint_t cnst, make_constraint_active(sys, cnst); } -lmm_constraint_t lmm_get_cnst_from_var(lmm_system_t sys, lmm_variable_t var, int num) +lmm_constraint_t lmm_get_cnst_from_var(lmm_system_t sys, + lmm_variable_t var, int num) { - if(numcnsts_number) return(var->cnsts[num].constraint); - else return NULL; + if (num < var->cnsts_number) + return (var->cnsts[num].constraint); + else + return NULL; } int lmm_get_number_of_cnst_from_var(lmm_system_t sys, lmm_variable_t var) { - return(var->cnsts_number); + return (var->cnsts_number); } -lmm_variable_t lmm_get_var_from_cnst(lmm_system_t sys, lmm_constraint_t cnst, - lmm_variable_t *var) +lmm_variable_t lmm_get_var_from_cnst(lmm_system_t sys, + lmm_constraint_t cnst, + lmm_variable_t * var) { - if(!(*var)) xbt_swag_getFirst(&(cnst->element_set)); - else *var=xbt_swag_getNext(*var,cnst->element_set.offset); + if (!(*var)) + xbt_swag_getFirst(&(cnst->element_set)); + else + *var = xbt_swag_getNext(*var, cnst->element_set.offset); return *var; } @@ -191,17 +196,20 @@ void *lmm_variable_id(lmm_variable_t var) } static void saturated_constraint_set_update(lmm_system_t sys, - lmm_constraint_t cnst, - xbt_maxmin_float_t * min_usage) + lmm_constraint_t cnst, + double *min_usage) { lmm_constraint_t useless_cnst = NULL; - if(cnst->usage <=0) return; - if (cnst->remaining <= 0) return; + if (cnst->usage <= 0) + return; + if (cnst->remaining <= 0) + return; if ((*min_usage < 0) || (*min_usage > cnst->remaining / cnst->usage)) { *min_usage = cnst->remaining / cnst->usage; - while ((useless_cnst = xbt_swag_getFirst(&(sys->saturated_constraint_set)))) + while ((useless_cnst = + xbt_swag_getFirst(&(sys->saturated_constraint_set)))) xbt_swag_remove(useless_cnst, &(sys->saturated_constraint_set)); xbt_swag_insert(cnst, &(sys->saturated_constraint_set)); @@ -221,8 +229,8 @@ static void saturated_variable_set_update(lmm_system_t sys) while ((cnst = xbt_swag_getFirst(cnst_list))) { elem_list = &(cnst->active_element_set); xbt_swag_foreach(elem, elem_list) - if((elem->value>0) && (elem->variable->weight>0)) - xbt_swag_insert(elem->variable, &(sys->saturated_variable_set)); + if ((elem->value > 0) && (elem->variable->weight > 0)) + xbt_swag_insert(elem->variable, &(sys->saturated_variable_set)); xbt_swag_remove(cnst, cnst_list); } @@ -236,9 +244,10 @@ void lmm_solve(lmm_system_t sys) xbt_swag_t cnst_list = NULL; xbt_swag_t var_list = NULL; xbt_swag_t elem_list = NULL; - xbt_maxmin_float_t min_usage = -1; + double min_usage = -1; - if(!(sys->modified)) return; + if (!(sys->modified)) + return; /* Init */ var_list = &(sys->variable_set); @@ -256,7 +265,7 @@ void lmm_solve(lmm_system_t sys) cnst->remaining = cnst->bound; cnst->usage = 0; xbt_swag_foreach(elem, elem_list) { - if((elem->value>0) && (elem->variable->weight>0)) { + if ((elem->value > 0) && (elem->variable->weight > 0)) { cnst->usage += elem->value / elem->variable->weight; insert_active_elem_in_constraint(elem); } @@ -317,7 +326,7 @@ void lmm_solve(lmm_system_t sys) /* Not a O(1) function */ void lmm_update(lmm_system_t sys, lmm_constraint_t cnst, - lmm_variable_t var, xbt_maxmin_float_t value) + lmm_variable_t var, double value) { int i; @@ -330,21 +339,21 @@ void lmm_update(lmm_system_t sys, lmm_constraint_t cnst, } void lmm_update_variable_bound(lmm_system_t sys, lmm_variable_t var, - xbt_maxmin_float_t bound) + double bound) { sys->modified = 1; var->bound = bound; } void lmm_update_variable_weight(lmm_system_t sys, lmm_variable_t var, - xbt_maxmin_float_t weight) + double weight) { sys->modified = 1; var->weight = weight; } void lmm_update_constraint_bound(lmm_system_t sys, lmm_constraint_t cnst, - xbt_maxmin_float_t bound) + double bound) { sys->modified = 1; cnst->bound = bound; @@ -352,7 +361,7 @@ void lmm_update_constraint_bound(lmm_system_t sys, lmm_constraint_t cnst, int lmm_constraint_used(lmm_system_t sys, lmm_constraint_t cnst) { - return xbt_swag_belongs(cnst,&(sys->active_constraint_set)); + return xbt_swag_belongs(cnst, &(sys->active_constraint_set)); } diff --git a/src/surf/maxmin_private.h b/src/surf/maxmin_private.h index 26ca260087..7053c9ad14 100644 --- a/src/surf/maxmin_private.h +++ b/src/surf/maxmin_private.h @@ -18,7 +18,7 @@ typedef struct lmm_element { lmm_constraint_t constraint; lmm_variable_t variable; - xbt_maxmin_float_t value; + double value; } s_lmm_element_t, *lmm_element_t; #define insert_elem_in_constraint(elem) xbt_swag_insert(elem,&(elem->constraint->element_set)) #define insert_active_elem_in_constraint(elem) xbt_swag_insert(elem,&(elem->constraint->active_element_set)) @@ -32,9 +32,9 @@ typedef struct lmm_constraint { s_xbt_swag_t element_set; /* a list of lmm_mat_element_t */ s_xbt_swag_t active_element_set; /* a list of lmm_mat_element_t */ - xbt_maxmin_float_t bound; - xbt_maxmin_float_t remaining; - xbt_maxmin_float_t usage; + double bound; + double remaining; + double usage; void *id; } s_lmm_constraint_t; @@ -46,9 +46,9 @@ typedef struct lmm_variable { s_lmm_element_t *cnsts; int cnsts_size; int cnsts_number; - xbt_maxmin_float_t weight; - xbt_maxmin_float_t bound; - xbt_maxmin_float_t value; + double weight; + double bound; + double value; void *id; } s_lmm_variable_t; diff --git a/src/surf/network.c b/src/surf/network.c index fec83e5071..d8e4e4f632 100644 --- a/src/surf/network.c +++ b/src/surf/network.c @@ -36,9 +36,9 @@ static void network_link_free(void *nw_link) } static network_link_t network_link_new(const char *name, - xbt_maxmin_float_t bw_initial, + double bw_initial, tmgr_trace_t bw_trace, - xbt_maxmin_float_t lat_initial, + double lat_initial, tmgr_trace_t lat_trace, e_surf_network_link_state_t state_initial, @@ -104,24 +104,24 @@ static void route_new(int src_id, int dst_id, char **links, int nb_link) bandwidth trace latency trace state trace Token: TOKEN_WORD TOKEN_WORD TOKEN_WORD TOKEN_WORD TOKEN_WORD TOKEN_WORD TOKEN_WORD - Type: string float string float string ON/OFF string + Type: string double string double string ON/OFF string */ static void parse_network_link(void) { e_surf_token_t token; char *name; - xbt_maxmin_float_t bw_initial; + double bw_initial; tmgr_trace_t bw_trace; - xbt_maxmin_float_t lat_initial; + double lat_initial; tmgr_trace_t lat_trace; e_surf_network_link_state_t state_initial; tmgr_trace_t state_trace; name = xbt_strdup(surf_parse_text); - surf_parse_float(&bw_initial); + surf_parse_double(&bw_initial); surf_parse_trace(&bw_trace); - surf_parse_float(&lat_initial); + surf_parse_double(&lat_initial); surf_parse_trace(&lat_trace); token = surf_parse(); /* state_initial */ @@ -291,7 +291,7 @@ static void action_change_state(surf_action_t action, return; } -static xbt_heap_float_t share_resources(xbt_heap_float_t now) +static double share_resources(double now) { s_surf_action_network_t action; return generic_maxmin_share_resources(surf_network_resource-> @@ -301,10 +301,9 @@ static xbt_heap_float_t share_resources(xbt_heap_float_t now) } -static void update_actions_state(xbt_heap_float_t now, - xbt_heap_float_t delta) +static void update_actions_state(double now, double delta) { - xbt_heap_float_t deltap = 0.0; + double deltap = 0.0; surf_action_network_t action = NULL; surf_action_network_t next_action = NULL; xbt_swag_t running_actions = @@ -364,12 +363,12 @@ static void update_actions_state(xbt_heap_float_t now, static void update_resource_state(void *id, tmgr_trace_event_t event_type, - xbt_maxmin_float_t value) + double value) { network_link_t nw_link = id; -/* printf("[" XBT_HEAP_FLOAT_T "] Asking to update network card \"%s\" with value " */ -/* XBT_MAXMIN_FLOAT_T " for event %p\n", surf_get_clock(), nw_link->name, */ +/* printf("[" "%lg" "] Asking to update network card \"%s\" with value " */ +/* "%lg" " for event %p\n", surf_get_clock(), nw_link->name, */ /* value, event_type); */ if (event_type == nw_link->bw_event) { @@ -377,7 +376,7 @@ static void update_resource_state(void *id, lmm_update_constraint_bound(maxmin_system, nw_link->constraint, nw_link->bw_current); } else if (event_type == nw_link->lat_event) { - xbt_maxmin_float_t delta = value - nw_link->lat_current; + double delta = value - nw_link->lat_current; lmm_variable_t var = NULL; surf_action_network_t action = NULL; @@ -401,8 +400,7 @@ static void update_resource_state(void *id, return; } -static surf_action_t communicate(void *src, void *dst, - xbt_maxmin_float_t size) +static surf_action_t communicate(void *src, void *dst, double size) { surf_action_network_t action = NULL; network_card_t card_src = src; diff --git a/src/surf/network_private.h b/src/surf/network_private.h index 963f93236d..e873b07f0f 100644 --- a/src/surf/network_private.h +++ b/src/surf/network_private.h @@ -12,19 +12,19 @@ #include "xbt/dict.h" typedef enum { - SURF_NETWORK_LINK_ON = 1, /* Ready */ - SURF_NETWORK_LINK_OFF = 0 /* Running */ + SURF_NETWORK_LINK_ON = 1, /* Ready */ + SURF_NETWORK_LINK_OFF = 0 /* Running */ } e_surf_network_link_state_t; typedef struct network_link { - surf_resource_t resource; /* Any such object, added in a trace - should start by this field!!! */ - /* Using this object with the public part of - resource does not make sense */ + surf_resource_t resource; /* Any such object, added in a trace + should start by this field!!! */ + /* Using this object with the public part of + resource does not make sense */ const char *name; - xbt_maxmin_float_t bw_current; + double bw_current; tmgr_trace_event_t bw_event; - xbt_maxmin_float_t lat_current; + double lat_current; tmgr_trace_event_t lat_event; e_surf_network_link_state_t state_current; tmgr_trace_event_t state_event; @@ -39,8 +39,8 @@ typedef struct network_card { typedef struct surf_action_network { s_surf_action_t generic_action; - xbt_heap_float_t latency; - xbt_heap_float_t lat_current; + double latency; + double lat_current; lmm_variable_t variable; network_card_t src; network_card_t dst; diff --git a/src/surf/surf.c b/src/surf/surf.c index a563608987..5308482323 100644 --- a/src/surf/surf.c +++ b/src/surf/surf.c @@ -8,48 +8,49 @@ #include "surf_private.h" #include "xbt/module.h" -static xbt_heap_float_t NOW=0; +static double NOW = 0; xbt_dynar_t resource_list = NULL; tmgr_history_t history = NULL; lmm_system_t maxmin_system = NULL; -xbt_heap_float_t generic_maxmin_share_resources(xbt_swag_t running_actions, - size_t offset) +double generic_maxmin_share_resources(xbt_swag_t running_actions, + size_t offset) { surf_action_t action = NULL; - xbt_maxmin_float_t min = -1; - xbt_maxmin_float_t value = -1; + double min = -1; + double value = -1; #define VARIABLE(action) (*((lmm_variable_t*)(((char *) (action)) + (offset)))) - lmm_solve(maxmin_system); + lmm_solve(maxmin_system); xbt_swag_foreach(action, running_actions) { value = lmm_variable_getvalue(VARIABLE(action)); - if((value>0) || (action->max_duration>=0)) break; + if ((value > 0) || (action->max_duration >= 0)) + break; } - + if (!action) return -1.0; - if(value>0) { + if (value > 0) { min = value = action->remains / value; - if((action->max_duration>=0) && - (action->max_durationmax_duration >= 0) && (action->max_duration < min)) min = action->max_duration; - } else min = action->max_duration; + } else + min = action->max_duration; + - - for(action=xbt_swag_getNext(action,running_actions->offset); - action; - action=xbt_swag_getNext(action,running_actions->offset)) { + for (action = xbt_swag_getNext(action, running_actions->offset); + action; + action = xbt_swag_getNext(action, running_actions->offset)) { value = lmm_variable_getvalue(VARIABLE(action)); - if(value>0) { + if (value > 0) { value = action->remains / value; - if (value < min) min = value; + if (value < min) + min = value; } - if((action->max_duration>=0) && - (action->max_durationmax_duration >= 0) && (action->max_duration < min)) min = action->max_duration; } #undef VARIABLE @@ -58,15 +59,16 @@ xbt_heap_float_t generic_maxmin_share_resources(xbt_swag_t running_actions, e_surf_action_state_t surf_action_get_state(surf_action_t action) { - surf_action_state_t action_state = &(action->resource_type->common_public->states); - - if(action->state_set == action_state->ready_action_set) + surf_action_state_t action_state = + &(action->resource_type->common_public->states); + + if (action->state_set == action_state->ready_action_set) return SURF_ACTION_READY; - if(action->state_set == action_state->running_action_set) + if (action->state_set == action_state->running_action_set) return SURF_ACTION_RUNNING; - if(action->state_set == action_state->failed_action_set) + if (action->state_set == action_state->failed_action_set) return SURF_ACTION_FAILED; - if(action->state_set == action_state->done_action_set) + if (action->state_set == action_state->done_action_set) return SURF_ACTION_DONE; return SURF_ACTION_NOT_IN_THE_SYSTEM; } @@ -75,81 +77,92 @@ void surf_action_free(surf_action_t * action) { (*action)->resource_type->common_public->action_cancel(*action); xbt_free(*action); - *action=NULL; + *action = NULL; } -void surf_action_change_state(surf_action_t action, e_surf_action_state_t state) +void surf_action_change_state(surf_action_t action, + e_surf_action_state_t state) { - surf_action_state_t action_state = &(action->resource_type->common_public->states); + surf_action_state_t action_state = + &(action->resource_type->common_public->states); xbt_swag_remove(action, action->state_set); - if(state == SURF_ACTION_READY) + if (state == SURF_ACTION_READY) action->state_set = action_state->ready_action_set; - else if(state == SURF_ACTION_RUNNING) + else if (state == SURF_ACTION_RUNNING) action->state_set = action_state->running_action_set; - else if(state == SURF_ACTION_FAILED) + else if (state == SURF_ACTION_FAILED) action->state_set = action_state->failed_action_set; - else if(state == SURF_ACTION_DONE) + else if (state == SURF_ACTION_DONE) action->state_set = action_state->done_action_set; - else action->state_set = NULL; + else + action->state_set = NULL; - if(action->state_set) xbt_swag_insert(action, action->state_set); + if (action->state_set) + xbt_swag_insert(action, action->state_set); } void surf_init(int *argc, char **argv) { xbt_init(argc, argv); - if(!resource_list) resource_list = xbt_dynar_new(sizeof(surf_resource_private_t), NULL); - if(!history) history = tmgr_history_new(); - if(!maxmin_system) maxmin_system = lmm_system_new(); + if (!resource_list) + resource_list = xbt_dynar_new(sizeof(surf_resource_private_t), NULL); + if (!history) + history = tmgr_history_new(); + if (!maxmin_system) + maxmin_system = lmm_system_new(); } void surf_finalize(void) -{ +{ int i; surf_resource_t resource = NULL; - xbt_dynar_foreach (resource_list,i,resource) { + xbt_dynar_foreach(resource_list, i, resource) { resource->common_private->finalize(); } - if(maxmin_system) { + if (maxmin_system) { lmm_system_free(maxmin_system); maxmin_system = NULL; } - if(history) { + if (history) { tmgr_history_free(history); history = NULL; } - if(resource_list) xbt_dynar_free(&resource_list); + if (resource_list) + xbt_dynar_free(&resource_list); tmgr_finalize(); } -xbt_heap_float_t surf_solve(void) +double surf_solve(void) { static int first_run = 1; - xbt_heap_float_t min = -1.0; - xbt_heap_float_t next_event_date = -1.0; - xbt_heap_float_t resource_next_action_end = -1.0; - xbt_maxmin_float_t value = -1.0; + double min = -1.0; + double next_event_date = -1.0; + double resource_next_action_end = -1.0; + double value = -1.0; surf_resource_object_t resource_obj = NULL; surf_resource_t resource = NULL; tmgr_trace_event_t event = NULL; int i; - if(first_run) { + if (first_run) { while ((next_event_date = tmgr_history_next_date(history)) != -1.0) { - if(next_event_date > NOW) break; - while ((event = tmgr_history_get_next_event_leq(history, next_event_date, - &value, (void **) &resource_obj))) { - resource_obj->resource->common_private->update_resource_state(resource_obj, - event, value); + if (next_event_date > NOW) + break; + while ((event = + tmgr_history_get_next_event_leq(history, next_event_date, + &value, + (void **) &resource_obj))) { + resource_obj->resource->common_private-> + update_resource_state(resource_obj, event, value); } } - xbt_dynar_foreach (resource_list,i,resource) { + xbt_dynar_foreach(resource_list, i, resource) { resource->common_private->update_actions_state(NOW, 0.0); } first_run = 0; @@ -158,39 +171,46 @@ xbt_heap_float_t surf_solve(void) min = -1.0; - xbt_dynar_foreach (resource_list,i,resource) { - resource_next_action_end = resource->common_private->share_resources(NOW); - if(((min<0.0) || (resource_next_action_end=0.0)) + xbt_dynar_foreach(resource_list, i, resource) { + resource_next_action_end = + resource->common_private->share_resources(NOW); + if (((min < 0.0) || (resource_next_action_end < min)) + && (resource_next_action_end >= 0.0)) min = resource_next_action_end; } - if(min<0.0) return 0.0; + if (min < 0.0) + return 0.0; while ((next_event_date = tmgr_history_next_date(history)) != -1.0) { - if(next_event_date > NOW+min) break; - while ((event=tmgr_history_get_next_event_leq(history, next_event_date, - &value, (void **) &resource_obj))) { - if(resource_obj->resource->common_private->resource_used(resource_obj)) { - min = next_event_date-NOW; + if (next_event_date > NOW + min) + break; + while ((event = + tmgr_history_get_next_event_leq(history, next_event_date, + &value, + (void **) &resource_obj))) { + if (resource_obj->resource->common_private-> + resource_used(resource_obj)) { + min = next_event_date - NOW; } /* update state of resource_obj according to new value. Does not touch lmm. It will be modified if needed when updating actions */ - resource_obj->resource->common_private->update_resource_state(resource_obj, - event, value); + resource_obj->resource->common_private-> + update_resource_state(resource_obj, event, value); } } - xbt_dynar_foreach (resource_list,i,resource) { + xbt_dynar_foreach(resource_list, i, resource) { resource->common_private->update_actions_state(NOW, min); } - NOW=NOW+min; + NOW = NOW + min; return min; } -xbt_heap_float_t surf_get_clock(void) +double surf_get_clock(void) { return NOW; } diff --git a/src/surf/surf_parse.l b/src/surf/surf_parse.l index d2bee6502b..f8558f6c78 100644 --- a/src/surf/surf_parse.l +++ b/src/surf/surf_parse.l @@ -184,7 +184,7 @@ void close_section(const char* section_name) void surf_parse_open(const char *file) { file_to_parse = fopen(file,"r"); - xbt_assert1((file_to_parse), "Unable to open \"%s\"\n",file) + xbt_assert1((file_to_parse), "Unable to open \"%s\"\n",file); input_buffer = surf_parse__create_buffer( file_to_parse, 10 ); surf_parse__switch_to_buffer(input_buffer); @@ -202,14 +202,14 @@ void surf_parse_close(void) { tok_num = 0; } -void surf_parse_float(xbt_maxmin_float_t *value) +void surf_parse_double(double *value) { e_surf_token_t token; int ret = 0; token = surf_parse(); /* power_scale */ xbt_assert1((token == TOKEN_WORD), "Parse error line %d", line_pos); - ret = sscanf(surf_parse_text, XBT_MAXMIN_FLOAT_T, value); + ret = sscanf(surf_parse_text, "%lg", value); xbt_assert2((ret==1), "Parse error line %d : %s not a number", line_pos, surf_parse_text); } diff --git a/src/surf/surf_private.h b/src/surf/surf_private.h index 3fbf9959e2..ff76645a17 100644 --- a/src/surf/surf_private.h +++ b/src/surf/surf_private.h @@ -17,25 +17,27 @@ #define NO_MAX_DURATION -1.0 typedef struct surf_resource_private { - int (*resource_used)(void *resource_id); + int (*resource_used) (void *resource_id); /* Share the resources to the actions and return in hom much time - the next action may terminate */ - xbt_heap_float_t(*share_resources) (xbt_heap_float_t now); + the next action may terminate */ + double (*share_resources) (double now); /* Update the actions' state */ - void (*update_actions_state) (xbt_heap_float_t now, xbt_heap_float_t delta); - void (*update_resource_state) (void *id,tmgr_trace_event_t event_type, xbt_maxmin_float_t value); - void (*finalize)(void); + void (*update_actions_state) (double now, double delta); + void (*update_resource_state) (void *id, tmgr_trace_event_t event_type, + double value); + void (*finalize) (void); } s_surf_resource_private_t; /* #define pub2priv(r) ((surf_resource_private_t) ((char *)(r) -(sizeof(struct surf_resource_private_part)))) */ /* #define priv2pub(r) ((void *) ((char *)(r) +(sizeof(struct surf_resource_private_part)))) */ -xbt_heap_float_t generic_maxmin_share_resources(xbt_swag_t running_actions, - size_t offset); +double generic_maxmin_share_resources(xbt_swag_t running_actions, + size_t offset); /* Generic functions common to all ressources */ e_surf_action_state_t surf_action_get_state(surf_action_t action); void surf_action_free(surf_action_t * action); -void surf_action_change_state(surf_action_t action, e_surf_action_state_t state); +void surf_action_change_state(surf_action_t action, + e_surf_action_state_t state); extern lmm_system_t maxmin_system; extern tmgr_history_t history; diff --git a/src/surf/trace_mgr.c b/src/surf/trace_mgr.c index 8eb0ca0ff1..80db05db81 100644 --- a/src/surf/trace_mgr.c +++ b/src/surf/trace_mgr.c @@ -43,7 +43,7 @@ tmgr_trace_t tmgr_trace_new(const char *filename) FILE *f = NULL; int linecount = 0; char line[256]; - xbt_heap_float_t periodicity = -1.0; /* No periodicity by default */ + double periodicity = -1.0; /* No periodicity by default */ s_tmgr_event_t event; tmgr_event_t last_event = NULL; @@ -54,7 +54,7 @@ tmgr_trace_t tmgr_trace_new(const char *filename) } if ((f = fopen(filename, "r")) == NULL) { - xbt_assert1(0,"Cannot open file '%s'", filename); + xbt_assert1(0, "Cannot open file '%s'", filename); } trace = xbt_new0(s_tmgr_trace_t, 1); @@ -65,24 +65,25 @@ tmgr_trace_t tmgr_trace_new(const char *filename) if ((line[0] == '#') || (line[0] == '\n') || (line[0] == '%')) continue; - if (sscanf(line, "PERIODICITY " XBT_HEAP_FLOAT_T "\n", &(periodicity)) + if (sscanf(line, "PERIODICITY " "%lg" "\n", &(periodicity)) == 1) { if (periodicity <= 0) { - xbt_assert2(0,"%s,%d: Syntax error. Periodicity has to be positive", + xbt_assert2(0, + "%s,%d: Syntax error. Periodicity has to be positive", filename, linecount); } continue; } if (sscanf - (line, XBT_HEAP_FLOAT_T " " XBT_MAXMIN_FLOAT_T "\n", &event.delta, - &event.value) != 2) { - xbt_assert2(0,"%s,%d: Syntax error", filename, linecount); + (line, "%lg" " " "%lg" "\n", &event.delta, &event.value) != 2) { + xbt_assert2(0, "%s,%d: Syntax error", filename, linecount); } if (last_event) { if ((last_event->delta = event.delta - last_event->delta) <= 0) { - xbt_assert2(0,"%s,%d: Invalid trace value, events have to be sorted", + xbt_assert2(0, + "%s,%d: Invalid trace value, events have to be sorted", filename, linecount); } } @@ -116,8 +117,9 @@ void tmgr_trace_free(tmgr_trace_t trace) xbt_free(trace); } -tmgr_trace_event_t tmgr_history_add_trace(tmgr_history_t history, tmgr_trace_t trace, - xbt_heap_float_t start_time, int offset, +tmgr_trace_event_t tmgr_history_add_trace(tmgr_history_t history, + tmgr_trace_t trace, + double start_time, int offset, void *resource) { tmgr_trace_event_t trace_event = NULL; @@ -136,7 +138,7 @@ tmgr_trace_event_t tmgr_history_add_trace(tmgr_history_t history, tmgr_trace_t t return trace_event; } -xbt_heap_float_t tmgr_history_next_date(tmgr_history_t history) +double tmgr_history_next_date(tmgr_history_t history) { if (xbt_heap_size(history->heap)) return (xbt_heap_maxkey(history->heap)); @@ -145,11 +147,11 @@ xbt_heap_float_t tmgr_history_next_date(tmgr_history_t history) } tmgr_trace_event_t tmgr_history_get_next_event_leq(tmgr_history_t history, - xbt_heap_float_t date, - xbt_maxmin_float_t * value, + double date, + double *value, void **resource) { - xbt_heap_float_t event_date = xbt_heap_maxkey(history->heap); + double event_date = xbt_heap_maxkey(history->heap); tmgr_trace_event_t trace_event = NULL; tmgr_event_t event = NULL; tmgr_trace_t trace = NULL; diff --git a/src/surf/trace_mgr_private.h b/src/surf/trace_mgr_private.h index 5bd6c32ffd..f63d1a28c4 100644 --- a/src/surf/trace_mgr_private.h +++ b/src/surf/trace_mgr_private.h @@ -13,8 +13,8 @@ #include "surf/trace_mgr.h" typedef struct tmgr_event { - xbt_heap_float_t delta; - xbt_maxmin_float_t value; + double delta; + double value; } s_tmgr_event_t, *tmgr_event_t; typedef struct tmgr_trace { diff --git a/src/surf/workstation.c b/src/surf/workstation.c index 85433667e1..0cf5fc7c04 100644 --- a/src/surf/workstation.c +++ b/src/surf/workstation.c @@ -89,33 +89,31 @@ static void action_change_state(surf_action_t action, return; } -static xbt_heap_float_t share_resources(xbt_heap_float_t now) +static double share_resources(double now) { return -1.0; } -static void update_actions_state(xbt_heap_float_t now, - xbt_heap_float_t delta) +static void update_actions_state(double now, double delta) { return; } static void update_resource_state(void *id, tmgr_trace_event_t event_type, - xbt_maxmin_float_t value) + double value) { return; } -static surf_action_t execute(void *workstation, xbt_maxmin_float_t size) +static surf_action_t execute(void *workstation, double size) { return surf_cpu_resource->extension_public-> execute(((workstation_t) workstation)->cpu, size); } -static surf_action_t action_sleep(void *workstation, - xbt_maxmin_float_t duration) +static surf_action_t action_sleep(void *workstation, double duration) { return surf_cpu_resource->extension_public-> sleep(((workstation_t) workstation)->cpu, duration); @@ -138,8 +136,7 @@ static void action_resume(surf_action_t action) } static surf_action_t communicate(void *workstation_src, - void *workstation_dst, - xbt_maxmin_float_t size) + void *workstation_dst, double size) { return surf_network_resource->extension_public-> communicate(((workstation_t) workstation_src)->network_card, diff --git a/src/xbt/heap.c b/src/xbt/heap.c index 5ddbdf6d77..d9c31a1977 100644 --- a/src/xbt/heap.c +++ b/src/xbt/heap.c @@ -10,7 +10,7 @@ #include "xbt/sysdep.h" #include "xbt/error.h" #include "heap_private.h" -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(heap,xbt,"Heap"); +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(heap, xbt, "Heap"); /** * xbt_heap_new: @@ -67,7 +67,7 @@ int xbt_heap_size(xbt_heap_t H) * Add an element int the heap. The element with the smallest key is * automatically moved at the top of the heap. */ -void xbt_heap_push(xbt_heap_t H, void *content, xbt_heap_float_t key) +void xbt_heap_push(xbt_heap_t H, void *content, double key) { int count = ++(H->count); int size = H->size; @@ -95,9 +95,10 @@ void xbt_heap_push(xbt_heap_t H, void *content, xbt_heap_float_t key) */ void *xbt_heap_pop(xbt_heap_t H) { - void *max ; + void *max; - if(H->count==0) return NULL; + if (H->count == 0) + return NULL; max = CONTENT(H, 0); @@ -119,9 +120,10 @@ void *xbt_heap_pop(xbt_heap_t H) * * Returns the smallest key in the heap without modifying the heap. */ -xbt_heap_float_t xbt_heap_maxkey(xbt_heap_t H) +double xbt_heap_maxkey(xbt_heap_t H) { - if(H->count==0) abort(); + if (H->count == 0) + abort(); return KEY(H, 0); } @@ -134,7 +136,8 @@ xbt_heap_float_t xbt_heap_maxkey(xbt_heap_t H) */ void *xbt_heap_maxcontent(xbt_heap_t H) { - if(H->count==0) abort(); + if (H->count == 0) + abort(); return CONTENT(H, 0); } diff --git a/src/xbt/heap_private.h b/src/xbt/heap_private.h index 782947b25c..87de1eb58a 100644 --- a/src/xbt/heap_private.h +++ b/src/xbt/heap_private.h @@ -13,7 +13,7 @@ typedef struct xbt_heapItem { void *content; - xbt_heap_float_t key; + double key; } s_xbt_heapItem_t, *xbt_heapItem_t; typedef struct xbt_heap { diff --git a/testsuite/surf/maxmin_bench.c b/testsuite/surf/maxmin_bench.c index a2b531e630..d3123c8d20 100644 --- a/testsuite/surf/maxmin_bench.c +++ b/testsuite/surf/maxmin_bench.c @@ -10,12 +10,12 @@ #include #include #include "surf/maxmin.h" -#include "gras/virtu.h" /* time manipulation for benchmarking */ +#include "gras/virtu.h" /* time manipulation for benchmarking */ double date; -xbt_maxmin_float_t float_random(xbt_maxmin_float_t max); -xbt_maxmin_float_t float_random(xbt_maxmin_float_t max) +double float_random(double max); +double float_random(double max) { return ((max * rand()) / (RAND_MAX + 1.0)); } diff --git a/testsuite/surf/platform.txt b/testsuite/surf/platform.txt index f135883a7b..090347b5f8 100644 --- a/testsuite/surf/platform.txt +++ b/testsuite/surf/platform.txt @@ -1,3 +1,4 @@ +/* $Id$ */ "Cpu A" 100.00 1.0 trace_A.txt ON trace_A_failure.txt diff --git a/testsuite/surf/surf_usage.c b/testsuite/surf/surf_usage.c index a4b030d4ac..0577f21822 100644 --- a/testsuite/surf/surf_usage.c +++ b/testsuite/surf/surf_usage.c @@ -44,10 +44,10 @@ void test(void) e_surf_action_state_t stateActionA; e_surf_action_state_t stateActionB; e_surf_action_state_t stateActionC; - xbt_maxmin_float_t now = -1.0; + double now = -1.0; - surf_cpu_resource_init("platform.txt"); /* Now it is possible to use CPUs */ - surf_network_resource_init("platform.txt"); /* Now it is possible to use eth0 */ + surf_cpu_resource_init("platform.txt"); /* Now it is possible to use CPUs */ + surf_network_resource_init("platform.txt"); /* Now it is possible to use eth0 */ /*********************** CPU ***********************************/ printf("%p \n", surf_cpu_resource); @@ -55,8 +55,10 @@ void test(void) cpuB = surf_cpu_resource->common_public->name_service("Cpu B"); /* Let's check that those two processors exist */ - printf("%s : %p\n", surf_cpu_resource->common_public->get_resource_name(cpuA), cpuA); - printf("%s : %p\n", surf_cpu_resource->common_public->get_resource_name(cpuB), cpuB); + printf("%s : %p\n", + surf_cpu_resource->common_public->get_resource_name(cpuA), cpuA); + printf("%s : %p\n", + surf_cpu_resource->common_public->get_resource_name(cpuB), cpuB); /* Let's do something on it */ actionA = surf_cpu_resource->extension_public->execute(cpuA, 1000.0); @@ -79,37 +81,51 @@ void test(void) cardB = surf_network_resource->common_public->name_service("Cpu B"); /* Let's check that those two processors exist */ - printf("%s : %p\n", surf_network_resource->common_public->get_resource_name(cardA), cardA); - printf("%s : %p\n", surf_network_resource->common_public->get_resource_name(cardB), cardB); + printf("%s : %p\n", + surf_network_resource->common_public->get_resource_name(cardA), + cardA); + printf("%s : %p\n", + surf_network_resource->common_public->get_resource_name(cardB), + cardB); /* Let's do something on it */ - commAB = surf_network_resource->extension_public->communicate(cardA, cardB, 150.0); + commAB = + surf_network_resource->extension_public->communicate(cardA, cardB, + 150.0); - surf_solve(); /* Takes traces into account. Returns 0.0 */ + surf_solve(); /* Takes traces into account. Returns 0.0 */ do { - surf_action_t action = NULL; + surf_action_t action = NULL; now = surf_get_clock(); - printf("Next Event : " XBT_HEAP_FLOAT_T "\n", now); + printf("Next Event : " "%lg" "\n", now); printf("\t CPU actions\n"); - while((action=xbt_swag_extract(surf_cpu_resource->common_public->states.failed_action_set))) { + while ((action = + xbt_swag_extract(surf_cpu_resource->common_public->states. + failed_action_set))) { printf("\t * Failed : %p\n", action); action->resource_type->common_public->action_free(action); } - while((action=xbt_swag_extract(surf_cpu_resource->common_public->states.done_action_set))) { + while ((action = + xbt_swag_extract(surf_cpu_resource->common_public->states. + done_action_set))) { printf("\t * Done : %p\n", action); action->resource_type->common_public->action_free(action); } printf("\t Network actions\n"); - while((action=xbt_swag_extract(surf_network_resource->common_public->states.failed_action_set))) { + while ((action = + xbt_swag_extract(surf_network_resource->common_public->states. + failed_action_set))) { printf("\t * Failed : %p\n", action); action->resource_type->common_public->action_free(action); } - while((action=xbt_swag_extract(surf_network_resource->common_public->states.done_action_set))) { + while ((action = + xbt_swag_extract(surf_network_resource->common_public->states. + done_action_set))) { printf("\t * Done : %p\n", action); action->resource_type->common_public->action_free(action); } - } while(surf_solve()); + } while (surf_solve()); printf("Simulation Terminated\n"); @@ -119,7 +135,7 @@ void test(void) int main(int argc, char **argv) { - surf_init(&argc, argv); /* Initialize some common structures */ + surf_init(&argc, argv); /* Initialize some common structures */ test(); return 0; } diff --git a/testsuite/surf/surf_usage2.c b/testsuite/surf/surf_usage2.c index d4ca5374c2..55994dc68e 100644 --- a/testsuite/surf/surf_usage2.c +++ b/testsuite/surf/surf_usage2.c @@ -42,7 +42,7 @@ void test(void) e_surf_action_state_t stateActionA; e_surf_action_state_t stateActionB; e_surf_action_state_t stateActionC; - xbt_maxmin_float_t now = -1.0; + double now = -1.0; surf_workstation_resource_init("platform.txt"); @@ -82,9 +82,9 @@ void test(void) surf_resource_t resource = NULL; now = surf_get_clock(); - printf("Next Event : " XBT_HEAP_FLOAT_T "\n", now); - - xbt_dynar_foreach (resource_list,i,resource) { + printf("Next Event : " "%lg" "\n", now); + + xbt_dynar_foreach(resource_list, i, resource) { printf("\t %s actions\n", resource->common_public->name); while (action = xbt_swag_extract(resource->common_public->states. diff --git a/testsuite/surf/trace_usage.c b/testsuite/surf/trace_usage.c index 157ee5b370..ece86561a7 100644 --- a/testsuite/surf/trace_usage.c +++ b/testsuite/surf/trace_usage.c @@ -18,8 +18,8 @@ void test(void) tmgr_history_t history = tmgr_history_new(); tmgr_trace_t trace_A = tmgr_trace_new("trace_A.txt"); tmgr_trace_t trace_B = tmgr_trace_new("trace_B.txt"); - xbt_heap_float_t next_event_date = -1.0; - xbt_maxmin_float_t value = -1.0; + double next_event_date = -1.0; + double value = -1.0; char *resource = NULL; char *host_A = strdup("Host A"); char *host_B = strdup("Host B"); @@ -28,10 +28,10 @@ void test(void) tmgr_history_add_trace(history, trace_B, 0.0, 0, host_B); while ((next_event_date = tmgr_history_next_date(history)) != -1.0) { - printf(XBT_HEAP_FLOAT_T " : \n", next_event_date); + printf("%lg" " : \n", next_event_date); while (tmgr_history_get_next_event_leq(history, next_event_date, &value, (void **) &resource)) { - printf("\t %s : " XBT_MAXMIN_FLOAT_T "\n", resource, value); + printf("\t %s : " "%lg" "\n", resource, value); } if (next_event_date > 1000) break; diff --git a/testsuite/xbt/heap_bench.c b/testsuite/xbt/heap_bench.c index 7db507f70e..5f3e1c40cc 100644 --- a/testsuite/xbt/heap_bench.c +++ b/testsuite/xbt/heap_bench.c @@ -11,20 +11,20 @@ #include #include "xbt/heap.h" -#include "gras/virtu.h" /* time manipulation in bench */ +#include "gras/virtu.h" /* time manipulation in bench */ #define MAX_TEST 1000000 -int compare_xbt_heap_float_t(const void *a, const void *b); +int compare_double(const void *a, const void *b); void test_heap_validity(int size); void test_heap_mean_operation(int size); -int compare_xbt_heap_float_t(const void *a, const void *b) +int compare_double(const void *a, const void *b) { - xbt_heap_float_t pa, pb; + double pa, pb; - pa = *((xbt_heap_float_t *) a); - pb = *((xbt_heap_float_t *) b); + pa = *((double *) a); + pb = *((double *) b); if (pa > pb) return 1; @@ -36,7 +36,7 @@ int compare_xbt_heap_float_t(const void *a, const void *b) void test_heap_validity(int size) { xbt_heap_t heap = xbt_heap_new(size, NULL); - xbt_heap_float_t *tab = calloc(size, sizeof(xbt_heap_float_t)); + double *tab = calloc(size, sizeof(double)); int i; for (i = 0; i < size; i++) { @@ -44,10 +44,10 @@ void test_heap_validity(int size) xbt_heap_push(heap, NULL, tab[i]); } - qsort(tab, size, sizeof(xbt_heap_float_t), compare_xbt_heap_float_t); + qsort(tab, size, sizeof(double), compare_double); for (i = 0; i < size; i++) { - /* printf(XBT_HEAP_FLOAT_T " ", xbt_heap_maxkey(heap)); */ + /* printf("%lg" " ", xbt_heap_maxkey(heap)); */ if (xbt_heap_maxkey(heap) != tab[i]) { fprintf(stderr, "Problem !\n"); exit(1); @@ -62,7 +62,7 @@ void test_heap_validity(int size) void test_heap_mean_operation(int size) { xbt_heap_t heap = xbt_heap_new(size, NULL); - xbt_heap_float_t val; + double val; double date = 0; int i, j;