FFTW_MT

Usage

use FFTW_MT;

Multi-threaded FFT computations via FFTW (version 3)

This module defines Chapel wrappers around key FFTW routines supporting multithreaded execution. It builds directly on the FFTW module, inheriting all of its functionality, so refer to that module for documentation on the transforms themselves.

To use this module:

  1. Ensure that FFTW (version 3) is installed on your system with multi-threaded support enabled and that the header and library files (e.g., fftw3.h, libfftw3.*) are either installed in a standard system location or that your C compiler's environment variables are set up to find them (alternatively, the Chapel compiler's -I and -L flags can be used to specify these locations).
  2. Add use FFTW_MT; to your Chapel code.
  3. Compile and run your Chapel program as usual.

The steps to making multi-threaded FFTW calls are:

  1. By default, the module will initialize itself to use here.maxTaskPar threads per locale when calling plan_dft* routines. This auto-initialization can be disabled by setting autoInitFFTW_MT to false at compile-time and calling init_FFTW_MT and plan_with_nthreads manually. At any time during program execution, the number of threads to be used by FFTW can be changed by calling plan_with_nthreads with a new value.
  2. Create, ...
  3. execute, ...
  4. ...and destroy plans as in single-threaded uses of FFTW.
  5. Call cleanup_threads to release the memory used by FFTW's threads and cleanup as in single-threaded uses of FFTW.

Note that where the main FFTW module is a single-locale module, this one is multi-locale in that, once it is initialized, any locale can create and execute plans, though those plans will only be valid on that locale. Calls to init_FFTW_MT, plan_with_nthreads and cleanup_threads will take those actions across all locales.

config param autoInitFFTW_MT = true

By default, this module will call init_FFTW_MT() and plan_with_nthreads() as part of its initialization. Setting this to false at compile-time will disable this auto-initialization, requiring these calls to be made manually.

proc init_FFTW_MT()

Initialize the FFTW_MT module. This has the effect of calling the FFTW C routine fftw_init_threads() on all locales, halting the Chapel program if any of the calls generate an error.

proc plan_with_nthreads(nthreads: int = 0)

Register the number of threads to use for multi-threaded FFTW plans on all locales. If fewer than one thread is requested, each locale will default to here.maxTaskPar threads. Note that this routine can be called multiple times, overwriting previous values.

Arguments:nthreads : int -- The number of threads to use.
proc cleanup_threads()

Clean up the memory used by FFTW threads on all locales.