/************************** Global ******************************************/
void MSG_global_init(void);
+void MSG_global_init_args(int *argc, char **argv);
void MSG_set_verbosity(MSG_outputmode_t mode);
MSG_error_t MSG_set_channel_number(int number);
MSG_error_t MSG_set_sharing_policy(MSG_sharing_t mode, long double param);
*/
void MSG_launch_application(const char *file)
{
- MSG_global_init();
- surf_parse_reset_parser();
+ xbt_assert0(msg_global,"MSG_global_init_args has to be called before MSG_launch_application.");
STag_process_fun = parse_process_init;
ETag_argument_fun = parse_argument;
ETag_process_fun = parse_process_finalize;
surf_parse_open(file);
- surf_parse_lex();
+ xbt_assert1((!surf_parse_lex()),"Parse error in %s",file);
surf_parse_close();
}
*/
void MSG_function_register(const char *name,m_process_code_t code)
{
- MSG_global_init();
+ xbt_assert0(msg_global,"MSG_global_init_args has to be called before MSG_function_register.");
xbt_dict_set(msg_global->registered_functions,name,code,NULL);
}
{
m_process_code_t code = NULL;
- MSG_global_init();
+ xbt_assert0(msg_global,"MSG_global_init_args has to be called before MSG_get_registered_function.");
xbt_dict_get(msg_global->registered_functions,name,(void **) &code);
*/
void MSG_global_init(void)
{
- if (!msg_global) {
- int argc=0;
- char **argv=NULL;
+ int argc=0;
+ char **argv=NULL;
+
+ CRITICAL0("Please stop using this function. Use MSG_global_init_args instead.");
+ DIE_IMPOSSIBLE;
+ MSG_global_init_args(&argc,argv);
+}
+void MSG_global_init_args(int *argc, char **argv)
+{
+ if (!msg_global) {
msg_global = xbt_new0(s_MSG_Global_t,1);
- surf_init(&argc, argv); /* Initialize some common structures */
+ surf_init(argc, argv); /* Initialize some common structures */
xbt_context_init();
msg_global->host = xbt_fifo_new();
msg_global->process_to_run = xbt_fifo_new();
*/
MSG_error_t MSG_set_channel_number(int number)
{
- MSG_global_init();
-
- xbt_assert0((msg_global->max_channel == 0), "Channel number already set!");
+ xbt_assert0((msg_global) && (msg_global->max_channel == 0), "Channel number already set!");
msg_global->max_channel = number;
*/
int MSG_get_channel_number(void)
{
- MSG_global_init();
-
- xbt_assert0((msg_global->max_channel != 0), "Channel number not set yet!");
+ xbt_assert0((msg_global)&&(msg_global->max_channel != 0), "Channel number not set yet!");
return msg_global->max_channel;
}
surf_parse_reset_parser();
ETag_cpu_fun=parse_cpu;
surf_parse_open(file);
- surf_parse_lex();
+ xbt_assert1((!surf_parse_lex()),"Parse error in %s",file);
surf_parse_close();
}
surf_parse_reset_parser();
ETag_network_link_fun=parse_network_link;
surf_parse_open(file);
- surf_parse_lex();
+ xbt_assert1((!surf_parse_lex()),"Parse error in %s",file);
surf_parse_close();
/* Figuring out the network cards used */
surf_parse_reset_parser();
STag_route_fun=parse_route_set_endpoints;
surf_parse_open(file);
- surf_parse_lex();
+ xbt_assert1((!surf_parse_lex()),"Parse error in %s",file);
surf_parse_close();
create_routing_table();
ETag_route_element_fun=parse_route_elem;
ETag_route_fun=parse_route_set_route;
surf_parse_open(file);
- surf_parse_lex();
+ xbt_assert1((!surf_parse_lex()),"Parse error in %s",file);
surf_parse_close();
}
#include "surf_private.h"
#include "xbt/module.h"
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_global, surf,
+ "Logging specific to the SURF global module");
+
+
static double NOW = 0;
xbt_dynar_t resource_list = NULL;
tmgr_history_t history = NULL;
lmm_system_t maxmin_system = NULL;
+xbt_dynar_t surf_path = NULL;
double generic_maxmin_share_resources(xbt_swag_t running_actions,
size_t offset)
void surf_init(int *argc, char **argv)
{
+ int i,j;
+ char *opt;
+
xbt_init(argc, argv);
+ if (!surf_path) {
+ const char *initial_path = "./";
+ surf_path = xbt_dynar_new(sizeof(char*), NULL);
+ xbt_dynar_push(surf_path,&initial_path);
+
+ for (i=1; i<*argc; i++) {
+ if (!strncmp(argv[i],"--surf-path=",strlen("--surf-path="))) {
+ opt=strchr(argv[i],'=');
+ opt++;
+ xbt_dynar_push(surf_path,&opt);
+ /*remove this from argv*/
+ for (j=i+1; j<*argc; j++) {
+ argv[j-1] = argv[j];
+ }
+ argv[j-1] = NULL;
+ (*argc)--;
+ i--; /* compensate effect of next loop incrementation */
+ }
+ }
+ }
if (!resource_list)
resource_list = xbt_dynar_new(sizeof(surf_resource_private_t), NULL);
if (!history)
maxmin_system = lmm_system_new();
}
+FILE *surf_fopen(const char *name, const char *mode)
+{
+ int i;
+ char* path = NULL;
+ FILE *file = NULL;
+ static char* path_name = NULL;
+
+ xbt_assert0(surf_path,"surf_init has to be called before using surf_fopen");
+ if(!path_name) path_name=xbt_new0(char,strlen(name)+1);
+
+ xbt_dynar_foreach(surf_path,i,path) {
+ if(strlen(path_name)<strlen(path)+strlen(name)+2)
+ path_name=xbt_realloc(path_name,strlen(path)+strlen(name)+2);
+ strcpy(path_name, path);
+ strcat(path_name,"/");
+ strcat(path_name,name);
+ file = fopen(path_name,mode);
+ if(file) return file;
+ }
+ return file;
+}
+
void surf_finalize(void)
{
int i;
e_surf_action_state_t state);
void surf_action_set_data(surf_action_t action,
void *data);
+FILE *surf_fopen(const char *name, const char *mode);
extern lmm_system_t maxmin_system;
extern tmgr_history_t history;
+extern xbt_dynar_t surf_path;
#endif /* _SURF_SURF_PRIVATE_H */
#include "xbt/error.h"
#include "xbt/dict.h"
#include "trace_mgr_private.h"
+#include "surf_private.h"
#include <stdlib.h>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(trace, surf,
tmgr_history_t tmgr_history_new(void)
{
- tmgr_history_t history;
+ tmgr_history_t h;
- history = xbt_new0(s_tmgr_history_t, 1);
+ h = xbt_new0(s_tmgr_history_t, 1);
- history->heap = xbt_heap_new(8, xbt_free); /* Why 8 ? Well, why not... */
+ h->heap = xbt_heap_new(8, xbt_free); /* Why 8 ? Well, why not... */
- return history;
+ return h;
}
-void tmgr_history_free(tmgr_history_t history)
+void tmgr_history_free(tmgr_history_t h)
{
- xbt_heap_free(history->heap);
- xbt_free(history);
+ xbt_heap_free(h->heap);
+ xbt_free(h);
}
tmgr_trace_t tmgr_trace_new(const char *filename)
return trace;
}
- if ((f = fopen(filename, "r")) == NULL) {
+ if ((f = surf_fopen(filename, "r")) == NULL) {
xbt_assert1(0, "Cannot open file '%s'", filename);
}
xbt_free(trace);
}
-tmgr_trace_event_t tmgr_history_add_trace(tmgr_history_t history,
+tmgr_trace_event_t tmgr_history_add_trace(tmgr_history_t h,
tmgr_trace_t trace,
double start_time, int offset,
void *resource)
xbt_assert0((trace_event->idx < xbt_dynar_length(trace->event_list)),
"You're refering to an event that does not exist!");
- xbt_heap_push(history->heap, trace_event, start_time);
+ xbt_heap_push(h->heap, trace_event, start_time);
return trace_event;
}
-double tmgr_history_next_date(tmgr_history_t history)
+double tmgr_history_next_date(tmgr_history_t h)
{
- if (xbt_heap_size(history->heap))
- return (xbt_heap_maxkey(history->heap));
+ if (xbt_heap_size(h->heap))
+ return (xbt_heap_maxkey(h->heap));
else
return -1.0;
}
-tmgr_trace_event_t tmgr_history_get_next_event_leq(tmgr_history_t history,
+tmgr_trace_event_t tmgr_history_get_next_event_leq(tmgr_history_t h,
double date,
double *value,
void **resource)
{
- double event_date = xbt_heap_maxkey(history->heap);
+ double event_date = xbt_heap_maxkey(h->heap);
tmgr_trace_event_t trace_event = NULL;
tmgr_event_t event = NULL;
tmgr_trace_t trace = NULL;
if (event_date > date)
return NULL;
- if (!(trace_event = xbt_heap_pop(history->heap)))
+ if (!(trace_event = xbt_heap_pop(h->heap)))
return NULL;
trace = trace_event->trace;
*resource = trace_event->resource;
if (trace_event->idx < xbt_dynar_length(trace->event_list) - 1) {
- xbt_heap_push(history->heap, trace_event, event_date + event->delta);
+ xbt_heap_push(h->heap, trace_event, event_date + event->delta);
trace_event->idx++;
} else if (event->delta > 0) { /* Last element, checking for periodicity */
- xbt_heap_push(history->heap, trace_event, event_date + event->delta);
+ xbt_heap_push(h->heap, trace_event, event_date + event->delta);
trace_event->idx = 0;
} else { /* We don't need this trace_event anymore */
xbt_free(trace_event);
int unix_emitter(int argc, char *argv[]);
int unix_receiver(int argc, char *argv[]);
int unix_forwarder(int argc, char *argv[]);
-void test_all(const char *platform_file, const char *application_file, double sharing);
+void test_all(const char *platform_file, const char *application_file);
/** The names of the channels we will use in this simulation. There is
m_task_t *todo = NULL;
int i;
- PRINT_MESSAGE("Hello !");
+
print_args(argc,argv);
{ /* Process organisation */
m_task_t *todo = (m_task_t *) calloc(NB_TASK, sizeof(m_task_t));
int i;
- PRINT_MESSAGE("Hello !");
print_args(argc,argv);
for (i = 0; i < NB_TASK;) {
m_task_t *todo = (m_task_t *) calloc(NB_TASK, sizeof(m_task_t));
int i;
- PRINT_MESSAGE("Hello !");
print_args(argc,argv);
for (i = 0; i < NB_TASK;) {
}
-void test_all(const char *platform_file,const char *application_file, double sharing)
+void test_all(const char *platform_file,const char *application_file)
{
{ /* Simulation setting */
- MSG_global_init();
- MSG_set_verbosity(MSG_SILENT);
MSG_set_channel_number(MAX_CHANNEL);
- if(sharing<=0) {
- MSG_set_sharing_policy(MSG_TCP,.1);
- } else {
- MSG_set_sharing_policy(MSG_STORE_AND_FORWARD,sharing);
- }
MSG_create_environment(platform_file);
}
{ /* Application deployment */
}
MSG_main();
printf("Simulation time %Lg\n",MSG_getClock());
- MSG_clean();
}
int main(int argc, char *argv[])
{
- test_all("msg_platform.xml","msg_deployment.xml",-.1);
-/* test_all("msg_platform.txt","msg_deployment.txt",.1); */
+ MSG_global_init_args(&argc,argv);
+ test_all("msg_platform.xml","msg_deployment.xml");
+ MSG_clean();
return (0);
}
"gras/datadesc_usage@EXEEXT@ --read @top_srcdir@/testsuite/gras/datadesc.g5" \
\
surf/maxmin_usage@EXEEXT@ surf/maxmin_bench@EXEEXT@ \
- surf/trace_usage@EXEEXT@ \
- "surf/surf_usage@EXEEXT@ @top_srcdir@/testsuite/surf/platform.txt" \
- "surf/surf_usage2@EXEEXT@ @top_srcdir@/testsuite/surf/platform.txt"
+ "surf/trace_usage@EXEEXT@ --surf-path=surf/" \
+ "surf/surf_usage@EXEEXT@ --surf-path=surf/ platform.xml" \
+ "surf/surf_usage2@EXEEXT@ --surf-path=surf/ platform.xml"
do
tests_nb=`expr $tests_nb + 1`
echo "#### Test $test"
--- /dev/null
+<?xml version='1.0'?>
+<!DOCTYPE platform_description SYSTEM "surfxml.dtd">
+<platform_description>
+ <cpu name="Cpu A" power="100.00" availability_file="trace_A.txt" state_file="trace_A_failure.txt"/>
+ <cpu name="Cpu B" power="100.00" availability_file="trace_B.txt"/>
+ <network_link name="LinkA" bandwidth="10.0" latency="0.2"/>
+ <route src="Cpu A" dst="Cpu B"><route_element name="LinkA"/></route>
+</platform_description>
resource->common_public->action_free(action);
}
}
- } while (surf_solve());
+ } while (surf_solve()>=0.0);
printf("Simulation Terminated\n");
#include <stdio.h>
#include <string.h>
#include "surf/trace_mgr.h"
+#include "surf/surf.h"
void test(void);
void test(void)
int main(int argc, char **argv)
{
+ surf_init(&argc,argv);
test();
return 0;
}