Pillow-SIMD: improving the performance of image processing
github.com
github.com
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.
#pragma comment(linker, ...)
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.
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.
[1]: https://github.com/halide/Halide/blob/e9ece5ee8ee9cb62295d5e...
(I'm one of the main Halide devs)
If you support JPEG, PNG, and GIF you will have 99% of the user data supported. Very few people upload RLE TARGA to webpages these days.
It does all of the above operations without decoding the image, giving a significant speed boost.
I just benchmarked it against pillow-smd on my laptop (SSE4 only) and it's 1.3-1.8x faster, depending on the operation.
(But yeah, would love to see this merged upstream. Lots of Python libraries have sorted out harder CPU/GPU dependencies.)
There have been some bugs that look like people have been successfully fuzzing, but there's nothing organized.
The goal is certainly to be safe against user input, I would say we're there, but we're better off than we were 6months ago.
> If you have ever worried or wondered about the future of PIL, please stop. We're here to save the day
What's the backstory here?
(I'm one of the maintainers of pillow, but I hadn't seen the smid fork before.)
No backstory, the development of PIL gradually slowed down and ultimately stopped in 2011 (the last official release having been cut in 2009), I've never seen any info as to why that happened, it just did. Possibly the difficulty of implementing P3 compatibility while remaining pre-2.7 compatible.
PIL was always an idiosyncratic package with a completely custom setup script, a difficult install (including setuptools-incompatibility) and weird-ass modules (probably owing in part to 1.5~2.7 compatibility), as well as a fairly slow release schedule (bi-yearly at the best of times).
And so in 2013 it was forked (not entirely unlike LibreSSL from OpenSSL) and a dedicated group started on maintaining and cleaning the stuff, progressively phasing out pre-2.6 compatibility and adding Python 3 support, etc...
wget http://effbot.org/downloads/Imaging-1.1.7.tar.gz
tar xvf Imaging-1.1.7.tar.gz
cd Imaging-1.1.7/
python2.7 setup.py build
sudo python2.7 setup.py install
Alas, those simple days are over.EDIT: Preemptively, I know how to verify checksums.
Then you can use Bash or another strange scripting language from the late-1980s, presuming you're okay with it writing files, too.