Gromacs
2024.4
|
#include "gmxpre.h"
#include <cassert>
#include <cstdlib>
#include <string>
#include "gromacs/gpu_utils/gpu_utils.h"
#include "gromacs/gpu_utils/ocl_compiler.h"
#include "gromacs/mdtypes/interaction_const.h"
#include "gromacs/mdtypes/md_enums.h"
#include "gromacs/nbnxm/gpu_jit_support.h"
#include "gromacs/nbnxm/nbnxm_gpu.h"
#include "gromacs/pbcutil/ishift.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/stringutil.h"
#include "nbnxm_ocl_types.h"
Defines functions that support JIT compilation (e.g. for OpenCL)
Functions | |
static std::string | makeDefinesForKernelTypes (bool bFastGen, enum Nbnxm::ElecType elecType, enum Nbnxm::VdwType vdwType) |
Returns a string with the compiler defines required to avoid all flavour generation. More... | |
void | nbnxn_gpu_compile_kernels (NbnxmGpu *nb) |
Compiles nbnxn kernels for OpenCL GPU given by mygpu . More... | |
Variables | |
static const char * | kernel_electrostatic_family_definitions [] |
Array of the defines needed to generate a specific eel flavour. More... | |
static const char * | kernel_VdW_family_definitions [] |
Array of the defines needed to generate a specific vdw flavour. More... | |
|
static |
Returns a string with the compiler defines required to avoid all flavour generation.
For example if flavour ElecType::RF with VdwType::FSwitch, the output will be such that the corresponding kernel flavour is generated: -DGMX_OCL_FASTGEN (will replace flavour generator nbnxn_ocl_kernels.clh with nbnxn_ocl_kernels_fastgen.clh) -DEL_RF (The ElecType::RF flavour) -DEELNAME=_ElecRF (The first part of the generated kernel name ) -DLJ_EWALD_COMB_GEOM (The VdwType::FSwitch flavour) -DVDWNAME=_VdwLJEwCombGeom (The second part of the generated kernel name )
prune/energy are still generated as originally. It is only the flavour-level that has changed, so that only the required flavour for the simulation is compiled.
If elecType is single-range Ewald, then we need to add the twin-cutoff flavour kernels to the JIT, because PME tuning might need it. This path sets -DGMX_OCL_FASTGEN_ADD_TWINCUT, which triggers the use of nbnxn_ocl_kernels_fastgen_add_twincut.clh. This hard-codes the generation of extra kernels that have the same base flavour, and add the required -DVDW_CUTOFF_CHECK and "TwinCut" to the kernel name.
If FastGen is not active, then nothing needs to be returned. The JIT defaults to compiling all kernel flavours.
[in] | bFastGen | Whether FastGen should be used |
[in] | elecType | Electrostatics kernel flavour for FastGen |
[in] | vdwType | VDW kernel flavour for FastGen |
std::bad_alloc | if out of memory |
void nbnxn_gpu_compile_kernels | ( | NbnxmGpu * | nb | ) |
Compiles nbnxn kernels for OpenCL GPU given by mygpu
.
With OpenCL, a call to this function must not precede nbnxn_gpu_init() (which also calls it).
Doing bFastGen means only the requested kernels are compiled, significantly reducing the total compilation time. If false, all OpenCL kernels are compiled.
A fatal error results if compilation fails.
[in,out] | nb | Manages OpenCL non-bonded calculations; compiled kernels returned in deviceInfo members |
Does not throw
|
static |
Array of the defines needed to generate a specific eel flavour.
The twin-cutoff entries are not normally used, because those setups are not available to the user. FastGen takes care of generating both single- and twin-cutoff versions because PME tuning might need both.
|
static |
Array of the defines needed to generate a specific vdw flavour.