OpenCLKernelFactory.cpp 4.74 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* -------------------------------------------------------------------------- *
 *                                   OpenMM                                   *
 * -------------------------------------------------------------------------- *
 * This is part of the OpenMM molecular simulation toolkit originating from   *
 * Simbios, the NIH National Center for Physics-Based Simulation of           *
 * Biological Structures at Stanford, funded under the NIH Roadmap for        *
 * Medical Research, grant U54 GM072970. See https://simtk.org.               *
 *                                                                            *
 * Portions copyright (c) 2008 Stanford University and the Authors.           *
 * Authors: Peter Eastman                                                     *
 * Contributors:                                                              *
 *                                                                            *
 * This program is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU Lesser General Public License as published   *
 * by the Free Software Foundation, either version 3 of the License, or       *
 * (at your option) any later version.                                        *
 *                                                                            *
 * This program is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
 * GNU Lesser General Public License for more details.                        *
 *                                                                            *
 * You should have received a copy of the GNU Lesser General Public License   *
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.      *
 * -------------------------------------------------------------------------- */

#include "OpenCLKernelFactory.h"
#include "OpenCLKernels.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/OpenMMException.h"

using namespace OpenMM;

KernelImpl* OpenCLKernelFactory::createKernelImpl(std::string name, const Platform& platform, ContextImpl& context) const {
    OpenCLPlatform::PlatformData& data = *static_cast<OpenCLPlatform::PlatformData*>(context.getPlatformData());
36
37
    if (name == CalcForcesAndEnergyKernel::Name())
        return new OpenCLCalcForcesAndEnergyKernel(name, platform, data);
38
39
    if (name == UpdateStateDataKernel::Name())
        return new OpenCLUpdateStateDataKernel(name, platform, data);
40
41
    if (name == CalcHarmonicBondForceKernel::Name())
        return new OpenCLCalcHarmonicBondForceKernel(name, platform, data, context.getSystem());
42
43
44
45
    if (name == CalcHarmonicAngleForceKernel::Name())
        return new OpenCLCalcHarmonicAngleForceKernel(name, platform, data, context.getSystem());
    if (name == CalcPeriodicTorsionForceKernel::Name())
        return new OpenCLCalcPeriodicTorsionForceKernel(name, platform, data, context.getSystem());
46
47
    if (name == CalcRBTorsionForceKernel::Name())
        return new OpenCLCalcRBTorsionForceKernel(name, platform, data, context.getSystem());
48
49
50
51
52
53
//    if (name == CalcNonbondedForceKernel::Name())
//        return new OpenCLCalcNonbondedForceKernel(name, platform, data, context.getSystem());
//    if (name == CalcCustomNonbondedForceKernel::Name())
//        return new OpenCLCalcCustomNonbondedForceKernel(name, platform, data, context.getSystem());
//    if (name == CalcGBSAOBCForceKernel::Name())
//        return new OpenCLCalcGBSAOBCForceKernel(name, platform, data);
54
55
    if (name == IntegrateVerletStepKernel::Name())
        return new OpenCLIntegrateVerletStepKernel(name, platform, data);
56
57
58
59
60
61
62
63
64
65
//    if (name == IntegrateLangevinStepKernel::Name())
//        return new OpenCLIntegrateLangevinStepKernel(name, platform, data);
//    if (name == IntegrateBrownianStepKernel::Name())
//        return new OpenCLIntegrateBrownianStepKernel(name, platform, data);
//    if (name == IntegrateVariableVerletStepKernel::Name())
//        return new OpenCLIntegrateVariableVerletStepKernel(name, platform, data);
//    if (name == IntegrateVariableLangevinStepKernel::Name())
//        return new OpenCLIntegrateVariableLangevinStepKernel(name, platform, data);
//    if (name == ApplyAndersenThermostatKernel::Name())
//        return new OpenCLApplyAndersenThermostatKernel(name, platform, data);
66
    if (name == CalcKineticEnergyKernel::Name())
67
        return new OpenCLCalcKineticEnergyKernel(name, platform, data);
68
69
70
71
//    if (name == RemoveCMMotionKernel::Name())
//        return new OpenCLRemoveCMMotionKernel(name, platform, data);
    throw OpenMMException((std::string("Tried to create kernel with illegal kernel name '")+name+"'").c_str());
}