-
Notifications
You must be signed in to change notification settings - Fork 231
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
Consider marking functions constexpr
#48
Comments
In my original post on SO, I intend to use SIMD in an overloaded operator function to add two mathematical vectors together. Although this makes the addition fast at runtime, since I'm using SIMD in these functions, I cannot use the operators with constexpr variables. This forces simply evaluabe vectors that are comprised of some combination of expressions using these overloaded operators to be evaluated at runtime, which is not optimal. |
I understand what People don't generally have a lot of data available at compile-time, and if you do you should probably be pre-processing it instead of relying on the compiler and |
I just realized that may have sounded a bit snarky, which isn't what I intended. I think this is an interesting idea, I'm just having trouble thinking of a reason you would want to do what you described that wouldn't be better addressed by a different solution. If there is something I'm missing I'd definitely consider implementing this, I just don't want to do something that would add a lot of complexity to SIMDe without a good reason. |
I'm going to close this, but I'm still open to the idea if anyone can convince me that it's worth the additional complication. In the meantime, maybe Iris might be more open to this? The depend pretty heavily on templates so you wouldn't need to modify nearly as many places as for SIMD. Unfortunately they don't have the code that SIMDe does for accelerating one ISA extension with another, or AFAIK even a native implementation (though I could be wrong about that part). |
Someone was asking about something like this on StackOverflow recently. I'm skeptical that it's worth the effort, but I thought I'd at least open up the issue for discussion.
The basic idea is that with C++2a (or C++11 with something supported by
HEDLEY_IS_CONSTEXPR_
, or maybe c2x if they decide to addconstexpr
to the language) it should be possible to have pretty much everything in SIMDe beconstexpr
by using the portable implementation at compile-time.Unfortunately, the implementation could get pretty messy. We would need to do something like
In every function. Also,
HAVE_NATIVE_VERSION
should also include using other ISA extensions (e.g., NEON for an x86 function)… really any time where we have a faster alternative to the portable version.Obviously this complicates the implementations somewhat, but not prohibitively so. It would take a fair amount of time to go back and add to all the existing functions, but it's pretty straightforward work (good first issue, maybe?).
My main concern is just that I'm not sure it's worth the effort; SIMD instructions tend to be used mostly when there is a lot of data that can't be computed at compile-time, so this feels like a solution in search of a problem. That said, if people really find themselves in situations where this would be useful on a somewhat regular basis, I could be convinced to (accept a patch to) add it to SIMDe.
If anyone cares about this one way or the other please comment. If people don't respond I'll assume nobody cares and it won't happen. If you don't want to comment but do want to vote, thumbs up/down for yes/no.
The text was updated successfully, but these errors were encountered: