Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.

Conversation

@Honry
Copy link
Contributor

@Honry Honry commented Dec 19, 2019

Tests are pulled from WAVM/WAVM#242

@Honry
Copy link
Contributor Author

Honry commented Dec 19, 2019

@arunetm, @tlively, PTAL, thanks!

Copy link
Collaborator

@arunetm arunetm left a comment

Choose a reason for hiding this comment

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

Thanks. LGTM.

@arunetm
Copy link
Collaborator

arunetm commented Dec 19, 2019

Let's wait to merge until we get a second set of eyes on the python changes.
cc @tlively

if '0x' in p1:
base1 = 16
else:
base1 = 10
Copy link
Member

Choose a reason for hiding this comment

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

It looks like the parameters are allowed to be base-10, but the doc comment specifies that they must be hex. One of these should be updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I will fix it soon.

elif op in ['min_u', 'max_u']:
lane = LaneValue(lane_width)
i1 = v1 & lane.mask
i2 = v2 & lane.mask
Copy link
Member

Choose a reason for hiding this comment

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

Why use IntegerSimpleOp.get_valid_value above but & here? It might be cleaner to use the same kind of interface for signed and unsigned values, even if underneath the covers the unsigned implementation is simpler than the signed implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good proposal, I will improve it.

def binary_op(op: str, p1: str, p2: str, lane_width: int) -> str:
"""Binary operation on p1 and p2 with the operation specified by op

:param op: min_s, min_u, max_s, max_u
Copy link
Member

Choose a reason for hiding this comment

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

This seems generally useful. Are you planning to extend this to more operations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's part of my ongoing plan.


@property
def quarter(self):
return pow(2, self.lane_width - 2) No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

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

What is quarter used for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm splitting this class from https://github.com/WebAssembly/simd/blob/master/test/core/simd/meta/simd_arithmetic.py#L20, which is used for set various test data per properties defined above.

e.g. for an i8 value, its bit width is 255, its quarter is 64, for an i16 value, its quarter is 16384, thus we can have different test data for different lane width value. I just want to specific a test data between the boundary value.

)
)
"type mismatch"
)(assert_invalid
Copy link
Member

Choose a reason for hiding this comment

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

This is a little funky without an extra newline in there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ummm... I will figure it out.

@@ -0,0 +1,387 @@
;; Tests for i16x8 [min_s, min_u, max_s, max_u] operations.
Copy link
Member

Choose a reason for hiding this comment

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

Should the file name include "min" and "max" or is it going to eventually include many more operations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will include the "avgr" then, don't have an ideal file name, any proposal?

Copy link
Member

Choose a reason for hiding this comment

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

Not any good ideas. The best I can think of is simd_i16x8_val_arith.wast. Adding "val" doesn't really convey much more information, but it does suggest that the contents are more specific than the name simd_i16x8.wast suggests. My other idea is simd_i16x8_arith2.wast, which has the same benefits and drawbacks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd prefer simd_i16x8_arith2.wast. :)

"type mismatch"
)

;; Combination
Copy link
Member

Choose a reason for hiding this comment

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

How are we deciding what combinations of instructions are useful to test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question, actually I don't have a specific definition, I just choose some combinations randomly.

And we don't want to leverage full set of pairwise comparison, since it will cause exponential test cases with low efficiency to capture bugs.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good. I would err on the side of testing fewer combinations because I agree that we want to avoid having more tests than necessary and I don't think the combinations will find as many bugs.

Copy link
Contributor Author

@Honry Honry left a comment

Choose a reason for hiding this comment

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

@tlively, thanks for your comments!

def binary_op(op: str, p1: str, p2: str, lane_width: int) -> str:
"""Binary operation on p1 and p2 with the operation specified by op

:param op: min_s, min_u, max_s, max_u
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's part of my ongoing plan.

if '0x' in p1:
base1 = 16
else:
base1 = 10
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I will fix it soon.

elif op in ['min_u', 'max_u']:
lane = LaneValue(lane_width)
i1 = v1 & lane.mask
i2 = v2 & lane.mask
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good proposal, I will improve it.


@property
def quarter(self):
return pow(2, self.lane_width - 2) No newline at end of file
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm splitting this class from https://github.com/WebAssembly/simd/blob/master/test/core/simd/meta/simd_arithmetic.py#L20, which is used for set various test data per properties defined above.

e.g. for an i8 value, its bit width is 255, its quarter is 64, for an i16 value, its quarter is 16384, thus we can have different test data for different lane width value. I just want to specific a test data between the boundary value.

@@ -0,0 +1,387 @@
;; Tests for i16x8 [min_s, min_u, max_s, max_u] operations.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will include the "avgr" then, don't have an ideal file name, any proposal?

)
)
"type mismatch"
)(assert_invalid
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ummm... I will figure it out.

"type mismatch"
)

;; Combination
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question, actually I don't have a specific definition, I just choose some combinations randomly.

And we don't want to leverage full set of pairwise comparison, since it will cause exponential test cases with low efficiency to capture bugs.

@tlively
Copy link
Member

tlively commented Dec 20, 2019

Thanks, @Honry! I'll merge this now, but feel free to change the filename in a followup PR if you want.

@tlively tlively merged commit 6499b31 into WebAssembly:master Dec 20, 2019
Honry added a commit to Honry/simd that referenced this pull request Dec 23, 2019
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.

3 participants