Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fftw3 - add support for Apple silicon and fix preprocessor #1042

Merged
merged 1 commit into from
Aug 24, 2023

Conversation

PovlAbrahamsen
Copy link
Contributor

First, a bug fix:

  • rather than invoking Apple's preprocessor directly, preprocess via GCC (by calling "gcc-fsf-11 -E"). If we don't do this, we end up with a bunch of errors when checking header usability.
  • Also, header paths are CPPFLAGS, not CFLAGS.

And then we add support for Apple silicon:

  • an upstream patch for using the Arm CNTVCT_EL0 counter on Apple silicon (default to CNTVCT_EL0 cycle counter on Apple M1 FFTW/fftw3#267)
  • remove the Intel-specific command-line arguments when compiling on Apple silicon
  • specify support for the CNTVCT_EL0 counter. Strictly speaking, this probably isn't necessary, as the first patch should enable this support automatically on MacOS. Alternatively, we could specify this argument and omit the patchfile. Probably comes under the heading of "belt and braces"...

This all requires a working installation of GCC 11. Since I'm now using MacOS 13.4.1 on Apple silicon, I'm using #1033. It compiles and passes all tests with "-m".

@nieder nieder added the waiting for reply Waiting for reply from submitter label Jul 22, 2023
@nieder
Copy link
Member

nieder commented Jul 22, 2023

Seems like a lot of good optimizations are now found (10.14.6):

checking whether C compiler accepts -mtune=native... yes
checking whether C compiler accepts -malign-double... yes
checking whether C compiler accepts -fstrict-aliasing... yes
checking whether C compiler accepts -fno-schedule-insns... yes
checking whether C compiler accepts -O3 -fomit-frame-pointer -mtune=native -malign-double -fstrict-aliasing -fno-schedule-insns... yes

I can't test arm64.

The old CPP=which cpp check was introduced in 51f99bb. Any idea as to why the generic system cpp might have been chosen? This seems better, but just curious.

Also, do you know why the code is rebuilt in InstallScript before running make check?
Why is --enable-float added here and not originally?

For the InstallScript ./configure ..., the two commands in the %m conditional are identical except for the addition of --enable-sse in !arm64. That's already included in %c and conditionalized on %m. Can we get rid of the InstallScript conditional and have a single command?

@PovlAbrahamsen
Copy link
Contributor Author

The first run of configure & make & install builds the double-precision libraries. The second runs, in InstallScript, build and install the single-precision libraries. It’s a strange solution, but it works! And two passes are necessary to install both sets of libraries.

The old commit that you refer to specifies the new header paths for 10.9+. But I have no idea why generic CPP was specified; perhaps there was a problem with early builds of gcc? Either way, on 13.4 using generic CPP here produces a bunch of errors in configure which result in options (and possibly optimisations) not being chosen correctly - even though it does build.

@nieder
Copy link
Member

nieder commented Aug 16, 2023

Grrr. Never got the email that you had responded.
Thanks for the clarifications.

The conditional check in InstallScript to build the single-precision libraries can be removed and just keep the same command as in CompileScript with --enable-float appended. --enable-sse is already conditionalized in ConfigureParams, so there's no need to and an extra if..then..else.

Copy link
Member

@nieder nieder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The only issue left is the duplicated command in InstallScript, which can be changed after merging.

@nieder nieder merged commit cb6503b into fink:master Aug 24, 2023
@PovlAbrahamsen
Copy link
Contributor Author

Grrr. Never got the email that you had responded. Thanks for the clarifications.

The conditional check in InstallScript to build the single-precision libraries can be removed and just keep the same command as in CompileScript with --enable-float appended. --enable-sse is already conditionalized in ConfigureParams, so there's no need to and an extra if..then..else.

No, --enable-sse2 is in the main ConfigureParams, not --enable-sse! Probably best to leave as is - or add --enable-sse to ConfigureParams, for x86_64, unless this will mess something else up? I'm afraid I won't have chance to do anything further on this in the next few weeks.

@PovlAbrahamsen PovlAbrahamsen deleted the fftw3 branch August 24, 2023 18:16
@nieder
Copy link
Member

nieder commented Aug 24, 2023

Good catch on the extra 2. Leaving as is.

@nieder nieder mentioned this pull request Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for reply Waiting for reply from submitter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants