Gromacs  2024.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions | Variables
nbnxm_ocl_jit_support.cpp File Reference
#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"
+ Include dependency graph for nbnxm_ocl_jit_support.cpp:

Description

Defines functions that support JIT compilation (e.g. for OpenCL)

Author
Dimitrios Karkoulis dimit.nosp@m.ris..nosp@m.karko.nosp@m.ulis.nosp@m.@gmai.nosp@m.l.co.nosp@m.m
Mark Abraham mark..nosp@m.j.ab.nosp@m.raham.nosp@m.@gma.nosp@m.il.co.nosp@m.m

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...
 

Function Documentation

static std::string makeDefinesForKernelTypes ( bool  bFastGen,
enum Nbnxm::ElecType  elecType,
enum Nbnxm::VdwType  vdwType 
)
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.

Parameters
[in]bFastGenWhether FastGen should be used
[in]elecTypeElectrostatics kernel flavour for FastGen
[in]vdwTypeVDW kernel flavour for FastGen
Returns
String with the defines if FastGen is active
Exceptions
std::bad_allocif 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.

Parameters
[in,out]nbManages OpenCL non-bonded calculations; compiled kernels returned in deviceInfo members

Does not throw

Variable Documentation

const char* kernel_electrostatic_family_definitions[]
static
Initial value:
= {
" -DEL_CUTOFF -DEELNAME=_ElecCut",
" -DEL_RF -DEELNAME=_ElecRF",
" -DEL_EWALD_TAB -DEELNAME=_ElecEwQSTab",
" -DEL_EWALD_TAB -DVDW_CUTOFF_CHECK -DEELNAME=_ElecEwQSTabTwinCut",
" -DEL_EWALD_ANA -DEELNAME=_ElecEw",
" -DEL_EWALD_ANA -DVDW_CUTOFF_CHECK -DEELNAME=_ElecEwTwinCut"
}

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.

const char* kernel_VdW_family_definitions[]
static
Initial value:
= {
" -DVDWNAME=_VdwLJ",
" -DLJ_COMB_GEOM -DVDWNAME=_VdwLJCombGeom",
" -DLJ_COMB_LB -DVDWNAME=_VdwLJCombLB",
" -DLJ_FORCE_SWITCH -DVDWNAME=_VdwLJFsw",
" -DLJ_POT_SWITCH -DVDWNAME=_VdwLJPsw",
" -DLJ_EWALD_COMB_GEOM -DVDWNAME=_VdwLJEwCombGeom",
" -DLJ_EWALD_COMB_LB -DVDWNAME=_VdwLJEwCombLB"
}

Array of the defines needed to generate a specific vdw flavour.