Skip to content

Commit

Permalink
defensive try and updated baselines post kpoint sort consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
PDoakORNL committed Feb 24, 2025
1 parent a4bd470 commit c4e1b82
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 62 deletions.
105 changes: 57 additions & 48 deletions src/Particle/HDFWalkerInput_0_4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,63 +127,72 @@ bool HDFWalkerInput_0_4::read_hdf5(const std::filesystem::path& h5name)
{
size_t nw_in = 0;

hdf_archive hin(myComm, false); //everone reads this
bool success = hin.open(h5name, H5F_ACC_RDONLY);
//check if hdf and xml versions can work together
HDFVersion aversion;

hin.read(aversion, hdf::version);
if (!(aversion < i_info.version))
{
int found_group = hin.is_group(hdf::main_state);
hin.push(hdf::main_state);
hin.read(nw_in, hdf::num_walkers);
}
else
{
app_error() << " Mismatched version. xml = " << i_info.version << " hdf = " << aversion << std::endl;
}

if (nw_in == 0)
// This prevents a strange race condition I've see where the previous sections
// for sure already closed hdf5 file isn't available.
try
{
app_error() << " No walkers in " << h5name << std::endl;
return false;
}
hdf_archive hin(myComm, false); //everone reads this
myComm->barrier();
bool success = hin.open(h5name, H5F_ACC_RDONLY);
//check if hdf and xml versions can work together
HDFVersion aversion;
hin.read(aversion, hdf::version);
if (!(aversion < i_info.version))
{
int found_group = hin.is_group(hdf::main_state);
hin.push(hdf::main_state);
hin.read(nw_in, hdf::num_walkers);
}
else
{
app_error() << " Mismatched version. xml = " << i_info.version << " hdf = " << aversion << std::endl;
}

using Buffer_t = std::vector<QMCTraits::RealType>;
std::array<size_t, 3> dims{nw_in, num_ptcls_, OHMMS_DIM};
Buffer_t posin(dims[0] * dims[1] * dims[2]);
hin.readSlabReshaped(posin, dims, hdf::walkers);
std::vector<QMCTraits::FullPrecRealType> weights_in(nw_in);
const bool has_weights = hin.readEntry(weights_in, hdf::walker_weights);
if (nw_in == 0)
{
app_error() << " No walkers in " << h5name << std::endl;
return false;
}

std::vector<int> woffsets;
hin.read(woffsets, "walker_partition");
using Buffer_t = std::vector<QMCTraits::RealType>;
std::array<size_t, 3> dims{nw_in, num_ptcls_, OHMMS_DIM};
Buffer_t posin(dims[0] * dims[1] * dims[2]);
hin.readSlabReshaped(posin, dims, hdf::walkers);
std::vector<QMCTraits::FullPrecRealType> weights_in(nw_in);
const bool has_weights = hin.readEntry(weights_in, hdf::walker_weights);

int np1 = myComm->size() + 1;
if (woffsets.size() != np1)
{
woffsets.resize(myComm->size() + 1, 0);
FairDivideLow(nw_in, myComm->size(), woffsets);
}
std::vector<int> woffsets;
hin.read(woffsets, "walker_partition");

app_log() << " HDFWalkerInput_0_4::put getting " << dims[0] << " walkers " << posin.size() << std::endl;
nw_in = woffsets[myComm->rank() + 1] - woffsets[myComm->rank()];
{
const int nitems = num_ptcls_ * OHMMS_DIM;
const int curWalker = wc_list_.getActiveWalkers();
wc_list_.createWalkers(nw_in, num_ptcls_);
int np1 = myComm->size() + 1;
if (woffsets.size() != np1)
{
woffsets.resize(myComm->size() + 1, 0);
FairDivideLow(nw_in, myComm->size(), woffsets);
}

auto it = posin.begin() + woffsets[myComm->rank()] * nitems;
for (int i = 0; i < nw_in; ++i, it += nitems)
copy(it, it + nitems, get_first_address(wc_list_[i + curWalker]->R));
if (has_weights)
app_log() << " HDFWalkerInput_0_4::put getting " << dims[0] << " walkers " << posin.size() << std::endl;
nw_in = woffsets[myComm->rank() + 1] - woffsets[myComm->rank()];
{
const auto woffset = woffsets[myComm->rank()];
for (int i = 0; i < nw_in; ++i)
wc_list_[i + curWalker]->Weight = weights_in[i + woffset];
const int nitems = num_ptcls_ * OHMMS_DIM;
const int curWalker = wc_list_.getActiveWalkers();
wc_list_.createWalkers(nw_in, num_ptcls_);

auto it = posin.begin() + woffsets[myComm->rank()] * nitems;
for (int i = 0; i < nw_in; ++i, it += nitems)
copy(it, it + nitems, get_first_address(wc_list_[i + curWalker]->R));
if (has_weights)
{
const auto woffset = woffsets[myComm->rank()];
for (int i = 0; i < nw_in; ++i)
wc_list_[i + curWalker]->Weight = weights_in[i + woffset];
}
}
}
catch (...)
{
throw std::runtime_error("Failed to open: " + h5name.string() + "to read walkers!");
}

return true;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/solids/diamondC_2x1x1-Gaussian_pp_MSD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ if(QMC_MIXED_PRECISION)
list(APPEND det_diamondC_2x1x1-Gaussian_pp_MSD_VMC_DMC_BATCH_MWALKERS-r1-t16_1_SCALARS "eeenergy"
"-5.08527221 0.00003")
list(APPEND det_diamondC_2x1x1-Gaussian_pp_MSD_VMC_DMC_BATCH_MWALKERS-r1-t16_1_SCALARS "ionion"
"-25.55133363 0.000002")
"-25.55132413 0.000002")
list(APPEND det_diamondC_2x1x1-Gaussian_pp_MSD_VMC_DMC_BATCH_MWALKERS-r1-t16_1_SCALARS "localecp"
"-9.83228444 0.0002")
list(APPEND det_diamondC_2x1x1-Gaussian_pp_MSD_VMC_DMC_BATCH_MWALKERS-r1-t16_1_SCALARS "nonlocalecp"
Expand All @@ -373,7 +373,7 @@ if(QMC_MIXED_PRECISION)
list(APPEND det_diamondC_2x1x1-Gaussian_pp_MSD_VMC_DMC_BATCH_MWALKERS-r1-t16_2_SCALARS "eeenergy"
"-4.68529565 0.00003")
list(APPEND det_diamondC_2x1x1-Gaussian_pp_MSD_VMC_DMC_BATCH_MWALKERS-r1-t16_2_SCALARS "ionion"
"-25.55133363 0.000002")
"-25.55132413 0.000002")
list(APPEND det_diamondC_2x1x1-Gaussian_pp_MSD_VMC_DMC_BATCH_MWALKERS-r1-t16_2_SCALARS "localecp"
"-15.31087459 0.0002")
list(APPEND det_diamondC_2x1x1-Gaussian_pp_MSD_VMC_DMC_BATCH_MWALKERS-r1-t16_2_SCALARS "nonlocalecp"
Expand All @@ -389,7 +389,7 @@ if(QMC_MIXED_PRECISION)
list(APPEND det_diamondC_2x1x1-Gaussian_pp_MSD_VMC_DMC_BATCH_MWALKERS-r1-t16_3_SCALARS "eeenergy"
"-4.60729524 0.00003")
list(APPEND det_diamondC_2x1x1-Gaussian_pp_MSD_VMC_DMC_BATCH_MWALKERS-r1-t16_3_SCALARS "ionion"
"-25.55133363 0.000002")
"-25.55132353 0.000002")
list(APPEND det_diamondC_2x1x1-Gaussian_pp_MSD_VMC_DMC_BATCH_MWALKERS-r1-t16_3_SCALARS "localecp"
"-17.12262279 0.0002")
list(APPEND det_diamondC_2x1x1-Gaussian_pp_MSD_VMC_DMC_BATCH_MWALKERS-r1-t16_3_SCALARS "nonlocalecp"
Expand Down
22 changes: 11 additions & 11 deletions tests/solids/diamondC_2x1x1_pp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ if(QMC_MIXED_PRECISION)
list(APPEND DET_DIAMOND2_DMC_SCALARS "kinetic" "22.67695498 0.00001003")
list(APPEND DET_DIAMOND2_DMC_SCALARS "potential" "-43.71422745 0.00000515")
list(APPEND DET_DIAMOND2_DMC_SCALARS "eeenergy" "-6.17624904 0.000001")
list(APPEND DET_DIAMOND2_DMC_SCALARS "ionion" "-25.55133296 0.0000014")
list(APPEND DET_DIAMOND2_DMC_SCALARS "ionion" "-25.55132413 0.0000014")
list(APPEND DET_DIAMOND2_DMC_SCALARS "localecp" "-9.10928079 0.00000442")
list(APPEND DET_DIAMOND2_DMC_SCALARS "nonlocalecp" "-2.87736895 0.00000177")
list(APPEND DET_DIAMOND2_DMC_SCALARS "samples" "9.00000000 0.0")
Expand Down Expand Up @@ -571,7 +571,7 @@ if(QMC_MIXED_PRECISION)
list(APPEND DET_DIAMOND2_DMC_EXCITED_SCALARS "kinetic" "24.80059962 0.00002563")
list(APPEND DET_DIAMOND2_DMC_EXCITED_SCALARS "potential" "-44.85581823 0.00000861")
list(APPEND DET_DIAMOND2_DMC_EXCITED_SCALARS "eeenergy" "-5.88258978 0.00000192")
list(APPEND DET_DIAMOND2_DMC_EXCITED_SCALARS "ionion" "-25.55133347 0.000002")
list(APPEND DET_DIAMOND2_DMC_EXCITED_SCALARS "ionion" "-25.55132413 0.000002")
list(APPEND DET_DIAMOND2_DMC_EXCITED_SCALARS "localecp" "-16.39535242 0.00000777")
list(APPEND DET_DIAMOND2_DMC_EXCITED_SCALARS "nonlocalecp" "2.97345613 0.00001229")
list(APPEND DET_DIAMOND2_DMC_EXCITED_SCALARS "samples" "9.00000000 0.0")
Expand Down Expand Up @@ -626,7 +626,7 @@ if(QMC_MIXED_PRECISION)
list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS1_SCALARS "kinetic" "19.21103034 0.0005")
list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS1_SCALARS "potential" "-41.26064989 0.0001")
list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS1_SCALARS "eeenergy" "-6.68405093 0.00003")
list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS1_SCALARS "ionion" "-25.55133345 0.000002")
list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS1_SCALARS "ionion" "-25.55132413 0.000002")
list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS1_SCALARS "localecp" "-10.92577863 0.0002")
list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS1_SCALARS "nonlocalecp" "1.90051359 0.0001")
list(APPEND DET_DIAMOND2_VMC_BATCH_MWALKERS1_SCALARS "flux" "-0.31336816 0.001")
Expand Down Expand Up @@ -744,7 +744,7 @@ if(QMC_MIXED_PRECISION)
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t4_1_SCALARS "kinetic" "21.58412194 0.0005")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t4_1_SCALARS "potential" "-43.34107537 0.0001")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t4_1_SCALARS "eeenergy" "-4.93051914 0.00003")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t4_1_SCALARS "ionion" "-25.55133345 0.000002")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t4_1_SCALARS "ionion" "-25.55132413 0.000002")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t4_1_SCALARS "localecp" "-14.55016309 0.0002")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t4_1_SCALARS "nonlocalecp" "1.69094030 0.0001")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t4_1_SCALARS "flux" "14.56015197 0.001")
Expand All @@ -754,7 +754,7 @@ if(QMC_MIXED_PRECISION)
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t4_2_SCALARS "kinetic" "21.75835414 0.0005")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t4_2_SCALARS "potential" "-43.16599791 0.0001")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t4_2_SCALARS "eeenergy" "-5.31127989 0.00003")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t4_2_SCALARS "ionion" "-25.55133345 0.000002")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t4_2_SCALARS "ionion" "-25.55132413 0.000002")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t4_2_SCALARS "localecp" "-13.83088578 0.0002")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t4_2_SCALARS "nonlocalecp" "1.52749084 0.0001")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t4_2_SCALARS "flux" "1.55142989 0.001")
Expand All @@ -764,7 +764,7 @@ if(QMC_MIXED_PRECISION)
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t4_3_SCALARS "kinetic" "24.31653559 0.0005")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t4_3_SCALARS "potential" "-46.08009462 0.0001")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t4_3_SCALARS "eeenergy" "-5.15140370 0.00003")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t4_3_SCALARS "ionion" "-25.55133345 0.000002")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t4_3_SCALARS "ionion" "-25.55132413 0.000002")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t4_3_SCALARS "localecp" "-17.32746386 0.0002")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t4_3_SCALARS "nonlocalecp" "1.95010638 0.0001")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t4_3_SCALARS "flux" "-15.81523996 0.001")
Expand Down Expand Up @@ -886,7 +886,7 @@ if(QMC_MIXED_PRECISION)
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS_SERIALIZED-r1-t4_1_SCALARS "kinetic" "20.59152300 0.0005")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS_SERIALIZED-r1-t4_1_SCALARS "potential" "-42.28743906 0.0001")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS_SERIALIZED-r1-t4_1_SCALARS "eeenergy" "-4.99385904 0.00003")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS_SERIALIZED-r1-t4_1_SCALARS "ionion" "-25.55133345 0.000002")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS_SERIALIZED-r1-t4_1_SCALARS "ionion" "-25.55132413 0.000002")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS_SERIALIZED-r1-t4_1_SCALARS "localecp" "-13.52316837 0.0002")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS_SERIALIZED-r1-t4_1_SCALARS "nonlocalecp" "1.78092056 0.0001")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS_SERIALIZED-r1-t4_1_SCALARS "flux" "0.04231199 0.001")
Expand All @@ -896,7 +896,7 @@ if(QMC_MIXED_PRECISION)
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS_SERIALIZED-r1-t4_2_SCALARS "kinetic" "20.01371014 0.0005")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS_SERIALIZED-r1-t4_2_SCALARS "potential" "-41.48156478 0.0001")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS_SERIALIZED-r1-t4_2_SCALARS "eeenergy" "-5.33482570 0.00003")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS_SERIALIZED-r1-t4_2_SCALARS "ionion" "-25.55133345 0.000002")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS_SERIALIZED-r1-t4_2_SCALARS "ionion" "-25.55132413 0.000002")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS_SERIALIZED-r1-t4_2_SCALARS "localecp" "-12.01852844 0.0002")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS_SERIALIZED-r1-t4_2_SCALARS "nonlocalecp" "1.42312156 0.0001")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS_SERIALIZED-r1-t4_2_SCALARS "flux" "-3.44516609 0.001")
Expand All @@ -906,7 +906,7 @@ if(QMC_MIXED_PRECISION)
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS_SERIALIZED-r1-t4_3_SCALARS "kinetic" "19.99149153 0.0005")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS_SERIALIZED-r1-t4_3_SCALARS "potential" "-41.44921562 0.0001")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS_SERIALIZED-r1-t4_3_SCALARS "eeenergy" "-5.08977813 0.00003")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS_SERIALIZED-r1-t4_3_SCALARS "ionion" "-25.55133345 0.000002")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS_SERIALIZED-r1-t4_3_SCALARS "ionion" "-25.55132393 0.000002")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS_SERIALIZED-r1-t4_3_SCALARS "localecp" "-11.98988102 0.0002")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS_SERIALIZED-r1-t4_3_SCALARS "nonlocalecp" "1.18177600 0.0001")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS_SERIALIZED-r1-t4_3_SCALARS "flux" "-11.51920996 0.001")
Expand Down Expand Up @@ -1080,7 +1080,7 @@ if(QMC_MIXED_PRECISION)
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t16_3_SCALARS "kinetic" "19.10457607 0.0005")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t16_3_SCALARS "potential" "-41.32836692 0.0001")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t16_3_SCALARS "eeenergy" "-5.53681243 0.00003")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t16_3_SCALARS "ionion" "-25.55133345 0.000002")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t16_3_SCALARS "ionion" "-25.55132393 0.000002")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t16_3_SCALARS "localecp" "-12.48670659 0.0002")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t16_3_SCALARS "nonlocalecp" "2.24647505 0.0001")
list(APPEND DET_DIAMOND2_VMC_DMC_BATCH_MWALKERS-r1-t16_3_SCALARS "flux" "-6.00048904 0.001")
Expand Down Expand Up @@ -1565,7 +1565,7 @@ if(QMC_MIXED_PRECISION)
list(APPEND DET_DIAMOND2_DMC_BATCH_EXCITED_SCALARS "kinetic" "17.47436757 0.00002563")
list(APPEND DET_DIAMOND2_DMC_BATCH_EXCITED_SCALARS "potential" "-38.41717159 0.00000861")
list(APPEND DET_DIAMOND2_DMC_BATCH_EXCITED_SCALARS "eeenergy" "-5.71276953 0.00000192")
list(APPEND DET_DIAMOND2_DMC_BATCH_EXCITED_SCALARS "ionion" "-25.55133347 0.000002")
list(APPEND DET_DIAMOND2_DMC_BATCH_EXCITED_SCALARS "ionion" "-25.55132690 0.000002")
list(APPEND DET_DIAMOND2_DMC_BATCH_EXCITED_SCALARS "localecp" "-8.33530885 0.00000777")
list(APPEND DET_DIAMOND2_DMC_BATCH_EXCITED_SCALARS "nonlocalecp" "1.18224586 0.00001229")
else()
Expand Down

0 comments on commit c4e1b82

Please sign in to comment.