FFTW / fftw3

DO NOT CHECK OUT THESE FILES FROM GITHUB UNLESS YOU KNOW WHAT YOU ARE DOING. (See below.)
GNU General Public License v2.0
2.72k stars 661 forks source link

Clarify current/future cmake support #307

Open LecrisUT opened 1 year ago

LecrisUT commented 1 year ago

The wording in the readme is rather contradictory with how the current status of the project is. I.e.:

matteo-frigo commented 1 year ago

Here is my view on this issue.

autotools is and will remain the primary mechanism for compiling FFTW on any system that has a unix-like shell. It is the only mechanism that we personally use.

cmake support was contributed by other people, to whom we are thankful. We incorporated it because it simplifies building FFTW on Windows, which has historically been a problem for decades. We (as authors of Free Software) have no appetite whatsoever to touch Windows, and keeping the cmake support around is extra work for us. Nevertheless, not adding cmake support makes the life of other people harder at no benefit to us, so we added cmake support.

Building FFTW is complicated because a substantial majority of the C code that comprises FFTW is automatically generated, and code generation used to take a long time. Many years ago (before github was invented) we settled on a distribution model where the code-generation stage is performed by us once and for all, and the final user only needs a C compiler and a unix shell to compile FFTW. In this model, the primary distribution mechanism is a tarball downloaded from fftw.org, and github is a secondary distribution mechanism not really meant to be used by civilians.

The code generation machinery is currently only supported by autotools. Migrating this machinery to cmake would not solve any problem that we currently have, and thus I am disinclined to do any work on this front.

LecrisUT commented 1 year ago

I would say that one disadvantage of not migrating to more standard toolchains is the gatekeeping of new colaborators and the lack of IDE support. For example, easy CI support and maintenance.

Doing a preliminary scan of the code that is generated, there doesn't seem to be anything majorly complicated that cannot be done with macros (but honestly C++ templates would be significantly simpler, and migrating would not be difficult using a simple regex substitution). The code generation seems to be just calling some perl scripts, which can be done straightforwardly in cmake. If there are more complicated generations, please elaborate more on how the code-generation works.

stevengj commented 1 year ago

Doing a preliminary scan of the code that is generated, there doesn't seem to be anything majorly complicated that cannot be done with macros (but honestly C++ templates would be significantly simpler, and migrating would not be difficult using a simple regex substitution).

Um.... see the paper A Fast Fourier Transform Compiler.

C++ templates are turing complete, and so in principle could do anything, but it is unlikely to be "simpler" to do algebraic pattern matching and simplification in templates than using a language (OCaml) designed for those tasks. In any case, this isn't going to happen.

Definitely the code-generation programs could be invoked from cmake, but as Matteo wrote above this doesn't really interest us for any practical reason at the moment.

LecrisUT commented 1 year ago

Let me know if I understand this correctly:

The place where I was thinking would be a good idea to port to C++ is in substituting the macros, e.g. the X macro. The user would not need to care about what FFTW precision they need natively, and instead have the C++ template call the appropriate function. Am I missing something about OCaml - C/C++ interface?

The lack of native cmake integration is unfortunate because for users it would greatly simplify their implementation:

matteo-frigo commented 1 year ago

I have no interest in continuing this conversation. The last one leaving please close the ticket.

stevengj commented 1 year ago

@LecrisUT, the API of FFTW needs to be based on C, not C++, even though it should be callable from C++. This is partly for technical reasons — it is vastly easier to call C libraries from other languages than it is to call C++ libraries.

(Various authors have layered more "native-feeling" C++ interfaces on top of FFTW and they are welcome to do so, along with the interfaces to FFTW from Python, Julia, R, Rust, etcetera.)