Rounding mode switching side-effects
- Langage dominant
- C++
- Étoiles
- 335
- Forks
- 88
- Merge moyen
- 1 h 28 min
- PR mergées (30 j)
- 1
Description
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.
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
Commencez par reproduire le cas du solver FloatVars sur Linux x64 et inspecter les points d’entrée get_rounding_mode et set_rounding_mode de Gecode::Float::Rounding. Comparez le mode d’arrondi avant et après l’exécution du solver ; le travail est terminé lorsque le solver restaure le mode d’arrondi d’origine de l’appelant.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- cpp
- Domaine
- backend
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100