Skip to content

Commit

Permalink
Try p3dfft
Browse files Browse the repository at this point in the history
  • Loading branch information
paugier committed Feb 8, 2024
1 parent e02ce53 commit e3f509f
Show file tree
Hide file tree
Showing 10 changed files with 853 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ tests_mpi:
- job: "image:build"
optional: true
script:
- nox -s "tests(with_cov=True, with_mpi=True)" -- --with-pfft
- nox -s "tests(with_cov=True, with_mpi=True)" -- --with-pfft --with-p3dfft


pages:
Expand Down
4 changes: 2 additions & 2 deletions plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ The following plugins are implemented in Fluidfft repository:
- [x] fluidfft-fftw
- [x] fluidfft-mpi_with_fftw (parallel methods using the sequential FFTW3 library)
- [x] fluidfft-fftwmpi (methods using the library `libfftw_mpi`)
- [x] fluidfft-p3dfft
- [x] fluidfft-pfft
- [x] fluidfft-mpi4pyfft (cannot be tested because mpi4py-fft installation fails)

We plan to soon also have:

- [ ] fluidfft-p3dfft
- [ ] fluidfft-pfft
- [ ] fluidfft-pyvkfft (https://pyvkfft.readthedocs.io)
674 changes: 674 additions & 0 deletions plugins/fluidfft-p3dfft/LICENSE

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions plugins/fluidfft-p3dfft/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

develop:
pip install -e . -vv --no-build-isolation --no-deps

clean:
rm -rf build

test:
mpirun -np 2 pytest --exitfirst -v
15 changes: 15 additions & 0 deletions plugins/fluidfft-p3dfft/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Fluidfft plugin for parallel FFTs using P3DFFT

This plugin provides a method for parallel FFTs using P3DFFT:
`fft3d.mpi_with_p3dfft`.

## Environment variables

The default include path can be expanded with `CPATH` for GCC/Clang and
`INCLUDE` for MSVC.

The default library search path can be expanded with `LIBRARY_PATH` for
GCC/Clang and `LIB` for MSVC.

Alternatively, one could define `PFFT_DIR` or `PFFT_LIB_DIR` and
`PFFT_INCLUDE_DIR`.
87 changes: 87 additions & 0 deletions plugins/fluidfft-p3dfft/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
project(
'fluidfft-p3dfft',
'cpp',
'cython',
license: 'CeCILL',
meson_version: '>= 1.1.0',
default_options: [
'buildtype=release',
'c_std=c99',
'cpp_std=c++11',
],
)

py_mod = import('python')
py = py_mod.find_installation('python3', pure: false)
py_dep = py.dependency()

fftw_dep = dependency('fftw3', static: false)
mpi_dep = dependency('mpi', language: 'cpp')

incdir_numpy = run_command(
'transonic-get-include', 'numpy', check: true
).stdout().strip()
inc_np = include_directories(incdir_numpy)
np_dep = declare_dependency(include_directories: inc_np)

compiler = meson.get_compiler('cpp')
# fftw_mpi is not found on Ubuntu
fftwmpi_dep = compiler.find_library('fftw_mpi', required: false)


P3DFFT_DIR = run_command(
py, '-c', 'import os; print(os.environ.get("P3DFFT_DIR", ""))',
check: true
).stdout().strip()
message('P3DFFT_DIR=' + P3DFFT_DIR)

if P3DFFT_DIR != ''
P3DFFT_LIB_DIR = P3DFFT_DIR + '/lib'
P3DFFT_INCLUDE_DIR = P3DFFT_DIR + '/include'
else
P3DFFT_LIB_DIR = run_command(
py, '-c', 'import os; print(os.environ.get("P3DFFT_LIB_DIR", ""))',
check: true
).stdout().strip()
message('P3DFFT_LIB_DIR=' + P3DFFT_LIB_DIR)

P3DFFT_INCLUDE_DIR = run_command(
py, '-c', 'import os; print(os.environ.get("P3DFFT_INCLUDE_DIR", ""))',
check: true
).stdout().strip()
message('P3DFFT_INCLUDE_DIR=' + P3DFFT_INCLUDE_DIR)
endif

dirs = []
if P3DFFT_LIB_DIR != ''
dirs += [P3DFFT_LIB_DIR]
endif

include_directories = []
if P3DFFT_INCLUDE_DIR != ''
include_directories = include_directories(P3DFFT_INCLUDE_DIR)
endif

p3dfft_dep = compiler.find_library(
'p3dfft',
dirs: dirs,
has_headers: ['p3dfft.h'],
header_include_directories: include_directories,
required: true,
)
link_args = ['-lfftw3_mpi']

dependencies = [fftw_dep, mpi_dep, np_dep, fftwmpi_dep, p3dfft_dep]

include_path_fluidfft_builder = run_command(
'fluidfft-builder-print-include-dir', check: true
).stdout().strip()

include_directories = [include_directories, include_path_fluidfft_builder]

include_path_cy = run_command(
'fluidfft-builder-print-include-dir-cython', check: true
).stdout().strip()
add_project_arguments('-I', include_path_cy, language : 'cython')

subdir('src/fluidfft_p3dfft')
22 changes: 22 additions & 0 deletions plugins/fluidfft-p3dfft/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[build-system]
requires = [
"meson-python", "numpy", "fluidfft-builder>=0.0.1", "cython", "mpi4py", "transonic>=0.6.1"
]
build-backend = 'mesonpy'

[project]
name = "fluidfft-p3dfft"
version = "0.0.1"
description = "Fluidfft plugin for MPI FFTs using fftw"
authors = [{name = "Pierre Augier", email = "pierre.augier@univ-grenoble-alpes.fr"}]
license = {file = "LICENSE"}
classifiers = ["License :: OSI Approved :: MIT License"]
dependencies = ["fluidfft"]
readme = "README.md"

[project.urls]
Home = "https://foss.heptapod.net/fluiddyn/fluidfft"

[project.entry-points."fluidfft.plugins"]

"fft3d.mpi_with_p3dfft" = "fluidfft_p3dfft.mpi_with_p3dfft"
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

FFT3DMPIWithP3DFFT::FFT3DMPIWithP3DFFT(int argN0, int argN1, int argN2)
: BaseFFT3DMPI::BaseFFT3DMPI(argN0, argN1, argN2) {
double clocktime_in_sec;
chrono::duration<double> clocktime_in_sec;

int conf;
int memsize[3];
Expand Down
32 changes: 32 additions & 0 deletions plugins/fluidfft-p3dfft/src/fluidfft_p3dfft/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

py.install_sources('__init__.py', subdir: 'fluidfft_p3dfft')

pyx = custom_target(
'mpi_with_p3dfft.pyx',
output: 'mpi_with_p3dfft.pyx',
command: ['fluidfft-builder-make-file', '@OUTPUT@', 'FFT3DMPIWithP3DFFT'],
)

pxd = custom_target(
'fft3dmpi_with_p3dfft.pxd',
output: 'fft3dmpi_with_p3dfft.pxd',
command: ['fluidfft-builder-make-file', '@OUTPUT@', 'FFT3DMPIWithP3DFFT'],
)

py.extension_module(
'mpi_with_p3dfft',
pyx,
pxd,
'fft3dmpi_with_p3dfft.cpp',
'fft3dmpi_with_p3dfft.h',
include_path_fluidfft_builder / 'base_fft.cpp',
include_path_fluidfft_builder / 'base_fft3d.cpp',
include_path_fluidfft_builder / 'base_fftmpi.cpp',
include_path_fluidfft_builder / 'base_fft3dmpi.cpp',
dependencies: dependencies,
override_options : ['cython_language=cpp'],
include_directories: include_directories,
link_args: link_args,
install: true,
subdir: 'fluidfft_p3dfft',
)
10 changes: 10 additions & 0 deletions plugins/fluidfft-p3dfft/tests/test_3dpfft.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from unittest import TestCase

from fluidfft.fft3d.testing import complete_test_class_3d


class Tests(TestCase):
pass


complete_test_class_3d("fft3d.mpi_with_p3dfft", Tests)

0 comments on commit e3f509f

Please sign in to comment.