6. AOCL-FFTW#

AMD optimized version of Fast Fourier Transform Algorithm (FFTW) is a comprehensive collection of fast C routines for computing the Discrete Fourier Transform (DFT) and various special cases thereof that are optimized for AMD EPYCTM and other AMD “Zen”-based processors. It is an open- source implementation of FFTW. It can compute transforms of real and complex valued arrays of arbitrary size and dimension.

6.1. Installing#

AOCL-FFTW can be installed from the source or pre-built binaries.

6.1.1. Building AOCL-FFTW from Source on Linux#

Prerequisites

The following prerequisites must be met:

  • GNU Make 4.2 or later

  • GCC 6.1.0 or later

  • AOCC 2.1 or later

  • MPI compiler 3.1 or later

  • Makeinfo 6.8 or later

  • For more information on supported operating systems, refer to Operating Systems.

Complete the following steps to build AOCL-FFTW for AMD EPYCTM processor based on the architecture generation:

  1. Download the latest stable release of AOCL-FFTW (amd/amd-fftw).

  2. Depending on the target system and build environment, you must enable/disable the appropriate configure options. Set PATH and LD_LIBRARY_PATH to the MPI installation. In the case of building for AMD Optimized FFTW library with AOCC compiler, you must compile and setup OpenMPI with AOCC compiler.

    Complete the following steps to compile it for EPYCTM processors and other AMD “Zen”-based processors:

    Note

    For a complete list of options and their description, type ./configure --help.

    • With GCC (default)

      **Double Precision FFTW libraries**
      
      $ ./configure --enable-sse2 --enable-avx --enable-avx2
      --enable-avx512 --enable-mpi -- enable-openmp --enable-shared
      --enable-amd-opt --enable-amd-mpifft --enable-dynamic- dispatcher
      --prefix=<your-install-dir>
      
      **Single Precision FFTW libraries**
      
      $ ./configure --enable-sse2 --enable-avx --enable-avx2
      --enable-avx512 --enable-mpi -- enable-openmp --enable-shared
      --enable-single --enable-amd-opt --enable-amd-mpifft --
      enable-dynamic-dispatcher --prefix=<your-install-dir>
      
      **Long double FFTW libraries**
      
      $ ./configure --enable-shared --enable-openmp --enable-mpi
      --enable-long-double -- enable-amd-opt --enable-amd-mpifft
      --enable-dynamic-dispatcher --prefix=<your-install- dir>
      
      **Quad Precision FFTW libraries**
      
      $ ./configure --enable-shared --enable-openmp --enable-quad-precision
      --enable-amd-opt --enable-dynamic-dispatcher --prefix=<your-install-dir>
      
    • With AOCC

      **Double Precision FFTW libraries**
      
      $ ./configure --enable-sse2 --enable-avx --enable-avx2
      --enable-avx512 --enable-mpi -- enable-openmp --enable-shared
      --enable-amd-opt --enable-amd-mpifft --enable-dynamic- dispatcher
      --prefix=<your-install-dir> CC=clang F77=flang FC=flang
      
      **Single Precision FFTW libraries**
      
      $ ./configure --enable-sse2 --enable-avx --enable-avx2
      --enable-avx512 --enable-mpi -- enable-openmp --enable-shared
      --enable-single --enable-amd-opt --enable-amd-mpifft --
      enable-dynamic-dispatcher --prefix=<your-install-dir> CC=clang
      F77=flang FC=flang
      
      **Long double FFTW libraries**
      
      $ ./configure --enable-shared --enable-openmp --enable-mpi
      --enable-long-double -- enable-amd-opt --enable-amd-mpifft
      --enable-dynamic-dispatcher --prefix=<your-install- dir> CC=clang
      F77=flang FC=flang
      
      **Quad FFTW libraries**
      
      $ ./configure --enable-shared --enable-openmp --enable-quad-precision
      --enable-amd-opt --enable-dynamic-dispatcher --prefix=<your-install-dir>
      CC=clang F77=flang FC=flang
      

    AMD optimized fast planner is added as an extension to the original planner to improve the planning time of various planning modes in general and PATIENT mode in particular.

    The configure user option --enable-amd-fast-planner when given in addition to -enable-amd-opt enables this new fast planner.

    An optional configure option AMD_ARCH is supported, that can be set to the CPU architecture values, such as auto, znver1, znver2, znver3, znver4 or znver5 for AMD EPYCTM and other AMD “Zen”- based processors.

    Additional config and build options to enable specific optimizations are covered in the AOCL Performance Tuning Guide.

    A dynamic dispatcher feature has been added to build a single portable optimized library for execution on a wide range of x86 CPU architectures. Use the–enable-dynamic-dispatcher configure option to enable this feature on Linux-based systems. The configure option –enable- amd-opt is the mandatory master optimization switch that must be set for enabling other optional configure options, such as:

    • –enable-amd-mpifft

    • –enable-amd-mpi-vader-limit

    • –enable-amd-trans

    • –enable-amd-fast-planner

    • –enable-amd-top-n-planner

    • –enable-amd-app-opt

    • –enable-dynamic-dispatcher

  3. Build the library:

    $ make
    
  4. Install the library in the preferred path:

    $ make install
    
  5. Verify the installed library:

    $ make check
    

6.1.2. Building AOCL-FFTW from Source on Windows#

AOCL-FFTW uses CMake along with Microsoft Visual Studio for building binaries from the sources on Windows. This section explains the GUI and command-line schemes for building the binaries and test suite.

Prerequisites

The following prerequisites must be met:

  • Windows 10/11 and Windows Server 2019/2022

  • A suitable MPI library installation along with the appropriate environment variables on the host machine

  • LLVM 13/14 for AMD “Zen3” support

  • LLVM plug-in for Microsoft Visual Studio (if latest version of LLVM is installed separately, this plugin enables linking Visual Studio with the installed LLVM tool-chain)

  • For more information on CMake versions validated, refer to Build Utilities

  • MPI compiler

  • Microsoft Visual Studio 2019 build 16.8.7

  • Microsoft Visual Studio tools

    • Python development

    • Desktop development with C++: C++ Clang-Cl for build tool (x64 or

      x86)

6.1.2.1. Using CMake GUI to Build#

Complete the following steps in the CMake GUI:

  1. Set the source (folder containing FFTW source code) and build (folder in which the project files will be generated, for example, out) folder paths.

  2. Click on the Configure button to prepare the project options.

  3. Set the generator to Visual Studio 16 2019 or Visual Studio 17 2022 and the compiler to ClangCl or LLVM.

  4. Update the options based on the project requirements. All the available options are listed in the following table:

    Table 6.1 AOCL-FFTW Config Options#

    Feature

    CMake Parameters

    Build type (Release or Debug mode)

    CMAKE_BUILD_TYPE=Release/Debug

    AMD CPU architecture (AMD “Zen”/AMD “Zen2”/ AMD “Zen3”/AMD “Zen4”/ AMD “Zen5”)

    AMD_ARCH: STRING=znver1/znver2/znver3/ znver4/znver5

    Shared library without multithreading

    BUILD_SHARED_LIBS=ON ENABLE_OPENMP=OFF ENABLE_THREADS=OFF

    Shared library with multithreading

    BUILD_SHARED_LIBS=ON ENABLE_OPENMP=ON

    Static library without multithreading

    BUILD_SHARED_LIBS=OFF ENABLE_OPENMP=OFF

    Static library with multithreading

    BUILD_SHARED_LIBS=OFF ENABLE_OPENMP=ON

    Use Threads instead of OpenMP for multithreading

    ENABLE_THREADS=ON WITH_COMBINED_THREADS=ON

    Use both Threads and OpenMP for multithreading

    ENABLE_THREADS=ON ENABLE_OPENMP=ON

    Flags for enhanced instruction set support

    ENABLE_SSE=ON ENABLE_SSE2=ON ENABLE_AVX=ON ENABLE_AVX2=ON ENABLE_AVX512=ON

    Flags for single and long double

    ENABLE_FLOAT=ON ENABLE_LONG_DOUBLE=ON

    Build tests directory and generate test applications

    BUILD_TESTS=ON

    Enables MPI lib

    ENABLE_MPI=ON

    Enables AMD optimizations

    ENABLE_AMD_OPT=ON

    Enables AMD MPI FFT optimizations

    ENABLE_AMD_MPIFFT=ON ENABLE_AMD_MPI_VADER_LIMIT: ON

    Enables AMD optimized transpose

    ENABLE_AMD_TRANS=ON

    Enables AMD optimizations for HPC/Scientific applications

    ENABLE_AMD_APP_OPT: ON

    Note

    ENABLE_QUAD_PRECISION is currently not supported on Windows.

    Select the available and recommended options as follows:

    _images/image14_aocl.jpeg

    Figure 6.1 AOCL-FFTW CMake Config Options#

  5. Click the Generate button and then Open Project.

6.1.2.2. Using Command-Line Arguments to Build#

Complete the following steps to trigger the project configuration and build procedures from the command prompt:

  1. In the AOCL-FFTW project folder, create a folder out. Open the command prompt in this directory and run the following command to configure the project:

    $ cmake .. -DBUILD_TESTS=ON -D[other options1] -D[other options2] -T
    ClangCl -G "Visual Studio 16 2019" && cmake --build . --config Release
    
  2. Refer to AOCL-FFTW Config Options and update the parameter options in the command according to the project requirements.

    The library files would be generated in the Release or Debug folder based on the project settings.

  3. To verify the installed library, copy the test scripts from \win\tests to \out\Release and run python fftw_check.py.

6.1.3. Using Pre-Built Libraries#

The AOCL-FFTW library binaries for Linux and Windows are available at the following URL:

https://www.amd.com/en/developer/aocl/fftw.html

The AOCL-FFTW binary for Linux and Windows can also be installed from the AOCL master installer (tar packages for Linux and zip packages for Windows) available at the following URL:

https://www.amd.com/en/developer/aocl.html

The tar and zip files include pre-built binaries of other AMD libraries as explained in Using Master Package.

Note

The pre-built libraries are prepared on a specific platform having dependencies related to OS, Compiler (GCC, Clang), MPI, Visual studio, and GLIBC. Your platform must adhere to the same versions of these dependencies to use the pre-built libraries.

6.2. Usage#

Sample programs and executable binaries demonstrating the usage of AOCL-FFTW APIs and performance benchmarking are available in tests/ and mpi/ directories for Linux and out/Release directory for Windows.

6.2.1. Sample Programs for Single-Threaded and Multi-Threaded FFTW#

To run single-threaded test, execute the following command:

$ bench -opatient -s [i|o][r|c][f|b]<size>

Where,

  • i/o means in-place or out-of-place. Out of place is the default.

  • r/c means real or complex transform. Complex is the default.

  • f/b means forward or backward transform. Forward is the default.

  • <size> is an arbitrary multidimensional sequence of integers separated by the character ‘x’.

Check the tuning guidelines for single-threaded test execution in the AOCL Performance Tuning Guide.

To run multi-threaded test, execute the following command:

$ bench -opatient -onthreads=N -s [i|o][r|c][f|b]<size>

Where, N is number of threads.

Check the tuning guidelines for multi-threaded test execution in the AOCL Performance Tuning Guide.

6.2.2. Sample Programs for MPI FFTW#

$ mpirun -np N mpi-bench -opatient -s [i|o][r|c][f|b]<size>

Where, N is the number of processes.

Check the tuning guidelines for MPI test execution in the AOCL Performance Tuning Guide.

6.2.3. Additional Options#

  • -owisdom

    On startup, read wisdom from the file wis.dat in the current directory (if it exists).

    On completion, write accumulated wisdom to wis.dat (overwriting if file exists).

    This bypasses the planner next time onwards and directly executes the read plan from wisdom.

  • –verify <problem>

    Verify that AOCL-FFTW is computing correctly. It does not output anything unless there is an error.

  • -v<n>

    Set verbosity to <n> or 1 if <n> is omitted. -v2 will output the created plans.

Note

  1. The names of windows FFTW test bench application has .exe extension (bench.exe and mpi- bench.exe).

  2. The folder /win/tests/ includes Windows benchmark scripts for single-threaded, multi- threaded and MPI FFT execution for standard sizes. A README file is also provided with the instructions to run these benchmark scripts.

To display the AOCL version number of AOCL-FFTW library, application must call the following FFTW API fftw_aoclversion().

The test bench executables of AOCL-FFTW support the display of AOCL version using the --info-all option.