help: master slave output

  • 14 years ago
    int master(int argc, char *argv[])
    {
    int slaves_count = 0;
    m_host_t *slaves = NULL;
    m_task_t *todo = NULL;
    int number_of_tasks = 0;
    double task_comp_size = 0;
    double task_comm_size = 0;


    int i;

    xbt_assert1(sscanf(argv[1],"%d", &number_of_tasks),
    "Invalid argument %s\n",argv[1]);
    xbt_assert1(sscanf(argv[2],"%lg", &task_comp_size),
    "Invalid argument %s\n",argv[2]);
    xbt_assert1(sscanf(argv[3],"%lg", &task_comm_size),
    "Invalid argument %s\n",argv[3]);

    { /* Task creation */
    char sprintf_buffer[64];

    todo = calloc(number_of_tasks, sizeof(m_task_t));

    for (i = 0; i < number_of_tasks; i++) {
    sprintf(sprintf_buffer, "Task_%d", i);
    todo[i] = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL);
    }
    }

    { /* Process organisation */
    slaves_count = argc - 4;
    slaves = calloc(slaves_count, sizeof(m_host_t));

    for (i = 4; i < argc; i++) {
    slaves[i-4] = MSG_get_host_by_name(argv[i]);
    if(slaves[i-4]==NULL) {
    INFO1("Unknown host %s. Stopping Now! ", argv[i]);
    abort();
    }
    }
    }

    INFO1("Got %d slave(s) :", slaves_count);
    for (i = 0; i < slaves_count; i++)
    INFO1("\t %s", slaves[i]->name);

    INFO1("Got %d task to process :", number_of_tasks);

    for (i = 0; i < number_of_tasks; i++)
    INFO1("\t\"%s\"", todo[i]->name);

    for (i = 0; i < number_of_tasks; i++) {
    INFO2("Sending \"%s\" to \"%s\"",
    todo[i]->name,
    slaves[i % slaves_count]->name);
    if(MSG_host_self()==slaves[i % slaves_count]) {
    INFO0("Hey ! It's me ! ");
    }
    MSG_task_put(todo[i], slaves[i % slaves_count],
    PORT_22);
    INFO0("Send completed");
    }

    INFO0("All tasks have been dispatched. Let's tell everybody the computation is over.");
    for (i = 0; i < slaves_count; i++)
    MSG_task_put(MSG_task_create("finalize", 0, 0, FINALIZE),
    slaves[i], PORT_22);

    INFO0("Goodbye now!");
    free(slaves);
    free(todo);
    return 0;
    } /* end_of_master */

    int slave(int argc, char *argv[])
    {
    while(1) {
    m_task_t task = NULL;
    int a;
    a = MSG_task_get(&(task), PORT_22);
    if (a == MSG_OK) {
    INFO1("Received \"%s\" ", MSG_task_get_name(task));
    if(MSG_task_get_data(task)==FINALIZE) {
    MSG_task_destroy(task);
    break;
    }
    INFO1("Processing \"%s\" ", MSG_task_get_name(task));
    MSG_task_execute(task);
    INFO1("\"%s\" done ", MSG_task_get_name(task));
    MSG_task_destroy(task);
    } else {
    INFO0("Hey ?! What's up ? ");
    xbt_assert0(0,"Unexpected behavior");
    }
    }
    INFO0("I'm done. See you!");
    return 0;
    } /* end_of_slave */]

    how do i change this code so that it will produce output that list down all the task handled by particular slave
    something like this

    master = (master name)

    slave
    (name of slave1)
    (list of tasks handled by slave1)

    (name of slave2)
    (list of tasks handled by slave2)

    ...

    i've been trying all day but still dont get the output
    i need help


















































































































Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Debugging is anticipated with distaste, performed with reluctance, and bragged about forever.” - Dan Kaminsky