evaleev / libint

Libint: high-performance library for computing Gaussian integrals in quantum mechanics
Other
230 stars 96 forks source link

Segmentation Fault on OSX/clang++ for L > 1 #48

Closed wavefunction91 closed 8 years ago

wavefunction91 commented 8 years ago

I've recently compiled the latest change set of Libint on OSX with clang++ and ran into a problem with segmentation full whenever I hit basis functions with L > 1.

% clang++ --version
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix

and libint configure

#!/bin/sh
$PWD/configure \
--enable-eri=1 \
--with-max-am=7 \
--with-opt-am=4 \
--disable-unrolling \
--enable-generic-code \
--enable-contracted-ints \
--with-cxx=clang++ \
--with-cxx-optflags="-std=c++11 -O3" \
--with-cxxgen-optflags="-std=c++11 -O3" \
--prefix=$PWD/..

The code that seg faults is thus:

RealMatrix genSpx(BasisSet obs1, BasisSet obs2){
  if(obs1.size() != obs2.size()) {
    cout << "genSpx cannot take two basis sets of different size" << endl;
    std::exit(1);
  }
  RealMatrix S(obs1.size(),obs2.size());
  auto shell2bf = obs1.shell2bf();

  libint2::OneBodyEngine engine(libint2::OneBodyEngine::overlap,
    obs1.max_nprim(),obs1.max_l(),0);

  cout << obs1.size() << "," << obs2.size() << endl;
  for(auto iSh = 0; iSh < obs1.size(); iSh++)
  for(auto jSh = 0; jSh < obs2.size(); jSh++){
    auto s1 = shell2bf[iSh];
    auto s2 = shell2bf[jSh];
    auto n1 = obs1[iSh].size();
    auto n2 = obs2[jSh].size();
    cout << iSh << "," << jSh << endl;
    cout << s1 << "," << s2 << endl;
    cout << n1 << "," << n2 << endl;
    const auto *buff = engine.compute(obs1[iSh],obs2[jSh]);
    RealConstMap sMap(buff,n1,n2);
    cout << "sMap" << endl << sMap << endl << endl;
//    S.block(s1,s2,n1,n2) = sMap;
  }

  return S;
};

and the output is

Will read basis set from /Volumes/Gaussian/dbwy/Documents/Projects/libint/../share/libint/2.1.0-beta2/basis/cc-pvdz.g94
Will read basis set from /Volumes/Gaussian/dbwy/Documents/Projects/libint/../share/libint/2.1.0-beta2/basis/cc-pvdz.g94
24,24
0,0
0,0
1,1
sMap
1

0,1
0,1
1,1
sMap
-0.2157

0,2
0,2
1,1
sMap
0.19014

0,3
0,3
1,3
Segmentation fault

I've tried this with obs1 and obs1 in the ovelap call with the exact same problem. The point of this code is to compute the overlap of basis sets at different geometries, but it fails for the "vanilla" usage as well (passing only obs1 into the compute function)

wavefunction91 commented 8 years ago

I should also note that the seg fault also happens if I put a print statement before the eigen map

evaleev commented 8 years ago

fairly sure you did not do libint2::init() before doing this ... please check (I made the same mistake and reproduced your error).

also, you probably want to pass basis sets by reference since they have deep copy semantics.

wavefunction91 commented 8 years ago

Ah, yes, you're absolutely correct (this was done outside CQ, so I just forgot the add that line). As for the BasisSet pass, that's actually what I do, I just dictated it quickly as I didn't copy/paste.

On Thu, Jan 28, 2016 at 8:24 AM, Eduard Valeyev notifications@github.com wrote:

Closed #48 https://github.com/evaleev/libint/issues/48.

— Reply to this email directly or view it on GitHub https://github.com/evaleev/libint/issues/48#event-529927798.

David Williams-Young Department of Chemistry University of Washington Xiaosong Li Research Group