Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: FFTW 3.3.5: Using Plans Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: Chris@42:
Chris@42:

Chris@42: Next: , Previous: , Up: FFTW Reference   [Contents][Index]

Chris@42:
Chris@42:
Chris@42: Chris@42:

4.2 Using Plans

Chris@42: Chris@42:

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

Chris@42:
Chris@42:
void fftw_execute(const fftw_plan plan);
Chris@42: 
Chris@42: Chris@42: Chris@42:

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

Chris@42:

To apply a given plan to a different array, you can use the new-array execute Chris@42: interface. See New-array Execute Functions. Chris@42:

Chris@42:

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

Chris@42:

This function: Chris@42:

Chris@42:
void fftw_destroy_plan(fftw_plan plan);
Chris@42: 
Chris@42: Chris@42:

deallocates the plan and all its associated data. Chris@42:

Chris@42:

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

Chris@42:
Chris@42:
void fftw_cleanup(void);
Chris@42: 
Chris@42: Chris@42: Chris@42:

After calling fftw_cleanup, all existing plans become undefined, Chris@42: and you should not attempt to execute them nor to destroy them. You can Chris@42: however create and execute/destroy new plans, in which case FFTW starts Chris@42: accumulating wisdom information again. Chris@42:

Chris@42:

fftw_cleanup does not deallocate your plans, however. To prevent Chris@42: memory leaks, you must still call fftw_destroy_plan before Chris@42: executing fftw_cleanup. Chris@42:

Chris@42:

Occasionally, it may useful to know FFTW’s internal “cost” metric Chris@42: that it uses to compare plans to one another; this cost is Chris@42: proportional to an execution time of the plan, in undocumented units, Chris@42: if the plan was created with the FFTW_MEASURE or other Chris@42: timing-based options, or alternatively is a heuristic cost function Chris@42: for FFTW_ESTIMATE plans. (The cost values of measured and Chris@42: estimated plans are not comparable, being in different units. Also, Chris@42: costs from different FFTW versions or the same version compiled Chris@42: differently may not be in the same units. Plans created from wisdom Chris@42: have a cost of 0 since no timing measurement is performed for them. Chris@42: Finally, certain problems for which only one top-level algorithm was Chris@42: possible may have required no measurements of the cost of the whole Chris@42: plan, in which case fftw_cost will also return 0.) The cost Chris@42: metric for a given plan is returned by: Chris@42:

Chris@42:
Chris@42:
double fftw_cost(const fftw_plan plan);
Chris@42: 
Chris@42: Chris@42: Chris@42:

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

Chris@42:
Chris@42:
void fftw_flops(const fftw_plan plan, 
Chris@42:                 double *add, double *mul, double *fma);
Chris@42: 
Chris@42: Chris@42: Chris@42:

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

Chris@42:
Chris@42:
void fftw_fprint_plan(const fftw_plan plan, FILE *output_file);
Chris@42: void fftw_print_plan(const fftw_plan plan);
Chris@42: char *fftw_sprint_plan(const fftw_plan plan);
Chris@42: 
Chris@42: Chris@42: Chris@42: Chris@42:

This outputs a “nerd-readable” representation of the plan to Chris@42: the given file, to stdout, or two a newly allocated Chris@42: NUL-terminated string (which the caller is responsible for deallocating Chris@42: with free), respectively. Chris@42:

Chris@42:
Chris@42:
Chris@42:

Chris@42: Next: , Previous: , Up: FFTW Reference   [Contents][Index]

Chris@42:
Chris@42: Chris@42: Chris@42: Chris@42: Chris@42: