Ticket #438 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

extension modules on x86_64 fail, march is set to i686

Reported by: tovrstra Owned by: cookedm
Priority: normal Milestone: 1.0.2 Release
Component: numpy.f2py Version: 1.0.1
Keywords: Cc:

Description

When trying to compile this fortran example module into a python module:

MODULE test
IMPLICIT NONE
CONTAINS
    FUNCTION add(a,b)
        REAL(8),INTENT(IN) :: a,b
        REAL(8) :: add
        add = a+b
    END FUNCTION
END MODULE

with f2py:

f2py -c test.f90

on my x86-64 box, I get the following output:

toon@dropklop:~/$ f2py -c test.f90
running build
running config_fc
running build_src
building extension "untitled" sources
f2py options: []
f2py:> /tmp/tmpus7JnZ/src.linux-x86_64-2.4/untitledmodule.c
creating /tmp/tmpus7JnZ
creating /tmp/tmpus7JnZ/src.linux-x86_64-2.4
Reading fortran codes...
        Reading file 'test.f90' (format:free)
Post-processing...
        Block: untitled
                        Block: test
                                Block: add
Post-processing (stage 2)...
        Block: untitled
                Block: unknown_interface
                        Block: test
                                Block: add
Building modules...
        Building module "untitled"...
                Constructing F90 module support for "test"...
                Creating wrapper for Fortran function "add"("add")...
                        Constructing wrapper function "test.add"...
                          add = add(a,b)
        Wrote C/API module "untitled" to file "/tmp/tmpus7JnZ/src.linux-x86_64-2.4/untitledmodule.c"
        Fortran 90 wrappers are saved to "/tmp/tmpus7JnZ/src.linux-x86_64-2.4/untitled-f2pywrappers2.f90"
  adding '/tmp/tmpus7JnZ/src.linux-x86_64-2.4/fortranobject.c' to sources.
  adding '/tmp/tmpus7JnZ/src.linux-x86_64-2.4' to include_dirs.
copying /usr/lib/python2.4/site-packages/numpy/f2py/src/fortranobject.c -> /tmp/tmpus7JnZ/src.linux-x86_64-2.4
copying /usr/lib/python2.4/site-packages/numpy/f2py/src/fortranobject.h -> /tmp/tmpus7JnZ/src.linux-x86_64-2.4
  adding '/tmp/tmpus7JnZ/src.linux-x86_64-2.4/untitled-f2pywrappers2.f90' to sources.
running build_ext
customize UnixCCompiler
customize UnixCCompiler using build_ext
Could not locate executable g77
Could not locate executable f77
customize GnuFCompiler
Could not locate executable ifort
Could not locate executable ifc
Could not locate executable ifort
Could not locate executable efort
Could not locate executable efc
Could not locate executable ifort
Could not locate executable efort
Could not locate executable efc
customize IntelFCompiler
customize LaheyFCompiler
customize PGroupFCompiler
customize AbsoftFCompiler
customize NAGFCompiler
customize VastFCompiler
customize GnuFCompiler
customize CompaqFCompiler
customize IntelItaniumFCompiler
customize IntelEM64TFCompiler
customize Gnu95FCompiler
customize Gnu95FCompiler
customize Gnu95FCompiler using build_ext
building 'untitled' extension
compiling C sources
C compiler: gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O2 -Wall -Wstrict-prototypes -fPIC

creating /tmp/tmpus7JnZ/tmp
creating /tmp/tmpus7JnZ/tmp/tmpus7JnZ
creating /tmp/tmpus7JnZ/tmp/tmpus7JnZ/src.linux-x86_64-2.4
compile options: '-I/tmp/tmpus7JnZ/src.linux-x86_64-2.4 -I/usr/lib/python2.4/site-packages/numpy/core/include -I/usr/include/python2.4 -c'
gcc: /tmp/tmpus7JnZ/src.linux-x86_64-2.4/untitledmodule.c
gcc: /tmp/tmpus7JnZ/src.linux-x86_64-2.4/fortranobject.c
compiling Fortran 90 module sources
Fortran f77 compiler: /usr/bin/gfortran -Wall -ffixed-form -fno-second-underscore -fPIC -O3 -funroll-loops -march=i686 -mmmx -msse2 -msse -fomit-frame-pointer
Fortran f90 compiler: /usr/bin/gfortran -Wall -fno-second-underscore -fPIC -O3 -funroll-loops -march=i686 -mmmx -msse2 -msse -fomit-frame-pointer
Fortran fix compiler: /usr/bin/gfortran -Wall -ffixed-form -fno-second-underscore -Wall -fno-second-underscore -fPIC -O3 -funroll-loops -march=i686 -mmmx -msse2 -msse -fomit-frame-pointer
compile options: '-I/tmp/tmpus7JnZ/src.linux-x86_64-2.4 -I/usr/lib/python2.4/site-packages/numpy/core/include -I/usr/include/python2.4 -c'
extra options: '-J/tmp/tmpus7JnZ/ -I/tmp/tmpus7JnZ/'
gfortran:f90: test.f90
test.f90:0: error: CPU you selected does not support x86-64 instruction set
test.f90:0: error: CPU you selected does not support x86-64 instruction set
test.f90:0: error: CPU you selected does not support x86-64 instruction set
test.f90:0: error: CPU you selected does not support x86-64 instruction set
error: Command "/usr/bin/gfortran -Wall -fno-second-underscore -fPIC -O3 -funroll-loops -march=i686 -mmmx -msse2 -msse -fomit-frame-pointer -I/tmp/tmpus7JnZ/src.linux-x86_64-2.4 -I/usr/lib/python2.4/site-packages/numpy/core/include -I/usr/include/python2.4 -c -c test.f90 -o /tmp/tmpus7JnZ/test.o -J/tmp/tmpus7JnZ/ -I/tmp/tmpus7JnZ/" failed with exit status 1

It seems that f2py is not correctly recognizing the cpu architecture. i.e. the compiler option -march=i686 is wrong. As a workaround, one can simply disable the architecture optimization:

FARCH='' f2py -c test.f90

Change History

Changed 3 years ago by jitter

It looks like this is caused by changeset 3538 (fixing the scipy ticket #349).

No idea whether _is_Nocona() has intentionally been changed from P IV to i686 at that time, but it doesn't work for me on a Pentium 4 D (with x86_64 support). Additionally this breaks the fftpack/dfftpack building in scipy (same -march problem).

Solutions: either revert the i686 thingy in _is_Nocona() (which would be my suggestion, as there isn't any i686 with 64bit support, right?) or apply this patch as a workaround:

Index: numpy/distutils/cpuinfo.py =================================================================== --- numpy/distutils/cpuinfo.py (revision 3546) +++ numpy/distutils/cpuinfo.py (working copy) @@ -185,7 +185,7 @@

return self.is_PentiumIV() and self.has_sse3()

def _is_Nocona(self):

- return self.is_64bit() and self.is_i686() + return self.is_64bit() and (self.is_i686() or self.is_PentiumIV())

def _is_Core2(self):

return self.is_64bit() and self.is_Intel() and \

Just to help the maintainer of cpuinfo.py, here are the contents of /proc/cpuinfo on that machine (running SuSE 10.0, x86_64): processor : 0 vendor_id : GenuineIntel? cpu family : 15 model : 4 model name : Intel(R) Pentium(R) 4 CPU 3.00GHz stepping : 3 cpu MHz : 2990.595 cache size : 2048 KB fpu : yes fpu_exception : yes cpuid level : 5 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl est cid cx16 xtpr bogomips : 5989.97 clflush size : 64 cache_alignment : 128 address sizes : 36 bits physical, 48 bits virtual power management:

Changed 3 years ago by jitter

eeek... WikiFormatting. Sorry about that.

Patch:

Index: numpy/distutils/cpuinfo.py
===================================================================
--- numpy/distutils/cpuinfo.py  (revision 3546)
+++ numpy/distutils/cpuinfo.py  (working copy)
@@ -185,7 +185,7 @@
         return self.is_PentiumIV() and self.has_sse3()

     def _is_Nocona(self):
-        return self.is_64bit() and self.is_i686()
+        return self.is_64bit() and (self.is_i686() or self.is_PentiumIV())

     def _is_Core2(self):
         return self.is_64bit() and self.is_Intel() and \

/proc/cpuinfo:

processor       : 0
vendor_id       : GenuineIntel
cpu family      : 15
model           : 4
model name      :               Intel(R) Pentium(R) 4 CPU 3.00GHz
stepping        : 3
cpu MHz         : 2990.595
cache size      : 2048 KB
fpu             : yes
fpu_exception   : yes
cpuid level     : 5
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl est cid cx16 xtpr
bogomips        : 5989.97
clflush size    : 64
cache_alignment : 128
address sizes   : 36 bits physical, 48 bits virtual
power management:

Changed 3 years ago by cookedm

  • owner changed from somebody to cookedm
  • status changed from new to assigned

Changed 3 years ago by cookedm

  • milestone set to 1.0.2 Release

Changed 3 years ago by cookedm

Fixed in r3615. I removed the 686 part.

Changed 3 years ago by cookedm

  • status changed from assigned to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.