fft-support.texi 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. @c -*-texinfo-*-
  2. @c This file is part of the StarPU Handbook.
  3. @c Copyright (C) 2009--2011 Universit@'e de Bordeaux 1
  4. @c Copyright (C) 2010, 2011, 2012 Centre National de la Recherche Scientifique
  5. @c Copyright (C) 2011 Institut National de Recherche en Informatique et Automatique
  6. @c See the file starpu.texi for copying conditions.
  7. StarPU provides @code{libstarpufft}, a library whose design is very similar to
  8. both fftw and cufft, the difference being that it takes benefit from both CPUs
  9. and GPUs. It should however be noted that GPUs do not have the same precision as
  10. CPUs, so the results may different by a negligible amount
  11. float, double and long double precisions are available, with the fftw naming
  12. convention:
  13. @enumerate
  14. @item double precision structures and functions are named e.g. @code{starpufft_execute}
  15. @item float precision structures and functions are named e.g. @code{starpufftf_execute}
  16. @item long double precision structures and functions are named e.g. @code{starpufftl_execute}
  17. @end enumerate
  18. The documentation below uses names for double precision, replace
  19. @code{starpufft_} with @code{starpufftf_} or @code{starpufftl_} as appropriate.
  20. Only complex numbers are supported at the moment.
  21. The application has to call @code{starpu_init} before calling starpufft functions.
  22. Either main memory pointers or data handles can be provided.
  23. @enumerate
  24. @item To provide main memory pointers, use @code{starpufft_start} or
  25. @code{starpufft_execute}. Only one FFT can be performed at a time, because
  26. StarPU will have to register the data on the fly. In the @code{starpufft_start}
  27. case, @code{starpufft_cleanup} needs to be called to unregister the data.
  28. @item To provide data handles (which is preferrable),
  29. use @code{starpufft_start_handle} (preferred) or
  30. @code{starpufft_execute_handle}. Several FFTs Several FFT tasks can be submitted
  31. for a given plan, which permits e.g. to start a series of FFT with just one
  32. plan. @code{starpufft_start_handle} is preferrable since it does not wait for
  33. the task completion, and thus permits to enqueue a series of tasks.
  34. @end enumerate
  35. @section Compilation
  36. The flags required to compile or link against the FFT library are accessible
  37. with the following commands:
  38. @example
  39. % pkg-config --cflags starpufft-1.0 # options for the compiler
  40. % pkg-config --libs starpufft-1.0 # options for the linker
  41. @end example
  42. Also pass the @code{--static} option if the application is to be linked statically.
  43. @section Initialisation
  44. @deftypefun {void *} starpufft_malloc (size_t @var{n})
  45. Allocates memory for @var{n} bytes. This is preferred over @code{malloc}, since
  46. it allocates pinned memory, which allows overlapped transfers.
  47. @end deftypefun
  48. @deftypefun {void *} starpufft_free (void *@var{p})
  49. Release memory previously allocated.
  50. @end deftypefun
  51. @deftypefun {struct starpufft_plan *} starpufft_plan_dft_1d (int @var{n}, int @var{sign}, unsigned @var{flags})
  52. Initializes a plan for 1D FFT of size @var{n}. @var{sign} can be
  53. @code{STARPUFFT_FORWARD} or @code{STARPUFFT_INVERSE}. @var{flags} must be 0.
  54. @end deftypefun
  55. @deftypefun {struct starpufft_plan *} starpufft_plan_dft_2d (int @var{n}, int @var{m}, int @var{sign}, unsigned @var{flags})
  56. Initializes a plan for 2D FFT of size (@var{n}, @var{m}). @var{sign} can be
  57. @code{STARPUFFT_FORWARD} or @code{STARPUFFT_INVERSE}. @var{flags} must be 0.
  58. @end deftypefun
  59. @deftypefun {struct starpu_task *} starpufft_start (starpufft_plan @var{p}, void *@var{in}, void *@var{out})
  60. Start an FFT previously planned as @var{p}, using @var{in} and @var{out} as
  61. input and output. This only submits the task and does not wait for it.
  62. The application should call @code{starpufft_cleanup} to unregister the data.
  63. @end deftypefun
  64. @deftypefun {struct starpu_task *} starpufft_start_handle (starpufft_plan @var{p}, starpu_data_handle_t @var{in}, starpu_data_handle_t @var{out})
  65. Start an FFT previously planned as @var{p}, using data handles @var{in} and
  66. @var{out} as input and output (assumed to be vectors of elements of the expected
  67. types). This only submits the task and does not wait for it.
  68. @end deftypefun
  69. @deftypefun void starpufft_execute (starpufft_plan @var{p}, void *@var{in}, void *@var{out})
  70. Execute an FFT previously planned as @var{p}, using @var{in} and @var{out} as
  71. input and output. This submits and waits for the task.
  72. @end deftypefun
  73. @deftypefun void starpufft_execute_handle (starpufft_plan @var{p}, starpu_data_handle_t @var{in}, starpu_data_handle_t @var{out})
  74. Execute an FFT previously planned as @var{p}, using data handles @var{in} and
  75. @var{out} as input and output (assumed to be vectors of elements of the expected
  76. types). This submits and waits for the task.
  77. @end deftypefun
  78. @deftypefun void starpufft_cleanup (starpufft_plan @var{p})
  79. Releases data for plan @var{p}, in the @code{starpufft_start} case.
  80. @end deftypefun
  81. @deftypefun void starpufft_destroy_plan (starpufft_plan @var{p})
  82. Destroys plan @var{p}, i.e. release all CPU (fftw) and GPU (cufft) resources.
  83. @end deftypefun