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
4c107329
"csrc/gfx93/vscode:/vscode.git/clone" did not exist on "c353b35b3c90f8aeb684261d882f3c7975bb5d51"
Unverified
Commit
4c107329
authored
Dec 14, 2023
by
Peter Eastman
Committed by
GitHub
Dec 14, 2023
Browse files
Fixed bug in large blocks optimization with triclinic boxes (#4351)
parent
4717c840
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
16 deletions
+28
-16
platforms/cuda/src/kernels/findInteractingBlocks.cu
platforms/cuda/src/kernels/findInteractingBlocks.cu
+14
-8
platforms/opencl/src/kernels/findInteractingBlocks.cl
platforms/opencl/src/kernels/findInteractingBlocks.cl
+14
-8
No files found.
platforms/cuda/src/kernels/findInteractingBlocks.cu
View file @
4c107329
...
...
@@ -146,19 +146,17 @@ extern "C" __global__ void sortBoxData(const unsigned int* __restrict__ sortedBl
unsigned
int
index
=
sortedBlocks
[
i
]
&
BLOCK_INDEX_MASK
;
sortedBlockCenter
[
i
]
=
blockCenter
[
index
];
sortedBlockBoundingBox
[
i
]
=
half3
(
trimTo3
(
blockBoundingBox
[
index
]));
}
#ifdef USE_LARGE_BLOCKS
// Compute the sizes of large blocks (composed of 32 regular blocks) starting from each block.
// Compute the sizes of large blocks (composed of 32 regular blocks) starting from each block.
for
(
int
i
=
threadIdx
.
x
+
blockIdx
.
x
*
blockDim
.
x
;
i
<
NUM_BLOCKS
;
i
+=
blockDim
.
x
*
gridDim
.
x
)
{
unsigned
int
index
=
sortedBlocks
[
i
]
&
BLOCK_INDEX_MASK
;
real4
minPos
=
blockCenter
[
index
]
-
blockBoundingBox
[
index
];
real4
maxPos
=
blockCenter
[
index
]
+
blockBoundingBox
[
index
];
int
last
=
min
(
i
+
32
,
NUM_BLOCKS
);
for
(
int
j
=
i
+
1
;
j
<
last
;
j
++
)
{
index
=
sortedBlocks
[
j
]
&
BLOCK_INDEX_MASK
;
real4
blockPos
=
blockCenter
[
index
];
real4
width
=
blockBoundingBox
[
index
];
unsigned
int
index
2
=
sortedBlocks
[
j
]
&
BLOCK_INDEX_MASK
;
real4
blockPos
=
blockCenter
[
index
2
];
real4
width
=
blockBoundingBox
[
index
2
];
#ifdef USE_PERIODIC
real4
center
=
0.5
f
*
(
maxPos
+
minPos
);
APPLY_PERIODIC_TO_POS_WITH_CENTER
(
blockPos
,
center
)
...
...
@@ -168,8 +166,9 @@ extern "C" __global__ void sortBoxData(const unsigned int* __restrict__ sortedBl
}
largeBlockCenter
[
i
]
=
0.5
f
*
(
maxPos
+
minPos
);
largeBlockBoundingBox
[
i
]
=
half3
(
trimTo3
(
0.5
f
*
(
maxPos
-
minPos
)));
}
#endif
}
// Also check whether any atom has moved enough so that we really need to rebuild the neighbor list.
bool
rebuild
=
forceRebuild
;
...
...
@@ -377,6 +376,13 @@ extern "C" __global__ __launch_bounds__(GROUP_SIZE,3) void findBlocksWithInterac
blockDelta
.
y
=
max
(
0.0
f
,
fabs
(
blockDelta
.
y
)
-
blockSizeX
.
y
-
largeSize
.
y
);
blockDelta
.
z
=
max
(
0.0
f
,
fabs
(
blockDelta
.
z
)
-
blockSizeX
.
z
-
largeSize
.
z
);
includeLargeBlock
=
(
blockDelta
.
x
*
blockDelta
.
x
+
blockDelta
.
y
*
blockDelta
.
y
+
blockDelta
.
z
*
blockDelta
.
z
<
PADDED_CUTOFF_SQUARED
);
#ifdef TRICLINIC
// The calculation to find the nearest periodic copy is only guaranteed to work if the nearest copy is less than half a box width away.
// If there's any possibility we might have missed it, do a detailed check.
if
(
periodicBoxSize
.
z
/
2
-
blockSizeX
.
z
-
largeSize
.
z
<
PADDED_CUTOFF
||
periodicBoxSize
.
y
/
2
-
blockSizeX
.
y
-
largeSize
.
y
<
PADDED_CUTOFF
)
includeLargeBlock
=
true
;
#endif
}
largeBlockFlags
=
BALLOT
(
includeLargeBlock
);
loadedLargeBlocks
=
32
;
...
...
platforms/opencl/src/kernels/findInteractingBlocks.cl
View file @
4c107329
...
...
@@ -112,19 +112,17 @@ __kernel void sortBoxData(__global const unsigned int* restrict sortedBlocks, __
unsigned
int
index
=
sortedBlocks[i]
&
BLOCK_INDEX_MASK
;
sortedBlockCenter[i]
=
blockCenter[index]
;
sortedBlockBoundingBox[i]
=
blockBoundingBox[index]
;
}
#
ifdef
USE_LARGE_BLOCKS
//
Compute
the
sizes
of
large
blocks
(
composed
of
32
regular
blocks
)
starting
from
each
block.
//
Compute
the
sizes
of
large
blocks
(
composed
of
32
regular
blocks
)
starting
from
each
block.
for
(
int
i
=
get_global_id
(
0
)
; i < NUM_BLOCKS; i += get_global_size(0)) {
unsigned
int
index
=
sortedBlocks[i]
&
BLOCK_INDEX_MASK
;
real4
minPos
=
blockCenter[index]-blockBoundingBox[index]
;
real4
maxPos
=
blockCenter[index]+blockBoundingBox[index]
;
int
last
=
min
(
i+32,
NUM_BLOCKS
)
;
for
(
int
j
=
i+1
; j < last; j++) {
index
=
sortedBlocks[j]
&
BLOCK_INDEX_MASK
;
real4
blockPos
=
blockCenter[index]
;
real4
width
=
blockBoundingBox[index]
;
unsigned
int
index
2
=
sortedBlocks[j]
&
BLOCK_INDEX_MASK
;
real4
blockPos
=
blockCenter[index
2
]
;
real4
width
=
blockBoundingBox[index
2
]
;
#
ifdef
USE_PERIODIC
real4
center
=
0.5f*
(
maxPos+minPos
)
;
APPLY_PERIODIC_TO_POS_WITH_CENTER
(
blockPos,
center
)
...
...
@@ -134,8 +132,9 @@ __kernel void sortBoxData(__global const unsigned int* restrict sortedBlocks, __
}
largeBlockCenter[i]
=
0.5f*
(
maxPos+minPos
)
;
largeBlockBoundingBox[i]
=
0.5f*
(
maxPos-minPos
)
;
}
#
endif
}
//
Also
check
whether
any
atom
has
moved
enough
so
that
we
really
need
to
rebuild
the
neighbor
list.
bool
rebuild
=
forceRebuild
;
...
...
@@ -245,6 +244,13 @@ __kernel void findBlocksWithInteractions(real4 periodicBoxSize, real4 invPeriodi
blockDelta.y
=
max
((
real
)
0
,
fabs
(
blockDelta.y
)
-blockSizeX.y-largeSize.y
)
;
blockDelta.z
=
max
((
real
)
0
,
fabs
(
blockDelta.z
)
-blockSizeX.z-largeSize.z
)
;
includeLargeBlock
=
(
blockDelta.x*blockDelta.x+blockDelta.y*blockDelta.y+blockDelta.z*blockDelta.z
<
PADDED_CUTOFF_SQUARED
)
;
#
ifdef
TRICLINIC
//
The
calculation
to
find
the
nearest
periodic
copy
is
only
guaranteed
to
work
if
the
nearest
copy
is
less
than
half
a
box
width
away.
//
If
there
's
any
possibility
we
might
have
missed
it,
do
a
detailed
check.
if
(
periodicBoxSize.z/2-blockSizeX.z-largeSize.z
<
PADDED_CUTOFF
|
| periodicBoxSize.y/2-blockSizeX.y-largeSize.y < PADDED_CUTOFF)
includeLargeBlock = true;
#endif
}
largeBlockFlags[get_local_id(0)] = includeLargeBlock;
loadedLargeBlocks = 32;
...
...
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