1 /* GOAL loader prototype. Not ready for public usage yet */
3 /* Copyright (c) 2011. The SimGrid Team.
4 * All rights reserved. */
6 /* This program is free software; you can redistribute it and/or modify it
7 * under the terms of the license (GNU LGPL) which comes with this package. */
11 #include "simdag/simdag.h"
15 #include "xbt/xbt_os_time.h"
17 XBT_LOG_NEW_DEFAULT_CATEGORY(goal, "The GOAL loader into SimDag");
21 } s_bcast_task_t,*bcast_task_t;
24 const SD_workstation_t* ws_list;
27 xbt_dynar_t reclaimed;
29 static void send_one(int from, int to) {
30 //XBT_DEBUG("send_one(%d, %d)",from,to);
32 if (count %100000 == 0)
33 XBT_INFO("Sending task #%d",count);
37 if (!xbt_dynar_is_empty(reclaimed)) {
38 bt = xbt_dynar_pop_as(reclaimed,bcast_task_t);
40 bt = xbt_new(s_bcast_task_t,1);
46 SD_task_t task = SD_task_create_comm_e2e(NULL,bt,424242);
48 XBT_DEBUG("Schedule task between %d and %d",bt->i,bt->j);
49 SD_task_schedulel(task,2,ws_list[bt->i],ws_list[bt->j]);
50 SD_task_watch(task,SD_DONE);
54 int main(int argc, char **argv) {
55 xbt_os_timer_t timer = xbt_os_timer_new();
57 /* initialization of SD */
61 SD_create_environment(argv[1]);
63 SD_create_environment("../../platforms/One_cluster_no_backbone.xml");
66 ws_list = SD_workstation_get_list();
67 reclaimed = xbt_dynar_new(sizeof(bcast_task_t),xbt_free_ref);
68 xbt_dynar_t done = NULL;
70 xbt_os_timer_start(timer);
71 send_one(0,SD_workstation_get_number());
73 if (done != NULL && !xbt_dynar_is_empty(done)) {
77 xbt_dynar_foreach(done, cursor, task) {
78 bcast_task_t bt = SD_task_get_data(task);
80 if (bt->i != bt->j -1)
81 send_one(bt->i,bt->j);
82 if (bt->j != bt->k -1)
83 send_one(bt->j,bt->k);
85 if (xbt_dynar_length(reclaimed)<100) {
86 xbt_dynar_push_as(reclaimed,bcast_task_t,bt);
90 SD_task_destroy(task);
92 xbt_dynar_free(&done);
95 } while(!xbt_dynar_is_empty(done));
96 xbt_os_timer_stop(timer);
97 printf("parse_time:%lf\n", xbt_os_timer_elapsed(timer) );
99 xbt_dynar_free(&done);
100 xbt_dynar_free(&reclaimed);
103 XBT_INFO("Done. Bailing out");