Skip to content

Commit

Permalink
added fftw_cost function; this is the second time people have asked f…
Browse files Browse the repository at this point in the history
…or this, and there is a reasonable use for it in comparing e.g. oout-of-place vs. in-place plans

[empty commit message]
  • Loading branch information
stevengj committed Mar 30, 2010
1 parent 101fc17 commit 7be5dbd
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* New function fftw_cost to return FFTW's internal cost metric for
a given plan; thanks to Rhys Ulerich and Nathanael Schaeffer for the
suggestion.

FFTW 3.2.2

* Improve performance of some copy operations of complex arrays on
Expand Down
10 changes: 10 additions & 0 deletions api/f77funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ FFTW_VOIDFUNC F77(flops,FLOPS)(X(plan) *p, double *add, double *mul, double *fma
X(flops)(*p, add, mul, fma);
}

FFTW_VOIDFUNC F77(estimate_cost,ESTIMATE_COST)(double *cost, X(plan) * const p)
{
*cost = X(estimate_cost)(*p);
}

FFTW_VOIDFUNC F77(cost,COST)(double *cost, X(plan) * const p)
{
*cost = X(cost)(*p);
}

/******************************** DFT ***********************************/

FFTW_VOIDFUNC F77(plan_dft, PLAN_DFT)(X(plan) *p, int *rank, const int *n,
Expand Down
1 change: 1 addition & 0 deletions api/fftw3.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ FFTW_EXTERN void X(free)(void *p); \
FFTW_EXTERN void X(flops)(const X(plan) p, \
double *add, double *mul, double *fmas); \
FFTW_EXTERN double X(estimate_cost)(const X(plan) p); \
FFTW_EXTERN double X(cost)(const X(plan) p); \
\
FFTW_EXTERN const char X(version)[]; \
FFTW_EXTERN const char X(cc)[]; \
Expand Down
5 changes: 5 additions & 0 deletions api/flops.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ double X(estimate_cost)(const X(plan) p)
{
return X(iestimate_cost)(X(the_planner)(), p->pln, p->prb);
}

double X(cost)(const X(plan) p)
{
return p->pln->pcost;
}
17 changes: 17 additions & 0 deletions doc/fftw3.texi
Original file line number Diff line number Diff line change
Expand Up @@ -1951,6 +1951,23 @@ accumulating wisdom information again.
memory leaks, you must still call @code{fftw_destroy_plan} before
executing @code{fftw_cleanup}.
Occasionally, it may useful to know FFTW's internal ``cost'' metric
that it uses to compare plans to one another; this cost is
proportional to an execution time of the plan, in undocumented units,
if the plan was created with the @code{FFTW_MEASURE} or other
timing-based options, or alternatively is a heuristic cost function
for @code{FFTW_EXECUTE} plans. (The cost values of measured and
estimated plans are not comparable, being in different units. Also,
costs from different FFTW versions or the same version compiled
differently may not be in the same units. Plans created from wisdom
have a cost of 0 since no timing measurement is performed for them.)
The cost metric for a given plan is returned by:
@example
double fftw_cost(const fftw_plan plan);
@end example
@findex fftw_cost
The following two routines are provided purely for academic purposes
(that is, for entertainment).
Expand Down

0 comments on commit 7be5dbd

Please sign in to comment.