@@ -37,20 +37,21 @@ double DecimationReductionMethod::ParameterizedDecimation::get_flop_amount_to_de
3737 XBT_DEBUG (" Compute decimation cost with: cost_per_element = %.2f and interpolation_method = %s" , cost_per_element_,
3838 interpolation_method_.c_str ());
3939 double amount = cost_per_element_;
40+ auto local_size = static_cast <double >(var_->get_local_size ());
4041 if (interpolation_method_.empty ()) {
41- amount *= var_-> get_local_size () ;
42+ amount *= local_size ;
4243 } else if (interpolation_method_ == " linear" ) {
43- amount = 2 * amount * var_-> get_local_size () ;
44+ amount = 2 * amount * local_size ;
4445 } else if (interpolation_method_ == " quadratic" ) {
45- amount = 4 * amount * var_-> get_local_size () ;
46+ amount = 4 * amount * local_size ;
4647 } else if (interpolation_method_ == " cubic" ) {
47- amount = 8 * amount * var_-> get_local_size () ;
48+ amount = 8 * amount * local_size ;
4849 } // Sanity check done when parameterizing the reduction method for this variable
4950 return amount;
5051}
5152
52- void DecimationReductionMethod::parameterize_for_variable (const Variable& var,
53- const std::map<std::string, std::string>& parameters)
53+ void DecimationReductionMethod::parameterize_for_variable (
54+ const Variable& var, const std::map<std::string, std::string, std::less<> >& parameters)
5455{
5556 std::vector<size_t > new_stride;
5657 std::string new_interpolation_method;
@@ -103,7 +104,7 @@ void DecimationReductionMethod::parameterize_for_variable(const Variable& var,
103104 } else if (key == " cost_per_element" )
104105 new_cost_per_element = std::stod (value);
105106 else
106- throw UnknownDecimationOptionException (XBT_THROW_POINT, key. c_str () );
107+ throw UnknownDecimationOptionException (XBT_THROW_POINT, key);
107108 }
108109
109110 if (!exists) {
@@ -135,7 +136,8 @@ void DecimationReductionMethod::reduce_variable(const Variable& var)
135136 std::vector<size_t > reduced_shape;
136137 size_t i = 0 ;
137138 for (auto dim_size : original_shape)
138- reduced_shape.push_back (std::ceil (dim_size / (stride[i++] * 1.0 )));
139+ reduced_shape.push_back (
140+ static_cast <size_t >(std::ceil (static_cast <double >(dim_size) / static_cast <double >(stride[i++]))));
139141 parameterization->set_reduced_shape (reduced_shape);
140142
141143 auto self = sg4::Actor::self ();
@@ -145,9 +147,10 @@ void DecimationReductionMethod::reduce_variable(const Variable& var)
145147
146148 for (size_t i = 0 ; i < original_shape.size (); i++) {
147149 // Sanity checks that shape, start, and count have the same size have already been done
148- size_t r_start = std::ceil (start[i] / (stride[i] * 1.0 ));
149- size_t r_next_start =
150- std::min (original_shape[i], static_cast <size_t >(std::ceil ((start[i] + count[i]) / (stride[i] * 1.0 ))));
150+ size_t r_start = static_cast <size_t >(std::ceil (static_cast <double >(start[i]) / static_cast <double >(stride[i])));
151+ size_t r_next_start = std::min (
152+ original_shape[i],
153+ static_cast <size_t >(std::ceil (static_cast <double >(start[i] + count[i]) / static_cast <double >(stride[i]))));
151154 XBT_DEBUG (" Dim %zu: stride = %zu, Start = %zu, r_start = %zu, Count = %zu, r_count = %zu" , i, stride[i], start[i],
152155 r_start, count[i], r_next_start - r_start);
153156 reduced_start.push_back (r_start);
0 commit comments