From: Artem Zhmurov Date: Wed, 10 Mar 2021 09:43:52 +0000 (+0300) Subject: Rework atom locality validity checks X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=09aa3f7327d379e2e4908ce03ebbaeb92e237b1c;p=alexxy%2Fgromacs.git Rework atom locality validity checks The function that checks the validity of atom locality partly duplicates its callers logic. The chacks are done naturally in the callers and the function is used to construct and print an error message. --- diff --git a/src/gromacs/nbnxm/gpu_common_utils.h b/src/gromacs/nbnxm/gpu_common_utils.h index ea4f2d9d63..6694f2b2fb 100644 --- a/src/gromacs/nbnxm/gpu_common_utils.h +++ b/src/gromacs/nbnxm/gpu_common_utils.h @@ -45,7 +45,7 @@ #include "config.h" #include "gromacs/listed_forces/gpubonded.h" -#include "gromacs/utility/fatalerror.h" +#include "gromacs/utility/exceptions.h" #include "gromacs/utility/range.h" #include "gromacs/nbnxm/nbnxm_gpu.h" @@ -73,25 +73,6 @@ static inline bool canSkipNonbondedWork(const NbnxmGpu& nb, InteractionLocality return (iloc == InteractionLocality::NonLocal && nb.plist[iloc]->nsci == 0); } -/*! \brief Check that atom locality values are valid for the GPU module. - * - * In the GPU module atom locality "all" is not supported, the local and - * non-local ranges are treated separately. - * - * \param[in] atomLocality atom locality specifier - */ -static inline void validateGpuAtomLocality(const AtomLocality atomLocality) -{ - std::string str = gmx::formatString( - "Invalid atom locality passed (%d); valid here is only " - "local (%d) or nonlocal (%d)", - static_cast(atomLocality), - static_cast(AtomLocality::Local), - static_cast(AtomLocality::NonLocal)); - - GMX_ASSERT(atomLocality == AtomLocality::Local || atomLocality == AtomLocality::NonLocal, str.c_str()); -} - /*! \brief Convert atom locality to interaction locality. * * In the current implementation the this is straightforward conversion: @@ -102,7 +83,6 @@ static inline void validateGpuAtomLocality(const AtomLocality atomLocality) */ static inline InteractionLocality gpuAtomToInteractionLocality(const AtomLocality atomLocality) { - validateGpuAtomLocality(atomLocality); /* determine interaction locality from atom locality */ if (atomLocality == AtomLocality::Local) @@ -115,7 +95,8 @@ static inline InteractionLocality gpuAtomToInteractionLocality(const AtomLocalit } else { - gmx_incons("Wrong locality"); + GMX_THROW(gmx::InconsistentInputError( + "Only Local and NonLocal atom locities can be converted to interaction locality.")); } } @@ -142,17 +123,21 @@ static inline bool haveGpuShortRangeWork(const NbnxmGpu& nb, const gmx::Interact static inline gmx::Range getGpuAtomRange(const NBAtomData* atomData, const AtomLocality atomLocality) { assert(atomData); - validateGpuAtomLocality(atomLocality); /* calculate the atom data index range based on locality */ if (atomLocality == AtomLocality::Local) { return gmx::Range(0, atomData->numAtomsLocal); } - else + else if (atomLocality == AtomLocality::NonLocal) { return gmx::Range(atomData->numAtomsLocal, atomData->numAtoms); } + else + { + GMX_THROW(gmx::InconsistentInputError( + "Only Local and NonLocal atom locities can be used to get atom ranges in NBNXM.")); + } } } // namespace Nbnxm