#
# This file is part of the GROMACS molecular simulation package.
#
-# Copyright (c) 2013, by the GROMACS development team, led by
+# Copyright (c) 2013,2014, by the GROMACS development team, led by
# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
# and including many others, as listed in the AUTHORS file in the
# top-level source directory and at http://www.gromacs.org.
import re
import sys
import os
+os.chdir(os.path.dirname(os.path.abspath(__file__)))
import collections # Requires Python 2.7
sys.path.append('../../../../../admin')
from copyright import create_copyright_header
-FileHeader = create_copyright_header('2012,2013')
+FileHeader = create_copyright_header('2012,2013,2014')
FileHeader += """/*
* Note: this file was generated by the Verlet kernel generator for
* kernel type {0}.
# The dict order must match the order of an enumeration in
# nbnxn_kernel_simd_template.c.pre
ElectrostaticsDict = collections.OrderedDict()
-ElectrostaticsDict['rf'] = { 'define' : '#define CALC_COUL_RF' }
-ElectrostaticsDict['tab'] = { 'define' : '#define CALC_COUL_TAB' }
-ElectrostaticsDict['tab_twin'] = { 'define' : '#define CALC_COUL_TAB\n#define VDW_CUTOFF_CHECK /* Use twin-range cut-off */' }
-ElectrostaticsDict['ewald'] = { 'define' : '#define CALC_COUL_EWALD' }
-ElectrostaticsDict['ewald_twin'] = { 'define' : '#define CALC_COUL_EWALD\n#define VDW_CUTOFF_CHECK /* Use twin-range cut-off */' }
-
+ElectrostaticsDict['ElecRF'] = { 'define' : '#define CALC_COUL_RF' }
+ElectrostaticsDict['ElecQSTab'] = { 'define' : '#define CALC_COUL_TAB' }
+ElectrostaticsDict['ElecQSTabTwinCut'] = { 'define' : '#define CALC_COUL_TAB\n#define VDW_CUTOFF_CHECK /* Use twin-range cut-off */' }
+ElectrostaticsDict['ElecEw'] = { 'define' : '#define CALC_COUL_EWALD' }
+ElectrostaticsDict['ElecEwTwinCut'] = { 'define' : '#define CALC_COUL_EWALD\n#define VDW_CUTOFF_CHECK /* Use twin-range cut-off */' }
+
# The dict order must match the order of a C enumeration.
-LJCombinationRuleDict = collections.OrderedDict()
-LJCombinationRuleDict['geom'] = { 'define' : '#define LJ_COMB_GEOM' }
-LJCombinationRuleDict['lb'] = { 'define' : '#define LJ_COMB_LB' }
-LJCombinationRuleDict['none'] = { 'define' : '/* Use no LJ combination rule */' }
+VdwTreatmentDict = collections.OrderedDict()
+VdwTreatmentDict['VdwLJCombGeom'] = { 'define' : '#define LJ_CUT\n#define LJ_COMB_GEOM' }
+VdwTreatmentDict['VdwLJCombLB'] = { 'define' : '#define LJ_CUT\n#define LJ_COMB_LB' }
+VdwTreatmentDict['VdwLJ'] = { 'define' : '#define LJ_CUT\n/* Use full LJ combination matrix */' }
+VdwTreatmentDict['VdwLJFSw'] = { 'define' : '#define LJ_FORCE_SWITCH\n/* Use full LJ combination matrix */' }
+VdwTreatmentDict['VdwLJPSw'] = { 'define' : '#define LJ_POT_SWITCH\n/* Use full LJ combination matrix */' }
+VdwTreatmentDict['VdwLJEwCombGeom'] = { 'define' : '#define LJ_CUT\n#define LJ_EWALD_GEOM\n/* Use full LJ combination matrix + geometric rule for the grid correction */' }
# This is OK as an unordered dict
EnergiesComputationDict = {
- 'ener' : {
+ 'F' : {
+ 'function type' : 'nbk_func_noener',
+ 'define' : '/* Will not calculate energies */',
+ },
+ 'VF' : {
'function type' : 'nbk_func_ener',
'define' : '#define CALC_ENERGIES',
},
- 'energrp' : {
+ 'VgrpF' : {
'function type' : 'nbk_func_ener',
'define' : '#define CALC_ENERGIES\n#define ENERGY_GROUPS',
},
- 'noener' : {
- 'function type' : 'nbk_func_noener',
- 'define' : '/* Will not calculate energies */',
- },
}
# This is OK as an unordered dict
'2xnn' : {
'Define' : 'GMX_NBNXN_SIMD_2XNN',
'WidthSetup' : '/* Include the full-width SIMD macros */\n',
- 'WidthCheck' : ('#if !(GMX_SIMD_WIDTH_HERE == 8 || GMX_SIMD_WIDTH_HERE == 16)\n' \
+ 'WidthCheck' : ('#if !(GMX_SIMD_REAL_WIDTH == 8 || GMX_SIMD_REAL_WIDTH == 16)\n' \
'#error "unsupported SIMD width"\n' \
'#endif\n'),
'UnrollSize' : 2,
},
'4xn' : {
'Define' : 'GMX_NBNXN_SIMD_4XN',
- 'WidthSetup' : ('#ifdef GMX_NBNXN_HALF_WIDTH_SIMD\n' \
- '#define GMX_USE_HALF_WIDTH_SIMD_HERE\n' \
- '#endif\n'),
- 'WidthCheck' : ('#if !(GMX_SIMD_WIDTH_HERE == 2 || GMX_SIMD_WIDTH_HERE == 4 || GMX_SIMD_WIDTH_HERE == 8)\n' \
+ 'WidthSetup' : (''),
+ 'WidthCheck' : ('#if !(GMX_SIMD_REAL_WIDTH == 2 || GMX_SIMD_REAL_WIDTH == 4 || GMX_SIMD_REAL_WIDTH == 8)\n' \
'#error "unsupported SIMD width"\n' \
'#endif\n'),
'UnrollSize' : 1,
# for each kernel, a file defining the single C function for that kernel
for type in VerletKernelTypeDict:
DirName = "../simd_{0}".format(type)
- KernelNamePrefix = 'nbnxn_kernel_simd_{0}'.format(type)
- KernelsHeaderFileName = "{0}.h".format(KernelNamePrefix)
+ KernelNamePrefix = 'nbnxn_kernel'
+ KernelsName = "{0}_simd_{1}".format(KernelNamePrefix,type)
+ KernelsHeaderFileName = "{0}.h".format(KernelsName,type)
+ KernelsHeaderPathName = "gromacs/mdlib/nbnxn_kernels/simd_{0}/{1}".format(type,KernelsHeaderFileName)
KernelFunctionLookupTable = {}
KernelDeclarations = ''
- KernelTemplate = read_kernel_template("{0}_kernel.c.pre".format(KernelNamePrefix))
+ KernelTemplate = read_kernel_template("{0}_kernel.c.pre".format(KernelsName))
# Loop over all kernels
for ener in EnergiesComputationDict:
KernelFunctionLookupTable[ener] = '{\n'
for elec in ElectrostaticsDict:
KernelFunctionLookupTable[ener] += ' {\n'
- for ljcomb in LJCombinationRuleDict:
- KernelName = ('{0}_{1}_comb_{2}_{3}'
- .format(KernelNamePrefix,elec,ljcomb,ener))
+ for ljtreat in VdwTreatmentDict:
+ KernelName = ('{0}_{1}_{2}_{3}_{4}'
+ .format(KernelNamePrefix,elec,ljtreat,ener,type))
# Declare the kernel function
KernelDeclarations += ('{1:21} {0};\n'
kernelfp.write(KernelTemplate
.format(VerletKernelTypeDict[type]['Define'],
ElectrostaticsDict[elec]['define'],
- LJCombinationRuleDict[ljcomb]['define'],
+ VdwTreatmentDict[ljtreat]['define'],
EnergiesComputationDict[ener]['define'],
- KernelsHeaderFileName,
+ KernelsHeaderPathName,
KernelName,
" " * (len(KernelName) + 1),
VerletKernelTypeDict[type]['UnrollSize'],
with open('{0}/{1}'.format(DirName,KernelsHeaderFileName),'w') as fp:
fp.write(FileHeader.format(type))
fp.write(KernelsHeaderTemplate
- .format(KernelNamePrefix,
- " " * (len(KernelNamePrefix) + 1),
+ .format(KernelsName,
+ " " * (len(KernelsName) + 1),
KernelDeclarations))
# Write the file defining the kernel dispatcher
# function for this type
- with open('{0}/{1}'.format(DirName,"{0}.c".format(KernelNamePrefix)),'w') as fp:
+ with open('{0}/{1}'.format(DirName,"{0}.c".format(KernelsName,type)),'w') as fp:
fp.write(FileHeader.format(type))
fp.write(KernelDispatcherTemplate
.format(VerletKernelTypeDict[type]['Define'],
VerletKernelTypeDict[type]['WidthCheck'],
VerletKernelTypeDict[type]['UnrollSize'],
KernelsHeaderFileName,
- KernelNamePrefix,
- ' ' * (len(KernelNamePrefix)+1),
- KernelFunctionLookupTable['ener'],
- KernelFunctionLookupTable['energrp'],
- KernelFunctionLookupTable['noener'],
+ KernelsName,
+ ' ' * (len(KernelsName)+1),
+ KernelFunctionLookupTable['F'],
+ KernelFunctionLookupTable['VF'],
+ KernelFunctionLookupTable['VgrpF'],
)
)