Port more Vector tests to Vector128/256<T>#17737
Conversation
3844408 to
c80ce9a
Compare
8134949 to
121909f
Compare
|
test Windows_NT x64 checked jitstress1 |
CarolEidt
left a comment
There was a problem hiding this comment.
It would be nice to see more shared code, which I think could be done with one or more helper functions.
Also, since these are closely based on the SIMD tests, it would be good to mention that in a comment, for future reference.
| } | ||
| } | ||
|
|
||
| static public unsafe int Vector128Array(T deltaValue) |
There was a problem hiding this comment.
I see that this applies to the existing test that you based this on, but deltaValue doesn't seem to be used. I presume that it was intended to be the value used to initialize the delta vector, but I'm not sure.
| const int vectorSize = 16; | ||
| int elementCount = vectorSize / elementSize; | ||
|
|
||
| if (typeof(T) == typeof(byte)) |
There was a problem hiding this comment.
Expanding each type makes this much more cumbersome that it needs to be. Is there some reason you didn't make this generic, e.g. using something like the GetValueFromInt<T>() that the SIMD tests use?
|
@CarolEidt Thank you for the suggestions. Will make these changes. |
| { | ||
| return Sse2.SetZeroVector128<T>(); | ||
| } | ||
| } |
There was a problem hiding this comment.
@CarolEidt @tannergooding Without the fix of #17691, users have to write something like this as the workaround. However, it does not work because
- RyuJIT checks the type arguments in the importer, so that the above code cannot be compiled with Debug build (the false-branch of
if(typeof(T) == typeof(float))is not eliminated in the front end).
Assert failure(PID 15536 [0x00003cb0], Thread: 17436 [0x441c]): Assertion failed 'insOfHWIntrinsic(intrinsic, baseType) != INS_invalid' in 'IntelHardwareIntrinsicTest:SetZeroVector128():struct' (IL size 55)
File: d:\workspace\coreclr\src\jit\hwintrinsicxarch.cpp Line: 816
Image: D:\workspace\coreclr\bin\tests\Windows_NT.x64.Debug\Tests\Core_Root\CoreRun.exe
- the current SSE2
SetZeroVector128has noHW_Flag_OneTypeGenericflag so that cannot throw the exception for non-numeric type arguments, which is a critical inconsistent behavior.
#17691 will fix these two issues, please re-consider that PR.
There was a problem hiding this comment.
I think that these issues can be addressed without #17691, though the usability implications still make an argument.
For now, although it would be more cumbersome, you could put the "else" clause in a separate method, which would not be inlined in Debug, I don't think.
In general, we should ensure that user mis-use doesn't result in an assert in the JIT.
CarolEidt
left a comment
There was a problem hiding this comment.
I think a little more work is needed.
| { | ||
| return Sse2.SetZeroVector128<T>(); | ||
| } | ||
| } |
There was a problem hiding this comment.
I think that these issues can be addressed without #17691, though the usability implications still make an argument.
For now, although it would be more cumbersome, you could put the "else" clause in a separate method, which would not be inlined in Debug, I don't think.
In general, we should ensure that user mis-use doesn't result in an assert in the JIT.
| } | ||
| } | ||
|
|
||
| static public unsafe int Vector128Array(T deltaValue) |
There was a problem hiding this comment.
Will do. The original S.N.Vector tests also do not use this parameter.
|
@CarolEidt Addressed all the feedback. PTAL |
CarolEidt
left a comment
There was a problem hiding this comment.
LGTM - thanks for making all the changes!
|
Can we merge this PR? |
|
|
||
| public VectorArg128(float r, float g, float b) | ||
| { | ||
| float[] temp = new float[4]; |
There was a problem hiding this comment.
Do the tests need to be a 1-to-1 mapping?
It seems like, in some cases, we could make these more intrinsic oriented (such as just using SetVector128 here, instead of allocating an array)?
| { | ||
| int returnVal = Pass; | ||
|
|
||
| if (Sse41.IsSupported) |
There was a problem hiding this comment.
We should probably support this test on SSE as well. The code for extracting an element isn't too complicated (just a shuffle and convert to scalar).
tannergooding
left a comment
There was a problem hiding this comment.
Overall, LGTM. There are some coding-style issues (IMO) but those seem to be taken from the original S.N.Vector code.
|
I will resolve @tannergooding 's suggestion in the next PR. |
This PR ports the test cases of VectorArray, VectorArgs, and VectorUnused to
Vector128/256<T>.Contribute to https://github.com/dotnet/coreclr/issues/15490
@CarolEidt @tannergooding PTAL