Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Kill unused parameters.
[simgrid.git] / src / surf / disk_s19.cpp
1 /* Copyright (c) 2013-2021. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "disk_s19.hpp"
7 #include "simgrid/kernel/routing/NetPoint.hpp"
8 #include "simgrid/kernel/routing/NetZoneImpl.hpp"
9 #include "simgrid/s4u/Engine.hpp"
10 #include "simgrid/s4u/Host.hpp"
11 #include "src/kernel/EngineImpl.hpp"
12 #include "src/kernel/lmm/maxmin.hpp"
13 #include "src/surf/xml/platf.hpp"
14 #include "surf/surf.hpp"
15
16 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_disk);
17
18 /*********
19  * Model *
20  *********/
21
22 void surf_disk_model_init_default()
23 {
24   auto disk_model = std::make_shared<simgrid::kernel::resource::DiskS19Model>("Disk");
25   simgrid::kernel::EngineImpl::get_instance()->add_model(disk_model);
26   simgrid::s4u::Engine::get_instance()->get_netzone_root()->get_impl()->set_disk_model(disk_model);
27 }
28
29 namespace simgrid {
30 namespace kernel {
31 namespace resource {
32
33 DiskImpl* DiskS19Model::create_disk(const std::string& name, double read_bandwidth, double write_bandwidth)
34 {
35   return (new DiskS19(name, read_bandwidth, write_bandwidth))->set_model(this);
36 }
37
38 void DiskS19Model::update_actions_state(double /*now*/, double delta)
39 {
40   for (auto it = std::begin(*get_started_action_set()); it != std::end(*get_started_action_set());) {
41     auto& action = *it;
42     ++it; // increment iterator here since the following calls to action.finish() may invalidate it
43     action.update_remains(rint(action.get_variable()->get_value() * delta));
44     action.update_max_duration(delta);
45
46     if (((action.get_remains_no_update() <= 0) && (action.get_variable()->get_penalty() > 0)) ||
47         ((action.get_max_duration() != NO_MAX_DURATION) && (action.get_max_duration() <= 0))) {
48       action.finish(Action::State::FINISHED);
49     }
50   }
51 }
52
53 DiskAction* DiskS19Model::io_start(const DiskImpl* disk, sg_size_t size, s4u::Io::OpType type)
54 {
55   auto* action = new DiskS19Action(this, static_cast<double>(size), not disk->is_on());
56   get_maxmin_system()->expand(disk->get_constraint(), action->get_variable(), 1.0);
57   switch (type) {
58     case s4u::Io::OpType::READ:
59       get_maxmin_system()->expand(disk->get_read_constraint(), action->get_variable(), 1.0);
60       break;
61     case s4u::Io::OpType::WRITE:
62       get_maxmin_system()->expand(disk->get_write_constraint(), action->get_variable(), 1.0);
63       break;
64     default:
65       THROW_UNIMPLEMENTED;
66   }
67   return action;
68 }
69
70 /************
71  * Resource *
72  ************/
73 /**********
74  * Action *
75  **********/
76
77 DiskS19Action::DiskS19Action(Model* model, double cost, bool failed)
78     : DiskAction(model, cost, failed, model->get_maxmin_system()->variable_new(this, 1.0, -1.0, 3))
79 {
80 }
81
82 void DiskS19Action::update_remains_lazy(double /*now*/)
83 {
84   THROW_IMPOSSIBLE;
85 }
86 } // namespace resource
87 } // namespace kernel
88 } // namespace simgrid