fft-support.texi 4.9 KB

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