
Hi all, I'm curious about how to control compiler options for mingw builds of numpy on windows... Specifically, I want to build binaries without SSE support, so that they can run on older hardware. Setting a CFLAGS variable on the command-line doesn't appear to do anything, but perhaps appearances are deceiving. Thanks for any suggestions -- I've googled fruitlessly for a while. Zach

On Sat, Nov 29, 2008 at 5:35 AM, Zachary Pincus <zachary.pincus@yale.edu> wrote:
Hi all,
I'm curious about how to control compiler options for mingw builds of numpy on windows... Specifically, I want to build binaries without SSE support, so that they can run on older hardware.
The windows binaries of numpy can run on machines without SSE support. If for some reason you want to build it by yourself, you just need a BLAS/LAPACK without SSE - assuming you want BLAS/LAPACK. Note that depending on your intent, all the scripts to generate the full binary (which install the most optimized binary depending on the detected arch) are in svn too, if that's something you want to do. I have recently remove the arch specific optimization in numpy.distutils, so this should not be a problem either. David

I'm curious about how to control compiler options for mingw builds of numpy on windows... Specifically, I want to build binaries without SSE support, so that they can run on older hardware.
The windows binaries of numpy can run on machines without SSE support. If for some reason you want to build it by yourself, you just need a BLAS/LAPACK without SSE - assuming you want BLAS/LAPACK. Note that depending on your intent, all the scripts to generate the full binary (which install the most optimized binary depending on the detected arch) are in svn too, if that's something you want to do.
I have recently remove the arch specific optimization in numpy.distutils, so this should not be a problem either.
Thanks for the information, David! Regarding the windows binary installer, it appears that it selects the optimized/unoptimized binary at *install time*, which causes complications for further bundling of numpy with e.g. py2exe for use on other machines. (E.g. my dev machine has SSE3, and it appears that SSE3-optimized binaries get installed on it, which then causes crashing when I bundle up a numpy script with py2exe ad run it on an older box.) Is this in fact the case? If so, is there any easy way to force the installer to just use the basic unoptimized configuration? That would be the best... On the other hand, if I'm using a SSE-free BLAS/LAPACK or non at all, there'll be no SSE optimization done? I understand that gcc4, and thus mingw derived from that version, will automatically try to use sse instructions where possible if not specifically disabled, which is what induced my original question. So, to be certain that gcc isn't introducing sse instructions under the covers, I would still like to know if there's a way to pass compiler flags to the build stage of numpy. On UNIX, CFLAGS seems to do the trick, but on windows with mingw the flags don't seem to be recognized... (E.g. setting CFLAGS to '-mfoo' causes an invalid option error on OS X, but not with windows.) Thanks again, Zach

Zachary Pincus wrote:
Regarding the windows binary installer, it appears that it selects the optimized/unoptimized binary at *install time*, which causes complications for further bundling of numpy with e.g. py2exe for use on other machines. (E.g. my dev machine has SSE3, and it appears that SSE3-optimized binaries get installed on it, which then causes crashing when I bundle up a numpy script with py2exe ad run it on an older box.) Is this in fact the case?
Yes
If so, is there any easy way to force the installer to just use the basic unoptimized configuration?
No at the moment, but you can easily decompress the .exe content to get the internal .exe (which are straight installers built by python setup.py setup.py bdist_wininst). It should be possible to force an architecture at install time using a command line option, but I don't have the time ATM to support this. If you are willing to add the option, you should add the option to the template .nsi file: http://projects.scipy.org/scipy/numpy/browser/trunk/tools/win32build/nsis_sc... The documentation is on nsis webpage: http://nsis.sourceforge.net/Main_Page
On the other hand, if I'm using a SSE-free BLAS/LAPACK or non at all, there'll be no SSE optimization done? I understand that gcc4, and thus mingw derived from that version, will automatically try to use sse instructions where possible if not specifically disabled, which is what induced my original question.
First, mingw uses gcc3, unless you use a custom built or alpha release. Also, I am pretty sure that by default, gcc does NOT use any SSE optimization. You have to request it.
So, to be certain that gcc isn't introducing sse instructions under the covers, I would still like to know if there's a way to pass compiler flags to the build stage of numpy. On UNIX, CFLAGS seems to do the trick, but on windows with mingw the flags don't seem to be recognized... (E.g. setting CFLAGS to '-mfoo' causes an invalid option error on OS X, but not with windows.)
This may be due to the 'shell' in windows, I don't know. Generally, using CFLAGS is not reliable with numpy.distutils. But again, in numpy trunk, no arch specific flag is added by numpy.distutils anymore, so you should not need it. David

On Sun, Nov 30, 2008 at 3:02 PM, David Cournapeau <david@ar.media.kyoto-u.ac.jp> wrote:
No at the moment, but you can easily decompress the .exe content to get the internal .exe (which are straight installers built by python setup.py setup.py bdist_wininst). It should be possible to force an architecture at install time using a command line option, but I don't have the time ATM to support this.
I needed it to help me fixing a couple of bugs for old CPU, so it ended up being implemented in the nsis script for scipy now (I will add it to numpy installers too). So from now, any newly releases of both numpy and scipy installers could be overriden: installer-name.exe /arch native -> default behavior installer-name.exe /arch nosse -> Force installation wo sse, even if SSE-cpu is detected. It does not check that the option is valid, so you can end up requesting SSE3 installer on a SSE2 CPU. But well... David

I needed it to help me fixing a couple of bugs for old CPU, so it ended up being implemented in the nsis script for scipy now (I will add it to numpy installers too). So from now, any newly releases of both numpy and scipy installers could be overriden:
installer-name.exe /arch native -> default behavior installer-name.exe /arch nosse -> Force installation wo sse, even if SSE-cpu is detected.
It does not check that the option is valid, so you can end up requesting SSE3 installer on a SSE2 CPU. But well...
Cool! Thanks! This will be really useful... Zach
participants (3)
-
David Cournapeau
-
David Cournapeau
-
Zachary Pincus