Skip to content

Commit 4d836c2

Browse files
committed
Updated README
1 parent 7a3e1a3 commit 4d836c2

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

README.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
OpenMM Example Plugin
22
=====================
33

4-
This project is an example of how to write a plugin for [OpenMM](https://simtk.org/home/openmm).
4+
This project is an example of how to write a plugin for [OpenMM](https://openmm.org).
55
It includes nearly everything you would want in a real plugin, including implementations for the
66
Reference, OpenCL, and CUDA platforms, serialization support, test cases, and a Python API. It
77
is useful as a starting point for anyone who wants to write a plugin.
@@ -84,6 +84,12 @@ run the test suite.
8484
OpenCL and CUDA Kernels
8585
=======================
8686

87+
The OpenCL and CUDA versions of the force are implemented with the common compute framework.
88+
This allows us to write a single class (`CommonCalcExampleForceKernel`) that provides an
89+
implementation for both platforms at the same time. Device code is written in a subset of
90+
the OpenCL and CUDA languages, with a few macro and function definitions to make them
91+
identical.
92+
8793
The OpenCL and CUDA platforms compile all of their kernels from source at runtime. This
8894
requires you to store all your kernel source in a way that makes it accessible at runtime. That
8995
turns out to be harder than you might think: simply storing source files on disk is brittle,
@@ -93,13 +99,13 @@ strings in the code, but that is very inconvenient to edit and maintain, especia
9399
doesn't have a clean syntax for multi-line strings.
94100

95101
This project (like OpenMM itself) uses a hybrid mechanism that provides the best of both
96-
approaches. The source code for the OpenCL and CUDA implementations each include a "kernels"
97-
directory. At build time, a CMake script loads every .cl (for OpenCL) or .cu (for CUDA) file
98-
contained in the directory and generates a class with all the file contents as strings. For
99-
example, the OpenCL kernels directory contains a single file called exampleForce.cl. You can
102+
approaches. The source code for the kernels is found in the `platforms/common/src/kernels`
103+
directory. At build time, a CMake script loads every .cc file contained in the directory
104+
and generates a class with all the file contents as strings. For the example plugin, the
105+
directory contains a single file called exampleForce.cc. You can
100106
put anything you want into this file, and then C++ code can access the content of that file
101-
as `OpenCLExampleKernelSources::exampleForce`. If you add more .cl files to this directory,
102-
correspondingly named variables will automatically be added to `OpenCLExampleKernelSources`.
107+
as `CommonExampleKernelSources::exampleForce`. If you add more .cc files to this directory,
108+
correspondingly named variables will automatically be added to `CommonExampleKernelSources`.
103109

104110

105111
Python API
@@ -111,7 +117,7 @@ It then generates a Python extension module exposing the C++ API in Python.
111117

112118
When building OpenMM's Python API, the interface file is generated automatically from the C++
113119
API. That guarantees the C++ and Python APIs are always synchronized with each other and avoids
114-
the potential bugs that would come from have duplicate definitions. It takes a lot of complex
120+
the potential bugs that would come from having duplicate definitions. It takes a lot of complex
115121
processing to do that, though, and for a single plugin it's far simpler to just write the
116122
interface file by hand. You will find it in the "python" directory.
117123

@@ -136,7 +142,7 @@ Simbios, the NIH National Center for Physics-Based Simulation of
136142
Biological Structures at Stanford, funded under the NIH Roadmap for
137143
Medical Research, grant U54 GM072970. See https://simtk.org.
138144

139-
Portions copyright (c) 2014 Stanford University and the Authors.
145+
Portions copyright (c) 2014-2021 Stanford University and the Authors.
140146

141147
Authors: Peter Eastman
142148

0 commit comments

Comments
 (0)