From: Berk Hess Date: Fri, 31 Oct 2014 18:10:13 +0000 (+0100) Subject: Corrected parameter for sorting on search grid X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=e036b6721d561a6c2b552d2143883ab4a8dfcdf3;p=alexxy%2Fgromacs.git Corrected parameter for sorting on search grid The nbnxn grid search sorting range parameter used the whole box height instead of the local DD cell height with domain decomposition along z. This could not cause errors, but the search used O(N^2) time with more than 4 domains along z, instead of O(N). Change-Id: I324df6b15635a5ecff7c8bfeb124fdb933e5f845 --- diff --git a/src/gromacs/mdlib/nbnxn_internal.h b/src/gromacs/mdlib/nbnxn_internal.h index fc42e60935..e8e94fdfde 100644 --- a/src/gromacs/mdlib/nbnxn_internal.h +++ b/src/gromacs/mdlib/nbnxn_internal.h @@ -97,6 +97,7 @@ typedef struct { typedef struct { rvec c0; /* The lower corner of the (local) grid */ rvec c1; /* The upper corner of the (local) grid */ + rvec size; /* c1 - c0 */ real atom_density; /* The atom number density for the local grid */ gmx_bool bSimple; /* Is this grid simple or super/sub */ diff --git a/src/gromacs/mdlib/nbnxn_search.c b/src/gromacs/mdlib/nbnxn_search.c index 3114bebc22..5d182ee11c 100644 --- a/src/gromacs/mdlib/nbnxn_search.c +++ b/src/gromacs/mdlib/nbnxn_search.c @@ -571,6 +571,7 @@ static int set_grid_size_xy(const nbnxn_search_t nbs, copy_rvec(corner0, grid->c0); copy_rvec(corner1, grid->c1); + copy_rvec(size, grid->size); return nc_max; } @@ -1007,7 +1008,6 @@ static void combine_bounding_box_pairs(nbnxn_grid_t *grid, const nbnxn_bb_t *bb) /* Prints the average bb size, used for debug output */ static void print_bbsizes_simple(FILE *fp, - const nbnxn_search_t nbs, const nbnxn_grid_t *grid) { int c, d; @@ -1023,19 +1023,18 @@ static void print_bbsizes_simple(FILE *fp, } dsvmul(1.0/grid->nc, ba, ba); - fprintf(fp, "ns bb: %4.2f %4.2f %4.2f %4.2f %4.2f %4.2f rel %4.2f %4.2f %4.2f\n", - nbs->box[XX][XX]/grid->ncx, - nbs->box[YY][YY]/grid->ncy, - nbs->box[ZZ][ZZ]*grid->ncx*grid->ncy/grid->nc, + fprintf(fp, "ns bb: grid %4.2f %4.2f %4.2f abs %4.2f %4.2f %4.2f rel %4.2f %4.2f %4.2f\n", + grid->sx, + grid->sy, + grid->na_c/(grid->atom_density*grid->sx*grid->sy), ba[XX], ba[YY], ba[ZZ], - ba[XX]*grid->ncx/nbs->box[XX][XX], - ba[YY]*grid->ncy/nbs->box[YY][YY], - ba[ZZ]*grid->nc/(grid->ncx*grid->ncy*nbs->box[ZZ][ZZ])); + ba[XX]/grid->sx, + ba[YY]/grid->sy, + ba[ZZ]/(grid->na_c/(grid->atom_density*grid->sx*grid->sy))); } /* Prints the average bb size, used for debug output */ static void print_bbsizes_supersub(FILE *fp, - const nbnxn_search_t nbs, const nbnxn_grid_t *grid) { int ns, c, s; @@ -1077,14 +1076,14 @@ static void print_bbsizes_supersub(FILE *fp, } dsvmul(1.0/ns, ba, ba); - fprintf(fp, "ns bb: %4.2f %4.2f %4.2f %4.2f %4.2f %4.2f rel %4.2f %4.2f %4.2f\n", - nbs->box[XX][XX]/(grid->ncx*GPU_NSUBCELL_X), - nbs->box[YY][YY]/(grid->ncy*GPU_NSUBCELL_Y), - nbs->box[ZZ][ZZ]*grid->ncx*grid->ncy/(grid->nc*GPU_NSUBCELL_Z), + fprintf(fp, "ns bb: grid %4.2f %4.2f %4.2f abs %4.2f %4.2f %4.2f rel %4.2f %4.2f %4.2f\n", + grid->sx/GPU_NSUBCELL_X, + grid->sy/GPU_NSUBCELL_Y, + grid->na_sc/(grid->atom_density*grid->sx*grid->sy*GPU_NSUBCELL_Z), ba[XX], ba[YY], ba[ZZ], - ba[XX]*grid->ncx*GPU_NSUBCELL_X/nbs->box[XX][XX], - ba[YY]*grid->ncy*GPU_NSUBCELL_Y/nbs->box[YY][YY], - ba[ZZ]*grid->nc*GPU_NSUBCELL_Z/(grid->ncx*grid->ncy*nbs->box[ZZ][ZZ])); + ba[XX]*GPU_NSUBCELL_X/grid->sx, + ba[YY]*GPU_NSUBCELL_Y/grid->sy, + ba[ZZ]/(grid->na_sc/(grid->atom_density*grid->sx*grid->sy*GPU_NSUBCELL_Z))); } /* Potentially sorts atoms on LJ coefficients !=0 and ==0. @@ -1332,7 +1331,7 @@ static void sort_columns_simple(const nbnxn_search_t nbs, sort_atoms(ZZ, FALSE, dd_zone, nbs->a+ash, na, x, grid->c0[ZZ], - 1.0/nbs->box[ZZ][ZZ], ncz*grid->na_sc, + 1.0/grid->size[ZZ], ncz*grid->na_sc, sort_work); /* Fill the ncz cells in this column */ @@ -1418,7 +1417,7 @@ static void sort_columns_supersub(const nbnxn_search_t nbs, sort_atoms(ZZ, FALSE, dd_zone, nbs->a+ash, na, x, grid->c0[ZZ], - 1.0/nbs->box[ZZ][ZZ], ncz*grid->na_sc, + 1.0/grid->size[ZZ], ncz*grid->na_sc, sort_work); /* This loop goes over the supercells and subcells along z at once */ @@ -1742,14 +1741,14 @@ static void calc_cell_indices(const nbnxn_search_t nbs, { if (grid->bSimple) { - print_bbsizes_simple(debug, nbs, grid); + print_bbsizes_simple(debug, grid); } else { fprintf(debug, "ns non-zero sub-cells: %d average atoms %.2f\n", grid->nsubc_tot, (a1-a0)/(double)grid->nsubc_tot); - print_bbsizes_supersub(debug, nbs, grid); + print_bbsizes_supersub(debug, grid); } } } @@ -2623,7 +2622,7 @@ static void print_nblist_statistics_simple(FILE *fp, const nbnxn_pairlist_t *nbl fprintf(fp, "nbl na_sc %d rl %g ncp %d per cell %.1f atoms %.1f ratio %.2f\n", nbl->na_sc, rl, nbl->ncj, nbl->ncj/(double)grid->nc, nbl->ncj/(double)grid->nc*grid->na_sc, - nbl->ncj/(double)grid->nc*grid->na_sc/(0.5*4.0/3.0*M_PI*rl*rl*rl*grid->nc*grid->na_sc/det(nbs->box))); + nbl->ncj/(double)grid->nc*grid->na_sc/(0.5*4.0/3.0*M_PI*rl*rl*rl*grid->nc*grid->na_sc/(grid->size[XX]*grid->size[YY]*grid->size[ZZ]))); fprintf(fp, "nbl average j cell list length %.1f\n", 0.25*nbl->ncj/(double)nbl->nci); @@ -2673,7 +2672,7 @@ static void print_nblist_statistics_supersub(FILE *fp, const nbnxn_pairlist_t *n fprintf(fp, "nbl na_c %d rl %g ncp %d per cell %.1f atoms %.1f ratio %.2f\n", nbl->na_ci, rl, nbl->nci_tot, nbl->nci_tot/(double)grid->nsubc_tot, nbl->nci_tot/(double)grid->nsubc_tot*grid->na_c, - nbl->nci_tot/(double)grid->nsubc_tot*grid->na_c/(0.5*4.0/3.0*M_PI*rl*rl*rl*grid->nsubc_tot*grid->na_c/det(nbs->box))); + nbl->nci_tot/(double)grid->nsubc_tot*grid->na_c/(0.5*4.0/3.0*M_PI*rl*rl*rl*grid->nsubc_tot*grid->na_c/(grid->size[XX]*grid->size[YY]*grid->size[ZZ]))); fprintf(fp, "nbl average j super cell list length %.1f\n", 0.25*nbl->ncj4/(double)nbl->nsci);