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
1cb85ba3
"platforms/cpu/src/CpuCustomNonbondedForceVec4.cpp" did not exist on "0bb293f885265fd654b0ccde1f09dcba3411212d"
Commit
1cb85ba3
authored
Sep 25, 2012
by
Peter Eastman
Browse files
Minor cleanup to simplify code and eliminate unnecessary memory access
parent
a5640f95
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
93 additions
and
149 deletions
+93
-149
plugins/amoeba/platforms/cuda2/src/kernels/amoebaGk.cu
plugins/amoeba/platforms/cuda2/src/kernels/amoebaGk.cu
+42
-63
plugins/amoeba/platforms/cuda2/src/kernels/multipoleElectrostatics.cu
...ba/platforms/cuda2/src/kernels/multipoleElectrostatics.cu
+23
-43
plugins/amoeba/platforms/cuda2/src/kernels/multipoleFixedField.cu
...amoeba/platforms/cuda2/src/kernels/multipoleFixedField.cu
+11
-19
plugins/amoeba/platforms/cuda2/src/kernels/pmeMultipoleElectrostatics.cu
...platforms/cuda2/src/kernels/pmeMultipoleElectrostatics.cu
+17
-24
No files found.
plugins/amoeba/platforms/cuda2/src/kernels/amoebaGk.cu
View file @
1cb85ba3
...
...
@@ -590,14 +590,15 @@ inline __device__ void loadAtomData4(AtomData4& data, int atom, const real4* __r
data
.
thole
=
temp
.
y
;
}
__device__
real
computeDScaleFactor
(
unsigned
int
polarizationGroup
)
{
return
(
polarizationGroup
&
1
?
0
:
1
);
__device__
real
computeDScaleFactor
(
unsigned
int
polarizationGroup
,
int
index
)
{
return
(
polarizationGroup
&
1
<<
index
?
0
:
1
);
}
__device__
float
computePScaleFactor
(
uint2
covalent
,
unsigned
int
polarizationGroup
)
{
bool
x
=
(
covalent
.
x
&
1
);
bool
y
=
(
covalent
.
y
&
1
);
bool
p
=
(
polarizationGroup
&
1
);
__device__
float
computePScaleFactor
(
uint2
covalent
,
unsigned
int
polarizationGroup
,
int
index
)
{
int
mask
=
1
<<
index
;
bool
x
=
(
covalent
.
x
&
mask
);
bool
y
=
(
covalent
.
y
&
mask
);
bool
p
=
(
polarizationGroup
&
mask
);
return
(
x
&&
y
?
0.0
f
:
(
x
&&
p
?
0.5
f
:
1.0
f
));
}
...
...
@@ -679,15 +680,12 @@ extern "C" __global__ void computeEDiffForce(
if
(
atom1
!=
atom2
&&
atom1
<
NUM_ATOMS
&&
atom2
<
NUM_ATOMS
)
{
real3
tempForce
;
real
tempEnergy
;
float
d
=
computeDScaleFactor
(
polarizationGroup
);
float
p
=
computePScaleFactor
(
covalent
,
polarizationGroup
);
float
d
=
computeDScaleFactor
(
polarizationGroup
,
j
);
float
p
=
computePScaleFactor
(
covalent
,
polarizationGroup
,
j
);
computeOneEDiffInteractionF1
(
data
,
localData
[
tbx
+
j
],
d
,
p
,
tempEnergy
,
tempForce
);
energy
+=
0.25
f
*
tempEnergy
;
data
.
force
+=
tempForce
;
}
covalent
.
x
>>=
1
;
covalent
.
y
>>=
1
;
polarizationGroup
>>=
1
;
}
data
.
force
*=
ENERGY_SCALE_FACTOR
;
atomicAdd
(
&
forceBuffers
[
atom1
],
static_cast
<
unsigned
long
long
>
((
long
long
)
(
data
.
force
.
x
*
0xFFFFFFFF
)));
...
...
@@ -698,20 +696,15 @@ extern "C" __global__ void computeEDiffForce(
// Compute torques.
data
.
force
=
make_real3
(
0
);
covalent
=
covalentFlags
[
exclusionIndex
[
localGroupIndex
]
+
tgx
];
polarizationGroup
=
polarizationGroupFlags
[
exclusionIndex
[
localGroupIndex
]
+
tgx
];
for
(
unsigned
int
j
=
0
;
j
<
TILE_SIZE
;
j
++
)
{
int
atom2
=
y
*
TILE_SIZE
+
j
;
if
(
atom1
!=
atom2
&&
atom1
<
NUM_ATOMS
&&
atom2
<
NUM_ATOMS
)
{
real3
tempTorque
;
float
d
=
computeDScaleFactor
(
polarizationGroup
);
float
p
=
computePScaleFactor
(
covalent
,
polarizationGroup
);
float
d
=
computeDScaleFactor
(
polarizationGroup
,
j
);
float
p
=
computePScaleFactor
(
covalent
,
polarizationGroup
,
j
);
computeOneEDiffInteractionT1
(
data
,
localData
[
tbx
+
j
],
d
,
p
,
tempTorque
);
data
.
force
+=
tempTorque
;
}
covalent
.
x
>>=
1
;
covalent
.
y
>>=
1
;
polarizationGroup
>>=
1
;
}
data
.
force
*=
ENERGY_SCALE_FACTOR
;
atomicAdd
(
&
torqueBuffers
[
atom1
],
static_cast
<
unsigned
long
long
>
((
long
long
)
(
data
.
force
.
x
*
0xFFFFFFFF
)));
...
...
@@ -726,9 +719,6 @@ extern "C" __global__ void computeEDiffForce(
localData
[
threadIdx
.
x
].
force
=
make_real3
(
0
);
uint2
covalent
=
(
hasExclusions
?
covalentFlags
[
exclusionIndex
[
localGroupIndex
]
+
tgx
]
:
make_uint2
(
0
,
0
));
unsigned
int
polarizationGroup
=
(
hasExclusions
?
polarizationGroupFlags
[
exclusionIndex
[
localGroupIndex
]
+
tgx
]
:
0
);
covalent
.
x
=
(
covalent
.
x
>>
tgx
)
|
(
covalent
.
x
<<
(
TILE_SIZE
-
tgx
));
covalent
.
y
=
(
covalent
.
y
>>
tgx
)
|
(
covalent
.
y
<<
(
TILE_SIZE
-
tgx
));
polarizationGroup
=
(
polarizationGroup
>>
tgx
)
|
(
polarizationGroup
<<
(
TILE_SIZE
-
tgx
));
// Compute forces.
...
...
@@ -738,16 +728,13 @@ extern "C" __global__ void computeEDiffForce(
if
(
atom1
<
NUM_ATOMS
&&
atom2
<
NUM_ATOMS
)
{
real3
tempForce
;
real
tempEnergy
;
float
d
=
computeDScaleFactor
(
polarizationGroup
);
float
p
=
computePScaleFactor
(
covalent
,
polarizationGroup
);
float
d
=
computeDScaleFactor
(
polarizationGroup
,
tj
);
float
p
=
computePScaleFactor
(
covalent
,
polarizationGroup
,
tj
);
computeOneEDiffInteractionF1
(
data
,
localData
[
tbx
+
tj
],
d
,
p
,
tempEnergy
,
tempForce
);
energy
+=
0.5
f
*
tempEnergy
;
data
.
force
+=
tempForce
;
localData
[
tbx
+
tj
].
force
-=
tempForce
;
}
covalent
.
x
>>=
1
;
covalent
.
y
>>=
1
;
polarizationGroup
>>=
1
;
tj
=
(
tj
+
1
)
&
(
TILE_SIZE
-
1
);
}
data
.
force
*=
ENERGY_SCALE_FACTOR
;
...
...
@@ -762,44 +749,36 @@ extern "C" __global__ void computeEDiffForce(
atomicAdd
(
&
forceBuffers
[
offset
+
PADDED_NUM_ATOMS
],
static_cast
<
unsigned
long
long
>
((
long
long
)
(
localData
[
threadIdx
.
x
].
force
.
y
*
0xFFFFFFFF
)));
atomicAdd
(
&
forceBuffers
[
offset
+
2
*
PADDED_NUM_ATOMS
],
static_cast
<
unsigned
long
long
>
((
long
long
)
(
localData
[
threadIdx
.
x
].
force
.
z
*
0xFFFFFFFF
)));
}
// Compute torques.
data
.
force
=
make_real3
(
0
);
localData
[
threadIdx
.
x
].
force
=
make_real3
(
0
);
covalent
=
(
hasExclusions
?
covalentFlags
[
exclusionIndex
[
localGroupIndex
]
+
tgx
]
:
make_uint2
(
0
,
0
));
polarizationGroup
=
(
hasExclusions
?
polarizationGroupFlags
[
exclusionIndex
[
localGroupIndex
]
+
tgx
]
:
0
);
covalent
.
x
=
(
covalent
.
x
>>
tgx
)
|
(
covalent
.
x
<<
(
TILE_SIZE
-
tgx
));
covalent
.
y
=
(
covalent
.
y
>>
tgx
)
|
(
covalent
.
y
<<
(
TILE_SIZE
-
tgx
));
polarizationGroup
=
(
polarizationGroup
>>
tgx
)
|
(
polarizationGroup
<<
(
TILE_SIZE
-
tgx
));
for
(
j
=
0
;
j
<
TILE_SIZE
;
j
++
)
{
int
atom2
=
y
*
TILE_SIZE
+
tj
;
if
(
atom1
<
NUM_ATOMS
&&
atom2
<
NUM_ATOMS
)
{
real3
tempTorque
;
float
d
=
computeDScaleFactor
(
polarizationGroup
);
float
p
=
computePScaleFactor
(
covalent
,
polarizationGroup
);
computeOneEDiffInteractionT1
(
data
,
localData
[
tbx
+
tj
],
d
,
p
,
tempTorque
);
data
.
force
+=
tempTorque
;
computeOneEDiffInteractionT3
(
data
,
localData
[
tbx
+
tj
],
d
,
p
,
tempTorque
);
localData
[
tbx
+
tj
].
force
+=
tempTorque
;
}
covalent
.
x
>>=
1
;
covalent
.
y
>>=
1
;
polarizationGroup
>>=
1
;
tj
=
(
tj
+
1
)
&
(
TILE_SIZE
-
1
);
}
data
.
force
*=
ENERGY_SCALE_FACTOR
;
localData
[
threadIdx
.
x
].
force
*=
ENERGY_SCALE_FACTOR
;
if
(
pos
<
end
)
{
unsigned
int
offset
=
x
*
TILE_SIZE
+
tgx
;
atomicAdd
(
&
torqueBuffers
[
offset
],
static_cast
<
unsigned
long
long
>
((
long
long
)
(
data
.
force
.
x
*
0xFFFFFFFF
)));
atomicAdd
(
&
torqueBuffers
[
offset
+
PADDED_NUM_ATOMS
],
static_cast
<
unsigned
long
long
>
((
long
long
)
(
data
.
force
.
y
*
0xFFFFFFFF
)));
atomicAdd
(
&
torqueBuffers
[
offset
+
2
*
PADDED_NUM_ATOMS
],
static_cast
<
unsigned
long
long
>
((
long
long
)
(
data
.
force
.
z
*
0xFFFFFFFF
)));
offset
=
y
*
TILE_SIZE
+
tgx
;
atomicAdd
(
&
torqueBuffers
[
offset
],
static_cast
<
unsigned
long
long
>
((
long
long
)
(
localData
[
threadIdx
.
x
].
force
.
x
*
0xFFFFFFFF
)));
atomicAdd
(
&
torqueBuffers
[
offset
+
PADDED_NUM_ATOMS
],
static_cast
<
unsigned
long
long
>
((
long
long
)
(
localData
[
threadIdx
.
x
].
force
.
y
*
0xFFFFFFFF
)));
atomicAdd
(
&
torqueBuffers
[
offset
+
2
*
PADDED_NUM_ATOMS
],
static_cast
<
unsigned
long
long
>
((
long
long
)
(
localData
[
threadIdx
.
x
].
force
.
z
*
0xFFFFFFFF
)));
// Compute torques.
data
.
force
=
make_real3
(
0
);
localData
[
threadIdx
.
x
].
force
=
make_real3
(
0
);
for
(
j
=
0
;
j
<
TILE_SIZE
;
j
++
)
{
int
atom2
=
y
*
TILE_SIZE
+
tj
;
if
(
atom1
<
NUM_ATOMS
&&
atom2
<
NUM_ATOMS
)
{
real3
tempTorque
;
float
d
=
computeDScaleFactor
(
polarizationGroup
,
tj
);
float
p
=
computePScaleFactor
(
covalent
,
polarizationGroup
,
tj
);
computeOneEDiffInteractionT1
(
data
,
localData
[
tbx
+
tj
],
d
,
p
,
tempTorque
);
data
.
force
+=
tempTorque
;
computeOneEDiffInteractionT3
(
data
,
localData
[
tbx
+
tj
],
d
,
p
,
tempTorque
);
localData
[
tbx
+
tj
].
force
+=
tempTorque
;
}
tj
=
(
tj
+
1
)
&
(
TILE_SIZE
-
1
);
}
data
.
force
*=
ENERGY_SCALE_FACTOR
;
localData
[
threadIdx
.
x
].
force
*=
ENERGY_SCALE_FACTOR
;
if
(
pos
<
end
)
{
unsigned
int
offset
=
x
*
TILE_SIZE
+
tgx
;
atomicAdd
(
&
torqueBuffers
[
offset
],
static_cast
<
unsigned
long
long
>
((
long
long
)
(
data
.
force
.
x
*
0xFFFFFFFF
)));
atomicAdd
(
&
torqueBuffers
[
offset
+
PADDED_NUM_ATOMS
],
static_cast
<
unsigned
long
long
>
((
long
long
)
(
data
.
force
.
y
*
0xFFFFFFFF
)));
atomicAdd
(
&
torqueBuffers
[
offset
+
2
*
PADDED_NUM_ATOMS
],
static_cast
<
unsigned
long
long
>
((
long
long
)
(
data
.
force
.
z
*
0xFFFFFFFF
)));
offset
=
y
*
TILE_SIZE
+
tgx
;
atomicAdd
(
&
torqueBuffers
[
offset
],
static_cast
<
unsigned
long
long
>
((
long
long
)
(
localData
[
threadIdx
.
x
].
force
.
x
*
0xFFFFFFFF
)));
atomicAdd
(
&
torqueBuffers
[
offset
+
PADDED_NUM_ATOMS
],
static_cast
<
unsigned
long
long
>
((
long
long
)
(
localData
[
threadIdx
.
x
].
force
.
y
*
0xFFFFFFFF
)));
atomicAdd
(
&
torqueBuffers
[
offset
+
2
*
PADDED_NUM_ATOMS
],
static_cast
<
unsigned
long
long
>
((
long
long
)
(
localData
[
threadIdx
.
x
].
force
.
z
*
0xFFFFFFFF
)));
}
}
}
pos
++
;
...
...
plugins/amoeba/platforms/cuda2/src/kernels/multipoleElectrostatics.cu
View file @
1cb85ba3
...
...
@@ -35,20 +35,22 @@ inline __device__ void loadAtomData(AtomData& data, int atom, const real4* __res
data
.
thole
=
temp
.
y
;
}
__device__
real
computeDScaleFactor
(
unsigned
int
polarizationGroup
)
{
return
(
polarizationGroup
&
1
?
0
:
1
);
__device__
real
computeDScaleFactor
(
unsigned
int
polarizationGroup
,
int
index
)
{
return
(
polarizationGroup
&
1
<<
index
?
0
:
1
);
}
__device__
float
computeMScaleFactor
(
uint2
covalent
)
{
bool
x
=
(
covalent
.
x
&
1
);
bool
y
=
(
covalent
.
y
&
1
);
__device__
float
computeMScaleFactor
(
uint2
covalent
,
int
index
)
{
int
mask
=
1
<<
index
;
bool
x
=
(
covalent
.
x
&
mask
);
bool
y
=
(
covalent
.
y
&
mask
);
return
(
x
?
(
y
?
0.0
f
:
0.4
f
)
:
(
y
?
0.8
f
:
1.0
f
));
}
__device__
float
computePScaleFactor
(
uint2
covalent
,
unsigned
int
polarizationGroup
)
{
bool
x
=
(
covalent
.
x
&
1
);
bool
y
=
(
covalent
.
y
&
1
);
bool
p
=
(
polarizationGroup
&
1
);
__device__
float
computePScaleFactor
(
uint2
covalent
,
unsigned
int
polarizationGroup
,
int
index
)
{
int
mask
=
1
<<
index
;
bool
x
=
(
covalent
.
x
&
mask
);
bool
y
=
(
covalent
.
y
&
mask
);
bool
p
=
(
polarizationGroup
&
mask
);
return
(
x
&&
y
?
0.0
f
:
(
x
&&
p
?
0.5
f
:
1.0
f
));
}
...
...
@@ -147,16 +149,13 @@ extern "C" __global__ void computeElectrostatics(
if
(
atom1
!=
atom2
&&
atom1
<
NUM_ATOMS
&&
atom2
<
NUM_ATOMS
)
{
real3
tempForce
;
real
tempEnergy
;
float
d
=
computeDScaleFactor
(
polarizationGroup
);
float
p
=
computePScaleFactor
(
covalent
,
polarizationGroup
);
float
m
=
computeMScaleFactor
(
covalent
);
float
d
=
computeDScaleFactor
(
polarizationGroup
,
j
);
float
p
=
computePScaleFactor
(
covalent
,
polarizationGroup
,
j
);
float
m
=
computeMScaleFactor
(
covalent
,
j
);
computeOneInteractionF1
(
data
,
localData
[
tbx
+
j
],
d
,
p
,
m
,
tempEnergy
,
tempForce
);
data
.
force
+=
tempForce
;
energy
+=
0.5
f
*
tempEnergy
;
}
covalent
.
x
>>=
1
;
covalent
.
y
>>=
1
;
polarizationGroup
>>=
1
;
}
data
.
force
*=
ENERGY_SCALE_FACTOR
;
atomicAdd
(
&
forceBuffers
[
atom1
],
static_cast
<
unsigned
long
long
>
((
long
long
)
(
data
.
force
.
x
*
0xFFFFFFFF
)));
...
...
@@ -166,21 +165,16 @@ extern "C" __global__ void computeElectrostatics(
// Compute torques.
data
.
force
=
make_real3
(
0
);
covalent
=
covalentFlags
[
exclusionIndex
[
localGroupIndex
]
+
tgx
];
polarizationGroup
=
polarizationGroupFlags
[
exclusionIndex
[
localGroupIndex
]
+
tgx
];
for
(
unsigned
int
j
=
0
;
j
<
TILE_SIZE
;
j
++
)
{
int
atom2
=
y
*
TILE_SIZE
+
j
;
if
(
atom1
!=
atom2
&&
atom1
<
NUM_ATOMS
&&
atom2
<
NUM_ATOMS
)
{
real3
tempForce
;
float
d
=
computeDScaleFactor
(
polarizationGroup
);
float
p
=
computePScaleFactor
(
covalent
,
polarizationGroup
);
float
m
=
computeMScaleFactor
(
covalent
);
float
d
=
computeDScaleFactor
(
polarizationGroup
,
j
);
float
p
=
computePScaleFactor
(
covalent
,
polarizationGroup
,
j
);
float
m
=
computeMScaleFactor
(
covalent
,
j
);
computeOneInteractionT1
(
data
,
localData
[
tbx
+
j
],
d
,
p
,
m
,
tempForce
);
data
.
force
+=
tempForce
;
}
covalent
.
x
>>=
1
;
covalent
.
y
>>=
1
;
polarizationGroup
>>=
1
;
}
data
.
force
*=
ENERGY_SCALE_FACTOR
;
atomicAdd
(
&
torqueBuffers
[
atom1
],
static_cast
<
unsigned
long
long
>
((
long
long
)
(
data
.
force
.
x
*
0xFFFFFFFF
)));
...
...
@@ -324,9 +318,6 @@ extern "C" __global__ void computeElectrostatics(
uint2
covalent
=
(
hasExclusions
?
covalentFlags
[
exclusionIndex
[
localGroupIndex
]
+
tgx
]
:
make_uint2
(
0
,
0
));
unsigned
int
polarizationGroup
=
(
hasExclusions
?
polarizationGroupFlags
[
exclusionIndex
[
localGroupIndex
]
+
tgx
]
:
0
);
covalent
.
x
=
(
covalent
.
x
>>
tgx
)
|
(
covalent
.
x
<<
(
TILE_SIZE
-
tgx
));
covalent
.
y
=
(
covalent
.
y
>>
tgx
)
|
(
covalent
.
y
<<
(
TILE_SIZE
-
tgx
));
polarizationGroup
=
(
polarizationGroup
>>
tgx
)
|
(
polarizationGroup
<<
(
TILE_SIZE
-
tgx
));
// Compute forces.
...
...
@@ -336,17 +327,14 @@ extern "C" __global__ void computeElectrostatics(
if
(
atom1
<
NUM_ATOMS
&&
atom2
<
NUM_ATOMS
)
{
real3
tempForce
;
real
tempEnergy
;
float
d
=
computeDScaleFactor
(
polarizationGroup
);
float
p
=
computePScaleFactor
(
covalent
,
polarizationGroup
);
float
m
=
computeMScaleFactor
(
covalent
);
float
d
=
computeDScaleFactor
(
polarizationGroup
,
tj
);
float
p
=
computePScaleFactor
(
covalent
,
polarizationGroup
,
tj
);
float
m
=
computeMScaleFactor
(
covalent
,
tj
);
computeOneInteractionF1
(
data
,
localData
[
tbx
+
tj
],
d
,
p
,
m
,
tempEnergy
,
tempForce
);
data
.
force
+=
tempForce
;
localData
[
tbx
+
tj
].
force
-=
tempForce
;
energy
+=
tempEnergy
;
}
covalent
.
x
>>=
1
;
covalent
.
y
>>=
1
;
polarizationGroup
>>=
1
;
tj
=
(
tj
+
1
)
&
(
TILE_SIZE
-
1
);
}
data
.
force
*=
ENERGY_SCALE_FACTOR
;
...
...
@@ -366,26 +354,18 @@ extern "C" __global__ void computeElectrostatics(
data
.
force
=
make_real3
(
0
);
localData
[
threadIdx
.
x
].
force
=
make_real3
(
0
);
covalent
=
(
hasExclusions
?
covalentFlags
[
exclusionIndex
[
localGroupIndex
]
+
tgx
]
:
make_uint2
(
0
,
0
));
polarizationGroup
=
(
hasExclusions
?
polarizationGroupFlags
[
exclusionIndex
[
localGroupIndex
]
+
tgx
]
:
0
);
covalent
.
x
=
(
covalent
.
x
>>
tgx
)
|
(
covalent
.
x
<<
(
TILE_SIZE
-
tgx
));
covalent
.
y
=
(
covalent
.
y
>>
tgx
)
|
(
covalent
.
y
<<
(
TILE_SIZE
-
tgx
));
polarizationGroup
=
(
polarizationGroup
>>
tgx
)
|
(
polarizationGroup
<<
(
TILE_SIZE
-
tgx
));
for
(
j
=
0
;
j
<
TILE_SIZE
;
j
++
)
{
int
atom2
=
y
*
TILE_SIZE
+
tj
;
if
(
atom1
<
NUM_ATOMS
&&
atom2
<
NUM_ATOMS
)
{
real3
tempForce
;
float
d
=
computeDScaleFactor
(
polarizationGroup
);
float
p
=
computePScaleFactor
(
covalent
,
polarizationGroup
);
float
m
=
computeMScaleFactor
(
covalent
);
float
d
=
computeDScaleFactor
(
polarizationGroup
,
tj
);
float
p
=
computePScaleFactor
(
covalent
,
polarizationGroup
,
tj
);
float
m
=
computeMScaleFactor
(
covalent
,
tj
);
computeOneInteractionT1
(
data
,
localData
[
tbx
+
tj
],
d
,
p
,
m
,
tempForce
);
data
.
force
+=
tempForce
;
computeOneInteractionT3
(
data
,
localData
[
tbx
+
tj
],
d
,
p
,
m
,
tempForce
);
localData
[
tbx
+
tj
].
force
+=
tempForce
;
}
covalent
.
x
>>=
1
;
covalent
.
y
>>=
1
;
polarizationGroup
>>=
1
;
tj
=
(
tj
+
1
)
&
(
TILE_SIZE
-
1
);
}
data
.
force
*=
ENERGY_SCALE_FACTOR
;
...
...
plugins/amoeba/platforms/cuda2/src/kernels/multipoleFixedField.cu
View file @
1cb85ba3
...
...
@@ -381,14 +381,15 @@ __device__ void computeOneGkInteraction(AtomData& atom1, AtomData& atom2, real3
}
#endif
__device__
real
computeDScaleFactor
(
unsigned
int
polarizationGroup
)
{
return
(
polarizationGroup
&
1
?
0
:
1
);
__device__
real
computeDScaleFactor
(
unsigned
int
polarizationGroup
,
int
index
)
{
return
(
polarizationGroup
&
1
<<
index
?
0
:
1
);
}
__device__
float
computePScaleFactor
(
uint2
covalent
,
unsigned
int
polarizationGroup
)
{
bool
x
=
(
covalent
.
x
&
1
);
bool
y
=
(
covalent
.
y
&
1
);
bool
p
=
(
polarizationGroup
&
1
);
__device__
float
computePScaleFactor
(
uint2
covalent
,
unsigned
int
polarizationGroup
,
int
index
)
{
int
mask
=
1
<<
index
;
bool
x
=
(
covalent
.
x
&
mask
);
bool
y
=
(
covalent
.
y
&
mask
);
bool
p
=
(
polarizationGroup
&
mask
);
return
(
x
&&
y
?
0.0
f
:
(
x
&&
p
?
0.5
f
:
1.0
f
));
}
...
...
@@ -499,8 +500,8 @@ extern "C" __global__ void computeFixedField(
int
atom2
=
y
*
TILE_SIZE
+
j
;
if
(
atom1
!=
atom2
&&
atom1
<
NUM_ATOMS
&&
atom2
<
NUM_ATOMS
)
{
real3
fields
[
4
];
float
d
=
computeDScaleFactor
(
polarizationGroup
);
float
p
=
computePScaleFactor
(
covalent
,
polarizationGroup
);
float
d
=
computeDScaleFactor
(
polarizationGroup
,
j
);
float
p
=
computePScaleFactor
(
covalent
,
polarizationGroup
,
j
);
computeOneInteraction
(
data
,
localData
[
tbx
+
j
],
delta
,
d
,
p
,
fields
);
data
.
field
+=
fields
[
0
];
data
.
fieldPolar
+=
fields
[
1
];
...
...
@@ -512,9 +513,6 @@ extern "C" __global__ void computeFixedField(
data
.
gkField
+=
fields
[
0
];
}
#endif
covalent
.
x
>>=
1
;
covalent
.
y
>>=
1
;
polarizationGroup
>>=
1
;
}
}
else
{
...
...
@@ -604,9 +602,6 @@ extern "C" __global__ void computeFixedField(
uint2
covalent
=
(
hasExclusions
?
covalentFlags
[
exclusionIndex
[
localGroupIndex
]
+
tgx
]
:
make_uint2
(
0
,
0
));
unsigned
int
polarizationGroup
=
(
hasExclusions
?
polarizationGroupFlags
[
exclusionIndex
[
localGroupIndex
]
+
tgx
]
:
0
);
covalent
.
x
=
(
covalent
.
x
>>
tgx
)
|
(
covalent
.
x
<<
(
TILE_SIZE
-
tgx
));
covalent
.
y
=
(
covalent
.
y
>>
tgx
)
|
(
covalent
.
y
<<
(
TILE_SIZE
-
tgx
));
polarizationGroup
=
(
polarizationGroup
>>
tgx
)
|
(
polarizationGroup
<<
(
TILE_SIZE
-
tgx
));
unsigned
int
tj
=
tgx
;
for
(
j
=
0
;
j
<
TILE_SIZE
;
j
++
)
{
real3
delta
=
trimTo3
(
localData
[
tbx
+
tj
].
posq
-
data
.
posq
);
...
...
@@ -618,8 +613,8 @@ extern "C" __global__ void computeFixedField(
int
atom2
=
y
*
TILE_SIZE
+
tj
;
if
(
atom1
<
NUM_ATOMS
&&
atom2
<
NUM_ATOMS
)
{
real3
fields
[
4
];
float
d
=
computeDScaleFactor
(
polarizationGroup
);
float
p
=
computePScaleFactor
(
covalent
,
polarizationGroup
);
float
d
=
computeDScaleFactor
(
polarizationGroup
,
tj
);
float
p
=
computePScaleFactor
(
covalent
,
polarizationGroup
,
tj
);
computeOneInteraction
(
data
,
localData
[
tbx
+
tj
],
delta
,
d
,
p
,
fields
);
data
.
field
+=
fields
[
0
];
data
.
fieldPolar
+=
fields
[
1
];
...
...
@@ -631,9 +626,6 @@ extern "C" __global__ void computeFixedField(
localData
[
tbx
+
tj
].
gkField
+=
fields
[
1
];
#endif
}
covalent
.
x
>>=
1
;
covalent
.
y
>>=
1
;
polarizationGroup
>>=
1
;
tj
=
(
tj
+
1
)
&
(
TILE_SIZE
-
1
);
}
}
...
...
plugins/amoeba/platforms/cuda2/src/kernels/pmeMultipoleElectrostatics.cu
View file @
1cb85ba3
...
...
@@ -41,20 +41,22 @@ inline __device__ void loadAtomData(AtomData& data, int atom, const real4* __res
data
.
thole
=
temp
.
y
;
}
__device__
real
computeDScaleFactor
(
unsigned
int
polarizationGroup
)
{
return
(
polarizationGroup
&
1
?
0
:
1
);
__device__
real
computeDScaleFactor
(
unsigned
int
polarizationGroup
,
int
index
)
{
return
(
polarizationGroup
&
1
<<
index
?
0
:
1
);
}
__device__
float
computeMScaleFactor
(
uint2
covalent
)
{
bool
x
=
(
covalent
.
x
&
1
);
bool
y
=
(
covalent
.
y
&
1
);
__device__
float
computeMScaleFactor
(
uint2
covalent
,
int
index
)
{
int
mask
=
1
<<
index
;
bool
x
=
(
covalent
.
x
&
mask
);
bool
y
=
(
covalent
.
y
&
mask
);
return
(
x
?
(
y
?
0.0
f
:
0.4
f
)
:
(
y
?
0.8
f
:
1.0
f
));
}
__device__
float
computePScaleFactor
(
uint2
covalent
,
unsigned
int
polarizationGroup
)
{
bool
x
=
(
covalent
.
x
&
1
);
bool
y
=
(
covalent
.
y
&
1
);
bool
p
=
(
polarizationGroup
&
1
);
__device__
float
computePScaleFactor
(
uint2
covalent
,
unsigned
int
polarizationGroup
,
int
index
)
{
int
mask
=
1
<<
index
;
bool
x
=
(
covalent
.
x
&
mask
);
bool
y
=
(
covalent
.
y
&
mask
);
bool
p
=
(
polarizationGroup
&
mask
);
return
(
x
&&
y
?
0.0
f
:
(
x
&&
p
?
0.5
f
:
1.0
f
));
}
...
...
@@ -270,14 +272,11 @@ extern "C" __global__ void computeElectrostatics(
for
(
unsigned
int
j
=
0
;
j
<
TILE_SIZE
;
j
++
)
{
int
atom2
=
y
*
TILE_SIZE
+
j
;
if
(
atom1
!=
atom2
&&
atom1
<
NUM_ATOMS
&&
atom2
<
NUM_ATOMS
)
{
float
d
=
computeDScaleFactor
(
polarizationGroup
);
float
p
=
computePScaleFactor
(
covalent
,
polarizationGroup
);
float
m
=
computeMScaleFactor
(
covalent
);
float
d
=
computeDScaleFactor
(
polarizationGroup
,
j
);
float
p
=
computePScaleFactor
(
covalent
,
polarizationGroup
,
j
);
float
m
=
computeMScaleFactor
(
covalent
,
j
);
computeOneInteraction
(
data
,
localData
[
tbx
+
j
],
hasExclusions
,
d
,
p
,
m
,
0.5
f
,
energy
,
periodicBoxSize
,
invPeriodicBoxSize
);
}
covalent
.
x
>>=
1
;
covalent
.
y
>>=
1
;
polarizationGroup
>>=
1
;
}
if
(
atom1
<
NUM_ATOMS
)
computeSelfEnergyAndTorque
(
data
,
energy
);
...
...
@@ -391,9 +390,6 @@ extern "C" __global__ void computeElectrostatics(
uint2
covalent
=
(
hasExclusions
?
covalentFlags
[
exclusionIndex
[
localGroupIndex
]
+
tgx
]
:
make_uint2
(
0
,
0
));
unsigned
int
polarizationGroup
=
(
hasExclusions
?
polarizationGroupFlags
[
exclusionIndex
[
localGroupIndex
]
+
tgx
]
:
0
);
covalent
.
x
=
(
covalent
.
x
>>
tgx
)
|
(
covalent
.
x
<<
(
TILE_SIZE
-
tgx
));
covalent
.
y
=
(
covalent
.
y
>>
tgx
)
|
(
covalent
.
y
<<
(
TILE_SIZE
-
tgx
));
polarizationGroup
=
(
polarizationGroup
>>
tgx
)
|
(
polarizationGroup
<<
(
TILE_SIZE
-
tgx
));
// Compute forces.
...
...
@@ -401,14 +397,11 @@ extern "C" __global__ void computeElectrostatics(
for
(
j
=
0
;
j
<
TILE_SIZE
;
j
++
)
{
int
atom2
=
y
*
TILE_SIZE
+
tj
;
if
(
atom1
<
NUM_ATOMS
&&
atom2
<
NUM_ATOMS
)
{
float
d
=
computeDScaleFactor
(
polarizationGroup
);
float
p
=
computePScaleFactor
(
covalent
,
polarizationGroup
);
float
m
=
computeMScaleFactor
(
covalent
);
float
d
=
computeDScaleFactor
(
polarizationGroup
,
tj
);
float
p
=
computePScaleFactor
(
covalent
,
polarizationGroup
,
tj
);
float
m
=
computeMScaleFactor
(
covalent
,
tj
);
computeOneInteraction
(
data
,
localData
[
tbx
+
tj
],
hasExclusions
,
d
,
p
,
m
,
1
,
energy
,
periodicBoxSize
,
invPeriodicBoxSize
);
}
covalent
.
x
>>=
1
;
covalent
.
y
>>=
1
;
polarizationGroup
>>=
1
;
tj
=
(
tj
+
1
)
&
(
TILE_SIZE
-
1
);
}
data
.
force
*=
-
ENERGY_SCALE_FACTOR
;
...
...
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