diff options
author | kguerda-idris <84066930+kguerda-idris@users.noreply.github.com> | 2021-09-29 15:29:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-29 15:29:31 +0200 |
commit | 1c7e7ce2da8bb362c184fb6eae71fe7e36356494 (patch) | |
tree | 92fdc31870b6d5384c8ba83ff72d85a2d5a1eee6 /setup.py | |
parent | 7dde9e8e4b6aae756e103d49198caaa4f24150e3 (diff) |
[MRG] OpenMP support (#260)
* Added : OpenMP support
Restored : Epsilon and Debug mode
Replaced : parmap => multiprocessing is now replace by multithreading
* Commit clean up
* Number of CPUs correctly calculated on SLURM clusters
* Corrected number of processes for cluster slurm
* Mistake corrected
* parmap is now deprecated
* Now a different solver is used depending on the requested number of threads
* Tiny mistake corrected
* Folders are now in the ot library instead of at the root
* Helpers is now correctly placed
* Attempt to make compilation work smoothly
* OS compatible path
* NumThreads now defaults to 1
* Better flags
* Mistake corrected in case of OpenMP unavailability
* Revert OpenMP flags modification, which do not compile on Windows
* Test helper functions
* Helpers comments
* Documentation update
* File title corrected
* Warning no longer using print
* Last attempt for macos compilation
* pls work
* atempt
* solving a type error
* TypeError OpenMP
* Compilation finally working on Windows
* Bug solve, number of threads now correctly selected
* 64 bits solver to avoid overflows for bigger problems
* 64 bits EMD corrected
Co-authored-by: kguerda-idris <ssos023@jean-zay3.idris.fr>
Co-authored-by: ncassereau-idris <84033440+ncassereau-idris@users.noreply.github.com>
Co-authored-by: ncassereau <nathan.cassereau@idris.fr>
Co-authored-by: RĂ©mi Flamary <remi.flamary@gmail.com>
Diffstat (limited to 'setup.py')
-rw-r--r-- | setup.py | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -11,6 +11,8 @@ from setuptools.extension import Extension import numpy from Cython.Build import cythonize +sys.path.append(os.path.join("ot", "helpers")) +from openmp_helpers import check_openmp_support # dirty but working __version__ = re.search( @@ -30,7 +32,14 @@ if 'clean' in sys.argv[1:]: os.remove('ot/lp/emd_wrap.cpp') # add platform dependant optional compilation argument -compile_args = ["-O3"] +openmp_supported, flags = check_openmp_support() +compile_args = ["/O2" if sys.platform == "win32" else "-O3"] +link_args = [] + +if openmp_supported: + compile_args += flags + ["/DOMP" if sys.platform == 'win32' else "-DOMP"] + link_args += flags + if sys.platform.startswith('darwin'): compile_args.append("-stdlib=libc++") sdk_path = subprocess.check_output(['xcrun', '--show-sdk-path']) @@ -52,6 +61,7 @@ setup( language="c++", include_dirs=[numpy.get_include(), os.path.join(ROOT, 'ot/lp')], extra_compile_args=compile_args, + extra_link_args=link_args )), platforms=['linux', 'macosx', 'windows'], download_url='https://github.com/PythonOT/POT/archive/{}.tar.gz'.format(__version__), |