Can boost::math::float_distance be sped up?
- Langage dominant
- C++
- Étoiles
- 374
- Forks
- 264
- Merge moyen
- 1 j 23 h
- PR mergées (30 j)
- 17
Description
In the AGM PR, I have found that ~90% of the runtime is spent computing float distances. However, at least for `float` and `double`, the following trivial modification drops the runtime to a negligible fraction of the total runtime:
```
int32_t fast_float_distance(float x, float y) {
static_assert(sizeof(float) == sizeof(int32_t), "float is incorrect size.");
int32_t xi = *reinterpret_cast(&x);
int32_t yi = *reinterpret_cast(&y);
return yi - xi;
}
int64_t fast_float_distance(double x, double y) {
static_assert(sizeof(double) == sizeof(int64_t), "double is incorrect size.");
int64_t xi = *reinterpret_cast(&x);
int64_t yi = *reinterpret_cast(&y);
return yi - xi;
}
```
It seems like `boost::math::float_distance` is considerably more general than this, but can we dive through a happy path to extract performance in the trivial cases?
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Évaluation
Cette issue n'a pas encore été évaluée.