+ gras_msg_handle(60); // command message
+ gras_msg_wait(60, "go", NULL, NULL);
+ {
+ worker_data_t g = gras_userdata_get();
+ unsigned int cursor;
+ xbt_workload_elm_t cmd;
+ const char *myname = gras_os_myname();
+ xbt_dynar_t cmd_to_go =
+ xbt_dynar_new(sizeof(xbt_workload_elm_t), NULL);
+
+ xbt_dynar_foreach(g->commands, cursor, cmd) {
+ if (!strcmp(cmd->who, myname)) {
+ char *c = xbt_workload_elm_to_string(cmd);
+ // XBT_INFO("TODO: %s",c);
+ free(c);
+
+ switch (cmd->action) {
+ case XBT_WORKLOAD_COMPUTE:
+ /* If any communication were queued, do them in parallel */
+ if (xbt_dynar_length(cmd_to_go)) {
+ TRY {
+ xbt_dynar_dopar(cmd_to_go, do_command);
+ xbt_dynar_reset(cmd_to_go);
+ }
+ CATCH(e) {
+ SIMIX_display_process_status();
+ }
+ XBT_INFO("Communications all done");
+ xbt_dynar_reset(cmd_to_go);
+ }
+ XBT_INFO("Compute %.f flops", cmd->d_arg);
+ gras_cpu_burn(cmd->d_arg);
+ XBT_INFO("Done computing %.f flops", cmd->d_arg);
+ break;
+ case XBT_WORKLOAD_SEND:
+ /* Create the socket from main thread since it seems to fails when done from dopar thread */
+ get_peer_sock(cmd->str_arg);
+ case XBT_WORKLOAD_RECV:
+ /* queue communications for later realization in parallel */
+ xbt_dynar_push(cmd_to_go, &cmd);
+ break;
+ }
+ }
+ }
+ /* do in parallel any communication still queued */
+ XBT_INFO("Do %ld pending communications after end of TODO list",
+ xbt_dynar_length(cmd_to_go));
+ if (xbt_dynar_length(cmd_to_go)) {
+ xbt_dynar_dopar(cmd_to_go, do_command);
+ xbt_dynar_reset(cmd_to_go);
+ }
+ }
+
+ gras_msg_send(master, "go", NULL);
+// amok_pm_group_leave(master, "replay");