X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e184b2de2b9a3d87527eda652b94b8eb80449a30..e89b84e7dc1848f52242c4b3134b21333a85c6d0:/src/surf/HostImpl.cpp diff --git a/src/surf/HostImpl.cpp b/src/surf/HostImpl.cpp index ae6d38acc6..eef87951b8 100644 --- a/src/surf/HostImpl.cpp +++ b/src/surf/HostImpl.cpp @@ -1,5 +1,4 @@ -/* Copyright (c) 2013-2015. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2013-2016. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -14,8 +13,7 @@ #include "network_interface.hpp" #include "virtual_machine.hpp" -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_host, surf, - "Logging specific to the SURF host module"); +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_host, surf, "Logging specific to the SURF host module"); simgrid::surf::HostModel *surf_host_model = nullptr; @@ -31,7 +29,7 @@ simgrid::xbt::Extension HostImpl::EXTENSION_ID; /********* * Model * *********/ -HostImpl *HostModel::createHost(const char *name, routing::NetCard *netElm, Cpu *cpu){ +HostImpl *HostModel::createHost(const char *name, kernel::routing::NetCard *netElm, Cpu *cpu){ xbt_dynar_t storageList = (xbt_dynar_t)xbt_lib_get_or_null(storage_lib, name, ROUTING_STORAGE_HOST_LEVEL); HostImpl *host = new simgrid::surf::HostImpl(surf_host_model, name, storageList, cpu); @@ -76,7 +74,8 @@ Action *HostModel::executeParallelTask(int host_nb, sg_host_t *host_list, double *flops_amount, double *bytes_amount, - double rate){ + double rate) +{ #define cost_or_zero(array,pos) ((array)?(array)[pos]:0.0) Action *action =nullptr; if ((host_nb == 1) @@ -99,17 +98,17 @@ Action *HostModel::executeParallelTask(int host_nb, value = cost_or_zero(bytes_amount, i); } } - if (nb == 1){ - action = surf_network_model->communicate(host_list[0]->pimpl_netcard, - host_list[1]->pimpl_netcard, - value, rate); + if (nb == 1) { + action = surf_network_model->communicate(host_list[0]->pimpl_netcard, host_list[1]->pimpl_netcard, value, rate); + } else if (nb == 0) { + xbt_die("Cannot have a communication with no flop to exchange in this model. You should consider using the ptask model"); + } else { + xbt_die("Cannot have a communication that is not a simple point-to-point in this model. You should consider using the ptask model"); } - } else - THROW_UNIMPLEMENTED; /* This model does not implement parallel tasks for more than 2 hosts */ + } else + xbt_die("This model only accepts one of the following. You should consider using the ptask model for the other cases.\n - execution with one host only and no communication\n - Self-comms with one host only\n - Communications with two hosts and no computation"); #undef cost_or_zero xbt_free(host_list); - if(action==nullptr) - xbt_die("This model doesn't support tasks with 0 comm and 0 computation, please use ptask_L07 instead"); return action; } @@ -149,10 +148,10 @@ HostImpl::~HostImpl() void HostImpl::attach(simgrid::s4u::Host* host) { - if (p_host != nullptr) + if (piface != nullptr) xbt_die("Already attached to host %s", host->name().c_str()); host->extension_set(this); - p_host = host; + piface = host; } bool HostImpl::isOn() const { @@ -164,13 +163,13 @@ bool HostImpl::isOff() const { void HostImpl::turnOn(){ if (isOff()) { p_cpu->turnOn(); - simgrid::s4u::Host::onStateChange(*this->p_host); + simgrid::s4u::Host::onStateChange(*this->piface); } } void HostImpl::turnOff(){ if (isOn()) { p_cpu->turnOff(); - simgrid::s4u::Host::onStateChange(*this->p_host); + simgrid::s4u::Host::onStateChange(*this->piface); } } @@ -181,15 +180,15 @@ simgrid::surf::Storage *HostImpl::findStorageOnMountList(const char* mount) unsigned int cursor; XBT_DEBUG("Search for storage name '%s' on '%s'", mount, getName()); - xbt_dynar_foreach(p_storage,cursor,mnt) - { + xbt_dynar_foreach(p_storage,cursor,mnt){ XBT_DEBUG("See '%s'",mnt.name); if(!strcmp(mount,mnt.name)){ st = static_cast(mnt.storage); break; } } - if(!st) xbt_die("Can't find mount '%s' for '%s'", mount, getName()); + if(!st) + xbt_die("Can't find mount '%s' for '%s'", mount, getName()); return st; } @@ -411,5 +410,4 @@ void HostImpl::setParams(vm_params_t params) p_params = *params; } -} -} +}}