Skip to content

Commit

Permalink
replace PaddedRVecVector by gmx::HostVector<gmx::RVec>
Browse files Browse the repository at this point in the history
  • Loading branch information
BerndDoser committed Jan 12, 2018
1 parent e05b93a commit c156ba4
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 36 deletions.
12 changes: 6 additions & 6 deletions src/gromacs/fda/DistributedForces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void DistributedForces::write_detailed_vector(std::ostream& os) const
}
}

void DistributedForces::write_detailed_scalar(std::ostream& os, PaddedRVecVector const& x) const
void DistributedForces::write_detailed_scalar(std::ostream& os, gmx::HostVector<gmx::RVec> const& x) const
{
for (size_t i = 0; i != detailed.size(); ++i) {
auto const& detailed_i = detailed[i];
Expand Down Expand Up @@ -125,7 +125,7 @@ void DistributedForces::write_summed_vector(std::ostream& os) const
}
}

void DistributedForces::write_summed_scalar(std::ostream& os, PaddedRVecVector const& x) const
void DistributedForces::write_summed_scalar(std::ostream& os, gmx::HostVector<gmx::RVec> const& x) const
{
for (size_t i = 0; i != summed.size(); ++i) {
auto const& summed_i = summed[i];
Expand Down Expand Up @@ -155,7 +155,7 @@ void DistributedForces::write_scalar(std::ostream& os) const
}
}

void DistributedForces::write_total_forces(std::ostream& os, PaddedRVecVector const& x) const
void DistributedForces::write_total_forces(std::ostream& os, gmx::HostVector<gmx::RVec> const& x) const
{
std::vector<real> total_forces(syslen, 0.0);
for (size_t i = 0; i != summed.size(); ++i) {
Expand Down Expand Up @@ -247,7 +247,7 @@ void DistributedForces::write_scalar_compat_ascii(std::ostream& os) const
os << std::endl;
}

void DistributedForces::write_summed_compat_ascii(std::ostream& os, PaddedRVecVector const& x) const
void DistributedForces::write_summed_compat_ascii(std::ostream& os, gmx::HostVector<gmx::RVec> const& x) const
{
// Print total number of interactions
int nb_interactions = 0;
Expand Down Expand Up @@ -338,7 +338,7 @@ void DistributedForces::write_scalar_compat_bin(std::ostream& os) const
}
}

void DistributedForces::write_summed_compat_bin(std::ostream& os, PaddedRVecVector const& x) const
void DistributedForces::write_summed_compat_bin(std::ostream& os, gmx::HostVector<gmx::RVec> const& x) const
{
// Print total number of interactions
int nb_interactions = 0;
Expand Down Expand Up @@ -392,7 +392,7 @@ void DistributedForces::scalar_real_divide(real divisor)
for (auto& scalar_j : scalar_i) scalar_j.force *= inv;
}

void DistributedForces::summed_merge_to_scalar(PaddedRVecVector const& x)
void DistributedForces::summed_merge_to_scalar(gmx::HostVector<gmx::RVec> const& x)
{
for (size_t i = 0; i != summed.size(); ++i) {
auto & scalar_i = scalar[i];
Expand Down
14 changes: 7 additions & 7 deletions src/gromacs/fda/DistributedForces.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define SRC_GROMACS_FDA_DISTRIBUTEDFORCES_H_

#include <vector>
#include "gromacs/math/paddedvector.h"
#include "gromacs/gpu_utils/hostallocator.h"
#include "gromacs/math/vectypes.h"
#include "gromacs/utility/real.h"
#include "DetailedForce.h"
Expand Down Expand Up @@ -55,28 +55,28 @@ class DistributedForces

void write_detailed_vector(std::ostream& os) const;

void write_detailed_scalar(std::ostream& os, PaddedRVecVector const& x) const;
void write_detailed_scalar(std::ostream& os, gmx::HostVector<gmx::RVec> const& x) const;

void write_summed_vector(std::ostream& os) const;

void write_summed_scalar(std::ostream& os, PaddedRVecVector const& x) const;
void write_summed_scalar(std::ostream& os, gmx::HostVector<gmx::RVec> const& x) const;

void write_scalar(std::ostream& os) const;

void write_total_forces(std::ostream& os, PaddedRVecVector const& x) const;
void write_total_forces(std::ostream& os, gmx::HostVector<gmx::RVec> const& x) const;

void write_scalar_compat_ascii(std::ostream& os) const;

void write_summed_compat_ascii(std::ostream& os, PaddedRVecVector const& x) const;
void write_summed_compat_ascii(std::ostream& os, gmx::HostVector<gmx::RVec> const& x) const;

void write_scalar_compat_bin(std::ostream& os) const;

void write_summed_compat_bin(std::ostream& os, PaddedRVecVector const& x) const;
void write_summed_compat_bin(std::ostream& os, gmx::HostVector<gmx::RVec> const& x) const;

/// Divide all scalar forces by the divisor
void scalar_real_divide(real divisor);

void summed_merge_to_scalar(PaddedRVecVector const& x);
void summed_merge_to_scalar(gmx::HostVector<gmx::RVec> const& x);

private:

Expand Down
10 changes: 5 additions & 5 deletions src/gromacs/fda/FDA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,13 +406,13 @@ void FDA::add_virial_dihedral(int i, int j, int k, int l,
add_virial(l, v, QUARTER);
}

void FDA::save_and_write_scalar_time_averages(PaddedRVecVector const& x, gmx_mtop_t *mtop)
void FDA::save_and_write_scalar_time_averages(gmx::HostVector<gmx::RVec> const& x, gmx_mtop_t *mtop)
{
if (fda_settings.time_averaging_period != 1) {
if (atom_based.PF_or_PS_mode())
atom_based.distributed_forces.summed_merge_to_scalar(x);
if (residue_based.PF_or_PS_mode()) {
PaddedRVecVector com = get_residues_com(x, mtop);
gmx::HostVector<gmx::RVec> com = get_residues_com(x, mtop);
residue_based.distributed_forces.summed_merge_to_scalar(com);
for (int i = 0; i != fda_settings.syslen_residues; ++i) {
rvec_inc(time_averaging_com[i], com[i]);
Expand Down Expand Up @@ -458,7 +458,7 @@ void FDA::write_scalar_time_averages()
time_averaging_steps = 0;
}

void FDA::write_frame(PaddedRVecVector const& x, gmx_mtop_t *mtop)
void FDA::write_frame(gmx::HostVector<gmx::RVec> const& x, gmx_mtop_t *mtop)
{
atom_based.write_frame(x, nsteps);
residue_based.write_frame(get_residues_com(x, mtop), nsteps);
Expand Down Expand Up @@ -685,7 +685,7 @@ void FDA::modify_energy_group_exclusions(gmx_mtop_t *mtop, t_inputrec *inputrec)

}

PaddedRVecVector FDA::get_residues_com(PaddedRVecVector const& x, gmx_mtop_t *mtop) const
gmx::HostVector<gmx::RVec> FDA::get_residues_com(gmx::HostVector<gmx::RVec> const& x, gmx_mtop_t *mtop) const
{
int moltype_index, mol_index, d;
int i, atom_index, atom_global_index, residue_global_index;
Expand All @@ -695,7 +695,7 @@ PaddedRVecVector FDA::get_residues_com(PaddedRVecVector const& x, gmx_mtop_t *mt
rvec r;

std::vector<real> mass(fda_settings.syslen_residues);
PaddedRVecVector com(fda_settings.syslen_residues);
gmx::HostVector<gmx::RVec> com(fda_settings.syslen_residues);

for (i = 0; i < fda_settings.syslen_residues; i++) {
mass[i] = 0.0;
Expand Down
8 changes: 4 additions & 4 deletions src/gromacs/fda/FDA.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <vector>
#include "FDABase.h"
#include "FDASettings.h"
#include "gromacs/math/paddedvector.h"
#include "gromacs/gpu_utils/hostallocator.h"
#include "gromacs/mdtypes/inputrec.h"
#include "InteractionType.h"
#include "PureInteractionType.h"
Expand Down Expand Up @@ -102,7 +102,7 @@ class FDA {
* writing because for this fda->atoms would need to be initialized (to get the atom
* number or to get the sys2ps mapping) which only happens when AtomBased is non-zero
*/
void save_and_write_scalar_time_averages(PaddedRVecVector const& x, gmx_mtop_t *mtop);
void save_and_write_scalar_time_averages(gmx::HostVector<gmx::RVec> const& x, gmx_mtop_t *mtop);

/**
* Write scalar time averages; this is similar to pf_write_frame, except that time averages are used
Expand All @@ -117,7 +117,7 @@ class FDA {
*/
void write_scalar_time_averages();

void write_frame(PaddedRVecVector const& x, gmx_mtop_t *mtop);
void write_frame(gmx::HostVector<gmx::RVec> const& x, gmx_mtop_t *mtop);

/// Main routine for FDA exclusions
void modify_energy_group_exclusions(gmx_mtop_t *mtop, t_inputrec *inputrec) const;
Expand All @@ -132,7 +132,7 @@ class FDA {
* not express the COM of the whole residue but the COM of the atoms of the residue which
* are interesting for PF
*/
PaddedRVecVector get_residues_com(PaddedRVecVector const& x, gmx_mtop_t *mtop) const;
gmx::HostVector<gmx::RVec> get_residues_com(gmx::HostVector<gmx::RVec> const& x, gmx_mtop_t *mtop) const;

/// Append group to energy groups, returns the position index
int add_name_to_energygrp(char const* name, gmx_groups_t* groups) const;
Expand Down
10 changes: 5 additions & 5 deletions src/gromacs/fda/FDABase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ FDABase<Base>::FDABase(ResultType result_type, int syslen, std::string const& re
}

template <class Base>
void FDABase<Base>::write_frame(PaddedRVecVector const& x, int nsteps)
void FDABase<Base>::write_frame(gmx::HostVector<gmx::RVec> const& x, int nsteps)
{
switch (fda_settings.one_pair) {
case OnePair::DETAILED:
Expand Down Expand Up @@ -94,7 +94,7 @@ void FDABase<Base>::write_frame(PaddedRVecVector const& x, int nsteps)
}

template <class Base>
void FDABase<Base>::write_frame_detailed(PaddedRVecVector const& x, bool print_vector, int nsteps)
void FDABase<Base>::write_frame_detailed(gmx::HostVector<gmx::RVec> const& x, bool print_vector, int nsteps)
{
result_file << "frame " << nsteps << std::endl;
if (print_vector)
Expand All @@ -104,7 +104,7 @@ void FDABase<Base>::write_frame_detailed(PaddedRVecVector const& x, bool print_v
}

template <class Base>
void FDABase<Base>::write_frame_summed(PaddedRVecVector const& x, bool print_vector, int nsteps)
void FDABase<Base>::write_frame_summed(gmx::HostVector<gmx::RVec> const& x, bool print_vector, int nsteps)
{
result_file << "frame " << nsteps << std::endl;
if (print_vector)
Expand All @@ -121,7 +121,7 @@ void FDABase<Base>::write_frame_scalar(int nsteps)
}

template <class Base>
void FDABase<Base>::write_total_forces(PaddedRVecVector const& x)
void FDABase<Base>::write_total_forces(gmx::HostVector<gmx::RVec> const& x)
{
distributed_forces.write_total_forces(result_file, x);
}
Expand Down Expand Up @@ -162,7 +162,7 @@ void FDABase<Base>::write_frame_scalar_compat(int nsteps)
}

template <class Base>
void FDABase<Base>::write_frame_summed_compat(PaddedRVecVector const& x, int nsteps)
void FDABase<Base>::write_frame_summed_compat(gmx::HostVector<gmx::RVec> const& x, int nsteps)
{
if (result_type == ResultType::COMPAT_ASCII) {
result_file << "<begin_block>" << std::endl;
Expand Down
13 changes: 7 additions & 6 deletions src/gromacs/fda/FDABase.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <vector>
#include "FDASettings.h"
#include "DistributedForces.h"
#include "gromacs/gpu_utils/hostallocator.h"
#include "gromacs/topology/topology.h"
#include "gromacs/utility/fatalerror.h"
#include "OnePair.h"
Expand Down Expand Up @@ -78,17 +79,17 @@ class FDABase : Base
result_type == ResultType::VIRIAL_STRESS_VON_MISES;
}

void write_frame(PaddedRVecVector const& x, int nsteps);
void write_frame(gmx::HostVector<gmx::RVec> const& x, int nsteps);

void write_frame_detailed(PaddedRVecVector const& x, bool print_vector, int nsteps);
void write_frame_detailed(gmx::HostVector<gmx::RVec> const& x, bool print_vector, int nsteps);

void write_frame_summed(PaddedRVecVector const& x, bool print_vector, int nsteps);
void write_frame_summed(gmx::HostVector<gmx::RVec> const& x, bool print_vector, int nsteps);

void write_frame_scalar(int nsteps);

void sum_total_forces(PaddedRVecVector const& x);
void sum_total_forces(gmx::HostVector<gmx::RVec> const& x);

void write_total_forces(PaddedRVecVector const& x);
void write_total_forces(gmx::HostVector<gmx::RVec> const& x);

/**
* Writes a header as in original PF implementation;
Expand All @@ -102,7 +103,7 @@ class FDABase : Base

void write_frame_scalar_compat(int nsteps);

void write_frame_summed_compat(PaddedRVecVector const& x, int nsteps);
void write_frame_summed_compat(gmx::HostVector<gmx::RVec> const& x, int nsteps);

/// The stress is the negative atom_vir value.
void write_virial_sum();
Expand Down
2 changes: 1 addition & 1 deletion src/gromacs/fda/Utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ real vector2signedscalar(const rvec v, const rvec xi, const rvec xj, Vector2Scal
return GMX_FLOAT_MAX;
}

real vector2unsignedscalar(const rvec v, int i, int j, PaddedRVecVector const& x)
real vector2unsignedscalar(const rvec v, int i, int j, gmx::HostVector<gmx::RVec> const& x)
{
rvec r;
rvec_sub(x[j], x[i], r);
Expand Down
4 changes: 2 additions & 2 deletions src/gromacs/fda/Utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef SRC_GROMACS_FDA_UTILITIES_H_
#define SRC_GROMACS_FDA_UTILITIES_H_

#include "gromacs/math/paddedvector.h"
#include "gromacs/gpu_utils/hostallocator.h"
#include "gromacs/math/vectypes.h"
#include "gromacs/utility/real.h"
#include "Vector2Scalar.h"
Expand All @@ -23,7 +23,7 @@ namespace fda {
*/
real vector2signedscalar(const rvec v, const rvec xi, const rvec xj, Vector2Scalar v2s);

real vector2unsignedscalar(const rvec v, int i, int j, PaddedRVecVector const& x);
real vector2unsignedscalar(const rvec v, int i, int j, gmx::HostVector<gmx::RVec> const& x);

} // namespace fda

Expand Down

0 comments on commit c156ba4

Please sign in to comment.