From: Frederic Suter Date: Mon, 22 Feb 2016 19:17:02 +0000 (+0100) Subject: never ending cleanup of the simdag world X-Git-Tag: v3_13~734 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/a4fc28ec2b9c97fc5bff04e0e5f420703f5ab419 never ending cleanup of the simdag world + useless includes + useless WIN32 safeguard in CMakeLists + indent + hostify well, clean, clean, clean ... --- diff --git a/examples/simdag/CMakeLists.txt b/examples/simdag/CMakeLists.txt index 983c15b583..8fe66308ff 100644 --- a/examples/simdag/CMakeLists.txt +++ b/examples/simdag/CMakeLists.txt @@ -1,49 +1,18 @@ set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}") -add_executable(ex_sd_test sd_test.c) +add_executable(sd_test sd_test.c) add_executable(sd_test2 sd_test2.c) add_executable(sd_fail sd_fail.c) add_executable(sd_avail sd_avail.c) add_executable(sd_typed_tasks_test sd_typed_tasks_test.c) add_executable(sd_comm_throttling sd_comm_throttling.c) -### Add definitions for compile -if(NOT WIN32) - target_link_libraries(ex_sd_test simgrid pthread ) - target_link_libraries(sd_test2 simgrid pthread ) - target_link_libraries(sd_fail simgrid pthread ) - target_link_libraries(sd_avail simgrid pthread ) - target_link_libraries(sd_typed_tasks_test simgrid pthread ) - target_link_libraries(sd_comm_throttling simgrid pthread ) - - add_custom_command(TARGET ex_sd_test - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/ex_sd_test ${CMAKE_CURRENT_BINARY_DIR}/sd_test - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/" - ) - get_directory_property(extra_clean_files ADDITIONAL_MAKE_CLEAN_FILES) - set_directory_properties( - PROPERTIES - ADDITIONAL_MAKE_CLEAN_FILES "${extra_clean_files};${CMAKE_CURRENT_BINARY_DIR}/sd_test") - -else() - target_link_libraries(ex_sd_test simgrid) - target_link_libraries(sd_test2 simgrid) - target_link_libraries(sd_fail simgrid) - target_link_libraries(sd_avail simgrid) - target_link_libraries(sd_typed_tasks_test simgrid) - target_link_libraries(sd_comm_throttling simgrid) - - add_custom_command(TARGET ex_sd_test - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/ex_sd_test.exe ${CMAKE_CURRENT_BINARY_DIR}/sd_test.exe - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/" - ) - get_directory_property(extra_clean_files ADDITIONAL_MAKE_CLEAN_FILES) - set_directory_properties( - PROPERTIES - ADDITIONAL_MAKE_CLEAN_FILES "${extra_clean_files};${CMAKE_CURRENT_BINARY_DIR}/sd_test.exe") -endif() +target_link_libraries(sd_test simgrid) +target_link_libraries(sd_test2 simgrid) +target_link_libraries(sd_fail simgrid) +target_link_libraries(sd_avail simgrid) +target_link_libraries(sd_typed_tasks_test simgrid) +target_link_libraries(sd_comm_throttling simgrid) set(tesh_files ${tesh_files} diff --git a/examples/simdag/dax/CMakeLists.txt b/examples/simdag/dax/CMakeLists.txt index b421a94c63..77dafa09b7 100644 --- a/examples/simdag/dax/CMakeLists.txt +++ b/examples/simdag/dax/CMakeLists.txt @@ -1,13 +1,7 @@ set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}") add_executable(dax_test dax_test.c) - -### Add definitions for compile -if(NOT WIN32) - target_link_libraries(dax_test simgrid pthread ) -else() - target_link_libraries(dax_test simgrid) -endif() +target_link_libraries(dax_test simgrid) set(tesh_files ${tesh_files} @@ -16,7 +10,6 @@ set(tesh_files PARENT_SCOPE) set(xml_files ${xml_files} - ${CMAKE_CURRENT_SOURCE_DIR}/Montage_50.xml ${CMAKE_CURRENT_SOURCE_DIR}/simple_dax_with_cycle.xml ${CMAKE_CURRENT_SOURCE_DIR}/smalldax.xml PARENT_SCOPE) diff --git a/examples/simdag/dax/dax_test.c b/examples/simdag/dax/dax_test.c index 3d68e1b0be..3954c6b592 100644 --- a/examples/simdag/dax/dax_test.c +++ b/examples/simdag/dax/dax_test.c @@ -6,22 +6,16 @@ /* 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 #include #include "simgrid/simdag.h" #include "xbt/log.h" -#include "xbt/ex.h" #include -XBT_LOG_NEW_DEFAULT_CATEGORY(test, - "Logging specific to this SimDag example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Logging specific to this SimDag example"); static int name_compare_hosts(const void *n1, const void *n2) { - return strcmp( - sg_host_get_name(*(sg_host_t *) n1), - sg_host_get_name(*(sg_host_t *) n2) - ); + return strcmp(sg_host_get_name(*(sg_host_t *) n1), sg_host_get_name(*(sg_host_t *) n2)); } int main(int argc, char **argv) @@ -35,16 +29,13 @@ int main(int argc, char **argv) /* Check our arguments */ xbt_assert(argc > 2, "Usage: %s platform_file dax_file [jedule_file]\n" - "\tExample: %s simulacrum_7_hosts.xml Montage_25.xml Montage_25.jed", - argv[0], argv[0]); + "\tExample: %s simulacrum_7_hosts.xml Montage_25.xml Montage_25.jed", argv[0], argv[0]); char *last = strrchr(argv[2], '.'); - char * tracefilename = bprintf("%.*s.trace",(int) (last == NULL ? - strlen(argv[2]) : - last - argv[2]), argv[2]); + char * tracefilename = bprintf("%.*s.trace",(int) (last == NULL ? strlen(argv[2]):last - argv[2]), argv[2]); if (argc == 4) tracefilename = xbt_strdup(argv[3]); - + /* creation of the environment */ SD_create_environment(argv[1]); @@ -58,8 +49,7 @@ int main(int argc, char **argv) } /* Display all the tasks */ - XBT_INFO - ("------------------- Display all tasks of the loaded DAG ---------------------------"); + XBT_INFO("------------------- Display all tasks of the loaded DAG ---------------------------"); xbt_dynar_foreach(dax, cursor, task) { SD_task_dump(task); } @@ -72,12 +62,11 @@ int main(int argc, char **argv) fprintf(dotout, "}\n"); fclose(dotout); - /* Schedule them all on the first workstation */ + /* Schedule them all on the first host */ XBT_INFO("------------------- Schedule tasks ---------------------------"); const sg_host_t *ws_list = sg_host_list(); int hosts_count = sg_host_count(); - qsort((void *) ws_list, hosts_count, sizeof(sg_host_t), - name_compare_hosts); + qsort((void *) ws_list, hosts_count, sizeof(sg_host_t), name_compare_hosts); xbt_dynar_foreach(dax, cursor, task) { if (SD_task_get_kind(task) == SD_TASK_COMP_SEQ) { @@ -88,11 +77,9 @@ int main(int argc, char **argv) } } - XBT_INFO - ("------------------- Run the schedule ---------------------------"); + XBT_INFO("------------------- Run the schedule ---------------------------"); SD_simulate(-1); - XBT_INFO - ("------------------- Produce the trace file---------------------------"); + XBT_INFO("------------------- Produce the trace file---------------------------"); XBT_INFO("Producing the trace of the run into %s", tracefilename); FILE *out = fopen(tracefilename, "w"); xbt_assert(out, "Cannot write to %s", tracefilename); @@ -103,32 +90,23 @@ int main(int argc, char **argv) sg_host_t *wsl = SD_task_get_workstation_list(task); switch (kind) { case SD_TASK_COMP_SEQ: - fprintf(out, "[%f] %s compute %f # %s\n", - SD_task_get_start_time(task), - sg_host_get_name(wsl[0]), SD_task_get_amount(task), - SD_task_get_name(task)); + fprintf(out, "[%f] %s compute %f # %s\n", SD_task_get_start_time(task), sg_host_get_name(wsl[0]), + SD_task_get_amount(task), SD_task_get_name(task)); break; case SD_TASK_COMM_E2E: - fprintf(out, "[%f] %s send %s %f # %s\n", - SD_task_get_start_time(task), - sg_host_get_name(wsl[0]), - sg_host_get_name(wsl[1]), SD_task_get_amount(task), - SD_task_get_name(task)); - fprintf(out, "[%f] %s recv %s %f # %s\n", - SD_task_get_finish_time(task), - sg_host_get_name(wsl[1]), - sg_host_get_name(wsl[0]), SD_task_get_amount(task), - SD_task_get_name(task)); + fprintf(out, "[%f] %s send %s %f # %s\n", SD_task_get_start_time(task), sg_host_get_name(wsl[0]), + sg_host_get_name(wsl[1]), SD_task_get_amount(task), SD_task_get_name(task)); + fprintf(out, "[%f] %s recv %s %f # %s\n", SD_task_get_finish_time(task), sg_host_get_name(wsl[1]), + sg_host_get_name(wsl[0]), SD_task_get_amount(task), SD_task_get_name(task)); break; default: - xbt_die("Task %s is of unknown kind %d", SD_task_get_name(task), - SD_task_get_kind(task)); + xbt_die("Task %s is of unknown kind %d", SD_task_get_name(task), SD_task_get_kind(task)); } SD_task_destroy(task); } fclose(out); xbt_dynar_free_container(&dax); - /* exit */ + SD_exit(); return 0; } diff --git a/examples/simdag/dot/CMakeLists.txt b/examples/simdag/dot/CMakeLists.txt index fe2834fa48..c45b57cd33 100644 --- a/examples/simdag/dot/CMakeLists.txt +++ b/examples/simdag/dot/CMakeLists.txt @@ -6,21 +6,10 @@ if(HAVE_GRAPHVIZ) add_executable(simulate_dot simulate_dot.c) add_executable(dot_test2 dot_test2.c) - if(NOT WIN32) - target_link_libraries(dot_test simgrid pthread m) - target_link_libraries(ptg_test simgrid pthread m) - target_link_libraries(simulate_dot simgrid pthread m) - target_link_libraries(dot_test2 simgrid pthread m) - else() - target_link_libraries(dot_test simgrid) - target_link_libraries(ptg_test simgrid) - target_link_libraries(simulate_dot simgrid) - target_link_libraries(dot_test2 simgrid) - endif() - get_directory_property(extra_clean_files ADDITIONAL_MAKE_CLEAN_FILES) - set_directory_properties( - PROPERTIES - ADDITIONAL_MAKE_CLEAN_FILES "${extra_clean_files};${CMAKE_CURRENT_BINARY_DIR}/dot_test; ${CMAKE_CURRENT_BINARY_DIR}/simulate_dot;") + target_link_libraries(dot_test simgrid) + target_link_libraries(ptg_test simgrid) + target_link_libraries(simulate_dot simgrid) + target_link_libraries(dot_test2 simgrid) endif() set(tesh_files diff --git a/examples/simdag/dot/dot_test.c b/examples/simdag/dot/dot_test.c index 37f46846af..37f825cde6 100644 --- a/examples/simdag/dot/dot_test.c +++ b/examples/simdag/dot/dot_test.c @@ -6,11 +6,9 @@ /* 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 #include #include "simgrid/simdag.h" #include "xbt/log.h" -#include "xbt/ex.h" #include #include diff --git a/examples/simdag/dot/dot_test2.c b/examples/simdag/dot/dot_test2.c index 38b70958b8..dbbc218816 100644 --- a/examples/simdag/dot/dot_test2.c +++ b/examples/simdag/dot/dot_test2.c @@ -6,12 +6,8 @@ /* 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 -#include #include "simgrid/simdag.h" #include "xbt/log.h" -#include "xbt/ex.h" -#include XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Logging specific to this SimDag example"); diff --git a/examples/simdag/dot/ptg_test.c b/examples/simdag/dot/ptg_test.c index a313557ba3..aa0c2c4e95 100644 --- a/examples/simdag/dot/ptg_test.c +++ b/examples/simdag/dot/ptg_test.c @@ -4,13 +4,9 @@ /* 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 #include #include "simgrid/simdag.h" #include "xbt/log.h" -#include "xbt/ex.h" -#include -#include XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Logging specific to this SimDag example"); diff --git a/examples/simdag/dot/simulate_dot.c b/examples/simdag/dot/simulate_dot.c index efcf24b581..d3827c9327 100644 --- a/examples/simdag/dot/simulate_dot.c +++ b/examples/simdag/dot/simulate_dot.c @@ -6,11 +6,9 @@ /* 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 #include #include "simgrid/simdag.h" #include "xbt/log.h" -#include "xbt/ex.h" #include #include diff --git a/examples/simdag/goal/CMakeLists.txt b/examples/simdag/goal/CMakeLists.txt index b988fa677b..d0f13f5f20 100644 --- a/examples/simdag/goal/CMakeLists.txt +++ b/examples/simdag/goal/CMakeLists.txt @@ -1,13 +1,7 @@ set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}") add_executable(goal_test goal_test.c) - -### Add definitions for compile -if(NOT WIN32) - target_link_libraries(goal_test simgrid pthread ) -else() - target_link_libraries(goal_test simgrid) -endif() +target_link_libraries(goal_test simgrid) set(examples_src ${examples_src} diff --git a/examples/simdag/io/CMakeLists.txt b/examples/simdag/io/CMakeLists.txt index 51613c806d..3f4db61446 100644 --- a/examples/simdag/io/CMakeLists.txt +++ b/examples/simdag/io/CMakeLists.txt @@ -1,13 +1,7 @@ set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}") add_executable(sd_io sd_io.c) - -### Add definitions for compile -if(NOT WIN32) - target_link_libraries(sd_io simgrid pthread m) -else() - target_link_libraries(sd_io simgrid) -endif() +target_link_libraries(sd_io simgrid) set(tesh_files ${tesh_files} diff --git a/examples/simdag/io/sd_io.c b/examples/simdag/io/sd_io.c index 4d8c3a4e0c..ed6897b4ac 100644 --- a/examples/simdag/io/sd_io.c +++ b/examples/simdag/io/sd_io.c @@ -4,14 +4,11 @@ /* 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 -#include #include "simgrid/simdag.h" -#include "xbt/ex.h" #include "xbt/log.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(sd_io, - "Logging specific to this SimDag example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(sd_io, "Logging specific to this SimDag example"); + int main(int argc, char **argv) { unsigned int ctr; @@ -23,9 +20,7 @@ int main(int argc, char **argv) xbt_dict_cursor_t cursor = NULL; SD_init(&argc, argv); - /* Set the workstation model to default, as storage is not supported by the - * ptask_L07 model yet. - */ + /* Set the workstation model to default, as storage is not supported by the ptask_L07 model yet. */ SD_config("host/model", "default"); SD_create_environment(argv[1]); workstations = sg_host_list(); @@ -34,10 +29,10 @@ int main(int argc, char **argv) for (ctr=0; ctr -#include #include "simgrid/simdag.h" -#include "xbt/ex.h" #include "xbt/log.h" -#include "xbt/dynar.h" #include "xbt/dict.h" XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Property test"); int main(int argc, char **argv) { - sg_host_t w1; - sg_host_t w2; - const char *name1; - const char *name2; + sg_host_t h1, h2; + const char *name1, *name2; xbt_dict_t props; xbt_dict_cursor_t cursor = NULL; char *key, *data; @@ -29,46 +23,37 @@ int main(int argc, char **argv) /* SD initialization */ SD_init(&argc, argv); - xbt_assert(argc > 1, - "Usage: %s platform_file\n\tExample: %s ../two_hosts.xml", - argv[0], argv[0]); + xbt_assert(argc > 1, "Usage: %s platform_file\n\tExample: %s ../../platforms/prop.xml", argv[0], argv[0]); SD_create_environment(argv[1]); /* init of platform elements */ - w1 = sg_host_by_name("host1"); - w2 = sg_host_by_name("host2"); - name1 = sg_host_get_name(w1); - name2 = sg_host_get_name(w2); - - - /* The host properties can be retrieved from all interfaces */ + h1 = sg_host_by_name("host1"); + h2 = sg_host_by_name("host2"); + name1 = sg_host_get_name(h1); + name2 = sg_host_get_name(h2); + /* Get the property list of 'host1' */ XBT_INFO("Property list for host %s", name1); - /* Get the property list of the workstation 1 */ - props = sg_host_get_properties(w1); - + props = sg_host_get_properties(h1); /* Trying to set a new property */ xbt_dict_set(props, "NewProp", strdup("newValue"), xbt_free_f); - /* Print the properties of the workstation 1 */ + /* Print the properties of 'host1' */ xbt_dict_foreach(props, cursor, key, data) { XBT_INFO("\tProperty: %s has value: %s", key, data); } /* Try to get a property that does not exist */ - - value = sg_host_get_property_value(w1, noexist); + value = sg_host_get_property_value(h1, noexist); XBT_INFO("\tProperty: %s has value: %s", noexist, value?value:"Undefined (NULL)"); - + /* Get the property list of 'host2' */ XBT_INFO("Property list for host %s", name2); - /* Get the property list of the workstation 2 */ - props = sg_host_get_properties(w2); - cursor = NULL; + props = sg_host_get_properties(h2); - /* Print the properties of the workstation 2 */ + /* Print the properties of 'host2' */ xbt_dict_foreach(props, cursor, key, data) { XBT_INFO("\tProperty: %s on host: %s", key, data); } @@ -76,7 +61,7 @@ int main(int argc, char **argv) /* Modify an existing property test. First check it exists */ XBT_INFO("Modify an existing property"); - value = sg_host_get_property_value(w2, exist); + value = sg_host_get_property_value(h2, exist); if (value == NULL) XBT_INFO("\tProperty: %s is undefined", exist); else { @@ -85,11 +70,11 @@ int main(int argc, char **argv) } /* Test if we have changed the value */ - value = sg_host_get_property_value(w2, exist); + value = sg_host_get_property_value(h2, exist); XBT_INFO("\tProperty: %s new value: %s", exist, value?value:"Undefined (NULL)"); /* Test if properties are displayed by sg_host_dump */ - sg_host_dump(w2); + sg_host_dump(h2); SD_exit(); return 0; diff --git a/examples/simdag/sd_avail.c b/examples/simdag/sd_avail.c index d0ff07815b..653562eea5 100644 --- a/examples/simdag/sd_avail.c +++ b/examples/simdag/sd_avail.c @@ -1,17 +1,13 @@ -/* Copyright (c) 2012-2015. The SimGrid Team. +/* Copyright (c) 2012-2016. 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. */ -#include -#include #include "simgrid/simdag.h" -#include "xbt/ex.h" #include "xbt/log.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(sd_avail, - "Logging specific to this SimDag example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(sd_avail, "Logging specific to this SimDag example"); /* Test of dynamic availability traces * Scenario: @@ -45,13 +41,13 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(sd_avail, int main(int argc, char **argv) { unsigned int ctr; - const sg_host_t *workstations; + const sg_host_t *hosts; SD_task_t t1, c1, t2, c2, t3, c3, t4, task; xbt_dynar_t changed_tasks; SD_init(&argc, argv); SD_create_environment(argv[1]); - workstations = sg_host_list(); + hosts = sg_host_list(); t1 = SD_task_create_comp_seq("t1", NULL, 25000000); c1 = SD_task_create_comm_e2e("c1", NULL, 125000000); @@ -71,10 +67,10 @@ int main(int argc, char **argv) /* Schedule tasks t1 and w3 on first host, t2 on second host */ /* Transfers are auto-scheduled */ - SD_task_schedulel(t1, 1, workstations[0]); - SD_task_schedulel(t2, 1, workstations[1]); - SD_task_schedulel(t3, 1, workstations[0]); - SD_task_schedulel(t4, 1, workstations[1]); + SD_task_schedulel(t1, 1, hosts[0]); + SD_task_schedulel(t2, 1, hosts[1]); + SD_task_schedulel(t3, 1, hosts[0]); + SD_task_schedulel(t4, 1, hosts[1]); /* Add some watchpoint upon task completion */ SD_task_watch(t1, SD_DONE); @@ -85,19 +81,13 @@ int main(int argc, char **argv) SD_task_watch(c3, SD_DONE); SD_task_watch(t4, SD_DONE); - while (!xbt_dynar_is_empty((changed_tasks = SD_simulate(-1.0)))) { - XBT_INFO("link1: bw=%.0f, lat=%f", - SD_route_get_bandwidth(workstations[0], workstations[1]), - SD_route_get_latency(workstations[0], workstations[1])); - XBT_INFO("Jupiter: speed=%.0f", - sg_host_speed(workstations[0])* - sg_host_get_available_speed(workstations[0])); - XBT_INFO("Tremblay: speed=%.0f", - sg_host_speed(workstations[1])* - sg_host_get_available_speed(workstations[1])); + while (!xbt_dynar_is_empty((changed_tasks = SD_simulate(-1.0)))) { + XBT_INFO("link1: bw=%.0f, lat=%f", SD_route_get_bandwidth(hosts[0], hosts[1]), + SD_route_get_latency(hosts[0], hosts[1])); + XBT_INFO("Jupiter: speed=%.0f", sg_host_speed(hosts[0])* sg_host_get_available_speed(hosts[0])); + XBT_INFO("Tremblay: speed=%.0f", sg_host_speed(hosts[1])* sg_host_get_available_speed(hosts[1])); xbt_dynar_foreach(changed_tasks, ctr, task) { - XBT_INFO("Task '%s' start time: %f, finish time: %f", - SD_task_get_name(task), + XBT_INFO("Task '%s' start time: %f, finish time: %f", SD_task_get_name(task), SD_task_get_start_time(task), SD_task_get_finish_time(task)); if (SD_task_get_state(task)==SD_DONE) SD_task_destroy(task); diff --git a/examples/simdag/sd_comm_throttling.c b/examples/simdag/sd_comm_throttling.c index 8bbcf9556c..99a6605c9e 100644 --- a/examples/simdag/sd_comm_throttling.c +++ b/examples/simdag/sd_comm_throttling.c @@ -5,39 +5,28 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include -#include #include "simgrid/simdag.h" -#include "xbt/ex.h" #include "xbt/log.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(sd_comm_throttling, - "Logging specific to this SimDag example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(sd_comm_throttling, "Logging specific to this SimDag example"); int main(int argc, char **argv) { unsigned int ctr; - const char *platform_file; - const sg_host_t *workstations; + const sg_host_t *hosts; SD_task_t task, taskA, taskB, taskC, taskD, taskE; xbt_dynar_t changed_tasks; - /* initialization of SD */ SD_init(&argc, argv); - - /* xbt_log_control_set("sd.thres=debug"); */ - - xbt_assert(argc > 1, "Usage: %s platform_file\n" - "\nExample: %s two_clusters.xml", argv[0], argv[0]); + xbt_assert(argc > 1, "Usage: %s platform_file\n\nExample: %s two_clusters.xml", argv[0], argv[0]); /* creation of the environment */ - platform_file = argv[1]; - SD_create_environment(platform_file); - - workstations = sg_host_list(); + SD_create_environment(argv[1]); + + hosts = sg_host_list(); /* creation of some typed tasks and their dependencies */ - /* chain of five tasks, three compute tasks with two data transfers */ - /* in between */ + /* chain of five tasks, three compute tasks with two data transfers in between */ taskA = SD_task_create_comp_seq("Task A", NULL, 5e9); taskB = SD_task_create_comm_e2e("Task B", NULL, 1e7); taskC = SD_task_create_comp_seq("Task C", NULL, 5e9); @@ -56,30 +45,26 @@ int main(int argc, char **argv) /* Auto-schedule the compute tasks on three different workstations */ /* Data transfer tasks taskB and taskD are automagically scheduled */ - SD_task_schedulel(taskA, 1, workstations[0]); - SD_task_schedulel(taskC, 1, workstations[1]); - SD_task_schedulel(taskE, 1, workstations[0]); + SD_task_schedulel(taskA, 1, hosts[0]); + SD_task_schedulel(taskC, 1, hosts[1]); + SD_task_schedulel(taskE, 1, hosts[0]); while (!xbt_dynar_is_empty((changed_tasks = SD_simulate(-1.0)))) { XBT_INFO("Simulation stopped after %.4f seconds", SD_get_clock()); xbt_dynar_foreach(changed_tasks, ctr, task) { - XBT_INFO("Task '%s' start time: %f, finish time: %f", - SD_task_get_name(task), - SD_task_get_start_time(task), - SD_task_get_finish_time(task)); - + XBT_INFO("Task '%s' start time: %f, finish time: %f", SD_task_get_name(task), SD_task_get_start_time(task), + SD_task_get_finish_time(task)); } + /* let throttle the communication for taskD if its parent is SD_DONE */ - /* the bandwidth is 1.25e8, the data size is 1e7, and we want to throttle - * the bandwidth by a factor 2. the rate is then 1.25e8/(2*1e7)=6.25 - * Changing the rate is possible before the task execution starts (in SD_RUNNING - * state). + /* the bandwidth is 1.25e8, the data size is 1e7, and we want to throttle the bandwidth by a factor 2. + * The rate is then 1.25e8/(2*1e7)=6.25 + * Changing the rate is possible before the task execution starts (in SD_RUNNING state). */ if (SD_task_get_state(taskC) == SD_DONE && SD_task_get_state(taskD) < SD_RUNNING) SD_task_set_rate(taskD, 6.25); } XBT_DEBUG("Destroying tasks..."); - SD_task_destroy(taskA); SD_task_destroy(taskB); SD_task_destroy(taskC); @@ -87,7 +72,6 @@ int main(int argc, char **argv) SD_task_destroy(taskE); XBT_DEBUG("Tasks destroyed. Exiting SimDag..."); - SD_exit(); return 0; } diff --git a/examples/simdag/sd_fail.c b/examples/simdag/sd_fail.c index fc1647cfe4..1abaeea045 100644 --- a/examples/simdag/sd_fail.c +++ b/examples/simdag/sd_fail.c @@ -1,24 +1,20 @@ -/* Copyright (c) 2006-2010, 2012-2015. The SimGrid Team. +/* Copyright (c) 2006-2010, 2012-2016. 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. */ -#include -#include #include "simgrid/simdag.h" -#include "xbt/ex.h" #include "xbt/log.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(sd_fail, - "Logging specific to this SimDag example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(sd_fail, "Logging specific to this SimDag example"); int main(int argc, char **argv) { SD_task_t task; double computation_amount[1]; double communication_amount[2] = { 0 }; - sg_host_t workstation_list[1]; + sg_host_t hosts[1]; /* initialization of SD */ SD_init(&argc, argv); @@ -33,8 +29,7 @@ int main(int argc, char **argv) SD_task_watch(task, SD_FAILED); SD_task_watch(task, SD_DONE); - XBT_INFO("Schedule task '%s' on workstation 'Faulty Host'", - SD_task_get_name(task)); + XBT_INFO("Schedule task '%s' on 'Faulty Host'", SD_task_get_name(task)); SD_task_schedulel(task, 1, sg_host_by_name("Faulty Host")); @@ -42,12 +37,10 @@ int main(int argc, char **argv) SD_task_dump(task); - XBT_INFO("Task '%s' has failed. %.f flops remain to be done", - SD_task_get_name(task), + XBT_INFO("Task '%s' has failed. %.f flops remain to be done", SD_task_get_name(task), SD_task_get_remaining_amount(task)); - XBT_INFO("let's unschedule task '%s' and reschedule it on the 'Safe Host'", - SD_task_get_name(task)); + XBT_INFO("let's unschedule task '%s' and reschedule it on the 'Safe Host'", SD_task_get_name(task)); SD_task_unschedule(task); SD_task_schedulel(task, 1, sg_host_by_name("Safe Host")); @@ -55,10 +48,8 @@ int main(int argc, char **argv) SD_simulate(-1.0); SD_task_dump(task); - XBT_INFO("Task '%s' start time: %f, finish time: %f", - SD_task_get_name(task), - SD_task_get_start_time(task), - SD_task_get_finish_time(task)); + XBT_INFO("Task '%s' start time: %f, finish time: %f", SD_task_get_name(task), SD_task_get_start_time(task), + SD_task_get_finish_time(task)); SD_task_destroy(task); task=NULL; @@ -71,37 +62,30 @@ int main(int argc, char **argv) computation_amount[0] = 2e10; - XBT_INFO("Schedule task '%s' on workstation 'Faulty Host'", - SD_task_get_name(task)); + XBT_INFO("Schedule task '%s' on 'Faulty Host'", SD_task_get_name(task)); - workstation_list[0] = sg_host_by_name("Faulty Host"); - SD_task_schedule(task, 1, workstation_list, - computation_amount, communication_amount,-1); + hosts[0] = sg_host_by_name("Faulty Host"); + SD_task_schedule(task, 1, hosts, computation_amount, communication_amount,-1); SD_simulate(-1.0); SD_task_dump(task); - XBT_INFO("Task '%s' has failed. %.f flops remain to be done", - SD_task_get_name(task), + XBT_INFO("Task '%s' has failed. %.f flops remain to be done", SD_task_get_name(task), SD_task_get_remaining_amount(task)); - XBT_INFO("let's unschedule task '%s' and reschedule it on the 'Safe Host'", - SD_task_get_name(task)); + XBT_INFO("let's unschedule task '%s' and reschedule it on the 'Safe Host'", SD_task_get_name(task)); SD_task_unschedule(task); - workstation_list[0] = sg_host_by_name("Safe Host"); + hosts[0] = sg_host_by_name("Safe Host"); - SD_task_schedule(task, 1, workstation_list, - computation_amount, communication_amount,-1); + SD_task_schedule(task, 1, hosts, computation_amount, communication_amount,-1); XBT_INFO("Run the simulation again"); SD_simulate(-1.0); SD_task_dump(task); - XBT_INFO("Task '%s' start time: %f, finish time: %f", - SD_task_get_name(task), - SD_task_get_start_time(task), + XBT_INFO("Task '%s' start time: %f, finish time: %f", SD_task_get_name(task), SD_task_get_start_time(task), SD_task_get_finish_time(task)); SD_task_destroy(task); diff --git a/examples/simdag/sd_test.c b/examples/simdag/sd_test.c index 5acc969a2a..0c9d0654ef 100644 --- a/examples/simdag/sd_test.c +++ b/examples/simdag/sd_test.c @@ -4,86 +4,63 @@ /* 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 -#include #include "simgrid/simdag.h" #include "xbt/ex.h" #include "xbt/log.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(sd_test, - "Logging specific to this SimDag example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(sd_test, "Logging specific to this SimDag example"); int main(int argc, char **argv) { int i; unsigned int ctr; - const char *platform_file; - const sg_host_t *workstations; - const char *name1; - const char *name2; - double computation_amount1; - double computation_amount2; - double communication_amount12; - double communication_amount21; + const sg_host_t *hosts; + const char *name1, *name2; + double comp_amount1, comp_amount2; + double comm_amount12, comm_amount21; const SD_link_t *route; int route_size; SD_task_t task, taskA, taskB, taskC, taskD, checkB, checkD; xbt_dynar_t changed_tasks; xbt_ex_t ex; - const int workstation_number = 2; - sg_host_t workstation_list[2]; + const int host_count = 2; + sg_host_t host_list[2]; double computation_amount[2]; double communication_amount[4] = { 0 }; double rate = -1.0; - sg_host_t w1, w2; + sg_host_t h1, h2; /* initialization of SD */ SD_init(&argc, argv); - /* xbt_log_control_set("sd.thres=debug"); */ - - xbt_assert(argc > 1, "Usage: %s platform_file\n" - "\nExample: %s two_clusters.xml", argv[0], argv[0]); - - /* creation of the environment */ - platform_file = argv[1]; - SD_create_environment(platform_file); + xbt_assert(argc > 1, "Usage: %s platform_file\n\nExample: %s two_clusters.xml", argv[0], argv[0]); + SD_create_environment(argv[1]); /* test the estimation functions */ - workstations = sg_host_list(); - w1 = workstations[0]; - w2 = workstations[1]; - name1 = sg_host_get_name(w1); - name2 = sg_host_get_name(w2); - computation_amount1 = 2000000; - computation_amount2 = 1000000; - communication_amount12 = 2000000; - communication_amount21 = 3000000; - XBT_INFO("Computation time for %f flops on %s: %f", computation_amount1, - name1, computation_amount1/sg_host_speed(w1)); - XBT_INFO("Computation time for %f flops on %s: %f", computation_amount2, - name2, computation_amount2/sg_host_speed(w2)); + hosts = sg_host_list(); + h1 = hosts[0]; + h2 = hosts[1]; + name1 = sg_host_get_name(h1); + name2 = sg_host_get_name(h2); + comp_amount1 = 2000000; + comp_amount2 = 1000000; + comm_amount12 = 2000000; + comm_amount21 = 3000000; + XBT_INFO("Computation time for %f flops on %s: %f", comp_amount1, name1, comp_amount1/sg_host_speed(h1)); + XBT_INFO("Computation time for %f flops on %s: %f", comp_amount2, name2, comp_amount2/sg_host_speed(h2)); XBT_INFO("Route between %s and %s:", name1, name2); - route = SD_route_get_list(w1, w2); - route_size = SD_route_get_size(w1, w2); + route = SD_route_get_list(h1, h2); + route_size = SD_route_get_size(h1, h2); for (i = 0; i < route_size; i++) { - XBT_INFO(" Link %s: latency = %f, bandwidth = %f", - sg_link_name(route[i]), - sg_link_latency(route[i]), - sg_link_bandwidth(route[i])); + XBT_INFO(" Link %s: latency = %f, bandwidth = %f", sg_link_name(route[i]), sg_link_latency(route[i]), + sg_link_bandwidth(route[i])); } - XBT_INFO("Route latency = %f, route bandwidth = %f", - SD_route_get_latency(w1, w2), - SD_route_get_bandwidth(w1, w2)); - XBT_INFO("Communication time for %f bytes between %s and %s: %f", - communication_amount12, name1, name2, - SD_route_get_latency(w1, w2) + - communication_amount12 / SD_route_get_bandwidth(w1, w2)); - XBT_INFO("Communication time for %f bytes between %s and %s: %f", - communication_amount21, name2, name1, - SD_route_get_latency(w2, w1) + - communication_amount21 / SD_route_get_bandwidth(w2, w1)); + XBT_INFO("Route latency = %f, route bandwidth = %f", SD_route_get_latency(h1, h2), SD_route_get_bandwidth(h1, h2)); + XBT_INFO("Communication time for %f bytes between %s and %s: %f", comm_amount12, name1, name2, + SD_route_get_latency(h1, h2) + comm_amount12 / SD_route_get_bandwidth(h1, h2)); + XBT_INFO("Communication time for %f bytes between %s and %s: %f", comm_amount21, name2, name1, + SD_route_get_latency(h2, h1) + comm_amount21 / SD_route_get_bandwidth(h2, h1)); /* creation of the tasks and their dependencies */ taskA = SD_task_create("Task A", NULL, 10.0); @@ -92,8 +69,8 @@ int main(int argc, char **argv) taskD = SD_task_create("Task D", NULL, 60.0); /* try to attach and retrieve user data to a task */ - SD_task_set_data(taskA, (void*) &computation_amount1); - if (computation_amount1 != (*((double*) SD_task_get_data(taskA)))) + SD_task_set_data(taskA, (void*) &comp_amount1); + if (comp_amount1 != (*((double*) SD_task_get_data(taskA)))) XBT_ERROR("User data was corrupted by a simple set/get"); SD_task_dependency_add(NULL, NULL, taskB, taskA); @@ -102,8 +79,6 @@ int main(int argc, char **argv) SD_task_dependency_add(NULL, NULL, taskD, taskC); SD_task_dependency_add(NULL, NULL, taskB, taskC); - - TRY { SD_task_dependency_add(NULL, NULL, taskA, taskA); /* shouldn't work and must raise an exception */ xbt_die("Hey, I can add a dependency between Task A and Task A!"); @@ -144,7 +119,6 @@ int main(int argc, char **argv) xbt_ex_free(ex); } - /* if everything is ok, no exception is forwarded or rethrown by main() */ /* watch points */ @@ -152,56 +126,43 @@ int main(int argc, char **argv) SD_task_watch(taskB, SD_DONE); SD_task_unwatch(taskD, SD_DONE); - /* scheduling parameters */ - workstation_list[0] = w1; - workstation_list[1] = w2; - computation_amount[0] = computation_amount1; - computation_amount[1] = computation_amount2; + host_list[0] = h1; + host_list[1] = h2; + computation_amount[0] = comp_amount1; + computation_amount[1] = comp_amount2; - communication_amount[1] = communication_amount12; - communication_amount[2] = communication_amount21; + communication_amount[1] = comm_amount12; + communication_amount[2] = comm_amount21; /* estimated time */ task = taskD; - XBT_INFO("Estimated time for '%s': %f", SD_task_get_name(task), - SD_task_get_execution_time(task, workstation_number, - workstation_list, computation_amount, - communication_amount)); - - /* let's launch the simulation! */ - - SD_task_schedule(taskA, workstation_number, workstation_list, - computation_amount, communication_amount, rate); - SD_task_schedule(taskB, workstation_number, workstation_list, - computation_amount, communication_amount, rate); - SD_task_schedule(taskC, workstation_number, workstation_list, - computation_amount, communication_amount, rate); - SD_task_schedule(taskD, workstation_number, workstation_list, - computation_amount, communication_amount, rate); + XBT_INFO("Estimated time for '%s': %f", SD_task_get_name(task), SD_task_get_execution_time(task, host_count, + host_list, computation_amount, communication_amount)); + + SD_task_schedule(taskA, host_count, host_list, computation_amount, communication_amount, rate); + SD_task_schedule(taskB, host_count, host_list, computation_amount, communication_amount, rate); + SD_task_schedule(taskC, host_count, host_list, computation_amount, communication_amount, rate); + SD_task_schedule(taskD, host_count, host_list, computation_amount, communication_amount, rate); changed_tasks = SD_simulate(-1.0); xbt_dynar_foreach(changed_tasks, ctr, task) { - XBT_INFO("Task '%s' start time: %f, finish time: %f", - SD_task_get_name(task), + XBT_INFO("Task '%s' start time: %f, finish time: %f", SD_task_get_name(task), SD_task_get_start_time(task), SD_task_get_finish_time(task)); } xbt_dynar_get_cpy(changed_tasks, 0, &checkD); xbt_dynar_get_cpy(changed_tasks, 1, &checkB); - xbt_assert(checkD == taskD && - checkB == taskB, "Unexpected simulation results"); + xbt_assert(checkD == taskD && checkB == taskB, "Unexpected simulation results"); XBT_DEBUG("Destroying tasks..."); - SD_task_destroy(taskA); SD_task_destroy(taskB); SD_task_destroy(taskC); SD_task_destroy(taskD); XBT_DEBUG("Tasks destroyed. Exiting SimDag..."); - SD_exit(); return 0; } diff --git a/examples/simdag/sd_test2.c b/examples/simdag/sd_test2.c index ce4f739dda..9904631218 100644 --- a/examples/simdag/sd_test2.c +++ b/examples/simdag/sd_test2.c @@ -4,22 +4,16 @@ /* 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 -#include #include #include "simgrid/simdag.h" #include "xbt/log.h" -#include "xbt/sysdep.h" /* calloc, printf */ - -XBT_LOG_NEW_DEFAULT_CATEGORY(sd_test, - "Logging specific to this SimDag example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(sd_test, "Logging specific to this SimDag example"); static int nameCompareHosts(const void *n1, const void *n2) { - return strcmp(sg_host_get_name(*((sg_host_t *) n1)), - sg_host_get_name(*((sg_host_t *) n2))); + return strcmp(sg_host_get_name(*((sg_host_t *) n1)), sg_host_get_name(*((sg_host_t *) n2))); } int main(int argc, char **argv) @@ -56,13 +50,9 @@ int main(int argc, char **argv) double final_cost = 5e+9; double *ParComp_wcomm2_table; - /* SD initialization */ SD_init(&argc, argv); - /* creation of the environment */ - xbt_assert(strstr(argv[1],".xml"), - "Unsupported platform description style (not XML): %s", - argv[1]); + xbt_assert(strstr(argv[1],".xml"), "Unsupported platform description style (not XML): %s", argv[1]); SD_create_environment(argv[1]); /* getting platform infos */ @@ -70,8 +60,7 @@ int main(int argc, char **argv) hosts = sg_host_list(); /* sorting hosts by hostname */ - qsort((void *) hosts, n_hosts, sizeof(sg_host_t), - nameCompareHosts); + qsort((void *) hosts, n_hosts, sizeof(sg_host_t), nameCompareHosts); /* creation of the tasks */ taskInit = SD_task_create("Initial", NULL, 1.0); @@ -84,7 +73,6 @@ int main(int argc, char **argv) taskFinal = SD_task_create("Final", NULL, 1.0); ParComp_wcomm2 = SD_task_create("Par Comp with comm 2", NULL, 1.0); - /* creation of the dependencies */ SD_task_dependency_add(NULL, NULL, taskInit, PtoPComm1); SD_task_dependency_add(NULL, NULL, taskInit, PtoPComm2); @@ -96,9 +84,6 @@ int main(int argc, char **argv) SD_task_dependency_add(NULL, NULL, ParComp_wcomm2, taskFinal); SD_task_dependency_add(NULL, NULL, PtoPComm2, taskFinal); - - /* scheduling parameters */ - /* large point-to-point communication (0.1 sec duration) */ PtoPcomm1_hosts[0] = hosts[0]; PtoPcomm1_hosts[1] = hosts[1]; @@ -159,7 +144,6 @@ int main(int argc, char **argv) /* parallel task with intra communications */ /* Communication domination (0.1 sec duration) */ - ParComp_wcomm2_table = xbt_new0(double, 25); for (i = 0; i < 5; i++) { @@ -175,35 +159,22 @@ int main(int argc, char **argv) } } - /* Sequential task */ - - /* scheduling the tasks */ - SD_task_schedule(taskInit, 1, hosts, SD_SCHED_NO_COST, SD_SCHED_NO_COST, - -1.0); - SD_task_schedule(PtoPComm1, 2, PtoPcomm1_hosts, SD_SCHED_NO_COST, - PtoPcomm1_table, -1.0); - SD_task_schedule(PtoPComm2, 2, PtoPcomm2_hosts, SD_SCHED_NO_COST, - PtoPcomm2_table, -1.0); - SD_task_schedule(ParComp_wocomm, 5, ParComp_wocomm_hosts, - ParComp_wocomm_cost, ParComp_wocomm_table, -1.0); - SD_task_schedule(IntraRedist, 5, IntraRedist_hosts, IntraRedist_cost, - IntraRedist_table, -1.0); - SD_task_schedule(ParComp_wcomm1, 5, ParComp_wcomm1_hosts, - ParComp_wcomm1_cost, ParComp_wcomm1_table, -1.0); - SD_task_schedule(InterRedist, 10, hosts, InterRedist_cost, - InterRedist_table, -1.0); - SD_task_schedule(ParComp_wcomm2, 5, ParComp_wcomm2_hosts, - ParComp_wcomm2_cost, ParComp_wcomm2_table, -1.0); - SD_task_schedule(taskFinal, 1, &(hosts[9]), &final_cost, - SD_SCHED_NO_COST, -1.0); + SD_task_schedule(taskInit, 1, hosts, SD_SCHED_NO_COST, SD_SCHED_NO_COST, -1.0); + SD_task_schedule(PtoPComm1, 2, PtoPcomm1_hosts, SD_SCHED_NO_COST, PtoPcomm1_table, -1.0); + SD_task_schedule(PtoPComm2, 2, PtoPcomm2_hosts, SD_SCHED_NO_COST, PtoPcomm2_table, -1.0); + SD_task_schedule(ParComp_wocomm, 5, ParComp_wocomm_hosts, ParComp_wocomm_cost, ParComp_wocomm_table, -1.0); + SD_task_schedule(IntraRedist, 5, IntraRedist_hosts, IntraRedist_cost, IntraRedist_table, -1.0); + SD_task_schedule(ParComp_wcomm1, 5, ParComp_wcomm1_hosts, ParComp_wcomm1_cost, ParComp_wcomm1_table, -1.0); + SD_task_schedule(InterRedist, 10, hosts, InterRedist_cost, InterRedist_table, -1.0); + SD_task_schedule(ParComp_wcomm2, 5, ParComp_wcomm2_hosts, ParComp_wcomm2_cost, ParComp_wcomm2_table, -1.0); + SD_task_schedule(taskFinal, 1, &(hosts[9]), &final_cost, SD_SCHED_NO_COST, -1.0); /* let's launch the simulation! */ SD_simulate(-1.0); XBT_INFO("Simulation time: %f", SD_get_clock()); - free(ParComp_wocomm_table); free(IntraRedist_cost); free(IntraRedist_table); diff --git a/examples/simdag/sd_typed_tasks_test.c b/examples/simdag/sd_typed_tasks_test.c index 632ca94026..cd248090e3 100644 --- a/examples/simdag/sd_typed_tasks_test.c +++ b/examples/simdag/sd_typed_tasks_test.c @@ -1,45 +1,33 @@ -/* Copyright (c) 2006-2010, 2012-2015. The SimGrid Team. +/* Copyright (c) 2006-2010, 2012-2016. 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. */ -#include -#include #include "simgrid/simdag.h" -#include "xbt/ex.h" #include "xbt/log.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(sd_typed_tasks_test, - "Logging specific to this SimDag example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(sd_typed_tasks_test, "Logging specific to this SimDag example"); int main(int argc, char **argv) { int i; unsigned int ctr; - const char *platform_file; - const sg_host_t *workstations; + const sg_host_t *hosts; SD_task_t task, seq_comp1, e2e_comm, seq_comp2; SD_task_t par_comp1, redist, par_comp2, par_comp3; xbt_dynar_t changed_tasks; double computation_amount[4]; double communication_amount[16] = { 0 }; - sg_host_t workstation_list[4]; - - /* initialization of SD */ - SD_init(&argc, argv); + sg_host_t host_list[4]; - /* xbt_log_control_set("sd.thres=debug"); */ + SD_init(&argc, argv); - xbt_assert(argc > 1, "Usage: %s platform_file\n" - "\nExample: %s two_clusters.xml", argv[0], argv[0]); + xbt_assert(argc > 1, "Usage: %s platform_file\n\nExample: %s two_clusters.xml", argv[0], argv[0]); + SD_create_environment(argv[1]); - /* creation of the environment */ - platform_file = argv[1]; - SD_create_environment(platform_file); - - workstations = sg_host_list(); + hosts = sg_host_list(); /* creation of some typed tasks and their dependencies */ seq_comp1 = SD_task_create_comp_seq("Seq. comp. 1", NULL, 1e9); @@ -57,36 +45,32 @@ int main(int argc, char **argv) SD_task_dependency_add(NULL, NULL, par_comp1, redist); SD_task_dependency_add(NULL, NULL, redist, par_comp2); - SD_task_schedulel(seq_comp1, 1, workstations[8]); - SD_task_schedulel(seq_comp2, 1, workstations[9]); + SD_task_schedulel(seq_comp1, 1, hosts[8]); + SD_task_schedulel(seq_comp2, 1, hosts[9]); - SD_task_schedulev(par_comp1, 4, workstations); - SD_task_schedulev(par_comp2, 3, workstations); + SD_task_schedulev(par_comp1, 4, hosts); + SD_task_schedulev(par_comp2, 3, hosts); - /* Let's unschedule these tasks and test the auto-scheduling in the - * opposite way. - */ + /* Let's unschedule these tasks and test the auto-scheduling in the opposite way. */ SD_task_unschedule(par_comp1); SD_task_unschedule(par_comp2); SD_task_unschedule(redist); /* yes, it was scheduled too */ - SD_task_schedulev(par_comp2, 3, workstations); - SD_task_schedulev(par_comp1, 4, workstations); + SD_task_schedulev(par_comp2, 3, hosts); + SD_task_schedulev(par_comp1, 4, hosts); for (i=0;i<4;i++){ - workstation_list[i]=workstations[i+4]; + host_list[i]=hosts[i+4]; /* Apply Amdahl's law manually assuming a 20% serial part */ computation_amount[i]=(0.2 + (1 - 0.2)/4) * SD_task_get_amount(par_comp3); } - SD_task_schedule(par_comp3, 4, workstation_list, - computation_amount, communication_amount, -1); + SD_task_schedule(par_comp3, 4, host_list, computation_amount, communication_amount, -1); changed_tasks = SD_simulate(-1.0); xbt_dynar_foreach(changed_tasks, ctr, task) { - XBT_INFO("Task '%s' start time: %f, finish time: %f", - SD_task_get_name(task), - SD_task_get_start_time(task), SD_task_get_finish_time(task)); + XBT_INFO("Task '%s' start time: %f, finish time: %f", SD_task_get_name(task), SD_task_get_start_time(task), + SD_task_get_finish_time(task)); } xbt_dynar_foreach(changed_tasks, ctr, task) { diff --git a/examples/simdag/test_simdag_fail.tesh b/examples/simdag/test_simdag_fail.tesh index d4ec5285b4..2de13b3e56 100644 --- a/examples/simdag/test_simdag_fail.tesh +++ b/examples/simdag/test_simdag_fail.tesh @@ -5,7 +5,7 @@ p Test of the management of failed tasks simdag $ $SG_TEST_EXENV ${bindir:=.}/sd_fail > [0.000000] [xbt_cfg/INFO] Switching to the L07 model to handle parallel tasks. > [0.000000] [sd_fail/INFO] First test: COMP_SEQ task -> [0.000000] [sd_fail/INFO] Schedule task 'Poor task' on workstation 'Faulty Host' +> [0.000000] [sd_fail/INFO] Schedule task 'Poor task' on 'Faulty Host' > [10.000000] [sd_task/INFO] Displaying task Poor task > [10.000000] [sd_task/INFO] - state: not runnable failed > [10.000000] [sd_task/INFO] - kind: sequential computation @@ -21,7 +21,7 @@ $ $SG_TEST_EXENV ${bindir:=.}/sd_fail > [50.000000] [sd_task/INFO] - Dependencies to satisfy: 0 > [50.000000] [sd_fail/INFO] Task 'Poor task' start time: 10.000000, finish time: 50.000000 > [50.000000] [sd_fail/INFO] Second test: NON TYPED task -> [50.000000] [sd_fail/INFO] Schedule task 'Poor parallel task' on workstation 'Faulty Host' +> [50.000000] [sd_fail/INFO] Schedule task 'Poor parallel task' on 'Faulty Host' > [60.000000] [sd_task/INFO] Displaying task Poor parallel task > [60.000000] [sd_task/INFO] - state: not runnable failed > [60.000000] [sd_task/INFO] - amount: 20000000000 diff --git a/include/simgrid/simdag.h b/include/simgrid/simdag.h index c627e0d2b6..15480fdd85 100644 --- a/include/simgrid/simdag.h +++ b/include/simgrid/simdag.h @@ -18,9 +18,8 @@ SG_BEGIN_DECL() /** @brief Link datatype @ingroup SD_datatypes_management - A link is a network node represented as a name, a current - bandwidth and a current latency. A route is a list of - links between two workstations. + A link is a network node represented as a name, a bandwidth and a latency. + A route is a list of links between two workstations. @see SD_link_management */ typedef Link *SD_link_t; @@ -28,11 +27,9 @@ typedef Link *SD_link_t; /** @brief Task datatype @ingroup SD_datatypes_management - A task is some computing amount that can be executed - in parallel on several workstations. A task may depend on other - tasks, this means that the task cannot start until the other tasks are done. - Each task has a \ref e_SD_task_state_t "state" indicating whether - the task is scheduled, running, done, etc. + A task is some computing amount that can be executed in parallel on several hosts. + A task may depend on other tasks, which means that the task cannot start until the other tasks are done. + Each task has a \ref e_SD_task_state_t "state" indicating whether the task is scheduled, running, done, ... @see SD_task_management */ typedef struct SD_task *SD_task_t; @@ -68,8 +65,6 @@ typedef enum { /** @brief Storage datatype @ingroup SD_datatypes_management - TODO PV: comment it ! - @see SD_storage_management */ typedef xbt_dictelm_t SD_storage_t; @@ -81,8 +76,7 @@ typedef xbt_dictelm_t SD_storage_t; * This section describes the functions for managing the hosts. * * A host is a place where a task can be executed. - * A host is represented as a physical resource with computing - * capabilities and has a name. + * A host is represented as a physical resource with computing capabilities and has a name. * * The hosts are created when you call the function SD_create_environment. * @@ -105,9 +99,9 @@ XBT_PUBLIC(const char*) SD_storage_get_host(SD_storage_t storage); * * This section describes the functions for managing the tasks. * - * A task is some working amount that can be executed in parallel on several hosts. A task may depend on other - * tasks, this means that the task cannot start until the other tasks are done. Each task has a - * \ref e_SD_task_state_t "state" indicating whether the task is scheduled, running, done, etc. + * A task is some working amount that can be executed in parallel on several hosts. + * A task may depend on other tasks, which means that the task cannot start until the other tasks are done. + * Each task has a \ref e_SD_task_state_t "state" indicating whether the task is scheduled, running, done, ... * * @see SD_task_t, SD_task_dependency_management * @{ @@ -195,8 +189,8 @@ XBT_PUBLIC(double) SD_get_clock(void); XBT_PUBLIC(void) SD_exit(void); XBT_PUBLIC(xbt_dynar_t) SD_daxload(const char *filename); XBT_PUBLIC(xbt_dynar_t) SD_dotload(const char *filename); -XBT_PUBLIC(xbt_dynar_t) SD_PTG_dotload(const char *filename); XBT_PUBLIC(xbt_dynar_t) SD_dotload_with_sched(const char *filename); +XBT_PUBLIC(xbt_dynar_t) SD_PTG_dotload(const char *filename); /** @} */ diff --git a/src/simdag/sd_daxloader.cpp b/src/simdag/sd_daxloader.cpp index af26fd6026..6eb07fdccc 100644 --- a/src/simdag/sd_daxloader.cpp +++ b/src/simdag/sd_daxloader.cpp @@ -27,10 +27,9 @@ bool parents_are_marked(SD_task_t task); static double dax_parse_double(const char *string) { - int ret = 0; double value; - ret = sscanf(string, "%lg", &value); + int ret = sscanf(string, "%lg", &value); xbt_assert (ret == 1, "Parse error on line %d: %s is not a double", dax_lineno, string); return value; } @@ -40,16 +39,14 @@ static double dax_parse_double(const char *string) void uniq_transfer_task_name(SD_task_t task) { SD_task_t child, parent; - xbt_dynar_t children, parents; - char *new_name; - children = SD_task_get_children(task); - parents = SD_task_get_parents(task); + xbt_dynar_t children = SD_task_get_children(task); + xbt_dynar_t parents = SD_task_get_parents(task); xbt_dynar_get_cpy(children, 0, &child); xbt_dynar_get_cpy(parents, 0, &parent); - new_name = bprintf("%s_%s_%s", SD_task_get_name(parent), SD_task_get_name(task), SD_task_get_name(child)); + char *new_name = bprintf("%s_%s_%s", SD_task_get_name(parent), SD_task_get_name(task), SD_task_get_name(child)); SD_task_set_name(task, new_name); @@ -59,37 +56,26 @@ void uniq_transfer_task_name(SD_task_t task) } bool children_are_marked(SD_task_t task){ - SD_task_t child_task = NULL; - bool all_marked = true; SD_dependency_t depafter = NULL; unsigned int count; + xbt_dynar_foreach(task->tasks_after,count,depafter){ - child_task = depafter->dst; - //test marked - if(child_task->marked == 0) { - all_marked = false; - break; + if(depafter->dst->marked == 0) { + return false; } - child_task = NULL; } - return all_marked; + return true; } bool parents_are_marked(SD_task_t task){ - SD_task_t parent_task = NULL; - bool all_marked = true; SD_dependency_t depbefore = NULL; unsigned int count; xbt_dynar_foreach(task->tasks_before,count,depbefore){ - parent_task = depbefore->src; - //test marked - if(parent_task->marked == 0) { - all_marked = false; - break; + if(depbefore->src->marked == 0) { + return false; } - parent_task = NULL; } - return all_marked; + return true; } bool acyclic_graph_detail(xbt_dynar_t dag){ @@ -209,8 +195,6 @@ bool acyclic_graph_detail(xbt_dynar_t dag){ return all_marked; } - - static YY_BUFFER_STATE input_buffer; static xbt_dynar_t result; @@ -353,12 +337,11 @@ void STag_dax__job(void) void STag_dax__uses(void) { - SD_task_t file; double size = dax_parse_double(A_dax__uses_size); int is_input = (A_dax__uses_link == A_dax__uses_link_input); // XBT_INFO("See ",A_dax__uses_file,(is_input?"in":"out")); - file = (SD_task_t)xbt_dict_get_or_null(files, A_dax__uses_file); + SD_task_t file = (SD_task_t)xbt_dict_get_or_null(files, A_dax__uses_file); if (file == NULL) { file = SD_task_create_comm_e2e(A_dax__uses_file, NULL, size); xbt_dynar_pop(sd_global->initial_task_set,NULL); diff --git a/src/simdag/sd_task.cpp b/src/simdag/sd_task.cpp index ce725ece20..c9243b018e 100644 --- a/src/simdag/sd_task.cpp +++ b/src/simdag/sd_task.cpp @@ -35,7 +35,6 @@ void SD_task_recycle_f(void *t) task->state= SD_NOT_SCHEDULED; xbt_dynar_push(sd_global->initial_task_set,&task); - task->marked = 0; task->start_time = -1.0; @@ -156,7 +155,7 @@ SD_task_t SD_task_create_comp_seq(const char *name, void *data, double flops_amo SD_task_t SD_task_create_comp_par_amdahl(const char *name, void *data, double flops_amount, double alpha) { xbt_assert(alpha < 1. && alpha >= 0., "Invalid parameter: alpha must be in [0.;1.["); - + SD_task_t res = SD_task_create(name, data, flops_amount); res->alpha = alpha; res->kind = SD_TASK_COMP_PAR_AMDAHL; @@ -197,7 +196,6 @@ SD_task_t SD_task_create_comm_par_mxn_1d_block(const char *name, void *data, dou */ void SD_task_destroy(SD_task_t task) { - int idx; XBT_DEBUG("Destroying task %s...", SD_task_get_name(task)); __SD_task_remove_dependencies(task); @@ -205,7 +203,7 @@ void SD_task_destroy(SD_task_t task) if (task->state == SD_SCHEDULED || task->state == SD_RUNNABLE) __SD_task_destroy_scheduling_data(task); - idx = xbt_dynar_search_or_negative(sd_global->return_set, &task); + int idx = xbt_dynar_search_or_negative(sd_global->return_set, &task); if (idx >=0) { xbt_dynar_remove_at(sd_global->return_set, idx, NULL); } @@ -370,10 +368,9 @@ void SD_task_set_name(SD_task_t task, const char *name) xbt_dynar_t SD_task_get_parents(SD_task_t task) { unsigned int i; - xbt_dynar_t parents; SD_dependency_t dep; - parents = xbt_dynar_new(sizeof(SD_task_t), NULL); + xbt_dynar_t parents = xbt_dynar_new(sizeof(SD_task_t), NULL); xbt_dynar_foreach(task->tasks_before, i, dep) { xbt_dynar_push(parents, &(dep->src)); } @@ -388,10 +385,9 @@ xbt_dynar_t SD_task_get_parents(SD_task_t task) xbt_dynar_t SD_task_get_children(SD_task_t task) { unsigned int i; - xbt_dynar_t children; SD_dependency_t dep; - children = xbt_dynar_new(sizeof(SD_task_t), NULL); + xbt_dynar_t children = xbt_dynar_new(sizeof(SD_task_t), NULL); xbt_dynar_foreach(task->tasks_after, i, dep) { xbt_dynar_push(children, &(dep->dst)); } @@ -487,10 +483,9 @@ void SD_task_dump(SD_task_t task) { unsigned int counter; SD_dependency_t dependency; - char *statename; XBT_INFO("Displaying task %s", SD_task_get_name(task)); - statename = bprintf("%s%s%s%s%s%s%s", + char *statename = bprintf("%s%s%s%s%s%s%s", (task->state == SD_NOT_SCHEDULED ? " not scheduled" : ""), (task->state == SD_SCHEDULABLE ? " schedulable" : ""), (task->state == SD_SCHEDULED ? " scheduled" : ""), @@ -588,20 +583,15 @@ static void __SD_task_dependency_destroy(void *dependency) */ void SD_task_dependency_add(const char *name, void *data, SD_task_t src, SD_task_t dst) { - xbt_dynar_t dynar; - unsigned long length; int found = 0; - unsigned long i; SD_dependency_t dependency; - e_SD_task_state_t state; - dynar = src->tasks_after; - length = xbt_dynar_length(dynar); + unsigned long length = xbt_dynar_length(src->tasks_after); if (src == dst) THROWF(arg_error, 0, "Cannot add a dependency between task '%s' and itself", SD_task_get_name(src)); - state = SD_task_get_state(src); + e_SD_task_state_t state = SD_task_get_state(src); if (state != SD_NOT_SCHEDULED && state != SD_SCHEDULABLE && state != SD_RUNNING && state != SD_SCHEDULED && state != SD_RUNNABLE) THROWF(arg_error, 0, "Task '%s' must be SD_NOT_SCHEDULED, SD_SCHEDULABLE, SD_SCHEDULED, SD_RUNNABLE, or SD_RUNNING", @@ -613,8 +603,8 @@ void SD_task_dependency_add(const char *name, void *data, SD_task_t src, SD_task SD_task_get_name(dst)); XBT_DEBUG("SD_task_dependency_add: src = %s, dst = %s", SD_task_get_name(src), SD_task_get_name(dst)); - for (i = 0; i < length && !found; i++) { - xbt_dynar_get_cpy(dynar, i, &dependency); + for (unsigned long i = 0; i < length && !found; i++) { + xbt_dynar_get_cpy(src->tasks_after, i, &dependency); found = (dependency->dst == dst); XBT_DEBUG("Dependency %lu: dependency->dst = %s", i, SD_task_get_name(dependency->dst)); } @@ -643,6 +633,7 @@ void SD_task_dependency_add(const char *name, void *data, SD_task_t src, SD_task SD_task_set_state(dst, SD_SCHEDULED); } } + /** * \brief Returns the name given as input when dependency has been created.. * @@ -672,13 +663,12 @@ const char *SD_task_dependency_get_name(SD_task_t src, SD_task_t dst){ */ int SD_task_dependency_exists(SD_task_t src, SD_task_t dst) { - unsigned int counter; - SD_dependency_t dependency; - xbt_assert(src != NULL || dst != NULL, "Invalid parameter: both src and dst are NULL"); if (src) { if (dst) { + unsigned int counter; + SD_dependency_t dependency; xbt_dynar_foreach(src->tasks_after, counter, dependency) { if (dependency->dst == dst) return 1; @@ -701,20 +691,17 @@ int SD_task_dependency_exists(SD_task_t src, SD_task_t dst) */ void SD_task_dependency_remove(SD_task_t src, SD_task_t dst) { - xbt_dynar_t dynar; unsigned long length; int found = 0; - unsigned long i; SD_dependency_t dependency; /* remove the dependency from src->tasks_after */ - dynar = src->tasks_after; - length = xbt_dynar_length(dynar); + length = xbt_dynar_length(src->tasks_after); - for (i = 0; i < length && !found; i++) { - xbt_dynar_get_cpy(dynar, i, &dependency); + for (unsigned long i = 0; i < length && !found; i++) { + xbt_dynar_get_cpy(src->tasks_after, i, &dependency); if (dependency->dst == dst) { - xbt_dynar_remove_at(dynar, i, NULL); + xbt_dynar_remove_at(src->tasks_after, i, NULL); found = 1; } } @@ -723,14 +710,13 @@ void SD_task_dependency_remove(SD_task_t src, SD_task_t dst) SD_task_get_name(src), SD_task_get_name(dst), SD_task_get_name(dst), SD_task_get_name(src)); /* remove the dependency from dst->tasks_before */ - dynar = dst->tasks_before; - length = xbt_dynar_length(dynar); + length = xbt_dynar_length(dst->tasks_before); found = 0; - for (i = 0; i < length && !found; i++) { - xbt_dynar_get_cpy(dynar, i, &dependency); + for (unsigned long i = 0; i < length && !found; i++) { + xbt_dynar_get_cpy(dst->tasks_before, i, &dependency); if (dependency->src == src) { - xbt_dynar_remove_at(dynar, i, NULL); + xbt_dynar_remove_at(dst->tasks_before, i, NULL); __SD_task_dependency_destroy(dependency); dst->unsatisfied_dependencies--; dst->is_not_ready--; @@ -742,7 +728,6 @@ void SD_task_dependency_remove(SD_task_t src, SD_task_t dst) SD_task_get_name(dst), SD_task_get_name(src), SD_task_get_name(src), SD_task_get_name(dst)); /* if the task was scheduled and dst->tasks_before is empty now, we can make it runnable */ - if (dst->unsatisfied_dependencies == 0) { if (SD_task_get_state(dst) == SD_SCHEDULED) SD_task_set_state(dst, SD_RUNNABLE); @@ -764,17 +749,13 @@ void SD_task_dependency_remove(SD_task_t src, SD_task_t dst) */ void *SD_task_dependency_get_data(SD_task_t src, SD_task_t dst) { - xbt_dynar_t dynar; - unsigned long length; int found = 0; - unsigned long i; SD_dependency_t dependency; - dynar = src->tasks_after; - length = xbt_dynar_length(dynar); + unsigned long length = xbt_dynar_length(src->tasks_after); - for (i = 0; i < length && !found; i++) { - xbt_dynar_get_cpy(dynar, i, &dependency); + for (unsigned long i = 0; i < length && !found; i++) { + xbt_dynar_get_cpy(src->tasks_after, i, &dependency); found = (dependency->dst == dst); } if (!found) @@ -790,8 +771,7 @@ void *SD_task_dependency_get_data(SD_task_t src, SD_task_t dst) * The watch point is then automatically removed. * * \param task a task - * \param state the \ref e_SD_task_state_t "state" you want to watch - * (cannot be #SD_NOT_SCHEDULED) + * \param state the \ref e_SD_task_state_t "state" you want to watch (cannot be #SD_NOT_SCHEDULED) * \see SD_task_unwatch() */ void SD_task_watch(SD_task_t task, e_SD_task_state_t state) @@ -812,7 +792,6 @@ void SD_task_watch(SD_task_t task, e_SD_task_state_t state) void SD_task_unwatch(SD_task_t task, e_SD_task_state_t state) { xbt_assert(state != SD_NOT_SCHEDULED, "SimDag error: Cannot have a watch point for state SD_NOT_SCHEDULED"); - task->watch_points = task->watch_points & ~state; } @@ -832,19 +811,17 @@ void SD_task_unwatch(SD_task_t task, e_SD_task_state_t state) double SD_task_get_execution_time(SD_task_t task, int workstation_nb, const sg_host_t *workstation_list, const double *flops_amount, const double *bytes_amount) { - double time, max_time = 0.0; - int i, j; xbt_assert(workstation_nb > 0, "Invalid parameter"); + double max_time = 0.0; /* the task execution time is the maximum execution time of the parallel tasks */ - - for (i = 0; i < workstation_nb; i++) { - time = 0.0; + for (int i = 0; i < workstation_nb; i++) { + double time = 0.0; if (flops_amount != NULL) time = flops_amount[i] / sg_host_speed(workstation_list[i]); if (bytes_amount != NULL) - for (j = 0; j < workstation_nb; j++) { + for (int j = 0; j < workstation_nb; j++) { if (bytes_amount[i * workstation_nb + j] !=0 ) { time += (SD_route_get_latency(workstation_list[i], workstation_list[j]) + bytes_amount[i * workstation_nb + j] / @@ -864,7 +841,6 @@ static XBT_INLINE void SD_task_do_schedule(SD_task_t task) if (SD_task_get_state(task) > SD_SCHEDULABLE) THROWF(arg_error, 0, "Task '%s' has already been scheduled", SD_task_get_name(task)); - /* update the task state */ if (task->unsatisfied_dependencies == 0) SD_task_set_state(task, SD_RUNNABLE); else @@ -878,30 +854,30 @@ static XBT_INLINE void SD_task_do_schedule(SD_task_t task) * Once scheduled, a task is executed as soon as possible in \see SD_simulate, i.e. when its dependencies are satisfied. * * \param task the task you want to schedule - * \param workstation_count number of workstations on which the task will be executed + * \param host_count number of workstations on which the task will be executed * \param workstation_list the workstations on which the task will be executed * \param flops_amount computation amount for each workstation * \param bytes_amount communication amount between each pair of workstations * \param rate task execution speed rate * \see SD_task_unschedule() */ -void SD_task_schedule(SD_task_t task, int workstation_count, const sg_host_t * workstation_list, +void SD_task_schedule(SD_task_t task, int host_count, const sg_host_t * workstation_list, const double *flops_amount, const double *bytes_amount, double rate) { - xbt_assert(workstation_count > 0, "workstation_nb must be positive"); + xbt_assert(host_count > 0, "workstation_nb must be positive"); - task->host_count = workstation_count; + task->host_count = host_count; task->rate = rate; if (flops_amount) { - task->flops_amount = (double*)xbt_realloc(task->flops_amount, sizeof(double) * workstation_count); - memcpy(task->flops_amount, flops_amount, sizeof(double) * workstation_count); + task->flops_amount = (double*)xbt_realloc(task->flops_amount, sizeof(double) * host_count); + memcpy(task->flops_amount, flops_amount, sizeof(double) * host_count); } else { xbt_free(task->flops_amount); task->flops_amount = NULL; } - int communication_nb = workstation_count * workstation_count; + int communication_nb = host_count * host_count; if (bytes_amount) { task->bytes_amount = (double*)xbt_realloc(task->bytes_amount, sizeof(double) * communication_nb); memcpy(task->bytes_amount, bytes_amount, sizeof(double) * communication_nb); @@ -910,8 +886,8 @@ void SD_task_schedule(SD_task_t task, int workstation_count, const sg_host_t * w task->bytes_amount = NULL; } - task->host_list = (sg_host_t*) xbt_realloc(task->host_list, sizeof(sg_host_t) * workstation_count); - memcpy(task->host_list, workstation_list, sizeof(sg_host_t) * workstation_count); + task->host_list = (sg_host_t*) xbt_realloc(task->host_list, sizeof(sg_host_t) * host_count); + memcpy(task->host_list, workstation_list, sizeof(sg_host_t) * host_count); SD_task_do_schedule(task); } @@ -971,9 +947,6 @@ static void __SD_task_destroy_scheduling_data(SD_task_t task) /* Runs a task. */ void SD_task_run(SD_task_t task) { - int i; - sg_host_t *hosts; - xbt_assert(SD_task_get_state(task) == SD_RUNNABLE, "Task '%s' is not runnable! Task state: %d", SD_task_get_name(task), (int)SD_task_get_state(task)); xbt_assert(task->host_list != NULL, "Task '%s': workstation_list is NULL!", SD_task_get_name(task)); @@ -982,9 +955,9 @@ void SD_task_run(SD_task_t task) /* Copy the elements of the task into the action */ int host_nb = task->host_count; - hosts = xbt_new(sg_host_t, host_nb); + sg_host_t *hosts = xbt_new(sg_host_t, host_nb); - for (i = 0; i < host_nb; i++) + for (int i = 0; i < host_nb; i++) hosts[i] = task->host_list[i]; double *flops_amount = xbt_new0(double, host_nb); @@ -1006,9 +979,6 @@ void SD_task_run(SD_task_t task) __SD_task_destroy_scheduling_data(task); /* now the scheduling data are not useful anymore */ SD_task_set_state(task, SD_RUNNING); - xbt_assert(SD_task_get_state(task) == SD_RUNNING, "Bad state of task '%s': %d", - SD_task_get_name(task), (int)SD_task_get_state(task)); - } /* @@ -1065,7 +1035,6 @@ double SD_task_get_finish_time(SD_task_t task) void SD_task_distribute_comp_amdahl(SD_task_t task, int ws_count) { - int i; xbt_assert(task->kind == SD_TASK_COMP_PAR_AMDAHL, "Task %s is not a SD_TASK_COMP_PAR_AMDAHL typed task." "Cannot use this function.", SD_task_get_name(task)); task->flops_amount = xbt_new0(double, ws_count); @@ -1074,7 +1043,7 @@ void SD_task_distribute_comp_amdahl(SD_task_t task, int ws_count) task->host_count = ws_count; task->host_list = xbt_new0(sg_host_t, ws_count); - for(i=0;iflops_amount[i] = (task->alpha + (1 - task->alpha)/ws_count) * task->amount; } } @@ -1120,10 +1089,10 @@ void SD_task_schedulev(SD_task_t task, int count, const sg_host_t * list) default: xbt_die("Kind of task %s not supported by SD_task_schedulev()", SD_task_get_name(task)); } + if (task->kind == SD_TASK_COMM_E2E) { XBT_VERB("Schedule comm task %s between %s -> %s. It costs %.f bytes", SD_task_get_name(task), sg_host_get_name(task->host_list[0]), sg_host_get_name(task->host_list[1]), task->bytes_amount[2]); - } /* Iterate over all children and parents being COMM_E2E to say where I am located (and start them if runnable) */ @@ -1277,9 +1246,8 @@ void SD_task_schedulel(SD_task_t task, int count, ...) { va_list ap; sg_host_t *list = xbt_new(sg_host_t, count); - int i; va_start(ap, count); - for (i = 0; i < count; i++) { + for (int i = 0; i < count; i++) { list[i] = va_arg(ap, sg_host_t); } va_end(ap); diff --git a/teshsuite/simdag/availability/CMakeLists.txt b/teshsuite/simdag/availability/CMakeLists.txt index 47f4f54ae5..05cdb9cf2f 100644 --- a/teshsuite/simdag/availability/CMakeLists.txt +++ b/teshsuite/simdag/availability/CMakeLists.txt @@ -1,13 +1,7 @@ set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}") add_executable(availability_test availability_test.c) - -### Add definitions for compile -if(NOT WIN32) - target_link_libraries(availability_test simgrid m) -else() - target_link_libraries(availability_test simgrid) -endif() +target_link_libraries(availability_test simgrid) set(tesh_files ${tesh_files} diff --git a/teshsuite/simdag/availability/availability_test.c b/teshsuite/simdag/availability/availability_test.c index 88d34f07a6..a0f3c73c3a 100644 --- a/teshsuite/simdag/availability/availability_test.c +++ b/teshsuite/simdag/availability/availability_test.c @@ -4,24 +4,15 @@ /* 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 -#include #include -#include -#include #include #include -#include -#include XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging for the current example"); static int name_compare_hosts(const void *n1, const void *n2) { - return strcmp( - sg_host_get_name(*(sg_host_t *) n1), - sg_host_get_name(*(sg_host_t *) n2) - ); + return strcmp(sg_host_get_name(*(sg_host_t *) n1), sg_host_get_name(*(sg_host_t *) n2)); } static void scheduleDAX(xbt_dynar_t dax) @@ -33,54 +24,34 @@ static void scheduleDAX(xbt_dynar_t dax) int totalHosts = sg_host_count(); qsort((void *) ws_list, totalHosts, sizeof(sg_host_t), name_compare_hosts); - xbt_dynar_foreach(dax, cursor, task) { if (SD_task_get_kind(task) == SD_TASK_COMP_SEQ) { - if (!strcmp(SD_task_get_name(task), "end") - || !strcmp(SD_task_get_name(task), "root")) { - XBT_INFO("Scheduling %s to node: %s", SD_task_get_name(task), - sg_host_get_name(ws_list[0])); + if (!strcmp(SD_task_get_name(task), "end") || !strcmp(SD_task_get_name(task), "root")) { + XBT_INFO("Scheduling %s to node: %s", SD_task_get_name(task), sg_host_get_name(ws_list[0])); SD_task_schedulel(task, 1, ws_list[0]); } else { - XBT_INFO("Scheduling %s to node: %s", SD_task_get_name(task), - sg_host_get_name(ws_list[(cursor) % totalHosts])); + XBT_INFO("Scheduling %s to node: %s", SD_task_get_name(task), sg_host_get_name(ws_list[(cursor) % totalHosts])); SD_task_schedulel(task, 1, ws_list[(cursor) % totalHosts]); } } } } -static xbt_dynar_t initDynamicThrottling(int argc, char *argv[]) +int main(int argc, char *argv[]) { SD_init(&argc, argv); - xbt_assert(argc == 3, - "Error on parameters.\n" - "Usage: %s \n", argv[0]); - - FILE *testFile = fopen(argv[1], "r"); - xbt_assert(testFile, "Cannot open platform file %s.\n", argv[1]); - testFile = fopen(argv[2], "r"); - xbt_assert(testFile, "Cannot open DAX file %s.\n", argv[2]); + xbt_assert(argc > 2, "Usage: %s platform_file dax_file\n" + "\tExample: %s simulacrum_7_hosts.xml Montage_25.xml", argv[0], argv[0]); SD_create_environment(argv[1]); xbt_dynar_t dax = SD_daxload(argv[2]); - // Schedule DAX XBT_INFO("Scheduling DAX..."); scheduleDAX(dax); XBT_INFO("DAX scheduled"); SD_simulate(-1); XBT_INFO("Simulation done."); - return dax; -} - -int main(int argc, char *argv[]) -{ - - /* Start process... */ - xbt_dynar_t dax = initDynamicThrottling(argc, argv); - // Free memory while (!xbt_dynar_is_empty(dax)) { SD_task_t task = xbt_dynar_pop_as(dax, SD_task_t); diff --git a/teshsuite/simdag/basic/CMakeLists.txt b/teshsuite/simdag/basic/CMakeLists.txt index fbbd03ffa7..69af506766 100644 --- a/teshsuite/simdag/basic/CMakeLists.txt +++ b/teshsuite/simdag/basic/CMakeLists.txt @@ -8,24 +8,13 @@ add_executable(basic4 basic4.c) add_executable(basic5 basic5.c) add_executable(basic6 basic6.c) -### Add definitions for compile -if(NOT WIN32) - target_link_libraries(basic0 simgrid m pthread ) - target_link_libraries(basic1 simgrid m pthread ) - target_link_libraries(basic2 simgrid m pthread ) - target_link_libraries(basic3 simgrid m pthread ) - target_link_libraries(basic4 simgrid m pthread ) - target_link_libraries(basic5 simgrid m pthread ) - target_link_libraries(basic6 simgrid m pthread ) -else() - target_link_libraries(basic0 simgrid) - target_link_libraries(basic1 simgrid) - target_link_libraries(basic2 simgrid) - target_link_libraries(basic3 simgrid) - target_link_libraries(basic4 simgrid) - target_link_libraries(basic5 simgrid) - target_link_libraries(basic6 simgrid) -endif() +target_link_libraries(basic0 simgrid) +target_link_libraries(basic1 simgrid) +target_link_libraries(basic2 simgrid) +target_link_libraries(basic3 simgrid) +target_link_libraries(basic4 simgrid) +target_link_libraries(basic5 simgrid) +target_link_libraries(basic6 simgrid) set(tesh_files ${tesh_files} diff --git a/teshsuite/simdag/basic/basic0.c b/teshsuite/simdag/basic/basic0.c index b14c08c68a..4b472c3fd3 100644 --- a/teshsuite/simdag/basic/basic0.c +++ b/teshsuite/simdag/basic/basic0.c @@ -4,8 +4,6 @@ /* 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 -#include #include "simgrid/simdag.h" #include "xbt/log.h" @@ -16,21 +14,14 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(basic0, sd, "SimDag test basic0"); * - Create a no-op Init task * - Create two communication tasks: 100MB and 1B * - Schedule them concurrently on the two hosts of the platform - * The two communications occur simultaneously but one is so short that it has - * no impact on the other. + * The two communications occur simultaneously but one is so short that it has no impact on the other. * Simulated time should be: * 1e8/1.25e8 + 1e-4 = 0.8001 seconds - * This corresponds to paying latency once and having the full bandwidth for the - * big message. + * This corresponds to paying latency once and having the full bandwidth for the big message. */ int main(int argc, char **argv) { - SD_task_t taskInit; - SD_task_t taskA; - SD_task_t taskB; - /* scheduling parameters */ - double communication_amount1[] = { 0, 1e8, 0, 0 }; double communication_amount2[] = { 0, 1, 0, 0 }; const double no_cost[] = { 0.0, 0.0 }; @@ -42,22 +33,18 @@ int main(int argc, char **argv) SD_create_environment(argv[1]); /* creation of the tasks and their dependencies */ - taskInit = SD_task_create("Init", NULL, 1.0); - taskA = SD_task_create("Task Comm 1", NULL, 1.0); - taskB = SD_task_create("Task Comm 2", NULL, 1.0); - - /* let's launch the simulation! */ - - SD_task_schedule(taskInit, 1, sg_host_list(), no_cost, - no_cost, -1.0); - SD_task_schedule(taskA, 2, sg_host_list(), no_cost, - communication_amount1, -1.0); - SD_task_schedule(taskB, 2, sg_host_list(), no_cost, - communication_amount2, -1.0); + SD_task_t taskInit = SD_task_create("Init", NULL, 1.0); + SD_task_t taskA = SD_task_create("Task Comm 1", NULL, 1.0); + SD_task_t taskB = SD_task_create("Task Comm 2", NULL, 1.0); SD_task_dependency_add(NULL, NULL, taskInit, taskA); SD_task_dependency_add(NULL, NULL, taskInit, taskB); + SD_task_schedule(taskInit, 1, sg_host_list(), no_cost, no_cost, -1.0); + SD_task_schedule(taskA, 2, sg_host_list(), no_cost, communication_amount1, -1.0); + SD_task_schedule(taskB, 2, sg_host_list(), no_cost, communication_amount2, -1.0); + + /* let's launch the simulation! */ SD_simulate(-1.0); SD_task_destroy(taskInit); SD_task_destroy(taskA); diff --git a/teshsuite/simdag/basic/basic1.c b/teshsuite/simdag/basic/basic1.c index 851a53e3fa..1d0b508dc5 100644 --- a/teshsuite/simdag/basic/basic1.c +++ b/teshsuite/simdag/basic/basic1.c @@ -4,8 +4,6 @@ /* 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 -#include #include "simgrid/simdag.h" #include "xbt/log.h" @@ -23,17 +21,11 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(basic1, sd, "SimDag test basic1"); */ int main(int argc, char **argv) { - - SD_task_t taskInit; - SD_task_t taskA; - SD_task_t taskB; - + /* scheduling parameters */ double communication_amount1 = 1e9; double communication_amount2 = 1e9; double no_cost = 0.0; - const sg_host_t *workstation; - /* initialization of SD */ SD_init(&argc, argv); @@ -41,27 +33,20 @@ int main(int argc, char **argv) SD_create_environment(argv[1]); /* creation of the tasks and their dependencies */ - taskInit = SD_task_create("Init", NULL, 1.0); - taskA = SD_task_create("Task Comm A", NULL, 1.0); - taskB = SD_task_create("Task Comm B", NULL, 1.0); - + SD_task_t taskInit = SD_task_create("Init", NULL, 1.0); + SD_task_t taskA = SD_task_create("Task Comm A", NULL, 1.0); + SD_task_t taskB = SD_task_create("Task Comm B", NULL, 1.0); - /* scheduling parameters */ + SD_task_dependency_add(NULL, NULL, taskInit, taskA); + SD_task_dependency_add(NULL, NULL, taskInit, taskB); + const sg_host_t *hosts = sg_host_list(); - workstation = sg_host_list(); + SD_task_schedule(taskInit, 1, sg_host_list(), &no_cost, &no_cost, -1.0); + SD_task_schedule(taskA, 1, &hosts[0], &no_cost, &communication_amount1, -1.0); + SD_task_schedule(taskB, 1, &hosts[1], &no_cost, &communication_amount2, -1.0); /* let's launch the simulation! */ - SD_task_schedule(taskInit, 1, sg_host_list(), &no_cost, - &no_cost, -1.0); - SD_task_schedule(taskA, 1, &workstation[0], &no_cost, - &communication_amount1, -1.0); - SD_task_schedule(taskB, 1, &workstation[1], &no_cost, - &communication_amount2, -1.0); - - SD_task_dependency_add(NULL, NULL, taskInit, taskA); - SD_task_dependency_add(NULL, NULL, taskInit, taskB); - SD_simulate(-1.0); SD_task_destroy(taskA); SD_task_destroy(taskB); diff --git a/teshsuite/simdag/basic/basic2.c b/teshsuite/simdag/basic/basic2.c index 74edbe7910..96b8408f06 100644 --- a/teshsuite/simdag/basic/basic2.c +++ b/teshsuite/simdag/basic/basic2.c @@ -4,8 +4,6 @@ /* 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 -#include #include "simgrid/simdag.h" #include "xbt/log.h" @@ -16,20 +14,14 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(basic2, sd, "SimDag test basic2"); * - Create a no-op Init task * - Create two communication tasks: 1GB and 100MB * - Schedule them concurrently on the two hosts of the platform - * The two communications occur simultaneously. They share the network for the - * duration of the shortest one, then the longest one has the full bandwidth. + * The two communications occur simultaneously. They share the network for the duration of the shortest one, then the + * longest one has the full bandwidth. * Simulated time should be: * 1e8/(1/2*1.25e8) + 9e8/1.25e8) + 1e-4 = 8.8001 seconds */ int main(int argc, char **argv) { - - SD_task_t taskInit; - SD_task_t taskA; - SD_task_t taskB; - - const sg_host_t *workstation; - + /* scheduling parameters */ double communication_amount1 = 1e9; double communication_amount2 = 1e8; double no_cost = 0.0; @@ -41,26 +33,20 @@ int main(int argc, char **argv) SD_create_environment(argv[1]); /* creation of the tasks and their dependencies */ - taskInit = SD_task_create("Init", NULL, 1.0); - taskA = SD_task_create("Task Comm A", NULL, 1.0); - taskB = SD_task_create("Task Comm B", NULL, 1.0); + SD_task_t taskInit = SD_task_create("Init", NULL, 1.0); + SD_task_t taskA = SD_task_create("Task Comm A", NULL, 1.0); + SD_task_t taskB = SD_task_create("Task Comm B", NULL, 1.0); + SD_task_dependency_add(NULL, NULL, taskInit, taskA); + SD_task_dependency_add(NULL, NULL, taskInit, taskB); - /* scheduling parameters */ + const sg_host_t *workstation = sg_host_list(); - workstation = sg_host_list(); + SD_task_schedule(taskInit, 1, sg_host_list(), &no_cost, &no_cost, -1.0); + SD_task_schedule(taskA, 1, &workstation[0], &no_cost, &communication_amount1, -1.0); + SD_task_schedule(taskB, 1, &workstation[1], &no_cost, &communication_amount2, -1.0); /* let's launch the simulation! */ - SD_task_schedule(taskInit, 1, sg_host_list(), &no_cost, - &no_cost, -1.0); - SD_task_schedule(taskA, 1, &workstation[0], &no_cost, - &communication_amount1, -1.0); - SD_task_schedule(taskB, 1, &workstation[1], &no_cost, - &communication_amount2, -1.0); - - SD_task_dependency_add(NULL, NULL, taskInit, taskA); - SD_task_dependency_add(NULL, NULL, taskInit, taskB); - SD_simulate(-1.0); SD_task_destroy(taskA); SD_task_destroy(taskB); diff --git a/teshsuite/simdag/basic/basic3.c b/teshsuite/simdag/basic/basic3.c index 94690acc35..6c2e431021 100644 --- a/teshsuite/simdag/basic/basic3.c +++ b/teshsuite/simdag/basic/basic3.c @@ -4,8 +4,6 @@ /* 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 -#include #include "simgrid/simdag.h" #include "xbt/log.h" @@ -18,13 +16,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(basic3, sd, "SimDag test basic3"); */ int main(int argc, char **argv) { - - SD_task_t taskInit; - SD_task_t taskA; - SD_task_t taskFin; - /* scheduling parameters */ - double no_cost[] = { 0.0, 0.0, 0.0, 0.0 }; /* initialization of SD */ @@ -34,21 +26,18 @@ int main(int argc, char **argv) SD_create_environment(argv[1]); /* creation of the tasks and their dependencies */ - taskInit = SD_task_create("Task Init", NULL, 1.0); - taskA = SD_task_create("Task A", NULL, 1.0); - taskFin = SD_task_create("Task Fin", NULL, 1.0); - - /* let's launch the simulation! */ - SD_task_schedule(taskInit, 1, sg_host_list(), no_cost, - no_cost, -1.0); - SD_task_schedule(taskA, 2, sg_host_list(), no_cost, no_cost, - -1.0); - SD_task_schedule(taskFin, 1, sg_host_list(), no_cost, no_cost, - -1.0); + SD_task_t taskInit = SD_task_create("Task Init", NULL, 1.0); + SD_task_t taskA = SD_task_create("Task A", NULL, 1.0); + SD_task_t taskFin = SD_task_create("Task Fin", NULL, 1.0); SD_task_dependency_add(NULL, NULL, taskInit, taskA); SD_task_dependency_add(NULL, NULL, taskA, taskFin); + SD_task_schedule(taskInit, 1, sg_host_list(), no_cost, no_cost, -1.0); + SD_task_schedule(taskA, 2, sg_host_list(), no_cost, no_cost, -1.0); + SD_task_schedule(taskFin, 1, sg_host_list(), no_cost, no_cost, -1.0); + + /* let's launch the simulation! */ SD_simulate(-1.0); SD_task_destroy(taskInit); SD_task_destroy(taskA); diff --git a/teshsuite/simdag/basic/basic4.c b/teshsuite/simdag/basic/basic4.c index a3ab2e3698..c1c36f9c19 100644 --- a/teshsuite/simdag/basic/basic4.c +++ b/teshsuite/simdag/basic/basic4.c @@ -4,8 +4,6 @@ /* 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 -#include #include "simgrid/simdag.h" #include "xbt/log.h" @@ -20,14 +18,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(basic4, sd, "SimDag test basic4"); */ int main(int argc, char **argv) { - /* creation of the tasks and their dependencies */ - - SD_task_t taskInit; - SD_task_t taskA; - SD_task_t taskFin; - /* scheduling parameters */ - double no_cost[] = { 0., 0., 0., 0. }; double amount[] = { 0., 1., 0., 0. }; @@ -38,22 +29,18 @@ int main(int argc, char **argv) SD_create_environment(argv[1]); /* creation of the tasks and their dependencies */ - taskInit = SD_task_create("Task Init", NULL, 1.0); - taskA = SD_task_create("Task A", NULL, 1.0); - taskFin = SD_task_create("Task Fin", NULL, 1.0); - - - /* let's launch the simulation! */ - SD_task_schedule(taskInit, 1, sg_host_list(), no_cost, - no_cost, -1.0); - SD_task_schedule(taskA, 2, sg_host_list(), no_cost, amount, - -1.0); - SD_task_schedule(taskFin, 1, sg_host_list(), no_cost, no_cost, - -1.0); + SD_task_t taskInit = SD_task_create("Task Init", NULL, 1.0); + SD_task_t taskA = SD_task_create("Task A", NULL, 1.0); + SD_task_t taskFin = SD_task_create("Task Fin", NULL, 1.0); SD_task_dependency_add(NULL, NULL, taskInit, taskA); SD_task_dependency_add(NULL, NULL, taskA, taskFin); + SD_task_schedule(taskInit, 1, sg_host_list(), no_cost, no_cost, -1.0); + SD_task_schedule(taskA, 2, sg_host_list(), no_cost, amount, -1.0); + SD_task_schedule(taskFin, 1, sg_host_list(), no_cost, no_cost, -1.0); + + /* let's launch the simulation! */ SD_simulate(-1.0); SD_task_destroy(taskInit); SD_task_destroy(taskA); diff --git a/teshsuite/simdag/basic/basic5.c b/teshsuite/simdag/basic/basic5.c index 7ca6bb12ff..59e0bf6a78 100644 --- a/teshsuite/simdag/basic/basic5.c +++ b/teshsuite/simdag/basic/basic5.c @@ -4,8 +4,6 @@ /* 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 -#include #include "simgrid/simdag.h" #include "xbt/log.h" @@ -22,14 +20,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(basic5, sd, "SimDag test basic5"); */ int main(int argc, char **argv) { - - /* creation of the tasks and their dependencies */ - SD_task_t taskInit; - SD_task_t taskA; - SD_task_t taskB; - /* scheduling parameters */ - double no_cost[] = { 0., 0., 0., 0. }; double amount[] = { 0., 100000., 0., 0. }; double comput[] = { 10000000. }; @@ -41,21 +32,18 @@ int main(int argc, char **argv) SD_create_environment(argv[1]); /* creation of the tasks and their dependencies */ - taskInit = SD_task_create("Task Init", NULL, 1.0); - taskA = SD_task_create("Task A", NULL, 1.0); - taskB = SD_task_create("Task B", NULL, 1.0); - - /* let's launch the simulation! */ - SD_task_schedule(taskInit, 1, sg_host_list(), no_cost, - no_cost, -1.0); - SD_task_schedule(taskA, 2, sg_host_list(), no_cost, amount, - -1.0); - SD_task_schedule(taskB, 1, sg_host_list(), comput, no_cost, - -1.0); + SD_task_t taskInit = SD_task_create("Task Init", NULL, 1.0); + SD_task_t taskA = SD_task_create("Task A", NULL, 1.0); + SD_task_t taskB = SD_task_create("Task B", NULL, 1.0); SD_task_dependency_add(NULL, NULL, taskInit, taskA); SD_task_dependency_add(NULL, NULL, taskInit, taskB); + SD_task_schedule(taskInit, 1, sg_host_list(), no_cost, no_cost, -1.0); + SD_task_schedule(taskA, 2, sg_host_list(), no_cost, amount, -1.0); + SD_task_schedule(taskB, 1, sg_host_list(), comput, no_cost, -1.0); + + /* let's launch the simulation! */ SD_simulate(-1.0); SD_task_destroy(taskInit); SD_task_destroy(taskA); diff --git a/teshsuite/simdag/basic/basic6.c b/teshsuite/simdag/basic/basic6.c index 7b5582fe18..5a2b3d5d74 100644 --- a/teshsuite/simdag/basic/basic6.c +++ b/teshsuite/simdag/basic/basic6.c @@ -4,8 +4,6 @@ /* 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 -#include #include "simgrid/simdag.h" #include "xbt/asserts.h" #include "xbt/log.h" @@ -26,24 +24,20 @@ int main(int argc, char **argv) { double comm_cost[] = { 0.0, 0.0, 0.0, 0.0 }; double comp_cost[] = { 1.0 }; - SD_task_t taskA, taskB; xbt_dynar_t ret; SD_init(&argc, argv); SD_create_environment(argv[1]); - taskA = SD_task_create("Task A", NULL, 1.0); - taskB = SD_task_create("Task B", NULL, 1.0); + SD_task_t taskA = SD_task_create("Task A", NULL, 1.0); + SD_task_t taskB = SD_task_create("Task B", NULL, 1.0); - SD_task_schedule(taskA, 1, sg_host_list(), comp_cost, - comm_cost, -1.0); - SD_task_schedule(taskB, 1, sg_host_list(), comp_cost, - comm_cost, -1.0); + SD_task_schedule(taskA, 1, sg_host_list(), comp_cost, comm_cost, -1.0); + SD_task_schedule(taskB, 1, sg_host_list(), comp_cost, comm_cost, -1.0); ret = SD_simulate(-1.0); - xbt_assert(xbt_dynar_length(ret) == 2, - "I was expecting the completion of 2 tasks, but I got %lu instead", - xbt_dynar_length(ret)); + xbt_assert(xbt_dynar_length(ret) == 2, "I was expecting the completion of 2 tasks, but I got %lu instead", + xbt_dynar_length(ret)); SD_task_destroy(taskA); SD_task_destroy(taskB); diff --git a/teshsuite/simdag/incomplete/CMakeLists.txt b/teshsuite/simdag/incomplete/CMakeLists.txt index fb74936b92..d62eb992d6 100644 --- a/teshsuite/simdag/incomplete/CMakeLists.txt +++ b/teshsuite/simdag/incomplete/CMakeLists.txt @@ -1,13 +1,7 @@ set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}") add_executable(incomplete incomplete.c) - -### Add definitions for compile -if(NOT WIN32) - target_link_libraries(incomplete simgrid m pthread ) -else() - target_link_libraries(incomplete simgrid) -endif() +target_link_libraries(incomplete simgrid) set(tesh_files ${tesh_files} diff --git a/teshsuite/simdag/incomplete/incomplete.c b/teshsuite/simdag/incomplete/incomplete.c index d108d09033..68238f013e 100644 --- a/teshsuite/simdag/incomplete/incomplete.c +++ b/teshsuite/simdag/incomplete/incomplete.c @@ -4,8 +4,6 @@ /* 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 -#include #include "simgrid/simdag.h" #include "xbt/log.h" @@ -23,12 +21,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(incomplete, sd, "SimDag incomplete test"); */ int main(int argc, char **argv) { - - SD_task_t taskInit; - SD_task_t taskA, taskB, taskC, taskD; - - const sg_host_t *workstation; - + /* scheduling parameters */ double communication_amount1 = 1e9; double no_cost = 0.0; @@ -39,31 +32,25 @@ int main(int argc, char **argv) SD_create_environment(argv[1]); /* creation of the tasks and their dependencies */ - taskInit = SD_task_create("Init", NULL, 1.0); - taskA = SD_task_create("Task A", NULL, 1.0); - taskB = SD_task_create("Task B", NULL, 1.0); - taskC = SD_task_create("Task C", NULL, 1.0); - taskD = SD_task_create("Task D", NULL, 1.0); - - - /* scheduling parameters */ - - workstation = sg_host_list(); + SD_task_t taskInit = SD_task_create("Init", NULL, 1.0); + SD_task_t taskA = SD_task_create("Task A", NULL, 1.0); + SD_task_t taskB = SD_task_create("Task B", NULL, 1.0); + SD_task_t taskC = SD_task_create("Task C", NULL, 1.0); + SD_task_t taskD = SD_task_create("Task D", NULL, 1.0); SD_task_dependency_add(NULL, NULL, taskInit, taskA); SD_task_dependency_add(NULL, NULL, taskInit, taskB); SD_task_dependency_add(NULL, NULL, taskC, taskD); - /* let's launch the simulation! */ - SD_task_schedule(taskInit, 1, sg_host_list(), &no_cost, - &no_cost, -1.0); - SD_task_schedule(taskA, 1, &workstation[0], &no_cost, - &communication_amount1, -1.0); - SD_task_schedule(taskD, 1, &workstation[0], &no_cost, - &communication_amount1, -1.0); + const sg_host_t *hosts = sg_host_list(); + SD_task_schedule(taskInit, 1, sg_host_list(), &no_cost, &no_cost, -1.0); + SD_task_schedule(taskA, 1, &hosts[0], &no_cost, &communication_amount1, -1.0); + SD_task_schedule(taskD, 1, &hosts[0], &no_cost, &communication_amount1, -1.0); + /* let's launch the simulation! */ SD_simulate(-1.); + SD_task_destroy(taskA); SD_task_destroy(taskB); SD_task_destroy(taskC); diff --git a/teshsuite/simdag/network/mxn/CMakeLists.txt b/teshsuite/simdag/network/mxn/CMakeLists.txt index 92d8f6cd07..7c60a4bde3 100644 --- a/teshsuite/simdag/network/mxn/CMakeLists.txt +++ b/teshsuite/simdag/network/mxn/CMakeLists.txt @@ -3,17 +3,9 @@ set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}") add_executable(test_intra_all2all test_intra_all2all.c) add_executable(test_intra_independent_comm test_intra_independent_comm.c) add_executable(test_intra_scatter test_intra_scatter.c) - -### Add definitions for compile -if(NOT WIN32) - target_link_libraries(test_intra_all2all simgrid m pthread ) - target_link_libraries(test_intra_independent_comm simgrid m pthread ) - target_link_libraries(test_intra_scatter simgrid m pthread ) -else() - target_link_libraries(test_intra_all2all simgrid) - target_link_libraries(test_intra_independent_comm simgrid) - target_link_libraries(test_intra_scatter simgrid) -endif() +target_link_libraries(test_intra_all2all simgrid) +target_link_libraries(test_intra_independent_comm simgrid) +target_link_libraries(test_intra_scatter simgrid) set(tesh_files ${tesh_files} @@ -31,9 +23,3 @@ set(teshsuite_src ${CMAKE_CURRENT_SOURCE_DIR}/test_intra_independent_comm.c ${CMAKE_CURRENT_SOURCE_DIR}/test_intra_scatter.c PARENT_SCOPE) -set(bin_files - ${bin_files} - PARENT_SCOPE) -set(txt_files - ${txt_files} - PARENT_SCOPE) diff --git a/teshsuite/simdag/network/mxn/test_intra_all2all.c b/teshsuite/simdag/network/mxn/test_intra_all2all.c index 06f52ed25c..7e746af047 100644 --- a/teshsuite/simdag/network/mxn/test_intra_all2all.c +++ b/teshsuite/simdag/network/mxn/test_intra_all2all.c @@ -7,8 +7,6 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include -#include - #include "simgrid/simdag.h" /* @@ -18,43 +16,31 @@ * send 1 byte from all to all * + 2 secs latency * should be 8 (platform_4p_1switch.xml) - * */ int main(int argc, char **argv) { - double time; - SD_task_t task; - double communication_amount[] = { 0.0, 1.0, 1.0, 1.0, - 1.0, 0.0, 1.0, 1.0, - 1.0, 1.0, 0.0, 1.0, - 1.0, 1.0, 1.0, 0.0, - }; + 1.0, 0.0, 1.0, 1.0, + 1.0, 1.0, 0.0, 1.0, + 1.0, 1.0, 1.0, 0.0 }; double no_cost[] = { 0.0, 0.0, 0.0, 0.0 }; - - /***************************************/ - SD_init(&argc, argv); SD_create_environment(argv[1]); - task = SD_task_create("All2all task", NULL, 1.0); + SD_task_t task = SD_task_create("All2all task", NULL, 1.0); - SD_task_schedule(task, 4, sg_host_list(), no_cost, - communication_amount, -1.0); + SD_task_schedule(task, 4, sg_host_list(), no_cost, communication_amount, -1.0); SD_simulate(-1.0); - time = SD_get_clock(); - - printf("%g\n", time); + printf("%g\n", SD_get_clock()); fflush(stdout); SD_task_destroy(task); SD_exit(); - return 0; } diff --git a/teshsuite/simdag/network/mxn/test_intra_independent_comm.c b/teshsuite/simdag/network/mxn/test_intra_independent_comm.c index 158f6f9a92..56d851e1f5 100644 --- a/teshsuite/simdag/network/mxn/test_intra_independent_comm.c +++ b/teshsuite/simdag/network/mxn/test_intra_independent_comm.c @@ -7,8 +7,6 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include -#include - #include "simgrid/simdag.h" /* @@ -23,38 +21,27 @@ int main(int argc, char **argv) { - double time; - SD_task_t task; - double communication_amount[] = { 0.0, 1.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 1.0, - 0.0, 0.0, 0.0, 0.0, - }; + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 1.0, + 0.0, 0.0, 0.0, 0.0 }; double no_cost[] = { 0.0, 0.0, 0.0, 0.0 }; - - /***************************************/ - SD_init(&argc, argv); SD_create_environment(argv[1]); - task = SD_task_create("Comm 1", NULL, 1.0); + SD_task_t task = SD_task_create("Comm 1", NULL, 1.0); - SD_task_schedule(task, 4, sg_host_list(), no_cost, - communication_amount, -1.0); + SD_task_schedule(task, 4, sg_host_list(), no_cost, communication_amount, -1.0); SD_simulate(-1.0); - time = SD_get_clock(); - - printf("%g\n", time); + printf("%g\n", SD_get_clock()); fflush(stdout); SD_task_destroy(task); SD_exit(); - return 0; } diff --git a/teshsuite/simdag/network/mxn/test_intra_scatter.c b/teshsuite/simdag/network/mxn/test_intra_scatter.c index 65174d4de8..8fc362d31b 100644 --- a/teshsuite/simdag/network/mxn/test_intra_scatter.c +++ b/teshsuite/simdag/network/mxn/test_intra_scatter.c @@ -7,8 +7,6 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include -#include - #include "simgrid/simdag.h" /* @@ -24,38 +22,27 @@ int main(int argc, char **argv) { - double time; - SD_task_t task; double communication_amount[] = { 0.0, 1.0, 2.0, 3.0, - 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, - }; - + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0 }; double no_cost[] = { 0.0, 0.0, 0.0, 0.0 }; - - /***************************************/ - SD_init(&argc, argv); SD_create_environment(argv[1]); - task = SD_task_create("Scatter task", NULL, 1.0); + SD_task_t task = SD_task_create("Scatter task", NULL, 1.0); - SD_task_schedule(task, 4, sg_host_list(), no_cost, - communication_amount, -1.0); + SD_task_schedule(task, 4, sg_host_list(), no_cost, communication_amount, -1.0); SD_simulate(-1.0); - time = SD_get_clock(); - - printf("%g\n", time); + printf("%g\n", SD_get_clock()); fflush(stdout); SD_task_destroy(task); SD_exit(); - return 0; } diff --git a/teshsuite/simdag/network/p2p/CMakeLists.txt b/teshsuite/simdag/network/p2p/CMakeLists.txt index dde435db51..5f68137487 100644 --- a/teshsuite/simdag/network/p2p/CMakeLists.txt +++ b/teshsuite/simdag/network/p2p/CMakeLists.txt @@ -4,19 +4,10 @@ add_executable(test_latency1 test_latency1.c) add_executable(test_latency2 test_latency2.c) add_executable(test_latency3 test_latency3.c) add_executable(test_latency_bound test_latency_bound.c) - -### Add definitions for compile -if(NOT WIN32) - target_link_libraries(test_latency1 simgrid m pthread ) - target_link_libraries(test_latency2 simgrid m pthread ) - target_link_libraries(test_latency3 simgrid m pthread ) - target_link_libraries(test_latency_bound simgrid m pthread ) -else() - target_link_libraries(test_latency1 simgrid) - target_link_libraries(test_latency2 simgrid) - target_link_libraries(test_latency3 simgrid) - target_link_libraries(test_latency_bound simgrid) -endif() +target_link_libraries(test_latency1 simgrid) +target_link_libraries(test_latency2 simgrid) +target_link_libraries(test_latency3 simgrid) +target_link_libraries(test_latency_bound simgrid) set(tesh_files ${tesh_files} diff --git a/teshsuite/simdag/network/p2p/test_latency1.c b/teshsuite/simdag/network/p2p/test_latency1.c index bf73f7dcb9..4896951313 100644 --- a/teshsuite/simdag/network/p2p/test_latency1.c +++ b/teshsuite/simdag/network/p2p/test_latency1.c @@ -7,8 +7,6 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include -#include - #include "simgrid/simdag.h" /* @@ -17,33 +15,26 @@ * * this is a test for multiple platforms * see tesh file for expected output - * */ int main(int argc, char **argv) { - double time; double communication_amount[] = { 0.0, 1.0, 0.0, 0.0 }; const double no_cost[] = { 0.0, 0.0 }; - SD_task_t task; SD_init(&argc, argv); SD_create_environment(argv[1]); - task = SD_task_create("Comm 1", NULL, 1.0); + SD_task_t task = SD_task_create("Comm 1", NULL, 1.0); - SD_task_schedule(task, 2, sg_host_list(), no_cost, - communication_amount, -1.0); + SD_task_schedule(task, 2, sg_host_list(), no_cost, communication_amount, -1.0); SD_simulate(-1.0); - time = SD_get_clock(); - - printf("%g\n", time); + printf("%g\n", SD_get_clock()); fflush(stdout); SD_task_destroy(task); SD_exit(); - return 0; } diff --git a/teshsuite/simdag/network/p2p/test_latency2.c b/teshsuite/simdag/network/p2p/test_latency2.c index 5a22fa0ad7..ceafd26e52 100644 --- a/teshsuite/simdag/network/p2p/test_latency2.c +++ b/teshsuite/simdag/network/p2p/test_latency2.c @@ -7,23 +7,15 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include -#include - #include "simgrid/simdag.h" - /* * bw and latency test 2 * send 2 x 1 byte from 2 task in same direction 0 -> 1 - * */ int main(int argc, char **argv) { - double time; - SD_task_t root; - SD_task_t task1; - SD_task_t task2; double communication_amount1[] = { 0.0, 1.0, 0.0, 0.0 }; double communication_amount2[] = { 0.0, 1.0, 0.0, 0.0 }; double no_cost1[] = { 0.0 }; @@ -32,25 +24,20 @@ int main(int argc, char **argv) SD_init(&argc, argv); SD_create_environment(argv[1]); - root = SD_task_create("Root", NULL, 1.0); - task1 = SD_task_create("Comm 1", NULL, 1.0); - task2 = SD_task_create("Comm 2", NULL, 1.0); + SD_task_t root = SD_task_create("Root", NULL, 1.0); + SD_task_t task1 = SD_task_create("Comm 1", NULL, 1.0); + SD_task_t task2 = SD_task_create("Comm 2", NULL, 1.0); - SD_task_schedule(root, 1, sg_host_list(), no_cost1, no_cost1, - -1.0); - SD_task_schedule(task1, 2, sg_host_list(), no_cost, - communication_amount1, -1.0); - SD_task_schedule(task2, 2, sg_host_list(), no_cost, - communication_amount2, -1.0); + SD_task_schedule(root, 1, sg_host_list(), no_cost1, no_cost1, -1.0); + SD_task_schedule(task1, 2, sg_host_list(), no_cost, communication_amount1, -1.0); + SD_task_schedule(task2, 2, sg_host_list(), no_cost, communication_amount2, -1.0); SD_task_dependency_add(NULL, NULL, root, task1); SD_task_dependency_add(NULL, NULL, root, task2); SD_simulate(-1.0); - time = SD_get_clock(); - - printf("%g\n", time); + printf("%g\n", SD_get_clock()); fflush(stdout); SD_task_destroy(root); diff --git a/teshsuite/simdag/network/p2p/test_latency3.c b/teshsuite/simdag/network/p2p/test_latency3.c index 22b491f006..c7ba9e45e2 100644 --- a/teshsuite/simdag/network/p2p/test_latency3.c +++ b/teshsuite/simdag/network/p2p/test_latency3.c @@ -7,8 +7,6 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include -#include - #include "simgrid/simdag.h" /** @@ -16,15 +14,10 @@ * same intention as test 2 * sending 2 x 1 bytes at the same time * this time in opposite direction - * */ int main(int argc, char **argv) { - double time; - SD_task_t root; - SD_task_t task1; - SD_task_t task2; double communication_amount1[] = { 0.0, 1.0, 0.0, 0.0 }; double communication_amount2[] = { 0.0, 0.0, 1.0, 0.0 }; double no_cost1[] = { 0.0 }; @@ -33,25 +26,20 @@ int main(int argc, char **argv) SD_init(&argc, argv); SD_create_environment(argv[1]); - root = SD_task_create("Root", NULL, 1.0); - task1 = SD_task_create("Comm 1", NULL, 1.0); - task2 = SD_task_create("Comm 2", NULL, 1.0); + SD_task_t root = SD_task_create("Root", NULL, 1.0); + SD_task_t task1 = SD_task_create("Comm 1", NULL, 1.0); + SD_task_t task2 = SD_task_create("Comm 2", NULL, 1.0); - SD_task_schedule(root, 1, sg_host_list(), no_cost1, - no_cost1, -1.0); - SD_task_schedule(task1, 2, sg_host_list(), no_cost, - communication_amount1, -1.0); - SD_task_schedule(task2, 2, sg_host_list(), no_cost, - communication_amount2, -1.0); + SD_task_schedule(root, 1, sg_host_list(), no_cost1, no_cost1, -1.0); + SD_task_schedule(task1, 2, sg_host_list(), no_cost, communication_amount1, -1.0); + SD_task_schedule(task2, 2, sg_host_list(), no_cost, communication_amount2, -1.0); SD_task_dependency_add(NULL, NULL, root, task1); SD_task_dependency_add(NULL, NULL, root, task2); SD_simulate(-1.0); - time = SD_get_clock(); - - printf("%g\n", time); + printf("%g\n", SD_get_clock()); fflush(stdout); SD_task_destroy(root); @@ -59,6 +47,5 @@ int main(int argc, char **argv) SD_task_destroy(task2); SD_exit(); - return 0; } diff --git a/teshsuite/simdag/network/p2p/test_latency_bound.c b/teshsuite/simdag/network/p2p/test_latency_bound.c index 234a3e33d1..357c4cc84b 100644 --- a/teshsuite/simdag/network/p2p/test_latency_bound.c +++ b/teshsuite/simdag/network/p2p/test_latency_bound.c @@ -7,8 +7,6 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include -#include - #include "simgrid/simdag.h" #define TASK_NUM 3 @@ -18,50 +16,37 @@ * 3 flows exceed bandwidth * should be 10001.5 * because the max tcp win size is 20000 - * - * @todo@ test assumes that max tcp win size is 20000 - * assert this */ int main(int argc, char **argv) { - int i; - double time; double communication_amount[] = { 0.0, 1.0, 0.0, 0.0 }; double no_cost[] = { 0.0, 0.0 }; - SD_task_t root; SD_task_t task[TASK_NUM]; SD_init(&argc, argv); SD_create_environment(argv[1]); - // xbt_assert( check max tcp win size, "MAX TCP WIN SIZE is 20000"); - - root = SD_task_create("Root", NULL, 1.0); - SD_task_schedule(root, 1, sg_host_list(), no_cost, no_cost, - -1.0); + SD_task_t root = SD_task_create("Root", NULL, 1.0); + SD_task_schedule(root, 1, sg_host_list(), no_cost, no_cost, -1.0); - for (i = 0; i < TASK_NUM; i++) { + for (int i = 0; i < TASK_NUM; i++) { task[i] = SD_task_create("Comm", NULL, 1.0); - SD_task_schedule(task[i], 2, sg_host_list(), no_cost, - communication_amount, -1.0); + SD_task_schedule(task[i], 2, sg_host_list(), no_cost, communication_amount, -1.0); SD_task_dependency_add(NULL, NULL, root, task[i]); } SD_simulate(-1.0); - time = SD_get_clock(); - - printf("%g\n", time); + printf("%g\n", SD_get_clock()); fflush(stdout); - for (i = 0; i < TASK_NUM; i++) { + for (int i = 0; i < TASK_NUM; i++) { SD_task_destroy(task[i]); } SD_task_destroy(root); SD_exit(); - return 0; } diff --git a/teshsuite/simdag/partask/CMakeLists.txt b/teshsuite/simdag/partask/CMakeLists.txt index 7d3dade5ca..176ea1e249 100644 --- a/teshsuite/simdag/partask/CMakeLists.txt +++ b/teshsuite/simdag/partask/CMakeLists.txt @@ -2,15 +2,8 @@ set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}") add_executable(test_comp_only_seq test_comp_only_seq.c) add_executable(test_comp_only_par test_comp_only_par.c) - -### Add definitions for compile -if(NOT WIN32) - target_link_libraries(test_comp_only_seq simgrid m pthread ) - target_link_libraries(test_comp_only_par simgrid m pthread ) -else() - target_link_libraries(test_comp_only_seq simgrid) - target_link_libraries(test_comp_only_par simgrid) -endif() +target_link_libraries(test_comp_only_seq simgrid) +target_link_libraries(test_comp_only_par simgrid) set(tesh_files ${tesh_files} diff --git a/teshsuite/simdag/partask/test_comp_only_par.c b/teshsuite/simdag/partask/test_comp_only_par.c index 6ad02ee64c..7d206316ec 100644 --- a/teshsuite/simdag/partask/test_comp_only_par.c +++ b/teshsuite/simdag/partask/test_comp_only_par.c @@ -5,36 +5,26 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include -#include - #include "simgrid/simdag.h" int main(int argc, char **argv) { - - double time; double comm_amount[] = { 0.0, 0.0, 0.0, 0.0 }; double comp_cost[] = { 1.0, 1.0 }; - SD_task_t task; - SD_init(&argc, argv); SD_create_environment(argv[1]); - task = SD_task_create("partask", NULL, 1.0); - SD_task_schedule(task, 2, sg_host_list(), comp_cost, - comm_amount, -1.0); + SD_task_t task = SD_task_create("partask", NULL, 1.0); + SD_task_schedule(task, 2, sg_host_list(), comp_cost, comm_amount, -1.0); SD_simulate(-1.0); - time = SD_get_clock(); - - printf("%g\n", time); + printf("%g\n", SD_get_clock()); fflush(stdout); SD_task_destroy(task); SD_exit(); - return 0; } diff --git a/teshsuite/simdag/partask/test_comp_only_seq.c b/teshsuite/simdag/partask/test_comp_only_seq.c index 9b17ca01f7..8bc1c667cd 100644 --- a/teshsuite/simdag/partask/test_comp_only_seq.c +++ b/teshsuite/simdag/partask/test_comp_only_seq.c @@ -12,29 +12,22 @@ int main(int argc, char **argv) { - double time; double comm_amount[] = { 0.0 }; double comp_cost[] = { 1.0 }; - SD_task_t task; - SD_init(&argc, argv); SD_create_environment(argv[1]); - task = SD_task_create("seqtask", NULL, 1.0); - SD_task_schedule(task, 1, sg_host_list(), comp_cost, - comm_amount, -1.0); + SD_task_t task = SD_task_create("seqtask", NULL, 1.0); + SD_task_schedule(task, 1, sg_host_list(), comp_cost, comm_amount, -1.0); SD_simulate(-1.0); - time = SD_get_clock(); - - printf("%g\n", time); + printf("%g\n", SD_get_clock()); fflush(stdout); SD_task_destroy(task); SD_exit(); - return 0; } diff --git a/teshsuite/simdag/platforms/CMakeLists.txt b/teshsuite/simdag/platforms/CMakeLists.txt index d2d04a275f..89f52e4f20 100644 --- a/teshsuite/simdag/platforms/CMakeLists.txt +++ b/teshsuite/simdag/platforms/CMakeLists.txt @@ -3,8 +3,11 @@ set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}") add_executable(basic_parsing_test basic_parsing_test.c) add_executable(is_router_test is_router_test.cpp) add_executable(flatifier flatifier.cpp) -add_executable(basic_tracing basic_tracing.c) add_executable(basic_link_test basic_link_test.c) +target_link_libraries(basic_parsing_test simgrid) +target_link_libraries(is_router_test simgrid) +target_link_libraries(flatifier simgrid) +target_link_libraries(basic_link_test simgrid) ### Add definitions for compile if(NOT WIN32) @@ -12,17 +15,6 @@ if(NOT WIN32) add_executable(evaluate_get_route_time Evaluate_get_route_time.c) target_link_libraries(evaluate_get_route_time simgrid m) target_link_libraries(evaluate_parse_time simgrid m) - target_link_libraries(basic_parsing_test simgrid m) - target_link_libraries(is_router_test simgrid m) - target_link_libraries(flatifier simgrid m) - target_link_libraries(basic_tracing simgrid m) - target_link_libraries(basic_link_test simgrid m) -else() - target_link_libraries(basic_parsing_test simgrid) - target_link_libraries(is_router_test simgrid) - target_link_libraries(flatifier simgrid) - target_link_libraries(basic_tracing simgrid) - target_link_libraries(basic_link_test simgrid) endif() set(tesh_files @@ -86,7 +78,6 @@ set(xml_files set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/basic_parsing_test.c - ${CMAKE_CURRENT_SOURCE_DIR}/basic_tracing.c ${CMAKE_CURRENT_SOURCE_DIR}/basic_link_test.c ${CMAKE_CURRENT_SOURCE_DIR}/Evaluate_get_route_time.c ${CMAKE_CURRENT_SOURCE_DIR}/Evaluate_parse_time.c diff --git a/teshsuite/simdag/platforms/Evaluate_get_route_time.c b/teshsuite/simdag/platforms/Evaluate_get_route_time.c index c9ef64b7fe..5737ea5cda 100644 --- a/teshsuite/simdag/platforms/Evaluate_get_route_time.c +++ b/teshsuite/simdag/platforms/Evaluate_get_route_time.c @@ -23,28 +23,28 @@ int main(int argc, char **argv) SD_init(&argc, argv); SD_create_environment(argv[1]); - sg_host_t *workstations = sg_host_list(); - int list_size = sg_host_count(); + sg_host_t *hosts = sg_host_list(); + int host_count = sg_host_count(); /* Random number initialization */ srand( (int) (xbt_os_time()*1000) ); do { - i = rand()%list_size; - j = rand()%list_size; + i = rand()%host_count; + j = rand()%host_count; } while(i==j); - sg_host_t w1 = workstations[i]; - sg_host_t w2 = workstations[j]; + sg_host_t h1 = hosts[i]; + sg_host_t h2 = hosts[j]; printf("%d\tand\t%d\t\t",i,j); xbt_os_cputimer_start(timer); - SD_route_get_list(w1, w2); + SD_route_get_list(h1, h2); xbt_os_cputimer_stop(timer); printf("%f\n", xbt_os_timer_elapsed(timer) ); - xbt_free(workstations); + xbt_free(hosts); SD_exit(); return 0; diff --git a/teshsuite/simdag/platforms/Evaluate_parse_time.c b/teshsuite/simdag/platforms/Evaluate_parse_time.c index e3c46a11a0..08fa38bed3 100644 --- a/teshsuite/simdag/platforms/Evaluate_parse_time.c +++ b/teshsuite/simdag/platforms/Evaluate_parse_time.c @@ -7,7 +7,6 @@ //teshsuite/simdag/platforms/evaluate_parse_time ../examples/platforms/nancy.xml #include -#include #include "simgrid/simdag.h" #include "surf/surf.h" #include "xbt/xbt_os_time.h" diff --git a/teshsuite/simdag/platforms/basic_link_test.c b/teshsuite/simdag/platforms/basic_link_test.c index be8439513f..f8de5b8d0b 100644 --- a/teshsuite/simdag/platforms/basic_link_test.c +++ b/teshsuite/simdag/platforms/basic_link_test.c @@ -5,12 +5,10 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include -#include #include "simgrid/simdag.h" #include "xbt/log.h" -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(basic_link_test, sd, - "SimDag test basic_link_test"); +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(basic_link_test, sd, "SimDag test basic_link_test"); static int cmp_link(const void*a, const void*b) { return strcmp(sg_link_name(*(SD_link_t*)a) , sg_link_name(*(SD_link_t*)b)); @@ -31,7 +29,8 @@ int main(int argc, char **argv) qsort((void *)links, count, sizeof(SD_link_t), cmp_link); for (int i=0; i < count; i++){ - XBT_INFO("%s: latency = %.5f, bandwidth = %f", sg_link_name(links[i]), sg_link_latency(links[i]), sg_link_bandwidth(links[i])); + XBT_INFO("%s: latency = %.5f, bandwidth = %f", sg_link_name(links[i]), + sg_link_latency(links[i]), sg_link_bandwidth(links[i])); sg_link_data_set(links[i], (void*) user_data); xbt_assert(!strcmp(user_data, (const char*)sg_link_data(links[i])),"User data was corrupted."); } diff --git a/teshsuite/simdag/platforms/basic_parsing_test.c b/teshsuite/simdag/platforms/basic_parsing_test.c index d361c39593..054964d874 100644 --- a/teshsuite/simdag/platforms/basic_parsing_test.c +++ b/teshsuite/simdag/platforms/basic_parsing_test.c @@ -5,7 +5,6 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include -#include #include "simgrid/simdag.h" int main(int argc, char **argv) @@ -16,40 +15,43 @@ int main(int argc, char **argv) SD_create_environment(argv[1]); printf("Workstation number: %zu, link number: %d\n", sg_host_count(), sg_link_count()); - sg_host_t *workstations = sg_host_list(); + sg_host_t *hosts = sg_host_list(); if (argc >= 3) { if (!strcmp(argv[2], "ONE_LINK")) { - sg_host_t w1 = workstations[0]; - sg_host_t w2 = workstations[1]; - const char *name1 = sg_host_get_name(w1); - const char *name2 = sg_host_get_name(w2); + sg_host_t h1 = hosts[0]; + sg_host_t h2 = hosts[1]; + const char *name1 = sg_host_get_name(h1); + const char *name2 = sg_host_get_name(h2); printf("Route between %s and %s\n", name1, name2); - SD_link_t *route = SD_route_get_list(w1, w2); - int route_size = SD_route_get_size(w1, w2); + SD_link_t *route = SD_route_get_list(h1, h2); + int route_size = SD_route_get_size(h1, h2); printf("Route size %d\n", route_size); for (int i = 0; i < route_size; i++) - printf(" Link %s: latency = %f, bandwidth = %f\n", sg_link_name(route[i]), sg_link_latency(route[i]), sg_link_bandwidth(route[i])); - printf("Route latency = %f, route bandwidth = %f\n", SD_route_get_latency(w1, w2), SD_route_get_bandwidth(w1, w2)); + printf(" Link %s: latency = %f, bandwidth = %f\n", sg_link_name(route[i]), + sg_link_latency(route[i]), sg_link_bandwidth(route[i])); + printf("Route latency = %f, route bandwidth = %f\n", + SD_route_get_latency(h1, h2), SD_route_get_bandwidth(h1, h2)); xbt_free(route); } if (!strcmp(argv[2], "FULL_LINK")) { int list_size = sg_host_count(); for (int i = 0; i < list_size; i++) { - sg_host_t w1 = workstations[i]; - const char *name1 = sg_host_get_name(w1); + sg_host_t h1 = hosts[i]; + const char *name1 = sg_host_get_name(h1); for (int j = 0; j < list_size; j++) { - sg_host_t w2 = workstations[j]; - const char *name2 = sg_host_get_name(w2); + sg_host_t h2 = hosts[j]; + const char *name2 = sg_host_get_name(h2); printf("Route between %s and %s\n", name1, name2); - SD_link_t *route = SD_route_get_list(w1, w2); - int route_size = SD_route_get_size(w1, w2); + SD_link_t *route = SD_route_get_list(h1, h2); + int route_size = SD_route_get_size(h1, h2); printf(" Route size %d\n", route_size); for (int k = 0; k < route_size; k++) { printf(" Link %s: latency = %f, bandwidth = %f\n", sg_link_name(route[k]), sg_link_latency(route[k]), sg_link_bandwidth(route[k])); } - printf(" Route latency = %f, route bandwidth = %f\n", SD_route_get_latency(w1, w2), SD_route_get_bandwidth(w1, w2)); + printf(" Route latency = %f, route bandwidth = %f\n", + SD_route_get_latency(h1, h2), SD_route_get_bandwidth(h1, h2)); xbt_free(route); } } @@ -57,7 +59,7 @@ int main(int argc, char **argv) if (!strcmp(argv[2], "PROP")) printf("SG_TEST_mem: %s\n", sg_host_get_property_value(sg_host_by_name("host1"), "SG_TEST_mem")); } - xbt_free(workstations); + xbt_free(hosts); SD_exit(); return 0;