void test(char *platform) { void *hostA = NULL; void *hostB = NULL; double now = -1.0; int running; xbt_cfg_set_parse(_sg_cfg_set, "network/model:CM02"); xbt_cfg_set_parse(_sg_cfg_set, "cpu/model:Cas01"); parse_platform_file(platform); /*********************** HOST ***********************************/ hostA = surf_host_resource_by_name("Cpu A"); hostB = surf_host_resource_by_name("Cpu B"); /* Let's check that those two processors exist */ XBT_DEBUG("%s : %p", surf_resource_name(hostA), hostA); XBT_DEBUG("%s : %p", surf_resource_name(hostB), hostB); /* Let's do something on it */ surf_host_execute(hostA, 1000.0); surf_host_execute(hostB, 1000.0); surf_host_sleep(hostB, 7.32); surf_host_model_communicate(surf_host_model, hostA, hostB, 150.0, -1.0); surf_solve(-1.0); /* Takes traces into account. Returns 0.0 */ do { surf_action_t action = NULL; unsigned int iter; surf_model_t model = NULL; running = 0; now = surf_get_clock(); XBT_DEBUG("Next Event : %g", now); xbt_dynar_foreach(model_list, iter, model) { XBT_DEBUG("\t %s actions", surf_model_name(model)); while ((action = surf_model_extract_failed_action_set((surf_model_t)model))) { XBT_DEBUG("\t * Failed : %p", action); surf_action_unref(action); } while ((action = surf_model_extract_done_action_set((surf_model_t)model))) { XBT_DEBUG("\t * Done : %p", action); surf_action_unref(action); } if (surf_model_running_action_set_size((surf_model_t)model)) { XBT_DEBUG("running %s", surf_model_name(model)); running = 1; } } } while (running && surf_solve(-1.0) >= 0.0); XBT_DEBUG("Simulation Terminated"); }
Action *HostCLM03Model::executeParallelTask(int host_nb, sg_host_t *host_list, double *flops_amount, double *bytes_amount, double rate){ #define cost_or_zero(array,pos) ((array)?(array)[pos]:0.0) Action *action =NULL; if ((host_nb == 1) && (cost_or_zero(bytes_amount, 0) == 0.0)){ action = surf_host_execute(host_list[0],flops_amount[0]); } else if ((host_nb == 1) && (cost_or_zero(flops_amount, 0) == 0.0)) { action = surf_network_model->communicate(sg_host_edge(host_list[0]), sg_host_edge(host_list[0]), bytes_amount[0], rate); } else if ((host_nb == 2) && (cost_or_zero(flops_amount, 0) == 0.0) && (cost_or_zero(flops_amount, 1) == 0.0)) { int i,nb = 0; double value = 0.0; for (i = 0; i < host_nb * host_nb; i++) { if (cost_or_zero(bytes_amount, i) > 0.0) { nb++; value = cost_or_zero(bytes_amount, i); } } if (nb == 1){ action = surf_network_model->communicate(sg_host_edge(host_list[0]), sg_host_edge(host_list[1]), value, rate); } } else THROW_UNIMPLEMENTED; /* This model does not implement parallel tasks for more than 2 hosts */ #undef cost_or_zero xbt_free(host_list); return action; }