/* Basic SimDag Test 0 * Scenario: * - 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. * 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. */ int main(int argc, char **argv) { /* scheduling parameters */ double communication_amount1[] = { 0, 1e8, 0, 0 }; double communication_amount2[] = { 0, 1, 0, 0 }; const double no_cost[] = { 0.0, 0.0 }; /* initialization of SD */ SD_init(&argc, argv); /* creation of the environment */ SD_create_environment(argv[1]); /* creation of the tasks and their dependencies */ 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); sg_host_t *hosts = sg_host_list(); SD_task_schedule(taskInit, 1, hosts, no_cost, no_cost, -1.0); SD_task_schedule(taskA, 2, hosts, no_cost, communication_amount1, -1.0); SD_task_schedule(taskB, 2, hosts, no_cost, communication_amount2, -1.0); xbt_free(hosts); /* let's launch the simulation! */ SD_simulate(-1.0); SD_task_destroy(taskInit); SD_task_destroy(taskA); SD_task_destroy(taskB); XBT_INFO("Simulation time: %f", SD_get_clock()); SD_exit(); return 0; }
/* Basic SimDag Test 4 * Scenario: * - Create a chain of tasks (Init, A, Fin) * - Have a 1B communication between two no-op tasks. * Verify that the tasks are actually simulated in the right order. * The simulated time should be equal to the network latency: 0.0001 seconds. */ int main(int argc, char **argv) { /* scheduling parameters */ double no_cost[] = { 0., 0., 0., 0. }; double amount[] = { 0., 1., 0., 0. }; /* SD initialization */ SD_init(&argc, argv); /* creation of the environment */ SD_create_environment(argv[1]); /* creation of the tasks and their dependencies */ 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); sg_host_t *hosts = sg_host_list(); SD_task_schedule(taskInit, 1, hosts, no_cost, no_cost, -1.0); SD_task_schedule(taskA, 2, hosts, no_cost, amount, -1.0); SD_task_schedule(taskFin, 1, hosts, no_cost, no_cost, -1.0); xbt_free(hosts); /* let's launch the simulation! */ SD_simulate(-1.0); SD_task_destroy(taskInit); SD_task_destroy(taskA); SD_task_destroy(taskFin); XBT_INFO("Simulation time: %f", SD_get_clock()); SD_exit(); return 0; }
/* * simple latency test * send one byte from 0 to 1 * * this is a test for multiple platforms * see tesh file for expected output */ int main(int argc, char **argv) { double communication_amount[] = { 0.0, 1.0, 0.0, 0.0 }; const double no_cost[] = { 0.0, 0.0 }; SD_init(&argc, argv); SD_create_environment(argv[1]); SD_task_t task = SD_task_create("Comm 1", NULL, 1.0); sg_host_t *hosts = sg_host_list(); SD_task_schedule(task, 2, hosts, no_cost, communication_amount, -1.0); xbt_free(hosts); SD_simulate(-1.0); printf("%g\n", SD_get_clock()); fflush(stdout); SD_task_destroy(task); SD_exit(); return 0; }
int main(int argc, char **argv) { 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 }; double no_cost[] = { 0.0, 0.0 }; SD_init(&argc, argv); SD_create_environment(argv[1]); 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); sg_host_t *hosts = sg_host_list(); SD_task_schedule(root, 1, hosts, no_cost1, no_cost1, -1.0); SD_task_schedule(task1, 2, hosts, no_cost, communication_amount1, -1.0); SD_task_schedule(task2, 2, hosts, no_cost, communication_amount2, -1.0); xbt_free(hosts); SD_task_dependency_add(NULL, NULL, root, task1); SD_task_dependency_add(NULL, NULL, root, task2); SD_simulate(-1.0); printf("%g\n", SD_get_clock()); fflush(stdout); SD_task_destroy(root); SD_task_destroy(task1); SD_task_destroy(task2); SD_exit(); return 0; }
int main(int argc, char **argv) { xbt_dynar_t dot; unsigned int cursor; SD_task_t task; /* initialization of SD */ SD_init(&argc, argv); /* Check our arguments */ xbt_assert(argc > 2, "Usage: %s platform_file dot_file [trace_file]" "example: %s ../2clusters.xml dag.dot dag.mytrace", argv[0], argv[0]); /* creation of the environment */ SD_create_environment(argv[1]); /* load the DOT file and schedule tasks */ dot = SD_dotload_with_sched(argv[2]); if(!dot){ XBT_CRITICAL("The dot file with the provided scheduling is wrong, more information with the option : --log=sd_dotparse.thres:verbose"); SD_exit(); exit(2); } char *tracefilename; char *last = strrchr(argv[2], '.'); tracefilename = bprintf("%.*s.trace", (int) (last == NULL ? strlen(argv[2]) : last - argv[2]),argv[2]); if (argc == 4) tracefilename = xbt_strdup(argv[3]); /* Display all the tasks */ XBT_INFO("------------------- Display all tasks of the loaded DAG ---------------------------"); xbt_dynar_foreach(dot, cursor, task) { SD_task_dump(task); }
int main(int argc, char **argv) { int i; const char *platform_file; const SD_workstation_t *workstations; int kind; SD_task_t task, taskA, taskB, taskC; xbt_dynar_t changed_tasks; SD_workstation_t workstation_list[2]; double computation_amount[2]; double communication_amount[4] = { 0 }; double rate = -1.0; SD_workstation_t w1, w2; /* SD initialization */ SD_init(&argc, argv); /* xbt_log_control_set("sd.thres=debug"); */ if (argc < 2) { XBT_INFO("Usage: %s platform_file", argv[0]); XBT_INFO("example: %s sd_platform.xml", argv[0]); exit(1); } /* creation of the environment */ platform_file = argv[1]; SD_create_environment(platform_file); /* Change the access mode of the workstations */ workstations = SD_workstation_get_list(); w1 = workstations[0]; w2 = workstations[1]; for (i = 0; i < 2; i++) { SD_workstation_set_access_mode(workstations[i], SD_WORKSTATION_SEQUENTIAL_ACCESS); XBT_INFO("Access mode of %s is %s", SD_workstation_get_name(workstations[i]), (SD_workstation_get_access_mode(workstations[i]) == SD_WORKSTATION_SEQUENTIAL_ACCESS) ? "sequential" : "shared"); } /* creation of the tasks and their dependencies */ taskA = SD_task_create_comp_seq("Task A", NULL, 2e9); taskB = SD_task_create_comm_e2e("Task B", NULL, 2e9); taskC = SD_task_create_comp_seq("Task C", NULL, 1e9); TRACE_category ("taskA"); TRACE_category ("taskB"); TRACE_category ("taskC"); TRACE_sd_set_task_category (taskA, "taskA"); TRACE_sd_set_task_category (taskB, "taskB"); TRACE_sd_set_task_category (taskC, "taskC"); /* if everything is ok, no exception is forwarded or rethrown by main() */ /* watch points */ SD_task_watch(taskA, SD_RUNNING); SD_task_watch(taskB, SD_RUNNING); SD_task_watch(taskC, SD_RUNNING); SD_task_watch(taskC, SD_DONE); /* scheduling parameters */ workstation_list[0] = w1; workstation_list[1] = w2; computation_amount[0] = SD_task_get_amount(taskA); computation_amount[1] = SD_task_get_amount(taskB); communication_amount[1] = SD_task_get_amount(taskC); communication_amount[2] = 0.0; SD_task_schedule(taskA, 1, &w1, &(computation_amount[0]), SD_SCHED_NO_COST, rate); SD_task_schedule(taskB, 2, workstation_list, SD_SCHED_NO_COST, communication_amount, rate); SD_task_schedule(taskC, 1, &w1, &(computation_amount[1]), SD_SCHED_NO_COST, rate); /* let's launch the simulation! */ while (!xbt_dynar_is_empty(changed_tasks = SD_simulate(-1.0))) { for (i = 0; i < 2; i++) { task = SD_workstation_get_current_task(workstations[i]); if (task) kind = SD_task_get_kind(task); else { XBT_INFO("There is no task running on %s", SD_workstation_get_name(workstations[i])); continue; } switch (kind) { case SD_TASK_COMP_SEQ: XBT_INFO("%s is currently running on %s (SD_TASK_COMP_SEQ)", SD_task_get_name(task), SD_workstation_get_name(workstations[i])); break; case SD_TASK_COMM_E2E: XBT_INFO("%s is currently running on %s (SD_TASK_COMM_E2E)", SD_task_get_name(task), SD_workstation_get_name(workstations[i])); break; case SD_TASK_NOT_TYPED: XBT_INFO("Task running on %s has no type", SD_workstation_get_name(workstations[i])); break; default: XBT_ERROR("Shouldn't be here"); } } xbt_dynar_free_container(&changed_tasks); } xbt_dynar_free_container(&changed_tasks); XBT_DEBUG("Destroying tasks..."); SD_task_destroy(taskA); SD_task_destroy(taskB); SD_task_destroy(taskC); XBT_DEBUG("Tasks destroyed. Exiting SimDag..."); SD_exit(); return 0; }
int main(int argc, char **argv) { /* initialisation of SD */ SD_workstation_t w1, w2; const SD_workstation_t *workstations; const SD_link_t *route; const char *name1; const char *name2; int route_size, i, j, k; int list_size; #ifdef _XBT_WIN32 setbuf(stderr, NULL); setbuf(stdout, NULL); #else setvbuf(stdout, NULL, _IOLBF, 0); #endif SD_init(&argc, argv); /* creation of the environment */ SD_create_environment(argv[1]); printf("Workstation number: %d, link number: %d\n", SD_workstation_get_number(), SD_link_get_number()); if (argc >= 3) { if (!strcmp(argv[2], "ONE_LINK")) { workstations = SD_workstation_get_list(); w1 = workstations[0]; w2 = workstations[1]; name1 = SD_workstation_get_name(w1); name2 = SD_workstation_get_name(w2); printf("Route between %s and %s\n", name1, name2); route = SD_route_get_list(w1, w2); route_size = SD_route_get_size(w1, w2); printf("Route size %d\n", route_size); for (i = 0; i < route_size; i++) { printf(" Link %s: latency = %f, bandwidth = %f\n", SD_link_get_name(route[i]), SD_link_get_current_latency(route[i]), SD_link_get_current_bandwidth(route[i])); } printf("Route latency = %f, route bandwidth = %f\n", SD_route_get_current_latency(w1, w2), SD_route_get_current_bandwidth(w1, w2)); } if (!strcmp(argv[2], "FULL_LINK")) { workstations = SD_workstation_get_list(); list_size = SD_workstation_get_number(); for (i = 0; i < list_size; i++) { w1 = workstations[i]; name1 = SD_workstation_get_name(w1); for (j = 0; j < list_size; j++) { w2 = workstations[j]; name2 = SD_workstation_get_name(w2); printf("Route between %s and %s\n", name1, name2); route = SD_route_get_list(w1, w2); route_size = SD_route_get_size(w1, w2); printf(" Route size %d\n", route_size); for (k = 0; k < route_size; k++) { printf(" Link %s: latency = %f, bandwidth = %f\n", SD_link_get_name(route[k]), SD_link_get_current_latency(route[k]), SD_link_get_current_bandwidth(route[k])); } printf(" Route latency = %f, route bandwidth = %f\n", SD_route_get_current_latency(w1, w2), SD_route_get_current_bandwidth(w1, w2)); } } } if (!strcmp(argv[2], "PROP")) { printf("SG_TEST_mem: %s\n", SD_workstation_get_property_value(SD_workstation_get_by_name("host1"), "SG_TEST_mem") ); printf("Author: %s\n", SD_as_router_get_property_value("AS0", "author")); printf("AS1: %s\n", SD_as_router_get_property_value("AS1", "name")); printf("AS2: %s\n", SD_as_router_get_property_value("AS2", "name")); } } SD_exit(); return 0; }
int main(int argc, char **argv) { int i; const char *platform_file; const SD_workstation_t *workstations; SD_task_t taskA, taskB, taskC, taskD; xbt_dynar_t changed_tasks; /* initialization of SD */ SD_init(&argc, argv); /* xbt_log_control_set("sd.thres=debug"); */ if (argc < 2) { XBT_INFO("Usage: %s platform_file", argv[0]); XBT_INFO("example: %s sd_platform.xml", argv[0]); exit(1); } /* creation of the environment */ platform_file = argv[1]; SD_create_environment(platform_file); /* Change the access mode of the workstations */ workstations = SD_workstation_get_list(); for (i = 0; i < 2; i++) { SD_workstation_dump(workstations[i]); SD_workstation_set_access_mode(workstations[i], SD_WORKSTATION_SEQUENTIAL_ACCESS); XBT_INFO(" Change access mode of %s to %s", SD_workstation_get_name(workstations[i]), (SD_workstation_get_access_mode(workstations[i]) == SD_WORKSTATION_SEQUENTIAL_ACCESS) ? "sequential" : "shared"); } /* Well I changed my mind, I want the second workstation to be shared */ SD_workstation_set_access_mode(workstations[1], SD_WORKSTATION_SHARED_ACCESS); XBT_INFO(" Change access mode of %s to %s", SD_workstation_get_name(workstations[1]), (SD_workstation_get_access_mode(workstations[1]) == SD_WORKSTATION_SEQUENTIAL_ACCESS) ? "sequential" : "shared"); /* creation of the tasks and their dependencies */ taskA = SD_task_create_comp_seq("Task A", NULL, 2e10); taskB = SD_task_create_comm_e2e("Task B", NULL, 2e8); taskC = SD_task_create_comp_seq("Task C", NULL, 1e10); taskD = SD_task_create_comp_seq("Task D", NULL, 1e11); SD_task_dependency_add("B->C", NULL,taskB, taskC); /* watch points */ SD_task_watch(taskA, SD_RUNNING); SD_task_watch(taskB, SD_RUNNING); SD_task_watch(taskC, SD_RUNNING); SD_task_watch(taskC, SD_DONE); SD_task_watch(taskD, SD_DONE); /* scheduling parameters */ SD_task_schedulel(taskA, 1, workstations[0]); SD_task_schedulel(taskB, 2, workstations[0], workstations[1]); SD_task_schedulel(taskC, 1, workstations[1]); SD_task_schedulel(taskD, 1, workstations[1]); /* let's launch the simulation! */ while (!xbt_dynar_is_empty(changed_tasks = SD_simulate(-1.0))) { XBT_INFO(" Simulation was suspended, check workstation states"); for (i = 0; i < 2; i++) { SD_workstation_dump(workstations[i]); } xbt_dynar_free(&changed_tasks); } xbt_dynar_free(&changed_tasks); 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; }
int main(int argc, char **argv) { sg_host_t host_list[2]; double computation_amount[2]; double communication_amount[4] = { 0 }; /* initialization of SD */ SD_init(&argc, argv); 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 */ const sg_host_t *hosts = sg_host_list(); 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); double comp_amount1 = 2000000; double comp_amount2 = 1000000; double comm_amount12 = 2000000; double 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); SD_link_t *route = SD_route_get_list(h1, h2); int route_size = SD_route_get_size(h1, h2); for (int 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_free(route); 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 */ SD_task_t taskA = SD_task_create("Task A", NULL, 10.0); SD_task_t taskB = SD_task_create("Task B", NULL, 40.0); SD_task_t taskC = SD_task_create("Task C", NULL, 30.0); SD_task_t taskD = SD_task_create("Task D", NULL, 60.0); /* try to attach and retrieve user data to a task */ SD_task_set_data(taskA, static_cast<void*>(&comp_amount1)); if (fabs(comp_amount1 - (*(static_cast<double*>(SD_task_get_data(taskA))))) > 1e-12) XBT_ERROR("User data was corrupted by a simple set/get"); SD_task_dependency_add(NULL, NULL, taskB, taskA); SD_task_dependency_add(NULL, NULL, taskC, taskA); SD_task_dependency_add(NULL, NULL, taskD, taskB); 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!"); } catch (xbt_ex& ex) { if (ex.category != arg_error) throw; /* this is a serious error */ } try { SD_task_dependency_add(NULL, NULL, taskB, taskA); /* shouldn't work and must raise an exception */ xbt_die("Oh oh, I can add an already existing dependency!"); } catch (xbt_ex& ex) { if (ex.category != arg_error) throw; } try { SD_task_dependency_remove(taskA, taskC); /* shouldn't work and must raise an exception */ xbt_die("Dude, I can remove an unknown dependency!"); } catch (xbt_ex& ex) { if (ex.category != arg_error) throw; } try { SD_task_dependency_remove(taskC, taskC); /* shouldn't work and must raise an exception */ xbt_die("Wow, I can remove a dependency between Task C and itself!"); } catch (xbt_ex& ex) { if (ex.category != arg_error) throw; } /* if everything is ok, no exception is forwarded or rethrown by main() */ /* watch points */ SD_task_watch(taskD, SD_DONE); SD_task_watch(taskB, SD_DONE); SD_task_unwatch(taskD, SD_DONE); /* scheduling parameters */ host_list[0] = h1; host_list[1] = h2; computation_amount[0] = comp_amount1; computation_amount[1] = comp_amount2; communication_amount[1] = comm_amount12; communication_amount[2] = comm_amount21; /* estimated time */ SD_task_t task = taskD; XBT_INFO("Estimated time for '%s': %f", SD_task_get_name(task), SD_task_get_execution_time(task, 2, host_list, computation_amount, communication_amount)); SD_task_schedule(taskA, 2, host_list, computation_amount, communication_amount, -1); SD_task_schedule(taskB, 2, host_list, computation_amount, communication_amount, -1); SD_task_schedule(taskC, 2, host_list, computation_amount, communication_amount, -1); SD_task_schedule(taskD, 2, host_list, computation_amount, communication_amount, -1); std::set<SD_task_t> *changed_tasks = simgrid::sd::simulate(-1.0); for (auto task: *changed_tasks){ 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_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; }
int main(int argc, char **argv) { int i, j; xbt_dynar_t changed_tasks; int n_hosts; const SD_workstation_t *hosts; SD_task_t taskInit; SD_task_t PtoPComm1; SD_task_t PtoPComm2; SD_task_t ParComp_wocomm; SD_task_t IntraRedist; SD_task_t ParComp_wcomm1; SD_task_t InterRedist; SD_task_t taskFinal; SD_task_t ParComp_wcomm2; SD_workstation_t PtoPcomm1_hosts[2]; SD_workstation_t PtoPcomm2_hosts[2]; double PtoPcomm1_table[] = { 0, 12500000, 0, 0 }; /* 100Mb */ double PtoPcomm2_table[] = { 0, 1250000, 0, 0 }; /* 10Mb */ double ParComp_wocomm_cost[] = { 1e+9, 1e+9, 1e+9, 1e+9, 1e+9 }; /* 1 Gflop per Proc */ double *ParComp_wocomm_table; SD_workstation_t ParComp_wocomm_hosts[5]; double *IntraRedist_cost; double *IntraRedist_table; SD_workstation_t IntraRedist_hosts[5]; double ParComp_wcomm1_cost[] = { 1e+9, 1e+9, 1e+9, 1e+9, 1e+9 }; /* 1 Gflop per Proc */ double *ParComp_wcomm1_table; SD_workstation_t ParComp_wcomm1_hosts[5]; double *InterRedist_cost; double *InterRedist_table; double ParComp_wcomm2_cost[] = { 1e+8, 1e+8, 1e+8, 1e+8, 1e+8 }; /* 1 Gflop per Proc (0.02sec duration) */ SD_workstation_t ParComp_wcomm2_hosts[5]; double final_cost = 5e+9; double *ParComp_wcomm2_table; /* initialisation of SD */ SD_init(&argc, argv); /* creation of the environment */ if (strstr(argv[1],".xml")) SD_create_environment(argv[1]); else xbt_die("Unsupported platform description style (not XML): %s", argv[1]); /* getting platform infos */ n_hosts = SD_workstation_get_number(); hosts = SD_workstation_get_list(); /* sorting hosts by hostname */ qsort((void *) hosts, n_hosts, sizeof(SD_workstation_t), nameCompareHosts); /* creation of the tasks */ taskInit = SD_task_create("Initial", NULL, 1.0); PtoPComm1 = SD_task_create("PtoP Comm 1", NULL, 1.0); PtoPComm2 = SD_task_create("PtoP Comm 2", NULL, 1.0); ParComp_wocomm = SD_task_create("Par Comp without comm", NULL, 1.0); IntraRedist = SD_task_create("intra redist", NULL, 1.0); ParComp_wcomm1 = SD_task_create("Par Comp with comm 1", NULL, 1.0); InterRedist = SD_task_create("inter redist", NULL, 1.0); 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); SD_task_dependency_add(NULL, NULL, PtoPComm1, ParComp_wocomm); SD_task_dependency_add(NULL, NULL, ParComp_wocomm, IntraRedist); SD_task_dependency_add(NULL, NULL, IntraRedist, ParComp_wcomm1); SD_task_dependency_add(NULL, NULL, ParComp_wcomm1, InterRedist); SD_task_dependency_add(NULL, NULL, InterRedist, ParComp_wcomm2); 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]; /* small point-to-point communication (0.01 sec duration) */ PtoPcomm2_hosts[0] = hosts[0]; PtoPcomm2_hosts[1] = hosts[2]; /* parallel task without intra communications (1 sec duration) */ ParComp_wocomm_table = xbt_new0(double, 25); for (i = 0; i < 5; i++) { ParComp_wocomm_hosts[i] = hosts[i]; } /* redistribution within a cluster (small latencies) */ /* each host send (4*2.5Mb =) 10Mb */ /* bandwidth is shared between 5 flows (0.05sec duration) */ IntraRedist_cost = xbt_new0(double, 5); IntraRedist_table = xbt_new0(double, 25); for (i = 0; i < 5; i++) { for (j = 0; j < 5; j++) { if (i == j) IntraRedist_table[i * 5 + j] = 0.; else IntraRedist_table[i * 5 + j] = 312500.; /* 2.5Mb */ } } for (i = 0; i < 5; i++) { IntraRedist_hosts[i] = hosts[i]; } /* parallel task with intra communications */ /* Computation domination (1 sec duration) */ ParComp_wcomm1_table = xbt_new0(double, 25); for (i = 0; i < 5; i++) { ParComp_wcomm1_hosts[i] = hosts[i]; } for (i = 0; i < 5; i++) { for (j = 0; j < 5; j++) { if (i == j) ParComp_wcomm1_table[i * 5 + j] = 0.; else ParComp_wcomm1_table[i * 5 + j] = 312500.; /* 2.5Mb */ } } /* inter cluster redistribution (big latency on the backbone) */ /* (0.5sec duration without latency impact) */ InterRedist_cost = xbt_new0(double, 10); InterRedist_table = xbt_new0(double, 100); for (i = 0; i < 5; i++) { InterRedist_table[i * 10 + i + 5] = 1250000.; /* 10Mb */ } /* parallel task with intra communications */ /* Communication domination (0.1 sec duration) */ ParComp_wcomm2_table = xbt_new0(double, 25); for (i = 0; i < 5; i++) { ParComp_wcomm2_hosts[i] = hosts[i + 5]; } for (i = 0; i < 5; i++) { for (j = 0; j < 5; j++) { if (i == j) ParComp_wcomm2_table[i * 5 + j] = 0.; else ParComp_wcomm2_table[i * 5 + j] = 625000.; /* 5Mb */ } } /* 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); /* let's launch the simulation! */ changed_tasks = SD_simulate(-1.0); XBT_INFO("Simulation time: %f", SD_get_clock()); xbt_dynar_free_container(&changed_tasks); free(ParComp_wocomm_table); free(IntraRedist_cost); free(IntraRedist_table); free(ParComp_wcomm1_table); free(InterRedist_cost); free(InterRedist_table); free(ParComp_wcomm2_table); SD_task_destroy(taskInit); SD_task_destroy(PtoPComm1); SD_task_destroy(PtoPComm2); SD_task_destroy(ParComp_wocomm); SD_task_destroy(IntraRedist); SD_task_destroy(ParComp_wcomm1); SD_task_destroy(InterRedist); SD_task_destroy(ParComp_wcomm2); SD_task_destroy(taskFinal); SD_exit(); return 0; }
int main(int argc, char **argv) { double computation_amount[1]; double communication_amount[2] = { 0 }; sg_host_t hosts[1]; /* initialization of SD */ SD_init(&argc, argv); /* creation of the environment */ SD_create_environment(argv[1]); /* creation of a single task that will poorly fail when the workstation will stop */ XBT_INFO("First test: COMP_SEQ task"); SD_task_t task = SD_task_create_comp_seq("Poor task", NULL, 2e10); SD_task_watch(task, SD_FAILED); SD_task_watch(task, SD_DONE); XBT_INFO("Schedule task '%s' on 'Faulty Host'", SD_task_get_name(task)); SD_task_schedulel(task, 1, sg_host_by_name("Faulty Host")); xbt_dynar_t tasks = SD_simulate(-1.0); xbt_dynar_free(&tasks); SD_task_dump(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)); SD_task_unschedule(task); SD_task_schedulel(task, 1, sg_host_by_name("Safe Host")); XBT_INFO("Run the simulation again"); tasks = SD_simulate(-1.0); xbt_dynar_free(&tasks); 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)); SD_task_destroy(task); task=NULL; XBT_INFO("Second test: NON TYPED task"); task = SD_task_create("Poor parallel task", NULL, 2e10); SD_task_watch(task, SD_FAILED); SD_task_watch(task, SD_DONE); computation_amount[0] = 2e10; XBT_INFO("Schedule task '%s' on 'Faulty Host'", SD_task_get_name(task)); hosts[0] = sg_host_by_name("Faulty Host"); SD_task_schedule(task, 1, hosts, computation_amount, communication_amount,-1); tasks = SD_simulate(-1.0); xbt_dynar_free(&tasks); SD_task_dump(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)); SD_task_unschedule(task); hosts[0] = sg_host_by_name("Safe Host"); SD_task_schedule(task, 1, hosts, computation_amount, communication_amount,-1); XBT_INFO("Run the simulation again"); tasks = SD_simulate(-1.0); xbt_dynar_free(&tasks); 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)); SD_task_destroy(task); SD_exit(); return 0; }