├── .github
└── workflows
│ └── main.yaml
├── .gitignore
├── .travis.yml
├── LICENSE
├── MANIFEST.in
├── README.rst
├── check_tag.sh
├── depends
└── install_pfft.sh
├── docs
├── Makefile
├── apidoc.sh
├── conf.py
├── index.rst
└── pfft.rst
├── examples
├── elasticwave.py
└── example.py
├── pfft
├── __init__.py
├── core.pyx
├── libmpi.pxd
├── tests
│ ├── __init__.py
│ └── test_pfft.py
└── version.py
├── pyproject.toml
├── runtests.py
├── scripts
└── pfft-roundtrip-matrix.py
└── setup.py
/.github/workflows/main.yaml:
--------------------------------------------------------------------------------
1 | # main test workflow; ported from .travis.yaml
2 | name: main
3 |
4 | on:
5 | push:
6 | branches: [ '*', $default-branch ]
7 | pull_request:
8 | branches: [ $default-branch ]
9 |
10 | jobs:
11 | build:
12 | runs-on: ubuntu-latest
13 | defaults:
14 | run:
15 | shell: bash -l {0}
16 | strategy:
17 | matrix:
18 | python-version: ['3.10', '3.12']
19 | steps:
20 | - name: Checkout source code
21 | uses: actions/checkout@v4
22 | - name: Install build deps
23 | run: |
24 | sudo apt-get update
25 | sudo apt-get -y install openmpi-bin libopenmpi-dev
26 | - name: Setup Python
27 | uses: actions/setup-python@v5
28 | with:
29 | python-version: ${{ matrix.python-version }}
30 | - name: Build
31 | run: |
32 | python -m pip install setuptools wheel nose mpi4py numpy cython build runtests
33 | python -m build
34 | - name: Install
35 | run: |
36 | python -m pip install `ls dist/pfft_python*.whl`
37 | - name: Unit tests
38 | run: |
39 | python ./runtests.py --mpirun="mpirun -np 4"
40 | - name: Roundtrips
41 | run: |
42 | mpirun -n 1 python $PWD/scripts/pfft-roundtrip-matrix.py -v -diag -Nproc 1 1 -Nmesh 13 15 16
43 | mpirun -n 2 python $PWD/scripts/pfft-roundtrip-matrix.py -v -diag -Nproc 2 1 -Nproc 1 2 -Nmesh 13 15 16
44 | #Not enough slots o github for this test.
45 | # mpirun -n 4 python $PWD/scripts/pfft-roundtrip-matrix.py -v -diag -Nproc 2 2 -Nmesh 13 15 16
46 | # mpirun -n 4 python $PWD/scripts/pfft-roundtrip-matrix.py -v -diag -Nproc 2 2 -Nmesh 13 15
47 | - name: Version
48 | run: |
49 | bash check_tag.sh pfft/version.py
50 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | build/
2 | *.pyc
3 | *.so
4 | tmp-*/
5 | pfft/core.c
6 | *.tar.gz
7 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 |
2 | # http://travis-ci.org/mpi4py/mpi4py
3 |
4 | language: python
5 | python:
6 | - 2.7
7 | - 3.7
8 |
9 | env:
10 | - NUMPY_VERSION=1.15
11 |
12 | cache:
13 | directories:
14 | - $TRAVIS_BUILD_DIR/tmp-pfft-1.0.8-alpha2-fftw3
15 |
16 | before_install:
17 | - wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh
18 | - chmod +x miniconda.sh
19 | - ./miniconda.sh -b -p $HOME/miniconda
20 | - export PATH=$HOME/miniconda/bin:$PATH
21 | - conda update --yes conda
22 |
23 | install:
24 | - conda create --yes -n test python=$TRAVIS_PYTHON_VERSION gcc_linux-64
25 | - source activate test
26 | - conda install --yes numpy=$NUMPY_VERSION nose cython
27 | - conda install --yes -c bccp mpi4py mpich
28 | - python setup.py install
29 | - ls $TRAVIS_BUILD_DIR/
30 |
31 | script:
32 | - pip install runtests
33 | - python ./runtests.py --mpirun="mpirun -np 4"
34 | - mpirun -n 1 python $PWD/scripts/pfft-roundtrip-matrix.py -v -diag -Nproc 1 1 -Nmesh 13 15 16
35 | - mpirun -n 2 python $PWD/scripts/pfft-roundtrip-matrix.py -v -diag -Nproc 2 1 -Nproc 1 2 -Nmesh 13 15 16
36 | - mpirun -n 4 python $PWD/scripts/pfft-roundtrip-matrix.py -v -diag -Nproc 2 2 -Nmesh 13 15 16
37 | - mpirun -n 4 python $PWD/scripts/pfft-roundtrip-matrix.py -v -diag -Nproc 2 2 -Nmesh 13 15
38 | - bash check_tag.sh pfft/version.py
39 |
40 | deploy:
41 | - provider: pypi
42 | distributions: sdist
43 | user: "rainwoodman"
44 | password:
45 | secure: "X1hq86ef/mw184w1lKs5ZnGXXaA9kFJK8A22Ny5K/n6BRSdQkBfkU1gDliT/HKFkH4P1ect4CiFvqokfcydQARMkQIXAaA7d29zqbO3KBAk6keuexh/EFiDBg6I9ZoleZ9oIAbNsXKtFs5bZcTqK2yUSrc8D264+Y9z0mtOxeoDM2+vW+sPgAYEsf0R8svyl/88JgXTcu4BcgRBa+vsFMDBp5BPcryiQUpR6vADyjIXlCRHH/aPAMjU4pPA+m1J0/Thya05JtfcLMsXMshWKAcEYWvqPXFNNDMbxrmGDnSZp4FyMmQw2PJ2U93BZZ0cgQW0qEhMfa3fPehpc0Wtv7jnpkrO8Bi8HmZ+5SDNDNbNi8Pp9uUXcshU2jqtss/5IOjJN0PmXH8MVcHs3eow3geZyaMjUm1su6gV7MDMp505Iv3BM+H/xlwljJerfmK+q6tVoJLzHx7UIyKptPQiJXHzhMW+or1ztPvnqaP02CxwvhEMs8OgzQvdKQSixcrCV1U844f8/kTXQW2p/guejGlBH1DdH6Wgdg0i8gAp9sYOgKtpQH3TYtgh+mxbr9bzuW7YtNvtWHfEOd8eR/iTMmuwV5RNtaBC4optx+y2vAF/M96Mky7jtA3ohU6rdDHDh09sljyJcW0dwmzdYeuN/ulBjLyaBa6IviS2pV1NQoZk="
46 | on:
47 | tags : true
48 | condition : $TRAVIS_PYTHON_VERSION = "2.7"
49 | #notifications:
50 | # email: false
51 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/MANIFEST.in:
--------------------------------------------------------------------------------
1 | include depends/install_pfft.sh
2 | include depends/pfft-1.0.8-alpha2-fftw3.tar.gz
3 | include pfft/*.pyx
4 | include tests/*.py
5 | include pfft/*.pxd
6 |
--------------------------------------------------------------------------------
/README.rst:
--------------------------------------------------------------------------------
1 | pfft-python
2 | ===========
3 |
4 | Python binding of PFFT. (github.com/mpip/pfft)
5 |
6 | PFFT is a massively parallel Fast Fourier Transform library. For its
7 | performance, see:
8 |
9 | https://www-user.tu-chemnitz.de/~potts/workgroup/pippig/software.php.en
10 |
11 | This is the python binding of PFFT.
12 | The API document is at
13 |
14 | http://rainwoodman.github.io/pfft-python/index.html
15 |
16 | .. image:: https://api.travis-ci.org/rainwoodman/pfft-python.svg
17 | :alt: Build Status
18 | :target: https://travis-ci.org/rainwoodman/pfft-python/
19 |
20 |
21 | DOI of pfft-python:
22 |
23 | .. image:: https://zenodo.org/badge/26140163.svg
24 | :target: https://zenodo.org/badge/latestdoi/26140163
25 |
26 | PFFT is a FFT library with excellent scaling at large number of processors.
27 | We have been routinely running 10,000 ** 3 transforms on 81,000 MPI ranks as
28 | a component of the BlueTides simulation at National Center for Supercomputing
29 | Applications. This is beyond our knowledge of the limits of FFTW.
30 |
31 | This Python binding of course cannot yet operate at such a large scale. Due
32 | to the limitations of Python packaging and moduling system.
33 | We nevertheless feel it is important to develop a python binding of PFFT to
34 | allow early exploration of a migration into scripting languages in super computing.
35 |
36 |
37 | For example, we have build a particle-mesh solver at
38 |
39 | http://github.com/rainwoodman/pmesh
40 |
41 | For some leverage of the python import problem, see `python-mpi-bcast` at
42 |
43 | http://github.com/rainwoodman/python-mpi-bcast
44 |
45 | pfft-python requires mpi4py for installation.
46 |
47 | To install from PyPI:
48 |
49 | .. code::
50 |
51 | pip --user pfft-python
52 |
53 | To install from git source
54 |
55 | .. code::
56 |
57 | python setup.py install --user
58 |
59 | PFFT, patched FFTW, and the binding are linked into one giant (6MB) shared
60 | object file. We use `-fvisibility=hidden` to hide the PFFT/FFTW symbols.
61 |
62 | For Macs with Anaconda, due to this bug https://github.com/conda/conda/issues/2277
63 | one needs to make a symlink from the anaconda installation directory to
64 | /opt/anaconda1anaconda2anaconda3 .
65 |
66 | The mental model of PFFT is similar to FFTW. We plan ahead such that the code
67 | runs and runs fast. 4 objects are involved in a FFT:
68 |
69 | - ProcMesh : The topology / geometry of the MPI ranks. For example 4x2 or 2x4 for 8
70 | ranks, or 250x200 for 500000 ranks.
71 |
72 | - Partition : The partition of the FFT input / output array onto the ranks.
73 | local_i_slice, local_i_start, local_ni describes the relative offset
74 | of the input. replacing 'i' with 'o' for the output.
75 |
76 | - LocalBuffer : The place holder of the local data storage (allocated by PFFT).
77 | use view_input() view_output() to obtain the correct numpy array of the
78 | correct shape and strides suited for either the input or the output.
79 | -- always indexed in (x, y, z) ordering.
80 |
81 | - Plan : The PFFT plan. execute the plan to obtain the results in the output array.
82 |
83 | A fairly complex example (testing agreement with numpy.fft) is at tests/roundtrip.py .
84 | A simpler example is example.py.
85 |
86 | The documentation is sparse and in the source code (pfft/core.pyx),
87 | hopefully the guide here can get you started:
88 |
89 | 1. create a ProcMesh object for the communication geometry
90 |
91 | 2. create a Partition object for the data partition of the FFT mesh,
92 | in real and fourier space, both
93 |
94 | 3. allocate LocalBuffer objects for input and output. A LocalBuffer can be
95 | reused for inplace transforms.
96 |
97 | 4. create Plan objects for the transforms, with the LocalBuffer objects as
98 | scratch
99 |
100 | 5. optionally, free the scratch buffers, and create new LocalBuffer objects.
101 |
102 | 6. view the LocalBuffer objects via view_input / view_output
103 |
104 | 7. fill the LocalBuffer objects, making use of
105 | Partition.local_i_start, local_o_start which marks the offset of the local
106 | mesh.
107 | A useful function is numpy.indices. numpy.meshgrid and numpy.ogrid are also useful.
108 |
109 | 8. Apply the plans via Plan.execute with LocalBuffer objects as arguments.
110 |
111 |
112 | Yu Feng
113 |
--------------------------------------------------------------------------------
/check_tag.sh:
--------------------------------------------------------------------------------
1 | #! /bin/bash
2 |
3 | if [[ -n "$TRAVIS_TAG" ]]; then
4 | if ! grep "$TRAVIS_TAG" "$1"; then
5 | echo Tag $TRAVIS_TAG does not match setup.py version. Bail.
6 | exit 1
7 | fi
8 | fi
9 | exit 0
10 |
--------------------------------------------------------------------------------
/depends/install_pfft.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh -e
2 |
3 | PREFIX="$1"
4 | shift
5 | OPTIMIZE="$*"
6 | OPTIMIZE1=`echo "$*" | sed 's;enable-sse2;enable-sse;'`
7 | echo "Optimization for double" ${OPTIMIZE}
8 | echo "Optimization for single" ${OPTIMIZE1}
9 |
10 | PFFT_VERSION=1.0.8-alpha3-fftw3-2don2d
11 | TMP="tmp-pfft-$PFFT_VERSION"
12 | LOGFILE="build.log"
13 |
14 | mkdir -p $TMP
15 | ROOT=`dirname $0`/../
16 | if ! [ -f $ROOT/depends/pfft-$PFFT_VERSION.tar.gz ]; then
17 | echo curl -L -o $ROOT/depends/pfft-$PFFT_VERSION.tar.gz \
18 | https://github.com/rainwoodman/pfft/releases/download/$PFFT_VERSION/pfft-$PFFT_VERSION.tar.gz
19 | curl -L -o $ROOT/depends/pfft-$PFFT_VERSION.tar.gz \
20 | https://github.com/rainwoodman/pfft/releases/download/$PFFT_VERSION/pfft-$PFFT_VERSION.tar.gz
21 | fi
22 |
23 | if ! [ -f $ROOT/depends/pfft-$PFFT_VERSION.tar.gz ]; then
24 | echo wget -P $ROOT/depends/ \
25 | https://github.com/rainwoodman/pfft/releases/download/$PFFT_VERSION/pfft-$PFFT_VERSION.tar.gz
26 | wget -P $ROOT/depends/ \
27 | https://github.com/rainwoodman/pfft/releases/download/$PFFT_VERSION/pfft-$PFFT_VERSION.tar.gz
28 | fi
29 |
30 | if ! [ -f $ROOT/depends/pfft-$PFFT_VERSION.tar.gz ]; then
31 | echo "Failed to get https://github.com/rainwoodman/pfft/releases/download/$PFFT_VERSION/pfft-$PFFT_VERSION.tar.gz"
32 | echo "Please check curl or wget"
33 | echo "You can also download it manually to $ROOT/depends/"
34 | exit 1
35 | fi
36 |
37 | gzip -dc $ROOT/depends/pfft-$PFFT_VERSION.tar.gz | tar xf - -C $TMP
38 | cd $TMP
39 |
40 | (
41 | mkdir -p double;cd double
42 |
43 | ../pfft-${PFFT_VERSION}/configure --prefix=$PREFIX --disable-shared --enable-static \
44 | --disable-fortran --disable-doc --enable-mpi ${OPTIMIZE} &&
45 | make -j 4 &&
46 | make install && echo "PFFT_DONE"
47 | ) 2>&1 |tee ${LOGFILE}.double | awk "{printf(\".\")} NR % 40 == 0 {printf(\"\n\")} END {printf(\"\n\")}"
48 |
49 | if ! grep PFFT_DONE ${LOGFILE}.double > /dev/null; then
50 | tail ${LOGFILE}.double
51 | exit 1
52 | fi
53 | (
54 | mkdir -p single;cd single
55 | ../pfft-${PFFT_VERSION}/configure --prefix=$PREFIX --enable-single --disable-shared --enable-static \
56 | --disable-fortran --disable-doc --enable-mpi $2 ${OPTIMIZE1} &&
57 | make -j 4 &&
58 | make install && echo "PFFT_DONE"
59 | ) 2>&1 |tee ${LOGFILE}.single | awk "{printf(\".\")} NR % 40 == 0 {printf(\"\n\")} END {printf(\"\n\")}"
60 |
61 | if ! grep PFFT_DONE ${LOGFILE}.single > /dev/null; then
62 | tail ${LOGFILE}.single
63 | exit 1
64 | fi
65 |
--------------------------------------------------------------------------------
/docs/Makefile:
--------------------------------------------------------------------------------
1 | # Makefile for Sphinx documentation
2 | #
3 |
4 | # You can set these variables from the command line.
5 | SPHINXOPTS =
6 | SPHINXBUILD = sphinx-build
7 | PAPER =
8 | BUILDDIR = _build
9 |
10 | # User-friendly check for sphinx-build
11 | ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
12 | $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
13 | endif
14 |
15 | # Internal variables.
16 | PAPEROPT_a4 = -D latex_paper_size=a4
17 | PAPEROPT_letter = -D latex_paper_size=letter
18 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
19 | # the i18n builder cannot share the environment and doctrees with the others
20 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
21 |
22 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext
23 |
24 | help:
25 | @echo "Please use \`make ' where is one of"
26 | @echo " html to make standalone HTML files"
27 | @echo " dirhtml to make HTML files named index.html in directories"
28 | @echo " singlehtml to make a single large HTML file"
29 | @echo " pickle to make pickle files"
30 | @echo " json to make JSON files"
31 | @echo " htmlhelp to make HTML files and a HTML help project"
32 | @echo " qthelp to make HTML files and a qthelp project"
33 | @echo " applehelp to make an Apple Help Book"
34 | @echo " devhelp to make HTML files and a Devhelp project"
35 | @echo " epub to make an epub"
36 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
37 | @echo " latexpdf to make LaTeX files and run them through pdflatex"
38 | @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
39 | @echo " text to make text files"
40 | @echo " man to make manual pages"
41 | @echo " texinfo to make Texinfo files"
42 | @echo " info to make Texinfo files and run them through makeinfo"
43 | @echo " gettext to make PO message catalogs"
44 | @echo " changes to make an overview of all changed/added/deprecated items"
45 | @echo " xml to make Docutils-native XML files"
46 | @echo " pseudoxml to make pseudoxml-XML files for display purposes"
47 | @echo " linkcheck to check all external links for integrity"
48 | @echo " doctest to run all doctests embedded in the documentation (if enabled)"
49 | @echo " coverage to run coverage check of the documentation (if enabled)"
50 |
51 | clean:
52 | rm -rf $(BUILDDIR)/*
53 |
54 | html:
55 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
56 | @echo
57 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
58 |
59 | gh-pages:
60 | ghp-import -n -p $(BUILDDIR)/html/
61 |
62 | dirhtml:
63 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
64 | @echo
65 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
66 |
67 | singlehtml:
68 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
69 | @echo
70 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
71 |
72 | pickle:
73 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
74 | @echo
75 | @echo "Build finished; now you can process the pickle files."
76 |
77 | json:
78 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
79 | @echo
80 | @echo "Build finished; now you can process the JSON files."
81 |
82 | htmlhelp:
83 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
84 | @echo
85 | @echo "Build finished; now you can run HTML Help Workshop with the" \
86 | ".hhp project file in $(BUILDDIR)/htmlhelp."
87 |
88 | qthelp:
89 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
90 | @echo
91 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \
92 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
93 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/ImagingLSS.qhcp"
94 | @echo "To view the help file:"
95 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/ImagingLSS.qhc"
96 |
97 | applehelp:
98 | $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
99 | @echo
100 | @echo "Build finished. The help book is in $(BUILDDIR)/applehelp."
101 | @echo "N.B. You won't be able to view it unless you put it in" \
102 | "~/Library/Documentation/Help or install it in your application" \
103 | "bundle."
104 |
105 | devhelp:
106 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
107 | @echo
108 | @echo "Build finished."
109 | @echo "To view the help file:"
110 | @echo "# mkdir -p $$HOME/.local/share/devhelp/ImagingLSS"
111 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/ImagingLSS"
112 | @echo "# devhelp"
113 |
114 | epub:
115 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
116 | @echo
117 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
118 |
119 | latex:
120 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
121 | @echo
122 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
123 | @echo "Run \`make' in that directory to run these through (pdf)latex" \
124 | "(use \`make latexpdf' here to do that automatically)."
125 |
126 | latexpdf:
127 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
128 | @echo "Running LaTeX files through pdflatex..."
129 | $(MAKE) -C $(BUILDDIR)/latex all-pdf
130 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
131 |
132 | latexpdfja:
133 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
134 | @echo "Running LaTeX files through platex and dvipdfmx..."
135 | $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
136 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
137 |
138 | text:
139 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
140 | @echo
141 | @echo "Build finished. The text files are in $(BUILDDIR)/text."
142 |
143 | man:
144 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
145 | @echo
146 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
147 |
148 | texinfo:
149 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
150 | @echo
151 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
152 | @echo "Run \`make' in that directory to run these through makeinfo" \
153 | "(use \`make info' here to do that automatically)."
154 |
155 | info:
156 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
157 | @echo "Running Texinfo files through makeinfo..."
158 | make -C $(BUILDDIR)/texinfo info
159 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
160 |
161 | gettext:
162 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
163 | @echo
164 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
165 |
166 | changes:
167 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
168 | @echo
169 | @echo "The overview file is in $(BUILDDIR)/changes."
170 |
171 | linkcheck:
172 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
173 | @echo
174 | @echo "Link check complete; look for any errors in the above output " \
175 | "or in $(BUILDDIR)/linkcheck/output.txt."
176 |
177 | doctest:
178 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
179 | @echo "Testing of doctests in the sources finished, look at the " \
180 | "results in $(BUILDDIR)/doctest/output.txt."
181 |
182 | coverage:
183 | $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
184 | @echo "Testing of coverage in the sources finished, look at the " \
185 | "results in $(BUILDDIR)/coverage/python.txt."
186 |
187 | xml:
188 | $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
189 | @echo
190 | @echo "Build finished. The XML files are in $(BUILDDIR)/xml."
191 |
192 | pseudoxml:
193 | $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
194 | @echo
195 | @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
196 |
--------------------------------------------------------------------------------
/docs/apidoc.sh:
--------------------------------------------------------------------------------
1 | # bash
2 |
3 | if ! python -c 'import numpydoc'; then easy_install --user numpydoc; fi
4 | if ! python -c 'import sphinx'; then easy_install --user sphinx; fi
5 |
6 | sphinx-apidoc -e -f -o . ../pfft
7 |
--------------------------------------------------------------------------------
/docs/conf.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | #
3 | # PFFT-Python documentation build configuration file, created by
4 | # sphinx-quickstart on Sun Mar 15 12:45:33 2015.
5 | #
6 | # This file is execfile()d with the current directory set to its
7 | # containing dir.
8 | #
9 | # Note that not all possible configuration values are present in this
10 | # autogenerated file.
11 | #
12 | # All configuration values have a default; values that are commented out
13 | # serve to show the default.
14 |
15 | import sys
16 | import os
17 | import shlex
18 |
19 | # -- General configuration ------------------------------------------------
20 |
21 | # If your documentation needs a minimal Sphinx version, state it here.
22 | #needs_sphinx = '1.0'
23 |
24 | # Add any Sphinx extension module names here, as strings. They can be
25 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
26 | # ones.
27 | extensions = [
28 | 'sphinx.ext.autodoc',
29 | 'sphinx.ext.todo',
30 | 'sphinx.ext.coverage',
31 | 'sphinx.ext.pngmath',
32 | 'sphinx.ext.viewcode',
33 | 'sphinx.ext.autosummary',
34 | 'numpydoc',
35 | ]
36 |
37 | numpydoc_show_class_members = False
38 |
39 | # Add any paths that contain templates here, relative to this directory.
40 | templates_path = ['_templates']
41 |
42 | # The suffix(es) of source filenames.
43 | source_suffix = '.rst'
44 |
45 | # The encoding of source files.
46 | #source_encoding = 'utf-8-sig'
47 |
48 | # The master toctree document.
49 | master_doc = 'index'
50 |
51 | # General information about the project.
52 | project = u'PFFT-Python'
53 | copyright = u'2015, Yu Feng'
54 | author = u'Yu Feng'
55 |
56 | # The version info for the project you're documenting, acts as replacement for
57 | # |version| and |release|, also used in various other places throughout the
58 | # built documents.
59 | #
60 | # The short X.Y version.
61 | import pfft
62 | version = pfft.__version__
63 | # The full version, including alpha/beta/rc tags.
64 | release = pfft.__version__
65 |
66 | # The language for content autogenerated by Sphinx. Refer to documentation
67 | # for a list of supported languages.
68 | #
69 | # This is also used if you do content translation via gettext catalogs.
70 | # Usually you set "language" from the command line for these cases.
71 | language = None
72 |
73 | # There are two options for replacing |today|: either, you set today to some
74 | # non-false value, then it is used:
75 | #today = ''
76 | # Else, today_fmt is used as the format for a strftime call.
77 | #today_fmt = '%B %d, %Y'
78 |
79 | # List of patterns, relative to source directory, that match files and
80 | # directories to ignore when looking for source files.
81 | exclude_patterns = ['_build']
82 |
83 | # The reST default role (used for this markup: `text`) to use for all
84 | # documents.
85 | #default_role = None
86 |
87 | # If true, '()' will be appended to :func: etc. cross-reference text.
88 | #add_function_parentheses = True
89 |
90 | # If true, the current module name will be prepended to all description
91 | # unit titles (such as .. function::).
92 | #add_module_names = True
93 |
94 | # If true, sectionauthor and moduleauthor directives will be shown in the
95 | # output. They are ignored by default.
96 | #show_authors = False
97 |
98 | # The name of the Pygments (syntax highlighting) style to use.
99 | pygments_style = 'sphinx'
100 |
101 | # A list of ignored prefixes for module index sorting.
102 | #modindex_common_prefix = []
103 |
104 | # If true, keep warnings as "system message" paragraphs in the built documents.
105 | #keep_warnings = False
106 |
107 | # If true, `todo` and `todoList` produce output, else they produce nothing.
108 | todo_include_todos = True
109 |
110 |
111 | # -- Options for HTML output ----------------------------------------------
112 |
113 | # The theme to use for HTML and HTML Help pages. See the documentation for
114 | # a list of builtin themes.
115 | #html_theme = 'sphinx_rtd_theme'
116 | html_theme = 'bizstyle'
117 |
118 | # Theme options are theme-specific and customize the look and feel of a theme
119 | # further. For a list of options available for each theme, see the
120 | # documentation.
121 | #html_theme_options = {}
122 |
123 | # Add any paths that contain custom themes here, relative to this directory.
124 | #html_theme_path = []
125 |
126 | # The name for this set of Sphinx documents. If None, it defaults to
127 | # " v documentation".
128 | #html_title = None
129 |
130 | # A shorter title for the navigation bar. Default is the same as html_title.
131 | #html_short_title = None
132 |
133 | # The name of an image file (relative to this directory) to place at the top
134 | # of the sidebar.
135 | #html_logo = None
136 |
137 | # The name of an image file (within the static path) to use as favicon of the
138 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
139 | # pixels large.
140 | #html_favicon = None
141 |
142 | # Add any paths that contain custom static files (such as style sheets) here,
143 | # relative to this directory. They are copied after the builtin static files,
144 | # so a file named "default.css" will overwrite the builtin "default.css".
145 | html_static_path = ['_static']
146 |
147 | # Add any extra paths that contain custom files (such as robots.txt or
148 | # .htaccess) here, relative to this directory. These files are copied
149 | # directly to the root of the documentation.
150 | #html_extra_path = []
151 |
152 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
153 | # using the given strftime format.
154 | #html_last_updated_fmt = '%b %d, %Y'
155 |
156 | # If true, SmartyPants will be used to convert quotes and dashes to
157 | # typographically correct entities.
158 | #html_use_smartypants = True
159 |
160 | # Custom sidebar templates, maps document names to template names.
161 | #html_sidebars = {}
162 |
163 | # Additional templates that should be rendered to pages, maps page names to
164 | # template names.
165 | #html_additional_pages = {}
166 |
167 | # If false, no module index is generated.
168 | #html_domain_indices = True
169 |
170 | # If false, no index is generated.
171 | #html_use_index = True
172 |
173 | # If true, the index is split into individual pages for each letter.
174 | #html_split_index = False
175 |
176 | # If true, links to the reST sources are added to the pages.
177 | #html_show_sourcelink = True
178 |
179 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
180 | #html_show_sphinx = True
181 |
182 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
183 | #html_show_copyright = True
184 |
185 | # If true, an OpenSearch description file will be output, and all pages will
186 | # contain a tag referring to it. The value of this option must be the
187 | # base URL from which the finished HTML is served.
188 | #html_use_opensearch = ''
189 |
190 | # This is the file name suffix for HTML files (e.g. ".xhtml").
191 | #html_file_suffix = None
192 |
193 | # Language to be used for generating the HTML full-text search index.
194 | # Sphinx supports the following languages:
195 | # 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
196 | # 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
197 | #html_search_language = 'en'
198 |
199 | # A dictionary with options for the search language support, empty by default.
200 | # Now only 'ja' uses this config value
201 | #html_search_options = {'type': 'default'}
202 |
203 | # The name of a javascript file (relative to the configuration directory) that
204 | # implements a search results scorer. If empty, the default will be used.
205 | #html_search_scorer = 'scorer.js'
206 |
207 | # Output file base name for HTML help builder.
208 | htmlhelp_basename = 'PFFT-Pythondoc'
209 |
210 | # -- Options for LaTeX output ---------------------------------------------
211 |
212 | latex_elements = {
213 | # The paper size ('letterpaper' or 'a4paper').
214 | #'papersize': 'letterpaper',
215 |
216 | # The font size ('10pt', '11pt' or '12pt').
217 | #'pointsize': '10pt',
218 |
219 | # Additional stuff for the LaTeX preamble.
220 | #'preamble': '',
221 |
222 | # Latex figure (float) alignment
223 | #'figure_align': 'htbp',
224 | }
225 |
226 | # Grouping the document tree into LaTeX files. List of tuples
227 | # (source start file, target name, title,
228 | # author, documentclass [howto, manual, or own class]).
229 | latex_documents = [
230 | (master_doc, 'PFFT-Python.tex', u'PFFT-Python Documentation',
231 | u'Yu Feng', 'manual'),
232 | ]
233 |
234 | # The name of an image file (relative to this directory) to place at the top of
235 | # the title page.
236 | #latex_logo = None
237 |
238 | # For "manual" documents, if this is true, then toplevel headings are parts,
239 | # not chapters.
240 | #latex_use_parts = False
241 |
242 | # If true, show page references after internal links.
243 | #latex_show_pagerefs = False
244 |
245 | # If true, show URL addresses after external links.
246 | #latex_show_urls = False
247 |
248 | # Documents to append as an appendix to all manuals.
249 | #latex_appendices = []
250 |
251 | # If false, no module index is generated.
252 | #latex_domain_indices = True
253 |
254 |
255 | # -- Options for manual page output ---------------------------------------
256 |
257 | # One entry per manual page. List of tuples
258 | # (source start file, name, description, authors, manual section).
259 | man_pages = [
260 | (master_doc, 'pfft-python', u'PFFT-Python Documentation',
261 | [author], 1)
262 | ]
263 |
264 | # If true, show URL addresses after external links.
265 | #man_show_urls = False
266 |
267 |
268 | # -- Options for Texinfo output -------------------------------------------
269 |
270 | # Grouping the document tree into Texinfo files. List of tuples
271 | # (source start file, target name, title, author,
272 | # dir menu entry, description, category)
273 | texinfo_documents = [
274 | (master_doc, 'PFFT-Python', u'PFFT-Python Documentation',
275 | author, 'PFFT-Python', 'One line description of project.',
276 | 'Miscellaneous'),
277 | ]
278 |
279 | # Documents to append as an appendix to all manuals.
280 | #texinfo_appendices = []
281 |
282 | # If false, no module index is generated.
283 | #texinfo_domain_indices = True
284 |
285 | # How to display URL addresses: 'footnote', 'no', or 'inline'.
286 | #texinfo_show_urls = 'footnote'
287 |
288 | # If true, do not generate a @detailmenu in the "Top" node's menu.
289 | #texinfo_no_detailmenu = False
290 |
--------------------------------------------------------------------------------
/docs/index.rst:
--------------------------------------------------------------------------------
1 | .. pfft-python documentation master file, created by
2 | sphinx-quickstart on Sun Apr 12 22:37:07 2015.
3 | You can adapt this file completely to your liking, but it should at least
4 | contain the root `toctree` directive.
5 |
6 | Welcome to pfft-python's documentation!
7 | =======================================
8 |
9 | Contents:
10 |
11 | .. toctree::
12 | :maxdepth: 2
13 |
14 |
15 |
16 | Indices and tables
17 | ==================
18 |
19 | * :ref:`genindex`
20 | * :ref:`modindex`
21 | * :ref:`search`
22 |
23 |
--------------------------------------------------------------------------------
/docs/pfft.rst:
--------------------------------------------------------------------------------
1 | pfft package
2 | ============
3 |
4 | Subpackages
5 | -----------
6 |
7 | .. toctree::
8 |
9 | pfft.tests
10 |
11 | Submodules
12 | ----------
13 |
14 | .. toctree::
15 |
16 | pfft.core
17 | pfft.version
18 |
19 | Module contents
20 | ---------------
21 |
22 | .. automodule:: pfft
23 | :members:
24 | :imported-members:
25 | :undoc-members:
26 | :show-inheritance:
27 |
--------------------------------------------------------------------------------
/examples/elasticwave.py:
--------------------------------------------------------------------------------
1 | from mpi4py import MPI
2 |
3 | import pfft
4 | import numpy
5 |
6 | def main(comm):
7 | Nmesh = [8, 8]
8 |
9 | if len(Nmesh) == 3:
10 | procmesh = pfft.ProcMesh(pfft.split_size_2d(comm.size), comm=comm)
11 | else:
12 | procmesh = pfft.ProcMesh((comm.size,), comm=comm)
13 |
14 | partition = pfft.Partition(
15 | pfft.Type.R2C,
16 | Nmesh,
17 | procmesh,
18 | pfft.Flags.PADDED_R2C | pfft.Flags.PFFT_TRANSPOSED_OUT | pfft.Flags.DESTROY_INPUT
19 | )
20 |
21 | # generate the coordinate support.
22 |
23 | k = [None] * partition.ndim
24 | x = [None] * partition.ndim
25 | for d in range(partition.ndim):
26 | k[d] = numpy.arange(partition.no[d])[partition.local_o_slice[d]]
27 | k[d][k[d] >= partition.n[d] // 2] -= partition.n[d]
28 | # set to the right numpy broadcast shape
29 | k[d] = k[d].reshape([-1 if i == d else 1 for i in range(partition.ndim)])
30 |
31 | x[d] = numpy.arange(partition.ni[d])[partition.local_i_slice[d]]
32 | # set to the right numpy broadcast shape
33 | x[d] = x[d].reshape([-1 if i == d else 1 for i in range(partition.ndim)])
34 |
35 | # allocate memory
36 | buffer1 = pfft.LocalBuffer(partition)
37 | phi_disp = buffer1.view_input()
38 |
39 | buffer2 = pfft.LocalBuffer(partition)
40 | phi_spec = buffer2.view_output()
41 |
42 | # forward plan
43 | disp_to_spec_inplace = pfft.Plan(partition, pfft.Direction.PFFT_FORWARD,
44 | buffer2, buffer2,
45 | # the two lines below not needed after version 0.1.21
46 | # type=pfft.Type.R2C,
47 | # flags=pfft.Flags.TRANSPOSED_OUT | pfft.Flags.DESTROY_INPUT | pfft.Flags.PADDED_R2C
48 | )
49 |
50 | buffer3 = pfft.LocalBuffer(partition)
51 | grad_spec = buffer3.view_output()
52 |
53 | buffer4 = pfft.LocalBuffer(partition)
54 | grad_disp = buffer4.view_input()
55 |
56 | # backward plan
57 | spec_to_disp = pfft.Plan(partition, pfft.Direction.PFFT_BACKWARD,
58 | buffer3, buffer4,
59 | # the two lines below not needed after version 0.1.21
60 | # type=pfft.Type.C2R,
61 | # flags=pfft.Flags.TRANSPOSED_IN | pfft.Flags.DESTROY_INPUT | pfft.Flags.PADDED_C2R
62 | )
63 |
64 | # to do : fill in initial value
65 | dx = x[0] - Nmesh[0] * 0.5 + 0.5
66 | dy = x[1] - Nmesh[1] * 0.5 + 0.5
67 | phi_disp[...] = dx ** 2 + dx * dy + dy ** 2
68 |
69 | cprint('phi =', gather(partition, phi_disp).round(2), comm=comm)
70 |
71 | # copy in to the buffer for inplace transform
72 | # this preserves value of phi_disp
73 | phi_spec.base.view_input()[...] = phi_disp
74 | disp_to_spec_inplace.execute(phi_spec.base, phi_spec.base)
75 |
76 | all_grad_disp = numpy.zeros([partition.ndim] + list(phi_disp.shape), dtype=grad_disp.dtype)
77 |
78 | # cprint('phi_k =', gather(partition, phi_spec, mode='output').round(2), comm=comm)
79 |
80 | for d in range(partition.ndim):
81 | grad_spec[...] = phi_spec[...] * (k[d] * 1j)
82 | spec_to_disp.execute(grad_spec.base, grad_disp.base)
83 | # copy the gradient along d th direction
84 | all_grad_disp[d] = grad_disp
85 |
86 | # now do your thing.
87 |
88 | for d in range(partition.ndim):
89 | cprint('dim =', gather(partition, all_grad_disp[d]).round(2), comm=comm)
90 |
91 | def cprint(*args, comm):
92 | if comm.rank == 0:
93 | print(*args)
94 |
95 | def gather(partition, data, mode='input'):
96 | if mode == 'input':
97 | full = numpy.zeros(partition.ni, data.dtype)
98 | full[partition.local_i_slice] = data
99 | else:
100 | full = numpy.zeros(partition.no, data.dtype)
101 | full[partition.local_o_slice] = data
102 | partition.procmesh.comm.Allreduce(MPI.IN_PLACE, full)
103 | return full
104 |
105 | main(MPI.COMM_WORLD)
106 |
--------------------------------------------------------------------------------
/examples/example.py:
--------------------------------------------------------------------------------
1 | from mpi4py import MPI
2 | import numpy
3 | import pfft
4 |
5 | if MPI.COMM_WORLD.rank == 0:
6 | print \
7 | """
8 | This example performs a in-place transform, with a naive slab decomposition.
9 |
10 | In place transform is achieved by providing a single buffer object to pfft.Plan.
11 | Consequently, calls to plan.execute we also provide only a single buffer object.
12 | """
13 |
14 |
15 | procmesh = pfft.ProcMesh([4], comm=MPI.COMM_WORLD)
16 | partition = pfft.Partition(
17 | pfft.Type.PFFT_C2C,
18 | [8, 8],
19 | procmesh,
20 | pfft.Flags.PFFT_TRANSPOSED_OUT | pfft.Flags.PFFT_DESTROY_INPUT
21 | )
22 | for irank in range(4):
23 | MPI.COMM_WORLD.barrier()
24 | if irank != procmesh.rank:
25 | continue
26 | print 'My rank is', procmesh.this
27 | print 'local_i_start', partition.local_i_start
28 | print 'local_o_start', partition.local_o_start
29 | print 'i_edges', partition.i_edges
30 | print 'o_edges', partition.o_edges
31 |
32 | buffer = pfft.LocalBuffer(partition)
33 |
34 | plan = pfft.Plan(partition, pfft.Direction.PFFT_FORWARD, buffer)
35 | iplan = pfft.Plan(partition, pfft.Direction.PFFT_BACKWARD, buffer,
36 | flags=pfft.Flags.PFFT_TRANSPOSED_OUT | pfft.Flags.PFFT_DESTROY_INPUT,
37 | )
38 |
39 | input = buffer.view_input()
40 | print input.base
41 | # now lets fill the input array in a funny way
42 | # a[i, j] = i * 10 + j
43 | # we will do a tranform roundtrip and print this out
44 | indices = numpy.array(numpy.indices(input.shape))
45 | indices += partition.local_i_start[:, None, None]
46 | i, j = indices
47 | input[...] = i * 10 + j
48 |
49 | plan.execute(buffer)
50 |
51 | output = buffer.view_output()
52 |
53 | # denormalize the forward transform
54 | output /= numpy.prod(partition.n)
55 |
56 | iplan.execute(buffer)
57 |
58 | ginput = MPI.COMM_WORLD.gather(input)
59 | if MPI.COMM_WORLD.rank == 0:
60 | print 'You shall see an array of form i * 10 + j'
61 | for item in ginput:
62 | print item
63 |
--------------------------------------------------------------------------------
/pfft/__init__.py:
--------------------------------------------------------------------------------
1 | from .version import __version__
2 |
3 | from .core import *
4 |
--------------------------------------------------------------------------------
/pfft/core.pyx:
--------------------------------------------------------------------------------
1 | #cython: embedsignature=True
2 | #cython: boundscheck=False
3 | """
4 | pfft-python: python binding of PFFT.
5 |
6 | Author: Yu Feng (yfeng1@berkeley.edu),
7 | University of California Berkeley (2014)
8 |
9 | """
10 | from mpi4py import MPI
11 | cimport libmpi as cMPI
12 | import numpy
13 | cimport numpy
14 | from libc.stdlib cimport free, calloc
15 | from libc.string cimport memset
16 |
17 | numpy.import_array()
18 |
19 | def split_size_2d(s):
20 | """ Split `s` into two integers,
21 | a and d, such that a * d == s and a <= d
22 |
23 | returns: a, d
24 | """
25 | a = int(s** 0.5) + 1
26 | d = s
27 | while a > 1:
28 | if s % a == 0:
29 | d = s // a
30 | break
31 | a = a - 1
32 | return a, d
33 |
34 | ####
35 | # import those pfft functions
36 | #####
37 | cdef extern from 'pfft.h':
38 | int _PFFT_FORWARD "PFFT_FORWARD"
39 | int _PFFT_BACKWARD "PFFT_BACKWARD"
40 | int _PFFT_TRANSPOSED_NONE "PFFT_TRANSPOSED_NONE"
41 | int _PFFT_TRANSPOSED_IN "PFFT_TRANSPOSED_IN"
42 | int _PFFT_TRANSPOSED_OUT "PFFT_TRANSPOSED_OUT"
43 | int _PFFT_SHIFTED_NONE "PFFT_SHIFTED_NONE"
44 | int _PFFT_SHIFTED_IN "PFFT_SHIFTED_IN"
45 | int _PFFT_SHIFTED_OUT "PFFT_SHIFTED_OUT"
46 | int _PFFT_MEASURE "PFFT_MEASURE"
47 | int _PFFT_ESTIMATE "PFFT_ESTIMATE"
48 | int _PFFT_PATIENT "PFFT_PATIENT"
49 | int _PFFT_EXHAUSTIVE "PFFT_EXHAUSTIVE"
50 | int _PFFT_NO_TUNE "PFFT_NO_TUNE"
51 | int _PFFT_TUNE "PFFT_TUNE"
52 | int _PFFT_PRESERVE_INPUT "PFFT_PRESERVE_INPUT"
53 | int _PFFT_DESTROY_INPUT "PFFT_DESTROY_INPUT"
54 | int _PFFT_BUFFERED_INPLACE "PFFT_BUFFERED_INPLACE"
55 | int _PFFT_PADDED_R2C "PFFT_PADDED_R2C"
56 | int _PFFT_PADDED_C2R "PFFT_PADDED_C2R"
57 |
58 | int _FFTW_R2HC "FFTW_R2HC"
59 | int _FFTW_HC2R "FFTW_HC2R"
60 |
61 | void pfft_init()
62 | void pfftf_init()
63 | void pfft_cleanup()
64 |
65 | ctypedef void * pfft_plan
66 |
67 | struct pfft_complex:
68 | pass
69 | struct pfftf_complex:
70 | pass
71 |
72 | void pfft_execute_dft(pfft_plan plan, void * input, void * output)
73 | void pfft_execute_dft_r2c(pfft_plan plan, void * input, void * output)
74 | void pfft_execute_dft_c2r(pfft_plan plan, void * input, void * output)
75 | void pfft_execute_r2r(pfft_plan plan, void * input, void * output)
76 |
77 | void pfftf_execute_dft(pfft_plan plan, void * input, void * output)
78 | void pfftf_execute_dft_r2c(pfft_plan plan, void * input, void * output)
79 | void pfftf_execute_dft_c2r(pfft_plan plan, void * input, void * output)
80 | void pfftf_execute_r2r(pfft_plan plan, void * input, void * output)
81 |
82 | void pfft_destroy_plan(pfft_plan plan)
83 | void pfftf_destroy_plan(pfft_plan plan)
84 |
85 | pfft_plan pfft_plan_dft(
86 | int rnk_n, numpy.intp_t *n, void * input, void * output,
87 | cMPI.MPI_Comm ccart,
88 | int sign, unsigned pfft_flags)
89 |
90 | pfft_plan pfft_plan_dft_r2c(
91 | int rnk_n, numpy.intp_t *n, void * input, void * output,
92 | cMPI.MPI_Comm ccart,
93 | int sign, unsigned pfft_flags)
94 |
95 | pfft_plan pfft_plan_dft_c2r(
96 | int rnk_n, numpy.intp_t *n, void * input, void * output,
97 | cMPI.MPI_Comm ccart,
98 | int sign, unsigned pfft_flags)
99 |
100 | pfft_plan pfft_plan_r2r(
101 | int rnk_n, numpy.intp_t *n, void * input, void * output,
102 | cMPI.MPI_Comm ccart,
103 | int * kinds, unsigned pfft_flags)
104 |
105 | pfft_plan pfftf_plan_dft(
106 | int rnk_n, numpy.intp_t *n, void * input, void * output,
107 | cMPI.MPI_Comm ccart,
108 | int sign, unsigned pfft_flags)
109 |
110 | pfft_plan pfftf_plan_dft_r2c(
111 | int rnk_n, numpy.intp_t *n, void * input, void * output,
112 | cMPI.MPI_Comm ccart,
113 | int sign, unsigned pfft_flags)
114 |
115 | pfft_plan pfftf_plan_dft_c2r(
116 | int rnk_n, numpy.intp_t *n, void * input, void * output,
117 | cMPI.MPI_Comm ccart,
118 | int sign, unsigned pfft_flags)
119 |
120 | pfft_plan pfftf_plan_r2r(
121 | int rnk_n, numpy.intp_t *n, void * input, void * output,
122 | cMPI.MPI_Comm ccart,
123 | int * kinds, unsigned pfft_flags)
124 |
125 | int pfft_create_procmesh(int rnk_n, cMPI.MPI_Comm comm, int *np,
126 | cMPI.MPI_Comm * ccart)
127 |
128 | int pfftf_create_procmesh(int rnk_n, cMPI.MPI_Comm comm, int *np,
129 | cMPI.MPI_Comm * ccart)
130 |
131 | numpy.intp_t pfft_local_size_dft(int rnk_n, numpy.intp_t * n, cMPI.MPI_Comm comm, int
132 | pfft_flags, numpy.intp_t * local_ni, numpy.intp_t * local_i_start,
133 | numpy.intp_t* local_no, numpy.intp_t * local_o_start)
134 |
135 | numpy.intp_t pfft_local_size_dft_r2c(int rnk_n, numpy.intp_t * n, cMPI.MPI_Comm comm, int
136 | pfft_flags, numpy.intp_t * local_ni, numpy.intp_t * local_i_start,
137 | numpy.intp_t* local_no, numpy.intp_t * local_o_start)
138 |
139 | numpy.intp_t pfft_local_size_dft_c2r(int rnk_n, numpy.intp_t * n, cMPI.MPI_Comm comm, int
140 | pfft_flags, numpy.intp_t * local_ni, numpy.intp_t * local_i_start,
141 | numpy.intp_t* local_no, numpy.intp_t * local_o_start)
142 |
143 | numpy.intp_t pfft_local_size_r2r(int rnk_n, numpy.intp_t * n, cMPI.MPI_Comm comm, int
144 | pfft_flags, numpy.intp_t * local_ni, numpy.intp_t * local_i_start,
145 | numpy.intp_t* local_no, numpy.intp_t * local_o_start)
146 |
147 | numpy.intp_t pfftf_local_size_dft(int rnk_n, numpy.intp_t * n, cMPI.MPI_Comm comm, int
148 | pfft_flags, numpy.intp_t * local_ni, numpy.intp_t * local_i_start,
149 | numpy.intp_t* local_no, numpy.intp_t * local_o_start)
150 |
151 | numpy.intp_t pfftf_local_size_dft_r2c(int rnk_n, numpy.intp_t * n, cMPI.MPI_Comm comm, int
152 | pfft_flags, numpy.intp_t * local_ni, numpy.intp_t * local_i_start,
153 | numpy.intp_t* local_no, numpy.intp_t * local_o_start)
154 |
155 | numpy.intp_t pfftf_local_size_dft_c2r(int rnk_n, numpy.intp_t * n, cMPI.MPI_Comm comm, int
156 | pfft_flags, numpy.intp_t * local_ni, numpy.intp_t * local_i_start,
157 | numpy.intp_t* local_no, numpy.intp_t * local_o_start)
158 |
159 | numpy.intp_t pfftf_local_size_r2r(int rnk_n, numpy.intp_t * n, cMPI.MPI_Comm comm, int
160 | pfft_flags, numpy.intp_t * local_ni, numpy.intp_t * local_i_start,
161 | numpy.intp_t* local_no, numpy.intp_t * local_o_start)
162 |
163 | double * pfft_alloc_real(size_t size)
164 | pfft_complex * pfft_alloc_complex(size_t size)
165 | pfftf_complex * pfftf_alloc_complex(size_t size)
166 | void pfft_free(void * ptr)
167 |
168 | #######
169 | # wrap Flags, Direction
170 | #####
171 |
172 | class Flags(int):
173 | """
174 | PFFT Transformation Flags
175 | """
176 |
177 | PFFT_TRANSPOSED_NONE = _PFFT_TRANSPOSED_NONE
178 | PFFT_TRANSPOSED_IN = _PFFT_TRANSPOSED_IN
179 | PFFT_TRANSPOSED_OUT = _PFFT_TRANSPOSED_OUT
180 | PFFT_SHIFTED_NONE = _PFFT_SHIFTED_NONE
181 | PFFT_SHIFTED_IN = _PFFT_SHIFTED_IN
182 | PFFT_SHIFTED_OUT = _PFFT_SHIFTED_OUT
183 | PFFT_MEASURE = _PFFT_MEASURE
184 | PFFT_ESTIMATE = _PFFT_ESTIMATE
185 | PFFT_PATIENT = _PFFT_PATIENT
186 | PFFT_EXHAUSTIVE = _PFFT_EXHAUSTIVE
187 | PFFT_NO_TUNE = _PFFT_NO_TUNE
188 | PFFT_TUNE = _PFFT_TUNE
189 | PFFT_PRESERVE_INPUT = _PFFT_PRESERVE_INPUT
190 | PFFT_DESTROY_INPUT = _PFFT_DESTROY_INPUT
191 | PFFT_BUFFERED_INPLACE = _PFFT_BUFFERED_INPLACE
192 | PFFT_PADDED_R2C = _PFFT_PADDED_R2C
193 | PFFT_PADDED_C2R = _PFFT_PADDED_C2R
194 | TRANSPOSED_NONE = _PFFT_TRANSPOSED_NONE
195 | TRANSPOSED_IN = _PFFT_TRANSPOSED_IN
196 | TRANSPOSED_OUT = _PFFT_TRANSPOSED_OUT
197 | SHIFTED_NONE = _PFFT_SHIFTED_NONE
198 | SHIFTED_IN = _PFFT_SHIFTED_IN
199 | SHIFTED_OUT = _PFFT_SHIFTED_OUT
200 | MEASURE = _PFFT_MEASURE
201 | ESTIMATE = _PFFT_ESTIMATE
202 | PATIENT = _PFFT_PATIENT
203 | EXHAUSTIVE = _PFFT_EXHAUSTIVE
204 | NO_TUNE = _PFFT_NO_TUNE
205 | TUNE = _PFFT_TUNE
206 | PRESERVE_INPUT = _PFFT_PRESERVE_INPUT
207 | DESTROY_INPUT = _PFFT_DESTROY_INPUT
208 | BUFFERED_INPLACE = _PFFT_BUFFERED_INPLACE
209 | PADDED_R2C = _PFFT_PADDED_R2C
210 | PADDED_C2R = _PFFT_PADDED_C2R
211 |
212 | def __new__(cls, value):
213 | self = int.__new__(cls, value)
214 | return self
215 |
216 | def __repr__(self):
217 | d = self.__class__.__dict__
218 | keys = sorted([k for k in d.keys() if k.isupper() and not k.startswith('PFFT')])
219 | return '|'.join([k for k in keys if (d[k] & self)])
220 |
221 | def format(self, flags=None):
222 | d = self.__class__.__dict__
223 | keys = sorted([k for k in d.keys() if k.isupper() and not k.startswith('PFFT')])
224 | s = []
225 | for key in keys:
226 | if flags is not None and not (d[key] & flags): continue
227 | if d[key] & self:
228 | s.append(key)
229 | else:
230 | s.append(" " * len(key))
231 | return ' '.join(s)
232 |
233 | class Direction(int):
234 | """
235 | PFFT Transformation Directions
236 | """
237 | PFFT_FORWARD = _PFFT_FORWARD
238 | PFFT_BACKWARD = _PFFT_BACKWARD
239 | FORWARD = _PFFT_FORWARD
240 | BACKWARD = _PFFT_BACKWARD
241 | def __new__(cls, value):
242 | self = int.__new__(cls, value)
243 | return self
244 |
245 | def __repr__(self):
246 | d = self.__class__.__dict__
247 | keys = sorted([k for k in d.keys() if k.isupper() and not k.startswith('PFFT')])
248 | return 'and'.join([k for k in keys if (d[k] == self)])
249 |
250 | ######
251 | # define Type as the transform type
252 | # fill in the function tables as well.
253 | ##
254 | class Type(int):
255 | """
256 | PFFT Transformation Types
257 | Double precision is prefixed with PFFT
258 | Single precision is prefixed with PFFTF
259 | """
260 | PFFT_C2C = 0
261 | PFFT_R2C = 1
262 | PFFT_C2R = 2
263 | PFFT_R2R = 3
264 | PFFTF_C2C = 4
265 | PFFTF_R2C = 5
266 | PFFTF_C2R = 6
267 | PFFTF_R2R = 7
268 | C2C = 0
269 | R2C = 1
270 | C2R = 2
271 | R2R = 3
272 | C2CF = 4
273 | R2CF = 5
274 | C2RF = 6
275 | R2RF = 7
276 | def __new__(cls, value):
277 | self = int.__new__(cls, value)
278 | return self
279 |
280 | def __repr__(self):
281 | d = self.__class__.__dict__
282 | keys = sorted([k for k in d.keys() if k.isupper() and not k.startswith('PFFT')])
283 | return 'and'.join([k for k in keys if (d[k] == self)])
284 |
285 | def is_inverse_of(self, other):
286 | return self == other.inverse
287 |
288 | @property
289 | def inverse(self):
290 | inverses = { Type.C2C : Type.C2C,
291 | Type.R2C : Type.C2R,
292 | Type.C2R : Type.R2C,
293 | Type.R2R : Type.R2R,
294 | Type.C2CF : Type.C2CF,
295 | Type.R2CF : Type.C2RF,
296 | Type.C2RF : Type.R2CF,
297 | Type.R2RF : Type.R2RF,
298 | }
299 | return inverses[self]
300 |
301 | ctypedef numpy.intp_t (*pfft_local_size_func)(int rnk_n, numpy.intp_t * n, cMPI.MPI_Comm comm, int
302 | pfft_flags, numpy.intp_t * local_ni, numpy.intp_t * local_i_start,
303 | numpy.intp_t* local_no, numpy.intp_t * local_o_start)
304 |
305 | cdef pfft_local_size_func PFFT_LOCAL_SIZE_FUNC [8]
306 |
307 | PFFT_LOCAL_SIZE_FUNC[:] = [
308 | pfft_local_size_dft,
309 | pfft_local_size_dft_r2c,
310 | pfft_local_size_dft_c2r,
311 | pfft_local_size_r2r,
312 | pfftf_local_size_dft,
313 | pfftf_local_size_dft_r2c,
314 | pfftf_local_size_dft_c2r,
315 | pfftf_local_size_r2r,
316 | ]
317 |
318 | ctypedef pfft_plan (*pfft_plan_func) (
319 | int rnk_n, numpy.intp_t *n, void * input, void * output,
320 | cMPI.MPI_Comm ccart,
321 | int sign, unsigned pfft_flags)
322 |
323 | ctypedef pfft_plan (*pfft_plan_func_r2r) (
324 | int rnk_n, numpy.intp_t *n, void * input, void * output,
325 | cMPI.MPI_Comm ccart,
326 | int * kinds, unsigned pfft_flags)
327 |
328 | cdef void * PFFT_PLAN_FUNC [8]
329 |
330 | PFFT_PLAN_FUNC[:] = [
331 | pfft_plan_dft,
332 | pfft_plan_dft_r2c,
333 | pfft_plan_dft_c2r,
334 | pfft_plan_r2r,
335 | pfftf_plan_dft,
336 | pfftf_plan_dft_r2c,
337 | pfftf_plan_dft_c2r,
338 | pfftf_plan_r2r,
339 | ]
340 |
341 | ctypedef void (*pfft_free_plan_func) (void * plan)
342 | cdef pfft_free_plan_func PFFT_FREE_PLAN_FUNC [8]
343 |
344 | PFFT_FREE_PLAN_FUNC[:] = [
345 | pfft_destroy_plan,
346 | pfft_destroy_plan,
347 | pfft_destroy_plan,
348 | pfft_destroy_plan,
349 | pfftf_destroy_plan,
350 | pfftf_destroy_plan,
351 | pfftf_destroy_plan,
352 | pfftf_destroy_plan,
353 | ]
354 |
355 | ctypedef void (*pfft_execute_func) ( pfft_plan plan, void * input, void * output)
356 | cdef pfft_execute_func PFFT_EXECUTE_FUNC [8]
357 |
358 | PFFT_EXECUTE_FUNC[:] = [
359 | pfft_execute_dft,
360 | pfft_execute_dft_r2c,
361 | pfft_execute_dft_c2r,
362 | pfft_execute_r2r,
363 | pfftf_execute_dft,
364 | pfftf_execute_dft_r2c,
365 | pfftf_execute_dft_c2r,
366 | pfftf_execute_r2r,
367 | ]
368 | cdef int PFFT_NPY_TYPE[8]
369 |
370 | PFFT_NPY_TYPE[:] = [
371 | numpy.NPY_DOUBLE,
372 | numpy.NPY_DOUBLE,
373 | numpy.NPY_DOUBLE,
374 | numpy.NPY_DOUBLE,
375 | numpy.NPY_FLOAT,
376 | numpy.NPY_FLOAT,
377 | numpy.NPY_FLOAT,
378 | numpy.NPY_FLOAT,
379 | ]
380 |
381 |
382 |
383 | cdef class ProcMesh(object):
384 | """
385 | The topology of the MPI ranks. (procmesh)
386 |
387 | Attributes
388 | ==========
389 | comm : MPI.Comm
390 | MPI communicator the proc mesh is built for.
391 | Note that it does not have the 2D topology.
392 |
393 | this : array_like
394 | The rank of current process in the procmesh
395 | np : array_like
396 | The shape of the proc mesh.
397 | ndim : int
398 | size of the proc mesh
399 | rank : int
400 | MPI rank
401 | """
402 | cdef readonly numpy.ndarray this # nd rank of the current process
403 | cdef readonly numpy.ndarray np
404 | cdef readonly int rank
405 | cdef readonly int ndim
406 | cdef readonly object comm
407 |
408 | cdef cMPI.MPI_Comm ccart
409 | cdef cMPI.MPI_Comm * ccol
410 |
411 | @classmethod
412 | def split(cls, ndim, comm=None):
413 | if comm is None:
414 | comm = MPI.COMM_WORLD
415 | if ndim == 2:
416 | np = split_size_2d(comm.size)
417 | elif ndim == 1:
418 | np = [comm.size]
419 | else:
420 | raise ValueError("only know how to split to upto 2d")
421 | return np
422 |
423 | def __init__(self, np, comm=None):
424 | """ A mesh of processes
425 | np is the number of processes in each direction.
426 |
427 | example:
428 | procmesh = ProcMesh([2, 3]) # creates a 2 x 3 mesh.
429 |
430 | product(np) must equal to comm.size
431 |
432 | if the mpi4py version is recent (cMPI._addressof), comm can
433 | be any mpi4py Comm objects.
434 | """
435 | cdef cMPI.MPI_Comm ccomm
436 | self.ccol = NULL
437 | self.ccart = NULL
438 |
439 | if comm is None:
440 | comm = MPI.COMM_WORLD
441 |
442 | if isinstance(comm, MPI.Comm):
443 | if hasattr(MPI, '_addressof'):
444 | ccomm = ( (
445 | MPI._addressof(comm))) [0]
446 | else:
447 | if comm == MPI.COMM_WORLD:
448 | ccomm = cMPI.MPI_COMM_WORLD
449 | else:
450 | raise ValueError("only comm=MPI.COMM_WORLD is supported, "
451 | + " update mpi4py to 2.0, with MPI._addressof")
452 | cdef int [::1] np_ = numpy.array(np, 'int32')
453 | rt = pfft_create_procmesh(np_.shape[0], ccomm, &np_[0], &self.ccart)
454 |
455 | if rt != 0:
456 | self.ccart = NULL
457 | raise RuntimeError("Failed to create proc mesh")
458 | pycomm = comm.Create_cart(dims=np_,
459 | periods=[True] * len(np_),
460 | reorder=1)
461 | self.comm = pycomm
462 | self.rank = pycomm.rank
463 |
464 | self.np = numpy.array(np_)
465 | self.ndim = len(self.np)
466 |
467 | # a buffer used for various purposes
468 | cdef int[::1] junk = numpy.empty(self.ndim, 'int32')
469 |
470 | # now fill `this'
471 | self.this = numpy.array(np, 'int32')
472 | cMPI.MPI_Cart_get(self.ccart, 2,
473 | &junk[0], &junk[0],
474 | self.this.data);
475 |
476 | # build the ccol sub communicators
477 | self.ccol = calloc(self.ndim, sizeof(cMPI.MPI_Comm))
478 | for i in range(self.ndim):
479 | junk[:] = 0
480 | junk[i] = 1
481 | if cMPI.MPI_SUCCESS != cMPI.MPI_Cart_sub(self.ccart, &junk[0],
482 | &self.ccol[i]):
483 | self.ccol[i] = NULL
484 | raise RuntimeError("Failed to create sub communicators")
485 |
486 | def __dealloc__(self):
487 | if self.ccart:
488 | cMPI.MPI_Comm_free(&self.ccart)
489 | pass
490 | if self.ccol != NULL:
491 | for i in range(self.ndim):
492 | if self.ccol[i]:
493 | cMPI.MPI_Comm_free(&self.ccol[i])
494 | free(self.ccol)
495 |
496 | cdef class Partition(object):
497 | cdef readonly size_t alloc_local
498 | cdef readonly int ndim
499 | cdef readonly numpy.ndarray n
500 | cdef readonly numpy.ndarray ni
501 | cdef readonly numpy.ndarray no
502 | cdef readonly numpy.ndarray local_ni
503 | cdef readonly numpy.ndarray local_i_start
504 | cdef readonly numpy.ndarray local_no
505 | cdef readonly numpy.ndarray local_o_start
506 | cdef readonly numpy.ndarray local_i_strides
507 | cdef readonly numpy.ndarray local_i_shape
508 | cdef readonly numpy.ndarray local_o_strides
509 | cdef readonly numpy.ndarray local_o_shape
510 | cdef readonly object local_i_slice
511 | cdef readonly object local_o_slice
512 | cdef readonly object type
513 | cdef readonly object flags
514 | cdef readonly ProcMesh procmesh
515 | cdef readonly object i_edges
516 | cdef readonly object o_edges
517 | cdef readonly numpy.dtype i_dtype
518 | cdef readonly numpy.dtype o_dtype
519 |
520 | i_dtypes = [
521 | 'complex128', 'float64', 'complex128', 'float64',
522 | 'complex64', 'float32', 'complex64', 'float32',
523 | ]
524 |
525 | o_dtypes = [
526 | 'complex128', 'complex128', 'float64', 'float64',
527 | 'complex64', 'complex64', 'float32', 'float32',
528 | ]
529 |
530 | def __init__(self, type, n, ProcMesh procmesh, flags):
531 | """ A data partition object
532 | type is the type of the transform, r2c, c2r, c2c or r2r see Type.
533 | n is the size of the mesh.
534 | procmesh is a ProcMesh object
535 | flags, see Flags
536 |
537 | i_edges: the edges of the input mesh. This is identical on all
538 | ranks. Notice that if the input is PFFT_TRANSPOSED_IN the edges
539 | remain the ordering of the original array. The mapping to
540 | the procmesh is somewhat complicated:
541 | (I will write this when I figure it out)
542 | o_edges: the edges of the output mesh. similar to i_edges
543 |
544 | local_i_start: the start offset.
545 | local_o_start: the start offset.
546 |
547 | Example:
548 | Partition(Type.R2C, [32, 32, 32], procmesh, Flags.PFFT_TRANSPOSED_OUT)
549 | """
550 | self.procmesh = procmesh
551 | cdef numpy.intp_t[::1] n_ = numpy.array(n, 'intp')
552 | cdef numpy.intp_t[::1] local_ni
553 | cdef numpy.intp_t[::1] local_no
554 | cdef numpy.intp_t[::1] local_i_start
555 | cdef numpy.intp_t[::1] local_o_start
556 | cdef numpy.intp_t[::1] local_i_strides
557 | cdef numpy.intp_t[::1] local_o_strides
558 |
559 | local_ni, local_no, local_i_start, local_o_start = numpy.empty((4, n_.shape[0]), 'intp')
560 |
561 | self.type = Type(type)
562 | self.flags = Flags(flags)
563 |
564 | if len(n_) < len(procmesh.np):
565 | raise ValueError("ProcMesh (%d) shall have less dimentions than Mesh (%d)" % (len(procmesh.np), len(n_)))
566 |
567 | if len(n_) == len(procmesh.np):
568 | if len(n_) != 2 and len(n_) != 3: # https://github.com/mpip/pfft/issues/29
569 | raise NotImplementedError("Currently using the same ProcMesh (%d) dimentions with Mesh (%d) is not supported other than 2don2d or 3don3d" % (len(procmesh.np), len(n_)))
570 |
571 | if ( ((self.flags & Flags.PFFT_PADDED_R2C) | (self.flags & Flags.PFFT_PADDED_C2R))
572 | and ( self.type in (Type.R2C, Type.C2R, Type.R2CF, Type.C2RF))
573 | ):
574 | # https://github.com/mpip/pfft/pull/31
575 | raise NotImplementedError("Currently using the same ProcMesh (%d) dimentions with Mesh (%d) is not supported on padded transforms." % (len(procmesh.np), len(n_)))
576 |
577 | cdef pfft_local_size_func func = PFFT_LOCAL_SIZE_FUNC[self.type]
578 |
579 |
580 | rt = func(n_.shape[0],
581 | &n_[0],
582 | procmesh.ccart,
583 | flags,
584 | &local_ni[0],
585 | &local_i_start[0],
586 | &local_no[0],
587 | &local_o_start[0])
588 |
589 | if rt <= 0:
590 | raise RuntimeError("failed local size")
591 |
592 | self.alloc_local = rt
593 | self.local_ni = numpy.array(local_ni)
594 | self.local_no = numpy.array(local_no)
595 | self.local_i_start = numpy.array(local_i_start)
596 | self.local_o_start = numpy.array(local_o_start)
597 | self.n = numpy.array(n_)
598 | self.ndim = len(self.n)
599 |
600 | self.i_dtype = numpy.dtype(self.i_dtypes[self.type])
601 | self.o_dtype = numpy.dtype(self.o_dtypes[self.type])
602 |
603 | self.local_i_shape, self.local_i_strides = \
604 | self._build_shape_strides(
605 | self.local_i_start,
606 | self.local_ni,
607 | self.flags & Flags.PFFT_TRANSPOSED_IN)
608 | self.local_i_strides *= self.i_dtype.itemsize
609 |
610 | self.local_o_shape, self.local_o_strides =\
611 | self._build_shape_strides(
612 | self.local_o_start,
613 | self.local_no,
614 | self.flags & Flags.PFFT_TRANSPOSED_OUT)
615 | self.local_o_strides *= self.o_dtype.itemsize
616 |
617 | # Notice that local_i_start and i_edges can be different
618 | # due to https://github.com/mpip/pfft/issues/22
619 | #
620 | # i_edges are used for domain decomposition, thus
621 | # supposed to be non-decreasing, so we calculate
622 | # them from local_ni.
623 |
624 | self.i_edges = self._build_edges(self.local_ni,
625 | self.flags & Flags.PFFT_TRANSPOSED_IN,
626 | )
627 | self.o_edges = self._build_edges(self.local_no,
628 | self.flags & Flags.PFFT_TRANSPOSED_OUT
629 | )
630 |
631 | # it is alright to use the 'zero' local_i_start
632 | # in slices, since the local_ni is is also zero
633 | # and would give a zero size slice anyways.
634 | self.local_i_slice = tuple(
635 | [slice(start, start + n)
636 | for start, n in zip(
637 | self.local_i_start, self.local_ni)])
638 | self.local_o_slice = tuple(
639 | [slice(start, start + n)
640 | for start, n in zip(
641 | self.local_o_start, self.local_no)])
642 |
643 | self.ni = numpy.array([e[-1] for e in self.i_edges], dtype='intp')
644 | self.no = numpy.array([e[-1] for e in self.o_edges], dtype='intp')
645 |
646 | def _build_shape_strides(self, numpy.intp_t[::1] local_start, numpy.intp_t[::1] local_n, transposed):
647 | cdef int d
648 | cdef numpy.intp_t[::1] axismapping
649 | cdef numpy.intp_t[::1] strides
650 | cdef numpy.intp_t[::1] shape
651 |
652 | strides = numpy.empty(local_n.shape[0], dtype='intp')
653 | shape = numpy.empty(local_n.shape[0], dtype='intp')
654 |
655 | # invaxismapping[d] stores the untransposed axis for d
656 | axismapping = numpy.arange(self.ndim, dtype='intp')
657 | if transposed:
658 | first = axismapping[:self.procmesh.ndim + 1]
659 | first[:] = numpy.roll(first, -1)
660 | # print numpy.array(axismapping)
661 | for d in range(self.ndim):
662 | shape[d] = local_n[d]
663 |
664 | # strides are transposed
665 | strides[axismapping[self.ndim - 1]] = 1
666 |
667 | #print 'local_n', numpy.array(local_n)
668 | for d in range(self.ndim - 2, -1, -1):
669 | d0 = axismapping[d]
670 | d1 = axismapping[d + 1]
671 | strides[d0] = local_n[d1] * strides[d1]
672 | #print d0, d1, local_n[d1], strides[d1], '=', strides[d0]
673 |
674 | # if shape[d] is too large, there is padding
675 | # we know it must be r2c here, so replace with n[d]
676 | for d in range(self.ndim):
677 | if shape[d] > self.n[d] - local_start[d]:
678 | shape[d] = self.n[d] - local_start[d]
679 |
680 | return numpy.array(shape), numpy.array(strides)
681 |
682 | def _build_edges(self, numpy.intp_t[::1] local_n, transposed):
683 | cdef numpy.intp_t[::1] start_dim
684 | cdef numpy.intp_t[::1] invaxismapping
685 | cdef numpy.intp_t tmp
686 | edges = []
687 | cdef int d
688 | cdef int d1
689 |
690 | # invaxismapping[d] stores the transposed axis for d
691 | invaxismapping = numpy.arange(self.ndim, dtype='intp')
692 | if transposed:
693 | first = invaxismapping[:self.procmesh.ndim + 1]
694 | first[:] = numpy.roll(first, 1)
695 |
696 | np = numpy.ones(self.ndim, dtype='int')
697 | np[:self.procmesh.ndim] = self.procmesh.np
698 | for d in range(self.ndim):
699 | d1 = invaxismapping[d]
700 |
701 | start_dim = numpy.empty((np[d1] + 1), dtype='intp')
702 | start_dim[0] = 0
703 | if d1 < self.procmesh.ndim:
704 | tmp = local_n[d]
705 | cMPI.MPI_Allgather(&tmp, sizeof(numpy.intp_t), cMPI.MPI_BYTE,
706 | &start_dim[1], sizeof(numpy.intp_t), cMPI.MPI_BYTE,
707 | self.procmesh.ccol[d1])
708 | else:
709 | # use the full axis, because it is not chopped
710 | start_dim[1] = local_n[d]
711 | # if local_n is too large, there is padding
712 | # we know it must be r2c here, so replace with n[d]
713 | if start_dim[1] > self.n[d]:
714 | start_dim[1] = self.n[d]
715 |
716 | start_dim_a = numpy.array(start_dim, copy=False)
717 | start_dim_a[:] = numpy.cumsum(start_dim_a)
718 |
719 | edges.append(numpy.array(start_dim))
720 | return edges
721 |
722 | def __repr__(self):
723 | return 'Partition(' + \
724 | ','.join([
725 | 'n = %s' % str(self.n),
726 | 'local_ni = %s' % str(self.local_ni),
727 | 'local_no = %s' % str(self.local_no),
728 | 'local_i_start = %s' % str(self.local_i_start),
729 | 'local_o_start = %s' % str(self.local_o_start),
730 | 'flags = %s' % repr(self.flags),
731 | 'type = %s' % repr(self.type),
732 | ]) + ')'
733 |
734 | cdef class LocalBuffer:
735 | cdef void * ptr
736 | cdef readonly numpy.intp_t address
737 | cdef readonly Partition partition
738 | cdef readonly LocalBuffer base
739 |
740 | # keep track of base because the python object may be destroyed
741 | # before dealloc is called
742 | cdef int _has_base
743 |
744 | def __init__(self, partition, LocalBuffer base=None):
745 | """ The local portion of the distributed array used by PFFT
746 |
747 | see the documents of view_input, view_output
748 | """
749 | self.partition = partition
750 |
751 | self.base = base
752 |
753 | if base is None:
754 | if PFFT_NPY_TYPE[self.partition.type] == numpy.NPY_DOUBLE:
755 | self.ptr = pfft_alloc_complex(partition.alloc_local)
756 | elif PFFT_NPY_TYPE[self.partition.type] == numpy.NPY_FLOAT:
757 | self.ptr = pfftf_alloc_complex(partition.alloc_local)
758 | self._has_base = 0
759 | else:
760 | assert base.partition.alloc_local == self.partition.alloc_local
761 | #FIXME: check procmesh
762 | self.ptr = base.ptr
763 | self._has_base = 1
764 |
765 | self.address = self.ptr
766 |
767 | def __contains__(self, LocalBuffer other):
768 | return self.address == other.address
769 |
770 | def view_raw(self, type=numpy.ndarray):
771 | cdef numpy.dtype dt
772 | if PFFT_NPY_TYPE[self.partition.type] == numpy.NPY_DOUBLE:
773 | dt = numpy.dtype('f8')
774 | else:
775 | dt = numpy.dtype('f4')
776 | cdef numpy.intp_t alloc_local = 2 * self.partition.alloc_local
777 | cdef numpy.intp_t strides = dt.itemsize
778 | cdef numpy.ndarray a = numpy.PyArray_New(type,
779 | 1,
780 | &alloc_local,
781 | dt.type_num,
782 | &strides,
783 | self.ptr, dt.itemsize, numpy.NPY_BEHAVED, None)
784 |
785 | numpy.set_array_base(a, self)
786 | return a
787 |
788 | def view_input(self, type=numpy.ndarray):
789 | cdef numpy.dtype dt = self.partition.i_dtype
790 | cdef numpy.ndarray a = numpy.PyArray_New(type,
791 | self.partition.ndim,
792 | self.partition.local_i_shape.data,
793 | dt.type_num,
794 | self.partition.local_i_strides.data,
795 | self.ptr, dt.itemsize, numpy.NPY_BEHAVED, None)
796 |
797 | numpy.set_array_base(a, self)
798 |
799 | return a
800 |
801 | def view_output(self, type=numpy.ndarray):
802 | cdef numpy.dtype dt = self.partition.o_dtype
803 |
804 | cdef numpy.ndarray a = numpy.PyArray_New(type,
805 | self.partition.ndim,
806 | self.partition.local_o_shape.data,
807 | dt.type_num,
808 | self.partition.local_o_strides.data,
809 | self.ptr, dt.itemsize, numpy.NPY_BEHAVED, None)
810 |
811 | numpy.set_array_base(a, self)
812 |
813 | return a
814 |
815 |
816 | def __dealloc__(self):
817 | if not self._has_base:
818 | pfft_free(self.ptr)
819 |
820 | cdef class Plan(object):
821 | cdef pfft_plan plan
822 | cdef readonly object flags
823 | cdef readonly object type
824 | cdef readonly object direction
825 | cdef readonly int inplace
826 | cdef pfft_free_plan_func free_func
827 |
828 | def __init__(self, Partition partition, direction,
829 | LocalBuffer i, LocalBuffer o=None,
830 | type=None, flags=None):
831 | """ initialize a Plan.
832 | o defaults to i
833 | type defaults to parititon.type
834 | flags defaults to partition.flags
835 |
836 | The usually convention is:
837 |
838 | iDFT: Direction.PFFT_FORWARD
839 | DFT : Direction.PFFT_BACKWARD
840 |
841 | CFT = dx * iDFT = (L/N) * iDFT
842 | iCFT = dk * DFT = (2pi / L) * DFT
843 |
844 | We have these normalizations:
845 | iDFT(DFT) = N
846 |
847 | iCFT(CFT) = dx * dk * DFT(iDFT)
848 | = L / N * (2pi / L) * N
849 | = 2 pi
850 |
851 | example:
852 | plan = Plan(partition, Direction.PFFT_FORWARD, buf1, buf2)
853 |
854 | """
855 | self.direction = Direction(direction)
856 |
857 | if type is None:
858 | if self.direction == Direction.BACKWARD:
859 | type = partition.type.inverse
860 | else:
861 | type = partition.type
862 |
863 | self.type = Type(type)
864 |
865 | n = partition.n
866 | cdef ProcMesh procmesh = partition.procmesh
867 |
868 | if flags is None:
869 | flags = partition.flags
870 |
871 | if self.type.is_inverse_of(partition.type) and self.direction == Direction.BACKWARD:
872 | if partition.flags & Flags.PFFT_TRANSPOSED_IN:
873 | flags = flags & ~Flags.PFFT_TRANSPOSED_IN
874 | flags |= Flags.PFFT_TRANSPOSED_OUT
875 |
876 | if partition.flags & Flags.PFFT_TRANSPOSED_OUT:
877 | flags = flags & ~Flags.PFFT_TRANSPOSED_OUT
878 | flags |= Flags.PFFT_TRANSPOSED_IN
879 |
880 | self.flags = Flags(flags)
881 |
882 | cdef pfft_plan_func plan_func = PFFT_PLAN_FUNC[self.type]
883 | cdef pfft_plan_func_r2r plan_func_r2r = PFFT_PLAN_FUNC[self.type]
884 |
885 | cdef numpy.intp_t [::1] n_ = numpy.array(n, dtype='intp')
886 | if o is None:
887 | o = i
888 | if o.ptr == i.ptr:
889 | self.inplace = True
890 | else:
891 | self.inplace = False
892 |
893 | if ( (self.type in (Type.PFFT_R2C, Type.PFFT_C2R, Type.PFFTF_R2C, Type.PFFT_C2R) )
894 | and (self.flags & Flags.PFFT_PRESERVE_INPUT)
895 | and not (self.flags & Flags.PFFT_PADDED_R2C)
896 | and not self.inplace
897 | ):
898 | raise NotImplementedError("out place non-padded r2c / c2r does not preserve input.(%s) " % repr(self.flags)
899 | + "Provide PFFT_DESTROY_INPUT as a flag and deal with this quirk.")
900 |
901 | cdef int [::1] kinds = numpy.zeros(len(n), dtype='int32')
902 |
903 | if direction == Direction.FORWARD:
904 | kinds[...] = _FFTW_R2HC
905 | else:
906 | kinds[...] = _FFTW_HC2R
907 |
908 | if self.type in (Type.R2R, Type.R2RF):
909 | self.plan = plan_func_r2r(n_.shape[0], &n_[0], i.ptr, o.ptr,
910 | procmesh.ccart,
911 | &kinds[0],
912 | flags)
913 | else:
914 | self.plan = plan_func(n_.shape[0], &n_[0], i.ptr, o.ptr,
915 | procmesh.ccart,
916 | self.direction,
917 | flags)
918 | if not self.plan:
919 | raise ValueError("Plan is not created")
920 |
921 | self.free_func = PFFT_FREE_PLAN_FUNC[self.type]
922 |
923 | def execute(self, LocalBuffer i, LocalBuffer o=None):
924 | """ execute a plan.
925 | o and i must match the alignment (unchecked),
926 | inplace status of the plan.
927 | """
928 | cdef pfft_execute_func func = PFFT_EXECUTE_FUNC[self.type]
929 | if o is None:
930 | o = i
931 | if o.ptr == i.ptr:
932 | inplace = True
933 | else:
934 | inplace = False
935 | if inplace != self.inplace:
936 | raise ValueError("inplace status mismatch with the plan")
937 |
938 | func(self.plan, i.ptr, o.ptr)
939 |
940 | def __repr__(self):
941 | return "Plan(" + \
942 | ','.join([
943 | 'flags = %s' % repr(self.flags),
944 | 'type = %s' % repr(self.type),
945 | 'direction = %s' % repr(self.direction),
946 | 'inplace = %s' % repr(self.inplace),
947 | ]) + ")"
948 | def __dealloc__(self):
949 | if self.plan:
950 | self.free_func(self.plan)
951 |
952 | pfft_init()
953 | pfftf_init()
954 | #print 'init pfft'
955 |
--------------------------------------------------------------------------------
/pfft/libmpi.pxd:
--------------------------------------------------------------------------------
1 | # Author: Lisandro Dalcin
2 | # Contact: dalcinl@gmail.com
3 |
4 | cdef import from "mpi.h" nogil:
5 |
6 | #-----------------------------------------------------------------
7 |
8 | ctypedef long MPI_Aint
9 | ctypedef long long MPI_Offset #:= long
10 | ctypedef long long MPI_Count #:= MPI_Offset
11 |
12 | ctypedef struct MPI_Status:
13 | int MPI_SOURCE
14 | int MPI_TAG
15 | int MPI_ERROR
16 |
17 | ctypedef struct _mpi_datatype_t
18 | ctypedef _mpi_datatype_t* MPI_Datatype
19 |
20 | ctypedef struct _mpi_request_t
21 | ctypedef _mpi_request_t* MPI_Request
22 |
23 | ctypedef struct _mpi_message_t
24 | ctypedef _mpi_message_t* MPI_Message
25 |
26 | ctypedef struct _mpi_op_t
27 | ctypedef _mpi_op_t* MPI_Op
28 |
29 | ctypedef struct _mpi_group_t
30 | ctypedef _mpi_group_t* MPI_Group
31 |
32 | ctypedef struct _mpi_info_t
33 | ctypedef _mpi_info_t* MPI_Info
34 |
35 | ctypedef struct _mpi_comm_t
36 | ctypedef _mpi_comm_t* MPI_Comm
37 |
38 | ctypedef struct _mpi_win_t
39 | ctypedef _mpi_win_t* MPI_Win
40 |
41 | ctypedef struct _mpi_file_t
42 | ctypedef _mpi_file_t* MPI_File
43 |
44 | ctypedef struct _mpi_errhandler_t
45 | ctypedef _mpi_errhandler_t* MPI_Errhandler
46 |
47 | #-----------------------------------------------------------------
48 |
49 | enum: MPI_UNDEFINED #:= -32766
50 | enum: MPI_ANY_SOURCE #:= MPI_UNDEFINED
51 | enum: MPI_ANY_TAG #:= MPI_UNDEFINED
52 | enum: MPI_PROC_NULL #:= MPI_UNDEFINED
53 | enum: MPI_ROOT #:= MPI_PROC_NULL
54 |
55 | enum: MPI_IDENT #:= 1
56 | enum: MPI_CONGRUENT #:= 2
57 | enum: MPI_SIMILAR #:= 3
58 | enum: MPI_UNEQUAL #:= 4
59 |
60 | void* MPI_BOTTOM #:= 0
61 | void* MPI_IN_PLACE #:= 0
62 |
63 | enum: MPI_KEYVAL_INVALID #:= 0
64 | enum: MPI_MAX_OBJECT_NAME #:= 1
65 |
66 | #-----------------------------------------------------------------
67 |
68 | # Null datatype
69 | MPI_Datatype MPI_DATATYPE_NULL #:= 0
70 | # MPI datatypes
71 | MPI_Datatype MPI_PACKED #:= MPI_DATATYPE_NULL
72 | MPI_Datatype MPI_BYTE #:= MPI_DATATYPE_NULL
73 | MPI_Datatype MPI_AINT #:= MPI_DATATYPE_NULL
74 | MPI_Datatype MPI_OFFSET #:= MPI_DATATYPE_NULL
75 | MPI_Datatype MPI_COUNT #:= MPI_DATATYPE_NULL
76 | # Elementary C datatypes
77 | MPI_Datatype MPI_CHAR #:= MPI_DATATYPE_NULL
78 | MPI_Datatype MPI_WCHAR #:= MPI_DATATYPE_NULL
79 | MPI_Datatype MPI_SIGNED_CHAR #:= MPI_DATATYPE_NULL
80 | MPI_Datatype MPI_SHORT #:= MPI_DATATYPE_NULL
81 | MPI_Datatype MPI_INT #:= MPI_DATATYPE_NULL
82 | MPI_Datatype MPI_LONG #:= MPI_DATATYPE_NULL
83 | MPI_Datatype MPI_LONG_LONG #:= MPI_DATATYPE_NULL
84 | MPI_Datatype MPI_LONG_LONG_INT #:= MPI_DATATYPE_NULL
85 | MPI_Datatype MPI_UNSIGNED_CHAR #:= MPI_DATATYPE_NULL
86 | MPI_Datatype MPI_UNSIGNED_SHORT #:= MPI_DATATYPE_NULL
87 | MPI_Datatype MPI_UNSIGNED #:= MPI_DATATYPE_NULL
88 | MPI_Datatype MPI_UNSIGNED_LONG #:= MPI_DATATYPE_NULL
89 | MPI_Datatype MPI_UNSIGNED_LONG_LONG #:= MPI_DATATYPE_NULL
90 | MPI_Datatype MPI_FLOAT #:= MPI_DATATYPE_NULL
91 | MPI_Datatype MPI_DOUBLE #:= MPI_DATATYPE_NULL
92 | MPI_Datatype MPI_LONG_DOUBLE #:= MPI_DATATYPE_NULL
93 | # C99 datatypes
94 | MPI_Datatype MPI_C_BOOL #:= MPI_DATATYPE_NULL
95 | MPI_Datatype MPI_INT8_T #:= MPI_DATATYPE_NULL
96 | MPI_Datatype MPI_INT16_T #:= MPI_DATATYPE_NULL
97 | MPI_Datatype MPI_INT32_T #:= MPI_DATATYPE_NULL
98 | MPI_Datatype MPI_INT64_T #:= MPI_DATATYPE_NULL
99 | MPI_Datatype MPI_UINT8_T #:= MPI_DATATYPE_NULL
100 | MPI_Datatype MPI_UINT16_T #:= MPI_DATATYPE_NULL
101 | MPI_Datatype MPI_UINT32_T #:= MPI_DATATYPE_NULL
102 | MPI_Datatype MPI_UINT64_T #:= MPI_DATATYPE_NULL
103 | MPI_Datatype MPI_C_COMPLEX #:= MPI_DATATYPE_NULL
104 | MPI_Datatype MPI_C_FLOAT_COMPLEX #:= MPI_DATATYPE_NULL
105 | MPI_Datatype MPI_C_DOUBLE_COMPLEX #:= MPI_DATATYPE_NULL
106 | MPI_Datatype MPI_C_LONG_DOUBLE_COMPLEX #:= MPI_DATATYPE_NULL
107 | # C++ datatypes
108 | MPI_Datatype MPI_CXX_BOOL #:= MPI_DATATYPE_NULL
109 | MPI_Datatype MPI_CXX_FLOAT_COMPLEX #:= MPI_DATATYPE_NULL
110 | MPI_Datatype MPI_CXX_DOUBLE_COMPLEX #:= MPI_DATATYPE_NULL
111 | MPI_Datatype MPI_CXX_LONG_DOUBLE_COMPLEX #:= MPI_DATATYPE_NULL
112 | # C datatypes for reduction operations
113 | MPI_Datatype MPI_SHORT_INT #:= MPI_DATATYPE_NULL
114 | MPI_Datatype MPI_2INT #:= MPI_DATATYPE_NULL
115 | MPI_Datatype MPI_LONG_INT #:= MPI_DATATYPE_NULL
116 | MPI_Datatype MPI_FLOAT_INT #:= MPI_DATATYPE_NULL
117 | MPI_Datatype MPI_DOUBLE_INT #:= MPI_DATATYPE_NULL
118 | MPI_Datatype MPI_LONG_DOUBLE_INT #:= MPI_DATATYPE_NULL
119 | # Elementary Fortran datatypes
120 | MPI_Datatype MPI_CHARACTER #:= MPI_DATATYPE_NULL
121 | MPI_Datatype MPI_LOGICAL #:= MPI_DATATYPE_NULL
122 | MPI_Datatype MPI_INTEGER #:= MPI_DATATYPE_NULL
123 | MPI_Datatype MPI_REAL #:= MPI_DATATYPE_NULL
124 | MPI_Datatype MPI_DOUBLE_PRECISION #:= MPI_DATATYPE_NULL
125 | MPI_Datatype MPI_COMPLEX #:= MPI_DATATYPE_NULL
126 | MPI_Datatype MPI_DOUBLE_COMPLEX #:= MPI_DATATYPE_NULL
127 | # Size-specific Fortran datatypes
128 | MPI_Datatype MPI_LOGICAL1 #:= MPI_DATATYPE_NULL
129 | MPI_Datatype MPI_LOGICAL2 #:= MPI_DATATYPE_NULL
130 | MPI_Datatype MPI_LOGICAL4 #:= MPI_DATATYPE_NULL
131 | MPI_Datatype MPI_LOGICAL8 #:= MPI_DATATYPE_NULL
132 | MPI_Datatype MPI_INTEGER1 #:= MPI_DATATYPE_NULL
133 | MPI_Datatype MPI_INTEGER2 #:= MPI_DATATYPE_NULL
134 | MPI_Datatype MPI_INTEGER4 #:= MPI_DATATYPE_NULL
135 | MPI_Datatype MPI_INTEGER8 #:= MPI_DATATYPE_NULL
136 | MPI_Datatype MPI_INTEGER16 #:= MPI_DATATYPE_NULL
137 | MPI_Datatype MPI_REAL2 #:= MPI_DATATYPE_NULL
138 | MPI_Datatype MPI_REAL4 #:= MPI_DATATYPE_NULL
139 | MPI_Datatype MPI_REAL8 #:= MPI_DATATYPE_NULL
140 | MPI_Datatype MPI_REAL16 #:= MPI_DATATYPE_NULL
141 | MPI_Datatype MPI_COMPLEX4 #:= MPI_DATATYPE_NULL
142 | MPI_Datatype MPI_COMPLEX8 #:= MPI_DATATYPE_NULL
143 | MPI_Datatype MPI_COMPLEX16 #:= MPI_DATATYPE_NULL
144 | MPI_Datatype MPI_COMPLEX32 #:= MPI_DATATYPE_NULL
145 |
146 | # Deprecated since MPI-2, removed in MPI-3
147 | MPI_Datatype MPI_UB #:= MPI_DATATYPE_NULL
148 | MPI_Datatype MPI_LB #:= MPI_DATATYPE_NULL
149 | int MPI_Type_lb(MPI_Datatype, MPI_Aint*)
150 | int MPI_Type_ub(MPI_Datatype, MPI_Aint*)
151 | int MPI_Type_extent(MPI_Datatype, MPI_Aint*)
152 | int MPI_Address(void*, MPI_Aint*)
153 | int MPI_Type_hvector(int, int, MPI_Aint, MPI_Datatype, MPI_Datatype*)
154 | int MPI_Type_hindexed(int, int[], MPI_Aint[], MPI_Datatype, MPI_Datatype*)
155 | int MPI_Type_struct(int, int[], MPI_Aint[], MPI_Datatype[], MPI_Datatype*)
156 | enum: MPI_COMBINER_HVECTOR_INTEGER #:= MPI_UNDEFINED
157 | enum: MPI_COMBINER_HINDEXED_INTEGER #:= MPI_UNDEFINED
158 | enum: MPI_COMBINER_STRUCT_INTEGER #:= MPI_UNDEFINED
159 |
160 | int MPI_Type_dup(MPI_Datatype, MPI_Datatype*)
161 | int MPI_Type_contiguous(int, MPI_Datatype, MPI_Datatype*)
162 | int MPI_Type_vector(int, int, int, MPI_Datatype, MPI_Datatype*)
163 | int MPI_Type_indexed(int, int[], int[], MPI_Datatype, MPI_Datatype*)
164 | int MPI_Type_create_indexed_block(int, int, int[], MPI_Datatype, MPI_Datatype*)
165 | enum: MPI_ORDER_C #:= 0
166 | enum: MPI_ORDER_FORTRAN #:= 1
167 | int MPI_Type_create_subarray(int, int[], int[], int[], int, MPI_Datatype, MPI_Datatype*)
168 | enum: MPI_DISTRIBUTE_NONE #:= 0
169 | enum: MPI_DISTRIBUTE_BLOCK #:= 1
170 | enum: MPI_DISTRIBUTE_CYCLIC #:= 2
171 | enum: MPI_DISTRIBUTE_DFLT_DARG #:= 4
172 | int MPI_Type_create_darray(int, int, int, int[], int[], int[], int[], int, MPI_Datatype, MPI_Datatype*)
173 |
174 | int MPI_Get_address(void*, MPI_Aint*) #:= MPI_Address
175 | int MPI_Type_create_hvector(int, int, MPI_Aint, MPI_Datatype, MPI_Datatype*) #:= MPI_Type_hvector
176 | int MPI_Type_create_hindexed(int, int[], MPI_Aint[], MPI_Datatype, MPI_Datatype*) #:= MPI_Type_hindexed
177 | int MPI_Type_create_hindexed_block(int, int, MPI_Aint[], MPI_Datatype, MPI_Datatype*)
178 | int MPI_Type_create_struct(int, int[], MPI_Aint[], MPI_Datatype[], MPI_Datatype*) #:= MPI_Type_struct
179 | int MPI_Type_create_resized(MPI_Datatype, MPI_Aint, MPI_Aint, MPI_Datatype*)
180 |
181 | int MPI_Type_size(MPI_Datatype, int*)
182 | int MPI_Type_size_x(MPI_Datatype, MPI_Count*)
183 | int MPI_Type_get_extent(MPI_Datatype, MPI_Aint*, MPI_Aint*)
184 | int MPI_Type_get_extent_x(MPI_Datatype, MPI_Count*, MPI_Count*)
185 | int MPI_Type_get_true_extent(MPI_Datatype, MPI_Aint*, MPI_Aint*)
186 | int MPI_Type_get_true_extent_x(MPI_Datatype, MPI_Count*, MPI_Count*)
187 |
188 | int MPI_Type_create_f90_integer(int, MPI_Datatype*)
189 | int MPI_Type_create_f90_real(int, int, MPI_Datatype*)
190 | int MPI_Type_create_f90_complex(int, int, MPI_Datatype*)
191 | enum: MPI_TYPECLASS_INTEGER #:= MPI_UNDEFINED
192 | enum: MPI_TYPECLASS_REAL #:= MPI_UNDEFINED
193 | enum: MPI_TYPECLASS_COMPLEX #:= MPI_UNDEFINED
194 | int MPI_Type_match_size(int, int, MPI_Datatype*)
195 |
196 | int MPI_Type_commit(MPI_Datatype*)
197 | int MPI_Type_free(MPI_Datatype*)
198 |
199 | int MPI_Pack(void*, int, MPI_Datatype, void*, int, int*, MPI_Comm)
200 | int MPI_Unpack(void*, int, int*, void*, int, MPI_Datatype, MPI_Comm)
201 | int MPI_Pack_size(int, MPI_Datatype, MPI_Comm, int*)
202 |
203 | int MPI_Pack_external(char[], void*, int, MPI_Datatype, void*, MPI_Aint, MPI_Aint*)
204 | int MPI_Unpack_external(char[], void*, MPI_Aint, MPI_Aint*, void*, int, MPI_Datatype)
205 | int MPI_Pack_external_size(char[], int, MPI_Datatype, MPI_Aint*)
206 |
207 | enum: MPI_COMBINER_NAMED #:= MPI_UNDEFINED
208 | enum: MPI_COMBINER_DUP #:= MPI_UNDEFINED
209 | enum: MPI_COMBINER_CONTIGUOUS #:= MPI_UNDEFINED
210 | enum: MPI_COMBINER_VECTOR #:= MPI_UNDEFINED
211 | enum: MPI_COMBINER_HVECTOR #:= MPI_UNDEFINED
212 | enum: MPI_COMBINER_INDEXED #:= MPI_UNDEFINED
213 | enum: MPI_COMBINER_HINDEXED #:= MPI_UNDEFINED
214 | enum: MPI_COMBINER_INDEXED_BLOCK #:= MPI_UNDEFINED
215 | enum: MPI_COMBINER_HINDEXED_BLOCK #:= MPI_UNDEFINED
216 | enum: MPI_COMBINER_STRUCT #:= MPI_UNDEFINED
217 | enum: MPI_COMBINER_SUBARRAY #:= MPI_UNDEFINED
218 | enum: MPI_COMBINER_DARRAY #:= MPI_UNDEFINED
219 | enum: MPI_COMBINER_F90_REAL #:= MPI_UNDEFINED
220 | enum: MPI_COMBINER_F90_COMPLEX #:= MPI_UNDEFINED
221 | enum: MPI_COMBINER_F90_INTEGER #:= MPI_UNDEFINED
222 | enum: MPI_COMBINER_RESIZED #:= MPI_UNDEFINED
223 | int MPI_Type_get_envelope(MPI_Datatype, int*, int*, int*, int*)
224 | int MPI_Type_get_contents(MPI_Datatype, int, int, int, int[], MPI_Aint[], MPI_Datatype[])
225 |
226 | int MPI_Type_get_name(MPI_Datatype, char[], int*)
227 | int MPI_Type_set_name(MPI_Datatype, char[])
228 |
229 | int MPI_Type_get_attr(MPI_Datatype, int, void*, int*)
230 | int MPI_Type_set_attr(MPI_Datatype, int, void*)
231 | int MPI_Type_delete_attr(MPI_Datatype, int)
232 |
233 | ctypedef int MPI_Type_copy_attr_function(MPI_Datatype,int,void*,void*,void*,int*)
234 | ctypedef int MPI_Type_delete_attr_function(MPI_Datatype,int,void*,void*)
235 | MPI_Type_copy_attr_function* MPI_TYPE_NULL_COPY_FN #:= 0
236 | MPI_Type_copy_attr_function* MPI_TYPE_DUP_FN #:= 0
237 | MPI_Type_delete_attr_function* MPI_TYPE_NULL_DELETE_FN #:= 0
238 | int MPI_Type_create_keyval(MPI_Type_copy_attr_function*, MPI_Type_delete_attr_function*, int*, void*)
239 | int MPI_Type_free_keyval(int*)
240 |
241 | #-----------------------------------------------------------------
242 |
243 | MPI_Status* MPI_STATUS_IGNORE #:= 0
244 | MPI_Status* MPI_STATUSES_IGNORE #:= 0
245 |
246 | int MPI_Get_count(MPI_Status*, MPI_Datatype, int*)
247 | int MPI_Get_elements(MPI_Status*, MPI_Datatype, int*)
248 | int MPI_Get_elements_x(MPI_Status*, MPI_Datatype, MPI_Count*)
249 | int MPI_Status_set_elements(MPI_Status*, MPI_Datatype, int)
250 | int MPI_Status_set_elements_x(MPI_Status*, MPI_Datatype, MPI_Count)
251 |
252 | int MPI_Test_cancelled(MPI_Status*, int*)
253 | int MPI_Status_set_cancelled(MPI_Status*, int)
254 |
255 | #-----------------------------------------------------------------
256 |
257 | MPI_Request MPI_REQUEST_NULL #:= 0
258 |
259 | int MPI_Request_free(MPI_Request*)
260 | int MPI_Wait(MPI_Request*, MPI_Status*)
261 | int MPI_Test(MPI_Request*, int*, MPI_Status*)
262 | int MPI_Request_get_status(MPI_Request, int*, MPI_Status*)
263 | int MPI_Cancel(MPI_Request*)
264 |
265 | int MPI_Waitany(int, MPI_Request[], int*, MPI_Status*)
266 | int MPI_Testany(int, MPI_Request[], int*, int*, MPI_Status*)
267 | int MPI_Waitall(int, MPI_Request[], MPI_Status[])
268 | int MPI_Testall(int, MPI_Request[], int*, MPI_Status[])
269 | int MPI_Waitsome(int, MPI_Request[], int*, int[], MPI_Status[])
270 | int MPI_Testsome(int, MPI_Request[], int*, int[], MPI_Status[])
271 |
272 | int MPI_Start(MPI_Request*)
273 | int MPI_Startall(int, MPI_Request*)
274 |
275 | ctypedef int MPI_Grequest_cancel_function(void*,int)
276 | ctypedef int MPI_Grequest_free_function(void*)
277 | ctypedef int MPI_Grequest_query_function(void*,MPI_Status*)
278 | int MPI_Grequest_start(MPI_Grequest_query_function*, MPI_Grequest_free_function*, MPI_Grequest_cancel_function*, void*, MPI_Request*)
279 | int MPI_Grequest_complete(MPI_Request)
280 |
281 | #-----------------------------------------------------------------
282 |
283 | MPI_Op MPI_OP_NULL #:= 0
284 | MPI_Op MPI_MAX #:= MPI_OP_NULL
285 | MPI_Op MPI_MIN #:= MPI_OP_NULL
286 | MPI_Op MPI_SUM #:= MPI_OP_NULL
287 | MPI_Op MPI_PROD #:= MPI_OP_NULL
288 | MPI_Op MPI_LAND #:= MPI_OP_NULL
289 | MPI_Op MPI_BAND #:= MPI_OP_NULL
290 | MPI_Op MPI_LOR #:= MPI_OP_NULL
291 | MPI_Op MPI_BOR #:= MPI_OP_NULL
292 | MPI_Op MPI_LXOR #:= MPI_OP_NULL
293 | MPI_Op MPI_BXOR #:= MPI_OP_NULL
294 | MPI_Op MPI_MAXLOC #:= MPI_OP_NULL
295 | MPI_Op MPI_MINLOC #:= MPI_OP_NULL
296 | MPI_Op MPI_REPLACE #:= MPI_OP_NULL
297 | MPI_Op MPI_NO_OP #:= MPI_OP_NULL
298 |
299 | int MPI_Op_free(MPI_Op*)
300 |
301 | ctypedef void MPI_User_function(void*,void*,int*,MPI_Datatype*)
302 | int MPI_Op_create(MPI_User_function*, int, MPI_Op*)
303 | int MPI_Op_commutative(MPI_Op, int*)
304 |
305 | #-----------------------------------------------------------------
306 |
307 | MPI_Info MPI_INFO_NULL #:= 0
308 | MPI_Info MPI_INFO_ENV #:= MPI_INFO_NULL
309 |
310 | int MPI_Info_free(MPI_Info*)
311 | int MPI_Info_create(MPI_Info*)
312 | int MPI_Info_dup(MPI_Info, MPI_Info*)
313 |
314 | enum: MPI_MAX_INFO_KEY #:= 1
315 | enum: MPI_MAX_INFO_VAL #:= 1
316 | int MPI_Info_get(MPI_Info, char[], int, char[], int*)
317 | int MPI_Info_set(MPI_Info, char[], char[])
318 | int MPI_Info_delete(MPI_Info, char[])
319 |
320 | int MPI_Info_get_nkeys(MPI_Info, int*)
321 | int MPI_Info_get_nthkey(MPI_Info, int, char[])
322 | int MPI_Info_get_valuelen(MPI_Info, char[], int*, int*)
323 |
324 | #-----------------------------------------------------------------
325 |
326 | MPI_Group MPI_GROUP_NULL #:= 0
327 | MPI_Group MPI_GROUP_EMPTY #:= 1
328 |
329 | int MPI_Group_free(MPI_Group*)
330 |
331 | int MPI_Group_size(MPI_Group, int*)
332 | int MPI_Group_rank(MPI_Group, int*)
333 | int MPI_Group_translate_ranks(MPI_Group, int, int[], MPI_Group, int[])
334 |
335 | int MPI_Group_compare(MPI_Group, MPI_Group, int*)
336 |
337 | int MPI_Group_union(MPI_Group, MPI_Group, MPI_Group*)
338 | int MPI_Group_intersection(MPI_Group, MPI_Group, MPI_Group*)
339 | int MPI_Group_difference(MPI_Group, MPI_Group, MPI_Group*)
340 | int MPI_Group_incl(MPI_Group, int, int[], MPI_Group*)
341 | int MPI_Group_excl(MPI_Group, int, int[], MPI_Group*)
342 | int MPI_Group_range_incl(MPI_Group, int, int[][3], MPI_Group*)
343 | int MPI_Group_range_excl(MPI_Group, int, int[][3], MPI_Group*)
344 |
345 | #-----------------------------------------------------------------
346 |
347 | MPI_Comm MPI_COMM_NULL #:= 0
348 | MPI_Comm MPI_COMM_SELF #:= MPI_COMM_NULL
349 | MPI_Comm MPI_COMM_WORLD #:= MPI_COMM_NULL
350 |
351 | int MPI_Comm_free(MPI_Comm*)
352 |
353 | int MPI_Comm_group(MPI_Comm, MPI_Group*)
354 |
355 | int MPI_Comm_size(MPI_Comm, int*)
356 | int MPI_Comm_rank(MPI_Comm, int*)
357 |
358 | int MPI_Comm_compare(MPI_Comm, MPI_Comm, int*)
359 | int MPI_Topo_test(MPI_Comm, int*)
360 | int MPI_Comm_test_inter(MPI_Comm, int*)
361 |
362 | int MPI_Abort(MPI_Comm, int)
363 |
364 | int MPI_Send(void*, int, MPI_Datatype, int, int, MPI_Comm)
365 | int MPI_Recv(void*, int, MPI_Datatype, int, int, MPI_Comm, MPI_Status*)
366 | int MPI_Sendrecv(void*, int, MPI_Datatype,int, int, void*, int, MPI_Datatype, int, int, MPI_Comm, MPI_Status*)
367 | int MPI_Sendrecv_replace(void*, int, MPI_Datatype, int, int, int, int, MPI_Comm, MPI_Status*)
368 |
369 | enum: MPI_BSEND_OVERHEAD #:= 0
370 | int MPI_Buffer_attach(void*, int)
371 | int MPI_Buffer_detach(void*, int*)
372 | int MPI_Bsend(void*, int, MPI_Datatype, int, int, MPI_Comm)
373 | int MPI_Ssend(void*, int, MPI_Datatype, int, int, MPI_Comm)
374 | int MPI_Rsend(void*, int, MPI_Datatype, int, int, MPI_Comm)
375 |
376 | int MPI_Isend(void*, int, MPI_Datatype, int, int, MPI_Comm, MPI_Request*)
377 | int MPI_Ibsend(void*, int, MPI_Datatype, int, int, MPI_Comm, MPI_Request*)
378 | int MPI_Issend(void*, int, MPI_Datatype, int, int, MPI_Comm, MPI_Request*)
379 | int MPI_Irsend(void*, int, MPI_Datatype, int, int, MPI_Comm, MPI_Request*)
380 | int MPI_Irecv(void*, int, MPI_Datatype, int, int, MPI_Comm, MPI_Request*)
381 |
382 | int MPI_Send_init(void*, int, MPI_Datatype, int, int, MPI_Comm, MPI_Request*)
383 | int MPI_Bsend_init(void*, int, MPI_Datatype, int,int, MPI_Comm, MPI_Request*)
384 | int MPI_Ssend_init(void*, int, MPI_Datatype, int,int, MPI_Comm, MPI_Request*)
385 | int MPI_Rsend_init(void*, int, MPI_Datatype, int,int, MPI_Comm, MPI_Request*)
386 | int MPI_Recv_init(void*, int, MPI_Datatype, int,int, MPI_Comm, MPI_Request*)
387 |
388 | int MPI_Probe(int, int, MPI_Comm, MPI_Status*)
389 | int MPI_Iprobe(int, int, MPI_Comm, int*, MPI_Status*)
390 |
391 | MPI_Message MPI_MESSAGE_NULL #:= 0
392 | MPI_Message MPI_MESSAGE_NO_PROC #:= MPI_MESSAGE_NULL
393 | int MPI_Mprobe(int, int, MPI_Comm, MPI_Message*, MPI_Status*)
394 | int MPI_Improbe(int, int, MPI_Comm, int*, MPI_Message*, MPI_Status*)
395 | int MPI_Mrecv(void*, int, MPI_Datatype, MPI_Message*, MPI_Status*)
396 | int MPI_Imrecv(void*, int, MPI_Datatype, MPI_Message*, MPI_Request*)
397 |
398 | int MPI_Barrier(MPI_Comm)
399 | int MPI_Bcast(void*, int, MPI_Datatype, int, MPI_Comm)
400 | int MPI_Gather(void*, int, MPI_Datatype, void*, int, MPI_Datatype, int, MPI_Comm)
401 | int MPI_Gatherv(void*, int, MPI_Datatype, void*, int[], int[], MPI_Datatype, int, MPI_Comm)
402 | int MPI_Scatter(void*, int, MPI_Datatype, void*, int, MPI_Datatype, int, MPI_Comm)
403 | int MPI_Scatterv(void*, int[], int[], MPI_Datatype, void*, int, MPI_Datatype, int, MPI_Comm)
404 | int MPI_Allgather(void*, int, MPI_Datatype, void*, int, MPI_Datatype, MPI_Comm)
405 | int MPI_Allgatherv(void*, int, MPI_Datatype, void*, int[], int[], MPI_Datatype, MPI_Comm)
406 | int MPI_Alltoall(void*, int, MPI_Datatype, void*, int, MPI_Datatype, MPI_Comm)
407 | int MPI_Alltoallv(void*, int[], int[], MPI_Datatype, void*, int[], int[], MPI_Datatype, MPI_Comm)
408 | int MPI_Alltoallw(void*, int[], int[], MPI_Datatype[], void*, int[], int[], MPI_Datatype[], MPI_Comm)
409 |
410 | int MPI_Reduce(void*, void*, int, MPI_Datatype, MPI_Op, int, MPI_Comm)
411 | int MPI_Allreduce(void*, void*, int, MPI_Datatype, MPI_Op, MPI_Comm)
412 | int MPI_Reduce_local(void*, void*, int, MPI_Datatype, MPI_Op)
413 | int MPI_Reduce_scatter_block(void*, void*, int, MPI_Datatype, MPI_Op, MPI_Comm)
414 | int MPI_Reduce_scatter(void*, void*, int[], MPI_Datatype, MPI_Op, MPI_Comm)
415 | int MPI_Scan(void*, void*, int, MPI_Datatype, MPI_Op, MPI_Comm)
416 | int MPI_Exscan(void*, void*, int, MPI_Datatype, MPI_Op, MPI_Comm)
417 |
418 | int MPI_Neighbor_allgather(void*, int, MPI_Datatype, void*, int, MPI_Datatype, MPI_Comm)
419 | int MPI_Neighbor_allgatherv(void*, int, MPI_Datatype, void*, int[], int[], MPI_Datatype, MPI_Comm)
420 | int MPI_Neighbor_alltoall(void*, int, MPI_Datatype, void*, int, MPI_Datatype, MPI_Comm)
421 | int MPI_Neighbor_alltoallv(void*, int[], int[],MPI_Datatype, void*, int[],int[], MPI_Datatype, MPI_Comm)
422 | int MPI_Neighbor_alltoallw(void*, int[], MPI_Aint[],MPI_Datatype[], void*, int[],MPI_Aint[], MPI_Datatype[], MPI_Comm)
423 |
424 | int MPI_Ibarrier(MPI_Comm, MPI_Request*)
425 | int MPI_Ibcast(void*, int, MPI_Datatype, int, MPI_Comm, MPI_Request*)
426 | int MPI_Igather(void*, int, MPI_Datatype, void*, int, MPI_Datatype, int, MPI_Comm, MPI_Request*)
427 | int MPI_Igatherv(void*, int, MPI_Datatype, void*, int[], int[], MPI_Datatype, int, MPI_Comm, MPI_Request*)
428 | int MPI_Iscatter(void*, int, MPI_Datatype, void*, int, MPI_Datatype, int, MPI_Comm, MPI_Request*)
429 | int MPI_Iscatterv(void*, int[], int[], MPI_Datatype, void*, int, MPI_Datatype, int, MPI_Comm, MPI_Request*)
430 | int MPI_Iallgather(void*, int, MPI_Datatype, void*, int, MPI_Datatype, MPI_Comm, MPI_Request*)
431 | int MPI_Iallgatherv(void*, int, MPI_Datatype, void*, int[], int[], MPI_Datatype, MPI_Comm, MPI_Request*)
432 | int MPI_Ialltoall(void*, int, MPI_Datatype, void*, int, MPI_Datatype, MPI_Comm, MPI_Request*)
433 | int MPI_Ialltoallv(void*, int[], int[], MPI_Datatype, void*, int[], int[], MPI_Datatype, MPI_Comm, MPI_Request*)
434 | int MPI_Ialltoallw(void*, int[], int[], MPI_Datatype[], void*, int[], int[], MPI_Datatype[], MPI_Comm, MPI_Request*)
435 |
436 | int MPI_Ireduce(void*, void*, int, MPI_Datatype, MPI_Op, int, MPI_Comm, MPI_Request*)
437 | int MPI_Iallreduce(void*, void*, int, MPI_Datatype, MPI_Op, MPI_Comm, MPI_Request*)
438 | int MPI_Ireduce_scatter_block(void*, void*, int, MPI_Datatype, MPI_Op, MPI_Comm, MPI_Request*)
439 | int MPI_Ireduce_scatter(void*, void*, int[], MPI_Datatype, MPI_Op, MPI_Comm, MPI_Request*)
440 | int MPI_Iscan(void*, void*, int, MPI_Datatype, MPI_Op, MPI_Comm, MPI_Request*)
441 | int MPI_Iexscan(void*, void*, int, MPI_Datatype, MPI_Op, MPI_Comm, MPI_Request*)
442 |
443 | int MPI_Ineighbor_allgather(void*, int, MPI_Datatype, void*, int, MPI_Datatype, MPI_Comm, MPI_Request*)
444 | int MPI_Ineighbor_allgatherv(void*, int, MPI_Datatype, void*, int[], int[], MPI_Datatype, MPI_Comm, MPI_Request*)
445 | int MPI_Ineighbor_alltoall(void*, int, MPI_Datatype, void*, int, MPI_Datatype, MPI_Comm, MPI_Request*)
446 | int MPI_Ineighbor_alltoallv(void*, int[], int[],MPI_Datatype, void*, int[],int[], MPI_Datatype, MPI_Comm, MPI_Request*)
447 | int MPI_Ineighbor_alltoallw(void*, int[], MPI_Aint[],MPI_Datatype[], void*, int[],MPI_Aint[], MPI_Datatype[], MPI_Comm, MPI_Request*)
448 |
449 | int MPI_Comm_dup(MPI_Comm, MPI_Comm*)
450 | int MPI_Comm_dup_with_info(MPI_Comm, MPI_Info, MPI_Comm*)
451 | int MPI_Comm_idup(MPI_Comm, MPI_Comm*, MPI_Request*)
452 | int MPI_Comm_create(MPI_Comm, MPI_Group, MPI_Comm*)
453 | int MPI_Comm_create_group(MPI_Comm, MPI_Group, int, MPI_Comm*)
454 | int MPI_Comm_split(MPI_Comm, int, int, MPI_Comm*)
455 | enum: MPI_COMM_TYPE_SHARED #:= MPI_UNDEFINED
456 | int MPI_Comm_split_type(MPI_Comm, int, int, MPI_Info, MPI_Comm*)
457 | int MPI_Comm_set_info(MPI_Comm, MPI_Info)
458 | int MPI_Comm_get_info(MPI_Comm, MPI_Info*)
459 |
460 | enum: MPI_CART #:= MPI_UNDEFINED
461 | int MPI_Cart_create(MPI_Comm, int, int[], int[], int, MPI_Comm*)
462 | int MPI_Cartdim_get(MPI_Comm, int*)
463 | int MPI_Cart_get(MPI_Comm, int, int[], int[], int[])
464 | int MPI_Cart_rank(MPI_Comm, int[], int*)
465 | int MPI_Cart_coords(MPI_Comm, int, int, int[])
466 | int MPI_Cart_shift(MPI_Comm, int, int, int[], int[])
467 | int MPI_Cart_sub(MPI_Comm, int[], MPI_Comm*)
468 | int MPI_Cart_map(MPI_Comm, int, int[], int[], int*)
469 | int MPI_Dims_create(int, int, int[])
470 |
471 | enum: MPI_GRAPH #:= MPI_UNDEFINED
472 | int MPI_Graph_create(MPI_Comm, int, int[], int[], int, MPI_Comm*)
473 | int MPI_Graphdims_get(MPI_Comm, int*, int*)
474 | int MPI_Graph_get(MPI_Comm, int, int, int[], int[])
475 | int MPI_Graph_map(MPI_Comm, int, int[], int[], int*)
476 | int MPI_Graph_neighbors_count(MPI_Comm, int, int*)
477 | int MPI_Graph_neighbors(MPI_Comm, int, int, int[])
478 |
479 | enum: MPI_DIST_GRAPH #:= MPI_UNDEFINED
480 | int* MPI_UNWEIGHTED #:= 0
481 | int* MPI_WEIGHTS_EMPTY #:= MPI_UNWEIGHTED
482 | int MPI_Dist_graph_create_adjacent(MPI_Comm, int, int[], int[], int, int[], int[], MPI_Info, int, MPI_Comm*)
483 | int MPI_Dist_graph_create(MPI_Comm, int, int[], int[], int[], int[], MPI_Info, int, MPI_Comm*)
484 | int MPI_Dist_graph_neighbors_count(MPI_Comm, int*, int*, int*)
485 | int MPI_Dist_graph_neighbors(MPI_Comm, int, int[], int[], int, int[], int[])
486 |
487 | int MPI_Intercomm_create(MPI_Comm, int, MPI_Comm, int, int, MPI_Comm*)
488 | int MPI_Comm_remote_group(MPI_Comm, MPI_Group*)
489 | int MPI_Comm_remote_size(MPI_Comm, int*)
490 | int MPI_Intercomm_merge(MPI_Comm, int, MPI_Comm*)
491 |
492 | enum: MPI_MAX_PORT_NAME #:= 1
493 | int MPI_Open_port(MPI_Info, char[])
494 | int MPI_Close_port(char[])
495 |
496 | int MPI_Publish_name(char[], MPI_Info, char[])
497 | int MPI_Unpublish_name(char[], MPI_Info, char[])
498 | int MPI_Lookup_name(char[], MPI_Info, char[])
499 |
500 | int MPI_Comm_accept(char[], MPI_Info, int, MPI_Comm, MPI_Comm*)
501 | int MPI_Comm_connect(char[], MPI_Info, int, MPI_Comm, MPI_Comm*)
502 | int MPI_Comm_join(int, MPI_Comm*)
503 | int MPI_Comm_disconnect(MPI_Comm*)
504 |
505 | char** MPI_ARGV_NULL #:= 0
506 | char*** MPI_ARGVS_NULL #:= 0
507 | int* MPI_ERRCODES_IGNORE #:= 0
508 | int MPI_Comm_spawn(char[], char*[], int, MPI_Info, int, MPI_Comm, MPI_Comm*, int[])
509 | int MPI_Comm_spawn_multiple(int, char*[], char**[], int[], MPI_Info[], int, MPI_Comm, MPI_Comm*, int[])
510 | int MPI_Comm_get_parent(MPI_Comm*)
511 |
512 | # Deprecated since MPI-2, removed in MPI-3
513 | int MPI_Errhandler_get(MPI_Comm, MPI_Errhandler*)
514 | int MPI_Errhandler_set(MPI_Comm, MPI_Errhandler)
515 | ctypedef void MPI_Handler_function(MPI_Comm*,int*,...)
516 | int MPI_Errhandler_create(MPI_Handler_function*, MPI_Errhandler*)
517 |
518 | # Deprecated since MPI-2
519 | int MPI_Attr_get(MPI_Comm, int, void*, int*)
520 | int MPI_Attr_put(MPI_Comm, int, void*)
521 | int MPI_Attr_delete(MPI_Comm, int)
522 | ctypedef int MPI_Copy_function(MPI_Comm,int,void*,void*,void*,int*)
523 | ctypedef int MPI_Delete_function(MPI_Comm,int,void*,void*)
524 | MPI_Copy_function* MPI_DUP_FN #:= 0
525 | MPI_Copy_function* MPI_NULL_COPY_FN #:= 0
526 | MPI_Delete_function* MPI_NULL_DELETE_FN #:= 0
527 | int MPI_Keyval_create(MPI_Copy_function*, MPI_Delete_function*, int*, void*)
528 | int MPI_Keyval_free(int*)
529 |
530 | int MPI_Comm_get_errhandler(MPI_Comm, MPI_Errhandler*) #:= MPI_Errhandler_get
531 | int MPI_Comm_set_errhandler(MPI_Comm, MPI_Errhandler) #:= MPI_Errhandler_set
532 | ctypedef void MPI_Comm_errhandler_fn(MPI_Comm*,int*,...) #:= MPI_Handler_function
533 | ctypedef void MPI_Comm_errhandler_function(MPI_Comm*,int*,...) #:= MPI_Comm_errhandler_fn
534 | int MPI_Comm_create_errhandler(MPI_Comm_errhandler_function*, MPI_Errhandler*) #:= MPI_Errhandler_create
535 | int MPI_Comm_call_errhandler(MPI_Comm, int)
536 |
537 | int MPI_Comm_get_name(MPI_Comm, char[], int*)
538 | int MPI_Comm_set_name(MPI_Comm, char[])
539 |
540 | enum: MPI_TAG_UB #:= MPI_KEYVAL_INVALID
541 | enum: MPI_HOST #:= MPI_KEYVAL_INVALID
542 | enum: MPI_IO #:= MPI_KEYVAL_INVALID
543 | enum: MPI_WTIME_IS_GLOBAL #:= MPI_KEYVAL_INVALID
544 |
545 | enum: MPI_UNIVERSE_SIZE #:= MPI_KEYVAL_INVALID
546 | enum: MPI_APPNUM #:= MPI_KEYVAL_INVALID
547 | enum: MPI_LASTUSEDCODE #:= MPI_KEYVAL_INVALID
548 |
549 | int MPI_Comm_get_attr(MPI_Comm, int, void*, int*) #:= MPI_Attr_get
550 | int MPI_Comm_set_attr(MPI_Comm, int, void*) #:= MPI_Attr_put
551 | int MPI_Comm_delete_attr(MPI_Comm, int) #:= MPI_Attr_delete
552 |
553 | ctypedef int MPI_Comm_copy_attr_function(MPI_Comm,int,void*,void*,void*,int*) #:= MPI_Copy_function
554 | ctypedef int MPI_Comm_delete_attr_function(MPI_Comm,int,void*,void*) #:= MPI_Delete_function
555 | MPI_Comm_copy_attr_function* MPI_COMM_DUP_FN #:= MPI_DUP_FN
556 | MPI_Comm_copy_attr_function* MPI_COMM_NULL_COPY_FN #:= MPI_NULL_COPY_FN
557 | MPI_Comm_delete_attr_function* MPI_COMM_NULL_DELETE_FN #:= MPI_NULL_DELETE_FN
558 | int MPI_Comm_create_keyval(MPI_Comm_copy_attr_function*, MPI_Comm_delete_attr_function*, int*, void*) #:= MPI_Keyval_create
559 | int MPI_Comm_free_keyval(int*) #:= MPI_Keyval_free
560 |
561 | #-----------------------------------------------------------------
562 |
563 | MPI_Win MPI_WIN_NULL #:= 0
564 |
565 | int MPI_Win_free(MPI_Win*)
566 | int MPI_Win_create(void*, MPI_Aint, int, MPI_Info, MPI_Comm, MPI_Win*)
567 | int MPI_Win_allocate(MPI_Aint, int, MPI_Info, MPI_Comm, void*, MPI_Win*)
568 | int MPI_Win_allocate_shared(MPI_Aint, int, MPI_Info, MPI_Comm, void*, MPI_Win*)
569 | int MPI_Win_shared_query(MPI_Win, int, MPI_Aint*, int*, void*)
570 | int MPI_Win_create_dynamic(MPI_Info, MPI_Comm, MPI_Win*)
571 | int MPI_Win_attach(MPI_Win, void*, MPI_Aint)
572 | int MPI_Win_detach(MPI_Win, void*)
573 | int MPI_Win_set_info(MPI_Win, MPI_Info)
574 | int MPI_Win_get_info(MPI_Win, MPI_Info*)
575 | int MPI_Win_get_group(MPI_Win, MPI_Group*)
576 |
577 | int MPI_Get(void*, int, MPI_Datatype, int, MPI_Aint, int, MPI_Datatype, MPI_Win)
578 | int MPI_Put(void*, int, MPI_Datatype, int, MPI_Aint, int, MPI_Datatype, MPI_Win)
579 | int MPI_Accumulate(void*, int, MPI_Datatype, int, MPI_Aint, int, MPI_Datatype, MPI_Op, MPI_Win)
580 | int MPI_Get_accumulate(void*, int, MPI_Datatype, void*, int,MPI_Datatype, int, MPI_Aint, int, MPI_Datatype, MPI_Op, MPI_Win)
581 | int MPI_Fetch_and_op(void*, void*, MPI_Datatype, int, MPI_Aint, MPI_Op, MPI_Win)
582 | int MPI_Compare_and_swap(void*, void*, void*, MPI_Datatype, int, MPI_Aint, MPI_Win)
583 |
584 | int MPI_Rget(void*, int, MPI_Datatype, int, MPI_Aint, int, MPI_Datatype, MPI_Win, MPI_Request*)
585 | int MPI_Rput(void*, int, MPI_Datatype, int, MPI_Aint, int, MPI_Datatype, MPI_Win, MPI_Request*)
586 | int MPI_Raccumulate(void*, int, MPI_Datatype, int, MPI_Aint, int, MPI_Datatype, MPI_Op, MPI_Win, MPI_Request*)
587 | int MPI_Rget_accumulate(void*, int, MPI_Datatype, void*, int,MPI_Datatype, int, MPI_Aint, int, MPI_Datatype, MPI_Op, MPI_Win, MPI_Request*)
588 |
589 | enum: MPI_MODE_NOCHECK #:= MPI_UNDEFINED
590 | enum: MPI_MODE_NOSTORE #:= MPI_UNDEFINED
591 | enum: MPI_MODE_NOPUT #:= MPI_UNDEFINED
592 | enum: MPI_MODE_NOPRECEDE #:= MPI_UNDEFINED
593 | enum: MPI_MODE_NOSUCCEED #:= MPI_UNDEFINED
594 | int MPI_Win_fence(int, MPI_Win)
595 | int MPI_Win_post(MPI_Group, int, MPI_Win)
596 | int MPI_Win_start(MPI_Group, int, MPI_Win)
597 | int MPI_Win_complete(MPI_Win)
598 | int MPI_Win_wait(MPI_Win)
599 | int MPI_Win_test(MPI_Win, int*)
600 |
601 | enum: MPI_LOCK_EXCLUSIVE #:= MPI_UNDEFINED
602 | enum: MPI_LOCK_SHARED #:= MPI_UNDEFINED
603 | int MPI_Win_lock(int, int, int, MPI_Win)
604 | int MPI_Win_unlock(int, MPI_Win)
605 | int MPI_Win_lock_all(int, MPI_Win)
606 | int MPI_Win_unlock_all(MPI_Win)
607 | int MPI_Win_flush(int, MPI_Win)
608 | int MPI_Win_flush_all(MPI_Win)
609 | int MPI_Win_flush_local(int, MPI_Win)
610 | int MPI_Win_flush_local_all(MPI_Win)
611 | int MPI_Win_sync(MPI_Win)
612 |
613 | int MPI_Win_get_errhandler(MPI_Win, MPI_Errhandler*)
614 | int MPI_Win_set_errhandler(MPI_Win, MPI_Errhandler)
615 | ctypedef void MPI_Win_errhandler_fn(MPI_Win*,int*,...)
616 | ctypedef void MPI_Win_errhandler_function(MPI_Win*,int*,...) #:= MPI_Win_errhandler_fn
617 | int MPI_Win_create_errhandler(MPI_Win_errhandler_function*, MPI_Errhandler*)
618 | int MPI_Win_call_errhandler(MPI_Win, int)
619 |
620 | int MPI_Win_get_name(MPI_Win, char[], int*)
621 | int MPI_Win_set_name(MPI_Win, char[])
622 |
623 | enum: MPI_WIN_BASE #:= MPI_KEYVAL_INVALID
624 | enum: MPI_WIN_SIZE #:= MPI_KEYVAL_INVALID
625 | enum: MPI_WIN_DISP_UNIT #:= MPI_KEYVAL_INVALID
626 | enum: MPI_WIN_CREATE_FLAVOR #:= MPI_KEYVAL_INVALID
627 | enum: MPI_WIN_MODEL #:= MPI_KEYVAL_INVALID
628 |
629 | enum: MPI_WIN_FLAVOR_CREATE #:= MPI_UNDEFINED
630 | enum: MPI_WIN_FLAVOR_ALLOCATE #:= MPI_UNDEFINED
631 | enum: MPI_WIN_FLAVOR_DYNAMIC #:= MPI_UNDEFINED
632 | enum: MPI_WIN_FLAVOR_SHARED #:= MPI_UNDEFINED
633 |
634 | enum: MPI_WIN_SEPARATE #:= MPI_UNDEFINED
635 | enum: MPI_WIN_UNIFIED #:= MPI_UNDEFINED
636 |
637 | int MPI_Win_get_attr(MPI_Win, int, void*, int*)
638 | int MPI_Win_set_attr(MPI_Win, int, void*)
639 | int MPI_Win_delete_attr(MPI_Win, int)
640 |
641 | ctypedef int MPI_Win_copy_attr_function(MPI_Win,int,void*,void*,void*,int*)
642 | ctypedef int MPI_Win_delete_attr_function(MPI_Win,int,void*,void*)
643 | MPI_Win_copy_attr_function* MPI_WIN_DUP_FN #:= 0
644 | MPI_Win_copy_attr_function* MPI_WIN_NULL_COPY_FN #:= 0
645 | MPI_Win_delete_attr_function* MPI_WIN_NULL_DELETE_FN #:= 0
646 | int MPI_Win_create_keyval(MPI_Win_copy_attr_function*, MPI_Win_delete_attr_function*, int*, void*)
647 | int MPI_Win_free_keyval(int*)
648 |
649 | #-----------------------------------------------------------------
650 |
651 | MPI_File MPI_FILE_NULL #:= 0
652 |
653 | enum: MPI_MODE_RDONLY #:= 1
654 | enum: MPI_MODE_RDWR #:= 2
655 | enum: MPI_MODE_WRONLY #:= 4
656 | enum: MPI_MODE_CREATE #:= 8
657 | enum: MPI_MODE_EXCL #:= 16
658 | enum: MPI_MODE_DELETE_ON_CLOSE #:= 32
659 | enum: MPI_MODE_UNIQUE_OPEN #:= 64
660 | enum: MPI_MODE_APPEND #:= 128
661 | enum: MPI_MODE_SEQUENTIAL #:= 256
662 |
663 | int MPI_File_open(MPI_Comm, char[], int, MPI_Info, MPI_File*)
664 | int MPI_File_close(MPI_File*)
665 | int MPI_File_delete(char[], MPI_Info)
666 |
667 | int MPI_File_set_size(MPI_File, MPI_Offset)
668 | int MPI_File_preallocate(MPI_File, MPI_Offset)
669 | int MPI_File_get_size(MPI_File, MPI_Offset*)
670 | int MPI_File_get_group(MPI_File, MPI_Group*)
671 | int MPI_File_get_amode(MPI_File, int*)
672 | int MPI_File_set_info(MPI_File, MPI_Info)
673 | int MPI_File_get_info(MPI_File, MPI_Info*)
674 |
675 | int MPI_File_get_view(MPI_File, MPI_Offset*, MPI_Datatype*, MPI_Datatype*, char[])
676 | int MPI_File_set_view(MPI_File, MPI_Offset, MPI_Datatype, MPI_Datatype, char[], MPI_Info)
677 |
678 | int MPI_File_read_at (MPI_File, MPI_Offset, void*, int, MPI_Datatype, MPI_Status*)
679 | int MPI_File_read_at_all (MPI_File, MPI_Offset, void*, int, MPI_Datatype, MPI_Status*)
680 | int MPI_File_write_at (MPI_File, MPI_Offset, void*, int, MPI_Datatype, MPI_Status*)
681 | int MPI_File_write_at_all (MPI_File, MPI_Offset, void*, int, MPI_Datatype, MPI_Status*)
682 |
683 | int MPI_File_iread_at (MPI_File, MPI_Offset, void*, int, MPI_Datatype, MPI_Request*)
684 | int MPI_File_iwrite_at (MPI_File, MPI_Offset, void*, int, MPI_Datatype, MPI_Request*)
685 |
686 | enum: MPI_SEEK_SET #:= 0
687 | enum: MPI_SEEK_CUR #:= 1
688 | enum: MPI_SEEK_END #:= 2
689 | enum: MPI_DISPLACEMENT_CURRENT #:= 3
690 | int MPI_File_seek(MPI_File, MPI_Offset, int)
691 | int MPI_File_get_position(MPI_File, MPI_Offset*)
692 | int MPI_File_get_byte_offset(MPI_File, MPI_Offset, MPI_Offset*)
693 |
694 | int MPI_File_read (MPI_File, void*, int, MPI_Datatype, MPI_Status*)
695 | int MPI_File_read_all (MPI_File, void*, int, MPI_Datatype, MPI_Status*)
696 | int MPI_File_write (MPI_File, void*, int, MPI_Datatype, MPI_Status*)
697 | int MPI_File_write_all (MPI_File, void*, int, MPI_Datatype, MPI_Status*)
698 | int MPI_File_iread (MPI_File, void*, int, MPI_Datatype, MPI_Request*)
699 | int MPI_File_iwrite (MPI_File, void*, int, MPI_Datatype, MPI_Request*)
700 |
701 | int MPI_File_read_shared (MPI_File, void*, int, MPI_Datatype, MPI_Status*)
702 | int MPI_File_write_shared (MPI_File, void*, int, MPI_Datatype, MPI_Status*)
703 | int MPI_File_iread_shared (MPI_File, void*, int, MPI_Datatype, MPI_Request*)
704 | int MPI_File_iwrite_shared (MPI_File, void*, int, MPI_Datatype, MPI_Request*)
705 | int MPI_File_read_ordered (MPI_File, void*, int, MPI_Datatype, MPI_Status*)
706 | int MPI_File_write_ordered (MPI_File, void*, int, MPI_Datatype, MPI_Status*)
707 |
708 | int MPI_File_seek_shared(MPI_File, MPI_Offset, int)
709 | int MPI_File_get_position_shared(MPI_File, MPI_Offset*)
710 |
711 | int MPI_File_read_at_all_begin (MPI_File, MPI_Offset, void*, int, MPI_Datatype)
712 | int MPI_File_read_at_all_end (MPI_File, void*, MPI_Status*)
713 | int MPI_File_write_at_all_begin (MPI_File, MPI_Offset, void*, int, MPI_Datatype)
714 | int MPI_File_write_at_all_end (MPI_File, void*, MPI_Status*)
715 | int MPI_File_read_all_begin (MPI_File, void*, int, MPI_Datatype)
716 | int MPI_File_read_all_end (MPI_File, void*, MPI_Status*)
717 | int MPI_File_write_all_begin (MPI_File, void*, int, MPI_Datatype)
718 | int MPI_File_write_all_end (MPI_File, void*, MPI_Status*)
719 | int MPI_File_read_ordered_begin (MPI_File, void*, int, MPI_Datatype)
720 | int MPI_File_read_ordered_end (MPI_File, void*, MPI_Status*)
721 | int MPI_File_write_ordered_begin (MPI_File, void*, int, MPI_Datatype)
722 | int MPI_File_write_ordered_end (MPI_File, void*, MPI_Status*)
723 |
724 | int MPI_File_get_type_extent(MPI_File, MPI_Datatype, MPI_Aint*)
725 |
726 | int MPI_File_set_atomicity(MPI_File, int)
727 | int MPI_File_get_atomicity(MPI_File, int*)
728 | int MPI_File_sync(MPI_File)
729 |
730 | int MPI_File_get_errhandler(MPI_File, MPI_Errhandler*)
731 | int MPI_File_set_errhandler(MPI_File, MPI_Errhandler)
732 | ctypedef void MPI_File_errhandler_fn(MPI_File*,int*,...)
733 | ctypedef void MPI_File_errhandler_function(MPI_File*,int*,...) #:= MPI_File_errhandler_fn
734 | int MPI_File_create_errhandler(MPI_File_errhandler_function*, MPI_Errhandler*)
735 | int MPI_File_call_errhandler(MPI_File, int)
736 |
737 | ctypedef int MPI_Datarep_conversion_function(void*,MPI_Datatype,int,void*,MPI_Offset,void*)
738 | ctypedef int MPI_Datarep_extent_function(MPI_Datatype,MPI_Aint*,void*)
739 | MPI_Datarep_conversion_function* MPI_CONVERSION_FN_NULL #:= 0
740 | enum: MPI_MAX_DATAREP_STRING #:= 1
741 | int MPI_Register_datarep(char[], MPI_Datarep_conversion_function*, MPI_Datarep_conversion_function*, MPI_Datarep_extent_function*, void*)
742 |
743 | #-----------------------------------------------------------------
744 |
745 | MPI_Errhandler MPI_ERRHANDLER_NULL #:= 0
746 | MPI_Errhandler MPI_ERRORS_RETURN #:= MPI_ERRHANDLER_NULL
747 | MPI_Errhandler MPI_ERRORS_ARE_FATAL #:= MPI_ERRHANDLER_NULL
748 |
749 | int MPI_Errhandler_free(MPI_Errhandler*)
750 |
751 | #-----------------------------------------------------------------
752 |
753 | enum: MPI_MAX_ERROR_STRING #:= 1
754 | int MPI_Error_class(int, int*)
755 | int MPI_Error_string(int, char[], int*)
756 |
757 | int MPI_Add_error_class(int*)
758 | int MPI_Add_error_code(int,int*)
759 | int MPI_Add_error_string(int,char[])
760 |
761 | # MPI-1 Error classes
762 | # -------------------
763 | # Actually no errors
764 | enum: MPI_SUCCESS #:= 0
765 | enum: MPI_ERR_LASTCODE #:= 1
766 | # MPI-1 Objects
767 | enum: MPI_ERR_COMM #:= MPI_ERR_LASTCODE
768 | enum: MPI_ERR_GROUP #:= MPI_ERR_LASTCODE
769 | enum: MPI_ERR_TYPE #:= MPI_ERR_LASTCODE
770 | enum: MPI_ERR_REQUEST #:= MPI_ERR_LASTCODE
771 | enum: MPI_ERR_OP #:= MPI_ERR_LASTCODE
772 | # Communication argument parameters
773 | enum: MPI_ERR_BUFFER #:= MPI_ERR_LASTCODE
774 | enum: MPI_ERR_COUNT #:= MPI_ERR_LASTCODE
775 | enum: MPI_ERR_TAG #:= MPI_ERR_LASTCODE
776 | enum: MPI_ERR_RANK #:= MPI_ERR_LASTCODE
777 | enum: MPI_ERR_ROOT #:= MPI_ERR_LASTCODE
778 | enum: MPI_ERR_TRUNCATE #:= MPI_ERR_LASTCODE
779 | # Multiple completion
780 | enum: MPI_ERR_IN_STATUS #:= MPI_ERR_LASTCODE
781 | enum: MPI_ERR_PENDING #:= MPI_ERR_LASTCODE
782 | # Topology argument parameters
783 | enum: MPI_ERR_TOPOLOGY #:= MPI_ERR_LASTCODE
784 | enum: MPI_ERR_DIMS #:= MPI_ERR_LASTCODE
785 | # All other arguments, this is a class with many kinds
786 | enum: MPI_ERR_ARG #:= MPI_ERR_LASTCODE
787 | # Other errors that are not simply an invalid argument
788 | enum: MPI_ERR_OTHER #:= MPI_ERR_LASTCODE
789 | enum: MPI_ERR_UNKNOWN #:= MPI_ERR_LASTCODE
790 | enum: MPI_ERR_INTERN #:= MPI_ERR_LASTCODE
791 |
792 | # MPI-2 Error classes
793 | # -------------------
794 | # Attributes
795 | enum: MPI_ERR_KEYVAL #:= MPI_ERR_ARG
796 | # Memory Allocation
797 | enum: MPI_ERR_NO_MEM #:= MPI_ERR_UNKNOWN
798 | # Info Object
799 | enum: MPI_ERR_INFO #:= MPI_ERR_ARG
800 | enum: MPI_ERR_INFO_KEY #:= MPI_ERR_UNKNOWN
801 | enum: MPI_ERR_INFO_VALUE #:= MPI_ERR_UNKNOWN
802 | enum: MPI_ERR_INFO_NOKEY #:= MPI_ERR_UNKNOWN
803 | # Dynamic Process Management
804 | enum: MPI_ERR_SPAWN #:= MPI_ERR_UNKNOWN
805 | enum: MPI_ERR_PORT #:= MPI_ERR_UNKNOWN
806 | enum: MPI_ERR_SERVICE #:= MPI_ERR_UNKNOWN
807 | enum: MPI_ERR_NAME #:= MPI_ERR_UNKNOWN
808 | # Input/Ouput
809 | enum: MPI_ERR_FILE #:= MPI_ERR_ARG
810 | enum: MPI_ERR_NOT_SAME #:= MPI_ERR_UNKNOWN
811 | enum: MPI_ERR_BAD_FILE #:= MPI_ERR_UNKNOWN
812 | enum: MPI_ERR_NO_SUCH_FILE #:= MPI_ERR_UNKNOWN
813 | enum: MPI_ERR_FILE_EXISTS #:= MPI_ERR_UNKNOWN
814 | enum: MPI_ERR_FILE_IN_USE #:= MPI_ERR_UNKNOWN
815 | enum: MPI_ERR_AMODE #:= MPI_ERR_UNKNOWN
816 | enum: MPI_ERR_ACCESS #:= MPI_ERR_UNKNOWN
817 | enum: MPI_ERR_READ_ONLY #:= MPI_ERR_UNKNOWN
818 | enum: MPI_ERR_NO_SPACE #:= MPI_ERR_UNKNOWN
819 | enum: MPI_ERR_QUOTA #:= MPI_ERR_UNKNOWN
820 | enum: MPI_ERR_UNSUPPORTED_DATAREP #:= MPI_ERR_UNKNOWN
821 | enum: MPI_ERR_UNSUPPORTED_OPERATION #:= MPI_ERR_UNKNOWN
822 | enum: MPI_ERR_CONVERSION #:= MPI_ERR_UNKNOWN
823 | enum: MPI_ERR_DUP_DATAREP #:= MPI_ERR_UNKNOWN
824 | enum: MPI_ERR_IO #:= MPI_ERR_UNKNOWN
825 | # One-Sided Communications
826 | enum: MPI_ERR_WIN #:= MPI_ERR_ARG
827 | enum: MPI_ERR_BASE #:= MPI_ERR_UNKNOWN
828 | enum: MPI_ERR_SIZE #:= MPI_ERR_UNKNOWN
829 | enum: MPI_ERR_DISP #:= MPI_ERR_UNKNOWN
830 | enum: MPI_ERR_ASSERT #:= MPI_ERR_UNKNOWN
831 | enum: MPI_ERR_LOCKTYPE #:= MPI_ERR_UNKNOWN
832 | enum: MPI_ERR_RMA_CONFLICT #:= MPI_ERR_UNKNOWN
833 | enum: MPI_ERR_RMA_SYNC #:= MPI_ERR_UNKNOWN
834 | enum: MPI_ERR_RMA_RANGE #:= MPI_ERR_UNKNOWN
835 | enum: MPI_ERR_RMA_ATTACH #:= MPI_ERR_UNKNOWN
836 | enum: MPI_ERR_RMA_SHARED #:= MPI_ERR_UNKNOWN
837 | enum: MPI_ERR_RMA_FLAVOR #:= MPI_ERR_UNKNOWN
838 |
839 | #-----------------------------------------------------------------
840 |
841 | int MPI_Alloc_mem(MPI_Aint, MPI_Info, void*)
842 | int MPI_Free_mem(void*)
843 |
844 | #-----------------------------------------------------------------
845 |
846 | int MPI_Init(int*, char**[])
847 | int MPI_Finalize()
848 | int MPI_Initialized(int*)
849 | int MPI_Finalized(int*)
850 |
851 | enum: MPI_THREAD_SINGLE #:= 0
852 | enum: MPI_THREAD_FUNNELED #:= 1
853 | enum: MPI_THREAD_SERIALIZED #:= 2
854 | enum: MPI_THREAD_MULTIPLE #:= 3
855 | int MPI_Init_thread(int*, char**[], int, int*)
856 | int MPI_Query_thread(int*)
857 | int MPI_Is_thread_main(int*)
858 |
859 | #-----------------------------------------------------------------
860 |
861 | enum: MPI_VERSION #:= 1
862 | enum: MPI_SUBVERSION #:= 0
863 | int MPI_Get_version(int*, int*)
864 |
865 | enum: MPI_MAX_LIBRARY_VERSION_STRING #:= 1
866 | int MPI_Get_library_version(char[], int*)
867 |
868 | enum: MPI_MAX_PROCESSOR_NAME #:= 1
869 | int MPI_Get_processor_name(char[], int*)
870 |
871 | #-----------------------------------------------------------------
872 |
873 | double MPI_Wtime()
874 | double MPI_Wtick()
875 |
876 | int MPI_Pcontrol(int, ...)
877 |
878 | #-----------------------------------------------------------------
879 |
880 | # Fortran INTEGER
881 | ctypedef int MPI_Fint
882 |
883 | MPI_Fint* MPI_F_STATUS_IGNORE #:= 0
884 | MPI_Fint* MPI_F_STATUSES_IGNORE #:= 0
885 | int MPI_Status_c2f (MPI_Status*, MPI_Fint*)
886 | int MPI_Status_f2c (MPI_Fint*, MPI_Status*)
887 |
888 | # C -> Fortran
889 | MPI_Fint MPI_Type_c2f (MPI_Datatype)
890 | MPI_Fint MPI_Request_c2f (MPI_Request)
891 | MPI_Fint MPI_Message_c2f (MPI_Message)
892 | MPI_Fint MPI_Op_c2f (MPI_Op)
893 | MPI_Fint MPI_Info_c2f (MPI_Info)
894 | MPI_Fint MPI_Group_c2f (MPI_Group)
895 | MPI_Fint MPI_Comm_c2f (MPI_Comm)
896 | MPI_Fint MPI_Win_c2f (MPI_Win)
897 | MPI_Fint MPI_File_c2f (MPI_File)
898 | MPI_Fint MPI_Errhandler_c2f (MPI_Errhandler)
899 |
900 | # Fortran -> C
901 | MPI_Datatype MPI_Type_f2c (MPI_Fint)
902 | MPI_Request MPI_Request_f2c (MPI_Fint)
903 | MPI_Message MPI_Message_f2c (MPI_Fint)
904 | MPI_Op MPI_Op_f2c (MPI_Fint)
905 | MPI_Info MPI_Info_f2c (MPI_Fint)
906 | MPI_Group MPI_Group_f2c (MPI_Fint)
907 | MPI_Comm MPI_Comm_f2c (MPI_Fint)
908 | MPI_Win MPI_Win_f2c (MPI_Fint)
909 | MPI_File MPI_File_f2c (MPI_Fint)
910 | MPI_Errhandler MPI_Errhandler_f2c (MPI_Fint)
911 |
912 | #-----------------------------------------------------------------
913 |
--------------------------------------------------------------------------------
/pfft/tests/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MP-Gadget/pfft-python/aaf907a8b8d3830dcef4b12569263e75522d8755/pfft/tests/__init__.py
--------------------------------------------------------------------------------
/pfft/tests/test_pfft.py:
--------------------------------------------------------------------------------
1 | from __future__ import absolute_import
2 | import pfft
3 |
4 | import numpy
5 | from numpy.testing import assert_array_equal, assert_almost_equal
6 |
7 |
8 | from runtests.mpi import MPITest
9 | from mpi4py import MPI
10 |
11 | def test_world():
12 | world = MPI.COMM_WORLD
13 |
14 | assert_array_equal(pfft.ProcMesh.split(2, None), pfft.ProcMesh.split(2, world))
15 | assert_array_equal(pfft.ProcMesh.split(1, None), pfft.ProcMesh.split(1, world))
16 |
17 | @MPITest(3)
18 | def test_edges(comm):
19 | procmesh = pfft.ProcMesh(np=[comm.size,], comm=comm)
20 |
21 | partition = pfft.Partition(pfft.Type.PFFT_C2C,
22 | [4, 4], procmesh,
23 | pfft.Flags.PFFT_TRANSPOSED_OUT
24 | )
25 |
26 | assert_array_equal(partition.i_edges[0], [0, 2, 4, 4])
27 | assert_array_equal(partition.i_edges[1], [0, 4])
28 |
29 | assert_array_equal(partition.o_edges[1], [0, 2, 4, 4])
30 | assert_array_equal(partition.o_edges[0], [0, 4])
31 |
32 | @MPITest(1)
33 | def test_edges_padded(comm):
34 | procmesh = pfft.ProcMesh(np=[comm.size,], comm=comm)
35 |
36 | partition = pfft.Partition(pfft.Type.PFFT_R2C,
37 | [16, 8], procmesh,
38 | pfft.Flags.PFFT_TRANSPOSED_OUT |
39 | pfft.Flags.PFFT_PADDED_R2C
40 | )
41 |
42 | assert_array_equal(partition.i_edges[0], [0, 16])
43 | assert_array_equal(partition.i_edges[1], [0, 8])
44 |
45 | assert_array_equal(partition.o_edges[0], [0, 16])
46 | assert_array_equal(partition.o_edges[1], [0, 5])
47 |
48 | @MPITest(3)
49 | def test_nino(comm):
50 | procmesh = pfft.ProcMesh(np=[comm.size,], comm=comm)
51 |
52 | partition = pfft.Partition(pfft.Type.PFFT_C2C,
53 | [4, 8], procmesh,
54 | pfft.Flags.PFFT_TRANSPOSED_OUT)
55 |
56 | assert_array_equal(partition.ni, [4, 8])
57 | assert_array_equal(partition.no, [4, 8])
58 |
59 | @MPITest(1)
60 | def test_transposed(comm):
61 | procmesh = pfft.ProcMesh(np=[1,], comm=comm)
62 |
63 | partition = pfft.Partition(pfft.Type.PFFT_C2C,
64 | [4, 8], procmesh,
65 | pfft.Flags.PFFT_TRANSPOSED_OUT)
66 |
67 | buffer = pfft.LocalBuffer(partition)
68 | o = buffer.view_output()
69 | i = buffer.view_input()
70 |
71 | assert_array_equal(i.shape, (4, 8))
72 | assert_array_equal(i.strides, (128, 16))
73 | assert_array_equal(o.shape, (4, 8))
74 | assert_array_equal(o.strides, (16, 64))
75 |
76 | assert o.dtype == numpy.dtype('complex128')
77 | assert i.dtype == numpy.dtype('complex128')
78 |
79 | @MPITest(1)
80 | def test_padded(comm):
81 | procmesh = pfft.ProcMesh(np=[1,], comm=comm)
82 |
83 | partition = pfft.Partition(pfft.Type.PFFT_R2C,
84 | [4, 8], procmesh,
85 | pfft.Flags.PFFT_TRANSPOSED_OUT | pfft.Flags.PFFT_PADDED_R2C)
86 |
87 | buffer = pfft.LocalBuffer(partition)
88 | i = buffer.view_input()
89 | o = buffer.view_output()
90 |
91 | assert_array_equal(i.shape, (4, 8))
92 | assert_array_equal(i.strides, (80, 8))
93 | assert_array_equal(o.shape, (4, 5))
94 | assert_array_equal(o.strides, (16, 64))
95 |
96 | assert i.dtype == numpy.dtype('float64')
97 | assert o.dtype == numpy.dtype('complex128')
98 |
99 | @MPITest(1)
100 | def test_correct_single(comm):
101 | procmesh = pfft.ProcMesh(np=[1], comm=comm)
102 |
103 | partition = pfft.Partition(pfft.Type.PFFT_C2C, [2, 2],
104 | procmesh, flags=pfft.Flags.PFFT_ESTIMATE)
105 |
106 | buffer1 = pfft.LocalBuffer(partition)
107 | buffer2 = pfft.LocalBuffer(partition)
108 |
109 | plan = pfft.Plan(partition, pfft.Direction.PFFT_FORWARD, buffer1, buffer2)
110 | buffer1.view_input()[:] = numpy.arange(4).reshape(2, 2)
111 | correct = numpy.fft.fftn(buffer1.view_input())
112 | plan.execute(buffer1, buffer2)
113 |
114 | assert_array_equal(correct, buffer2.view_output())
115 |
116 | @MPITest(1)
117 | def test_plan_backward(comm):
118 | procmesh = pfft.ProcMesh(np=[1], comm=comm)
119 |
120 | partition = pfft.Partition(pfft.Type.PFFT_R2C, [2, 2],
121 | procmesh, flags=pfft.Flags.PFFT_ESTIMATE | pfft.Flags.PFFT_TRANSPOSED_OUT)
122 |
123 | buffer1 = pfft.LocalBuffer(partition)
124 | buffer2 = pfft.LocalBuffer(partition)
125 |
126 | plan = pfft.Plan(partition, pfft.Direction.PFFT_FORWARD, buffer1, buffer2)
127 | assert plan.flags & pfft.Flags.PFFT_TRANSPOSED_OUT
128 | assert plan.type == pfft.Type.PFFT_R2C
129 |
130 | plan = pfft.Plan(partition, pfft.Direction.PFFT_BACKWARD, buffer1, buffer2)
131 | assert plan.flags & pfft.Flags.PFFT_TRANSPOSED_IN
132 | assert plan.type == pfft.Type.PFFT_C2R
133 |
134 | @MPITest(1)
135 | def test_raw(comm):
136 | procmesh = pfft.ProcMesh(np=[1], comm=comm)
137 |
138 | partition = pfft.Partition(pfft.Type.PFFT_R2C, [8, 8],
139 | procmesh, flags=pfft.Flags.PFFT_ESTIMATE | pfft.Flags.PFFT_TRANSPOSED_OUT)
140 |
141 | buffer1 = pfft.LocalBuffer(partition)
142 | assert buffer1.view_raw().size == 2 * partition.alloc_local
143 |
144 | @MPITest(1)
145 | def test_reuse_local_buffer(comm):
146 | procmesh = pfft.ProcMesh(np=[1], comm=comm)
147 |
148 | partition1 = pfft.Partition(pfft.Type.PFFT_R2C, [8, 8],
149 | procmesh, flags=pfft.Flags.PFFT_ESTIMATE | pfft.Flags.PFFT_TRANSPOSED_OUT)
150 |
151 | partition2 = pfft.Partition(pfft.Type.PFFT_R2C, [8, 8],
152 | procmesh, flags=pfft.Flags.PFFT_ESTIMATE)
153 |
154 | buffer1 = pfft.LocalBuffer(partition1)
155 | buffer2 = pfft.LocalBuffer(partition2, base=buffer1)
156 | buffer3 = pfft.LocalBuffer(partition1)
157 |
158 | assert buffer1 is not buffer2
159 | assert buffer1.address == buffer2.address
160 |
161 | assert buffer1 in buffer2
162 | assert buffer2 in buffer1
163 |
164 | assert buffer1 not in buffer3
165 | assert buffer3 not in buffer1
166 | assert buffer2 not in buffer3
167 | assert buffer3 not in buffer2
168 |
169 | @MPITest(1)
170 | def test_transpose_1d_decom(comm):
171 | procmesh = pfft.ProcMesh(np=[1,], comm=comm)
172 | N = (1, 2, 3, 4)
173 |
174 | partition = pfft.Partition(pfft.Type.PFFT_C2C, N,
175 | procmesh, flags=pfft.Flags.PFFT_ESTIMATE | pfft.Flags.PFFT_TRANSPOSED_OUT)
176 |
177 | buffer = pfft.LocalBuffer(partition)
178 | i = buffer.view_input()
179 | assert_array_equal(i.strides, [384, 192, 64, 16])
180 | o = buffer.view_output()
181 | assert_array_equal(o.strides, [192, 192, 64, 16])
182 |
183 | @MPITest(1)
184 | def test_transpose_2d_decom(comm):
185 | procmesh = pfft.ProcMesh(np=[1,1], comm=comm)
186 | N = (1, 2, 3, 4)
187 |
188 | partition = pfft.Partition(pfft.Type.PFFT_C2C, N,
189 | procmesh, flags=pfft.Flags.PFFT_ESTIMATE | pfft.Flags.PFFT_TRANSPOSED_OUT)
190 |
191 | buffer = pfft.LocalBuffer(partition)
192 | i = buffer.view_input()
193 | assert_array_equal(i.strides, [384, 192, 64, 16])
194 | o = buffer.view_output()
195 | assert_array_equal(o.strides, [64, 192, 64, 16])
196 |
197 | @MPITest(1)
198 | def test_transpose_3d_decom(comm):
199 | procmesh = pfft.ProcMesh(np=[1,1,1], comm=comm)
200 | N = (1, 2, 3, 4, 5)
201 |
202 | partition = pfft.Partition(pfft.Type.PFFT_C2C, N,
203 | procmesh, flags=pfft.Flags.PFFT_ESTIMATE | pfft.Flags.PFFT_TRANSPOSED_OUT)
204 |
205 | buffer = pfft.LocalBuffer(partition)
206 | #FIXME: check with @mpip if this is correct.
207 | i = buffer.view_input()
208 | assert_array_equal(i.strides, [1920, 960, 320, 80, 16])
209 | o = buffer.view_output()
210 | assert_array_equal(o.strides, [80, 960, 320, 80, 16])
211 |
212 | @MPITest((1, 4))
213 | def test_correct_multi(comm):
214 | procmesh = pfft.ProcMesh(np=[comm.size,], comm=comm)
215 | N = (2, 3)
216 | data = numpy.arange(numpy.prod(N), dtype='complex128').reshape(N)
217 | correct = numpy.fft.fftn(data)
218 | result = numpy.zeros_like(data)
219 |
220 | partition = pfft.Partition(pfft.Type.PFFT_C2C, N,
221 | procmesh, flags=pfft.Flags.PFFT_ESTIMATE)
222 |
223 | buffer1 = pfft.LocalBuffer(partition)
224 | buffer2 = pfft.LocalBuffer(partition)
225 |
226 | plan = pfft.Plan(partition, pfft.Direction.PFFT_FORWARD, buffer1, buffer2)
227 |
228 | buffer1.view_input()[:] = data[partition.local_i_slice]
229 | plan.execute(buffer1, buffer2)
230 |
231 | result[partition.local_o_slice] = buffer2.view_output()
232 | result = comm.allreduce(result)
233 | assert_almost_equal(correct, result)
234 |
235 | @MPITest(commsize=1)
236 | def test_leak(comm):
237 | for i in range(1024):
238 | procmesh = pfft.ProcMesh(np=[1,1], comm=comm)
239 |
240 | partition = pfft.Partition(pfft.Type.PFFT_C2C,
241 | [128, 128, 128], procmesh,
242 | pfft.Flags.PFFT_TRANSPOSED_OUT)
243 |
244 | buffer = pfft.LocalBuffer(partition)
245 | #FIXME: check with @mpip if this is correct.
246 | i = buffer.view_input()
247 |
248 | @MPITest([1, 4])
249 | def test_no_segfault_r2r(comm):
250 | procmesh = pfft.ProcMesh(np=[comm.size], comm=comm)
251 |
252 | partition = pfft.Partition(pfft.Type.PFFT_R2R, [32, 32],
253 | procmesh, flags=pfft.Flags.PFFT_ESTIMATE)
254 |
255 | buffer1 = pfft.LocalBuffer(partition)
256 | buffer2 = pfft.LocalBuffer(partition)
257 |
258 | plan = pfft.Plan(partition, pfft.Direction.PFFT_FORWARD, buffer1, buffer2)
259 | plan.execute(buffer1, buffer2)
260 |
261 |
262 | @MPITest([4])
263 | def test_2d_on_2d_c2c(comm):
264 | procmesh = pfft.ProcMesh(np=[2, 2], comm=comm)
265 | N = (8, 8)
266 |
267 | data = numpy.arange(numpy.prod(N), dtype='complex128').reshape(N)
268 |
269 | correct = numpy.fft.fftn(data.copy())
270 | result = numpy.zeros_like(correct)
271 |
272 | partition = pfft.Partition(pfft.Type.PFFT_C2C, N,
273 | procmesh, flags=pfft.Flags.PFFT_ESTIMATE
274 | | pfft.Flags.PFFT_TRANSPOSED_OUT
275 | # | pfft.Flags.PFFT_DESTROY_INPUT
276 | | pfft.Flags.PFFT_PRESERVE_INPUT
277 | )
278 |
279 | buffer1 = pfft.LocalBuffer(partition)
280 | buffer2 = pfft.LocalBuffer(partition)
281 |
282 | plan = pfft.Plan(partition, pfft.Direction.PFFT_FORWARD, buffer1, buffer2)
283 |
284 | buffer1.view_input()[:] = data[partition.local_i_slice]
285 | plan.execute(buffer1, buffer2)
286 |
287 | result[partition.local_o_slice] = buffer2.view_output()
288 | result = comm.allreduce(result)
289 | assert_almost_equal(correct, result)
290 |
291 | @MPITest([1, 4])
292 | def test_2d_on_2d_r2c(comm):
293 | if comm.size == 1:
294 | procmesh = pfft.ProcMesh(np=[1, 1], comm=comm)
295 | else:
296 | procmesh = pfft.ProcMesh(np=[2, 2], comm=comm)
297 | N = (8, 8)
298 |
299 | data = numpy.arange(numpy.prod(N), dtype='f8').reshape(N)
300 |
301 | correct = numpy.fft.rfftn(data.copy())
302 | result = numpy.zeros_like(correct)
303 |
304 | partition = pfft.Partition(pfft.Type.PFFT_R2C, N,
305 | procmesh, flags=pfft.Flags.PFFT_ESTIMATE
306 | | pfft.Flags.PFFT_TRANSPOSED_OUT
307 | | pfft.Flags.PFFT_DESTROY_INPUT
308 | # | pfft.Flags.PADDED_R2C # doesn't work yet
309 | )
310 |
311 | buffer1 = pfft.LocalBuffer(partition)
312 | buffer2 = pfft.LocalBuffer(partition)
313 |
314 | plan = pfft.Plan(partition, pfft.Direction.PFFT_FORWARD, buffer1, buffer2)
315 |
316 | buffer1.view_input()[:] = data[partition.local_i_slice]
317 | plan.execute(buffer1, buffer2)
318 |
319 | result[partition.local_o_slice] = buffer2.view_output()
320 | result = comm.allreduce(result)
321 | assert_almost_equal(correct, result)
322 |
323 | @MPITest(1)
324 | def test_1d(comm):
325 | procmesh = pfft.ProcMesh(np=[], comm=comm)
326 |
327 | N = (16)
328 |
329 | data = numpy.arange(numpy.prod(N), dtype='f8').reshape(N)
330 |
331 | correct = numpy.fft.rfftn(data.copy())
332 | result = numpy.zeros_like(correct)
333 |
334 | partition = pfft.Partition(pfft.Type.PFFT_R2C,
335 | [16], procmesh,
336 | pfft.Flags.PFFT_TRANSPOSED_OUT |
337 | pfft.Flags.PFFT_PADDED_R2C
338 | )
339 |
340 | assert_array_equal(partition.i_edges[0], [0, 16])
341 |
342 | # 1d-transforms are not supported by pfft.
343 | #buffer1 = pfft.LocalBuffer(partition)
344 | #buffer2 = pfft.LocalBuffer(partition)
345 |
346 | #buffer1.view_input()[:] = data[partition.local_i_slice]
347 |
348 | #plan = pfft.Plan(partition, pfft.Direction.PFFT_FORWARD, buffer1, buffer2)
349 | #plan.execute(buffer1, buffer2)
350 |
351 | #result[partition.local_o_slice] = buffer2.view_output()
352 | #result = comm.allreduce(result)
353 | #assert_almost_equal(correct, result)
354 |
--------------------------------------------------------------------------------
/pfft/version.py:
--------------------------------------------------------------------------------
1 | __version__ = "0.1.22"
2 |
--------------------------------------------------------------------------------
/pyproject.toml:
--------------------------------------------------------------------------------
1 | [build-system]
2 | requires = [
3 | "setuptools>=42",
4 | "wheel",
5 | "mpi4py",
6 | "Cython", # Ensure Cython is included as a build dependency
7 | "numpy" # It's often necessary to include numpy if using it in setup.py
8 | ]
9 | build-backend = "setuptools.build_meta"
10 |
--------------------------------------------------------------------------------
/runtests.py:
--------------------------------------------------------------------------------
1 | # pop the current directory from search path
2 | # python interpreter adds this to a top level script
3 | # but we will likely have a name conflict (runtests.py .vs runtests package)
4 | import sys; sys.path.pop(0)
5 | from runtests.mpi import Tester
6 |
7 | import os.path
8 |
9 | tester = Tester(os.path.join(os.path.abspath(__file__)), "pfft")
10 |
11 | tester.main(sys.argv[1:])
12 |
--------------------------------------------------------------------------------
/scripts/pfft-roundtrip-matrix.py:
--------------------------------------------------------------------------------
1 | """
2 | This is the standard tests for pfft-python.
3 |
4 | Roundtrip (Backward + Forward) tests are performed on a 3d grid,
5 | given by -Nmesh. Default is [29, 30, 31].
6 | Tested features are:
7 | regular transform (r2c + c2r, c2c)
8 | transposed in / out,
9 | padded in / out,
10 | destroy input,
11 | inplace transform
12 |
13 | Examples:
14 |
15 | * to run in source code, first get a shell with
16 | python runtests.py --shell
17 |
18 | * for single-rank numpy agreement test, run with
19 | mpirun -np 1 python roundtrip.py -Nmesh 32 32 32 -Nmesh 3 3 3 -verbose
20 |
21 | * for multi-rank tests, run with
22 | mpirun -np 4 python roundtrip.py -Nmesh 32 32 32 -Nmesh 3 3 3 --verbose
23 |
24 | n can be any number. procmeshes tested are:
25 | np = [n], [1, n], [n, 1], [a, d], [d, a]
26 | where a * d == n and a d are closest to n** 0.5
27 | """
28 | from __future__ import print_function
29 |
30 | from mpi4py import MPI
31 | import itertools
32 | import traceback
33 | import numpy
34 | import argparse
35 |
36 | import os.path
37 |
38 | parser = argparse.ArgumentParser(description='Roundtrip testing of pfft',
39 | epilog=__doc__,
40 | formatter_class=argparse.RawDescriptionHelpFormatter
41 | )
42 |
43 | from pfft import *
44 |
45 | oldprint = print
46 | def print(*args, **kwargs):
47 | if MPI.COMM_WORLD.rank == 0:
48 | oldprint(*args, **kwargs)
49 |
50 | parser.add_argument('-Nmesh', nargs='+', type=int,
51 | action='append',
52 | help='size of FFT mesh, default is 29 30 31',
53 | default=[])
54 | parser.add_argument('-Nproc', nargs='+', type=int,
55 | action='append',
56 | help='proc mesh',
57 | default=[])
58 | parser.add_argument('-diag', action='store_true', default=False,
59 | help='show which one failed and which one passed')
60 | parser.add_argument('-rigor', default="estimate", choices=['estimate', 'measure', 'patient', 'exhaustive'],
61 | help='the level of rigor in planning. ')
62 | parser.add_argument('-verbose', action='store_true', default=False,
63 | help='print which test will be ran')
64 |
65 | class LargeError(Exception):
66 | pass
67 |
68 | def test_roundtrip_3d(procmesh, type, flags, inplace, Nmesh):
69 |
70 | # if not requesting destroy input, preserve it
71 | if not (flags & Flags.PFFT_DESTROY_INPUT):
72 | flags |= Flags.PFFT_PRESERVE_INPUT
73 |
74 | partition = Partition(type, Nmesh, procmesh, flags)
75 | for rank in range(MPI.COMM_WORLD.size):
76 | MPI.COMM_WORLD.barrier()
77 | if rank != procmesh.rank:
78 | continue
79 | #oldprint(procmesh.rank, 'roundtrip test, np=', procmesh.np, 'Nmesh = ', Nmesh, 'inplace = ', inplace)
80 | #oldprint(repr(partition))
81 |
82 | buf1 = LocalBuffer(partition)
83 | if inplace:
84 | buf2 = buf1
85 | else:
86 | buf2 = LocalBuffer(partition)
87 |
88 | input = buf1.view_input()
89 | output = buf2.view_output()
90 |
91 | assert input.base == buf1
92 | assert output.base == buf2
93 |
94 | # print 'output', output.shape
95 | # print 'input', input.shape
96 | forward = Plan(
97 | partition,
98 | Direction.PFFT_FORWARD,
99 | buf1,
100 | buf2,
101 | type=type,
102 | flags=flags)
103 | # print(repr(forward))
104 |
105 | # find the inverse plan
106 | typemap = {
107 | Type.PFFT_R2C: Type.PFFT_C2R,
108 | Type.PFFT_C2C: Type.PFFT_C2C,
109 | Type.PFFTF_R2C: Type.PFFTF_C2R,
110 | Type.PFFTF_C2C: Type.PFFTF_C2C
111 | }
112 | btype = typemap[type]
113 | if type == Type.PFFT_R2C or type == Type.PFFTF_R2C:
114 | bflags = flags
115 | # the following lines are just good looking
116 | # PFFT_PADDED_R2C and PFFT_PADDED_C2R
117 | # are identical
118 | bflags &= ~Flags.PFFT_PADDED_R2C
119 | bflags &= ~Flags.PFFT_PADDED_C2R
120 | if flags & Flags.PFFT_PADDED_R2C:
121 | bflags |= Flags.PFFT_PADDED_C2R
122 |
123 | elif type == Type.PFFT_C2C or type == Type.PFFTF_C2C:
124 | bflags = flags
125 | else:
126 | raise Exception("only r2c and c2c roundtrip are tested")
127 |
128 | bflags &= ~Flags.PFFT_TRANSPOSED_IN
129 | bflags &= ~Flags.PFFT_TRANSPOSED_OUT
130 | if flags & Flags.PFFT_TRANSPOSED_IN:
131 | bflags |= Flags.PFFT_TRANSPOSED_OUT
132 | if flags & Flags.PFFT_TRANSPOSED_OUT:
133 | bflags |= Flags.PFFT_TRANSPOSED_IN
134 |
135 |
136 | backward = Plan(
137 | partition,
138 | Direction.PFFT_BACKWARD,
139 | buf2,
140 | buf1,
141 | type=btype,
142 | flags=bflags,
143 | )
144 | #print(repr(backward))
145 |
146 | numpy.random.seed(9999)
147 |
148 | fullinput = numpy.random.normal(size=Nmesh)
149 | if type == Type.PFFT_R2C or type == Type.PFFTF_R2C:
150 | correct = numpy.fft.rfftn(fullinput)
151 | elif type == Type.PFFT_C2C or type == Type.PFFTF_C2C:
152 | correct = numpy.fft.fftn(fullinput)
153 |
154 |
155 | input[:] = fullinput[partition.local_i_slice]
156 | correct = correct[partition.local_o_slice].copy()
157 |
158 | original = input.copy()
159 |
160 | if not inplace:
161 | output[:] = 0
162 |
163 | forward.execute(buf1, buf2)
164 |
165 | if not (flags & Flags.PFFT_DESTROY_INPUT) and not inplace:
166 | fpreserr = numpy.abs(original - input).max()
167 | else:
168 | fpreserr = 0.0
169 |
170 | if output.size > 0:
171 | r2cerr = numpy.abs(output - correct).max()
172 | else:
173 | r2cerr = 0.0
174 | # now test the backward transformation
175 | input[:] = 0
176 | output[:] = correct
177 |
178 | backward.execute(buf2, buf1)
179 |
180 | if not (flags & Flags.PFFT_DESTROY_INPUT) and not inplace:
181 | bpreserr = numpy.abs(output - correct).max()
182 | else:
183 | bpreserr = 0.0
184 |
185 | if input.size > 0:
186 | input[:] /= numpy.prod(Nmesh)
187 | # some distributions have no input value
188 | c2rerr = numpy.abs(original - input).max()
189 | else:
190 | c2rerr = 0.0
191 |
192 | for rank in range(MPI.COMM_WORLD.size):
193 | MPI.COMM_WORLD.barrier()
194 | if rank != procmesh.rank:
195 | continue
196 | # oldprint('error', original - input)
197 | MPI.COMM_WORLD.barrier()
198 |
199 | #if True:
200 | # print(repr(forward.type), 'preserve', "error = ", fpreserr)
201 | # print(repr(forward.type), 'forward', "error = ", r2cerr)
202 | # print(repr(forward.type), 'backward', "error = ", c2rerr)
203 |
204 | fpreserr = MPI.COMM_WORLD.allreduce(fpreserr, MPI.MAX)
205 | bpreserr = MPI.COMM_WORLD.allreduce(bpreserr, MPI.MAX)
206 | r2cerr = MPI.COMM_WORLD.allreduce(r2cerr, MPI.MAX)
207 | c2rerr = MPI.COMM_WORLD.allreduce(c2rerr, MPI.MAX)
208 |
209 | exc = []
210 |
211 | if (fpreserr > 5e-4):
212 | exc.append("forward changed input: %g" % fpreserr)
213 |
214 | if (bpreserr > 5e-4):
215 | exc.append("backward changed input: %g" % bpreserr)
216 |
217 | if (r2cerr > 5e-4):
218 | exc.append("forward: %g" % r2cerr)
219 |
220 | if (c2rerr > 5e-4):
221 | exc.append("backward: %g" % c2rerr)
222 |
223 | if len(exc) > 0:
224 | raise LargeError(":".join(exc))
225 |
226 | def main():
227 |
228 | ns = parser.parse_args()
229 | Nmesh = ns.Nmesh
230 |
231 | if len(Nmesh) == 0:
232 | # default
233 | Nmesh = [[29, 30, 31]]
234 |
235 | if MPI.COMM_WORLD.size == 1 and len(ns.Nproc) == 0:
236 | nplist = [ [1], [1, 1], ]
237 | else:
238 | nplist = ns.Nproc
239 |
240 | rigor = {
241 | 'exhaustive': Flags.PFFT_EXHAUSTIVE,
242 | 'patient' : Flags.PFFT_PATIENT,
243 | 'estimate' : Flags.PFFT_ESTIMATE,
244 | 'measure' : Flags.PFFT_MEASURE,
245 | }[ns.rigor]
246 | import itertools
247 | import functools
248 |
249 | flags = []
250 | matrix = Flags.PFFT_DESTROY_INPUT, Flags.PFFT_PADDED_R2C, Flags.PFFT_TRANSPOSED_OUT
251 | print_flags = functools.reduce(lambda x, y: x | y, matrix, rigor)
252 |
253 | matrix2 = [[0, i] for i in matrix]
254 | for row in itertools.product(*matrix2):
255 | flag = functools.reduce(lambda x, y: x | y, row, rigor)
256 |
257 | flags.append(flag)
258 |
259 | params = list(itertools.product(
260 | nplist, [Type.PFFT_C2C, Type.PFFT_R2C, Type.PFFTF_C2C, Type.PFFTF_R2C], flags, [True, False],
261 | Nmesh,
262 | ))
263 |
264 | PASS = []
265 | FAIL = []
266 | IMPL = []
267 | for param in params:
268 | if ns.verbose:
269 | f = param
270 | print("NP", f[0], repr(Type(f[1])), repr(Flags(f[2])), "InPlace", f[3], "Nmesh", f[4])
271 | np = param[0]
272 | procmesh = ProcMesh(np=np)
273 | try:
274 | test_roundtrip_3d(procmesh, *(param[1:]))
275 | PASS.append(param)
276 | except LargeError as e:
277 | if ns.verbose:
278 | f = param
279 | print("Failed", f, e)
280 | FAIL.append((param, e))
281 | except NotImplementedError as e:
282 | if ns.verbose:
283 | f = param
284 | print("notsupported", f, e)
285 | IMPL.append((param, e))
286 |
287 | N = len(PASS) + len(FAIL) + len(IMPL)
288 |
289 | print("PASS", len(PASS), '/', N)
290 |
291 | if ns.diag:
292 | printcase("", "", print_flags, header=True)
293 | for f in PASS:
294 | printcase(f, "", print_flags, )
295 |
296 | print("UNIMPL", len(IMPL), '/', N)
297 | if ns.diag:
298 | printcase("", "", print_flags, header=True)
299 | for f, e in IMPL:
300 | printcase(f, e, print_flags)
301 |
302 | print("FAIL", len(FAIL), '/', N)
303 | if ns.diag:
304 | printcase("", "", print_flags, header=True)
305 | for f, e in FAIL:
306 | printcase(f, e, print_flags)
307 |
308 | if len(FAIL) != 0:
309 | return 1
310 |
311 | return 0
312 |
313 | def printcase(f, e, flags, header=False):
314 | if header:
315 | inplace = "INPLACE"
316 | np = "NP"
317 | flags = "FLAGS"
318 | type = "TYPE"
319 | nmesh = "NMESH"
320 | error = "ERROR"
321 | else:
322 | inplace = "INPL" if f[3] else "OUTP"
323 | np = str(f[0])
324 | flags = Flags(f[2]).format(flags)
325 | type = repr(Type(f[1]))
326 | nmesh = str(f[4])
327 | error = str(e)
328 | print("%(np)-6s %(nmesh)-8s %(type)-6s %(inplace)-6s %(flags)-80s %(error)-s" % locals())
329 |
330 | # use unbuffered stdout
331 | class Unbuffered(object):
332 | def __init__(self, stream):
333 | self.stream = stream
334 | def write(self, data):
335 | self.stream.write(data)
336 | self.stream.flush()
337 | def writelines(self, datas):
338 | self.stream.writelines(datas)
339 | self.stream.flush()
340 | def __getattr__(self, attr):
341 | return getattr(self.stream, attr)
342 |
343 | import sys
344 | sys.stdout = Unbuffered(sys.stdout)
345 |
346 | if __name__ == '__main__':
347 |
348 | try:
349 | sys.exit(main())
350 | except Exception as e:
351 | print(traceback.format_exc())
352 | MPI.COMM_WORLD.Abort()
353 |
354 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | from setuptools import setup
2 | from Cython.Build import cythonize
3 | from Cython.Distutils import Extension
4 | from distutils.command.build_ext import build_ext
5 |
6 | import glob
7 | import os
8 | import os.path
9 | import numpy
10 | import mpi4py
11 |
12 | package_basedir = os.path.abspath(os.path.dirname(__file__))
13 |
14 | def build_pfft(prefix, compiler, cflags):
15 | # Avoid enabling SSE2 by default. aarch64 doesn't have it.
16 | # optimize="--enable-sse2"
17 | optimize=""
18 | line = ('CFLAGS="%s -fvisibility=hidden -Wno-error=incompatible-pointer-types" ' % cflags+
19 | 'MPICC="%s" ' % compiler +
20 | 'CC="%s" ' % compiler +
21 | 'sh %s/depends/install_pfft.sh ' % package_basedir +
22 | os.path.abspath(prefix) +
23 | ' %s' % optimize)
24 | if os.path.exists(os.path.join(prefix,
25 | 'lib', 'libpfft.a')):
26 | return
27 |
28 | ret=os.system(line)
29 | if ret != 0:
30 | raise ValueError("could not build fftw; check MPICC?")
31 |
32 | class build_ext_subclass(build_ext):
33 | user_options = build_ext.user_options + \
34 | [
35 | ('mpicc', None, 'MPICC')
36 | ]
37 | def initialize_options(self):
38 | try:
39 | compiler = str(mpi4py.get_config()['mpicc'])
40 | except:
41 | compiler = "mpicc"
42 |
43 | self.mpicc = os.environ.get('MPICC', compiler)
44 |
45 | build_ext.initialize_options(self)
46 |
47 | def finalize_options(self):
48 | build_ext.finalize_options(self)
49 | self.pfft_build_dir = os.path.join(self.build_temp, 'depends')
50 |
51 | self.include_dirs.insert(0, os.path.join(
52 | self.pfft_build_dir, 'include'))
53 |
54 | def build_extensions(self):
55 | # turns out set_executables only works for linker_so, but for compiler_so
56 | self.compiler.compiler_so[0] = self.mpicc
57 | self.compiler.linker_so[0] = self.mpicc
58 | build_pfft(self.pfft_build_dir, self.mpicc, ' '.join(self.compiler.compiler_so[1:]))
59 | link_objects = [
60 | 'libpfft.a',
61 | 'libpfftf.a',
62 | 'libfftw3_mpi.a',
63 | 'libfftw3.a',
64 | 'libfftw3f_mpi.a',
65 | 'libfftw3f.a',
66 | ]
67 |
68 | link_objects = [list(glob.glob(os.path.join(self.pfft_build_dir, '*', i)))[0] for i in link_objects]
69 | self.compiler.set_link_objects(link_objects)
70 |
71 | build_ext.build_extensions(self)
72 |
73 | try:
74 | from distutils.command.build_py import build_py_2to3 as build_py
75 | except ImportError:
76 | from distutils.command.build_py import build_py
77 |
78 | def find_version(path):
79 | import re
80 | # path shall be a plain ascii text file.
81 | s = open(path, 'rt').read()
82 | version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
83 | s, re.M)
84 | if version_match:
85 | return version_match.group(1)
86 | raise RuntimeError("Version not found")
87 |
88 | setup(
89 | name="pfft-python", version=find_version("pfft/version.py"),
90 | author="Yu Feng",
91 | author_email="rainwoodman@gmail.com",
92 | description="python binding of PFFT, a massively parallel FFT library",
93 | url="http://github.com/rainwoodman/pfft-python",
94 | #package_dir = {'pfft': 'pfft'},
95 | zip_safe=False,
96 | install_requires=['cython', 'numpy', 'mpi4py'],
97 | packages= ['pfft', 'pfft.tests'],
98 | requires=['numpy'],
99 | ext_modules = cythonize([Extension(
100 | "pfft.core",
101 | ["pfft/core.pyx"],
102 | include_dirs=["./",
103 | numpy.get_include(),
104 | mpi4py.get_include(),
105 | ],
106 | libraries=['m'],
107 | cython_directives = {"embedsignature": True}
108 | )],
109 | include_path=[os.path.join(mpi4py.get_include(),"../"),],
110 | ),
111 | license='GPL3',
112 | scripts=['scripts/pfft-roundtrip-matrix.py'],
113 | cmdclass = {
114 | "build_py":build_py,
115 | "build_ext": build_ext_subclass}
116 | )
117 |
--------------------------------------------------------------------------------