@@ -150,6 +150,8 @@ namespace simgrid::fsmod {
150150 // Determine what to write on each individual disk according to RAID level and which disk will store the
151151 // parity block
152152 sg_size_t write_size;
153+ double parity_block_comp_cost = 0.0 ;
154+
153155 switch (raid_level_) {
154156 case RAID::RAID0:
155157 write_size = size / num_disks_;
@@ -159,31 +161,27 @@ namespace simgrid::fsmod {
159161 break ;
160162 case RAID::RAID4:
161163 write_size = size / (num_disks_ - 1 );
164+ // Assume 1 flop per byte to write per parity block.
165+ parity_block_comp_cost = static_cast <double >(write_size);
162166 break ;
163167 case RAID::RAID5:
164168 update_parity_disk_idx ();
165169 write_size = size / (num_disks_ - 1 );
170+ // Assume 1 flop per byte to write per parity block.
171+ parity_block_comp_cost = static_cast <double >(write_size);
166172 break ;
167173 case RAID::RAID6:
168174 update_parity_disk_idx ();
169175 write_size = size / (num_disks_ - 2 );
176+ // Assume 2 flops per byte to write per parity block.
177+ parity_block_comp_cost = static_cast <double >(2 * write_size);
170178 break ;
171179 default :
172180 throw std::invalid_argument (" Unsupported RAID level. Supported level are: 0, 1, 4, 5, and 6" );
173181 }
174182
175183 // Compute the parity block (if any)
176- s4u::ExecPtr parity_block_comp;
177-
178- if (raid_level_ == RAID::RAID4 || raid_level_ == RAID::RAID5 || raid_level_ == RAID::RAID6) {
179- // Assume 1 flop per byte to write per parity block and two for RAID6.
180- // Do not assign the Exec yet, will be done after the completion of the CommPtr
181- if (raid_level_ == RAID::RAID6)
182- parity_block_comp = s4u::Exec::init ()->set_flops_amount (static_cast <double >(2 * write_size));
183- else
184- parity_block_comp = s4u::Exec::init ()->set_flops_amount (static_cast <double >(write_size));
185- } else // Create a no-op activity
186- parity_block_comp = s4u::Exec::init ()->set_flops_amount (0 );
184+ s4u::ExecPtr parity_block_comp = s4u::Exec::init ()->set_flops_amount (parity_block_comp_cost);
187185 parity_block_comp->set_name (" Parity Block Computation" );
188186
189187 // Do not start computing the parity block before the completion of the comm to the controller
@@ -200,7 +198,7 @@ namespace simgrid::fsmod {
200198
201199 // Create a no-op Activity that depends on the completion of all I/Os. This is the one ActivityPtr returned
202200 // to the caller
203- s4u::IoPtr completion_activity = s4u::Io::init ()->set_op_type (s4u::Io::OpType::WRITE)->set_size (0 );
201+ auto completion_activity = s4u::Io::init ()->set_op_type (s4u::Io::OpType::WRITE)->set_size (0 );
204202 completion_activity->set_name (" JBOD Write Completion" );
205203
206204 // Create the I/O activities on individual disks
0 commit comments