Skip to content

Categorize ops previously "under consideration" #121

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

Merged
merged 14 commits into from
Jun 12, 2015
Merged

Conversation

sunfishcode
Copy link
Member

This assigns more specific categorizations to several things that were "under consideration".

Summary:

  • floating point min/max promoted to AstSemantics.md for the MVP (trivially polyfillable, and arguably essential)
  • floating point trunc/nearestInt and integer clz/ctz/popcount/bswap added to EssentialPostMVPFeatures.md (not trivially polyfillable, but arguably essential)
  • various things added and moved to FutureFeatures.md

* Int32Clz - count leading zeroes (defined for all values, including 0)
* Int32Ctz - count trailing zeroes (defined for all values, including 0)
* Int32Popcnt - count number of ones
* Int32BSwap - reverse bytes (endian conversion)
Copy link
Member

Choose a reason for hiding this comment

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

Could you add the Int64 versions too, since it sounds likely that we'll have 64-bit integer arithmetic in MVP or soon thereafter? Same comment on other integer operations in FutureFeatures.md.

Or instead, we had discussed making the documentation generic for int32/int64 and float32/float64, so that we don't repeat everything twice. Should we do this instead? In another PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd prefer making the documentation (mostly) generic for int32/int64 and float32/float64. This wasn't done because WebAssembly/spec#42 (comment). @titzer, can we change your mind :-)?

@jfbastien
Copy link
Member

Sorry for initially missing this review! I only just saw it as I was going through the open PR list.

@sunfishcode sunfishcode force-pushed the categorize-ops branch 2 times, most recently from 54136a9 to bc04185 Compare June 10, 2015 16:01
@sunfishcode
Copy link
Member Author

If we can defer the Int32/Int64 refactoring, I believe this update addresses all comments so far.

For 16-bit floating-point support, it may make sense to split the feature
into two parts: support for just converting between 16-bit and 32-bit
formats possibly folded into load and store operations, and full support
for actual 16-bit arithmetic.
Copy link
Member

Choose a reason for hiding this comment

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

Conversion fp16↔fp64 too.

@jfbastien
Copy link
Member

I'll hold #135 until after this PR makes it in.

After my latest fp16↔fp64 nit this PR lgtm. Leaving open for others to comment, especially @titzer who's currently on a plane so may take a while to circle back.

@sunfishcode
Copy link
Member Author

Mentioned conversion between float16 and float64.

@sunfishcode
Copy link
Member Author

Following the same reasoning as in #135, I added an additional patch here which moves clz/ctz/popcount/bswap and trunc/nearestInt into the MVP.

@sunfishcode sunfishcode force-pushed the categorize-ops branch 2 times, most recently from 157d0cf to 46d7ca0 Compare June 12, 2015 15:51
@sunfishcode
Copy link
Member Author

Ok, for people who haven't followed the whole sequence here, this PR adds these to MVP.md:

Integer: Popcnt, Clz, and Ctz
Floating point: Trunc, NearestInt, Min, Max

Because they're very useful, quite common in popular hardware, most of them are in JS or are expected to be in the future, and as with Int64, even if JS doesn't have them today, emulating them in the polyfill is not hard and no worse than what compilers would have to do if we don't add them.

And, it moves a bunch of stuff out of "under consideration" sections into FutureFeatures.md and adds some new ideas to FutureFeatures.md as well.

@lukewagner
Copy link
Member

sgtm

As we said before, we're trying to be minimal with the MVP, but at the coarse feature level, not at the individual op level where the ops are trivial/cheap to implement. Also, that these ops are in multiple popular ISAs speaks strongly for their value; I don't think we have to re-validate this for ourselves.

@@ -213,3 +206,96 @@ use cases:
things possible. Possibly this could involve throwing or possibly by
resuming execution at the trapping instruction with the execution state
altered, if there can be a reasonable way to specify how that should work.

## Additional integer operations
Copy link
Member

Choose a reason for hiding this comment

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

Extra blank line after this.

@jfbastien
Copy link
Member

lgtm after nit.

@titzer
Copy link

titzer commented Jun 12, 2015

On Fri, Jun 12, 2015 at 8:59 AM, Dan Gohman [email protected]
wrote:

Ok, for people who haven't followed the whole sequence here, this PR adds
these to MVP.md:

Integer: Popcnt, Clz, and Ctz
Floating point: Trunc, NearestInt, Min, Max

Are we talking binary min/max or N-ary min/max?

Because they're very useful, quite common in popular hardware, most of
them are in JS or are expected to be in the future, and as with Int64, even
if JS doesn't have them today, emulating them in the polyfill is not hard
and no worse than what compilers would have to do if we don't add them.

And, it moves a bunch of stuff out of "under consideration" sections into
FutureFeatures.md and adds some new ideas to FutureFeatures.md as well.


Reply to this email directly or view it on GitHub
#121 (comment).

@sunfishcode
Copy link
Member Author

Binary min/max only, definitely. I'll add a note about that.

@titzer
Copy link

titzer commented Jun 12, 2015

On Fri, Jun 12, 2015 at 10:06 AM, Dan Gohman [email protected]
wrote:

Binary min/max only, definitely. I'll add a note about that.

sgtm


Reply to this email directly or view it on GitHub
#121 (comment).

@MikeHolman
Copy link
Member

lgtm

ctz/clz/popcount/bswap - not nicely polyfillable (ES6 will have clz, but
not all browsers will have that in the timeframe of the polyfill), but quite
essential in a modern ISA. These can be done in software and
pattern-matched, but except maybe ctz, the patterns are sufficiently gross
that I don't expect these will be controversial.

rot/min/max - nice to have, but not quite as essential, so put them in
FutureFeatures.md.
One of the main uses for these is implementing division-by-constant
optimizations, and I think we can call on JITs to do those, so we don't
need WebAssembly produers doing them and emitting larger WebAssembly
code. For other uses, real 64-bit integers will work fairly well when
we get those.
min/max - Promote these to base; they are all trivially polyfillable,
and are useful things to have in the base platform besides.

nearestInt - This is not trivially polyfillable (JavaScript's Math.round
does tie-breaking wrong), so put it in EssentialPostMVPFeatures.md so it
can join floor/ceil.

trunc - This is not trivially polyfillable (in ES6, but not in all the
browsers we need the polyfill to support), so put it in
EssentialPostMVPFeatures.md so it can join floor/ceil/nearestInt in
providing rouding to integer via all the standard roundings.

minNum/maxNum - Put these in FutureFeatures.md for future consideration.
They're not trivially polyfillable, and they're not obviously essential
at this point, though they do have uses.
Bang is unary !
Neg is unary -
And add a paragraph about 128-bit floating-point support.

Also specify that FMA would be IEEE-754 or not available.
This is inspired by the reasoning for adding Int64 to the MVP: the
polyfill isn't going to be worse than what compilers would have to lower
these things into otherwise, and having them there means a nicer path
forward to future versions.
If we don't accept !=, we'll probably want to revisit some of these.
@sunfishcode
Copy link
Member Author

Nit addressed. I'm taking the liberty of calling several approving posts above enough of a consensus to merge this. Further discussion is of course welcome.

sunfishcode added a commit that referenced this pull request Jun 12, 2015
Categorize ops previously "under consideration"
@sunfishcode sunfishcode merged commit 5cb017e into master Jun 12, 2015
@sunfishcode sunfishcode deleted the categorize-ops branch June 12, 2015 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants