Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template for double #54

Open
stellarpower opened this issue Nov 10, 2023 · 2 comments
Open

Template for double #54

stellarpower opened this issue Nov 10, 2023 · 2 comments

Comments

@stellarpower
Copy link
Contributor

I'm guessing there may be a reason linked deeply into the algorithm to use single-precision floats, instead of doubles, which are often the default in many applications and libraries today.

Would it be possible to template the algorithm's fundamental storage type in order to be able to use single- or double-precision floating-point numbers (or perhaps, even some more exotic types should there be a reason for these)?

Thanks

@fastlib
Copy link
Owner

fastlib commented Jan 6, 2025

Using single-precision floats instead of doubles has one major (and obvious) advantage: memory efficiency. Using singles reduces the number of cachemisses in the L caches, reduces memory usage and allows fftw to make better optimization plans. The only downside is the loss of precision. However, in my experience, the effect of this is negligible for the majority of real-world applications.

I would be possible to make a templated version for fCWT, but why would you want this? I think it is less work to make a wrapper in said environments. I'm not sure, but my guess is that converting your signal from doubles to singles is much faster than doing the entire calculation in doubles.

@stellarpower
Copy link
Contributor Author

Afraid as it was a year ago, so as of now I can't remember at all. I can see if I can check my code back again, although these days I'm using neural nets instead to get lower latency. Just allowing the compiler to cast is trivial so whether it was precision or some sort of ABI compatibility, I must have had a reason I was hitting to open the ticket. Although I also think templating is nice in general, then the user-programmer can choose, and it can open up the route for more optimisation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants