New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Move cython build to c++ #648
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All looks great to me. I can hardly believe you managed to get this all implemented and working so quickly
pyximport.install(setup_args={'include_dirs': [numpy.get_include()]}) | ||
del pyximport | ||
import qutip.cy.pyxbuilder as pbldr | ||
os.environ['CFLAGS'] = '-O1 -w -ffast-math' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a question: why do we have a reduced set of flags here compared to _compiler_flags
in cy/setup.py?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we are just gluing things together here. Setting optimizations to high here increases runtime build time for no performance gains.
@@ -35,7 +35,7 @@ cimport numpy as np | |||
cimport cython | |||
cimport libc.math | |||
|
|||
cdef extern from "src/zspmv.h" nogil: | |||
cdef extern from "src/zspmv.hpp" nogil: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would we do a conditional import here based on compiler / platform
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. Maybe src/win_zspmv or something on win platforms.
qutip/cy/setup.py
Outdated
@@ -11,23 +11,24 @@ | |||
exts = ['spmatfuncs', 'stochastic', 'sparse_utils', 'graph_utils', 'interpolate', | |||
'spmath', 'heom', 'math', 'spconvert', 'ptrace', 'testing'] | |||
|
|||
_compiler_flags = ['-w', '-ffast-math', '-O3', '-march=native', '-funroll-loops'] | |||
_compiler_flags = ['-w', '-std=c++11', '-ffast-math', '-O3', '-march=native', '-funroll-loops'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would we add platform / compiler specific flags in here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the format for visual studio compiler args is different.
There may be some who would wish continue using the mingw compiler on Windows, as it is a smaller download. I guess we could just say that we only support MS compilers on Windows. |
I have built this branch and tested on my linux machine here. All tests pass. |
Meant to add: I get this warning in build_ext and in all str format td tests |
Everything should work using mingw. The dwfault Anaconda mingw is 4.7.1, that supports the c++11 features we need. Mingwpy is 4.9 and even supports openmp. So eveything should be fine. But I have not checked. The command line warning you see is something that Cython is emitting, not QuTiP. Perhaps this is a bug on their end? I dont know how to remove the flags that Cython specifies. The dash -w should block all warnings though. |
And yes, will figure out the win stuff today at work. |
There is an issue with numpy.distutils on win. To get this done anytime soon, I think we need to move to setuptools. |
Do you mean the issue with not being able to find In my test project I used the workaround they suggest:
And this seems to work. Is it more complicated than that for us? |
Nope, it is something else. I have a workaround similar to what you did. Everything seems to ve working as the tests run fine. Awesome stuff. |
@ajgpitch, please try this latest update on Win. I had everything up and running at work today. The only thing I didn't have was a spmv source file that compiled under GCC, CLANG, and VS. I think the file I have up now should work, but as I don't have Win at home, I need a verification. The only thing missing from the pull is the optional fortran extension. I will add that on Monday. |
Attempt to install qutip in python2.7
|
Attempt in Python3.5
|
Py2.7 on Windows needs to always use the GCC. The VS version corresponding to Py27 does not support the functions that we need. The Py3.5 errors mean that my #define did not work. I have put up a different version, and will check it tomorrow at work. |
Okay, I am much happier with the idea that our recommended Python version for qutip on MS Wondows is >=3.5 than the other way round. I would be quite happy to consider dropping support for Python 2 altogether at some point. |
Ok, we should be set now. Tested working on GCC, CLANG, mingwpy, and VS 2015. |
I have just finished testing with Vs 2015 as well (win10, Python 3.5). All passed. |
Merging this now. |
I have managed to get everything moved over to c++. Should address #647. There are still a few issues to address, but the tests pass on unix based systems.