-
Notifications
You must be signed in to change notification settings - Fork 42
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
Conversation
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
Deploying chicory with
|
Latest commit: |
55c7a9f
|
Status: | ✅ Deploy successful! |
Preview URL: | https://6f99da75.chicory.pages.dev |
Branch Preview URL: | https://simd-testgen-fixes.chicory.pages.dev |
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! 🙏 |
Updated to use an for anyone that want to take over the work. |
Signed-off-by: Edoardo Vacchi <[email protected]>
Signed-off-by: Edoardo Vacchi <[email protected]>
# Conflicts: # test-gen-plugin/src/main/java/com/dylibso/chicory/maven/JavaTestGen.java
Signed-off-by: Edoardo Vacchi <[email protected]>
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.
A couple of nitpicks but this is ready to go, thanks 👍
test-gen-plugin/src/main/java/com/dylibso/chicory/maven/wast/WasmValueType.java
Outdated
Show resolved
Hide resolved
test-gen-plugin/src/main/java/com/dylibso/chicory/maven/wast/WasmValue.java
Show resolved
Hide resolved
Signed-off-by: Edoardo Vacchi <[email protected]>
4f26a10
to
6921be7
Compare
Signed-off-by: Edoardo Vacchi <[email protected]>
@@ -179,9 +179,9 @@ public void execute() throws MojoExecutionException { | |||
includedExcludedWasts.add(includedWast); | |||
} | |||
} | |||
// TODO: this mechanism fails when there are no excluded wast in one profile only |
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.
Nothing critical, but FYI @electrum , personally I think it's fine to relax those checks as most of the spec have already been included and we will still review the incoming PRs.
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.
LGTM, this is ready to go, thanks @evacchi !
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