Opened 11 years ago

Closed 11 years ago

#41622 closed enhancement (fixed)

fftw-3: enable avx instructions

Reported by: NicosPavlov Owned by: skymoo (Adam Mercer)
Priority: Normal Milestone:
Component: ports Version:
Keywords: haspatch Cc: 9peppe (Giuseppe C)
Port: fftw-3

Description

The proposed patch enables avx optimisation in case of clang compiler, along with the other optimizations in the portfile.

Attachments (3)

Portfile-fftw-3.diff (1.0 KB) - added by NicosPavlov 11 years ago.
fftw.log (409.5 KB) - added by 9peppe (Giuseppe C) 11 years ago.
Portfile-fftw-3-olderclang.diff (660 bytes) - added by NicosPavlov 11 years ago.

Download all attachments as: .zip

Change History (24)

Changed 11 years ago by NicosPavlov

Attachment: Portfile-fftw-3.diff added

comment:1 Changed 11 years ago by skymoo (Adam Mercer)

Status: newassigned

comment:2 Changed 11 years ago by skymoo (Adam Mercer)

Resolution: fixed
Status: assignedclosed

Committed in r114195, with appropriate revision bumps. Thanks.

comment:3 Changed 11 years ago by ryandesign (Ryan Carsten Schmidt)

What about when the compiler is e.g. "macports-clang-3.3"? Usually we detect clang by using [string match *clang* ${configure.compiler}].

comment:4 Changed 11 years ago by skymoo (Adam Mercer)

Good catch, also on a second look it doesn't apply the flag to the fftw-3-single subport.

comment:5 Changed 11 years ago by skymoo (Adam Mercer)

Resolution: fixed
Status: closedreopened

comment:6 Changed 11 years ago by skymoo (Adam Mercer)

I think the following is now correct?

--- a/math/fftw-3/Portfile
+++ b/math/fftw-3/Portfile
@@ -52,7 +52,7 @@ configure.cflags-append \
     -fomit-frame-pointer \
     -fstrict-aliasing

-if { ![string compare ${configure.compiler} "clang"] } {
+if { [string match *clang* ${configure.compiler}] } {
     set is_clang    1
 } else {
     set is_clang    0
@@ -97,11 +97,20 @@ platform powerpc {
 subport fftw-3-single {
     configure.args-append --enable-float

-    array set merger_configure_args {
-        ppc    "--enable-fma --enable-altivec"
-        ppc64  "--enable-fma --enable-altivec"
-        i386   "--enable-sse"
-        x86_64 "--enable-sse"
+    if { $is_clang == 1 } {
+        array set merger_configure_args {
+            ppc    "--enable-fma --enable-altivec"
+            ppc64  "--enable-fma --enable-altivec"
+            i386   "--enable-sse --enable-avx"
+            x86_64 "--enable-sse --enable-avx"
+        }
+    } else {
+        array set merger_configure_args {
+            ppc    "--enable-fma --enable-altivec"
+            ppc64  "--enable-fma --enable-altivec"
+            i386   "--enable-sse"
+            x86_64 "--enable-sse"
+        }
     }

     depends_lib port:fftw-3
@@ -110,6 +119,9 @@ subport fftw-3-single {
         if {![variant_isset universal]} {
             configure.args-delete --enable-sse2
             configure.args-append --enable-sse
+            if { $is_clang == 1 } {
+                configure.args-append --enable-avx
+            }
         }
     }

comment:7 Changed 11 years ago by 9peppe (Giuseppe C)

I attached my log. Revision 4 does not work for me.

comment:8 Changed 11 years ago by skymoo (Adam Mercer)

That's not from a clean attempted, can you clean the port and rebuild and then attach that log.

comment:9 in reply to:  8 Changed 11 years ago by 9peppe (Giuseppe C)

Replying to ram@…:

That's not from a clean attempted, can you clean the port and rebuild and then attach that log.

Done.

 % sudo port clean fftw-3                                                                       
--->  Cleaning fftw-3
 % sudo port upgrade fftw-3                                                                     
--->  Fetching archive for fftw-3
--->  Attempting to fetch fftw-3-3.3.3_4.darwin_10.x86_64.tbz2 from http://lil.fr.packages.macports.org/fftw-3
--->  Attempting to fetch fftw-3-3.3.3_4.darwin_10.x86_64.tbz2 from http://mse.uk.packages.macports.org/sites/packages.macports.org/fftw-3
--->  Attempting to fetch fftw-3-3.3.3_4.darwin_10.x86_64.tbz2 from http://packages.macports.org/fftw-3
--->  Fetching distfiles for fftw-3
--->  Verifying checksums for fftw-3
--->  Extracting fftw-3
--->  Configuring fftw-3
--->  Building fftw-3
Error: org.macports.build for port fftw-3 returned: command execution failed
Please see the log file for port fftw-3 for details:
    /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_math_fftw-3/fftw-3/main.log
Error: Unable to upgrade port: 1
To report a bug, follow the instructions in the guide:
    http://guide.macports.org/#project.tickets

Changed 11 years ago by 9peppe (Giuseppe C)

Attachment: fftw.log added

comment:10 Changed 11 years ago by skymoo (Adam Mercer)

I can't reproduce this on my Mountain Lion or Mavericks box, it looks like you're using Snow Leopard.

Nicolas: Any ideas as this was your patch?

comment:11 Changed 11 years ago by 9peppe (Giuseppe C)

Cc: peppecal@… added

Cc Me!

comment:12 in reply to:  10 Changed 11 years ago by 9peppe (Giuseppe C)

Replying to ram@…:

it looks like you're using Snow Leopard.

I am.

comment:13 in reply to:  10 ; Changed 11 years ago by NicosPavlov

Replying to ram@…:

I can't reproduce this on my Mountain Lion or Mavericks box, it looks like you're using Snow Leopard.

Nicolas: Any ideas as this was your patch?

It is quite possible that the patch provoked this indirectly. Looking up this type of error, it seems that people attribute it to a regression in clang-3.2, but testing

sudo port -d install fftw-3 configure.compiler=macports-clang-3.2

on my system also compiles the port (Mavericks). It may be deeper in the libraries, and be dependent on the XCode version. Which one do you have ?

comment:14 in reply to:  13 Changed 11 years ago by 9peppe (Giuseppe C)

Replying to nicos@…:

It may be deeper in the libraries, and be dependent on the XCode version. Which one do you have ?

4.2. Should I upgrade?

comment:15 Changed 11 years ago by NicosPavlov

Not necessarily, but this may mean that some older versions of clang may have to be blacklisted since they can't handle the additional options from the patch. Another option would be to apply the options from this patch only on some versions of clang, but that seems more complicated.

The attached patch could be used to blacklist the clang compiler from Xcode version 4.2 and older (which would in practice fall back to llvm-gcc-4.2 on 10.6).

Changed 11 years ago by NicosPavlov

comment:16 Changed 11 years ago by skymoo (Adam Mercer)

Looks like this also affects Lion: #41662

comment:17 Changed 11 years ago by skymoo (Adam Mercer)

OP for #41662 hadn't updated the command line tools in a long time. It looked that the version of clang installed was from Xcode-3.x. Updating to the Lion command line tools fixed the issue.

comment:18 Changed 11 years ago by skymoo (Adam Mercer)

peppecal: Does this patch allow you to build?

comment:19 in reply to:  18 Changed 11 years ago by 9peppe (Giuseppe C)

Replying to ram@…:

peppecal: Does this patch allow you to build?

yes.

 % patch Portfile Portfile-fftw-3-olderclang.diff                                               /tmp 00:06:31
patching file Portfile
 % sudo port install                                                                            /tmp 00:06:41 
Password:
--->  Fetching archive for fftw-3
--->  Attempting to fetch fftw-3-3.3.3_4.darwin_10.x86_64.tbz2 from http://lil.fr.packages.macports.org/fftw-3
--->  Attempting to fetch fftw-3-3.3.3_4.darwin_10.x86_64.tbz2 from http://mse.uk.packages.macports.org/sites/packages.macports.org/fftw-3
--->  Attempting to fetch fftw-3-3.3.3_4.darwin_10.x86_64.tbz2 from http://packages.macports.org/fftw-3
--->  Fetching distfiles for fftw-3
--->  Verifying checksums for fftw-3
--->  Extracting fftw-3
--->  Configuring fftw-3
--->  Building fftw-3
--->  Staging fftw-3 into destroot
--->  Installing fftw-3 @3.3.3_4
--->  Deactivating fftw-3 @3.3.3_3
--->  Cleaning fftw-3
--->  Activating fftw-3 @3.3.3_4
--->  Cleaning fftw-3
--->  Updating database of binaries: 100.0%
--->  Scanning binaries for linking errors: 100.0%
--->  No broken files found.
 %                                                                                              /tmp 00:10:34

comment:20 Changed 11 years ago by skymoo (Adam Mercer)

Great, thanks for the confirmation.

comment:21 Changed 11 years ago by skymoo (Adam Mercer)

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.