Skip to content

Commit

Permalink
pfft pluggin (draft)
Browse files Browse the repository at this point in the history
  • Loading branch information
paugier committed Feb 7, 2024
1 parent 9f8a752 commit ec84348
Show file tree
Hide file tree
Showing 13 changed files with 835 additions and 1 deletion.
Empty file.
674 changes: 674 additions & 0 deletions plugins/fluidfft-pfft/LICENSE

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions plugins/fluidfft-pfft/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
19 changes: 19 additions & 0 deletions plugins/fluidfft-pfft/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Fluidfft plugin for parallel FFTs using PFFT

This plugin provides a method for parallel FFTs using PFFT:
`fft3d.mpi_with_pfft`.

## Environment variables

- `LIBRARY_PATH`
- `CPATH`
- `LD_LIBRARY_PATH`

or

- `PFFT_DIR`

or

- `PFFT_LIB_DIR`
- `PFFT_INCLUDE_DIR`
68 changes: 68 additions & 0 deletions plugins/fluidfft-pfft/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
project(
'fluidfft-pfft',
'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)


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

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

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

# We need to do something with these values
# see https://stackoverflow.com/a/61072768/1779806

# set LIBRARY_PATH to include the directory where is libpfft.so
pfft_dep = compiler.find_library('pfft', required: true)
link_args = ['-lpfft', '-lfftw3_mpi']

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

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

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_pfft')
22 changes: 22 additions & 0 deletions plugins/fluidfft-pfft/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-pfft"
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_pfft" = "fluidfft_pfft.mpi_with_pfft"
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

FFT3DMPIWithPFFT::FFT3DMPIWithPFFT(int argN0, int argN1, int argN2)
: BaseFFT3DMPI::BaseFFT3DMPI(argN0, argN1, argN2) {
double clocktime_in_sec;
chrono::duration<double> clocktime_in_sec;
unsigned flag_fwd, flag_bck;
int irank;

Expand Down
File renamed without changes.
32 changes: 32 additions & 0 deletions plugins/fluidfft-pfft/src/fluidfft_pfft/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

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

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

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

py.extension_module(
'mpi_with_pfft',
pyx,
pxd,
'fft3dmpi_with_pfft.cpp',
'fft3dmpi_with_pfft.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_path_fluidfft_builder,
link_args: link_args,
install: true,
subdir: 'fluidfft_pfft',
)
10 changes: 10 additions & 0 deletions plugins/fluidfft-pfft/tests/test_pfft.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_pfft", Tests)

0 comments on commit ec84348

Please sign in to comment.