-
-
Notifications
You must be signed in to change notification settings - Fork 746
Added support for simd primitives to std.traits.Signed/Unsigned #1391
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
Conversation
Hmm, don't we |
|
Even if version(SIMD), the particular type chosen for the test may not be available. |
|
So was this a yay or a nay? |
|
|
|
I disagree with this pull. This adds a special case in a function that was originally designed to only handle built-in integrals. What about support for big ints? What about support for a user defined fixed sized integral? I think this should be solved using template restrictions: That's what they were designed for. First, we make |
|
simd int vectors are builtin integrals. That's precisely why I put it here. Maybe you're right... but I'm not convinced.
|
|
Ah... truth be told, I have close to 0 knowledge about SIMD. I thought they were pulled by "core.simd". Since this is not the case, my entire line of reasoning fails (as evidenced by your points). In that case, yes, I'm fine with the implementation being in Let's continue this review then. I think a pre-requisite would be for you to introduce the I still think it would be cleaner to have: template Unsigned (T) if (isIntegral!T) { ... }
template Unsigned (T) if (isVector!T) { ... }But arguably, this would be a new development, so you don't have to do it if you don't want to. In std.conv, there are analogous functions called Other than these comments: Unittests! I have nothing to go on that your new code actually works, and no guarantee that someone else won't break it if I pull. |
|
Added unit tests. @monarchdodra If someone wants to refactor it in that way, then they're welcome to. Personally, I like this code. It's minimally obtrusive. |
One suggestion would be |
std/traits.d
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess these are tabs?
Better kill em with fire before sombody else notices ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, detab please.
|
@monarchdodra : Want to continue with reviewing this pull or add any more suggestions? |
|
Should I add isSIMDVector and/or std.conv.signed/unsigned? |
I think we already have that.
I'd like that.
The code is mostly LGTM. It is lacking unittests though. I'd also be more comfortable with an @TurkeyMan NitPick: The phobos style guide is to place a space after an |
The last time I saw the style guide I think it lacked that note which is why I avoided complaining about this in other pulls. |
Now that you mention it, I can't even find the style guide specific to phobos, just a generic style guide for D code in general. In any case, this module's current style is to do it that way, and I think the major point in phobo's style guide is to just use the existing style for existing modules. |
|
I added isSIMDVector(). There's no consistency at all wrt 'if()' or 'if ()' in std.traits. It's basically chaos! Also, @monarchdodra, there are unittests... I'm not sure what you mean. Are they insufficient somehow? They're better than many other function in there have (none). |
|
What is std.conv.signed/unsigned supposed to do in the case of overflow? Nothing? Just a dumb reinterpret cast? |
I missed them, nevermind. Sorry.
Really? I counted 21 instances of
I'm not asking you to clean up or anything, just saying we should at least try to stick to a common convention, rather than introduce more "chaos".
AFAIK, that's what they are supposed to do. We recently moved them from |
|
conv looks a lot more complex. There's a lot more work to do in that module, and things like to!string have significant knock on effects in other modules. |
|
What happened to this? I want to be able to rely on it for other work... |
|
Added support for fullyQualifiedName. That seemed to be the only hole in std.traits to not support __vector(). I pondered isSigned and friends for a bit, but the problem is, they seem to be used in various places to detect a signed integer type, which may then be used in typical integer operations. |
|
Can anyone suggest why the autotester has failed? It works for me, and I can't reproduce the error that it's reporting :/ |
|
Offending code: enum fullyQualifiedNameImplForTypes = chain!(
format("__vector(%s[%s])", fullyQualifiedNameImplForTypes!(V, qualifiers), N)
);You're declaring an enum and then trying to instantiate it. |
|
Oh crap... I see, I've managed to run my tests in a different phobos tree than I'm building, which are different versions, and the function was renamed since the last DMD release for some reason >_< |
…Unsigned, and fullyQualifiedName
Added support for simd primitives to std.traits.Signed/Unsigned
I think the SIMD primitives should receive the same treatment as regular primitives in this case.
I also fixed a bug in Unsigned!float.
Didn't add a unittest, since it's not guaranteed these types will be available on the target hardware.