Hi Jiaqi,

Most likely you're seeing the LAPACK-level parallelization. I'm not an
expert on LAPACK using multiple CPU cores, but I haven't seen
parallelization of LAPACK result in any useful speedup. Try setting
the following environment variables (these are used by different
LAPACK implementations):

OPENBLAS_NUM_THREADS=1
OMP_NUM_THREADS=1
MKL_DYNAMIC=FALSE
MKL_NUM_THREADS=1

Best,
Anton

On Thu, 21 May 2020 at 23:55, Zhou Jiaqi <jiaqi.z...@uclouvain.be> wrote:
>
> Hi everyone,
>
> I am writing to discuss the parallelization of Kwant.
>
> I installed Kwant with MUMPS from 
> Ubuntu(https://launchpad.net/ubuntu/+source/mumps). When I run a Kwant script 
> (which will be shown in the end) in the normal way on a 4-core laptop (2 
> threads per core), the screenshot (the output of htop, see 
> https://drive.google.com/open?id=1TwEuc21DMjRnVQ9yG3XpkVilhFiAKaeb) shows 
> that all the 8 CPU threads are involved, but 21 python threads.
>
> However, according to the tutorial: " Kwant uses only the sequential, single 
> core version of MUMPS. The advantages due to MUMPS as used by Kwant are thus 
> independent of the number of CPU cores of the machine on which Kwant runs.”
>
> So it confuses me whether Kwant 1.4.1 has already employed parallelization or 
> not, and why there are 21 python threads? Moreover, I find the usage of 
> concurrent package slows down the calculation.
>
> Thanks a lot for your time, and it would be greatly appreciated if anyone 
> could share some news about the Kwant parallelization development.
>
> Best regards,
>
> Jiaqi
> UCLouvain
>
> ______________________
>
> import kwant
> import tbmodels
> import numpy as np
> import matplotlib.pyplot as plt
>
> model = tbmodels.Model.from_wannier_files(
>    hr_file='graphene_hr.dat',
>    wsvec_file='graphene_wsvec.dat',
>    xyz_file='graphene_centres.xyz',
>    win_file='graphene.win',
>    h_cutoff=0.01)
>
> lattice = model.to_kwant_lattice()
>
> wire = kwant.Builder()
> def shape(p):
>    x, y, z = p
>    return -5 < x < 5 and -5 < y < 5 and -1 < z < 1
> wire[lattice.shape(shape, (0, 0, 0))] = 0
> model.add_hoppings_kwant(wire)
>
> sym_lead_x = kwant.TranslationalSymmetry(lattice.vec((-2, 0, 0)))
> lead_x = kwant.Builder(sym_lead_x)
> def lead_shape(p):
>    x, y, z = p
>    return -5 <= x <= 5 and -5 < y < 5 and -1 < z < 1
> lead_x[lattice.shape(lead_shape, (0, 0, 0))] = 0
> model.add_hoppings_kwant(lead_x)
> wire.attach_lead(lead_x)
> wire.attach_lead(lead_x.reversed())
>
> syst = wire.finalized()
>
> def trans(energy):
>    smatrix = kwant.smatrix(syst, energy)
>    data = smatrix.transmission(1, 0)
>    return data
>
> def main():
>    energies = np.linspace(0, 1, 100)
>    tc = map(trans, energies)         # transmission coefficient
>    te = zip(energies, tc)
>    lte = list(te)
>    print(lte)
>
> if __name__ == '__main__':
>    main()

Reply via email to