Skip to content
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

DOC: Improve SIMD documentation(1/4) #19581

Merged
merged 6 commits into from Dec 10, 2021
Merged

Conversation

seiko2plus
Copy link
Member

@seiko2plus seiko2plus commented Jul 29, 2021

related to #18926, merge after #18884

This pull request is limited to improve the following :

  • Features generator
  • Split into multiple pages
    - [ ] CPU build options(remains runtime trace)
    - [ ] How to use the dispatcher API
    - [ ] How the dispatcher works

This pull request will not cover the following:

  • Universal intrinsics API (Going to be implemented with C++ interface in the next pr)
  • How to extend the infrastructure with more CPU features and architectures (requires improve the docstring of CCompilerOpt)

Live URL https://23836-908607-gh.circle-artifacts.com/0/doc/build/html/reference/simd/index.html

@seiko2plus seiko2plus added component: documentation component: SIMD Issues in SIMD (fast instruction sets) code or machinery labels Jul 29, 2021
@seiko2plus seiko2plus force-pushed the improve_simd_doc branch 2 times, most recently from 9936de3 to 296b5dc Compare July 29, 2021 03:03
@rgommers
Copy link
Member

rgommers commented Dec 8, 2021

@seiko2plus this is still draft, however there is valuable content in here already. Should we perhaps review and merge this as is, and leave the TODO items for a next PR?

@seiko2plus seiko2plus marked this pull request as ready for review December 8, 2021 20:22
@seiko2plus
Copy link
Member Author

@rgommers, sounds good to me, for the next pr then.

@seiko2plus seiko2plus changed the title WIP, DOC: Improve SIMD documentation DOC: Improve SIMD documentation(1/4) Dec 8, 2021
Copy link
Member

@melissawm melissawm left a comment

Choose a reason for hiding this comment

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

Hello @seiko2plus ! I did a thorough read and this looks really good. I left a number of comments, most of them about grammar, typos or formatting, nothing major. One point I would like to raise is that we could move this document to the "Under the hood" section, as I think it fits better there. But I'll leave the decision to you and other maintainers. Also feel free to ignore my nitpicky comments!

doc/source/reference/simd/index.rst Outdated Show resolved Hide resolved
doc/source/reference/simd/index.rst Outdated Show resolved Hide resolved

The optimization process in NumPy is carried out in three layers:

- Code is *written* using the universal intrinsics, with guards that
Copy link
Member

Choose a reason for hiding this comment

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

Can we provide a link to a definition or explanation of what universal intrinsics are?

Copy link
Member Author

Choose a reason for hiding this comment

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

add a simple explanation for it but I am not sure if that would be enough. we will have a separate document for it with a reference for the supported intrinsics.

doc/source/reference/simd/index.rst Outdated Show resolved Hide resolved
doc/source/reference/simd/build-options.rst Outdated Show resolved Hide resolved
doc/source/reference/simd/how-it-works.rst Outdated Show resolved Hide resolved
Comment on lines 5 to 10
NumPy dispatcher is based on multi-source compiling, which means taking
a certain source and compiling it multiple times with different compiler
flags and also with different **C** definitions that affect the code
paths to enable certain instruction-sets for each compiled object
depending on the required optimizations, then combining the returned
objects together.
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 very long sentence - might be re-worded, maybe something like:

Suggested change
NumPy dispatcher is based on multi-source compiling, which means taking
a certain source and compiling it multiple times with different compiler
flags and also with different **C** definitions that affect the code
paths to enable certain instruction-sets for each compiled object
depending on the required optimizations, then combining the returned
objects together.
NumPy dispatcher is based on multi-source compiling, which means taking
a certain source and compiling it multiple times with different compiler
flags and also with different **C** definitions that affect the code
paths. This enables certain instruction-sets for each compiled object
depending on the required optimizations which are then combined in the returned
objects together.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, but I have changed the last phrase to become "and ends with linking the
returned objects together.".

doc/source/reference/simd/how-it-works.rst Outdated Show resolved Hide resolved
doc/source/reference/simd/how-it-works.rst Outdated Show resolved Hide resolved
doc/source/reference/simd/how-it-works.rst Outdated Show resolved Hide resolved
@seiko2plus
Copy link
Member Author

Hi @melissawm!, thank you for your amazing and accurate review. I have addressed all your points within a separate commit. Now what is left is moving this index to "Under the hood", I'm not sure, to be honest of what the right call should be but the "build options" document shouldn't be part of the "under the hood" since its targets the end-user but it makes sense to move the rest and the upcoming documents to "under the hood". I'd rather leave that decision up to you and the doc team.

build-options
how-it-works

.. _`NEP-38`: https://numpy.org/neps/nep-0038-SIMD-optimizations.html
Copy link
Member

@rgommers rgommers Dec 10, 2021

Choose a reason for hiding this comment

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

This isn't needed. We have intersphinx set up for numpy.org/neps, so simply this should do it:

`NEP 38`_

The reference 6 lines up just needs the dash removed.

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 minor thing, so let's ignore it - maybe you can take it along in a future PR.

Copy link
Member

@rgommers rgommers left a comment

Choose a reason for hiding this comment

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

I had a read through, this looks great. The features generator is a good idea, keeps the detailed listing of supported features maintainable. Thanks @seiko2plus, and thanks @melissawm for the detailed review!

@rgommers rgommers merged commit 93301a5 into numpy:main Dec 10, 2021
@rgommers rgommers added this to the 1.23.0 release milestone Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
04 - Documentation component: documentation component: SIMD Issues in SIMD (fast instruction sets) code or machinery
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants