Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
rename fields for consistency
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 29 Aug 2016 08:53:41 +0000 (10:53 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 29 Aug 2016 08:53:41 +0000 (10:53 +0200)
src/surf/HostImpl.cpp
src/surf/HostImpl.hpp
src/surf/plugins/energy.cpp
src/surf/virtual_machine.cpp
src/surf/virtual_machine.hpp
src/surf/vm_hl13.cpp

index d4ae879..cb08a98 100644 (file)
@@ -33,7 +33,7 @@ HostImpl *HostModel::createHost(const char *name, kernel::routing::NetCard *netE
   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);
-  XBT_DEBUG("Create host %s with %ld mounted disks", name, xbt_dynar_length(host->p_storage));
+  XBT_DEBUG("Create host %s with %ld mounted disks", name, xbt_dynar_length(host->storage_));
   return host;
 }
 
@@ -46,7 +46,7 @@ void HostModel::adjustWeightOfDummyCpuActions()
   /* iterate for all virtual machines */
   for (VirtualMachine *ws_vm : VirtualMachine::allVms_) {
 
-    Cpu *cpu = ws_vm->p_cpu;
+    Cpu *cpu = ws_vm->cpu_;
 
     int is_active = lmm_constraint_used(cpu->getModel()->getMaxminSystem(), cpu->getConstraint());
 
@@ -115,20 +115,20 @@ Action *HostModel::executeParallelTask(int host_nb,
 HostImpl::HostImpl(simgrid::surf::HostModel *model, const char *name, xbt_dynar_t storage, Cpu *cpu)
  : Resource(model, name)
  , PropertyHolder(nullptr)
- , p_storage(storage), p_cpu(cpu)
+ , storage_(storage), cpu_(cpu)
 {
   if (!EXTENSION_ID.valid())
     EXTENSION_ID = simgrid::s4u::Host::extension_create<simgrid::surf::HostImpl>();
-  p_params.ramsize = 0;
+  params_.ramsize = 0;
 }
 
 HostImpl::HostImpl(simgrid::surf::HostModel *model, const char *name, lmm_constraint_t constraint,
                  xbt_dynar_t storage, Cpu *cpu)
  : Resource(model, name, constraint)
  , PropertyHolder(nullptr)
- , p_storage(storage), p_cpu(cpu)
+ , storage_(storage), cpu_(cpu)
 {
-  p_params.ramsize = 0;
+  params_.ramsize = 0;
 }
 
 /** @brief use destroy() instead of this destructor */
@@ -138,28 +138,28 @@ HostImpl::~HostImpl()
 
 void HostImpl::attach(simgrid::s4u::Host* host)
 {
-  if (piface != nullptr)
+  if (piface_ != nullptr)
     xbt_die("Already attached to host %s", host->name().c_str());
   host->extension_set(this);
-  piface = host;
+  piface_ = host;
 }
 
 bool HostImpl::isOn() const {
-  return p_cpu->isOn();
+  return cpu_->isOn();
 }
 bool HostImpl::isOff() const {
-  return p_cpu->isOff();
+  return cpu_->isOff();
 }
 void HostImpl::turnOn(){
   if (isOff()) {
-    p_cpu->turnOn();
-    simgrid::s4u::Host::onStateChange(*this->piface);
+    cpu_->turnOn();
+    simgrid::s4u::Host::onStateChange(*this->piface_);
   }
 }
 void HostImpl::turnOff(){
   if (isOn()) {
-    p_cpu->turnOff();
-    simgrid::s4u::Host::onStateChange(*this->piface);
+    cpu_->turnOff();
+    simgrid::s4u::Host::onStateChange(*this->piface_);
   }
 }
 
@@ -170,7 +170,7 @@ 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(storage_,cursor,mnt){
     XBT_DEBUG("See '%s'",mnt.name);
     if(!strcmp(mount,mnt.name)){
       st = static_cast<simgrid::surf::Storage*>(mnt.storage);
@@ -189,7 +189,7 @@ xbt_dict_t HostImpl::getMountedStorageList()
   xbt_dict_t storage_list = xbt_dict_new_homogeneous(nullptr);
   char *storage_name = nullptr;
 
-  xbt_dynar_foreach(p_storage,i,mnt){
+  xbt_dynar_foreach(storage_,i,mnt){
     storage_name = (char *)static_cast<simgrid::surf::Storage*>(mnt.storage)->getName();
     xbt_dict_set(storage_list,mnt.name,storage_name,nullptr);
   }
@@ -224,7 +224,7 @@ Action *HostImpl::open(const char* fullpath) {
   char *mount_name = nullptr;
 
   XBT_DEBUG("Search for storage name for '%s' on '%s'", fullpath, getName());
-  xbt_dynar_foreach(p_storage,cursor,mnt)
+  xbt_dynar_foreach(storage_,cursor,mnt)
   {
     XBT_DEBUG("See '%s'",mnt.name);
     file_mount_name = (char *) xbt_malloc ((strlen(mnt.name)+1));
@@ -386,13 +386,13 @@ xbt_dynar_t HostImpl::getVms()
 
 void HostImpl::getParams(vm_params_t params)
 {
-  *params = p_params;
+  *params = params_;
 }
 
 void HostImpl::setParams(vm_params_t params)
 {
   /* may check something here. */
-  p_params = *params;
+  params_ = *params;
 }
 
 }}
index b02cb26..9307cd3 100644 (file)
@@ -226,9 +226,9 @@ public:
     {THROW_IMPOSSIBLE;} // FIXME: Host should not be a Resource
 
 public:
-  xbt_dynar_t p_storage;
-  Cpu *p_cpu;
-  simgrid::s4u::Host* piface = nullptr;
+  xbt_dynar_t storage_;
+  Cpu *cpu_;
+  simgrid::s4u::Host* piface_ = nullptr;
 
   /** @brief Get the list of virtual machines on the current Host */
   xbt_dynar_t getVms();
@@ -239,9 +239,9 @@ public:
   void getParams(vm_params_t params);
   /** @brief Sets the params of that VM/PM */
   void setParams(vm_params_t params);
-  simgrid::s4u::Host* getHost() { return piface; }
+  simgrid::s4u::Host* getHost() { return piface_; }
 private:
-  s_vm_params_t p_params;
+  s_vm_params_t params_;
 };
 
 }
index 5212967..0ec679a 100644 (file)
@@ -70,12 +70,12 @@ void HostEnergy::update()
   double start_time = this->last_updated;
   double finish_time = surf_get_clock();
   double cpu_load;
-  if (surf_host->p_cpu->speed_.peak <= 0)
+  if (surf_host->cpu_->speed_.peak <= 0)
     // Some users declare a pstate of speed 0 flops (e.g., to model boot time).
     // We consider that the machine is then fully loaded. That's arbitrary but it avoids a NaN
     cpu_load = 1;
   else
-    cpu_load = lmm_constraint_get_usage(surf_host->p_cpu->getConstraint()) / surf_host->p_cpu->speed_.peak;
+    cpu_load = lmm_constraint_get_usage(surf_host->cpu_->getConstraint()) / surf_host->cpu_->speed_.peak;
 
   if (cpu_load > 1) // A machine with a load > 1 consumes as much as a fully loaded machine, not mores
     cpu_load = 1;
@@ -94,7 +94,7 @@ void HostEnergy::update()
   this->last_updated = finish_time;
 
   XBT_DEBUG("[update_energy of %s] period=[%.2f-%.2f]; current power peak=%.0E flop/s; consumption change: %.2f J -> %.2f J",
-      surf_host->getName(), start_time, finish_time, surf_host->p_cpu->speed_.peak, previous_energy, energy_this_step);
+      surf_host->getName(), start_time, finish_time, surf_host->cpu_->speed_.peak, previous_energy, energy_this_step);
 }
 
 HostEnergy::HostEnergy(simgrid::s4u::Host *ptr) : host(ptr), last_updated(surf_get_clock())
@@ -210,7 +210,7 @@ static void onActionStateChange(simgrid::surf::CpuAction *action, simgrid::surf:
     if (vm) // If it's a VM, take the corresponding PM
       host = vm->getPm()->extension<simgrid::surf::HostImpl>();
 
-    HostEnergy *host_energy = host->piface->extension<HostEnergy>();
+    HostEnergy *host_energy = host->piface_->extension<HostEnergy>();
 
     if(host_energy->last_updated < surf_get_clock())
       host_energy->update();
index 1666df5..fd7317b 100644 (file)
@@ -39,8 +39,8 @@ VirtualMachine::VirtualMachine(HostModel *model, const char *name, simgrid::s4u:
 , hostPM_(hostPM)
 {
   allVms_.push_back(this);
-  piface = simgrid::s4u::Host::by_name_or_create(name);
-  piface->extension_set<simgrid::surf::HostImpl>(this);
+  piface_ = simgrid::s4u::Host::by_name_or_create(name);
+  piface_->extension_set<simgrid::surf::HostImpl>(this);
 }
 
 /*
@@ -57,11 +57,11 @@ VirtualMachine::~VirtualMachine()
 }
 
 e_surf_vm_state_t VirtualMachine::getState() {
-  return p_vm_state;
+  return vmState_;
 }
 
 void VirtualMachine::setState(e_surf_vm_state_t state) {
-  p_vm_state = state;
+  vmState_ = state;
 }
 void VirtualMachine::turnOn() {
   if (isOff()) {
index d75e480..9cfdde0 100644 (file)
@@ -93,7 +93,7 @@ public:
   static std::deque<VirtualMachine*> allVms_;
 
 protected:
-  e_surf_vm_state_t p_vm_state = SURF_VM_STATE_CREATED;
+  e_surf_vm_state_t vmState_ = SURF_VM_STATE_CREATED;
 };
 
 /*********
index 9dd72aa..4b7c927 100644 (file)
@@ -32,7 +32,7 @@ s4u::Host *VMHL13Model::createVM(const char *name, sg_host_t host_PM)
 {
   VirtualMachine* vm = new VMHL13(this, name, host_PM);
   onVmCreation(vm);
-  return vm->piface;
+  return vm->piface_;
 }
 
 /* In the real world, processes on the guest operating system will be somewhat degraded due to virtualization overhead.
@@ -68,7 +68,7 @@ double VMHL13Model::next_occuring_event(double now)
 
   /* iterate for all virtual machines */
   for (VirtualMachine *ws_vm : VirtualMachine::allVms_) {
-    Cpu *cpu = ws_vm->p_cpu;
+    Cpu *cpu = ws_vm->cpu_;
     xbt_assert(cpu, "cpu-less host");
 
     double solved_value = ws_vm->action_->getVariable()->value;
@@ -95,7 +95,7 @@ VMHL13::VMHL13(VMModel *model, const char* name, sg_host_t host_PM)
  : VirtualMachine(model, name, host_PM)
 {
   /* Currently, we assume a VM has no storage. */
-  p_storage = nullptr;
+  storage_ = nullptr;
 
   /* Currently, a VM uses the network resource of its physical host. In
    * host_lib, this network resource object is referred from two different keys.
@@ -106,55 +106,55 @@ VMHL13::VMHL13(VMModel *model, const char* name, sg_host_t host_PM)
   sg_host_t host_VM = simgrid::s4u::Host::by_name_or_create(name);
   host_VM->pimpl_netcard = host_PM->pimpl_netcard;
 
-  p_vm_state = SURF_VM_STATE_CREATED;
+  vmState_ = SURF_VM_STATE_CREATED;
 
   // //// CPU  RELATED STUFF ////
   // Roughly, create a vcpu resource by using the values of the sub_cpu one.
-  CpuCas01 *sub_cpu = static_cast<CpuCas01*>(host_PM->pimpl_cpu);
+  CpuCas01 *sub_cpu = dynamic_cast<CpuCas01*>(host_PM->pimpl_cpu);
 
-  p_cpu = surf_cpu_model_vm->createCpu(host_VM, // the machine hosting the VM
+  cpu_ = surf_cpu_model_vm->createCpu(host_VM, // the machine hosting the VM
       sub_cpu->getSpeedPeakList(), 1 /*cores*/);
   if (sub_cpu->getPState() != 0)
-    p_cpu->setPState(sub_cpu->getPState());
+    cpu_->setPState(sub_cpu->getPState());
 
   /* We create cpu_action corresponding to a VM process on the host operating system. */
   /* FIXME: TODO: we have to periodically input GUESTOS_NOISE to the system? how ? */
   action_ = sub_cpu->execution_start(0);
 
-  XBT_VERB("Create VM(%s)@PM(%s) with %ld mounted disks", name, hostPM_->name().c_str(), xbt_dynar_length(p_storage));
+  XBT_VERB("Create VM(%s)@PM(%s) with %ld mounted disks", name, hostPM_->name().c_str(), xbt_dynar_length(storage_));
 }
 VMHL13::~VMHL13() {
-  delete p_cpu;
+  delete cpu_;
 }
 
 void VMHL13::suspend()
 {
   action_->suspend();
-  p_vm_state = SURF_VM_STATE_SUSPENDED;
+  vmState_ = SURF_VM_STATE_SUSPENDED;
 }
 
 void VMHL13::resume()
 {
   action_->resume();
-  p_vm_state = SURF_VM_STATE_RUNNING;
+  vmState_ = SURF_VM_STATE_RUNNING;
 }
 
 void VMHL13::save()
 {
-  p_vm_state = SURF_VM_STATE_SAVING;
+  vmState_ = SURF_VM_STATE_SAVING;
 
   /* FIXME: do something here */
   action_->suspend();
-  p_vm_state = SURF_VM_STATE_SAVED;
+  vmState_ = SURF_VM_STATE_SAVED;
 }
 
 void VMHL13::restore()
 {
-  p_vm_state = SURF_VM_STATE_RESTORING;
+  vmState_ = SURF_VM_STATE_RESTORING;
 
   /* FIXME: do something here */
   action_->resume();
-  p_vm_state = SURF_VM_STATE_RUNNING;
+  vmState_ = SURF_VM_STATE_RUNNING;
 }
 
 /* Update the physical host of the given VM */