mirror of
https://github.com/tildearrow/furnace.git
synced 2024-12-20 23:40:23 +00:00
139 lines
7.1 KiB
HTML
139 lines
7.1 KiB
HTML
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||
|
<html>
|
||
|
<!-- This manual is for FFTW
|
||
|
(version 3.3.10, 10 December 2020).
|
||
|
|
||
|
Copyright (C) 2003 Matteo Frigo.
|
||
|
|
||
|
Copyright (C) 2003 Massachusetts Institute of Technology.
|
||
|
|
||
|
Permission is granted to make and distribute verbatim copies of this
|
||
|
manual provided the copyright notice and this permission notice are
|
||
|
preserved on all copies.
|
||
|
|
||
|
Permission is granted to copy and distribute modified versions of this
|
||
|
manual under the conditions for verbatim copying, provided that the
|
||
|
entire resulting derived work is distributed under the terms of a
|
||
|
permission notice identical to this one.
|
||
|
|
||
|
Permission is granted to copy and distribute translations of this manual
|
||
|
into another language, under the above conditions for modified versions,
|
||
|
except that this permission notice may be stated in a translation
|
||
|
approved by the Free Software Foundation. -->
|
||
|
<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||
|
<title>Plan execution in Fortran (FFTW 3.3.10)</title>
|
||
|
|
||
|
<meta name="description" content="Plan execution in Fortran (FFTW 3.3.10)">
|
||
|
<meta name="keywords" content="Plan execution in Fortran (FFTW 3.3.10)">
|
||
|
<meta name="resource-type" content="document">
|
||
|
<meta name="distribution" content="global">
|
||
|
<meta name="Generator" content="makeinfo">
|
||
|
<link href="index.html" rel="start" title="Top">
|
||
|
<link href="Concept-Index.html" rel="index" title="Concept Index">
|
||
|
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
||
|
<link href="Calling-FFTW-from-Modern-Fortran.html" rel="up" title="Calling FFTW from Modern Fortran">
|
||
|
<link href="Allocating-aligned-memory-in-Fortran.html" rel="next" title="Allocating aligned memory in Fortran">
|
||
|
<link href="FFTW-Fortran-type-reference.html" rel="prev" title="FFTW Fortran type reference">
|
||
|
<style type="text/css">
|
||
|
<!--
|
||
|
a.summary-letter {text-decoration: none}
|
||
|
blockquote.indentedblock {margin-right: 0em}
|
||
|
div.display {margin-left: 3.2em}
|
||
|
div.example {margin-left: 3.2em}
|
||
|
div.lisp {margin-left: 3.2em}
|
||
|
kbd {font-style: oblique}
|
||
|
pre.display {font-family: inherit}
|
||
|
pre.format {font-family: inherit}
|
||
|
pre.menu-comment {font-family: serif}
|
||
|
pre.menu-preformatted {font-family: serif}
|
||
|
span.nolinebreak {white-space: nowrap}
|
||
|
span.roman {font-family: initial; font-weight: normal}
|
||
|
span.sansserif {font-family: sans-serif; font-weight: normal}
|
||
|
ul.no-bullet {list-style: none}
|
||
|
-->
|
||
|
</style>
|
||
|
|
||
|
|
||
|
</head>
|
||
|
|
||
|
<body lang="en">
|
||
|
<span id="Plan-execution-in-Fortran"></span><div class="header">
|
||
|
<p>
|
||
|
Next: <a href="Allocating-aligned-memory-in-Fortran.html" accesskey="n" rel="next">Allocating aligned memory in Fortran</a>, Previous: <a href="FFTW-Fortran-type-reference.html" accesskey="p" rel="prev">FFTW Fortran type reference</a>, Up: <a href="Calling-FFTW-from-Modern-Fortran.html" accesskey="u" rel="up">Calling FFTW from Modern Fortran</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
|
||
|
</div>
|
||
|
<hr>
|
||
|
<span id="Plan-execution-in-Fortran-1"></span><h3 class="section">7.4 Plan execution in Fortran</h3>
|
||
|
|
||
|
<p>In C, in order to use a plan, one normally calls <code>fftw_execute</code>,
|
||
|
which executes the plan to perform the transform on the input/output
|
||
|
arrays passed when the plan was created (see <a href="Using-Plans.html">Using Plans</a>). The
|
||
|
corresponding subroutine call in modern Fortran is:
|
||
|
</p><div class="example">
|
||
|
<pre class="example"> call fftw_execute(plan)
|
||
|
</pre></div>
|
||
|
<span id="index-fftw_005fexecute-6"></span>
|
||
|
|
||
|
<p>However, we have had reports that this causes problems with some
|
||
|
recent optimizing Fortran compilers. The problem is, because the
|
||
|
input/output arrays are not passed as explicit arguments to
|
||
|
<code>fftw_execute</code>, the semantics of Fortran (unlike C) allow the
|
||
|
compiler to assume that the input/output arrays are not changed by
|
||
|
<code>fftw_execute</code>. As a consequence, certain compilers end up
|
||
|
repositioning the call to <code>fftw_execute</code>, assuming incorrectly
|
||
|
that it does nothing to the arrays.
|
||
|
</p>
|
||
|
<p>There are various workarounds to this, but the safest and simplest
|
||
|
thing is to not use <code>fftw_execute</code> in Fortran. Instead, use the
|
||
|
functions described in <a href="New_002darray-Execute-Functions.html">New-array Execute Functions</a>, which take
|
||
|
the input/output arrays as explicit arguments. For example, if the
|
||
|
plan is for a complex-data DFT and was created for the arrays
|
||
|
<code>in</code> and <code>out</code>, you would do:
|
||
|
</p><div class="example">
|
||
|
<pre class="example"> call fftw_execute_dft(plan, in, out)
|
||
|
</pre></div>
|
||
|
<span id="index-fftw_005fexecute_005fdft-3"></span>
|
||
|
|
||
|
<p>There are a few things to be careful of, however:
|
||
|
</p>
|
||
|
<ul>
|
||
|
<li> <span id="index-fftw_005fexecute_005fdft_005fr2c-2"></span>
|
||
|
<span id="index-fftw_005fexecute_005fdft_005fc2r-1"></span>
|
||
|
<span id="index-fftw_005fexecute_005fr2r-1"></span>
|
||
|
You must use the correct type of execute function, matching the way
|
||
|
the plan was created. Complex DFT plans should use
|
||
|
<code>fftw_execute_dft</code>, Real-input (r2c) DFT plans should use use
|
||
|
<code>fftw_execute_dft_r2c</code>, and real-output (c2r) DFT plans should
|
||
|
use <code>fftw_execute_dft_c2r</code>. The various r2r plans should use
|
||
|
<code>fftw_execute_r2r</code>. Fortunately, if you use the wrong one you
|
||
|
will get a compile-time type-mismatch error (unlike legacy Fortran).
|
||
|
|
||
|
</li><li> You should normally pass the same input/output arrays that were used when
|
||
|
creating the plan. This is always safe.
|
||
|
|
||
|
</li><li> <em>If</em> you pass <em>different</em> input/output arrays compared to
|
||
|
those used when creating the plan, you must abide by all the
|
||
|
restrictions of the new-array execute functions (see <a href="New_002darray-Execute-Functions.html">New-array Execute Functions</a>). The most tricky of these is the
|
||
|
requirement that the new arrays have the same alignment as the
|
||
|
original arrays; the best (and possibly only) way to guarantee this
|
||
|
is to use the ‘<samp>fftw_alloc</samp>’ functions to allocate your arrays (see <a href="Allocating-aligned-memory-in-Fortran.html">Allocating aligned memory in Fortran</a>). Alternatively, you can
|
||
|
use the <code>FFTW_UNALIGNED</code> flag when creating the
|
||
|
plan, in which case the plan does not depend on the alignment, but
|
||
|
this may sacrifice substantial performance on architectures (like x86)
|
||
|
with SIMD instructions (see <a href="SIMD-alignment-and-fftw_005fmalloc.html">SIMD alignment and fftw_malloc</a>).
|
||
|
<span id="index-FFTW_005fUNALIGNED-2"></span>
|
||
|
|
||
|
</li></ul>
|
||
|
|
||
|
<hr>
|
||
|
<div class="header">
|
||
|
<p>
|
||
|
Next: <a href="Allocating-aligned-memory-in-Fortran.html" accesskey="n" rel="next">Allocating aligned memory in Fortran</a>, Previous: <a href="FFTW-Fortran-type-reference.html" accesskey="p" rel="prev">FFTW Fortran type reference</a>, Up: <a href="Calling-FFTW-from-Modern-Fortran.html" accesskey="u" rel="up">Calling FFTW from Modern Fortran</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
</body>
|
||
|
</html>
|