Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
012b28e6
Commit
012b28e6
authored
Apr 19, 2008
by
Peter Eastman
Browse files
Continuing to implement ReferencePlatform
parent
e561a678
Changes
34
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
314 additions
and
56 deletions
+314
-56
olla/include/KernelFactory.h
olla/include/KernelFactory.h
+1
-1
olla/include/KernelImpl.h
olla/include/KernelImpl.h
+9
-2
olla/include/StreamFactory.h
olla/include/StreamFactory.h
+1
-1
olla/include/StreamImpl.h
olla/include/StreamImpl.h
+11
-4
olla/include/kernels.h
olla/include/kernels.h
+9
-9
olla/src/KernelImpl.cpp
olla/src/KernelImpl.cpp
+6
-1
olla/src/Platform.cpp
olla/src/Platform.cpp
+3
-3
olla/src/StreamImpl.cpp
olla/src/StreamImpl.cpp
+4
-1
platforms/reference/include/ReferenceKernelFactory.h
platforms/reference/include/ReferenceKernelFactory.h
+1
-1
platforms/reference/include/ReferenceStreamFactory.h
platforms/reference/include/ReferenceStreamFactory.h
+1
-1
platforms/reference/src/ReferenceFloatStreamImpl.cpp
platforms/reference/src/ReferenceFloatStreamImpl.cpp
+1
-1
platforms/reference/src/ReferenceFloatStreamImpl.h
platforms/reference/src/ReferenceFloatStreamImpl.h
+1
-1
platforms/reference/src/ReferenceIntStreamImpl.cpp
platforms/reference/src/ReferenceIntStreamImpl.cpp
+84
-0
platforms/reference/src/ReferenceIntStreamImpl.h
platforms/reference/src/ReferenceIntStreamImpl.h
+59
-0
platforms/reference/src/ReferenceKernelFactory.cpp
platforms/reference/src/ReferenceKernelFactory.cpp
+11
-10
platforms/reference/src/ReferenceKernels.cpp
platforms/reference/src/ReferenceKernels.cpp
+75
-3
platforms/reference/src/ReferenceKernels.h
platforms/reference/src/ReferenceKernels.h
+15
-9
platforms/reference/src/ReferencePlatform.cpp
platforms/reference/src/ReferencePlatform.cpp
+9
-0
platforms/reference/src/ReferenceStreamFactory.cpp
platforms/reference/src/ReferenceStreamFactory.cpp
+10
-5
platforms/reference/src/SimTKReference/ReferenceAngleBondIxn.cpp
...ms/reference/src/SimTKReference/ReferenceAngleBondIxn.cpp
+3
-3
No files found.
olla/include/KernelFactory.h
View file @
012b28e6
...
...
@@ -49,7 +49,7 @@ public:
*
* @param name the name of the kernel to create
*/
virtual
KernelImpl
*
createKernelImpl
(
std
::
string
name
)
const
=
0
;
virtual
KernelImpl
*
createKernelImpl
(
std
::
string
name
,
const
Platform
&
platform
)
const
=
0
;
virtual
~
KernelFactory
()
{
}
};
...
...
olla/include/KernelImpl.h
View file @
012b28e6
...
...
@@ -32,6 +32,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "Platform.h"
#include <string>
namespace
OpenMM
{
...
...
@@ -47,9 +48,10 @@ public:
/**
* Create a KernelImpl.
*
* @param name the name of the kernel to create
* @param name the name of the kernel to create
* @param platform the Platform that created this kernel
*/
KernelImpl
(
std
::
string
name
);
KernelImpl
(
std
::
string
name
,
const
Platform
&
platform
);
virtual
~
KernelImpl
()
{
assert
(
referenceCount
==
0
);
}
...
...
@@ -57,9 +59,14 @@ public:
* Get the name of this kernel.
*/
std
::
string
getName
()
const
;
/**
* Get the Platform that created this KernelImpl.
*/
const
Platform
&
getPlatform
();
private:
friend
class
Kernel
;
std
::
string
name
;
const
Platform
*
platform
;
int
referenceCount
;
};
...
...
olla/include/StreamFactory.h
View file @
012b28e6
...
...
@@ -51,7 +51,7 @@ public:
* @param size the number of elements in the stream
* @param type the data type of each element in the stream
*/
virtual
StreamImpl
*
createStreamImpl
(
std
::
string
name
,
int
size
,
Stream
::
DataType
type
)
const
=
0
;
virtual
StreamImpl
*
createStreamImpl
(
std
::
string
name
,
int
size
,
Stream
::
DataType
type
,
const
Platform
&
platform
)
const
=
0
;
virtual
~
StreamFactory
()
{
}
};
...
...
olla/include/StreamImpl.h
View file @
012b28e6
...
...
@@ -32,6 +32,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "Platform.h"
#include "Stream.h"
#include <string>
...
...
@@ -46,11 +47,12 @@ public:
/**
* Create a StreamImpl.
*
* @param name the name of the stream to create
* @param size the number of elements in the stream
* @param type the data type of each element in the stream
* @param name the name of the stream to create
* @param size the number of elements in the stream
* @param type the data type of each element in the stream
* @param platform the Platform that created this kernel
*/
StreamImpl
(
std
::
string
name
,
int
size
,
Stream
::
DataType
type
);
StreamImpl
(
std
::
string
name
,
int
size
,
Stream
::
DataType
type
,
const
Platform
&
platform
);
virtual
~
StreamImpl
()
{
assert
(
referenceCount
==
0
);
}
...
...
@@ -66,6 +68,10 @@ public:
* Get the data type of each element in the stream.
*/
Stream
::
DataType
getDataType
()
const
;
/**
* Get the Platform that created this KernelImpl.
*/
const
Platform
&
getPlatform
();
/**
* Copy the contents of an array into this stream.
*
...
...
@@ -95,6 +101,7 @@ private:
std
::
string
name
;
int
size
;
Stream
::
DataType
type
;
const
Platform
*
platform
;
int
referenceCount
;
};
...
...
olla/include/kernels.h
View file @
012b28e6
...
...
@@ -48,7 +48,7 @@ public:
static
std
::
string
Name
()
{
return
"CalcStandardMMForces"
;
}
CalcStandardMMForcesKernel
(
std
::
string
name
)
:
KernelImpl
(
name
)
{
CalcStandardMMForcesKernel
(
std
::
string
name
,
const
Platform
&
platform
)
:
KernelImpl
(
name
,
platform
)
{
}
/**
* Initialize the kernel, setting up the values of all the force field parameters.
...
...
@@ -92,7 +92,7 @@ public:
static
std
::
string
Name
()
{
return
"CalcStandardMMEnergy"
;
}
CalcStandardMMEnergyKernel
(
std
::
string
name
)
:
KernelImpl
(
name
)
{
CalcStandardMMEnergyKernel
(
std
::
string
name
,
const
Platform
&
platform
)
:
KernelImpl
(
name
,
platform
)
{
}
/**
* Initialize the kernel, setting up the values of all the force field parameters.
...
...
@@ -135,7 +135,7 @@ public:
static
std
::
string
Name
()
{
return
"CalcGBSAOBCForces"
;
}
CalcGBSAOBCForcesKernel
(
std
::
string
name
)
:
KernelImpl
(
name
)
{
CalcGBSAOBCForcesKernel
(
std
::
string
name
,
const
Platform
&
platform
)
:
KernelImpl
(
name
,
platform
)
{
}
/**
* Initialize the kernel, setting up the values of all the force field parameters.
...
...
@@ -165,7 +165,7 @@ public:
static
std
::
string
Name
()
{
return
"CalcGBSAOBCEnergy"
;
}
CalcGBSAOBCEnergyKernel
(
std
::
string
name
)
:
KernelImpl
(
name
)
{
CalcGBSAOBCEnergyKernel
(
std
::
string
name
,
const
Platform
&
platform
)
:
KernelImpl
(
name
,
platform
)
{
}
/**
* Initialize the kernel, setting up the values of all the force field parameters.
...
...
@@ -194,7 +194,7 @@ public:
static
std
::
string
Name
()
{
return
"IntegrateVerletStep"
;
}
IntegrateVerletStepKernel
(
std
::
string
name
)
:
KernelImpl
(
name
)
{
IntegrateVerletStepKernel
(
std
::
string
name
,
const
Platform
&
platform
)
:
KernelImpl
(
name
,
platform
)
{
}
/**
* Initialize the kernel, setting up all parameters related to integrator.
...
...
@@ -224,7 +224,7 @@ public:
static
std
::
string
Name
()
{
return
"IntegrateLangevinStep"
;
}
IntegrateLangevinStepKernel
(
std
::
string
name
)
:
KernelImpl
(
name
)
{
IntegrateLangevinStepKernel
(
std
::
string
name
,
const
Platform
&
platform
)
:
KernelImpl
(
name
,
platform
)
{
}
/**
* Initialize the kernel, setting up all parameters related to integrator.
...
...
@@ -256,7 +256,7 @@ public:
static
std
::
string
Name
()
{
return
"IntegrateBrownianStep"
;
}
IntegrateBrownianStepKernel
(
std
::
string
name
)
:
KernelImpl
(
name
)
{
IntegrateBrownianStepKernel
(
std
::
string
name
,
const
Platform
&
platform
)
:
KernelImpl
(
name
,
platform
)
{
}
/**
* Initialize the kernel, setting up all parameters related to integrator.
...
...
@@ -288,7 +288,7 @@ public:
static
std
::
string
Name
()
{
return
"ApplyAndersenThermostat"
;
}
ApplyAndersenThermostatKernel
(
std
::
string
name
)
:
KernelImpl
(
name
)
{
ApplyAndersenThermostatKernel
(
std
::
string
name
,
const
Platform
&
platform
)
:
KernelImpl
(
name
,
platform
)
{
}
/**
* Initialize the kernel, setting up the values of unchanging parameters.
...
...
@@ -315,7 +315,7 @@ public:
static
std
::
string
Name
()
{
return
"CalcKineticEnergy"
;
}
CalcKineticEnergyKernel
(
std
::
string
name
)
:
KernelImpl
(
name
)
{
CalcKineticEnergyKernel
(
std
::
string
name
,
const
Platform
&
platform
)
:
KernelImpl
(
name
,
platform
)
{
}
/**
* Initialize the kernel, setting up the atomic masses.
...
...
olla/src/KernelImpl.cpp
View file @
012b28e6
...
...
@@ -34,9 +34,14 @@
using
namespace
OpenMM
;
using
namespace
std
;
KernelImpl
::
KernelImpl
(
string
name
)
:
name
(
name
),
referenceCount
(
1
)
{
KernelImpl
::
KernelImpl
(
string
name
,
const
Platform
&
platform
)
:
name
(
name
),
platform
(
&
platform
),
referenceCount
(
1
)
{
}
std
::
string
KernelImpl
::
getName
()
const
{
return
name
;
}
const
Platform
&
KernelImpl
::
getPlatform
()
{
return
*
platform
;
}
olla/src/Platform.cpp
View file @
012b28e6
...
...
@@ -73,13 +73,13 @@ bool Platform::supportsKernels(std::vector<std::string> kernelNames) const {
Kernel
Platform
::
createKernel
(
std
::
string
name
)
const
{
if
(
kernelFactories
.
find
(
name
)
==
kernelFactories
.
end
())
throw
PlatformException
(
"Called createKernel() on a Platform which does not support the requested kernel"
);
return
Kernel
(
kernelFactories
.
find
(
name
)
->
second
->
createKernelImpl
(
name
));
return
Kernel
(
kernelFactories
.
find
(
name
)
->
second
->
createKernelImpl
(
name
,
*
this
));
}
Stream
Platform
::
createStream
(
std
::
string
name
,
int
size
,
Stream
::
DataType
type
)
const
{
if
(
streamFactories
.
find
(
name
)
==
streamFactories
.
end
())
return
Stream
(
getDefaultStreamFactory
().
createStreamImpl
(
name
,
size
,
type
));
return
Stream
(
streamFactories
.
find
(
name
)
->
second
->
createStreamImpl
(
name
,
size
,
type
));
return
Stream
(
getDefaultStreamFactory
().
createStreamImpl
(
name
,
size
,
type
,
*
this
));
return
Stream
(
streamFactories
.
find
(
name
)
->
second
->
createStreamImpl
(
name
,
size
,
type
,
*
this
));
}
void
Platform
::
registerPlatform
(
Platform
*
platform
)
{
...
...
olla/src/StreamImpl.cpp
View file @
012b28e6
...
...
@@ -34,7 +34,7 @@
using
namespace
OpenMM
;
using
namespace
std
;
StreamImpl
::
StreamImpl
(
string
name
,
int
size
,
Stream
::
DataType
type
)
:
name
(
name
),
size
(
size
),
type
(
type
),
referenceCount
(
1
)
{
StreamImpl
::
StreamImpl
(
string
name
,
int
size
,
Stream
::
DataType
type
,
const
Platform
&
platform
)
:
name
(
name
),
size
(
size
),
type
(
type
),
platform
(
&
platform
),
referenceCount
(
1
)
{
}
std
::
string
StreamImpl
::
getName
()
const
{
...
...
@@ -49,3 +49,6 @@ Stream::DataType StreamImpl::getDataType() const {
return
type
;
}
const
Platform
&
StreamImpl
::
getPlatform
()
{
return
*
platform
;
}
platforms/reference/include/ReferenceKernelFactory.h
View file @
012b28e6
...
...
@@ -42,7 +42,7 @@ namespace OpenMM {
class
ReferenceKernelFactory
:
public
KernelFactory
{
public:
KernelImpl
*
createKernelImpl
(
std
::
string
name
)
const
;
KernelImpl
*
createKernelImpl
(
std
::
string
name
,
const
Platform
&
platform
)
const
;
};
}
// namespace OpenMM
...
...
platforms/reference/include/ReferenceStreamFactory.h
View file @
012b28e6
...
...
@@ -42,7 +42,7 @@ namespace OpenMM {
class
ReferenceStreamFactory
:
public
StreamFactory
{
public:
StreamImpl
*
createStreamImpl
(
std
::
string
name
,
int
size
,
Stream
::
DataType
type
)
const
;
StreamImpl
*
createStreamImpl
(
std
::
string
name
,
int
size
,
Stream
::
DataType
type
,
const
Platform
&
platform
)
const
;
};
}
// namespace OpenMM
...
...
platforms/reference/src/ReferenceFloatStreamImpl.cpp
View file @
012b28e6
...
...
@@ -33,7 +33,7 @@
using
namespace
OpenMM
;
ReferenceFloatStreamImpl
::
ReferenceFloatStreamImpl
(
std
::
string
name
,
int
size
,
Stream
::
DataType
type
)
:
StreamImpl
(
name
,
size
,
type
)
{
ReferenceFloatStreamImpl
::
ReferenceFloatStreamImpl
(
std
::
string
name
,
int
size
,
Stream
::
DataType
type
,
const
Platform
&
platform
)
:
StreamImpl
(
name
,
size
,
type
,
platform
)
{
switch
(
type
)
{
case
Stream
::
Float
:
case
Stream
::
Float2
:
...
...
platforms/reference/src/ReferenceFloatStreamImpl.h
View file @
012b28e6
...
...
@@ -43,7 +43,7 @@ namespace OpenMM {
class
ReferenceFloatStreamImpl
:
public
StreamImpl
{
public:
ReferenceFloatStreamImpl
(
std
::
string
name
,
int
size
,
Stream
::
DataType
type
);
ReferenceFloatStreamImpl
(
std
::
string
name
,
int
size
,
Stream
::
DataType
type
,
const
Platform
&
platform
);
~
ReferenceFloatStreamImpl
();
void
loadFromArray
(
const
void
*
array
);
void
saveToArray
(
void
*
array
);
...
...
platforms/reference/src/ReferenceIntStreamImpl.cpp
0 → 100644
View file @
012b28e6
/* -------------------------------------------------------------------------- *
* 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: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "ReferenceIntStreamImpl.h"
using
namespace
OpenMM
;
ReferenceIntStreamImpl
::
ReferenceIntStreamImpl
(
std
::
string
name
,
int
size
,
Stream
::
DataType
type
,
const
Platform
&
platform
)
:
StreamImpl
(
name
,
size
,
type
,
platform
)
{
switch
(
type
)
{
case
Stream
::
Integer
:
width
=
1
;
break
;
case
Stream
::
Integer2
:
width
=
2
;
break
;
case
Stream
::
Integer3
:
width
=
3
;
break
;
case
Stream
::
Integer4
:
width
=
4
;
break
;
}
data
=
new
int
*
[
size
];
for
(
int
i
=
0
;
i
<
size
;
++
i
)
data
[
i
]
=
new
int
[
width
];
}
ReferenceIntStreamImpl
::~
ReferenceIntStreamImpl
()
{
delete
data
;
}
void
ReferenceIntStreamImpl
::
loadFromArray
(
const
void
*
array
)
{
int
*
arrayData
=
(
int
*
)
array
;
for
(
int
i
=
0
;
i
<
getSize
();
++
i
)
for
(
int
j
=
0
;
j
<
width
;
++
j
)
data
[
i
][
j
]
=
arrayData
[
i
*
width
+
j
];
}
void
ReferenceIntStreamImpl
::
saveToArray
(
void
*
array
)
{
int
*
arrayData
=
(
int
*
)
array
;
for
(
int
i
=
0
;
i
<
getSize
();
++
i
)
for
(
int
j
=
0
;
j
<
width
;
++
j
)
arrayData
[
i
*
width
+
j
]
=
data
[
i
][
j
];
}
void
ReferenceIntStreamImpl
::
fillWithValue
(
void
*
value
)
{
int
valueData
=
*
((
int
*
)
value
);
for
(
int
i
=
0
;
i
<
getSize
();
++
i
)
for
(
int
j
=
0
;
j
<
width
;
++
j
)
data
[
i
][
j
]
=
valueData
;
}
int
**
ReferenceIntStreamImpl
::
getData
()
{
return
data
;
}
platforms/reference/src/ReferenceIntStreamImpl.h
0 → 100644
View file @
012b28e6
#ifndef OPENMM_REFERENCEINTSTREAMIMPL_H_
#define OPENMM_REFERENCEINTSTREAMIMPL_H_
/* -------------------------------------------------------------------------- *
* 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: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "StreamImpl.h"
namespace
OpenMM
{
/**
* This is the implementation of Float and Double streams in the reference Platform.
*/
class
ReferenceIntStreamImpl
:
public
StreamImpl
{
public:
ReferenceIntStreamImpl
(
std
::
string
name
,
int
size
,
Stream
::
DataType
type
,
const
Platform
&
platform
);
~
ReferenceIntStreamImpl
();
void
loadFromArray
(
const
void
*
array
);
void
saveToArray
(
void
*
array
);
void
fillWithValue
(
void
*
value
);
int
**
getData
();
private:
int
width
;
Stream
::
DataType
baseType
;
int
**
data
;
};
}
// namespace OpenMM
#endif
/*OPENMM_REFERENCEINTSTREAMIMPL_H_*/
platforms/reference/src/ReferenceKernelFactory.cpp
View file @
012b28e6
...
...
@@ -30,26 +30,27 @@
* -------------------------------------------------------------------------- */
#include "ReferenceKernelFactory.h"
#include "ReferenceKernels.h"
using
namespace
OpenMM
;
KernelImpl
*
ReferenceKernelFactory
::
createKernelImpl
(
std
::
string
name
)
const
{
KernelImpl
*
ReferenceKernelFactory
::
createKernelImpl
(
std
::
string
name
,
const
Platform
&
platform
)
const
{
if
(
name
==
CalcStandardMMForcesKernel
::
Name
())
return
new
ReferenceCalcStandardMMForcesKernel
(
name
);
return
new
ReferenceCalcStandardMMForcesKernel
(
name
,
platform
);
if
(
name
==
CalcStandardMMEnergyKernel
::
Name
())
return
new
ReferenceCalcStandardMMEnergyKernel
(
name
);
return
new
ReferenceCalcStandardMMEnergyKernel
(
name
,
platform
);
if
(
name
==
CalcGBSAOBCForcesKernel
::
Name
())
return
new
ReferenceCalcGBSAOBCForcesKernel
(
name
);
return
new
ReferenceCalcGBSAOBCForcesKernel
(
name
,
platform
);
if
(
name
==
CalcGBSAOBCEnergyKernel
::
Name
())
return
new
ReferenceCalcGBSAOBCEnergyKernel
(
name
);
return
new
ReferenceCalcGBSAOBCEnergyKernel
(
name
,
platform
);
if
(
name
==
IntegrateVerletStepKernel
::
Name
())
return
new
ReferenceIntegrateVerletStepKernel
(
name
);
return
new
ReferenceIntegrateVerletStepKernel
(
name
,
platform
);
if
(
name
==
IntegrateLangevinStepKernel
::
Name
())
return
new
ReferenceIntegrateLangevinStepKernel
(
name
);
return
new
ReferenceIntegrateLangevinStepKernel
(
name
,
platform
);
if
(
name
==
IntegrateBrownianStepKernel
::
Name
())
return
new
ReferenceIntegrateBrownianStepKernel
(
name
);
return
new
ReferenceIntegrateBrownianStepKernel
(
name
,
platform
);
if
(
name
==
ApplyAndersenThermostatKernel
::
Name
())
return
new
ReferenceApplyAndersenThermostatKernel
(
name
);
return
new
ReferenceApplyAndersenThermostatKernel
(
name
,
platform
);
if
(
name
==
CalcKineticEnergyKernel
::
Name
())
return
new
ReferenceCalcKineticEnergyKernel
(
name
);
return
new
ReferenceCalcKineticEnergyKernel
(
name
,
platform
);
}
platforms/reference/src/ReferenceKernels.cpp
View file @
012b28e6
...
...
@@ -34,13 +34,85 @@
using
namespace
OpenMM
;
using
namespace
std
;
int
**
allocateIntArray
(
int
length
,
int
width
)
{
int
**
array
=
new
int
*
[
length
];
for
(
int
i
=
0
;
i
<
length
;
++
i
)
array
[
i
]
=
new
int
[
width
];
return
array
;
}
RealOpenMM
**
allocateRealArray
(
int
length
,
int
width
)
{
RealOpenMM
**
array
=
new
RealOpenMM
*
[
length
];
for
(
int
i
=
0
;
i
<
length
;
++
i
)
array
[
i
]
=
new
RealOpenMM
[
width
];
return
array
;
}
int
**
copyToArray
(
const
vector
<
vector
<
int
>
>
vec
)
{
if
(
vec
.
size
()
==
0
)
return
new
int
*
[
0
];
int
**
array
=
allocateIntArray
(
vec
.
size
(),
vec
[
0
].
size
());
for
(
int
i
=
0
;
i
<
vec
.
size
();
++
i
)
for
(
int
j
=
0
;
j
<
vec
[
i
].
size
();
++
j
)
array
[
i
][
j
]
=
vec
[
i
][
j
];
return
array
;
}
RealOpenMM
**
copyToArray
(
const
vector
<
vector
<
double
>
>
vec
)
{
if
(
vec
.
size
()
==
0
)
return
new
RealOpenMM
*
[
0
];
RealOpenMM
**
array
=
allocateRealArray
(
vec
.
size
(),
vec
[
0
].
size
());
for
(
int
i
=
0
;
i
<
vec
.
size
();
++
i
)
for
(
int
j
=
0
;
j
<
vec
[
i
].
size
();
++
j
)
array
[
i
][
j
]
=
vec
[
i
][
j
];
return
array
;
}
void
disposeIntArray
(
int
**
array
,
int
size
)
{
if
(
array
)
{
for
(
int
i
=
0
;
i
<
size
;
++
i
)
delete
[]
array
[
i
];
delete
[]
array
;
}
}
void
disposeRealArray
(
RealOpenMM
**
array
,
int
size
)
{
if
(
array
)
{
for
(
int
i
=
0
;
i
<
size
;
++
i
)
delete
[]
array
[
i
];
delete
[]
array
;
}
}
ReferenceCalcStandardMMForcesKernel
::~
ReferenceCalcStandardMMForcesKernel
()
{
disposeIntArray
(
bondIndexArray
,
numBonds
);
disposeRealArray
(
bondParamArray
,
numBonds
);
disposeIntArray
(
angleIndexArray
,
numAngles
);
disposeRealArray
(
angleParamArray
,
numAngles
);
disposeIntArray
(
periodicTorsionIndexArray
,
numPeriodicTorsions
);
disposeRealArray
(
periodicTorsionParamArray
,
numPeriodicTorsions
);
disposeIntArray
(
rbTorsionIndexArray
,
numRBTorsions
);
disposeRealArray
(
rbTorsionParamArray
,
numRBTorsions
);
}
void
ReferenceCalcStandardMMForcesKernel
::
initialize
(
const
vector
<
vector
<
int
>
>&
bondIndices
,
const
vector
<
vector
<
double
>
>&
bondParameters
,
const
vector
<
vector
<
int
>
>&
angleIndices
,
const
vector
<
vector
<
double
>
>&
angleParameters
,
const
vector
<
vector
<
int
>
>&
periodicTorsionIndices
,
const
vector
<
vector
<
double
>
>&
periodicTorsionParameters
,
const
vector
<
vector
<
int
>
>&
rbTorsionIndices
,
const
vector
<
vector
<
double
>
>&
rbTorsionParameters
,
const
vector
<
vector
<
int
>
>&
bonded14Indices
,
const
vector
<
set
<
int
>
>&
exclusions
,
const
vector
<
vector
<
double
>
>&
nonbondedParameters
)
{
numBonds
=
bondIndices
.
size
();
numAngles
=
angleIndices
.
size
();
numPeriodicTorsions
=
periodicTorsionIndices
.
size
();
numRBTorsions
=
rbTorsionIndices
.
size
();
bondIndexArray
=
copyToArray
(
bondIndices
);
bondParamArray
=
copyToArray
(
bondParameters
);
angleIndexArray
=
copyToArray
(
angleIndices
);
angleParamArray
=
copyToArray
(
angleParameters
);
periodicTorsionIndexArray
=
copyToArray
(
periodicTorsionIndices
);
periodicTorsionParamArray
=
copyToArray
(
periodicTorsionParameters
);
rbTorsionIndexArray
=
copyToArray
(
rbTorsionIndices
);
rbTorsionParamArray
=
copyToArray
(
rbTorsionParameters
);
}
void
ReferenceCalcStandardMMForcesKernel
::
execute
(
const
Stream
&
positions
,
Stream
&
forces
)
{
...
...
@@ -69,12 +141,12 @@ void ReferenceCalcGBSAOBCForcesKernel::execute(const Stream& positions, Stream&
}
void
CalcGBSAOBCEnergyKernel
::
initialize
(
const
vector
<
double
>&
bornRadii
,
const
vector
<
vector
<
double
>
>&
atomParameters
,
void
Reference
CalcGBSAOBCEnergyKernel
::
initialize
(
const
vector
<
double
>&
bornRadii
,
const
vector
<
vector
<
double
>
>&
atomParameters
,
double
solventDielectric
,
double
soluteDielectric
)
{
}
double
CalcGBSAOBCEnergyKernel
::
execute
(
const
Stream
&
positions
)
{
double
Reference
CalcGBSAOBCEnergyKernel
::
execute
(
const
Stream
&
positions
)
{
return
0.0
;
// TODO implement correctly
}
...
...
platforms/reference/src/ReferenceKernels.h
View file @
012b28e6
...
...
@@ -33,6 +33,7 @@
* -------------------------------------------------------------------------- */
#include "kernels.h"
#include "SimTKUtilities/SimTKOpenMMRealType.h"
namespace
OpenMM
{
...
...
@@ -41,8 +42,9 @@ namespace OpenMM {
*/
class
ReferenceCalcStandardMMForcesKernel
:
public
CalcStandardMMForcesKernel
{
public:
ReferenceCalcStandardMMForcesKernel
(
std
::
string
name
)
:
CalcStandardMMForcesKernel
(
name
)
{
ReferenceCalcStandardMMForcesKernel
(
std
::
string
name
,
const
Platform
&
platform
)
:
CalcStandardMMForcesKernel
(
name
,
platform
)
{
}
~
ReferenceCalcStandardMMForcesKernel
();
/**
* Initialize the kernel, setting up the values of all the force field parameters.
*
...
...
@@ -75,6 +77,10 @@ public:
* have been calculated so far. The kernel should add its own forces to the values already in the stream.
*/
void
execute
(
const
Stream
&
positions
,
Stream
&
forces
);
private:
int
numAtoms
,
numBonds
,
numAngles
,
numPeriodicTorsions
,
numRBTorsions
;
int
**
bondIndexArray
,
**
angleIndexArray
,
**
periodicTorsionIndexArray
,
**
rbTorsionIndexArray
;
RealOpenMM
**
bondParamArray
,
**
angleParamArray
,
**
periodicTorsionParamArray
,
**
rbTorsionParamArray
;
};
/**
...
...
@@ -82,7 +88,7 @@ public:
*/
class
ReferenceCalcStandardMMEnergyKernel
:
public
CalcStandardMMEnergyKernel
{
public:
ReferenceCalcStandardMMEnergyKernel
(
std
::
string
name
)
:
CalcStandardMMEnergyKernel
(
name
)
{
ReferenceCalcStandardMMEnergyKernel
(
std
::
string
name
,
const
Platform
&
platform
)
:
CalcStandardMMEnergyKernel
(
name
,
platform
)
{
}
/**
* Initialize the kernel, setting up the values of all the force field parameters.
...
...
@@ -122,7 +128,7 @@ public:
*/
class
ReferenceCalcGBSAOBCForcesKernel
:
public
CalcGBSAOBCForcesKernel
{
public:
ReferenceCalcGBSAOBCForcesKernel
(
std
::
string
name
)
:
CalcGBSAOBCForcesKernel
(
name
)
{
ReferenceCalcGBSAOBCForcesKernel
(
std
::
string
name
,
const
Platform
&
platform
)
:
CalcGBSAOBCForcesKernel
(
name
,
platform
)
{
}
/**
* Initialize the kernel, setting up the values of all the force field parameters.
...
...
@@ -149,7 +155,7 @@ public:
*/
class
ReferenceCalcGBSAOBCEnergyKernel
:
public
CalcGBSAOBCEnergyKernel
{
public:
ReferenceCalcGBSAOBCEnergyKernel
(
std
::
string
name
)
:
CalcGBSAOBCEnergyKernel
(
name
)
{
ReferenceCalcGBSAOBCEnergyKernel
(
std
::
string
name
,
const
Platform
&
platform
)
:
CalcGBSAOBCEnergyKernel
(
name
,
platform
)
{
}
/**
* Initialize the kernel, setting up the values of all the force field parameters.
...
...
@@ -175,7 +181,7 @@ public:
*/
class
ReferenceIntegrateVerletStepKernel
:
public
IntegrateVerletStepKernel
{
public:
ReferenceIntegrateVerletStepKernel
(
std
::
string
name
)
:
IntegrateVerletStepKernel
(
name
)
{
ReferenceIntegrateVerletStepKernel
(
std
::
string
name
,
const
Platform
&
platform
)
:
IntegrateVerletStepKernel
(
name
,
platform
)
{
}
/**
* Initialize the kernel, setting up all parameters related to integrator.
...
...
@@ -202,7 +208,7 @@ public:
*/
class
ReferenceIntegrateLangevinStepKernel
:
public
IntegrateLangevinStepKernel
{
public:
ReferenceIntegrateLangevinStepKernel
(
std
::
string
name
)
:
IntegrateLangevinStepKernel
(
name
)
{
ReferenceIntegrateLangevinStepKernel
(
std
::
string
name
,
const
Platform
&
platform
)
:
IntegrateLangevinStepKernel
(
name
,
platform
)
{
}
/**
* Initialize the kernel, setting up all parameters related to integrator.
...
...
@@ -231,7 +237,7 @@ public:
*/
class
ReferenceIntegrateBrownianStepKernel
:
public
IntegrateBrownianStepKernel
{
public:
ReferenceIntegrateBrownianStepKernel
(
std
::
string
name
)
:
IntegrateBrownianStepKernel
(
name
)
{
ReferenceIntegrateBrownianStepKernel
(
std
::
string
name
,
const
Platform
&
platform
)
:
IntegrateBrownianStepKernel
(
name
,
platform
)
{
}
/**
* Initialize the kernel, setting up all parameters related to integrator.
...
...
@@ -260,7 +266,7 @@ public:
*/
class
ReferenceApplyAndersenThermostatKernel
:
public
ApplyAndersenThermostatKernel
{
public:
ReferenceApplyAndersenThermostatKernel
(
std
::
string
name
)
:
ApplyAndersenThermostatKernel
(
name
)
{
ReferenceApplyAndersenThermostatKernel
(
std
::
string
name
,
const
Platform
&
platform
)
:
ApplyAndersenThermostatKernel
(
name
,
platform
)
{
}
/**
* Initialize the kernel, setting up the values of unchanging parameters.
...
...
@@ -284,7 +290,7 @@ public:
*/
class
ReferenceCalcKineticEnergyKernel
:
public
CalcKineticEnergyKernel
{
public:
ReferenceCalcKineticEnergyKernel
(
std
::
string
name
)
:
CalcKineticEnergyKernel
(
name
)
{
ReferenceCalcKineticEnergyKernel
(
std
::
string
name
,
const
Platform
&
platform
)
:
CalcKineticEnergyKernel
(
name
,
platform
)
{
}
/**
* Initialize the kernel, setting up the atomic masses.
...
...
platforms/reference/src/ReferencePlatform.cpp
View file @
012b28e6
...
...
@@ -32,6 +32,7 @@
#include "ReferencePlatform.h"
#include "ReferenceKernelFactory.h"
#include "ReferenceKernels.h"
#include "SimTKUtilities/SimTKOpenMMRealType.h"
using
namespace
OpenMM
;
...
...
@@ -54,3 +55,11 @@ ReferencePlatform::ReferencePlatform() {
registerKernelFactory
(
ApplyAndersenThermostatKernel
::
Name
(),
factory
);
registerKernelFactory
(
CalcKineticEnergyKernel
::
Name
(),
factory
);
}
bool
ReferencePlatform
::
supportsDoublePrecision
()
const
{
return
(
sizeof
(
RealOpenMM
)
>=
sizeof
(
double
));
}
const
StreamFactory
&
ReferencePlatform
::
getDefaultStreamFactory
()
const
{
return
defaultStreamFactory
;
}
platforms/reference/src/ReferenceStreamFactory.cpp
View file @
012b28e6
...
...
@@ -29,12 +29,14 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "OpenMMException.h"
#include "ReferenceStreamFactory.h"
#include "ReferenceFloatStreamImpl.h"
#include "ReferenceIntStreamImpl.h"
using
namespace
OpenMM
;
StreamImpl
*
ReferenceStreamFactory
::
createStreamImpl
(
std
::
string
name
,
int
size
,
Stream
::
DataType
type
)
const
{
StreamImpl
*
ReferenceStreamFactory
::
createStreamImpl
(
std
::
string
name
,
int
size
,
Stream
::
DataType
type
,
const
Platform
&
platform
)
const
{
switch
(
type
)
{
case
Stream
::
Float
:
case
Stream
::
Float2
:
...
...
@@ -44,9 +46,12 @@ StreamImpl* ReferenceStreamFactory::createStreamImpl(std::string name, int size,
case
Stream
::
Double2
:
case
Stream
::
Double3
:
case
Stream
::
Double4
:
return
new
ReferenceFloatStreamImpl
(
name
,
size
,
type
);
default:
// TODO implement integer streams
return
0
;
return
new
ReferenceFloatStreamImpl
(
name
,
size
,
type
,
platform
);
case
Stream
::
Integer
:
case
Stream
::
Integer2
:
case
Stream
::
Integer3
:
case
Stream
::
Integer4
:
return
new
ReferenceIntStreamImpl
(
name
,
size
,
type
,
platform
);
}
throw
OpenMMException
(
"Tried to create a Stream with an illegal DataType."
);
}
platforms/reference/src/SimTKReference/ReferenceAngleBondIxn.cpp
View file @
012b28e6
...
...
@@ -25,9 +25,9 @@
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "
../SimTKUtilities/
SimTKOpenMMCommon.h"
#include "
../SimTKUtilities/
SimTKOpenMMLog.h"
#include "
../SimTKUtilities/
SimTKOpenMMUtilities.h"
#include "ReferenceAngleBondIxn.h"
#include "ReferenceForce.h"
...
...
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment