Gromacs  2018.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
pme-gpu-internal.cpp File Reference
#include "gmxpre.h"
#include "pme-gpu-internal.h"
#include "config.h"
#include <list>
#include <string>
#include "gromacs/ewald/ewald-utils.h"
#include "gromacs/gpu_utils/gpu_utils.h"
#include "gromacs/math/invertmatrix.h"
#include "gromacs/math/units.h"
#include "gromacs/mdtypes/commrec.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/logger.h"
#include "gromacs/utility/stringutil.h"
#include "pme-grid.h"
#include "pme-internal.h"
+ Include dependency graph for pme-gpu-internal.cpp:

Description

This file contains internal function implementations for performing the PME calculations on GPU.

Author
Aleksei Iupinov a.yup.nosp@m.inov.nosp@m.@gmai.nosp@m.l.co.nosp@m.m

Functions

static PmeGpuKernelParamsBasepme_gpu_get_kernel_params_base_ptr (const PmeGpu *pmeGpu)
 Wrapper for getting a pointer to the plain C++ part of the GPU kernel parameters structure. More...
 
gmx::ArrayRef< gmx::RVecpme_gpu_get_forces (PmeGpu *pmeGpu)
 Returns the GPU gathering staging forces buffer. More...
 
void pme_gpu_get_energy_virial (const PmeGpu *pmeGpu, real *energy, matrix virial)
 Returns the output virial and energy of the PME solving. More...
 
void pme_gpu_update_input_box (PmeGpu *pmeGpu, const matrix box)
 Updates the unit cell parameters. Does not check if update is necessary - that is done in pme_gpu_prepare_computation(). More...
 
void pme_gpu_reinit_computation (const PmeGpu *pmeGpu)
 The PME GPU reinitialization function that is called both at the end of any PME computation and on any load balancing. More...
 
static void pme_gpu_reinit_grids (PmeGpu *pmeGpu)
 (Re-)initializes all the PME GPU data related to the grid size and cut-off. More...
 
static void pme_gpu_copy_common_data_from (const gmx_pme_t *pme)
 Copies everything useful from the PME CPU to the PME GPU structure. The goal is to minimize interaction with the PME CPU structure in the GPU code. More...
 
static bool pme_gpu_check_restrictions (const gmx_pme_t *pme, std::string *error)
 Finds out if PME with given inputs is possible to run on GPU. More...
 
static void pme_gpu_init (gmx_pme_t *pme, gmx_device_info_t *gpuInfo)
 Initializes the PME GPU data at the beginning of the run. More...
 
void pme_gpu_transform_spline_atom_data (const PmeGpu *pmeGpu, const pme_atomcomm_t *atc, PmeSplineDataType type, int dimIndex, PmeLayoutTransform transform)
 Rearranges the atom spline data between the GPU and host layouts. Only used for test purposes so far, likely to be horribly slow. More...
 
void pme_gpu_get_real_grid_sizes (const PmeGpu *pmeGpu, gmx::IVec *gridSize, gmx::IVec *paddedGridSize)
 Get the normal/padded grid dimensions of the real-space PME grid on GPU. Only used in tests. More...
 
void pme_gpu_reinit (gmx_pme_t *pme, gmx_device_info_t *gpuInfo)
 (Re-)initializes the PME GPU data at the beginning of the run or on DLB. More...
 
void pme_gpu_destroy (PmeGpu *pmeGpu)
 Destroys the PME GPU data at the end of the run. More...
 
void pme_gpu_reinit_atoms (PmeGpu *pmeGpu, const int nAtoms, const real *charges)
 Reallocates the local atoms data (charges, coordinates, etc.). Copies the charges to the GPU. More...
 

Function Documentation

static bool pme_gpu_check_restrictions ( const gmx_pme_t *  pme,
std::string *  error 
)
static

Finds out if PME with given inputs is possible to run on GPU.

Parameters
[in]pmeThe PME structure.
[out]errorThe error message if the input is not supported on GPU.
Returns
True if this PME input is possible to run on GPU, false otherwise.
static void pme_gpu_copy_common_data_from ( const gmx_pme_t *  pme)
static

Copies everything useful from the PME CPU to the PME GPU structure. The goal is to minimize interaction with the PME CPU structure in the GPU code.

Parameters
[in]pmeThe PME structure.
void pme_gpu_destroy ( PmeGpu pmeGpu)

Destroys the PME GPU data at the end of the run.

Parameters
[in]pmeGpuThe PME GPU structure.
void pme_gpu_get_energy_virial ( const PmeGpu pmeGpu,
real energy,
matrix  virial 
)

Returns the output virial and energy of the PME solving.

Parameters
[in]pmeGpuThe PME GPU structure.
[out]energyThe output energy.
[out]virialThe output virial matrix.
gmx::ArrayRef<gmx::RVec> pme_gpu_get_forces ( PmeGpu pmeGpu)

Returns the GPU gathering staging forces buffer.

Parameters
[in]pmeGpuThe PME GPU structure.
Returns
The input/output forces.
static PmeGpuKernelParamsBase* pme_gpu_get_kernel_params_base_ptr ( const PmeGpu pmeGpu)
static

Wrapper for getting a pointer to the plain C++ part of the GPU kernel parameters structure.

Parameters
[in]pmeGpuThe PME GPU structure.
Returns
The pointer to the kernel parameters.
void pme_gpu_get_real_grid_sizes ( const PmeGpu pmeGpu,
gmx::IVec gridSize,
gmx::IVec paddedGridSize 
)

Get the normal/padded grid dimensions of the real-space PME grid on GPU. Only used in tests.

Parameters
[in]pmeGpuThe PME GPU structure.
[out]gridSizePointer to the grid dimensions to fill in.
[out]paddedGridSizePointer to the padded grid dimensions to fill in.
static void pme_gpu_init ( gmx_pme_t *  pme,
gmx_device_info_t gpuInfo 
)
static

Initializes the PME GPU data at the beginning of the run.

Parameters
[in,out]pmeThe PME structure.
[in,out]gpuInfoThe GPU information structure.
void pme_gpu_reinit ( gmx_pme_t *  pme,
gmx_device_info_t gpuInfo 
)

(Re-)initializes the PME GPU data at the beginning of the run or on DLB.

Parameters
[in,out]pmeThe PME structure.
[in,out]gpuInfoThe GPU information structure.
Exceptions
gmx::NotImplementedErrorif this generally valid PME structure is not valid for GPU runs.
void pme_gpu_reinit_atoms ( PmeGpu pmeGpu,
const int  nAtoms,
const real charges 
)

Reallocates the local atoms data (charges, coordinates, etc.). Copies the charges to the GPU.

Parameters
[in]pmeGpuThe PME GPU structure.
[in]nAtomsThe number of particles.
[in]chargesThe pointer to the host-side array of particle charges.

This is a function that should only be called in the beginning of the run and on domain decomposition. Should be called before the pme_gpu_set_io_ranges.

void pme_gpu_reinit_computation ( const PmeGpu pmeGpu)

The PME GPU reinitialization function that is called both at the end of any PME computation and on any load balancing.

Parameters
[in]pmeGpuThe PME GPU structure.
static void pme_gpu_reinit_grids ( PmeGpu pmeGpu)
static

(Re-)initializes all the PME GPU data related to the grid size and cut-off.

Parameters
[in]pmeGpuThe PME GPU structure.
void pme_gpu_transform_spline_atom_data ( const PmeGpu pmeGpu,
const pme_atomcomm_t *  atc,
PmeSplineDataType  type,
int  dimIndex,
PmeLayoutTransform  transform 
)

Rearranges the atom spline data between the GPU and host layouts. Only used for test purposes so far, likely to be horribly slow.

Parameters
[in]pmeGpuThe PME GPU structure.
[out]atcThe PME CPU atom data structure (with a single-threaded layout).
[in]typeThe spline data type (values or derivatives).
[in]dimIndexDimension index.
[in]transformLayout transform type
void pme_gpu_update_input_box ( PmeGpu pmeGpu,
const matrix  box 
)

Updates the unit cell parameters. Does not check if update is necessary - that is done in pme_gpu_prepare_computation().

Parameters
[in]pmeGpuThe PME GPU structure.
[in]boxThe unit cell box.