site-www
site-www copied to clipboard
Reintroduce and update Dart SIMD guide
What information is missing?
There is not really any information at all regarding Dart supporting SIMD, in fact you would need to be fairly determined in searching dart.dev to even discover that such support exists.
Yet there used to be what I would consider a pretty good documentation page for it: https://web.archive.org/web/20190402213240/https://www.dartlang.org/articles/server/simd
and reading through it, I am unclear as to why it was considered obsolete and hence removed from the website? Apart from its use of the new keyword, is any of the code or the prose text actually inaccurate for the current versions of Dart lang?
How would you like us to fix this problem?
Please re-instate the previously removed page documenting SIMD usage in Dart.
I would also be happy to contribute a PR updating the previous documentation page if someone could give some guidance on what specifically was lacking in it that caused it to be classified as "obsolete".
Thanks for sharing your interest in this page @maks. It would be nice to further SIMD documentation, perhaps by starting with this and making some updates. I'll ping @kwalrath and @mit-mit to see their thoughts on reviving an updated version of this page as it was originally removed in https://github.com/dart-lang/site-www/pull/1572
@mit-mit what would you like us to do about SIMD? It seems like we could update the article, put it under https://dart.dev/guides/libraries, and add mentions of SIMD to https://dart.dev/guides/language/numbers & maybe the language/library tour (at least).
What do you think? Who knows the most about SIMD now?
@maks I think the code examples would need to pass analysis using the current set of recommended lints. We'd ensure this by adding all code in the article to /examples, as documented in https://github.com/dart-lang/site-shared/blob/master/doc/code-excerpts.md & https://github.com/dart-lang/site-shared/blob/master/doc/examples.md.
@kwalrath thanks for looking into this so quickly! I'll have a read of those docs to see how it's done - or should I wait for @mit-mit to say on if the SIMD docs can come back before I start working on it? My 2c about why I raised this is that I think the fact that Dart supports SIMD is really a hidden gem of Dart that very few devs I spoken with in the community know about and would be a great selling point for Dart usage for some applications.
I suspect we'd be very happy to accept any help you can offer... but I can't guarantee that without talking to @mit-mit. Or maybe to @kevmoo.
So if you feel like looking at the text or playing with the code, that'd be awesome, but I can't make any promises about using the results... yet.
Most of our SIMD support IIRC is just methods in https://api.dart.dev/stable/2.14.4/dart-typed_data/dart-typed_data-library.html
Things like https://api.dart.dev/stable/2.14.4/dart-typed_data/Int32x4/operator_plus.html
Where you can operate on "chunks" of numeric values together.
@kevmoo thats true, but the dartdoc documentation is somewhat terse. Really I just found that the previous documentation page did a really nice job of clearly explaining SIMD and how to make use of SIMD in the context of Dart.
Having something like this article that brings it all together with some diagrams and small code examples (at least for me) I find is super helpful if being able to dive in and start using it quickly. For example the explanation and diagrams in the branching section I found helpful as a newcomer to using SIMD (not just SIMD in Dart).
Most of our SIMD support IIRC is just methods in https://api.dart.dev/stable/2.14.4/dart-typed_data/dart-typed_data-library.html
Things like https://api.dart.dev/stable/2.14.4/dart-typed_data/Int32x4/operator_plus.html
Where you can operate on "chunks" of numeric values together.
There was a really good article on SIMD that I suspect we jettisoned because its code was untested and rotting. The figures alone are very helpful!
@mit-mit , @kevmoo : Is this something you would like to see documented in the current public docs? If so, it would need updates for Dart 2 if not Dart 3. Thoughts?
@atsansone – I don't there have been any changes w/ Dart 3.
My main reason for opening this issue originally was just that I found https://web.archive.org/web/20190402213240/https://www.dartlang.org/articles/server/simd really helpful and useful and thought others would too. Would the Dart team be open to republishing on dart.dev again if I submitted a PR which updated the code examples in it to modern Dart usage (eg removing new's)?
@mraleph can you take a quick look at https://web.archive.org/web/20190402213240/https://www.dartlang.org/articles/server/simd and determine if that content is still relevant for the current-day VM?
The content is okay if it is updated. It's not just about updating the code - e.g. it should reflect that SIMD.js is abandoned, etc.
That being said, dart:typed_data API has some issues and I am not sure we want to evangelise it. If anything we should explore the way to pull it out of dart:typed_data and instead provide a number of platform specific intrinsic libraries. There are two core issues with the current API:
- It was designed in an Intel centric manner - however ARM and Intel instruction sets have different capabilities where it comes to SIMD e.g. classical example would be
signMaskwhich is a single instruction on Intel but requires multiple instructions on Arm. Consquently some SIMD operations have really bad implementations on ARM platforms. - It does not have and will never have a performant JS implementation, despite residing in a platform independent library.
Thanks for looking into it @mraleph Good to know about this limitations of the API, I'm still a beginner in SIMD (hence why I liked having the old article available) so I didn't realise about it being Intel centric.
I understand not wanting to promote something that you would like to replace, but I guess the current API is going to be here for quite sometime or are there plans for this to change this soon? sorry I couldn't seem to find if there is a roadmap for DartVM features vs the one that exists for upcoming language features/changes.
On the web front, would the upcoming support in Dart for WASM also help with not needing to worry as much about the JS implementation? Funny thing is that the V8 doc on WASM SIMD actually references as being influenced by both SIMD.js and the Dart SIMD 🙂 .
If my memory serves, we decided to drop the SIMD documentation as it was poorly maintained and outdated.
I think any non-perfect documentation is better than no documentation (or one that will change in the future), otherwise googling for "dart simd" will yield a parody-site as the first result (like as of now).