Re:Pillow-SIMD: improving the performance of image processing
by asb on Friday May 13, 2016 @01:14PM
(#11691684)
You can even use the GCC ifunc attribute and get the dynamic linker to handle selecting the right function.
Re:Pillow-SIMD: improving the performance of image processing
by btown on Friday May 13, 2016 @01:43PM
(#11691910)
Certainly seems like this is the right way to go: http://clang.llvm.org/docs/AttributeReference.html#ifunc-gnu...
Re:Pillow-SIMD: improving the performance of image processing
by dman on Friday May 13, 2016 @02:09PM
(#11692102)
Any pointers for similar functionality for Visual Studio?
Re:Pillow-SIMD: improving the performance of image processing
by tacos on Friday May 13, 2016 @03:49PM
(#11692794)
Code in separate libs then this inside #ifdefs.
#pragma comment(linker, ...)
Re:Pillow-SIMD: improving the performance of image processing
by dman on Friday May 13, 2016 @04:04PM
(#11692876)
Thanks!
Re:Pillow-SIMD: improving the performance of image processing
by dalke on Friday May 13, 2016 @02:24PM
(#11692210)
In practice, it's very hard to make Python's distutils do this. I tried to figure it out years ago, see http://stackoverflow.com/questions/15527611/how-do-i-specify... . I also asked on the distutils list. No one had a clean solution.
The best solution I have is to interpose my own "CC", which looks at what is being compile and adds the correct compiler options for the right files before calling the real compiler. This is hacky and inflexible.
Re:Pillow-SIMD: improving the performance of image processing
by wiredfool on Friday May 13, 2016 @02:50PM
(#11692413)
I'm curious how scpiy and numpy manage it. I'm pretty sure that they have solved some of this before.
Re:Pillow-SIMD: improving the performance of image processing
by tavert on Friday May 13, 2016 @03:39PM
(#11692733)
Entirely handled by the underlying BLAS library, OpenBLAS and MKL have this feature but few if any other libraries do. I believe FFTW has something similar, but scipy doesn't use FFTW.
Re:Pillow-SIMD: improving the performance of image processing
by dalke on Friday May 13, 2016 @03:14PM
(#11692580)
In my short search, I didn't see evidence that either package has run-time dispatch based on the processor type.
I don't see "cpuid" used in the scipy code base, and the only intrinsic I found is specifically in a MS Windows #ifdef.
Numpy doesn't use cpuid. It does have compile-time options for intrinsics, but not run-time.
Re:Pillow-SIMD: improving the performance of image processing
by johnt15 on Friday May 13, 2016 @07:55PM
(#11693930)
It's possible to do automatically this by using a SIMD library such as libsimdpp (https://github.com/p12tic/libsimdpp). Everything is mostly abstracted away and you just write the SIMDified code once and add a CMake rule that builds the same file for several architectures, sets up dynamic dispatch and links everything together.
They can create three versions of each affected function (fallback, SSE4 and AVX2), place them in separate files (one file for each set of compiler flags), compile each version with its own compiler flags, then link them all together, and in the main module (which is compiled for generic cpu) run cpuid and set global function pointers to the right function implementation.
Then always use the global function pointer to call the right implementation of the function, and only expose calling the global function pointer if the function is exported from a shared library.
They do need to make sure that function pre and post conditions are preserved in all versions and that memory alignment/layout required by optimized functions is created by the generic code.
I think x264 does this.