From b5cf7bf7c5fa12e26846b360e2115c83a3b0ac88 Mon Sep 17 00:00:00 2001 From: paugier Date: Fri, 12 Jan 2024 13:53:29 +0100 Subject: [PATCH] Build option for perf and not portable --- doc/build-from-source.md | 17 +++++++++++++---- meson.build | 5 ++++- meson.options | 23 +++++++++++++++++------ noxfile.py | 6 ++++-- 4 files changed, 38 insertions(+), 13 deletions(-) diff --git a/doc/build-from-source.md b/doc/build-from-source.md index b06aa90d..f15cbe53 100644 --- a/doc/build-from-source.md +++ b/doc/build-from-source.md @@ -97,6 +97,16 @@ There are 3 levels: ``` +````{important} + +One can activate a performance oriented and not portable build using: + +```sh +pip install . -v -C setup-args=-Dnative=true +``` + +```` + ````{note} Recent versions of `pip` allow one to specify different options like so: @@ -107,7 +117,6 @@ pip install . -v \ -C setup-args=-Duse-xsimd=false ``` - ```` Of course, one can also change values of @@ -140,8 +149,7 @@ pip install . -v -C setup-args=-Doptimization=2 ```{admonition} Advanced compilation configuration The environment variables `CC`, `CXX`, `CFLAGS`, `CXXFLAGS` and `LDFLAGS` -are honored. So for example, one could compile with -`CXXFLAGS="-march=native -Ofast"`. +are honored. Note that Fluidsim builds are not sensible to the [`~/.pythranrc` file](pythranrc)! @@ -157,7 +165,8 @@ Note that Fluidsim builds are not sensible to the [`~/.pythranrc` file](pythranr - How to differentiate a native build from a regular build to produce binaries usable on other computers? - ??? + By default the produced wheels should be portable. There is the `native` + build option to target the exact CPU used for compilation. - How to produce a wheel for other architectures (cross-compilation)? diff --git a/meson.build b/meson.build index 4100bfa1..47aa4c6e 100644 --- a/meson.build +++ b/meson.build @@ -83,12 +83,15 @@ print(incdir)''' ) endif - pythran_complex_hook = get_option('pythran-complex-hook') if pythran_complex_hook == 'os-dependent' pythran_complex_hook = host_machine.system() == 'linux' endif + if get_option('native') + cpp_args_pythran += ['-march=native', '-Ofast'] + endif + endif subdir('fluidsim') diff --git a/meson.options b/meson.options index ff44f3cd..b5c8ca59 100644 --- a/meson.options +++ b/meson.options @@ -4,13 +4,24 @@ option( value: 'pythran,python,numba', description: 'pythran,python,numba (default), cython, numpy, numba; ' + - 'or comma separated value representing multi-backends' + 'or comma separated value representing multi-backends', +) +option( + 'native', + type: 'boolean', + value: true, + description: 'Performance oriented and not portable build', +) +option( + 'use-xsimd', + type: 'boolean', + value: true, + description: 'Turns on xsimd vectorization' ) -option('use-xsimd', type: 'boolean', value: true, description: 'Use xsimd') option( 'pythran-complex-hook', - type : 'combo', - choices : ['os-dependent', 'true', 'false'], - value : 'os-dependent', - description: 'Pythran complex_hook option' + type: 'combo', + choices: ['os-dependent', 'true', 'false'], + value: 'os-dependent', + description: 'Pythran complex_hook option', ) diff --git a/noxfile.py b/noxfile.py index 3a1d2b3d..1593e3c8 100644 --- a/noxfile.py +++ b/noxfile.py @@ -14,7 +14,9 @@ def validate_code(session): def test_without_fft_and_pythran(session): command = "pdm install -G dev -G test -G mpi --no-self" session.run_always(*command.split(), external=True) - session.install(".", "--config-settings=setup-args=-Dtransonic-backend=python", "--no-deps") + session.install( + ".", "--config-settings=setup-args=-Dtransonic-backend=python", "--no-deps" + ) session.run( "make", "_tests_coverage", @@ -30,6 +32,6 @@ def test_with_fft_and_pythran(session): command = "pdm install -G dev -G test -G fft -G mpi --no-self" session.run_always(*command.split(), external=True) - session.install(".", "--no-deps") + session.install(".", "--no-deps", "-C", "setup-args=-Dnative=true") session.run("make", "_tests_coverage", external=True)