Skip to content

Commit

Permalink
Fixed numeric overflow in computing interaction groups (openmm#4148)
Browse files Browse the repository at this point in the history
  • Loading branch information
peastman authored Jul 21, 2023
1 parent dd07fa7 commit ae5bc67
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions platforms/common/src/kernels/customNonbondedGroups.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ KERNEL void computeInteractionGroups(
LOCAL AtomData localData[LOCAL_MEMORY_SIZE];
LOCAL int reductionBuffer[LOCAL_MEMORY_SIZE];

const unsigned int startTile = (useNeighborList ? warp*numGroupTiles[0]/totalWarps : FIRST_TILE+warp*(LAST_TILE-FIRST_TILE)/totalWarps);
const unsigned int endTile = (useNeighborList ? (warp+1)*numGroupTiles[0]/totalWarps : FIRST_TILE+(warp+1)*(LAST_TILE-FIRST_TILE)/totalWarps);
mm_ulong wl = warp;
const unsigned int startTile = (unsigned int) (useNeighborList ? wl*numGroupTiles[0]/totalWarps : FIRST_TILE+wl*(LAST_TILE-FIRST_TILE)/totalWarps);
const unsigned int endTile = (unsigned int) (useNeighborList ? (wl+1)*numGroupTiles[0]/totalWarps : FIRST_TILE+(wl+1)*(LAST_TILE-FIRST_TILE)/totalWarps);
for (int tile = startTile; tile < endTile; tile++) {
const int4 atomData = groupData[TILE_SIZE*tile+tgx];
const int atom1 = atomData.x;
Expand Down Expand Up @@ -155,8 +156,8 @@ KERNEL void buildNeighborList(GLOBAL int* RESTRICT rebuildNeighborList, GLOBAL i
LOCAL volatile int tileIndex[WARPS_IN_BLOCK];
LOCAL int reductionBuffer[LOCAL_MEMORY_SIZE];

const unsigned int startTile = warp*NUM_TILES/totalWarps;
const unsigned int endTile = (warp+1)*NUM_TILES/totalWarps;
const unsigned int startTile = (unsigned int) (warp*(mm_ulong)NUM_TILES/totalWarps);
const unsigned int endTile = (unsigned int) ((warp+1)*(mm_ulong)NUM_TILES/totalWarps);
for (int tile = startTile; tile < endTile; tile++) {
const int4 atomData = groupData[TILE_SIZE*tile+tgx];
const int atom1 = atomData.x;
Expand Down

0 comments on commit ae5bc67

Please sign in to comment.