QuTech-Delft / OpenQL

OpenQL: A Portable Quantum Programming Framework for Quantum Accelerators. https://dl.acm.org/doi/10.1145/3474222
https://openql.readthedocs.io
Other
99 stars 44 forks source link

Fix compile time due to unitary decomposition/Eigen #325

Closed jvanstraten closed 4 years ago

jvanstraten commented 4 years ago

This PR moves the unitary decomposition implementation within unitary.h into its own compile unit, to prevent its dependencies (notably Eigen) from having to be parsed/template-expanded for every other compile unit as well. unitary.cc still takes a while to compile, but using incremental compilation this should be less of a problem now, and a parallel build no longer brings my 32GB RAM workstation to its knees. I'm not sure why Eigen is compiling this slowly, requires 4GB of RAM during compilation, and outputs 36MiB of code into libql.a, but figuring that out probably requires looking at the actual algorithm implementation, which is greek to me.

To the best of my ability, I could only find references to size() and decompose() outside of the unitary class itself, so I only copied those into the new wrapper class (the wrapper is more-or-less necessary to prevent the Eigen includes from needing to be in the header file for the private Eigen::Matrix member). I left the class member variables basically as they were.

The only test I could find for unitary decomposition was unitary.py, which seems to be as broken as it was before these changes, I'm guessing because of the other things going on in modular (it's not writing output files when compile() is called).