fft-support.texi 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. @subsection Initialisation
  45. @deftypefun {void *} starpufft_malloc (size_t @var{n})
  46. Allocates memory for @var{n} bytes. This is preferred over @code{malloc}, since
  47. it allocates pinned memory, which allows overlapped transfers.
  48. @end deftypefun
  49. @deftypefun {void *} starpufft_free (void *@var{p})
  50. Release memory previously allocated.
  51. @end deftypefun
  52. @deftypefun {struct starpufft_plan *} starpufft_plan_dft_1d (int @var{n}, int @var{sign}, unsigned @var{flags})
  53. Initializes a plan for 1D FFT of size @var{n}. @var{sign} can be
  54. @code{STARPUFFT_FORWARD} or @code{STARPUFFT_INVERSE}. @var{flags} must be 0.
  55. @end deftypefun
  56. @deftypefun {struct starpufft_plan *} starpufft_plan_dft_2d (int @var{n}, int @var{m}, int @var{sign}, unsigned @var{flags})
  57. Initializes a plan for 2D FFT of size (@var{n}, @var{m}). @var{sign} can be
  58. @code{STARPUFFT_FORWARD} or @code{STARPUFFT_INVERSE}. @var{flags} must be 0.
  59. @end deftypefun
  60. @deftypefun {struct starpu_task *} starpufft_start (starpufft_plan @var{p}, void *@var{in}, void *@var{out})
  61. Start an FFT previously planned as @var{p}, using @var{in} and @var{out} as
  62. input and output. This only submits the task and does not wait for it.
  63. The application should call @code{starpufft_cleanup} to unregister the data.
  64. @end deftypefun
  65. @deftypefun {struct starpu_task *} starpufft_start_handle (starpufft_plan @var{p}, starpu_data_handle_t @var{in}, starpu_data_handle_t @var{out})
  66. Start an FFT previously planned as @var{p}, using data handles @var{in} and
  67. @var{out} as input and output (assumed to be vectors of elements of the expected
  68. types). This only submits the task and does not wait for it.
  69. @end deftypefun
  70. @deftypefun void starpufft_execute (starpufft_plan @var{p}, void *@var{in}, void *@var{out})
  71. Execute an FFT previously planned as @var{p}, using @var{in} and @var{out} as
  72. input and output. This submits and waits for the task.
  73. @end deftypefun
  74. @deftypefun void starpufft_execute_handle (starpufft_plan @var{p}, starpu_data_handle_t @var{in}, starpu_data_handle_t @var{out})
  75. Execute an FFT previously planned as @var{p}, using data handles @var{in} and
  76. @var{out} as input and output (assumed to be vectors of elements of the expected
  77. types). This submits and waits for the task.
  78. @end deftypefun
  79. @deftypefun void starpufft_cleanup (starpufft_plan @var{p})
  80. Releases data for plan @var{p}, in the @code{starpufft_start} case.
  81. @end deftypefun
  82. @deftypefun void starpufft_destroy_plan (starpufft_plan @var{p})
  83. Destroys plan @var{p}, i.e. release all CPU (fftw) and GPU (cufft) resources.
  84. @end deftypefun