TRIQS / cthyb

A fast and generic hybridization-expansion solver
https://triqs.github.io/cthyb
Other
21 stars 23 forks source link

using cthyb with MPI via python API #154

Closed FangXieTHU closed 1 year ago

FangXieTHU commented 1 year ago

Dear Triqs developers,

So I am trying to use the cthyb library to perform a self-consistent DMFT calculation for benchmark. In a self-consistent calculation, G0_iw in the next iteration is obtained from the self-consistent condition in the current iteration. I am wondering if I have to use if mpi.is_master_node(): S.G0_iw << evaluate_next_G0(S.G_iw) when calculating the next G0_iw. I tried the case without this if statement, which means every cpu is calculating its G0_iw separately, but it seems that the next iteration for different cpus will start at different time. May I ask whether I should only use master_node for self-consistent condition or not? Any help would be appreciated!

Version triqs 3.1.1 triqs_cthyb 3.1.0

Environment: macOS Ventura on Apple Silicon w/ Rosetta, for single core tests the results are reasonable.

the-hampel commented 1 year ago

Hi @FangXieTHU,

setting S.G0_iw should be done on each mpi rank, because each solver instance (on each rank) has its own input to start with. However, if your function evaluate_next_G0() has some elaborate steps in between that take some time you can of course do this on the master_node only and then bcast the result to all other ranks, i.e. do something like:

if mpi.is_master_node():
  S.G0_iw << evaluate_next_G0(S.G_iw)

S.G0_iw << mpi.bcast(S.G0_iw)
mpi.barrier()

However, now you have to do the extra communication between the nodes. This has to be balanced, depending which task takes how much time.

Best, Alex

P.S. since this is not really an issue, I moved this to the discussions page.