Hello,
I stumbled upon a problem in conjecture with openMP and ITensor2. It may very well have nothing to do with itensor, so I apologize in advance. Googling brought me nowhere, so I hope someone here may be able to figure out what the problem is.
Basically, adding a call to omp_get_wtime()
and running the program with more than a single thread completely messes up some itensor calculations.
I copied a minimal example at the end of this message. I am using the latest itensor 2 (did git pull) and LAPACK, c++11, compiling using -fopenmp.
I was only able to reproduce the problem with more than a single thread (for example, export OMP_NUM_THREADS=2
). When setting export OMP_NUM_THREADS=1
, things seem to work normally.
Similarly, If I remove the double start = omp_get_wtime();
line, things seem to work properly.
Here is a minimal example:
#include "itensor/all.h"
#include <omp.h>
using namespace itensor;
int
main()
{
int N = 10;
auto sites = SpinOne(N);
auto ampo = AutoMPO(sites);
for(int j = 1; j < N; ++j)
{
ampo += 0.5,"S+",j,"S-",j+1;
ampo += 0.5,"S-",j,"S+",j+1;
ampo += "Sz",j,"Sz",j+1;
}
auto H = MPO(ampo);
auto sweeps = Sweeps(5); //number of sweeps is 5
sweeps.maxm() = 10,20,100,100,200;
sweeps.cutoff() = 1E-10;
auto psi = MPS(sites);
double start = omp_get_wtime();
auto energy = dmrg(psi,H,sweeps,{"Quiet=",true});
printfln("Ground state energy from DMRG = %.12f",energy);
return 0;
}
Thanks