Hi!
I’ve encountered a strange bug I can’t seem to get rid of. It could just be me doing something silly so I figured it would be best to ask here and find out.
Specifically, when using different spins and quantum numbers the code will crash (choice of segfault, bad_alloc or bus error, all pointing to a memory issue). A simple example that produces the error on my system (using either g++ 13.1.1 or icpx 2023.1.0 - linked against MKL in both cases).
itensor::Args args({ "ConserveSz", true, "ConserveQNs", false });
itensor::SpinOneSite SL(args);
itensor::SpinHalfSite SR(args);
itensor::ITensor test = 2.0 * SL.op("Sz", args) * SR.op("Sz", args);
The fact that it happens with 2 compilers seems to point to an issue with ITensor, though interestingly I can’t replicate the issue in debug mode (granted I haven’t tried too hard so it may be possible, but debug mode is too slow for my simulations so that’s not quite as relevant to me). A short note, I tied with icpx and simply setting -O0 in release mode did not help when building the final code (I did not however recompile ITensor with it).
I was wondering if you have any insight into what the issue is and/or how to fix it, like I said, maybe I’m doing something I should not but am simply not aware of it.
The options.mk flags used are:
CCCOM=g++ -m64 -std=c++17 -fconcepts -fPIC
PLATFORM=mkl
BLAS_LAPACK_LIBFLAGS=-fopenmp -L$(MKLROOT)/lib/intel64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_rt -lmkl_core -liomp5 -lpthread
BLAS_LAPACK_INCLUDEFLAGS=-I$(MKLROOT)/include
OPTIMIZATIONS=-O3 -DNDEBUG -Wall -Wno-unknown-pragmas -fopenmp -mfma -DMKL_LP64
DEBUGFLAGS=-DDEBUG -g -Wall -Wno-unknown-pragmas -pedantic
and
CCCOM=icpx -m64 -std=c++17 -fPIC
PLATFORM=mkl
BLAS_LAPACK_LIBFLAGS=-qopenmp -L$(MKLROOT)/lib/intel64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_rt -lmkl_core -liomp5 -lpthread
BLAS_LAPACK_INCLUDEFLAGS=-I$(MKLROOT)/include
OPTIMIZATIONS=-O3 -DNDEBUG -Wall -Wno-unknown-pragmas -qopenmp -fma -DMKL_LP64
DEBUGFLAGS=-DDEBUG -g -Wall -Wno-unknown-pragmas -pedantic
got g++ and icpx respectively.
Edit:
After some further testing I can confirm that things appear to work correctly with gcc-11/icpc-2021. Nevertheless, it would probably be good to know what causes the problem with the newer compilers.
Any ideas would be appreciated. Thanks!