From 5fd2d422eea15fdeb065f38c97b3a3483d5d1627 Mon Sep 17 00:00:00 2001 From: Rafael Ravedutti Date: Wed, 2 Feb 2022 00:49:55 +0100 Subject: [PATCH] Adjust kernels to work with MxN loops Signed-off-by: Rafael Ravedutti --- gromacs/force_lj.c | 4 ++-- gromacs/pbc.c | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/gromacs/force_lj.c b/gromacs/force_lj.c index f55dbf0..1392731 100644 --- a/gromacs/force_lj.c +++ b/gromacs/force_lj.c @@ -61,7 +61,7 @@ double computeForceLJ(Parameter *param, Atom *atom, Neighbor *neighbor, Stats *s for(int k = 0; k < numneighs; k++) { int cj = neighs[k]; MD_FLOAT *cjptr = cluster_pos_ptr(cj); - for(int cii = 0; cii < atom->clusters[ci].natoms; cii++) { + for(int cii = 0; cii < CLUSTER_DIM_M; cii++) { MD_FLOAT xtmp = cluster_x(ciptr, cii); MD_FLOAT ytmp = cluster_y(ciptr, cii); MD_FLOAT ztmp = cluster_z(ciptr, cii); @@ -69,7 +69,7 @@ double computeForceLJ(Parameter *param, Atom *atom, Neighbor *neighbor, Stats *s MD_FLOAT fiy = 0; MD_FLOAT fiz = 0; - for(int cjj = 0; cjj < atom->clusters[cj].natoms; cjj++) { + for(int cjj = 0; cjj < CLUSTER_DIM_N; cjj++) { if(ci != cj || cii != cjj) { MD_FLOAT delx = xtmp - cluster_x(cjptr, cjj); MD_FLOAT dely = ytmp - cluster_y(cjptr, cjj); diff --git a/gromacs/pbc.c b/gromacs/pbc.c index 3d93c3b..5a303c3 100644 --- a/gromacs/pbc.c +++ b/gromacs/pbc.c @@ -44,7 +44,7 @@ void initPbc(Atom* atom) { /* update coordinates of ghost atoms */ /* uses mapping created in setupPbc */ -void updatePbc(Atom *atom, Parameter *param, int updateBoundingBoxes) { +void updatePbc(Atom *atom, Parameter *param, int firstUpdate) { int *border_map = atom->border_map; int nlocal = atom->Nclusters_local; MD_FLOAT xprd = param->xprd; @@ -68,7 +68,7 @@ void updatePbc(Atom *atom, Parameter *param, int updateBoundingBoxes) { cluster_y(cptr, cii) = ytmp; cluster_z(cptr, cii) = ztmp; - if(updateBoundingBoxes) { + if(firstUpdate) { // TODO: To create the bounding boxes faster, we can use SIMD operations if(bbminx > xtmp) { bbminx = xtmp; } if(bbmaxx < xtmp) { bbmaxx = xtmp; } @@ -79,7 +79,13 @@ void updatePbc(Atom *atom, Parameter *param, int updateBoundingBoxes) { } } - if(updateBoundingBoxes) { + if(firstUpdate) { + for(int cii = atom->clusters[ci].natoms; cii < CLUSTER_DIM_M; cii++) { + cluster_x(cptr, cii) = INFINITY; + cluster_y(cptr, cii) = INFINITY; + cluster_z(cptr, cii) = INFINITY; + } + atom->clusters[ci].bbminx = bbminx; atom->clusters[ci].bbmaxx = bbmaxx; atom->clusters[ci].bbminy = bbminy;