biod.pnpi.spb.ru
/
alexxy
/
gromacs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Expand signatures for nblib listed forces calculator
[alexxy/gromacs.git]
/
api
/
nblib
/
listed_forces
/
helpers.hpp
diff --git
a/api/nblib/listed_forces/helpers.hpp
b/api/nblib/listed_forces/helpers.hpp
index b5e89ba4aa9126b843dfa2f5503209c0d3c13823..b514089abaccf820168129928e9463c452b00a12 100644
(file)
--- a/
api/nblib/listed_forces/helpers.hpp
+++ b/
api/nblib/listed_forces/helpers.hpp
@@
-49,6
+49,8
@@
#include <unordered_map>
#include <unordered_map>
+#include "gromacs/utility/arrayref.h"
+
#include "nblib/pbc.hpp"
#include "definitions.h"
#include "nblib/util/util.hpp"
#include "nblib/pbc.hpp"
#include "definitions.h"
#include "nblib/util/util.hpp"
@@
-75,29
+77,29
@@
inline void gmxRVecZeroWorkaround<gmx::RVec>(gmx::RVec& value)
}
} // namespace detail
}
} // namespace detail
-/*! \internal \brief object to store forces for multithreaded listed forces computation
+/*! \internal \brief proxy object to access forces in an underlying buffer
+ *
+ * Depending on the index, either the underlying master buffer, or local
+ * storage for outliers is accessed. This object does not own the master buffer.
*
*/
template<class T>
*
*/
template<class T>
-class ForceBuffer
+class ForceBuffer
Proxy
{
using HashMap = std::unordered_map<int, T>;
public:
{
using HashMap = std::unordered_map<int, T>;
public:
- ForceBuffer
() : rangeStart(0), rangeEnd
(0) { }
+ ForceBuffer
Proxy() : rangeStart_(0), rangeEnd_
(0) { }
- ForceBuffer(T* mbuf, int rs, int re) :
- masterForceBuffer(mbuf),
- rangeStart(rs),
- rangeEnd(re)
+ ForceBufferProxy(int rangeStart, int rangeEnd) : rangeStart_(rangeStart), rangeEnd_(rangeEnd)
{
}
{
}
- void clear() { outliers.clear(); }
+ void clear
Outliers
() { outliers.clear(); }
inline NBLIB_ALWAYS_INLINE T& operator[](int i)
{
inline NBLIB_ALWAYS_INLINE T& operator[](int i)
{
- if (i >= rangeStart
&& i < rangeEnd
)
+ if (i >= rangeStart
_ && i < rangeEnd_
)
{
return masterForceBuffer[i];
}
{
return masterForceBuffer[i];
}
@@
-117,12
+119,14
@@
public:
typename HashMap::const_iterator begin() { return outliers.begin(); }
typename HashMap::const_iterator end() { return outliers.end(); }
typename HashMap::const_iterator begin() { return outliers.begin(); }
typename HashMap::const_iterator end() { return outliers.end(); }
- [[nodiscard]] bool inRange(int index) const { return (index >= rangeStart && index < rangeEnd); }
+ [[nodiscard]] bool inRange(int index) const { return (index >= rangeStart_ && index < rangeEnd_); }
+
+ void setMasterBuffer(gmx::ArrayRef<T> buffer) { masterForceBuffer = buffer; }
private:
private:
-
T*
masterForceBuffer;
- int rangeStart;
- int rangeEnd;
+
gmx::ArrayRef<T>
masterForceBuffer;
+ int rangeStart
_
;
+ int rangeEnd
_
;
HashMap outliers;
};
HashMap outliers;
};