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
09970632
Commit
09970632
authored
Jul 15, 2013
by
peastman
Browse files
RPMDIntegrator.setPositions() did not take periodic box offsets into account
parent
e4beb290
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
6 deletions
+32
-6
plugins/rpmd/platforms/cuda/src/CudaRpmdKernels.cpp
plugins/rpmd/platforms/cuda/src/CudaRpmdKernels.cpp
+16
-3
plugins/rpmd/platforms/opencl/src/OpenCLRpmdKernels.cpp
plugins/rpmd/platforms/opencl/src/OpenCLRpmdKernels.cpp
+16
-3
No files found.
plugins/rpmd/platforms/cuda/src/CudaRpmdKernels.cpp
View file @
09970632
...
...
@@ -296,12 +296,25 @@ void CudaIntegrateRPMDStepKernel::setPositions(int copy, const vector<Vec3>& pos
throw
OpenMMException
(
"RPMDIntegrator: Cannot set positions before the integrator is added to a Context"
);
if
(
pos
.
size
()
!=
numParticles
)
throw
OpenMMException
(
"RPMDIntegrator: wrong number of values passed to setPositions()"
);
// Adjust the positions based on the current cell offsets.
const
vector
<
int
>&
order
=
cu
.
getAtomIndex
();
double4
periodicBoxSize
=
cu
.
getPeriodicBoxSize
();
vector
<
Vec3
>
offsetPos
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
int4
offset
=
cu
.
getPosCellOffsets
()[
i
];
offsetPos
[
order
[
i
]]
=
pos
[
order
[
i
]]
+
Vec3
(
offset
.
x
*
periodicBoxSize
.
x
,
offset
.
y
*
periodicBoxSize
.
y
,
offset
.
z
*
periodicBoxSize
.
z
);
}
// Record the positions.
CUresult
result
;
if
(
cu
.
getUseDoublePrecision
())
{
vector
<
double4
>
posq
(
cu
.
getPaddedNumAtoms
());
cu
.
getPosq
().
download
(
posq
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
posq
[
i
]
=
make_double4
(
p
os
[
i
][
0
],
p
os
[
i
][
1
],
p
os
[
i
][
2
],
posq
[
i
].
w
);
posq
[
i
]
=
make_double4
(
offsetP
os
[
i
][
0
],
offsetP
os
[
i
][
1
],
offsetP
os
[
i
][
2
],
posq
[
i
].
w
);
result
=
cuMemcpyHtoD
(
positions
->
getDevicePointer
()
+
copy
*
cu
.
getPaddedNumAtoms
()
*
sizeof
(
double4
),
&
posq
[
0
],
numParticles
*
sizeof
(
double4
));
}
else
if
(
cu
.
getUseMixedPrecision
())
{
...
...
@@ -309,14 +322,14 @@ void CudaIntegrateRPMDStepKernel::setPositions(int copy, const vector<Vec3>& pos
cu
.
getPosq
().
download
(
posqf
);
vector
<
double4
>
posq
(
cu
.
getPaddedNumAtoms
());
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
posq
[
i
]
=
make_double4
(
p
os
[
i
][
0
],
p
os
[
i
][
1
],
p
os
[
i
][
2
],
posqf
[
i
].
w
);
posq
[
i
]
=
make_double4
(
offsetP
os
[
i
][
0
],
offsetP
os
[
i
][
1
],
offsetP
os
[
i
][
2
],
posqf
[
i
].
w
);
result
=
cuMemcpyHtoD
(
positions
->
getDevicePointer
()
+
copy
*
cu
.
getPaddedNumAtoms
()
*
sizeof
(
double4
),
&
posq
[
0
],
numParticles
*
sizeof
(
double4
));
}
else
{
vector
<
float4
>
posq
(
cu
.
getPaddedNumAtoms
());
cu
.
getPosq
().
download
(
posq
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
posq
[
i
]
=
make_float4
((
float
)
p
os
[
i
][
0
],
(
float
)
p
os
[
i
][
1
],
(
float
)
p
os
[
i
][
2
],
posq
[
i
].
w
);
posq
[
i
]
=
make_float4
((
float
)
offsetP
os
[
i
][
0
],
(
float
)
offsetP
os
[
i
][
1
],
(
float
)
offsetP
os
[
i
][
2
],
posq
[
i
].
w
);
result
=
cuMemcpyHtoD
(
positions
->
getDevicePointer
()
+
copy
*
cu
.
getPaddedNumAtoms
()
*
sizeof
(
float4
),
&
posq
[
0
],
numParticles
*
sizeof
(
float4
));
}
if
(
result
!=
CUDA_SUCCESS
)
{
...
...
plugins/rpmd/platforms/opencl/src/OpenCLRpmdKernels.cpp
View file @
09970632
...
...
@@ -312,11 +312,24 @@ void OpenCLIntegrateRPMDStepKernel::setPositions(int copy, const vector<Vec3>& p
throw
OpenMMException
(
"RPMDIntegrator: Cannot set positions before the integrator is added to a Context"
);
if
(
pos
.
size
()
!=
numParticles
)
throw
OpenMMException
(
"RPMDIntegrator: wrong number of values passed to setPositions()"
);
// Adjust the positions based on the current cell offsets.
const
vector
<
int
>&
order
=
cl
.
getAtomIndex
();
mm_double4
periodicBoxSize
=
cl
.
getPeriodicBoxSizeDouble
();
vector
<
Vec3
>
offsetPos
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
mm_int4
offset
=
cl
.
getPosCellOffsets
()[
i
];
offsetPos
[
order
[
i
]]
=
pos
[
order
[
i
]]
+
Vec3
(
offset
.
x
*
periodicBoxSize
.
x
,
offset
.
y
*
periodicBoxSize
.
y
,
offset
.
z
*
periodicBoxSize
.
z
);
}
// Record the positions.
if
(
cl
.
getUseDoublePrecision
())
{
vector
<
mm_double4
>
posq
(
cl
.
getPaddedNumAtoms
());
cl
.
getPosq
().
download
(
posq
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
posq
[
i
]
=
mm_double4
(
p
os
[
i
][
0
],
p
os
[
i
][
1
],
p
os
[
i
][
2
],
posq
[
i
].
w
);
posq
[
i
]
=
mm_double4
(
offsetP
os
[
i
][
0
],
offsetP
os
[
i
][
1
],
offsetP
os
[
i
][
2
],
posq
[
i
].
w
);
cl
.
getQueue
().
enqueueWriteBuffer
(
positions
->
getDeviceBuffer
(),
CL_TRUE
,
copy
*
cl
.
getPaddedNumAtoms
()
*
sizeof
(
mm_double4
),
numParticles
*
sizeof
(
mm_double4
),
&
posq
[
0
]);
}
else
if
(
cl
.
getUseMixedPrecision
())
{
...
...
@@ -324,14 +337,14 @@ void OpenCLIntegrateRPMDStepKernel::setPositions(int copy, const vector<Vec3>& p
cl
.
getPosq
().
download
(
posqf
);
vector
<
mm_double4
>
posq
(
cl
.
getPaddedNumAtoms
());
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
posq
[
i
]
=
mm_double4
(
p
os
[
i
][
0
],
p
os
[
i
][
1
],
p
os
[
i
][
2
],
posqf
[
i
].
w
);
posq
[
i
]
=
mm_double4
(
offsetP
os
[
i
][
0
],
offsetP
os
[
i
][
1
],
offsetP
os
[
i
][
2
],
posqf
[
i
].
w
);
cl
.
getQueue
().
enqueueWriteBuffer
(
positions
->
getDeviceBuffer
(),
CL_TRUE
,
copy
*
cl
.
getPaddedNumAtoms
()
*
sizeof
(
mm_double4
),
numParticles
*
sizeof
(
mm_double4
),
&
posq
[
0
]);
}
else
{
vector
<
mm_float4
>
posq
(
cl
.
getPaddedNumAtoms
());
cl
.
getPosq
().
download
(
posq
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
posq
[
i
]
=
mm_float4
((
cl_float
)
p
os
[
i
][
0
],
(
cl_float
)
p
os
[
i
][
1
],
(
cl_float
)
p
os
[
i
][
2
],
posq
[
i
].
w
);
posq
[
i
]
=
mm_float4
((
cl_float
)
offsetP
os
[
i
][
0
],
(
cl_float
)
offsetP
os
[
i
][
1
],
(
cl_float
)
offsetP
os
[
i
][
2
],
posq
[
i
].
w
);
cl
.
getQueue
().
enqueueWriteBuffer
(
positions
->
getDeviceBuffer
(),
CL_TRUE
,
copy
*
cl
.
getPaddedNumAtoms
()
*
sizeof
(
mm_float4
),
numParticles
*
sizeof
(
mm_float4
),
&
posq
[
0
]);
}
}
...
...
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