alexxy/gromacs.git
3 years agoDisable GPU update in the presence of frozen atoms
Andrey Alekseenko [Wed, 10 Mar 2021 05:55:30 +0000 (05:55 +0000)]
Disable GPU update in the presence of frozen atoms

There is a known bug (Issue #3920) affecting GPU update when frozen
atoms are present. While the bug is being resolved, we mark such
configuration as not allowed.

Refs #3920

3 years agoWrap more device pointers in DeviceBuffer
Andrey Alekseenko [Wed, 10 Mar 2021 05:28:27 +0000 (05:28 +0000)]
Wrap more device pointers in DeviceBuffer

Store and pass around more device pointers as DeviceBuffer<T>
instead of as a raw or even void pointer.

Related changes:

- PmeGpu->kernelParams->atoms.d_forces is now RVec, not float. Forces in
  most other places are RVec, so it seems more logical.
- GpuForceReduction::Impl::baseForce_ now stores pointer to the
  beginning of the array, without shift.

3 years agoUnify gpu_copy_xq_to_gpu(...) function
Artem Zhmurov [Tue, 9 Mar 2021 16:17:15 +0000 (19:17 +0300)]
Unify gpu_copy_xq_to_gpu(...) function

Refs. #2608

3 years agoMove radian-angle conversions to math/utility
ejjordan [Tue, 9 Mar 2021 15:16:05 +0000 (16:16 +0100)]
Move radian-angle conversions to math/utility

The constant M_PI is always defined there, and conversion is more
properly a utility than a unit.

3 years agoUse constexpr for physical constants and move them into gmx namespace
Joe Jordan [Tue, 9 Mar 2021 14:33:55 +0000 (14:33 +0000)]
Use constexpr for physical constants and move them into gmx namespace

The physical constants that are part of the public API are converted from
defines to constexprs and are moved into the gmx namespace. This means
that many files are touched with tirvial changes. The benefit is that
now the risk of symbol collision is reduced in cases where a library
might depend on these constants.

Additionally, in the same vein of library cleanup, the math/utility
header is removed from units header and included only in the sources
that actually need it.

3 years agoFix missing stdint.h
Paul Bauer [Tue, 9 Mar 2021 13:37:55 +0000 (13:37 +0000)]
Fix missing stdint.h

MSVC complained about missing definitions for int64_t because stdint.h was
not included.

3 years agoRevert "Use std::aligned_alloc"
Mark Abraham [Mon, 8 Mar 2021 09:24:30 +0000 (10:24 +0100)]
Revert "Use std::aligned_alloc"

This C++17 library capability is not yet available on Windows or Mac.

This reverts most of commit 768894fb93bb03a6972b10a8c930b1d1f64221c3.
Incidental aspects of that commit have not been reverted,
specifically, where unused header inclusions and unused functions were
removed.

Fixes #3968

3 years agoUse map to speed up PreprocessingAtomTypes::atomTypeFromName
Andrey Alekseenko [Mon, 8 Mar 2021 16:38:32 +0000 (16:38 +0000)]
Use map to speed up PreprocessingAtomTypes::atomTypeFromName

Previously, we were doing O(numExistingTypes) string comparisons in
PreprocessingAtomTypes::atomTypeFromName.

This significantly slowed down print_bonded function from toputil.cpp,
and, consequently, the pdb2top.

Here, we add an unordered map to store the mapping from type name to
type number, making the whole search O(log(numExistingTypes)), and
avoiding constantly constructing new std::string's from char*'s.

On my machine, this change reduced run time of Pdb2gmx3Test test from ~8
seconds to ~2 seconds.

Closes #3974

3 years agoRemove includes from math/utilities that are not needed there
ejjordan [Mon, 8 Mar 2021 08:15:05 +0000 (09:15 +0100)]
Remove includes from math/utilities that are not needed there

Neither of the include statements in math/utilities were actually needed there.

3 years agoFix "wait before marking" synchronization bug
Andrey Alekseenko [Fri, 5 Mar 2021 15:37:51 +0000 (18:37 +0300)]
Fix "wait before marking" synchronization bug

We did not initiate a D2H copy of coordinates when doing a neighbor
search but were anyway waiting on the associated event.

Unlikely that it had any negative consequences, but that's still a logic
bug.

3 years agoFix clang-tidy complaint failing our CI lint test
Andrey Alekseenko [Sat, 6 Mar 2021 14:01:57 +0000 (17:01 +0300)]
Fix clang-tidy complaint failing our CI lint test

The complaint was about non-const reference, but I also changed an
uninitialized variable nearby.

3 years agoFix typo introduced during nbfp_comb refactoring
Andrey Alekseenko [Fri, 5 Mar 2021 17:45:18 +0000 (20:45 +0300)]
Fix typo introduced during nbfp_comb refactoring

d440c46ef06c3a4c1695e3ec37e7e108ab7a2817 introduced a bug in OpenCL
NBXNM kernel.

Refs 3973

3 years agoClarify the SYCL subgroup size on different targets
Szilárd Páll [Fri, 5 Mar 2021 16:18:45 +0000 (16:18 +0000)]
Clarify the SYCL subgroup size on different targets

Also added some doxygen.

Refs #3934

3 years agoRemove physical constant enums
Paul Bauer [Fri, 5 Mar 2021 15:01:47 +0000 (15:01 +0000)]
Remove physical constant enums

Those have not been used anywhere.

Removed unused conversion functions.

Noted change in release notes API section.

3 years agoFix clang-format and naming of static variable
Mark Abraham [Fri, 5 Mar 2021 11:46:51 +0000 (11:46 +0000)]
Fix clang-format and naming of static variable

3 years agoIntroduce StringToEnumValue
Mark Abraham [Fri, 5 Mar 2021 08:02:59 +0000 (08:02 +0000)]
Introduce StringToEnumValue

This helper functor seems useful in a few places. Adds tests and
improves documentation.

Fixes #3963

3 years agoModernize AWH enumerations
Paul Bauer [Thu, 4 Mar 2021 08:39:30 +0000 (09:39 +0100)]
Modernize AWH enumerations

Changed enums to enum classes.
Use EnumerationArray for strings.

3 years ago Simplify LJ parameter lookup
Szilárd Páll [Thu, 4 Mar 2021 08:08:51 +0000 (08:08 +0000)]
 Simplify LJ parameter lookup

  - Unify the CUDA per-pair scaled C6/C12 LJ parameter
    loading codepaths so both texture and LDG paths do
    8-byte float2 loads.
  - Unify the CUDA per-atom LJ parameter loading codepaths
    so both texture and LDG paths do 8-byte float2 loads.
  - Simplify the LJ self interaction energy term calculation
    by only using the non-texture loads path to simplify code.
    As this is outside the main loop, its impact is negligible.
  - Use float2 loads for the above in OpenCL as well.

3 years agoCheck version names to be correct for release
Paul Bauer [Wed, 3 Mar 2021 18:52:43 +0000 (18:52 +0000)]
Check version names to be correct for release

Adds a check during release verification that the version names coming
from CMake and the actual name in the binary match.

Prevents issues with calculation of verified checksum.

Refs #3862

3 years agoCreate a documentation section for GitLab Label guidelines.
M. Eric Irrgang [Wed, 3 Mar 2021 14:05:32 +0000 (14:05 +0000)]
Create a documentation section for GitLab Label guidelines.

Also rename `gitlab.rst` to `gitlab-ci.rst` since we are starting
to document non-CI GitLab-related information in various places,
making `gitlab.rst` a misleading name.

Fixes #3949

3 years agoRemove PDO reading from gmx wham
Mark Abraham [Wed, 3 Mar 2021 08:56:19 +0000 (08:56 +0000)]
Remove PDO reading from gmx wham

These files were written by gmx 3.x, so likely nobody has any left
that they care about. Subsequent versons of GROMACS can still read
them if anybody does still have them. Meanwhile, we can simplify gmx
wham by removing this support, which was deprecated in GROMACS 2021.

3 years agoModernize atom enums
Paul Bauer [Tue, 2 Mar 2021 15:34:21 +0000 (15:34 +0000)]
Modernize atom enums

Use enum classes and enumeration array for particle and PDB record
types.

3 years agoFix nightly clang-tidy build
Paul Bauer [Tue, 2 Mar 2021 13:01:28 +0000 (14:01 +0100)]
Fix nightly clang-tidy build

Function signatures had not been correctly updated.

3 years agoUse optional instead of magic numbers in preprocessing
Paul Bauer [Tue, 2 Mar 2021 13:13:38 +0000 (13:13 +0000)]
Use optional instead of magic numbers in preprocessing

Replaced the NOTUSED magic numbers in the atom type preprocessing
functions with optionals to indicate that an entry was found or not.

Needed for modernizing the particle type and pdb record type enums
further along.

3 years agoUse std::aligned_alloc
Mark Abraham [Tue, 2 Mar 2021 08:18:02 +0000 (08:18 +0000)]
Use std::aligned_alloc

There is no longer any need to write our own code to allocate aligned
memory, as the C++ standard library provides a function to do that.

Relaxed some comments on our allocators as it is now technically
possible to free such memory with std::free.

Removed related configuration infrastructure that is no longer
required.

Also removed the unused gmx_pause, which shared some of that
infrastructure, and so was able to reduce the include requirements of
gmxomp.h header file.

3 years agoSet up build with hipSYCL
Andrey Alekseenko [Tue, 2 Mar 2021 07:30:21 +0000 (07:30 +0000)]
Set up build with hipSYCL

The kernel code is currently non-functional on NVIDIA/AMD hardware, but
the build itself is useful to ensure code portability.

- Disabled LeapFrog for hipSYCL. With `float3` being used in the host
  code, it is easiest to just disable the integrator until #3312 is
  resolved. This will have to be resolved in order to run full MD loop
  on GPU with hipSYCL. See #3941.

- Some warnings from the compiler and include headers silenced.

- Workarounds for features not supported by hipSYCL are introduced.
- - Shuffles. Should work, but not tested. Hopefully, they will be
    introduced in the mainline hipSYCL soon.
- - Barrier synchronization. Intel-specific extension to SYCL which can
    be imitated fairly well with native OpenCL/CUDA calls, but is
    stubbed very stupidly now. Proper solution will be done after #2527
    and #3924 are resolved.

- CI jobs are added. The set of target device architectures is chosen
  semi-arbitrarily, since the code is not being run yet anyway. Main
  concern was to have both HIP and CUDA there.

Refs #3923.

3 years agoUse const ref for mtop and inputrec in EnergyOutput initialization
Joe Jordan [Mon, 1 Mar 2021 08:14:16 +0000 (08:14 +0000)]
Use const ref for mtop and inputrec in EnergyOutput initialization

Some renaming for ir to inputrec is also done.

3 years agoUse more const ref in domdec API
Joe Jordan [Sun, 28 Feb 2021 14:10:06 +0000 (14:10 +0000)]
Use more const ref in domdec API

Several places that were using const pointers are changed to use
const refs. A few gmx_bool are replaced with bool as well.

3 years agoAdd coverage build to post merge
Paul Bauer [Fri, 26 Feb 2021 14:36:45 +0000 (14:36 +0000)]
Add coverage build to post merge

Every merged commit will be checked for changes to code coverage with
this addition.

Small change to flags added when building for coverage.

Build can be extended for other metrics later as well.

3 years agoOnly use const ref for mtop and inputrec in domdec
Joe Jordan [Fri, 26 Feb 2021 14:02:54 +0000 (14:02 +0000)]
Only use const ref for mtop and inputrec in domdec

All const pointers of mtop and inputrec in domdec module are
converted to const refs. Additionally, since inputrec lines need
to change anyway, renaming from ir to inputrec is performed.

3 years agoAdd device-to-device copy function wrapper with tests in CUDA
Artem Zhmurov [Wed, 24 Feb 2021 21:44:28 +0000 (00:44 +0300)]
Add device-to-device copy function wrapper with tests in CUDA

The D2D copy is currently only used in CUDA, so only stubs are added for OpenCL and SYCL.

Closes #3321

Refs #3318

3 years agoDeprecate gmx::Any
Mark Abraham [Thu, 25 Feb 2021 10:49:13 +0000 (11:49 +0100)]
Deprecate gmx::Any

Refs #3951

3 years agoIntroduce GTest regression tests for replica exchange
Pascal Merz [Fri, 26 Feb 2021 12:31:41 +0000 (12:31 +0000)]
Introduce GTest regression tests for replica exchange

This introduces regression tests within the GTest framework for
replica exchange simulations. These tests are restricted to 4
MPI ranks, used as either 2 replicas with 2 ranks each (using
the DD code path), or 4 replicas with 1 rank each (using code
paths used by multiple replicas). As the reference data would
be different for each combination of number of ranks / number
of simulations, this is restricted to a few setups to keep the
reference data manageable.

The tests are run with integrator `md` using v-rescale and
Nose-Hoover thermostats and c-rescale and parrinello-rahman
barostats, covering the thermodynamically correct temperature
and pressure control algorithms. The tests are also run with
integrator `md-vv`, Nose-Hoover thermostat and no barostat
to cover the Trotter decomposition code path (MTTK barostat
would require a different system because it doesn't work
with constraints, and it's not obvious that it would actually
increase code coverage significantly).

Refs #3918

3 years agoIncrease multsim test flexibility, test multisim + DD
Pascal Merz [Thu, 25 Feb 2021 20:08:52 +0000 (20:08 +0000)]
Increase multsim test flexibility, test multisim + DD

This increases the flexibility of the multisim testing infrastructure
by allowing to parametrize it for number of ranks per simulation,
integrator algorithm, and temperature and pressure coupling.

The multisim tests are also extracted into a separate test binary,
allowing to use a different MPI setup than the remaining MPI tests.

Finally, the flexibility is used to introduce multisim tests which
use domain decomposition in the respective single simulations.

Refs #3918

3 years agoFix testing of positions against reference data
Pascal Merz [Tue, 23 Feb 2021 02:15:43 +0000 (19:15 -0700)]
Fix testing of positions against reference data

When applying PBC to positions before comparing them to reference
data, a returned std::vector was assigned to an ArrayRef. This lead
to undefined values being compared. Position comparison against reference
data is currently unused, so this did not lead to any failing tests.

3 years agoAdd tests on asynchronous host-to-device copy and back
Artem Zhmurov [Wed, 24 Feb 2021 19:24:01 +0000 (19:24 +0000)]
Add tests on asynchronous host-to-device copy and back

The copy routines take different paths depending on transfer kind,
hence both sync and async copy should be tested. This adds tests
for async calls.

3 years agoRework state checkpoint enum handling
Paul Bauer [Wed, 24 Feb 2021 17:05:57 +0000 (17:05 +0000)]
Rework state checkpoint enum handling

The state enumerations have been changed to enum classes and enumeration
arrays. This was required by clang-tidy to remove the global available char
arrays.

Added templated function to convert enum to underlying int.

Was able to simplify quite a lot of the checkpoint handling that had to
work around the pure ints used before the enumerations to get the
correct names for the entries.

3 years agoUse GpuTimers in CUDA and OpenCL versions of NBNXM directly
Artem Zhmurov [Wed, 24 Feb 2021 13:42:23 +0000 (16:42 +0300)]
Use GpuTimers in CUDA and OpenCL versions of NBNXM directly

The GpuTimers are used through proxy objects in OpenCL and CUDA
versions of NBNXM, which complicates the unification of the code.
This change eliminates the proxy object by using the underlying
object directly.

Refs #2608

3 years agoFix multi-sim checkpoint writing bug
Pascal Merz [Fri, 19 Feb 2021 06:10:54 +0000 (23:10 -0700)]
Fix multi-sim checkpoint writing bug

In rare cases (when a checkpoint file existed on at least one multisim
rank but not on all), checkpoint writing with multiple simulation could
cause the ranks to get out of sync. This fixes the problem by moving
the barrier outside of the relevant if clause, making sure that it
is hit by all ranks.

Fixes #3919

3 years agoUse verbose names in init_forcerec
Joe Jordan [Tue, 23 Feb 2021 13:10:31 +0000 (13:10 +0000)]
Use verbose names in init_forcerec

3 years agoFix doxygen in domdec
Artem Zhmurov [Tue, 23 Feb 2021 11:09:57 +0000 (14:09 +0300)]
Fix doxygen in domdec

e2adf21a8c2ed0f6a8e1e590e3a12a099a6ebe24 was merged before all
Doxygen warnings got fixed. This fixes them.

3 years agoUse getAtomRanges(...) function in NBNXM more
Artem Zhmurov [Mon, 22 Feb 2021 18:27:08 +0000 (21:27 +0300)]
Use getAtomRanges(...) function in NBNXM more

Make getAtomRanges(...) function to return gmx::Range and
use it more.

Refs #2608

3 years agoHide newly exposed domdec internals
Mark Abraham [Mon, 22 Feb 2021 12:54:38 +0000 (13:54 +0100)]
Hide newly exposed domdec internals

By declaring the top-level destructor, we avoid needing to expose
details so the compiler has to generate the destructor everywhere.

Fixes #3926

3 years agoHold unique_ptr to gmx_ewald_tab_t in forcerec
Joe Jordan [Mon, 22 Feb 2021 19:00:38 +0000 (19:00 +0000)]
Hold unique_ptr to gmx_ewald_tab_t in forcerec

Proper constructor and destructor are added. The field eir, which
was anyway recomputed with every call to do_ewald, is removed from
the struct and made local to do_ewald. Since the type cvec is only
used by eir, it is moved to reside in ewald.cpp.

3 years agoHold unique_ptr for interaction_const in forcerec
Joe Jordan [Mon, 22 Feb 2021 17:35:53 +0000 (17:35 +0000)]
Hold unique_ptr for interaction_const in forcerec

Also renamed ic->interactionConst in init_interactionConst.

3 years agoFix code so clang-tidy no longer complains
Mark Abraham [Mon, 22 Feb 2021 12:29:43 +0000 (13:29 +0100)]
Fix code so clang-tidy no longer complains

3 years agoremove InteractionLocality from PairListSet constructor
ejjordan [Sun, 21 Feb 2021 18:47:09 +0000 (19:47 +0100)]
remove InteractionLocality from PairListSet constructor

The InteractionLocality is removed as a member from PairListSet
and is no longer passed to the constructor, but instead to
PairListSets::construct. This will make it easier to remove the
explicit dependence on domdec_zones in nbnxm module.

3 years agoUnify NB atoms and staging data structures in OpenCL, CUDA and SYCL
Artem Zhmurov [Mon, 22 Feb 2021 14:15:16 +0000 (14:15 +0000)]
Unify NB atoms and staging data structures in OpenCL, CUDA and SYCL

Refs #2608

3 years agoRemove raw pointer to gmx_reverse_top
Paul Bauer [Mon, 22 Feb 2021 12:00:03 +0000 (12:00 +0000)]
Remove raw pointer to gmx_reverse_top

Changed the underlying type to an unique_ptr and changed the type to an
impl struct to make this possible. This removes the memory leak found
there.

3 years agoReduce use of gmx_domdec_t in domdec_topology.cpp
Berk Hess [Mon, 22 Feb 2021 10:15:48 +0000 (11:15 +0100)]
Reduce use of gmx_domdec_t in domdec_topology.cpp

3 years agoRefactor md_enums
Paul Bauer [Mon, 22 Feb 2021 10:24:36 +0000 (10:24 +0000)]
Refactor md_enums

The old enum handling caused clang-tidy to complain about the globally
defined symbols for the enum strings, and also violated type safety by
using the enums both as enumerations and integers.

Changed all exposed enum strings and their corresponding char arrays
to classes and enumeration arrays.

Used enumeration array in a few places where it made sense to me.

Was not able to get rid of some instances where the enum to integer
conversion was abused.

Moved enum reading template to header to have it available for reading
all enums.

3 years agoAdd FloatN aliases to OpenCL and use them in NBNXM
Artem Zhmurov [Mon, 22 Feb 2021 09:43:43 +0000 (09:43 +0000)]
Add FloatN aliases to OpenCL and use them in NBNXM

These aliases are nessesary to unify OpenCL, CUDA and SYCL
code.

Refs #3312, #2608, #3311

3 years agoAdd FloatN aliases to CUDA and use them in NBNXM
Artem Zhmurov [Sat, 20 Feb 2021 08:12:02 +0000 (11:12 +0300)]
Add FloatN aliases to CUDA and use them in NBNXM

These aliases are nessesary to unify OpenCL, CUDA and SYCL
code.

Refs #3312, #2608, #3311

3 years agoRename our SYCL aliases floatN to FloatN
Andrey Alekseenko [Thu, 18 Feb 2021 10:09:14 +0000 (13:09 +0300)]
Rename our SYCL aliases floatN to FloatN

Main reasons:

- Clearly separate our types (or aliases) from native types. This will
  likely make later changes (e.g., in scope of #3312) easier.
- Enable hipSYCL build by avoiding clashes of multiple floatN in the
  global namespace.

Refs #3312, #3923

3 years agoSet temperature scaling groups upon construction of integrator
Artem Zhmurov [Sat, 20 Feb 2021 22:48:03 +0000 (22:48 +0000)]
Set temperature scaling groups upon construction of integrator

The temperature scaling parameters do not change, so can be
set upon construction of the integrator object.

Closes #3794

3 years agoRemove unsed structs from nblist and use vector in t_nblist
Joe Jordan [Sat, 20 Feb 2021 08:52:44 +0000 (08:52 +0000)]
Remove unsed structs from nblist and use vector in t_nblist

Several unused structs are removed from nblist.h. Some unused members of
t_nblist are removed, and pointers are changed to vectors.

3 years agoRevome unused code from nsgrid
Joe Jordan [Fri, 19 Feb 2021 20:33:04 +0000 (20:33 +0000)]
Revome unused code from nsgrid

In addition to removing several functions that are not used,
some unused parameters from the t_grid struct are removed.

3 years agoClean up DD reverse topology options
Berk Hess [Fri, 19 Feb 2021 14:44:49 +0000 (14:44 +0000)]
Clean up DD reverse topology options

Added a ReverseTopOptions struct to handle often used options for
functions. Added a constructor for gmx_reverse_top_t.
Replaced two bools by two enum classes for clarity and safety.

3 years agoUse const refs in init_nb_verlet
Joe Jordan [Fri, 19 Feb 2021 12:00:10 +0000 (12:00 +0000)]
Use const refs in init_nb_verlet

In addition to using more const refs instead of pointers
in some nbnmx setup code, names are made slightly more
verbose.

3 years agoReplace sqrt with std::sqrt in mdatoms.cpp
Andrey Alekseenko [Fri, 19 Feb 2021 09:20:35 +0000 (10:20 +0100)]
Replace sqrt with std::sqrt in mdatoms.cpp

We are including <cmath>, so we should use versions from the std namespace.

3 years agoPass restraint data structures to bonded functions
ejjordan [Thu, 18 Feb 2021 11:59:01 +0000 (12:59 +0100)]
Pass restraint data structures to bonded functions

This adds explicitly the t_disresdata and t_oriresdata structures to all
bonded force calculation calls, instead of passing them as members of
the t_fcdata structure. This is an unfortunate but necessary step in
order to be able to separate bondedtable_t from the two restraint
data structures. The splitting of t_fcdata into separate table data and
restraint data structures is needed to simplify the initialization of
the forcerec.

3 years agoUnify and clarify a couple of macro definitions in NBNXM
Artem Zhmurov [Thu, 18 Feb 2021 16:31:47 +0000 (19:31 +0300)]
Unify and clarify a couple of macro definitions in NBNXM

1. The GMX_NBNXN_PRUNE_KERNEL_J4_CONCURRENCY definition was
essentially duplicated in CUDA and OpenCL. This unify them.

2. The 1/sqrt(PI) macro was defined several times in OpenCL.

3 years agoRename and add doxygen to reaction field params in interaction_const
Joe Jordan [Fri, 19 Feb 2021 07:01:02 +0000 (07:01 +0000)]
Rename and add doxygen to reaction field params in interaction_const

This will make further changes to interaction_const RF params easier
to review.

3 years agoUse unique_ptr for forcerec in runner
Joe Jordan [Thu, 18 Feb 2021 20:48:33 +0000 (20:48 +0000)]
Use unique_ptr for forcerec in runner

Brings forcerec usage in line with most other large data structures there.

3 years agoMake the use of GpuEventSynchronizer in SYCL conformant with CUDA/OpenCL
Andrey Alekseenko [Thu, 18 Feb 2021 13:01:43 +0000 (16:01 +0300)]
Make the use of GpuEventSynchronizer in SYCL conformant with CUDA/OpenCL

MR !1035 refactored the use of GpuEventSynchronizer in CUDA and OpenCL
to make merging the code paths easier. Here, we update SYCL to the same
standard.

Note, that it introduces additional synchronization between local and
non-local queues. It is present in CUDA and OpenCL, but was implicit in
SYCL. To simplify code, it is added here. If it turns out to be
detrimental to performance, it can be (conditionally) NOPed.

Refs #2608, #3895.

3 years agoFix includes and forward declarations of domdec in nbnxm headers
ejjordan [Thu, 18 Feb 2021 17:18:12 +0000 (18:18 +0100)]
Fix includes and forward declarations of domdec in nbnxm headers

3 years agoUse array in gmx_domdec_zones_t
ejjordan [Thu, 18 Feb 2021 16:36:56 +0000 (17:36 +0100)]
Use array in gmx_domdec_zones_t

3 years agoFix doxygen in SYCL code
Paul Bauer [Thu, 18 Feb 2021 16:06:08 +0000 (17:06 +0100)]
Fix doxygen in SYCL code

Was left over when merging changes from development branch.

3 years agoImplement velocity terms for virtual sites
Pascal Merz [Thu, 11 Feb 2021 00:27:01 +0000 (17:27 -0700)]
Implement velocity terms for virtual sites

This change
* introduces velocity terms for virtual site reporting replacing the
  displacement hack used prior,
* removes work-arounds used to keep virtual sites frozen during real
  atom propagation,
* allows users of the VirtualSiteHandler object to chose whether to
  calculate positions only (used for non-output steps), positions
  and velocities (used for output-steps except in md-vv), or
  velocities only (used for output-steps in md-vv), which mitigates
  the fact that calculating the velocities requires a few additional
  operations,
* adds tests of the virtual velocity,
* updates the documentation accordingly.

Fixes #3866

3 years agoSYCL NBNXM offload support
Andrey Alekseenko [Thu, 18 Feb 2021 11:51:28 +0000 (11:51 +0000)]
SYCL NBNXM offload support

Associated changes:

- Added function stubs to PME: necessary for compilation.
- Stricter SYCL hardware compatibility checks: limits on subgroup size
  and the availability of local memory.
- The kernel implementation and overall logic closely follow the OpenCL
  implementation. Divergences are documented locally.

Limitations:

- No fine-grained timings yet.
- Code-duplication with CUDA and OpenCL: see #2608.
- Minor differences in local/nonlocal synchronization: see #3895,
  related to #2608.
- Only the OpenCL backend was extensively tested. LevelZero works fine
  without MPI but stalls due to a known bug. The fix for DPCPP runtime
  is available, but not yet part of any OneAPI release:
  https://github.com/intel/llvm/pull/3045.
- The complex/position-restraints regression test fails: see #3846.
- No performance tuning: see #3847.

Performance on rnase-cubic system is similar to OpenCL implementation.

3 years agoClean up box vector constants in do_force
Szilárd Páll [Wed, 17 Feb 2021 18:17:13 +0000 (19:17 +0100)]
Clean up box vector constants in do_force

3 years agoFix clang-8-cuda-10.0 container
Andrey Alekseenko [Thu, 18 Feb 2021 08:41:41 +0000 (11:41 +0300)]
Fix clang-8-cuda-10.0 container

MR !1135 (60deae1fd05334f0ecf2f295cc7f49d59f734bb9) introduced a hack to
work around Clang support for 11.x CUDA versions. This inadvertantly
broke Clang 8 + CUDA 10.0 build.

Apparently, Clang requires
$CUDA_HOME/version.txt file to have version in major.minor.patch format,
and fails to find libraries if it is specified as major.minor only.

3 years agoUpdate CMake requirement to 3.16.3
Paul Bauer [Thu, 18 Feb 2021 07:10:07 +0000 (07:10 +0000)]
Update CMake requirement to 3.16.3

We will require a more modern CMake beginning with the 2022 version, and
have chosen 3.16.3 as the minimum version, as this is what the Ubuntu
20.04 LTS ships by default.

Refs #3708

3 years agoIntroduce test checking freeze groups
Pascal Merz [Wed, 17 Feb 2021 12:27:55 +0000 (12:27 +0000)]
Introduce test checking freeze groups

This currently fails for the partially frozen velocities
of md-vv simulation. Fix is in the follow-up commit.

Refs #3849

3 years agoAdd -DGMX_SYCL_HIPSYCL cmake option
Andrey Alekseenko [Wed, 17 Feb 2021 10:44:43 +0000 (10:44 +0000)]
Add -DGMX_SYCL_HIPSYCL cmake option

When supplied, use hipSYCL's CMake module to set up compile options.
Otherwise, use our own code to configure flags for Intel's LLVM-based
SYCL compiler.

3 years agoUse GpuEventSynchronizer in NBNXM
Artem Zhmurov [Wed, 17 Feb 2021 10:24:31 +0000 (10:24 +0000)]
Use GpuEventSynchronizer in NBNXM

This unifies the event-based synchronization in CUDA and OpenCL
by using a wrapper with platform-agnostic interfaces for events.

Refs #2608

3 years agoRemove dead function declarations from forcerec
ejjordan [Wed, 17 Feb 2021 09:13:10 +0000 (10:13 +0100)]
Remove dead function declarations from forcerec

Not only are the removed functions not used, they are not even defined.

3 years agoMore const in edsam functions
ejjordan [Wed, 17 Feb 2021 07:52:18 +0000 (08:52 +0100)]
More const in edsam functions

In addition to increasing const correctness in edsam functions,
some additional minor cleanup is also done.

3 years agoUse const ref to mtop in init_forcerec
ejjordan [Tue, 16 Feb 2021 17:01:11 +0000 (18:01 +0100)]
Use const ref to mtop in init_forcerec

Also lower level function, which are currently static, are
refactored to take a const ref to mtop. This will make exposing
those lower level functions safer.

3 years agoSupport checking event status in GpuEventSynchronizer
Szilárd Páll [Thu, 11 Feb 2021 10:57:05 +0000 (11:57 +0100)]
Support checking event status in GpuEventSynchronizer

This commit adds an isReady() method that allows checking whether
the event has been triggered (or in SYCL associated barrier task has
completed).
The primary aim is porting the nbnxm module to the unified GPU layer.

Implements part of #2527

3 years agoFix clang-tidy-11 errors in NBNXM module, part 5
Andrey Alekseenko [Tue, 16 Feb 2021 15:13:56 +0000 (15:13 +0000)]
Fix clang-tidy-11 errors in NBNXM module, part 5

Refs #3897

3 years agoAdd support for Clang-CUDA 11.x and a post-merge CI build
Andrey Alekseenko [Tue, 16 Feb 2021 14:16:02 +0000 (14:16 +0000)]
Add support for Clang-CUDA 11.x and a post-merge CI build

Tested mostly with Clang-11 and CUDA-11.2

While Clang does not officially support CUDA after 10.1, it appears to
work fine with newer versions.

Caveat: Clang fails to properly detect CUDA versions past 10.2

This can be worked around by creating `/usr/local/cuda/version.txt`
file with the single line `CUDA Version X.Y.Z`.

Despite the workaround above, Clang:
- does not recognize sm_86.
- recognizes sm_80, but believes that the installed CUDA version
  is too old to support it.

3 years agoUse const ref to inputrec in do_force
Joe Jordan [Tue, 16 Feb 2021 13:43:14 +0000 (13:43 +0000)]
Use const ref to inputrec in do_force

Inputrec can be const at the level of do_force and below. This
will make subsequent refactorings in, e.g. setup code called
within do_force, easier.

3 years agoAdd container with LLVM 11, CUDA 11.2.1, hipSYCL
Andrey Alekseenko [Tue, 16 Feb 2021 13:01:05 +0000 (13:01 +0000)]
Add container with LLVM 11, CUDA 11.2.1, hipSYCL

- Introduce the option to add hipSYCL to a CI container.
- - Version is specified by commit SHA, because the latest stable
    release (0.9.0) is too old.
- - hipSYCL requires llvm-dev packages for compilation. This bloats the
    size of the image, but is much easier to manage than installing CUDA
    and ROCm into a temporary container.
- Add workarounds for known Clang limitations when dealing with the latest
  versions of CUDA (11.0-11.2.1) and ROCm (3.9-4.0).
- - Is also allows using cuda-clang build with CUDA 11.
- Add a new image to the admin/containers/buildall.sh:
- - Ubuntu 20.04, Clang 11, CUDA 11.2.1, hipSYCL develop.

3 years agoIntroduce virtual sites test
Pascal Merz [Tue, 16 Feb 2021 08:47:10 +0000 (08:47 +0000)]
Introduce virtual sites test

The virtual site tests contain two parts:

1. A reference implementation. The virtual sites code in mdrun is
   difficult to unit-test, since the function calls require data
   structures which are not available in our current testing
   framework. To circumvent that problem, a reference implementation
   is introduced in the tests. The reference implementation can be
   unit-tested, and can be compared to end-to-end mdrun output,
   which leads to a situation comparable to having unit and end-to-end
   tests for the virtual sites implementation. Additionally, the
   reference implementation is simplified and kept close to the
   analytical formulas, which makes verification by eye easier. The
   current unit tests compare the position calculation to the velocity
   calculation, ensuring that the latter is indeed the derivative of
   the first. Additional unit tests could be addded.

2. End-to-end tests. This ensures that all virtual site types can be
   run, and that the trajectory of the virtual site matches the
   trajectory of the real sites, using the reference implementation.
   These tests check that the mdrun implementation agrees with the
   reference implementation, and that real and virtual site reporting
   does not get out of sync.

Note that the reference implementation also includes virtual velocities,
which are, however, not used to test simulation output yet. This will
be introduced once the new velocity definitions are implemented in
mdrun.

Refs #3866

3 years agoRework SYCL CMake machinery to be compatible with hipSYCL
Andrey Alekseenko [Mon, 15 Feb 2021 19:31:21 +0000 (22:31 +0300)]
Rework SYCL CMake machinery to be compatible with hipSYCL

Unlike DPCPP, hipSYCL (and ComputeCPP) offer its own CMake package.
This package has a nice `add_sycl_to_target` function to indicate which
source files must be compiled with SYCL and which target must be linked
with appropriate libraries.

Such function is rather trivial for DPCPP, so, in the interest of
homogeneity, we add it here.

3 years agoMake the restraint history const during force calculation
Pascal Merz [Sun, 14 Feb 2021 20:19:32 +0000 (13:19 -0700)]
Make the restraint history const during force calculation

The history is updated later, and is read-only within the force
routines. Adds a few const qualifiers to clarify this.

Refs #3430

3 years agoFix clang-tidy-11 for topology module
Paul Bauer [Mon, 15 Feb 2021 09:45:02 +0000 (09:45 +0000)]
Fix clang-tidy-11 for topology module

Part of updates for clang-tidy changes to require variable
initialization.

3 years agoExpose mk_nbfp and make_ljpme_c6grid.
Sebastian Kehl [Mon, 15 Feb 2021 08:42:56 +0000 (09:42 +0100)]
Expose mk_nbfp and make_ljpme_c6grid.

Expose mk_nbfp and make_ljpme_c6grid from 'mdlib/forcerec.cpp'
in 'mdlib/forcerec.h'.

Thereby rename:
mk_nbfp           -> makeNonBondedParameterLists
make_ljpme_c6grid -> makeLJPmeC6GridCorrectionParameters

3 years agoFix release docs build
Paul Bauer [Fri, 12 Feb 2021 09:45:15 +0000 (10:45 +0100)]
Fix release docs build

The change to python handling for the documentation build was not
propagated to the release builds.

3 years agoFix leaked memory created in make_ljpme_c6grid.
Sebastian Kehl [Fri, 12 Feb 2021 19:24:47 +0000 (19:24 +0000)]
Fix leaked memory created in make_ljpme_c6grid.

3 years agoAdd gmx::isPowerOfTwo function
Andrey Alekseenko [Fri, 12 Feb 2021 15:42:10 +0000 (15:42 +0000)]
Add gmx::isPowerOfTwo function

A follow-up from a discussion in !1080.

3 years agoMerge branch release-2021 into master
Mark Abraham [Fri, 12 Feb 2021 14:24:31 +0000 (15:24 +0100)]
Merge branch release-2021 into master

No content, because that was accidentally squashed into commit
a660b04e8d8756ed9c4d.

3 years agoRemove unused function
Paul Bauer [Fri, 12 Feb 2021 09:48:26 +0000 (10:48 +0100)]
Remove unused function

This was leftover from the tree-reduce algorithm removal.

3 years agoImprove CUDA codegen flags
Mark Abraham [Fri, 12 Feb 2021 13:02:37 +0000 (13:02 +0000)]
Improve CUDA codegen flags

- onnly generate PTX for an early and the latest arch (3.5 and 8.0)
- add binary 8.0 and 8.6 targets

3 years agoMove virtual site calculation
Pascal Merz [Fri, 12 Feb 2021 08:02:58 +0000 (08:02 +0000)]
Move virtual site calculation

The previous implementation would lead to slight inaccuracies when
virtual positions were calculated before shifting positions in
pressure coupling algorithms. This change moves the calculation to the
top of the loop, right before DD and force calculation.

This also removes an unnecessary call to the virtual site construction
in rerun. That call was placed after force calculation and trajectory
writing, so had no influence since coordinates for the next step are
read from file. Since virtual sites are constructed when reading
coordinates from file, the results should have been correct anyway, the
call just had no influence.

This also moves the call to the virtual site construction in MiMiC.
Similar to the rerun case, the current call happened after virtual
sites are used. This call has been moved to right after the coordinates
are received. This is likely to have lead to wrong results when using
MiMiC with virtual sites.

Refs #3866

3 years agoUse unique_ptr for tables
Joe Jordan [Thu, 11 Feb 2021 18:21:13 +0000 (18:21 +0000)]
Use unique_ptr for tables

Instead of returning a raw pointer, make_tables now returns a unique_ptr.

3 years agoFix clang-tidy-11 errors in NBNXM module, part 3
Andrey Alekseenko [Thu, 11 Feb 2021 13:49:29 +0000 (13:49 +0000)]
Fix clang-tidy-11 errors in NBNXM module, part 3

Refs #3897

3 years agoDisable cos acceleration for non leap-frog code paths
Pascal Merz [Thu, 11 Feb 2021 06:23:24 +0000 (23:23 -0700)]
Disable cos acceleration for non leap-frog code paths

The cos acceleration is only applied in leap-frog. grompp and mdrun
would, however, happily accept non-zero cos-accel input, and report
viscosity-related quantities without ever applying the acceleration
for all other integrators.

This change adds a check at grompp time (to avoid new tprs with
non-implemented parameter combinations being created), and at
runner time (to catch older tprs). Should probably be backported
to the supported releases.

Refs #3903

3 years agoSafer handling of empty cells in Grid::sortColumnsCpuGeometry
Andrey Alekseenko [Tue, 9 Feb 2021 20:13:01 +0000 (23:13 +0300)]
Safer handling of empty cells in Grid::sortColumnsCpuGeometry

When the number of atoms is low, NBNXM grid can contain empty cells.
Previously, this caused the value of numAtomsCell in
Grid::sortColumnsCpuGeometry to become negative, and we were calling
Grid::fillCell with atomEnd < atomStart.

It did not cause any bugs as far as I observed, but is slightly
dangerous and couterintuitive behavior.

For example, such situation happens in
./bin/mdrunfep-test --gtest_filter=FreeEnergyCalculationsAreEquivalentToReference/FreeEnergyReferenceTest.WithinTolerances/coulandvdwsequential_coul_s