-/** Emitter function */
-int test(int argc, char *argv[])
-{
- int slaves_count = 0;
- m_host_t *slaves = NULL;
- double task_comp_size = 0;
- double task_comm_size = 0;
- double *computation_amount = NULL;
- double *communication_amount = NULL;
- m_task_t ptask = NULL;
- int i,j;
-
- slaves_count = MSG_get_host_number();
- slaves = MSG_get_host_table();
-
- computation_amount = calloc(slaves_count,sizeof(double));
- communication_amount = calloc(slaves_count*slaves_count,sizeof(double));
-
- for(i=0;i<slaves_count;i++)
- computation_amount[i]=task_comp_size;
-
- for(i=0;i<slaves_count;i++)
- for(j=i+1;j<slaves_count;j++)
- communication_amount[i*slaves_count+j]=task_comm_size;
-
- ptask = MSG_parallel_task_create("parallel task",
- slaves_count, slaves,
- computation_amount,
- communication_amount,
- NULL);
+ XBT_INFO("First, build a classical parallel task, with 1 Gflop to execute on each node, and 10MB to exchange between each pair");
+ double *computation_amounts = xbt_new0(double, slaves_count);
+ double *communication_amounts = xbt_new0(double, slaves_count * slaves_count);
+
+ for (i = 0; i < slaves_count; i++)
+ computation_amounts[i] = 1e9; // 1 Gflop
+
+ for (i = 0; i < slaves_count; i++)
+ for (j = i + 1; j < slaves_count; j++)
+ communication_amounts[i * slaves_count + j] = 1e7; // 10 MB
+
+ msg_task_t ptask = MSG_parallel_task_create("parallel task",
+ slaves_count, slaves, computation_amounts, communication_amounts, NULL /* no specific data to attach */);
+ MSG_parallel_task_execute(ptask);
+ MSG_task_destroy(ptask);
+ /* The arrays communication_amounts and computation_amounts are not to be freed manually */
+
+ XBT_INFO("Then, build a parallel task involving only computations and no communication (1 Gflop per node)");
+ computation_amounts = xbt_new0(double, slaves_count);
+ for (i = 0; i < slaves_count; i++)
+ computation_amounts[i] = 1e9; // 1 Gflop
+ ptask = MSG_parallel_task_create("parallel exec", slaves_count, slaves, computation_amounts, NULL/* no comm */, NULL /* no data */);