Rounding mode switching side-effects
- 主要语言
- C++
- 星标
- 335
- 派生
- 88
- 平均合并
- 1 小时 28 分钟
- 30 天内合并 PR
- 1
描述
When running a model involving FloatVars, the FPU rouding mode may get changed, which may cause issues with code running afterwards. This happens with Gecode 6.2.0 (I haven't checked whether this changed in 6.3 yet).
I'm not certain which platforms this applies to, but it certainly happened to me on Linux x64 and, in the past, on Windows (I wasn't able to reproduce this now).
I created the following simple "guard class" to work around this problem.
```
struct SaveRoundingState {
Gecode::Float::Rounding::rounding_mode original_rt;
SaveRoundingState() {
Gecode::Float::Rounding::get_rounding_mode(original_rt);
}
~SaveRoundingState() {
Gecode::Float::Rounding::set_rounding_mode(original_rt);
}
};
```
Using this as follows resolves the issue (including printouts of the rounding mode):
```
{
Gecode::Float::Rounding::rounding_mode rm;
Gecode::Float::Rounding::get_rounding_mode(rm);
std::cout << rm << "\n";
{
SaveRoundingState save_state;
// (run the solver)
}
Gecode::Float::Rounding::get_rounding_mode(rm);
std::cout << rm << "\n";
}
```
In any case I think that Gecode should be cleaning up by itself.
贡献指南
这个仓库没有索引到贡献指南
调研方向
首先在 Linux x64 上复现 FloatVars solver case,并检查 Gecode::Float::Rounding 的 get_rounding_mode 和 set_rounding_mode 入口点。比较 solver 运行前后的舍入模式;当 solver 恢复调用方原始的舍入模式时即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- cpp
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100