Gerson J. Ferreira wrote:
I'm still tracking why is there such a huge difference. The code basically builds a system without leads, extract the "hamiltonian_submatrix" for a given set of parameters and calculates the eigenvalues. Then I loop over a set of parameters. Running the code in the conda environment, it takes 15 minutes, but in my own virtualenv with compiled kwant it takes 2 hours!! It's exactly the same code.
Often when there is a difference in performance between different deployments of Kwant, it is due to MUMPS being used or not. After all, the MUMPS transport solver is typically considerably faster than the one using scipy.sparse. However in your case you seem not to be using MUMPS at all, so it should not matter whether it’s available or not. If you use Kwant to create a builder, finalize it, and run hamiltonian_submatrix, the code that takes up time is predominantly • Python Kwant code, • Cython Kwant code (for example hamiltonian_submatrix), • and Tinyarray (implemented in C++). There should not be a huge difference between the time it takes to execute such code no matter whether conda is used or not. There should not be a huge difference even if different compilers were used, except if something unusual was done like disabling compiler optimizations. My guess is that the runtime difference could be due the eigenvalue calculation. Perhaps the MKL routine that you are most likely using is significantly faster? You should be able to test this hypothesis by adding some simple timing to your script, time.time() should do the job. Or you can try to do some more serious profiling if you like.
Is there anything else I could be missing that would speed up the code? It seems that numpy is not the problem, since the MKL vs OpenBlas is at most a factor of 2. Maybe my compilation is not properly linking to MUMPS? How can I check if my kwant compilation is properly using openblas and MUMPS?
If you only create a system and evaluate its Hamiltonian Kwant should not do any significant linear algebra computations. But perhaps I’m overseeing something - could you try to narrow down the problem and let us know what you found out? Ideally you could post a simple example script so that others Christoph