Skip to content
Snippets Groups Projects
Commit 1806d88b authored by Philipp Arras's avatar Philipp Arras
Browse files

Resolvelib: move bench

parent d7472b04
Branches
Tags
1 merge request!37Draft: Observation: introduce __hash__
......@@ -49,6 +49,11 @@ test_resolve_mpi:
script:
- mpiexec -n 2 --bind-to none pytest-3 -q test/test_mpi
test_bench:
stage: testing
script:
- python3 bench/polarization_matrix_exponential.py quick
pages:
stage: release
script:
......
......@@ -44,7 +44,7 @@ if False:
op(ift.Linearization.make_var(loc))
for nthreads in [1, 4, 8]:
op = rve.cpp.PolarizationMatrixExponential(dom, nthreads)
op = rve.polarization_matrix_exponential_mf2f(dom, nthreads)
print(f"New implementation (nthreads={nthreads})")
ift.exec_time(op)
print()
......
......@@ -17,7 +17,7 @@
*/
/* Copyright (C) 2021-2022 Max-Planck-Society, Philipp Arras
Authors: Philipp Arras, Jakob Roth */
Authors: Philipp Arras */
// Includes related to pybind11
#include <pybind11/numpy.h>
......
......@@ -21,11 +21,11 @@ import nifty8 as ift
from .polarization_space import PolarizationSpace
from .simple_operators import MultiFieldStacker
from .global_config import nthreads
from .cpp import Pybind11Operator
from .global_config import nthreads as global_nthreads
def polarization_matrix_exponential_mf2f(domain):
def polarization_matrix_exponential_mf2f(domain, nthreads=None):
"""
Note
......@@ -53,7 +53,9 @@ def polarization_matrix_exponential_mf2f(domain):
f = _cpp.PolarizationMatrixExponential4
else:
raise NotImplementedError("Not compiled for this shape")
return Pybind11Operator(domain, target, f(nthreads()))
if nthreads is None:
nthreads = global_nthreads()
return Pybind11Operator(domain, target, f(nthreads))
def polarization_matrix_exponential(domain, jax=False):
......
import sys
import os.path
import itertools
from glob import iglob
import os
from setuptools import setup, Extension, find_packages
import pybind11
tmp = os.getenv("DUCC0_CFLAGS", "").split(" ")
user_cflags = [x for x in tmp if x != ""]
tmp = os.getenv("DUCC0_LFLAGS", "").split(" ")
user_lflags = [x for x in tmp if x != ""]
tmp = os.getenv("DUCC0_FLAGS", "").split(" ")
tmp = [x for x in tmp if x != ""]
user_cflags += tmp
user_lflags += tmp
compilation_strategy = os.getenv('DUCC0_OPTIMIZATION', 'native-strip')
if compilation_strategy not in ['none', 'none-debug', 'none-strip', 'portable', 'portable-debug', 'portable-strip', 'native', 'native-debug', 'native-strip']:
raise RuntimeError('unknown compilation strategy')
do_debug = compilation_strategy in ['none-debug', 'portable-debug', 'native-debug']
do_strip = compilation_strategy in ['none-strip', 'portable-strip', 'native-strip']
do_optimize = compilation_strategy not in ['none', 'none-debug', 'none-strip']
do_native = compilation_strategy in ['native', 'native-debug', 'native-strip']
def _print_env():
import platform
print("")
print("Build environment:")
print("Platform: ", platform.platform())
print("Machine: ", platform.machine())
print("System: ", platform.system())
print("Architecture: ", platform.architecture())
print("")
def _get_files_by_suffix(directory, suffix):
path = directory
iterable_sources = (iglob(os.path.join(root, '*.'+suffix))
for root, dirs, files in os.walk(path))
return list(itertools.chain.from_iterable(iterable_sources))
include_dirs = ['./ducc/src',
pybind11.get_include(True),
pybind11.get_include(False)]
extra_compile_args = ['-std=c++17', '-fvisibility=hidden']
if do_debug:
extra_compile_args += ['-g']
else:
extra_compile_args += ['-g0']
if do_optimize:
extra_compile_args += ['-ffast-math', '-O3']
else:
extra_compile_args += ['-O0']
if do_native:
extra_compile_args += ['-march=native']
python_module_link_args = []
if sys.platform == 'darwin':
import distutils.sysconfig
extra_compile_args += ['-mmacosx-version-min=10.14', '-pthread']
python_module_link_args += ['-mmacosx-version-min=10.14', '-pthread']
elif sys.platform == 'win32':
extra_compile_args = ['/EHsc', '/std:c++17']
if do_optimize:
extra_compile_args += ['/Ox']
else:
if do_optimize:
extra_compile_args += ['-Wfatal-errors',
'-Wfloat-conversion',
'-W',
'-Wall',
'-Wstrict-aliasing',
'-Wwrite-strings',
'-Wredundant-decls',
'-Woverloaded-virtual',
'-Wcast-qual',
'-Wcast-align',
'-Wpointer-arith']
extra_compile_args += ['-pthread']
python_module_link_args += ['-Wl,-rpath,$ORIGIN', '-pthread']
if do_native:
python_module_link_args += ['-march=native']
if do_strip:
python_module_link_args += ['-s']
extra_compile_args += user_cflags
python_module_link_args += user_lflags
depfiles = (_get_files_by_suffix('.', 'h') +
_get_files_by_suffix('.', 'cc') +
['setup.py'])
extensions = [Extension("resolvelib._cpp",
language='c++',
sources=['src/cpp/main.cc', 'ducc/src/ducc0/infra/threading.cc'],
depends=depfiles,
include_dirs=include_dirs,
extra_compile_args=extra_compile_args,
extra_link_args=python_module_link_args)]
this_directory = os.path.abspath(os.path.dirname(__file__))
_print_env()
setup(name="resolvelib",
version="0.0.0",
#description=description,
#long_description=long_description,
#long_description_content_type='text/markdown',
url='https://gitlab.mpcdf.mpg.de/ift/resolve',
#include_package_data=True,
author='Philipp Arras',
author_email='c@philipp-arras.de',
packages=find_packages(include=["resolvelib", "resolvelib.*"]),
python_requires=">=3.7",
ext_modules=extensions,
install_requires=['numpy>=1.17.0'],
license="GPLv3+",
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment