Skip to content

Commit

Permalink
WIP: try to compile fft2d_with_fftw1d.so
Browse files Browse the repository at this point in the history
  • Loading branch information
ogiorgis committed Jan 31, 2024
1 parent f10f436 commit 360fc98
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
from os.path import join
from datetime import datetime

here = os.path.abspath(os.path.dirname(__file__))

path_fluidfft = os.path.abspath(os.path.join(here, "..", "src", "fluidfft"))
path2d = os.path.join(path_fluidfft, "fft2d")
path3d = os.path.join(path_fluidfft, "fft3d")

HERE = os.path.abspath(os.path.dirname(__file__))
CURRENT_DIR = os.getcwd()

def load_template(filename):
"""Load template file using Mako or Jinja2.
Expand Down Expand Up @@ -42,12 +38,12 @@ def load_template(filename):
"</%doc>",
"%",
"##",
loader=FileSystemLoader(here),
loader=FileSystemLoader(HERE),
)
print("Falling back to Jinja2 as the template library...")
return env.get_template(filename)
else:
return Template(filename=join(here, filename))
return Template(filename=join(HERE, filename))


def modification_date(filename):
Expand All @@ -56,27 +52,26 @@ def modification_date(filename):


def get_path_files(module_name):
if module_name.startswith("fft2d"):
path_package = path2d
elif module_name.startswith("fft3d"):
path_package = path3d

path_pyx = join(path_package, module_name + ".pyx")
path_pxd = join(path_package, module_name + ".pxd")
path_pyx = join(CURRENT_DIR, module_name + ".pyx")
path_pxd = join(CURRENT_DIR, module_name + ".pxd")

return path_pyx, path_pxd


def make_file(module_name, class_name, numpy_api, templates):
def make_file(module_name, class_name, numpy_api):
templates = {
"fft2d_pyx": load_template("template2d_mako.pyx"),
"fft2d_pxd": load_template("template2d_mako.pxd"),
"fft3d_pyx": load_template("template3d_mako.pyx"),
"fft3d_pxd": load_template("template3d_mako.pxd"),
}
if module_name.startswith("fft2d"):
t_pyx = templates["fft2d_pyx"]
t_pxd = templates["fft2d_pxd"]
elif module_name.startswith("fft3d"):
t_pyx = templates["fft3d_pyx"]
t_pxd = templates["fft3d_pxd"]

path_pyx, path_pxd = get_path_files(module_name)

# Generate pyx and pxd files
for path, template in zip(get_path_files(module_name), (t_pyx, t_pxd)):
if not os.path.exists(path):
Expand Down Expand Up @@ -113,16 +108,8 @@ def make_file(module_name, class_name, numpy_api, templates):


def make_pyx_files():
templates = {}

templates["fft2d_pyx"] = load_template("template2d_mako.pyx")
templates["fft2d_pxd"] = load_template("template2d_mako.pxd")

templates["fft3d_pyx"] = load_template("template3d_mako.pyx")
templates["fft3d_pxd"] = load_template("template3d_mako.pxd")

for module_name, class_name, numpy_api in variables:
make_file(module_name, class_name, numpy_api, templates)
make_file(module_name, class_name, numpy_api)


def _remove(path):
Expand Down
1 change: 1 addition & 0 deletions plugins/fluidfft-fftw/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ requires = [
"fluidfft_build_deps>=0.0.1",
"pythran>=0.9.7",
"jinja2",
"mako",
"cython",
]
build-backend = 'mesonpy'
Expand Down
Empty file.
8 changes: 0 additions & 8 deletions plugins/fluidfft-fftw/src/fluidfft_fftw/fft1d/meson.build

This file was deleted.

33 changes: 28 additions & 5 deletions plugins/fluidfft-fftw/src/fluidfft_fftw/fft2d/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@ py.install_sources(
subdir: 'fluidfft-fftw/ftt2d'
)

cpp_path = run_command(
run_command(
py,
[
'-c',
'''from fluidfft_build_deps.src_cy.make_files_with_mako import make_file
make_file("fft2d_with_fftw1d", "FFT2DWithFFTW1D", "numpy")'''
],
check: true
)

src_cpp_path = run_command(
py,
[
'-c',
Expand All @@ -17,9 +27,22 @@ print(fluidfft_build_deps.src_cpp.__path__[0])'''
check: true
).stdout().strip()

base_sources = ['base_fft.h']
foreach filename : base_sources
src = join_paths(src_cpp_path, 'base', filename)
dest = join_paths(meson.current_source_dir(), filename)
run_command('cp', src, dest, check : true)
endforeach

run_command(['transonic', '--meson', '--backend', backend, 'operators2d.py', 'operators3d.py'], check: true)

foreach be : backends
subdir('__' + be + '__')
sources = ['base_fft2d.h', 'fft2d_with_fftw1d.cpp', 'fft2d_with_fftw1d.h']
foreach filename : sources
src = join_paths(src_cpp_path, '2d', filename)
dest = join_paths(meson.current_source_dir(), filename)
run_command('cp', src, dest, check : true)
endforeach

# shared_library(
# 'fft2d_with_fftw1d',
# ['fft2d_with_fftw1d.cpp', 'fft2d_with_fftw1d.h'],
# install : true,
# )
1 change: 0 additions & 1 deletion plugins/fluidfft-fftw/src/fluidfft_fftw/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ py.install_sources(
subdir: 'fluidfft-fftw'
)

subdir('fft1d')
subdir('fft2d')
subdir('fft3d')

0 comments on commit 360fc98

Please sign in to comment.