Skip to content

Commit

Permalink
Fix ornl CI tests
Browse files Browse the repository at this point in the history
sulfur: Add missing SPOSet header in NiO tests
nitrogen: Add missing memory header for std::unique_ptr
  • Loading branch information
williamfgc committed Oct 26, 2023
1 parent 29c7a64 commit 7a7614a
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 145 deletions.
229 changes: 84 additions & 145 deletions src/Particle/WalkerConfigurationsT.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "Particle/Walker.h"
#include "Utilities/IteratorUtility.h"

#include <memory>

namespace qmcplusplus
{
/** Monte Carlo Data of an ensemble
Expand All @@ -37,222 +39,159 @@ namespace qmcplusplus
* - Variance variance
* - LivingFraction fraction of walkers alive each step.
*/
template <typename T>
template<typename T>
struct MCDataType
{
T NumSamples;
T RNSamples;
T Weight;
T Energy;
T AlternateEnergy;
T Variance;
T R2Accepted;
T R2Proposed;
T LivingFraction;
T NumSamples;
T RNSamples;
T Weight;
T Energy;
T AlternateEnergy;
T Variance;
T R2Accepted;
T R2Proposed;
T LivingFraction;
};

/** A set of light weight walkers that are carried between driver sections and
* restart
*/
template <typename T>
template<typename T>
class WalkerConfigurationsT
{
public:
/// walker type
using Walker_t = Walker<ParticleSetTraits<T>, LatticeParticleTraits<T>>;
using RealType = typename Walker_t::RealType;
using FullPrecRealType = typename ParticleSetTraits<T>::FullPrecRealType;
/// container type of Walkers
using walker_list__t = std::vector<std::unique_ptr<Walker_t>>;
/// FIX: a type alias of iterator for an object should not be for just one
/// of many objects it holds.
using iterator = typename walker_list__t::iterator;
/// const_iterator of Walker container
using const_iterator = typename walker_list__t::const_iterator;

MCDataType<FullPrecRealType> EnsembleProperty;

WalkerConfigurationsT();
~WalkerConfigurationsT();
WalkerConfigurationsT(const WalkerConfigurationsT&) = delete;
WalkerConfigurationsT&
operator=(const WalkerConfigurationsT&) = delete;
WalkerConfigurationsT(WalkerConfigurationsT&&) = default;
WalkerConfigurationsT&
operator=(WalkerConfigurationsT&&) = default;

/** create numWalkers Walkers
/// walker type
using Walker_t = Walker<ParticleSetTraits<T>, LatticeParticleTraits<T>>;
using RealType = typename Walker_t::RealType;
using FullPrecRealType = typename ParticleSetTraits<T>::FullPrecRealType;
/// container type of Walkers
using walker_list__t = std::vector<std::unique_ptr<Walker_t>>;
/// FIX: a type alias of iterator for an object should not be for just one
/// of many objects it holds.
using iterator = typename walker_list__t::iterator;
/// const_iterator of Walker container
using const_iterator = typename walker_list__t::const_iterator;

MCDataType<FullPrecRealType> EnsembleProperty;

WalkerConfigurationsT();
~WalkerConfigurationsT();
WalkerConfigurationsT(const WalkerConfigurationsT&) = delete;
WalkerConfigurationsT& operator=(const WalkerConfigurationsT&) = delete;
WalkerConfigurationsT(WalkerConfigurationsT&&) = default;
WalkerConfigurationsT& operator=(WalkerConfigurationsT&&) = default;

/** create numWalkers Walkers
*
* Append Walkers to walker_list_.
*/
void
createWalkers(int numWalkers, size_t numPtcls);
/** create walkers
void createWalkers(int numWalkers, size_t numPtcls);
/** create walkers
* @param first walker iterator
* @param last walker iterator
*/
void
createWalkers(iterator first, iterator last);
/** copy walkers
void createWalkers(iterator first, iterator last);
/** copy walkers
* @param first input walker iterator
* @param last input walker iterator
* @param start first target iterator
*
* No memory allocation is allowed.
*/
void
copyWalkers(iterator first, iterator last, iterator start);
void copyWalkers(iterator first, iterator last, iterator start);

/** destroy Walkers from itstart to itend
/** destroy Walkers from itstart to itend
*@param first starting iterator of the walkers
*@param last ending iterator of the walkers
*/
iterator
destroyWalkers(iterator first, iterator last);
iterator destroyWalkers(iterator first, iterator last);

/** destroy Walkers
/** destroy Walkers
*@param nw number of walkers to be destroyed
*/
void
destroyWalkers(int nw);
void destroyWalkers(int nw);

/// clean up the walker list and make a new list
void
resize(int numWalkers, size_t numPtcls);
/// clean up the walker list and make a new list
void resize(int numWalkers, size_t numPtcls);

/// return the number of active walkers
inline size_t
getActiveWalkers() const
{
return walker_list_.size();
}
/// return the total number of active walkers among a MPI group
inline size_t
getGlobalNumWalkers() const
{
return walker_offsets_.empty() ? 0 : walker_offsets_.back();
}
/// return the total number of active walkers among a MPI group
/// return the number of active walkers
inline size_t getActiveWalkers() const { return walker_list_.size(); }
/// return the total number of active walkers among a MPI group
inline size_t getGlobalNumWalkers() const { return walker_offsets_.empty() ? 0 : walker_offsets_.back(); }
/// return the total number of active walkers among a MPI group

inline void
setWalkerOffsets(const std::vector<int>& o)
{
walker_offsets_ = o;
}
inline const std::vector<int>&
getWalkerOffsets() const
{
return walker_offsets_;
}
inline void setWalkerOffsets(const std::vector<int>& o) { walker_offsets_ = o; }
inline const std::vector<int>& getWalkerOffsets() const { return walker_offsets_; }

/// return the first iterator
inline iterator
begin()
{
return walker_list_.begin();
}
/// return the last iterator, [begin(), end())
inline iterator
end()
{
return walker_list_.end();
}
/// return the first iterator
inline iterator begin() { return walker_list_.begin(); }
/// return the last iterator, [begin(), end())
inline iterator end() { return walker_list_.end(); }

/// return the first const_iterator
inline const_iterator
begin() const
{
return walker_list_.begin();
}
/// return the first const_iterator
inline const_iterator begin() const { return walker_list_.begin(); }

/// return the last const_iterator [begin(), end())
inline const_iterator
end() const
{
return walker_list_.end();
}
/**@}*/
/// return the last const_iterator [begin(), end())
inline const_iterator end() const { return walker_list_.end(); }
/**@}*/

/** clear the walker_list_ without destroying them
/** clear the walker_list_ without destroying them
*
* Provide std::vector::clear interface
*/
inline void
clear()
{
walker_list_.clear();
}
inline void clear() { walker_list_.clear(); }

/** insert elements
/** insert elements
* @param it locator where the inserting begins
* @param first starting iterator
* @param last ending iterator
*
* Provide std::vector::insert interface
*/
template <class INPUT_ITER>
inline void
insert(iterator it, INPUT_ITER first, INPUT_ITER last)
{
walker_list_.insert(it, first, last);
}
template<class INPUT_ITER>
inline void insert(iterator it, INPUT_ITER first, INPUT_ITER last)
{
walker_list_.insert(it, first, last);
}

/** add Walker_t* at the end
/** add Walker_t* at the end
* @param awalker pointer to a walker
*
* Provide std::vector::push_back interface
*/
inline void
push_back(std::unique_ptr<Walker_t> awalker)
{
walker_list_.push_back(std::move(awalker));
}
inline void push_back(std::unique_ptr<Walker_t> awalker) { walker_list_.push_back(std::move(awalker)); }

/** delete the last Walker_t*
/** delete the last Walker_t*
*
* Provide std::vector::pop_back interface
*/
inline void
pop_back()
{
walker_list_.pop_back();
}
inline void pop_back() { walker_list_.pop_back(); }

inline Walker_t*
operator[](int i)
{
return walker_list_[i].get();
}
inline Walker_t* operator[](int i) { return walker_list_[i].get(); }

inline const Walker_t*
operator[](int i) const
{
return walker_list_[i].get();
}
inline const Walker_t* operator[](int i) const { return walker_list_[i].get(); }

/** reset the Walkers
/** reset the Walkers
*/
void
reset();
void reset();

/// save the particle positions of all the walkers into target
void
putConfigurations(RealType* target, FullPrecRealType* weights) const;
/// save the particle positions of all the walkers into target
void putConfigurations(RealType* target, FullPrecRealType* weights) const;

protected:
/// a collection of walkers
walker_list__t walker_list_;
/// a collection of walkers
walker_list__t walker_list_;

private:
/** starting index of the walkers in a processor group
/** starting index of the walkers in a processor group
*
* walker_offsets_[0]=0 and walker_offsets_[walker_offsets_.size()-1]=total
* number of walkers in a group
* walker_offsets_[processorid+1]-walker_offsets_[processorid] is equal to
* the number of walkers on a processor, i.e., W.getActiveWalkers().
* walker_offsets_ is added to handle parallel I/O with hdf5
*/
std::vector<int> walker_offsets_;
std::vector<int> walker_offsets_;
};
} // namespace qmcplusplus
#endif
1 change: 1 addition & 0 deletions src/QMCWaveFunctions/tests/test_einset_NiO_a16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "QMCWaveFunctions/WaveFunctionComponent.h"
#include "BsplineFactory/EinsplineSetBuilder.h"
#include "BsplineFactory/EinsplineSpinorSetBuilder.h"
#include "QMCWaveFunctions/SPOSet.h"
#include <ResourceCollection.h>

#include <stdio.h>
Expand Down

0 comments on commit 7a7614a

Please sign in to comment.