-
Notifications
You must be signed in to change notification settings - Fork 39
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
simd: apply some fixes to test generation #686
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Edoardo Vacchi <[email protected]>
sb.append("Integer.parseUnsignedInt(\"" + v + "\")"); | ||
break; |
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 think we don't need to parse these into Float bits in this case, the raw integer will do
|
||
var invocationMethod = ".apply(" + args + ")"; | ||
var invocationMethod = ".apply(" + String.join(",", args) + ")"; |
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.
notice, this is not correct, but works for now. It should be adapted to do same thing as the lines below, but it required a little more refactoring, and I wanted to push this out quickly to unblock @mfirry
Signed-off-by: Edoardo Vacchi <[email protected]>
Deploying chicory with Cloudflare Pages
|
here's an example of a test ( @Test()
@Order(9)
@DisplayName("simd_bitwise.wast:31")
public void test9() {
ExportFunction varAnd = testModule0Instance.export("and");
var args = new MStack();
args.pushAll(i32ToVec( new long[] { Long.parseUnsignedLong("0"), Long.parseUnsignedLong("0"), Long.parseUnsignedLong("4294967295"), Long.parseUnsignedLong("4294967295") }));
args.pushAll(i32ToVec( new long[] { Long.parseUnsignedLong("0"), Long.parseUnsignedLong("4294967295"), Long.parseUnsignedLong("0"), Long.parseUnsignedLong("4294967295") }));
var results = varAnd.apply(args.slice(0, 4));
var expected = new long[] {Long.parseUnsignedLong("0"), Long.parseUnsignedLong("0"), Long.parseUnsignedLong("0"), Long.parseUnsignedLong("4294967295") };
assertArrayEquals(expected, vecTo32(results));
} vs before: @Test()
@Order(9)
@DisplayName("simd_bitwise.wast:31")
public void test9() {
ExportFunction varAnd = testModule0Instance.export("and");
var results = varAnd.apply(new long[] { 0, 0, 4294967295, 4294967295 }, new long[] { 0, 4294967295, 0, 4294967295 });
var expected = new long[] {Long.parseUnsignedLong("0"), Long.parseUnsignedLong("0"), Long.parseUnsignedLong("0"), Long.parseUnsignedLong("4294967295") };
assertArrayEquals(expected, vecTo32(results));
} notice:
notice that it's not strictly necessary to modify MStack, we can also implement and ad-hoc stack or utility class (e.g. "TestArgs") only for tests |
FYI, I'll be AFK for the rest of the week, so feel free to rebase/change/rewrite this PR 👋 |
Thanks @evacchi for the effort!
var results = varAnd.apply(i32ToVec(new long[] { 0, 0, 4294967295, 4294967295 }, new long[] { 0, 4294967295, 0, 4294967295 }));
if anyone wants to step up and bring this to conclusion, just drop a message! 🙏 |
This fixes some aspects of the SIMD test codegen, introducing some (debatable) wider changes, so I'm going to push this as a draft, to let you judge :) some of these changes could be also applied to a utility class, but this should be the gist anyway
MStack
so that we can push V128s onto it: the reason is that codegen might become complicated otherwise: each v128 is along[]
so, you would have to "unpack" each long to several pushes. This way you can just push it all at once.Mstack.pushAll(long[])
method, so that we can easily push vectors all at once.MStack.slice(start, len)
method returning a copy of the array (thus, only useful for tests), so thata. all places expecting a given arg size (e.g. I have seen this behavior in the new tail call feature) do not get confused by a larger input array
b. we can pass in a number of values we want to pull; this is important when there are v128 values, since they are size=2
WasmValueType.size()
that is 2 for v128 and 1 otherwiseI have also added a few more missing (?) lanes (i64x2, F64x2) and the reverse of
vecTo32()
, etc...I will add some other notes inline.
@mfirry this should unblock you!
folks, feel free to push directly to this branch to apply your fixes on top