Node:Using Plans, Next:, Previous:Data Types and Files, Up:FFTW Reference



4.2 Using Plans

Plans for all transform types in FFTW are stored as type fftw_plan (an opaque pointer type), and are created by one of the various planning routines described in the following sections. An fftw_plan contains all information necessary to compute the transform, including the pointers to the input and output arrays.

void fftw_execute(const fftw_plan plan);

This executes the plan, to compute the corresponding transform on the arrays for which it was planned (which must still exist). The plan is not modified, and fftw_execute can be called as many times as desired.

To apply a given plan to a different array, you can use the guru interface. See Guru Interface.

fftw_execute (and equivalents) is the only function in FFTW guaranteed to be thread-safe; see Thread safety.

This function:

void fftw_destroy_plan(fftw_plan plan);
deallocates the plan and all its associated data.

FFTW's planner saves some other persistent data, such as the accumulated wisdom and a list of algorithms available in the current configuration. If you want to deallocate all of that and reset FFTW to the pristine state it was in when you started your program, you can call:

void fftw_cleanup(void);

This does not deallocate your plans; you should still call fftw_destroy_plan if you want to do this. You should not execute any previously created plans after calling fftw_cleanup, however.

The following two routines are provided purely for academic purposes (that is, for entertainment).

void fftw_flops(const fftw_plan plan, double *add, double *mul, double *fma);

Given a plan, set add, mul, and fma to an exact count of the number of floating-point additions, multiplications, and fused multiply-add operations involved in the plan's execution. The total number of floating-point operations (flops) is add + mul + 2*fma, or add + mul + fma if the hardware supports fused multiply-add instructions (although the number of FMA operations is only approximate because of compiler voodoo). (The number of operations should be an integer, but we use double to avoid overflowing int for large transforms; the arguments are of type double even for single and long-double precision versions of FFTW.)

void fftw_fprint_plan(const fftw_plan plan, FILE *output_file);
void fftw_print_plan(const fftw_plan plan);

This outputs a "nerd-readable" representation of the plan to the given file or to stdout, respectively.