Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Port more Vector tests to Vector128/256<T>#17737

Merged
CarolEidt merged 2 commits into
dotnet:masterfrom
fiigii:vectortests
May 1, 2018
Merged

Port more Vector tests to Vector128/256<T>#17737
CarolEidt merged 2 commits into
dotnet:masterfrom
fiigii:vectortests

Conversation

@fiigii
Copy link
Copy Markdown

@fiigii fiigii commented Apr 23, 2018

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

@fiigii fiigii force-pushed the vectortests branch 2 times, most recently from 3844408 to c80ce9a Compare April 23, 2018 20:46
@fiigii fiigii closed this Apr 23, 2018
@fiigii fiigii reopened this Apr 23, 2018
@fiigii fiigii force-pushed the vectortests branch 3 times, most recently from 8134949 to 121909f Compare April 24, 2018 09:05
@fiigii
Copy link
Copy Markdown
Author

fiigii commented Apr 24, 2018

test Windows_NT x64 checked jitstress1
test Windows_NT x64 checked jitstress2
test Windows_NT x86 checked jitstress1
test Windows_NT x86 checked jitstress2
test Ubuntu x64 checked jitstress1
test Ubuntu x64 checked jitstress2

Copy link
Copy Markdown

@CarolEidt CarolEidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@fiigii
Copy link
Copy Markdown
Author

fiigii commented Apr 24, 2018

@CarolEidt Thank you for the suggestions. Will make these changes.

{
return Sse2.SetZeroVector128<T>();
}
}
Copy link
Copy Markdown
Author

@fiigii fiigii Apr 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CarolEidt @tannergooding Without the fix of #17691, users have to write something like this as the workaround. However, it does not work because

  1. 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
  1. the current SSE2 SetZeroVector128 has no HW_Flag_OneTypeGeneric flag 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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CarolEidt ping?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... OK, will do.

Copy link
Copy Markdown

@CarolEidt CarolEidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a little more work is needed.

{
return Sse2.SetZeroVector128<T>();
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove this unused value?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do. The original S.N.Vector tests also do not use this parameter.

@fiigii
Copy link
Copy Markdown
Author

fiigii commented Apr 26, 2018

@CarolEidt Addressed all the feedback. PTAL

Copy link
Copy Markdown

@CarolEidt CarolEidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thanks for making all the changes!

@fiigii
Copy link
Copy Markdown
Author

fiigii commented May 1, 2018

Can we merge this PR?


public VectorArg128(float r, float g, float b)
{
float[] temp = new float[4];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, will change.

{
int returnVal = Pass;

if (Sse41.IsSupported)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, will do

Copy link
Copy Markdown
Member

@tannergooding tannergooding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, LGTM. There are some coding-style issues (IMO) but those seem to be taken from the original S.N.Vector code.

@CarolEidt CarolEidt merged commit 86736f9 into dotnet:master May 1, 2018
@fiigii
Copy link
Copy Markdown
Author

fiigii commented May 1, 2018

I will resolve @tannergooding 's suggestion in the next PR.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants