GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — ENH: enable multi-platform SIMD compiler optimizations by seiko2plus · Pull Request #13516 · numpy/numpy Conversation
|
|
I am concerned all this will become a maintenance burden moving forward. Is there a way to use this as a library or a subrepo? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
What does this comment about library or subrepo mean? This sounds very hostile to NumPy supporting other architectures. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
@mattip this is quite clearly addressed in the discussion that spurred this PR: gh-13393. And we also discussed it with the Steering Council before saying yes to posting the bounty mentioned in gh-13393. So yes it's a concern, but if things are done the right way there's no reason that this should substantially increase the maintenance burden. Please review that issue and comment on code or ideas that are potentially problematic, no need to start a new abstract discussion.
@edelsohn that's certainly not our intent as a project. We'd really like to have complete SIMD support for PowerPC as well as other architectures, with the compiler doing most of the heavy lifting. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
That said, this is quite a bit of code. I believe a lot of it is well-tested though, taken over from OpenCV (correct me if I'm wrong @seiko2plus). Some more context in the issue description would be useful:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
It is simply another way to organize the code. NumPy already has two submodules that provide tools to build the documentation, putting the code in a submodule allows the NumPy to use the code while letting development proceed at its own pace. Likewise, NumPy builds several libraries for the sorting and math code, probably not strictly necessary these days, but routines in the libraries are linked in when needed, and strictly speaking could be used by downstream projects. You have a number of new files dedicated to this work, so it might be nice to put them together in subdirecties, maybe organized by architecture. Note that the libraries have their own setup and include files and configure the system. So the question here is how should we organize the code, not whether we should have it. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
It seems to me, after a cursory inspection, that how you want to do the On the other hand, I recognize that the One thing to note is that we ought to be able to use this infrastructure to build another package that uses CPU features that the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
A maintenance burden already moving forward, I think what I'm doing is just trying to ease the burden.
I'm afraid not or at least for now , because the universal intrinsics (mapped intrinsics) are going to be heavily expanded depending on the needs and I think it should be part of NumPy's core, later we should forbid or at least reduce the direct use of raw SIMD intrinsics and only count on universal intrinsics for CPU optimizations.
Actually, most of the work here is mainly for the x86 due to the need to dealing with many SIMD extensions, compilers, and platforms which make it kinda complicated and I don't see VSX or even NEON create any obstacles here, maybe supporting BE mode for VSX will be a little bit challengable but I'm planning to implement it in a separate pull-request after I get done from re-implement the current optimized kernels using the new SIMD interface.
Yes, well I had to add some fundamental universal intrinsics just for testing propose but sure I will add a lot more depending on the needs.
I believe we shouldn't put our trust in any intrinsics even if it directly mapping to native instruction-set since
Like I mentioned before in #13393 the whole road map is inspired by OpenCV but not exactly the same design or code but I can tell the similarity is very high especially to infrastructure.
Of course, I will not be able to cover all areas in this pr but I think it's necessary to provide a decent example for illustrative and testing purposes and please feel free to add any extra tasks.
if it's necessary having a custom CI using "buildbot" could be an alternative solution too.
Do you think the current work isn't organized enough?
Although this work still not completed yet, I would truly appreciate it if you could provide a proposal or any kind of notes.
Sure it is a great idea and it seems like the community prefer this way (a separate package) but wait as you know every project have his own needs, that means you have to find compatibilities, flexible design which means more time, more issues and I think we should focus on the main purpose instead at least for now and have some fun by optimize some kernels :). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
no not necessary, and in fact very much undesired. we used to have those in the pre-TravisCI age and they're a maintenance nightmare. we'll just cover what we can with the hosted CI platforms we have, and the rest we test manually at PR develop/merge time and rely on community input to keep things working. that's the way it is now too for AIX, Sparc, etc. we'll just slowly expand coverage as we go |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
c1c7d9e to
8802a35
Compare
|
I think we should merge this as-is. With a PR this large, there will always be more to clean up around documentation and comments. PR gh-15551 adds a document to describe the mechanism here, and should be merged after this PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Implement new distutils class `CCompilerOpt`, used for handling the CPU/hardware optimization, starting from parsing the command arguments, to managing the relationship between the CPU baseline and dispatch-able features, also generating the required C headers and ending with compiling the sources with proper compiler's flags. `CCompilerOpt` mainly used as a helper class for `CCompiler`, and doesn't provide any runtime detection for the CPU features, instead only focuses on the compiler side, but it generates abstract C headers that can be used later for the final runtime dispatching process.
Add testing unit for `CCompilerOpt`
- Put `CCompilerOpt` in action through add two command line
arguments that passed directly to `CCompilerOpt`'s
parameters which explained as follows:
* `--cpu-baseline` minimal set of required optimizations,
default is 'min' which provides the minimum CPU features
that can safely run on a wide range of users platforms.
* `--cpu-dispatch` dispatched set of additional optimizations,
default is 'max-xop-fma4' which enables all CPU features,
except for AMD legacy features.
the new arguments can be reached from `build`, `build_clib`,
`build_ext`, if `build_clib` or `build_ext` are not specified
by the user the arguments of `build` will be used, which also
hold the default values.
- Activate the new compiler dispatcher that comes with `CCompilerOpt`,
through adding a hock inside `build_clib` and `build_ext`
that works as a filter taking any C source files ends with
`.dispatch.c` and pass it directly to `CCompilerOpt` and
then take returned objects and linked to the final C lib.
- Add a third command-line argument `--disable-optimization` which
explicitly disable the whole new infrastructure, also
It adds a new compiler definition called `NPY_DISABLE_OPTIMIZATION`.
when `--disable-optimization` is enabled the dispatch-able sources
that end with `.dispatch.c` will be treated as a normal
C sources, also due to this disabling any C headers that
generated by `CCompilerOpt` must guard it with `NPY_DISABLE_OPTIMIZATION`,
otherwise, it will definitely break the build.
- New auto-generated C header located at `core/include/numpy/_cpu_dispatch.h`,
the new header contains all definitions and headers of CPU features that
enabled according to specified configuration in `--cpu-baseline`
and `--cpu-dispatch`.
Add several C macros to `utils.h`
Add new C header located at `core/src/common/npy_cpu_dispatch.h`
the new header works as a bridge linking the generated
headers and macros by `CCompilerOpt` with NumPy runtime
CPU features detection API through provides several
C macros can be used in dispatching the generated objects
from dispatch-able sources.
- Add new attributes to umath module
* __cpu_baseline__ a list contains the minimal set of required optimizations
that supported by the compiler and platform according to the specified
values to command argument '--cpu-baseline'.
* __cpu_dispatch__ a list contains the dispatched set of additional optimizations
that supported by the compiler and platform according to the specified
values to command argument '--cpu-dispatch'
- Print required and additional optimizations during the run of PytestTester
Add testing unit for the utilites of CPU dispatcher
|
Thanks @seiko2plus. Step 1 is done! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I started to love the purple color, thank you! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@seiko2plus This PR raises compiler warnings with fedora gcc 10 when AVX is missing. EDIT: Also for other avx checks. Seems the checks should not be compiled without AVX. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@charris, class
If both tests failed, then the feature will be skipped, but since we're dealing with GCC-10 both tests should be passed. However, I tested (GCC version 10.1.0) and it looks fine to me. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@seiko2plus I don't see that warning anymore, may have changed with a recent kernel update. Let me try with an older kernel. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
No, they are still there, but tests run fine. I think the errors are configuration output that |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Could you put the complete build log up somewhere like https://paste.ubuntu.com/ ? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@mattip Here: https://paste.ubuntu.com/p/VH7x8qJkVS/ . Search for |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@charris, umm well it seems '-march=native' is provided through environment variable CFLAGS or it is part of distutils config vars. see the final build log: CPU baseline : Requested : 'native' Enabled : SSE SSE2 SSE3 SSSE3 SSE41 POPCNT SSE42 AVX F16C FMA3 AVX2 Flags : -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -mf16c -mfma -mavx2 CPU dispatch : Requested : 'max -xop -fma4' Enabled : AVX512F AVX512CD AVX512_KNL AVX512_KNM AVX512_SKX AVX512_CLX AVX512_CNL AVX512_ICL Generated : none CCompilerOpt._cache_write[786] : write cache to path -> /home/charris/Workspace/numpy.git/build/temp.linux-x86_64-3.9/ccompiler_opt_cache_ext.py ########### CLIB COMPILER OPTIMIZATION ########### CPU baseline : Requested : 'native' Enabled : SSE SSE2 SSE3 SSSE3 SSE41 POPCNT SSE42 AVX F16C FMA3 AVX2 Flags : -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -mf16c -mfma -mavx2 CPU dispatch : Requested : 'max -xop -fma4' Enabled : AVX512F AVX512CD AVX512_KNL AVX512_KNM AVX512_SKX AVX512_CLX AVX512_CNL AVX512_ICL Generated : none CCompilerOpt._cache_write[786] : write cache to path -> /home/charris/Workspace/numpy.git/build/temp.linux-x86_64-3.9/ccompiler_opt_cache_clib.py The failure messages are normal in this case since |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This is part of "build_clib" (line 627). The configuration work is done during "build_src" (line 135). Maybe we should do the same tricks during CCompilerOpt to ignore warnings that we do during build_src. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@mattip, why we should suppress the error messages? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Yes, It should be showing if
Yes, when the compiler doesn't support certain feature. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| ").*" | ||
| ) | ||
| @staticmethod | ||
| def _dist_test_spawn(cmd, display=None): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I am not sure whether we should suppress the warnings when someone specifies |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.