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
53539843
Commit
53539843
authored
Jan 05, 2010
by
Peter Eastman
Browse files
Fixed compilation warnings under Windows
parent
c553fe60
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
436 additions
and
433 deletions
+436
-433
platforms/opencl/src/OpenCLCompact.cpp
platforms/opencl/src/OpenCLCompact.cpp
+1
-1
platforms/opencl/src/OpenCLContext.cpp
platforms/opencl/src/OpenCLContext.cpp
+9
-9
platforms/opencl/src/OpenCLContext.h
platforms/opencl/src/OpenCLContext.h
+365
-365
platforms/opencl/src/OpenCLExpressionUtilities.cpp
platforms/opencl/src/OpenCLExpressionUtilities.cpp
+5
-2
platforms/opencl/src/OpenCLIntegrationUtilities.cpp
platforms/opencl/src/OpenCLIntegrationUtilities.cpp
+5
-5
platforms/opencl/src/OpenCLKernels.cpp
platforms/opencl/src/OpenCLKernels.cpp
+38
-38
platforms/opencl/src/OpenCLNonbondedUtilities.cpp
platforms/opencl/src/OpenCLNonbondedUtilities.cpp
+13
-13
No files found.
platforms/opencl/src/OpenCLCompact.cpp
View file @
53539843
...
@@ -42,7 +42,7 @@ OpenCLCompact::~OpenCLCompact() {
...
@@ -42,7 +42,7 @@ OpenCLCompact::~OpenCLCompact() {
void
OpenCLCompact
::
compactStream
(
OpenCLArray
<
cl_uint
>&
dOut
,
OpenCLArray
<
cl_uint
>&
dIn
,
OpenCLArray
<
cl_uint
>&
dValid
,
OpenCLArray
<
cl_uint
>&
numValid
)
{
void
OpenCLCompact
::
compactStream
(
OpenCLArray
<
cl_uint
>&
dOut
,
OpenCLArray
<
cl_uint
>&
dIn
,
OpenCLArray
<
cl_uint
>&
dValid
,
OpenCLArray
<
cl_uint
>&
numValid
)
{
// Figure out # elements per block
// Figure out # elements per block
int
len
=
dIn
.
getSize
();
unsigned
int
len
=
dIn
.
getSize
();
unsigned
int
numBlocks
=
context
.
getNumThreadBlocks
();
unsigned
int
numBlocks
=
context
.
getNumThreadBlocks
();
if
(
numBlocks
*
128
>
len
)
if
(
numBlocks
*
128
>
len
)
numBlocks
=
(
len
+
127
)
/
128
;
numBlocks
=
(
len
+
127
)
/
128
;
...
...
platforms/opencl/src/OpenCLContext.cpp
View file @
53539843
...
@@ -46,11 +46,11 @@ OpenCLContext::OpenCLContext(int numParticles, int deviceIndex) : time(0.0), ste
...
@@ -46,11 +46,11 @@ OpenCLContext::OpenCLContext(int numParticles, int deviceIndex) : time(0.0), ste
context
=
cl
::
Context
(
CL_DEVICE_TYPE_ALL
);
context
=
cl
::
Context
(
CL_DEVICE_TYPE_ALL
);
vector
<
cl
::
Device
>
devices
=
context
.
getInfo
<
CL_CONTEXT_DEVICES
>
();
vector
<
cl
::
Device
>
devices
=
context
.
getInfo
<
CL_CONTEXT_DEVICES
>
();
const
int
minThreadBlockSize
=
32
;
const
int
minThreadBlockSize
=
32
;
if
(
deviceIndex
<
0
||
deviceIndex
>=
devices
.
size
())
{
if
(
deviceIndex
<
0
||
deviceIndex
>=
(
int
)
devices
.
size
())
{
// Try to figure out which device is the fastest.
// Try to figure out which device is the fastest.
int
bestSpeed
=
0
;
int
bestSpeed
=
0
;
for
(
int
i
=
0
;
i
<
devices
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
devices
.
size
();
i
++
)
{
int
maxSize
=
devices
[
i
].
getInfo
<
CL_DEVICE_MAX_WORK_ITEM_SIZES
>
()[
0
];
int
maxSize
=
devices
[
i
].
getInfo
<
CL_DEVICE_MAX_WORK_ITEM_SIZES
>
()[
0
];
int
speed
=
devices
[
i
].
getInfo
<
CL_DEVICE_MAX_COMPUTE_UNITS
>
()
*
devices
[
i
].
getInfo
<
CL_DEVICE_MAX_CLOCK_FREQUENCY
>
();
int
speed
=
devices
[
i
].
getInfo
<
CL_DEVICE_MAX_COMPUTE_UNITS
>
()
*
devices
[
i
].
getInfo
<
CL_DEVICE_MAX_CLOCK_FREQUENCY
>
();
if
(
maxSize
>=
minThreadBlockSize
&&
speed
>
bestSpeed
)
if
(
maxSize
>=
minThreadBlockSize
&&
speed
>
bestSpeed
)
...
@@ -245,12 +245,12 @@ void OpenCLContext::findMoleculeGroups(const System& system) {
...
@@ -245,12 +245,12 @@ void OpenCLContext::findMoleculeGroups(const System& system) {
atomBonds
[
particle1
].
push_back
(
particle2
);
atomBonds
[
particle1
].
push_back
(
particle2
);
atomBonds
[
particle2
].
push_back
(
particle1
);
atomBonds
[
particle2
].
push_back
(
particle1
);
}
}
for
(
int
i
=
0
;
i
<
forces
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
forces
.
size
();
i
++
)
{
for
(
int
j
=
0
;
j
<
forces
[
i
]
->
getNumParticleGroups
();
j
++
)
{
for
(
int
j
=
0
;
j
<
forces
[
i
]
->
getNumParticleGroups
();
j
++
)
{
vector
<
int
>
particles
;
vector
<
int
>
particles
;
forces
[
i
]
->
getParticlesInGroup
(
j
,
particles
);
forces
[
i
]
->
getParticlesInGroup
(
j
,
particles
);
for
(
int
k
=
0
;
k
<
particles
.
size
();
k
++
)
for
(
int
k
=
0
;
k
<
(
int
)
particles
.
size
();
k
++
)
for
(
int
m
=
0
;
m
<
particles
.
size
();
m
++
)
for
(
int
m
=
0
;
m
<
(
int
)
particles
.
size
();
m
++
)
if
(
k
!=
m
)
if
(
k
!=
m
)
atomBonds
[
particles
[
k
]].
push_back
(
particles
[
m
]);
atomBonds
[
particles
[
k
]].
push_back
(
particles
[
m
]);
}
}
...
@@ -280,7 +280,7 @@ void OpenCLContext::findMoleculeGroups(const System& system) {
...
@@ -280,7 +280,7 @@ void OpenCLContext::findMoleculeGroups(const System& system) {
system
.
getConstraintParameters
(
i
,
particle1
,
particle2
,
distance
);
system
.
getConstraintParameters
(
i
,
particle1
,
particle2
,
distance
);
molecules
[
atomMolecule
[
particle1
]].
constraints
.
push_back
(
i
);
molecules
[
atomMolecule
[
particle1
]].
constraints
.
push_back
(
i
);
}
}
for
(
int
i
=
0
;
i
<
forces
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
(
int
)
forces
.
size
();
i
++
)
for
(
int
j
=
0
;
j
<
forces
[
i
]
->
getNumParticleGroups
();
j
++
)
{
for
(
int
j
=
0
;
j
<
forces
[
i
]
->
getNumParticleGroups
();
j
++
)
{
vector
<
int
>
particles
;
vector
<
int
>
particles
;
forces
[
i
]
->
getParticlesInGroup
(
j
,
particles
);
forces
[
i
]
->
getParticlesInGroup
(
j
,
particles
);
...
@@ -307,7 +307,7 @@ void OpenCLContext::findMoleculeGroups(const System& system) {
...
@@ -307,7 +307,7 @@ void OpenCLContext::findMoleculeGroups(const System& system) {
for
(
int
i
=
0
;
i
<
(
int
)
mol
.
atoms
.
size
()
&&
identical
;
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
mol
.
atoms
.
size
()
&&
identical
;
i
++
)
{
if
(
mol
.
atoms
[
i
]
!=
mol2
.
atoms
[
i
]
-
atomOffset
||
system
.
getParticleMass
(
mol
.
atoms
[
i
])
!=
system
.
getParticleMass
(
mol2
.
atoms
[
i
]))
if
(
mol
.
atoms
[
i
]
!=
mol2
.
atoms
[
i
]
-
atomOffset
||
system
.
getParticleMass
(
mol
.
atoms
[
i
])
!=
system
.
getParticleMass
(
mol2
.
atoms
[
i
]))
identical
=
false
;
identical
=
false
;
for
(
int
k
=
0
;
k
<
forces
.
size
();
k
++
)
for
(
int
k
=
0
;
k
<
(
int
)
forces
.
size
();
k
++
)
if
(
!
forces
[
k
]
->
areParticlesIdentical
(
mol
.
atoms
[
i
],
mol2
.
atoms
[
i
]))
if
(
!
forces
[
k
]
->
areParticlesIdentical
(
mol
.
atoms
[
i
],
mol2
.
atoms
[
i
]))
identical
=
false
;
identical
=
false
;
}
}
...
@@ -325,10 +325,10 @@ void OpenCLContext::findMoleculeGroups(const System& system) {
...
@@ -325,10 +325,10 @@ void OpenCLContext::findMoleculeGroups(const System& system) {
// See if the force groups are identical.
// See if the force groups are identical.
for
(
int
i
=
0
;
i
<
forces
.
size
()
&&
identical
;
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
forces
.
size
()
&&
identical
;
i
++
)
{
if
(
mol
.
groups
[
i
].
size
()
!=
mol2
.
groups
[
i
].
size
())
if
(
mol
.
groups
[
i
].
size
()
!=
mol2
.
groups
[
i
].
size
())
identical
=
false
;
identical
=
false
;
for
(
int
k
=
0
;
k
<
mol
.
groups
[
i
].
size
()
&&
identical
;
k
++
)
for
(
int
k
=
0
;
k
<
(
int
)
mol
.
groups
[
i
].
size
()
&&
identical
;
k
++
)
if
(
!
forces
[
i
]
->
areGroupsIdentical
(
mol
.
groups
[
i
][
k
],
mol2
.
groups
[
i
][
k
]))
if
(
!
forces
[
i
]
->
areGroupsIdentical
(
mol
.
groups
[
i
][
k
],
mol2
.
groups
[
i
][
k
]))
identical
=
false
;
identical
=
false
;
}
}
...
...
platforms/opencl/src/OpenCLContext.h
View file @
53539843
#ifndef OPENMM_OPENCLCONTEXT_H_
#ifndef OPENMM_OPENCLCONTEXT_H_
#define OPENMM_OPENCLCONTEXT_H_
#define OPENMM_OPENCLCONTEXT_H_
/* -------------------------------------------------------------------------- *
/* -------------------------------------------------------------------------- *
* OpenMM *
* OpenMM *
* -------------------------------------------------------------------------- *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* *
* Portions copyright (c) 2009 Stanford University and the Authors. *
* Portions copyright (c) 2009 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
* This program is free software: you can redistribute it and/or modify *
* 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 *
* 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 *
* by the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* (at your option) any later version. *
* *
* *
* This program is distributed in the hope that it will be useful, *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* GNU Lesser General Public License for more details. *
* *
* *
* You should have received a copy of the GNU Lesser General Public License *
* 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/>. *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* -------------------------------------------------------------------------- */
* -------------------------------------------------------------------------- */
#include <map>
#include <map>
#include <string>
#include <string>
#define __CL_ENABLE_EXCEPTIONS
#define __CL_ENABLE_EXCEPTIONS
#ifdef _MSC_VER
#ifdef _MSC_VER
// Prevent Windows from defining macros that interfere with other code.
// Prevent Windows from defining macros that interfere with other code.
#define NOMINMAX
#define NOMINMAX
#endif
#endif
#include <cl.hpp>
#include <cl.hpp>
namespace
OpenMM
{
namespace
OpenMM
{
template
<
class
T
>
template
<
class
T
>
class
OpenCLArray
;
class
OpenCLArray
;
class
OpenCLForceInfo
;
class
OpenCLForceInfo
;
class
OpenCLIntegrationUtilities
;
class
OpenCLIntegrationUtilities
;
class
OpenCLNonbondedUtilities
;
class
OpenCLNonbondedUtilities
;
class
System
;
class
System
;
/**
/**
* We can't use predefined vector types like cl_float4, since different OpenCL implementations currently define
* We can't use predefined vector types like cl_float4, since different OpenCL implementations currently define
* them in incompatible ways. Hopefully that will be fixed in the future. In the mean time, we define our own
* them in incompatible ways. Hopefully that will be fixed in the future. In the mean time, we define our own
* types to represent them on the host.
* types to represent them on the host.
*/
*/
struct
mm_float2
{
struct
mm_float2
{
cl_float
x
,
y
;
cl_float
x
,
y
;
mm_float2
()
{
mm_float2
()
{
}
}
mm_float2
(
cl_float
x
,
cl_float
y
)
:
x
(
x
),
y
(
y
)
{
mm_float2
(
cl_float
x
,
cl_float
y
)
:
x
(
x
),
y
(
y
)
{
}
}
};
};
struct
mm_float4
{
struct
mm_float4
{
cl_float
x
,
y
,
z
,
w
;
cl_float
x
,
y
,
z
,
w
;
mm_float4
()
{
mm_float4
()
{
}
}
mm_float4
(
cl_float
x
,
cl_float
y
,
cl_float
z
,
cl_float
w
)
:
x
(
x
),
y
(
y
),
z
(
z
),
w
(
w
)
{
mm_float4
(
cl_float
x
,
cl_float
y
,
cl_float
z
,
cl_float
w
)
:
x
(
x
),
y
(
y
),
z
(
z
),
w
(
w
)
{
}
}
};
};
struct
mm_float8
{
struct
mm_float8
{
cl_float
s0
,
s1
,
s2
,
s3
,
s4
,
s5
,
s6
,
s7
;
cl_float
s0
,
s1
,
s2
,
s3
,
s4
,
s5
,
s6
,
s7
;
mm_float8
()
{
mm_float8
()
{
}
}
mm_float8
(
cl_float
s0
,
cl_float
s1
,
cl_float
s2
,
cl_float
s3
,
cl_float
s4
,
cl_float
s5
,
cl_float
s6
,
cl_float
s7
)
:
mm_float8
(
cl_float
s0
,
cl_float
s1
,
cl_float
s2
,
cl_float
s3
,
cl_float
s4
,
cl_float
s5
,
cl_float
s6
,
cl_float
s7
)
:
s0
(
s0
),
s1
(
s1
),
s2
(
s2
),
s3
(
s3
),
s4
(
s4
),
s5
(
s5
),
s6
(
s6
),
s7
(
s7
)
{
s0
(
s0
),
s1
(
s1
),
s2
(
s2
),
s3
(
s3
),
s4
(
s4
),
s5
(
s5
),
s6
(
s6
),
s7
(
s7
)
{
}
}
};
};
struct
mm_int2
{
struct
mm_int2
{
cl_int
x
,
y
;
cl_int
x
,
y
;
mm_int2
()
{
mm_int2
()
{
}
}
mm_int2
(
cl_int
x
,
cl_int
y
)
:
x
(
x
),
y
(
y
)
{
mm_int2
(
cl_int
x
,
cl_int
y
)
:
x
(
x
),
y
(
y
)
{
}
}
};
};
struct
mm_int4
{
struct
mm_int4
{
cl_int
x
,
y
,
z
,
w
;
cl_int
x
,
y
,
z
,
w
;
mm_int4
()
{
mm_int4
()
{
}
}
mm_int4
(
cl_int
x
,
cl_int
y
,
cl_int
z
,
cl_int
w
)
:
x
(
x
),
y
(
y
),
z
(
z
),
w
(
w
)
{
mm_int4
(
cl_int
x
,
cl_int
y
,
cl_int
z
,
cl_int
w
)
:
x
(
x
),
y
(
y
),
z
(
z
),
w
(
w
)
{
}
}
};
};
struct
mm_int8
{
struct
mm_int8
{
cl_int
s0
,
s1
,
s2
,
s3
,
s4
,
s5
,
s6
,
s7
;
cl_int
s0
,
s1
,
s2
,
s3
,
s4
,
s5
,
s6
,
s7
;
mm_int8
()
{
mm_int8
()
{
}
}
mm_int8
(
cl_int
s0
,
cl_int
s1
,
cl_int
s2
,
cl_int
s3
,
cl_int
s4
,
cl_int
s5
,
cl_int
s6
,
cl_int
s7
)
:
mm_int8
(
cl_int
s0
,
cl_int
s1
,
cl_int
s2
,
cl_int
s3
,
cl_int
s4
,
cl_int
s5
,
cl_int
s6
,
cl_int
s7
)
:
s0
(
s0
),
s1
(
s1
),
s2
(
s2
),
s3
(
s3
),
s4
(
s4
),
s5
(
s5
),
s6
(
s6
),
s7
(
s7
)
{
s0
(
s0
),
s1
(
s1
),
s2
(
s2
),
s3
(
s3
),
s4
(
s4
),
s5
(
s5
),
s6
(
s6
),
s7
(
s7
)
{
}
}
};
};
/**
/**
* This class contains the information associated with a Context by the OpenCL Platform.
* This class contains the information associated with a Context by the OpenCL Platform.
*/
*/
class
OpenCLContext
{
class
OpenCLContext
{
public:
public:
static
const
int
ThreadBlockSize
=
64
;
static
const
int
ThreadBlockSize
=
64
;
static
const
int
TileSize
=
32
;
static
const
int
TileSize
=
32
;
OpenCLContext
(
int
numParticles
,
int
deviceIndex
);
OpenCLContext
(
int
numParticles
,
int
deviceIndex
);
~
OpenCLContext
();
~
OpenCLContext
();
/**
/**
* This is called to initialize internal data structures after all Forces in the system
* This is called to initialize internal data structures after all Forces in the system
* have been initialized.
* have been initialized.
*/
*/
void
initialize
(
const
System
&
system
);
void
initialize
(
const
System
&
system
);
/**
/**
* Add an OpenCLForce to this context.
* Add an OpenCLForce to this context.
*/
*/
void
addForce
(
OpenCLForceInfo
*
force
);
void
addForce
(
OpenCLForceInfo
*
force
);
/**
/**
* Get the cl::Context associated with this object.
* Get the cl::Context associated with this object.
*/
*/
cl
::
Context
&
getContext
()
{
cl
::
Context
&
getContext
()
{
return
context
;
return
context
;
}
}
/**
/**
* Get the cl::Device associated with this object.
* Get the cl::Device associated with this object.
*/
*/
cl
::
Device
&
getDevice
()
{
cl
::
Device
&
getDevice
()
{
return
device
;
return
device
;
}
}
/**
/**
* Get the index of the cl::Device associated with this object.
* Get the index of the cl::Device associated with this object.
*/
*/
int
getDeviceIndex
()
{
int
getDeviceIndex
()
{
return
deviceIndex
;
return
deviceIndex
;
}
}
/**
/**
* Get the cl::CommandQueue associated with this object.
* Get the cl::CommandQueue associated with this object.
*/
*/
cl
::
CommandQueue
&
getQueue
()
{
cl
::
CommandQueue
&
getQueue
()
{
return
queue
;
return
queue
;
}
}
/**
/**
* Get the array which contains the position and charge of each atom.
* Get the array which contains the position and charge of each atom.
*/
*/
OpenCLArray
<
mm_float4
>&
getPosq
()
{
OpenCLArray
<
mm_float4
>&
getPosq
()
{
return
*
posq
;
return
*
posq
;
}
}
/**
/**
* Get the array which contains the velocity and inverse mass of each atom.
* Get the array which contains the velocity and inverse mass of each atom.
*/
*/
OpenCLArray
<
mm_float4
>&
getVelm
()
{
OpenCLArray
<
mm_float4
>&
getVelm
()
{
return
*
velm
;
return
*
velm
;
}
}
/**
/**
* Get the array which contains the force on each atom.
* Get the array which contains the force on each atom.
*/
*/
OpenCLArray
<
mm_float4
>&
getForce
()
{
OpenCLArray
<
mm_float4
>&
getForce
()
{
return
*
force
;
return
*
force
;
}
}
/**
/**
* Get the array which contains the buffers in which forces are computed.
* Get the array which contains the buffers in which forces are computed.
*/
*/
OpenCLArray
<
mm_float4
>&
getForceBuffers
()
{
OpenCLArray
<
mm_float4
>&
getForceBuffers
()
{
return
*
forceBuffers
;
return
*
forceBuffers
;
}
}
/**
/**
* Get the array which contains the buffer in which energy is computed.
* Get the array which contains the buffer in which energy is computed.
*/
*/
OpenCLArray
<
cl_float
>&
getEnergyBuffer
()
{
OpenCLArray
<
cl_float
>&
getEnergyBuffer
()
{
return
*
energyBuffer
;
return
*
energyBuffer
;
}
}
/**
/**
* Get the array which contains the index of each atom.
* Get the array which contains the index of each atom.
*/
*/
OpenCLArray
<
cl_int
>&
getAtomIndex
()
{
OpenCLArray
<
cl_int
>&
getAtomIndex
()
{
return
*
atomIndex
;
return
*
atomIndex
;
}
}
/**
/**
* Get the number of cells by which the positions are offset.
* Get the number of cells by which the positions are offset.
*/
*/
std
::
vector
<
mm_int4
>&
getPosCellOffsets
()
{
std
::
vector
<
mm_int4
>&
getPosCellOffsets
()
{
return
posCellOffsets
;
return
posCellOffsets
;
}
}
/**
/**
* Load OpenCL source code from a file in the kernels directory.
* Load OpenCL source code from a file in the kernels directory.
*/
*/
std
::
string
loadSourceFromFile
(
const
std
::
string
&
filename
)
const
;
std
::
string
loadSourceFromFile
(
const
std
::
string
&
filename
)
const
;
/**
/**
* Load OpenCL source code from a file in the kernels directory.
* Load OpenCL source code from a file in the kernels directory.
*
*
* @param filename the file to load
* @param filename the file to load
* @param replacements a set of strings that should be replaced with new strings wherever they appear in the
* @param replacements a set of strings that should be replaced with new strings wherever they appear in the
*/
*/
std
::
string
loadSourceFromFile
(
const
std
::
string
&
filename
,
const
std
::
map
<
std
::
string
,
std
::
string
>&
replacements
)
const
;
std
::
string
loadSourceFromFile
(
const
std
::
string
&
filename
,
const
std
::
map
<
std
::
string
,
std
::
string
>&
replacements
)
const
;
/**
/**
* Create an OpenCL Program from source code.
* Create an OpenCL Program from source code.
*/
*/
cl
::
Program
createProgram
(
const
std
::
string
source
);
cl
::
Program
createProgram
(
const
std
::
string
source
);
/**
/**
* Create an OpenCL Program from source code.
* Create an OpenCL Program from source code.
*
*
* @param defines a set of preprocessor definitions (name, value) to define when compiling the program
* @param defines a set of preprocessor definitions (name, value) to define when compiling the program
*/
*/
cl
::
Program
createProgram
(
const
std
::
string
source
,
const
std
::
map
<
std
::
string
,
std
::
string
>&
defines
);
cl
::
Program
createProgram
(
const
std
::
string
source
,
const
std
::
map
<
std
::
string
,
std
::
string
>&
defines
);
/**
/**
* Execute a kernel.
* Execute a kernel.
*
*
* @param kernel the kernel to execute
* @param kernel the kernel to execute
* @param workUnits the maximum number of work units that should be used
* @param workUnits the maximum number of work units that should be used
* @param blockSize the size of each thread block to use
* @param blockSize the size of each thread block to use
*/
*/
void
executeKernel
(
cl
::
Kernel
&
kernel
,
int
workUnits
,
int
blockSize
=
-
1
);
void
executeKernel
(
cl
::
Kernel
&
kernel
,
int
workUnits
,
int
blockSize
=
-
1
);
/**
/**
* Set all elements of an array to 0.
* Set all elements of an array to 0.
*/
*/
void
clearBuffer
(
OpenCLArray
<
float
>&
array
);
void
clearBuffer
(
OpenCLArray
<
float
>&
array
);
/**
/**
* Set all elements of an array to 0.
* Set all elements of an array to 0.
*/
*/
void
clearBuffer
(
OpenCLArray
<
mm_float4
>&
array
);
void
clearBuffer
(
OpenCLArray
<
mm_float4
>&
array
);
/**
/**
* Set all elements of an array to 0.
* Set all elements of an array to 0.
*
*
* @param buffer the Buffer to clear
* @param buffer the Buffer to clear
* @param size the number of float elements in the buffer
* @param size the number of float elements in the buffer
*/
*/
void
clearBuffer
(
cl
::
Buffer
&
buffer
,
int
size
);
void
clearBuffer
(
cl
::
Buffer
&
buffer
,
int
size
);
/**
/**
* Given a collection of buffers packed into an array, sum them and store
* Given a collection of buffers packed into an array, sum them and store
* the sum in the first buffer.
* the sum in the first buffer.
*
*
* @param array the array containing the buffers to reduce
* @param array the array containing the buffers to reduce
* @param numBuffers the number of buffers packed into the array
* @param numBuffers the number of buffers packed into the array
*/
*/
void
reduceBuffer
(
OpenCLArray
<
mm_float4
>&
array
,
int
numBuffers
);
void
reduceBuffer
(
OpenCLArray
<
mm_float4
>&
array
,
int
numBuffers
);
/**
/**
* Get the current simulation time.
* Get the current simulation time.
*/
*/
double
getTime
()
{
double
getTime
()
{
return
time
;
return
time
;
}
}
/**
/**
* Set the current simulation time.
* Set the current simulation time.
*/
*/
void
setTime
(
double
t
)
{
void
setTime
(
double
t
)
{
time
=
t
;
time
=
t
;
}
}
/**
/**
* Get the number of integration steps that have been taken.
* Get the number of integration steps that have been taken.
*/
*/
int
getStepCount
()
{
int
getStepCount
()
{
return
stepCount
;
return
stepCount
;
}
}
/**
/**
* Set the number of integration steps that have been taken.
* Set the number of integration steps that have been taken.
*/
*/
void
setStepCount
(
int
steps
)
{
void
setStepCount
(
int
steps
)
{
stepCount
=
steps
;
stepCount
=
steps
;
}
}
/**
/**
* Get the number of times forces or energy has been computed.
* Get the number of times forces or energy has been computed.
*/
*/
int
getComputeForceCount
()
{
int
getComputeForceCount
()
{
return
computeForceCount
;
return
computeForceCount
;
}
}
/**
/**
* Set the number of times forces or energy has been computed.
* Set the number of times forces or energy has been computed.
*/
*/
void
setComputeForceCount
(
int
count
)
{
void
setComputeForceCount
(
int
count
)
{
computeForceCount
=
count
;
computeForceCount
=
count
;
}
}
/**
/**
* Get the number of atoms.
* Get the number of atoms.
*/
*/
int
getNumAtoms
()
const
{
int
getNumAtoms
()
const
{
return
numAtoms
;
return
numAtoms
;
}
}
/**
/**
* Get the number of atoms, rounded up to a multiple of TileSize. This is the actual size of
* Get the number of atoms, rounded up to a multiple of TileSize. This is the actual size of
* most arrays with one element per atom.
* most arrays with one element per atom.
*/
*/
int
getPaddedNumAtoms
()
const
{
int
getPaddedNumAtoms
()
const
{
return
paddedNumAtoms
;
return
paddedNumAtoms
;
}
}
/**
/**
* Get the number of blocks of TileSize atoms.
* Get the number of blocks of TileSize atoms.
*/
*/
int
getNumAtomBlocks
()
const
{
int
getNumAtomBlocks
()
const
{
return
numAtomBlocks
;
return
numAtomBlocks
;
}
}
/**
/**
* Get the standard number of thread blocks to use when executing kernels.
* Get the standard number of thread blocks to use when executing kernels.
*/
*/
int
getNumThreadBlocks
()
const
{
int
getNumThreadBlocks
()
const
{
return
numThreadBlocks
;
return
numThreadBlocks
;
}
}
/**
/**
* Get the number of force buffers.
* Get the number of force buffers.
*/
*/
int
getNumForceBuffers
()
const
{
int
getNumForceBuffers
()
const
{
return
numForceBuffers
;
return
numForceBuffers
;
}
}
/**
/**
* Get the SIMD width of the device being used.
* Get the SIMD width of the device being used.
*/
*/
int
getSIMDWidth
()
const
{
int
getSIMDWidth
()
const
{
return
simdWidth
;
return
simdWidth
;
}
}
/**
/**
* Get the OpenCLIntegrationUtilities for this context.
* Get the OpenCLIntegrationUtilities for this context.
*/
*/
OpenCLIntegrationUtilities
&
getIntegrationUtilities
()
{
OpenCLIntegrationUtilities
&
getIntegrationUtilities
()
{
return
*
integration
;
return
*
integration
;
}
}
/**
/**
* Get the OpenCLNonbondedUtilities for this context.
* Get the OpenCLNonbondedUtilities for this context.
*/
*/
OpenCLNonbondedUtilities
&
getNonbondedUtilities
()
{
OpenCLNonbondedUtilities
&
getNonbondedUtilities
()
{
return
*
nonbonded
;
return
*
nonbonded
;
}
}
/**
/**
* Reorder the internal arrays of atoms to try to keep spatially contiguous atoms close
* Reorder the internal arrays of atoms to try to keep spatially contiguous atoms close
* together in the arrays.
* together in the arrays.
*/
*/
void
reorderAtoms
();
void
reorderAtoms
();
private:
private:
struct
Molecule
;
struct
Molecule
;
struct
MoleculeGroup
;
struct
MoleculeGroup
;
void
findMoleculeGroups
(
const
System
&
system
);
void
findMoleculeGroups
(
const
System
&
system
);
static
void
tagAtomsInMolecule
(
int
atom
,
int
molecule
,
std
::
vector
<
int
>&
atomMolecule
,
std
::
vector
<
std
::
vector
<
int
>
>&
atomBonds
);
static
void
tagAtomsInMolecule
(
int
atom
,
int
molecule
,
std
::
vector
<
int
>&
atomMolecule
,
std
::
vector
<
std
::
vector
<
int
>
>&
atomBonds
);
double
time
;
double
time
;
int
deviceIndex
;
int
deviceIndex
;
int
stepCount
;
int
stepCount
;
int
computeForceCount
;
int
computeForceCount
;
int
numAtoms
;
int
numAtoms
;
int
paddedNumAtoms
;
int
paddedNumAtoms
;
int
numAtomBlocks
;
int
numAtomBlocks
;
int
numThreadBlocks
;
int
numThreadBlocks
;
int
numForceBuffers
;
int
numForceBuffers
;
int
simdWidth
;
int
simdWidth
;
std
::
string
compilationOptions
;
std
::
string
compilationOptions
;
cl
::
Context
context
;
cl
::
Context
context
;
cl
::
Device
device
;
cl
::
Device
device
;
cl
::
CommandQueue
queue
;
cl
::
CommandQueue
queue
;
cl
::
Program
utilities
;
cl
::
Program
utilities
;
cl
::
Kernel
clearBufferKernel
;
cl
::
Kernel
clearBufferKernel
;
cl
::
Kernel
reduceFloat4Kernel
;
cl
::
Kernel
reduceFloat4Kernel
;
std
::
vector
<
OpenCLForceInfo
*>
forces
;
std
::
vector
<
OpenCLForceInfo
*>
forces
;
std
::
vector
<
MoleculeGroup
>
moleculeGroups
;
std
::
vector
<
MoleculeGroup
>
moleculeGroups
;
std
::
vector
<
mm_int4
>
posCellOffsets
;
std
::
vector
<
mm_int4
>
posCellOffsets
;
OpenCLArray
<
mm_float4
>*
posq
;
OpenCLArray
<
mm_float4
>*
posq
;
OpenCLArray
<
mm_float4
>*
velm
;
OpenCLArray
<
mm_float4
>*
velm
;
OpenCLArray
<
mm_float4
>*
force
;
OpenCLArray
<
mm_float4
>*
force
;
OpenCLArray
<
mm_float4
>*
forceBuffers
;
OpenCLArray
<
mm_float4
>*
forceBuffers
;
OpenCLArray
<
cl_float
>*
energyBuffer
;
OpenCLArray
<
cl_float
>*
energyBuffer
;
OpenCLArray
<
cl_int
>*
atomIndex
;
OpenCLArray
<
cl_int
>*
atomIndex
;
OpenCLIntegrationUtilities
*
integration
;
OpenCLIntegrationUtilities
*
integration
;
OpenCLNonbondedUtilities
*
nonbonded
;
OpenCLNonbondedUtilities
*
nonbonded
;
};
};
struct
OpenCLContext
::
MoleculeGroup
{
struct
OpenCLContext
::
MoleculeGroup
{
std
::
vector
<
int
>
atoms
;
std
::
vector
<
int
>
atoms
;
std
::
vector
<
int
>
instances
;
std
::
vector
<
int
>
instances
;
};
};
}
// namespace OpenMM
}
// namespace OpenMM
#endif
/*OPENMM_OPENCLCONTEXT_H_*/
#endif
/*OPENMM_OPENCLCONTEXT_H_*/
platforms/opencl/src/OpenCLExpressionUtilities.cpp
View file @
53539843
...
@@ -260,7 +260,7 @@ void OpenCLExpressionUtilities::processExpression(stringstream& out, const Expre
...
@@ -260,7 +260,7 @@ void OpenCLExpressionUtilities::processExpression(stringstream& out, const Expre
bool
done
=
false
;
bool
done
=
false
;
while
(
!
done
)
{
while
(
!
done
)
{
done
=
true
;
done
=
true
;
for
(
int
i
=
0
;
i
<
exponents
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
exponents
.
size
();
i
++
)
{
if
(
exponents
[
i
]
%
2
==
1
)
{
if
(
exponents
[
i
]
%
2
==
1
)
{
if
(
!
hasAssigned
[
i
])
if
(
!
hasAssigned
[
i
])
out
<<
names
[
i
]
<<
" = multiplier;
\n
"
;
out
<<
names
[
i
]
<<
" = multiplier;
\n
"
;
...
@@ -313,7 +313,10 @@ void OpenCLExpressionUtilities::findRelatedTabulatedFunctions(const ExpressionTr
...
@@ -313,7 +313,10 @@ void OpenCLExpressionUtilities::findRelatedTabulatedFunctions(const ExpressionTr
void
OpenCLExpressionUtilities
::
findRelatedPowers
(
const
ExpressionTreeNode
&
node
,
const
ExpressionTreeNode
&
searchNode
,
map
<
int
,
const
ExpressionTreeNode
*>&
powers
)
{
void
OpenCLExpressionUtilities
::
findRelatedPowers
(
const
ExpressionTreeNode
&
node
,
const
ExpressionTreeNode
&
searchNode
,
map
<
int
,
const
ExpressionTreeNode
*>&
powers
)
{
if
(
searchNode
.
getOperation
().
getId
()
==
Operation
::
POWER_CONSTANT
&&
node
.
getChildren
()[
0
]
==
searchNode
.
getChildren
()[
0
])
{
if
(
searchNode
.
getOperation
().
getId
()
==
Operation
::
POWER_CONSTANT
&&
node
.
getChildren
()[
0
]
==
searchNode
.
getChildren
()[
0
])
{
int
power
=
dynamic_cast
<
const
Operation
::
PowerConstant
*>
(
&
searchNode
.
getOperation
())
->
getValue
();
double
realPower
=
dynamic_cast
<
const
Operation
::
PowerConstant
*>
(
&
searchNode
.
getOperation
())
->
getValue
();
int
power
=
(
int
)
realPower
;
if
(
power
!=
realPower
)
return
;
// We are only interested in integer powers.
if
(
powers
.
find
(
power
)
!=
powers
.
end
())
if
(
powers
.
find
(
power
)
!=
powers
.
end
())
return
;
// This power is already in the map.
return
;
// This power is already in the map.
if
(
powers
.
begin
()
->
first
*
power
<
0
)
if
(
powers
.
begin
()
->
first
*
power
<
0
)
...
...
platforms/opencl/src/OpenCLIntegrationUtilities.cpp
View file @
53539843
...
@@ -103,8 +103,8 @@ OpenCLIntegrationUtilities::OpenCLIntegrationUtilities(OpenCLContext& context, c
...
@@ -103,8 +103,8 @@ OpenCLIntegrationUtilities::OpenCLIntegrationUtilities(OpenCLContext& context, c
vector
<
map
<
int
,
float
>
>
settleConstraints
(
system
.
getNumParticles
());
vector
<
map
<
int
,
float
>
>
settleConstraints
(
system
.
getNumParticles
());
for
(
int
i
=
0
;
i
<
(
int
)
atom1
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
atom1
.
size
();
i
++
)
{
if
(
constraintCount
[
atom1
[
i
]]
==
2
&&
constraintCount
[
atom2
[
i
]]
==
2
)
{
if
(
constraintCount
[
atom1
[
i
]]
==
2
&&
constraintCount
[
atom2
[
i
]]
==
2
)
{
settleConstraints
[
atom1
[
i
]][
atom2
[
i
]]
=
distance
[
i
];
settleConstraints
[
atom1
[
i
]][
atom2
[
i
]]
=
(
float
)
distance
[
i
];
settleConstraints
[
atom2
[
i
]][
atom1
[
i
]]
=
distance
[
i
];
settleConstraints
[
atom2
[
i
]][
atom1
[
i
]]
=
(
float
)
distance
[
i
];
}
}
}
}
...
@@ -232,7 +232,7 @@ OpenCLIntegrationUtilities::OpenCLIntegrationUtilities(OpenCLContext& context, c
...
@@ -232,7 +232,7 @@ OpenCLIntegrationUtilities::OpenCLIntegrationUtilities(OpenCLContext& context, c
if
(
!
cluster
.
valid
)
if
(
!
cluster
.
valid
)
continue
;
continue
;
atoms
.
push_back
(
mm_int4
(
cluster
.
centralID
,
cluster
.
peripheralID
[
0
],
(
cluster
.
size
>
1
?
cluster
.
peripheralID
[
1
]
:
-
1
),
(
cluster
.
size
>
2
?
cluster
.
peripheralID
[
2
]
:
-
1
)));
atoms
.
push_back
(
mm_int4
(
cluster
.
centralID
,
cluster
.
peripheralID
[
0
],
(
cluster
.
size
>
1
?
cluster
.
peripheralID
[
1
]
:
-
1
),
(
cluster
.
size
>
2
?
cluster
.
peripheralID
[
2
]
:
-
1
)));
params
.
push_back
(
mm_float4
(
cluster
.
centralInvMass
,
0.5
f
/
(
cluster
.
centralInvMass
+
cluster
.
peripheralInvMass
),
cluster
.
distance
*
cluster
.
distance
,
cluster
.
peripheralInvMass
));
params
.
push_back
(
mm_float4
(
(
cl_float
)
cluster
.
centralInvMass
,
(
cl_float
)
(
0.5
/
(
cluster
.
centralInvMass
+
cluster
.
peripheralInvMass
)
)
,
(
cl_float
)
(
cluster
.
distance
*
cluster
.
distance
),
(
cl_float
)
cluster
.
peripheralInvMass
));
isShakeAtom
[
cluster
.
centralID
]
=
true
;
isShakeAtom
[
cluster
.
centralID
]
=
true
;
isShakeAtom
[
cluster
.
peripheralID
[
0
]]
=
true
;
isShakeAtom
[
cluster
.
peripheralID
[
0
]]
=
true
;
if
(
cluster
.
size
>
1
)
if
(
cluster
.
size
>
1
)
...
@@ -270,7 +270,7 @@ OpenCLIntegrationUtilities::~OpenCLIntegrationUtilities() {
...
@@ -270,7 +270,7 @@ OpenCLIntegrationUtilities::~OpenCLIntegrationUtilities() {
void
OpenCLIntegrationUtilities
::
applyConstraints
(
double
tol
)
{
void
OpenCLIntegrationUtilities
::
applyConstraints
(
double
tol
)
{
if
(
settleAtoms
!=
NULL
)
{
if
(
settleAtoms
!=
NULL
)
{
settleKernel
.
setArg
<
cl_int
>
(
0
,
settleAtoms
->
getSize
());
settleKernel
.
setArg
<
cl_int
>
(
0
,
settleAtoms
->
getSize
());
settleKernel
.
setArg
<
cl_float
>
(
1
,
tol
);
settleKernel
.
setArg
<
cl_float
>
(
1
,
(
cl_float
)
tol
);
settleKernel
.
setArg
<
cl
::
Buffer
>
(
2
,
context
.
getPosq
().
getDeviceBuffer
());
settleKernel
.
setArg
<
cl
::
Buffer
>
(
2
,
context
.
getPosq
().
getDeviceBuffer
());
settleKernel
.
setArg
<
cl
::
Buffer
>
(
3
,
posDelta
->
getDeviceBuffer
());
settleKernel
.
setArg
<
cl
::
Buffer
>
(
3
,
posDelta
->
getDeviceBuffer
());
settleKernel
.
setArg
<
cl
::
Buffer
>
(
4
,
posDelta
->
getDeviceBuffer
());
settleKernel
.
setArg
<
cl
::
Buffer
>
(
4
,
posDelta
->
getDeviceBuffer
());
...
@@ -281,7 +281,7 @@ void OpenCLIntegrationUtilities::applyConstraints(double tol) {
...
@@ -281,7 +281,7 @@ void OpenCLIntegrationUtilities::applyConstraints(double tol) {
}
}
if
(
shakeAtoms
!=
NULL
)
{
if
(
shakeAtoms
!=
NULL
)
{
shakeKernel
.
setArg
<
cl_int
>
(
0
,
shakeAtoms
->
getSize
());
shakeKernel
.
setArg
<
cl_int
>
(
0
,
shakeAtoms
->
getSize
());
shakeKernel
.
setArg
<
cl_float
>
(
1
,
tol
);
shakeKernel
.
setArg
<
cl_float
>
(
1
,
(
cl_float
)
tol
);
shakeKernel
.
setArg
<
cl
::
Buffer
>
(
2
,
context
.
getPosq
().
getDeviceBuffer
());
shakeKernel
.
setArg
<
cl
::
Buffer
>
(
2
,
context
.
getPosq
().
getDeviceBuffer
());
shakeKernel
.
setArg
<
cl
::
Buffer
>
(
3
,
posDelta
->
getDeviceBuffer
());
shakeKernel
.
setArg
<
cl
::
Buffer
>
(
3
,
posDelta
->
getDeviceBuffer
());
shakeKernel
.
setArg
<
cl
::
Buffer
>
(
4
,
posDelta
->
getDeviceBuffer
());
shakeKernel
.
setArg
<
cl
::
Buffer
>
(
4
,
posDelta
->
getDeviceBuffer
());
...
...
platforms/opencl/src/OpenCLKernels.cpp
View file @
53539843
...
@@ -120,12 +120,12 @@ void OpenCLUpdateStateDataKernel::setPositions(ContextImpl& context, const std::
...
@@ -120,12 +120,12 @@ void OpenCLUpdateStateDataKernel::setPositions(ContextImpl& context, const std::
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
mm_float4
&
pos
=
posq
[
i
];
mm_float4
&
pos
=
posq
[
i
];
const
Vec3
&
p
=
positions
[
order
[
i
]];
const
Vec3
&
p
=
positions
[
order
[
i
]];
pos
.
x
=
p
[
0
];
pos
.
x
=
(
cl_float
)
p
[
0
];
pos
.
y
=
p
[
1
];
pos
.
y
=
(
cl_float
)
p
[
1
];
pos
.
z
=
p
[
2
];
pos
.
z
=
(
cl_float
)
p
[
2
];
}
}
posq
.
upload
();
posq
.
upload
();
for
(
int
i
=
0
;
i
<
cl
.
getPosCellOffsets
().
size
();
i
++
)
for
(
int
i
=
0
;
i
<
(
int
)
cl
.
getPosCellOffsets
().
size
();
i
++
)
cl
.
getPosCellOffsets
()[
i
]
=
mm_int4
(
0
,
0
,
0
,
0
);
cl
.
getPosCellOffsets
()[
i
]
=
mm_int4
(
0
,
0
,
0
,
0
);
}
}
...
@@ -148,9 +148,9 @@ void OpenCLUpdateStateDataKernel::setVelocities(ContextImpl& context, const std:
...
@@ -148,9 +148,9 @@ void OpenCLUpdateStateDataKernel::setVelocities(ContextImpl& context, const std:
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
mm_float4
&
vel
=
velm
[
i
];
mm_float4
&
vel
=
velm
[
i
];
const
Vec3
&
p
=
velocities
[
order
[
i
]];
const
Vec3
&
p
=
velocities
[
order
[
i
]];
vel
.
x
=
p
[
0
];
vel
.
x
=
(
cl_float
)
p
[
0
];
vel
.
y
=
p
[
1
];
vel
.
y
=
(
cl_float
)
p
[
1
];
vel
.
z
=
p
[
2
];
vel
.
z
=
(
cl_float
)
p
[
2
];
}
}
velm
.
upload
();
velm
.
upload
();
}
}
...
@@ -219,7 +219,7 @@ void OpenCLCalcHarmonicBondForceKernel::initialize(const System& system, const H
...
@@ -219,7 +219,7 @@ void OpenCLCalcHarmonicBondForceKernel::initialize(const System& system, const H
params
->
upload
(
paramVector
);
params
->
upload
(
paramVector
);
indices
->
upload
(
indicesVector
);
indices
->
upload
(
indicesVector
);
int
maxBuffers
=
1
;
int
maxBuffers
=
1
;
for
(
int
i
=
0
;
i
<
forceBufferCounter
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
(
int
)
forceBufferCounter
.
size
();
i
++
)
maxBuffers
=
max
(
maxBuffers
,
forceBufferCounter
[
i
]);
maxBuffers
=
max
(
maxBuffers
,
forceBufferCounter
[
i
]);
cl
.
addForce
(
new
OpenCLBondForceInfo
(
maxBuffers
,
force
));
cl
.
addForce
(
new
OpenCLBondForceInfo
(
maxBuffers
,
force
));
cl
::
Program
program
=
cl
.
createProgram
(
cl
.
loadSourceFromFile
(
"harmonicBondForce.cl"
));
cl
::
Program
program
=
cl
.
createProgram
(
cl
.
loadSourceFromFile
(
"harmonicBondForce.cl"
));
...
@@ -304,14 +304,14 @@ void OpenCLCalcCustomBondForceKernel::initialize(const System& system, const Cus
...
@@ -304,14 +304,14 @@ void OpenCLCalcCustomBondForceKernel::initialize(const System& system, const Cus
vector
<
double
>
parameters
;
vector
<
double
>
parameters
;
force
.
getBondParameters
(
i
,
particle1
,
particle2
,
parameters
);
force
.
getBondParameters
(
i
,
particle1
,
particle2
,
parameters
);
paramVector
[
i
].
resize
(
parameters
.
size
());
paramVector
[
i
].
resize
(
parameters
.
size
());
for
(
int
j
=
0
;
j
<
parameters
.
size
();
j
++
)
for
(
int
j
=
0
;
j
<
(
int
)
parameters
.
size
();
j
++
)
paramVector
[
i
][
j
]
=
(
cl_float
)
parameters
[
j
];
paramVector
[
i
][
j
]
=
(
cl_float
)
parameters
[
j
];
indicesVector
[
i
]
=
mm_int4
(
particle1
,
particle2
,
forceBufferCounter
[
particle1
]
++
,
forceBufferCounter
[
particle2
]
++
);
indicesVector
[
i
]
=
mm_int4
(
particle1
,
particle2
,
forceBufferCounter
[
particle1
]
++
,
forceBufferCounter
[
particle2
]
++
);
}
}
params
->
setParameterValues
(
paramVector
);
params
->
setParameterValues
(
paramVector
);
indices
->
upload
(
indicesVector
);
indices
->
upload
(
indicesVector
);
int
maxBuffers
=
1
;
int
maxBuffers
=
1
;
for
(
int
i
=
0
;
i
<
forceBufferCounter
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
(
int
)
forceBufferCounter
.
size
();
i
++
)
maxBuffers
=
max
(
maxBuffers
,
forceBufferCounter
[
i
]);
maxBuffers
=
max
(
maxBuffers
,
forceBufferCounter
[
i
]);
cl
.
addForce
(
new
OpenCLCustomBondForceInfo
(
maxBuffers
,
force
));
cl
.
addForce
(
new
OpenCLCustomBondForceInfo
(
maxBuffers
,
force
));
...
@@ -367,7 +367,7 @@ void OpenCLCalcCustomBondForceKernel::executeForces(ContextImpl& context) {
...
@@ -367,7 +367,7 @@ void OpenCLCalcCustomBondForceKernel::executeForces(ContextImpl& context) {
return
;
return
;
if
(
globals
!=
NULL
)
{
if
(
globals
!=
NULL
)
{
bool
changed
=
false
;
bool
changed
=
false
;
for
(
int
i
=
0
;
i
<
globalParamNames
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
globalParamNames
.
size
();
i
++
)
{
cl_float
value
=
(
cl_float
)
context
.
getParameter
(
globalParamNames
[
i
]);
cl_float
value
=
(
cl_float
)
context
.
getParameter
(
globalParamNames
[
i
]);
if
(
value
!=
globalParamValues
[
i
])
if
(
value
!=
globalParamValues
[
i
])
changed
=
true
;
changed
=
true
;
...
@@ -455,7 +455,7 @@ void OpenCLCalcHarmonicAngleForceKernel::initialize(const System& system, const
...
@@ -455,7 +455,7 @@ void OpenCLCalcHarmonicAngleForceKernel::initialize(const System& system, const
params
->
upload
(
paramVector
);
params
->
upload
(
paramVector
);
indices
->
upload
(
indicesVector
);
indices
->
upload
(
indicesVector
);
int
maxBuffers
=
1
;
int
maxBuffers
=
1
;
for
(
int
i
=
0
;
i
<
forceBufferCounter
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
(
int
)
forceBufferCounter
.
size
();
i
++
)
maxBuffers
=
max
(
maxBuffers
,
forceBufferCounter
[
i
]);
maxBuffers
=
max
(
maxBuffers
,
forceBufferCounter
[
i
]);
cl
.
addForce
(
new
OpenCLAngleForceInfo
(
maxBuffers
,
force
));
cl
.
addForce
(
new
OpenCLAngleForceInfo
(
maxBuffers
,
force
));
cl
::
Program
program
=
cl
.
createProgram
(
cl
.
loadSourceFromFile
(
"harmonicAngleForce.cl"
));
cl
::
Program
program
=
cl
.
createProgram
(
cl
.
loadSourceFromFile
(
"harmonicAngleForce.cl"
));
...
@@ -539,7 +539,7 @@ void OpenCLCalcPeriodicTorsionForceKernel::initialize(const System& system, cons
...
@@ -539,7 +539,7 @@ void OpenCLCalcPeriodicTorsionForceKernel::initialize(const System& system, cons
params
->
upload
(
paramVector
);
params
->
upload
(
paramVector
);
indices
->
upload
(
indicesVector
);
indices
->
upload
(
indicesVector
);
int
maxBuffers
=
1
;
int
maxBuffers
=
1
;
for
(
int
i
=
0
;
i
<
forceBufferCounter
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
(
int
)
forceBufferCounter
.
size
();
i
++
)
maxBuffers
=
max
(
maxBuffers
,
forceBufferCounter
[
i
]);
maxBuffers
=
max
(
maxBuffers
,
forceBufferCounter
[
i
]);
cl
.
addForce
(
new
OpenCLPeriodicTorsionForceInfo
(
maxBuffers
,
force
));
cl
.
addForce
(
new
OpenCLPeriodicTorsionForceInfo
(
maxBuffers
,
force
));
cl
::
Program
program
=
cl
.
createProgram
(
cl
.
loadSourceFromFile
(
"periodicTorsionForce.cl"
));
cl
::
Program
program
=
cl
.
createProgram
(
cl
.
loadSourceFromFile
(
"periodicTorsionForce.cl"
));
...
@@ -623,7 +623,7 @@ void OpenCLCalcRBTorsionForceKernel::initialize(const System& system, const RBTo
...
@@ -623,7 +623,7 @@ void OpenCLCalcRBTorsionForceKernel::initialize(const System& system, const RBTo
params
->
upload
(
paramVector
);
params
->
upload
(
paramVector
);
indices
->
upload
(
indicesVector
);
indices
->
upload
(
indicesVector
);
int
maxBuffers
=
1
;
int
maxBuffers
=
1
;
for
(
int
i
=
0
;
i
<
forceBufferCounter
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
(
int
)
forceBufferCounter
.
size
();
i
++
)
maxBuffers
=
max
(
maxBuffers
,
forceBufferCounter
[
i
]);
maxBuffers
=
max
(
maxBuffers
,
forceBufferCounter
[
i
]);
cl
.
addForce
(
new
OpenCLRBTorsionForceInfo
(
maxBuffers
,
force
));
cl
.
addForce
(
new
OpenCLRBTorsionForceInfo
(
maxBuffers
,
force
));
cl
::
Program
program
=
cl
.
createProgram
(
cl
.
loadSourceFromFile
(
"rbTorsionForce.cl"
));
cl
::
Program
program
=
cl
.
createProgram
(
cl
.
loadSourceFromFile
(
"rbTorsionForce.cl"
));
...
@@ -809,7 +809,7 @@ void OpenCLCalcNonbondedForceKernel::initialize(const System& system, const Nonb
...
@@ -809,7 +809,7 @@ void OpenCLCalcNonbondedForceKernel::initialize(const System& system, const Nonb
}
}
exceptionParams
->
upload
(
exceptionParamsVector
);
exceptionParams
->
upload
(
exceptionParamsVector
);
exceptionIndices
->
upload
(
exceptionIndicesVector
);
exceptionIndices
->
upload
(
exceptionIndicesVector
);
for
(
int
i
=
0
;
i
<
forceBufferCounter
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
(
int
)
forceBufferCounter
.
size
();
i
++
)
maxBuffers
=
max
(
maxBuffers
,
forceBufferCounter
[
i
]);
maxBuffers
=
max
(
maxBuffers
,
forceBufferCounter
[
i
]);
}
}
cl
.
addForce
(
new
OpenCLNonbondedForceInfo
(
maxBuffers
,
force
));
cl
.
addForce
(
new
OpenCLNonbondedForceInfo
(
maxBuffers
,
force
));
...
@@ -829,7 +829,7 @@ void OpenCLCalcNonbondedForceKernel::executeForces(ContextImpl& context) {
...
@@ -829,7 +829,7 @@ void OpenCLCalcNonbondedForceKernel::executeForces(ContextImpl& context) {
int
numExceptions
=
exceptionIndices
->
getSize
();
int
numExceptions
=
exceptionIndices
->
getSize
();
exceptionsKernel
.
setArg
<
cl_int
>
(
0
,
cl
.
getPaddedNumAtoms
());
exceptionsKernel
.
setArg
<
cl_int
>
(
0
,
cl
.
getPaddedNumAtoms
());
exceptionsKernel
.
setArg
<
cl_int
>
(
1
,
numExceptions
);
exceptionsKernel
.
setArg
<
cl_int
>
(
1
,
numExceptions
);
exceptionsKernel
.
setArg
<
cl_float
>
(
2
,
cutoffSquared
);
exceptionsKernel
.
setArg
<
cl_float
>
(
2
,
(
cl_float
)
cutoffSquared
);
exceptionsKernel
.
setArg
<
mm_float4
>
(
3
,
cl
.
getNonbondedUtilities
().
getPeriodicBoxSize
());
exceptionsKernel
.
setArg
<
mm_float4
>
(
3
,
cl
.
getNonbondedUtilities
().
getPeriodicBoxSize
());
exceptionsKernel
.
setArg
<
cl
::
Buffer
>
(
4
,
cl
.
getForceBuffers
().
getDeviceBuffer
());
exceptionsKernel
.
setArg
<
cl
::
Buffer
>
(
4
,
cl
.
getForceBuffers
().
getDeviceBuffer
());
exceptionsKernel
.
setArg
<
cl
::
Buffer
>
(
5
,
cl
.
getEnergyBuffer
().
getDeviceBuffer
());
exceptionsKernel
.
setArg
<
cl
::
Buffer
>
(
5
,
cl
.
getEnergyBuffer
().
getDeviceBuffer
());
...
@@ -868,7 +868,7 @@ public:
...
@@ -868,7 +868,7 @@ public:
vector
<
double
>
params2
;
vector
<
double
>
params2
;
force
.
getParticleParameters
(
particle1
,
params1
);
force
.
getParticleParameters
(
particle1
,
params1
);
force
.
getParticleParameters
(
particle2
,
params2
);
force
.
getParticleParameters
(
particle2
,
params2
);
for
(
int
i
=
0
;
i
<
params1
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
(
int
)
params1
.
size
();
i
++
)
if
(
params1
[
i
]
!=
params2
[
i
])
if
(
params1
[
i
]
!=
params2
[
i
])
return
false
;
return
false
;
return
true
;
return
true
;
...
@@ -919,7 +919,7 @@ void OpenCLCalcCustomNonbondedForceKernel::initialize(const System& system, cons
...
@@ -919,7 +919,7 @@ void OpenCLCalcCustomNonbondedForceKernel::initialize(const System& system, cons
vector
<
double
>
parameters
;
vector
<
double
>
parameters
;
force
.
getParticleParameters
(
i
,
parameters
);
force
.
getParticleParameters
(
i
,
parameters
);
paramVector
[
i
].
resize
(
parameters
.
size
());
paramVector
[
i
].
resize
(
parameters
.
size
());
for
(
int
j
=
0
;
j
<
parameters
.
size
();
j
++
)
for
(
int
j
=
0
;
j
<
(
int
)
parameters
.
size
();
j
++
)
paramVector
[
i
][
j
]
=
(
cl_float
)
parameters
[
j
];
paramVector
[
i
][
j
]
=
(
cl_float
)
parameters
[
j
];
exclusionList
[
i
].
push_back
(
i
);
exclusionList
[
i
].
push_back
(
i
);
}
}
...
@@ -1013,7 +1013,7 @@ void OpenCLCalcCustomNonbondedForceKernel::initialize(const System& system, cons
...
@@ -1013,7 +1013,7 @@ void OpenCLCalcCustomNonbondedForceKernel::initialize(const System& system, cons
void
OpenCLCalcCustomNonbondedForceKernel
::
executeForces
(
ContextImpl
&
context
)
{
void
OpenCLCalcCustomNonbondedForceKernel
::
executeForces
(
ContextImpl
&
context
)
{
if
(
globals
!=
NULL
)
{
if
(
globals
!=
NULL
)
{
bool
changed
=
false
;
bool
changed
=
false
;
for
(
int
i
=
0
;
i
<
globalParamNames
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
globalParamNames
.
size
();
i
++
)
{
cl_float
value
=
(
cl_float
)
context
.
getParameter
(
globalParamNames
[
i
]);
cl_float
value
=
(
cl_float
)
context
.
getParameter
(
globalParamNames
[
i
]);
if
(
value
!=
globalParamValues
[
i
])
if
(
value
!=
globalParamValues
[
i
])
changed
=
true
;
changed
=
true
;
...
@@ -1187,7 +1187,7 @@ public:
...
@@ -1187,7 +1187,7 @@ public:
vector
<
double
>
params2
;
vector
<
double
>
params2
;
force
.
getParticleParameters
(
particle1
,
params1
);
force
.
getParticleParameters
(
particle1
,
params1
);
force
.
getParticleParameters
(
particle2
,
params2
);
force
.
getParticleParameters
(
particle2
,
params2
);
for
(
int
i
=
0
;
i
<
params1
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
(
int
)
params1
.
size
();
i
++
)
if
(
params1
[
i
]
!=
params2
[
i
])
if
(
params1
[
i
]
!=
params2
[
i
])
return
false
;
return
false
;
return
true
;
return
true
;
...
@@ -1260,7 +1260,7 @@ void OpenCLCalcCustomGBForceKernel::initialize(const System& system, const Custo
...
@@ -1260,7 +1260,7 @@ void OpenCLCalcCustomGBForceKernel::initialize(const System& system, const Custo
vector
<
double
>
parameters
;
vector
<
double
>
parameters
;
force
.
getParticleParameters
(
i
,
parameters
);
force
.
getParticleParameters
(
i
,
parameters
);
paramVector
[
i
].
resize
(
parameters
.
size
());
paramVector
[
i
].
resize
(
parameters
.
size
());
for
(
int
j
=
0
;
j
<
parameters
.
size
();
j
++
)
for
(
int
j
=
0
;
j
<
(
int
)
parameters
.
size
();
j
++
)
paramVector
[
i
][
j
]
=
(
cl_float
)
parameters
[
j
];
paramVector
[
i
][
j
]
=
(
cl_float
)
parameters
[
j
];
exclusionList
[
i
].
push_back
(
i
);
exclusionList
[
i
].
push_back
(
i
);
}
}
...
@@ -1807,7 +1807,7 @@ void OpenCLCalcCustomGBForceKernel::executeForces(ContextImpl& context) {
...
@@ -1807,7 +1807,7 @@ void OpenCLCalcCustomGBForceKernel::executeForces(ContextImpl& context) {
}
}
if
(
globals
!=
NULL
)
{
if
(
globals
!=
NULL
)
{
bool
changed
=
false
;
bool
changed
=
false
;
for
(
int
i
=
0
;
i
<
globalParamNames
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
globalParamNames
.
size
();
i
++
)
{
cl_float
value
=
(
cl_float
)
context
.
getParameter
(
globalParamNames
[
i
]);
cl_float
value
=
(
cl_float
)
context
.
getParameter
(
globalParamNames
[
i
]);
if
(
value
!=
globalParamValues
[
i
])
if
(
value
!=
globalParamValues
[
i
])
changed
=
true
;
changed
=
true
;
...
@@ -1854,7 +1854,7 @@ public:
...
@@ -1854,7 +1854,7 @@ public:
vector
<
double
>
params2
;
vector
<
double
>
params2
;
force
.
getParticleParameters
(
particle1
,
temp
,
params1
);
force
.
getParticleParameters
(
particle1
,
temp
,
params1
);
force
.
getParticleParameters
(
particle2
,
temp
,
params2
);
force
.
getParticleParameters
(
particle2
,
temp
,
params2
);
for
(
int
i
=
0
;
i
<
params1
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
(
int
)
params1
.
size
();
i
++
)
if
(
params1
[
i
]
!=
params2
[
i
])
if
(
params1
[
i
]
!=
params2
[
i
])
return
false
;
return
false
;
return
true
;
return
true
;
...
@@ -1888,7 +1888,7 @@ void OpenCLCalcCustomExternalForceKernel::initialize(const System& system, const
...
@@ -1888,7 +1888,7 @@ void OpenCLCalcCustomExternalForceKernel::initialize(const System& system, const
vector
<
double
>
parameters
;
vector
<
double
>
parameters
;
force
.
getParticleParameters
(
i
,
indicesVector
[
i
],
parameters
);
force
.
getParticleParameters
(
i
,
indicesVector
[
i
],
parameters
);
paramVector
[
i
].
resize
(
parameters
.
size
());
paramVector
[
i
].
resize
(
parameters
.
size
());
for
(
int
j
=
0
;
j
<
parameters
.
size
();
j
++
)
for
(
int
j
=
0
;
j
<
(
int
)
parameters
.
size
();
j
++
)
paramVector
[
i
][
j
]
=
(
cl_float
)
parameters
[
j
];
paramVector
[
i
][
j
]
=
(
cl_float
)
parameters
[
j
];
}
}
params
->
setParameterValues
(
paramVector
);
params
->
setParameterValues
(
paramVector
);
...
@@ -1951,7 +1951,7 @@ void OpenCLCalcCustomExternalForceKernel::initialize(const System& system, const
...
@@ -1951,7 +1951,7 @@ void OpenCLCalcCustomExternalForceKernel::initialize(const System& system, const
void
OpenCLCalcCustomExternalForceKernel
::
executeForces
(
ContextImpl
&
context
)
{
void
OpenCLCalcCustomExternalForceKernel
::
executeForces
(
ContextImpl
&
context
)
{
if
(
globals
!=
NULL
)
{
if
(
globals
!=
NULL
)
{
bool
changed
=
false
;
bool
changed
=
false
;
for
(
int
i
=
0
;
i
<
globalParamNames
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
globalParamNames
.
size
();
i
++
)
{
cl_float
value
=
(
cl_float
)
context
.
getParameter
(
globalParamNames
[
i
]);
cl_float
value
=
(
cl_float
)
context
.
getParameter
(
globalParamNames
[
i
]);
if
(
value
!=
globalParamValues
[
i
])
if
(
value
!=
globalParamValues
[
i
])
changed
=
true
;
changed
=
true
;
...
@@ -2014,7 +2014,7 @@ void OpenCLIntegrateVerletStepKernel::execute(ContextImpl& context, const Verlet
...
@@ -2014,7 +2014,7 @@ void OpenCLIntegrateVerletStepKernel::execute(ContextImpl& context, const Verlet
}
}
if
(
dt
!=
prevStepSize
)
{
if
(
dt
!=
prevStepSize
)
{
vector
<
mm_float2
>
stepSizeVec
(
1
);
vector
<
mm_float2
>
stepSizeVec
(
1
);
stepSizeVec
[
0
]
=
mm_float2
(
dt
,
dt
);
stepSizeVec
[
0
]
=
mm_float2
(
(
cl_float
)
dt
,
(
cl_float
)
dt
);
cl
.
getIntegrationUtilities
().
getStepSize
().
upload
(
stepSizeVec
);
cl
.
getIntegrationUtilities
().
getStepSize
().
upload
(
stepSizeVec
);
prevStepSize
=
dt
;
prevStepSize
=
dt
;
}
}
...
@@ -2136,17 +2136,17 @@ void OpenCLIntegrateLangevinStepKernel::execute(ContextImpl& context, const Lang
...
@@ -2136,17 +2136,17 @@ void OpenCLIntegrateLangevinStepKernel::execute(ContextImpl& context, const Lang
double
Yv
=
sqrt
(
kT
*
B
/
C
);
double
Yv
=
sqrt
(
kT
*
B
/
C
);
double
Yx
=
tau
*
sqrt
(
kT
*
B
/
(
1.0
-
EM
));
double
Yx
=
tau
*
sqrt
(
kT
*
B
/
(
1.0
-
EM
));
vector
<
cl_float
>
p
(
params
->
getSize
());
vector
<
cl_float
>
p
(
params
->
getSize
());
p
[
0
]
=
EM
;
p
[
0
]
=
(
cl_float
)
EM
;
p
[
1
]
=
EM
;
p
[
1
]
=
(
cl_float
)
EM
;
p
[
2
]
=
DOverTauC
;
p
[
2
]
=
(
cl_float
)
DOverTauC
;
p
[
3
]
=
TauOneMinusEM
;
p
[
3
]
=
(
cl_float
)
TauOneMinusEM
;
p
[
4
]
=
TauDOverEMMinusOne
;
p
[
4
]
=
(
cl_float
)
TauDOverEMMinusOne
;
p
[
5
]
=
V
;
p
[
5
]
=
(
cl_float
)
V
;
p
[
6
]
=
X
;
p
[
6
]
=
(
cl_float
)
X
;
p
[
7
]
=
Yv
;
p
[
7
]
=
(
cl_float
)
Yv
;
p
[
8
]
=
Yx
;
p
[
8
]
=
(
cl_float
)
Yx
;
p
[
9
]
=
fix1
;
p
[
9
]
=
(
cl_float
)
fix1
;
p
[
10
]
=
oneOverFix1
;
p
[
10
]
=
(
cl_float
)
oneOverFix1
;
params
->
upload
(
p
);
params
->
upload
(
p
);
prevTemp
=
temperature
;
prevTemp
=
temperature
;
prevFriction
=
friction
;
prevFriction
=
friction
;
...
@@ -2278,7 +2278,7 @@ void OpenCLIntegrateVariableVerletStepKernel::execute(ContextImpl& context, cons
...
@@ -2278,7 +2278,7 @@ void OpenCLIntegrateVariableVerletStepKernel::execute(ContextImpl& context, cons
float
maxStepSize
=
(
float
)(
maxTime
-
cl
.
getTime
());
float
maxStepSize
=
(
float
)(
maxTime
-
cl
.
getTime
());
selectSizeKernel
.
setArg
<
cl_float
>
(
1
,
maxStepSize
);
selectSizeKernel
.
setArg
<
cl_float
>
(
1
,
maxStepSize
);
selectSizeKernel
.
setArg
<
cl_float
>
(
2
,
integrator
.
getErrorTolerance
());
selectSizeKernel
.
setArg
<
cl_float
>
(
2
,
(
cl_float
)
integrator
.
getErrorTolerance
());
cl
.
executeKernel
(
selectSizeKernel
,
blockSize
,
blockSize
);
cl
.
executeKernel
(
selectSizeKernel
,
blockSize
,
blockSize
);
// Call the first integration kernel.
// Call the first integration kernel.
...
...
platforms/opencl/src/OpenCLNonbondedUtilities.cpp
View file @
53539843
...
@@ -79,10 +79,10 @@ void OpenCLNonbondedUtilities::addInteraction(bool usesCutoff, bool usesPeriodic
...
@@ -79,10 +79,10 @@ void OpenCLNonbondedUtilities::addInteraction(bool usesCutoff, bool usesPeriodic
}
}
if
(
usesExclusions
&&
atomExclusions
.
size
()
!=
0
)
{
if
(
usesExclusions
&&
atomExclusions
.
size
()
!=
0
)
{
bool
sameExclusions
=
(
exclusionList
.
size
()
==
atomExclusions
.
size
());
bool
sameExclusions
=
(
exclusionList
.
size
()
==
atomExclusions
.
size
());
for
(
int
i
=
0
;
i
<
exclusionList
.
size
()
&&
sameExclusions
;
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
exclusionList
.
size
()
&&
sameExclusions
;
i
++
)
{
if
(
exclusionList
[
i
].
size
()
!=
atomExclusions
[
i
].
size
())
if
(
exclusionList
[
i
].
size
()
!=
atomExclusions
[
i
].
size
())
sameExclusions
=
false
;
sameExclusions
=
false
;
for
(
int
j
=
0
;
j
<
exclusionList
[
i
].
size
();
j
++
)
for
(
int
j
=
0
;
j
<
(
int
)
exclusionList
[
i
].
size
();
j
++
)
if
(
exclusionList
[
i
][
j
]
!=
atomExclusions
[
i
][
j
])
if
(
exclusionList
[
i
][
j
]
!=
atomExclusions
[
i
][
j
])
sameExclusions
=
false
;
sameExclusions
=
false
;
}
}
...
@@ -115,7 +115,7 @@ void OpenCLNonbondedUtilities::initialize(const System& system) {
...
@@ -115,7 +115,7 @@ void OpenCLNonbondedUtilities::initialize(const System& system) {
// No exclusions were specifically requested, so just mark every atom as not interacting with itself.
// No exclusions were specifically requested, so just mark every atom as not interacting with itself.
atomExclusions
.
resize
(
context
.
getNumAtoms
());
atomExclusions
.
resize
(
context
.
getNumAtoms
());
for
(
int
i
=
0
;
i
<
atomExclusions
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
(
int
)
atomExclusions
.
size
();
i
++
)
atomExclusions
[
i
].
push_back
(
i
);
atomExclusions
[
i
].
push_back
(
i
);
}
}
...
@@ -126,8 +126,8 @@ void OpenCLNonbondedUtilities::initialize(const System& system) {
...
@@ -126,8 +126,8 @@ void OpenCLNonbondedUtilities::initialize(const System& system) {
tiles
=
new
OpenCLArray
<
cl_uint
>
(
context
,
numTiles
,
"tiles"
);
tiles
=
new
OpenCLArray
<
cl_uint
>
(
context
,
numTiles
,
"tiles"
);
vector
<
cl_uint
>
tileVec
(
tiles
->
getSize
());
vector
<
cl_uint
>
tileVec
(
tiles
->
getSize
());
unsigned
int
count
=
0
;
unsigned
int
count
=
0
;
for
(
unsigned
int
y
=
0
;
y
<
numAtomBlocks
;
y
++
)
for
(
unsigned
int
y
=
0
;
y
<
(
unsigned
int
)
numAtomBlocks
;
y
++
)
for
(
unsigned
int
x
=
y
;
x
<
numAtomBlocks
;
x
++
)
for
(
unsigned
int
x
=
y
;
x
<
(
unsigned
int
)
numAtomBlocks
;
x
++
)
tileVec
[
count
++
]
=
(
x
<<
17
)
|
(
y
<<
2
);
tileVec
[
count
++
]
=
(
x
<<
17
)
|
(
y
<<
2
);
// Mark which tiles have exclusions.
// Mark which tiles have exclusions.
...
@@ -242,14 +242,14 @@ void OpenCLNonbondedUtilities::initialize(const System& system) {
...
@@ -242,14 +242,14 @@ void OpenCLNonbondedUtilities::initialize(const System& system) {
findBlockBoundsKernel
.
setArg
<
cl
::
Buffer
>
(
4
,
blockBoundingBox
->
getDeviceBuffer
());
findBlockBoundsKernel
.
setArg
<
cl
::
Buffer
>
(
4
,
blockBoundingBox
->
getDeviceBuffer
());
findInteractingBlocksKernel
=
cl
::
Kernel
(
interactingBlocksProgram
,
"findBlocksWithInteractions"
);
findInteractingBlocksKernel
=
cl
::
Kernel
(
interactingBlocksProgram
,
"findBlocksWithInteractions"
);
findInteractingBlocksKernel
.
setArg
<
cl_int
>
(
0
,
tiles
->
getSize
());
findInteractingBlocksKernel
.
setArg
<
cl_int
>
(
0
,
tiles
->
getSize
());
findInteractingBlocksKernel
.
setArg
<
cl_float
>
(
1
,
cutoff
*
cutoff
);
findInteractingBlocksKernel
.
setArg
<
cl_float
>
(
1
,
(
cl_float
)
(
cutoff
*
cutoff
)
)
;
findInteractingBlocksKernel
.
setArg
<
mm_float4
>
(
2
,
periodicBoxSize
);
findInteractingBlocksKernel
.
setArg
<
mm_float4
>
(
2
,
periodicBoxSize
);
findInteractingBlocksKernel
.
setArg
<
cl
::
Buffer
>
(
3
,
tiles
->
getDeviceBuffer
());
findInteractingBlocksKernel
.
setArg
<
cl
::
Buffer
>
(
3
,
tiles
->
getDeviceBuffer
());
findInteractingBlocksKernel
.
setArg
<
cl
::
Buffer
>
(
4
,
blockCenter
->
getDeviceBuffer
());
findInteractingBlocksKernel
.
setArg
<
cl
::
Buffer
>
(
4
,
blockCenter
->
getDeviceBuffer
());
findInteractingBlocksKernel
.
setArg
<
cl
::
Buffer
>
(
5
,
blockBoundingBox
->
getDeviceBuffer
());
findInteractingBlocksKernel
.
setArg
<
cl
::
Buffer
>
(
5
,
blockBoundingBox
->
getDeviceBuffer
());
findInteractingBlocksKernel
.
setArg
<
cl
::
Buffer
>
(
6
,
interactionFlags
->
getDeviceBuffer
());
findInteractingBlocksKernel
.
setArg
<
cl
::
Buffer
>
(
6
,
interactionFlags
->
getDeviceBuffer
());
findInteractionsWithinBlocksKernel
=
cl
::
Kernel
(
interactingBlocksProgram
,
"findInteractionsWithinBlocks"
);
findInteractionsWithinBlocksKernel
=
cl
::
Kernel
(
interactingBlocksProgram
,
"findInteractionsWithinBlocks"
);
findInteractionsWithinBlocksKernel
.
setArg
<
cl_float
>
(
0
,
cutoff
*
cutoff
);
findInteractionsWithinBlocksKernel
.
setArg
<
cl_float
>
(
0
,
(
cl_float
)
(
cutoff
*
cutoff
)
)
;
findInteractionsWithinBlocksKernel
.
setArg
<
mm_float4
>
(
1
,
periodicBoxSize
);
findInteractionsWithinBlocksKernel
.
setArg
<
mm_float4
>
(
1
,
periodicBoxSize
);
findInteractionsWithinBlocksKernel
.
setArg
<
cl
::
Buffer
>
(
2
,
context
.
getPosq
().
getDeviceBuffer
());
findInteractionsWithinBlocksKernel
.
setArg
<
cl
::
Buffer
>
(
2
,
context
.
getPosq
().
getDeviceBuffer
());
findInteractionsWithinBlocksKernel
.
setArg
<
cl
::
Buffer
>
(
3
,
interactingTiles
->
getDeviceBuffer
());
findInteractionsWithinBlocksKernel
.
setArg
<
cl
::
Buffer
>
(
3
,
interactingTiles
->
getDeviceBuffer
());
...
@@ -282,7 +282,7 @@ cl::Kernel OpenCLNonbondedUtilities::createInteractionKernel(const string& sourc
...
@@ -282,7 +282,7 @@ cl::Kernel OpenCLNonbondedUtilities::createInteractionKernel(const string& sourc
map
<
string
,
string
>
replacements
;
map
<
string
,
string
>
replacements
;
replacements
[
"COMPUTE_INTERACTION"
]
=
source
;
replacements
[
"COMPUTE_INTERACTION"
]
=
source
;
stringstream
args
;
stringstream
args
;
for
(
int
i
=
0
;
i
<
params
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
params
.
size
();
i
++
)
{
args
<<
", __global "
;
args
<<
", __global "
;
args
<<
params
[
i
].
getType
();
args
<<
params
[
i
].
getType
();
args
<<
"* global_"
;
args
<<
"* global_"
;
...
@@ -292,7 +292,7 @@ cl::Kernel OpenCLNonbondedUtilities::createInteractionKernel(const string& sourc
...
@@ -292,7 +292,7 @@ cl::Kernel OpenCLNonbondedUtilities::createInteractionKernel(const string& sourc
args
<<
"* local_"
;
args
<<
"* local_"
;
args
<<
params
[
i
].
getName
();
args
<<
params
[
i
].
getName
();
}
}
for
(
int
i
=
0
;
i
<
arguments
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
arguments
.
size
();
i
++
)
{
if
((
arguments
[
i
].
getBuffer
().
getInfo
<
CL_MEM_FLAGS
>
()
&
CL_MEM_READ_ONLY
)
==
0
)
if
((
arguments
[
i
].
getBuffer
().
getInfo
<
CL_MEM_FLAGS
>
()
&
CL_MEM_READ_ONLY
)
==
0
)
args
<<
", __global "
;
args
<<
", __global "
;
else
else
...
@@ -303,7 +303,7 @@ cl::Kernel OpenCLNonbondedUtilities::createInteractionKernel(const string& sourc
...
@@ -303,7 +303,7 @@ cl::Kernel OpenCLNonbondedUtilities::createInteractionKernel(const string& sourc
}
}
replacements
[
"PARAMETER_ARGUMENTS"
]
=
args
.
str
();
replacements
[
"PARAMETER_ARGUMENTS"
]
=
args
.
str
();
stringstream
loadLocal1
;
stringstream
loadLocal1
;
for
(
int
i
=
0
;
i
<
params
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
params
.
size
();
i
++
)
{
loadLocal1
<<
"local_"
;
loadLocal1
<<
"local_"
;
loadLocal1
<<
params
[
i
].
getName
();
loadLocal1
<<
params
[
i
].
getName
();
loadLocal1
<<
"[get_local_id(0)] = "
;
loadLocal1
<<
"[get_local_id(0)] = "
;
...
@@ -312,7 +312,7 @@ cl::Kernel OpenCLNonbondedUtilities::createInteractionKernel(const string& sourc
...
@@ -312,7 +312,7 @@ cl::Kernel OpenCLNonbondedUtilities::createInteractionKernel(const string& sourc
}
}
replacements
[
"LOAD_LOCAL_PARAMETERS_FROM_1"
]
=
loadLocal1
.
str
();
replacements
[
"LOAD_LOCAL_PARAMETERS_FROM_1"
]
=
loadLocal1
.
str
();
stringstream
loadLocal2
;
stringstream
loadLocal2
;
for
(
int
i
=
0
;
i
<
params
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
params
.
size
();
i
++
)
{
loadLocal2
<<
"local_"
;
loadLocal2
<<
"local_"
;
loadLocal2
<<
params
[
i
].
getName
();
loadLocal2
<<
params
[
i
].
getName
();
loadLocal2
<<
"[get_local_id(0)] = global_"
;
loadLocal2
<<
"[get_local_id(0)] = global_"
;
...
@@ -321,7 +321,7 @@ cl::Kernel OpenCLNonbondedUtilities::createInteractionKernel(const string& sourc
...
@@ -321,7 +321,7 @@ cl::Kernel OpenCLNonbondedUtilities::createInteractionKernel(const string& sourc
}
}
replacements
[
"LOAD_LOCAL_PARAMETERS_FROM_GLOBAL"
]
=
loadLocal2
.
str
();
replacements
[
"LOAD_LOCAL_PARAMETERS_FROM_GLOBAL"
]
=
loadLocal2
.
str
();
stringstream
load1
;
stringstream
load1
;
for
(
int
i
=
0
;
i
<
params
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
params
.
size
();
i
++
)
{
load1
<<
params
[
i
].
getType
();
load1
<<
params
[
i
].
getType
();
load1
<<
" "
;
load1
<<
" "
;
load1
<<
params
[
i
].
getName
();
load1
<<
params
[
i
].
getName
();
...
@@ -331,7 +331,7 @@ cl::Kernel OpenCLNonbondedUtilities::createInteractionKernel(const string& sourc
...
@@ -331,7 +331,7 @@ cl::Kernel OpenCLNonbondedUtilities::createInteractionKernel(const string& sourc
}
}
replacements
[
"LOAD_ATOM1_PARAMETERS"
]
=
load1
.
str
();
replacements
[
"LOAD_ATOM1_PARAMETERS"
]
=
load1
.
str
();
stringstream
load2j
;
stringstream
load2j
;
for
(
int
i
=
0
;
i
<
params
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
params
.
size
();
i
++
)
{
load2j
<<
params
[
i
].
getType
();
load2j
<<
params
[
i
].
getType
();
load2j
<<
" "
;
load2j
<<
" "
;
load2j
<<
params
[
i
].
getName
();
load2j
<<
params
[
i
].
getName
();
...
...
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