From eadd816527e36dd4b5c016c6b054231dd9a2e14c Mon Sep 17 00:00:00 2001 From: Erik Lindahl Date: Sat, 1 Aug 2015 00:13:25 +0200 Subject: [PATCH] Remove unused code detected by PGI compiler Minor cleanup to fix warnings issued by the PGI compiler. - Unused routines have been removed, including ones that were never referenced unless specific defines were set directly in source files. - Unreachable breaks have been removed. - Add a flag to suppress warning that PGI does not understand a GCC pragma in the generated parser.cpp There are still issues with PGI not catching exceptions in the unit tests, SIMD, and OpenMP. Change-Id: Ic7900b80e31745aafa031c806f0664734014bbe5 --- cmake/gmxCFlags.cmake | 9 ++- src/gromacs/ewald/calculate-spline-moduli.cpp | 6 -- src/gromacs/ewald/pme-grid.cpp | 2 + src/gromacs/fileio/checkpoint.cpp | 8 +-- src/gromacs/gmxana/gmx_bar.cpp | 36 ----------- src/gromacs/gmxana/gmx_eneconv.cpp | 71 --------------------- src/gromacs/gmxana/gmx_hbond.cpp | 12 ---- src/gromacs/gmxana/gmx_hydorder.cpp | 25 -------- src/gromacs/gmxana/gmx_make_ndx.cpp | 58 ++++++++++-------- src/gromacs/gmxana/nrama.cpp | 36 ----------- src/gromacs/gmxana/princ.cpp | 6 +- src/gromacs/gmxlib/conformation-utilities.cpp | 39 ------------ src/gromacs/gmxpreprocess/gen_ad.cpp | 24 -------- src/gromacs/gmxpreprocess/topdirs.cpp | 1 - src/gromacs/gmxpreprocess/x2top.cpp | 15 ----- src/gromacs/listed-forces/bonded.cpp | 12 ---- src/gromacs/mdlib/calcvir.cpp | 66 -------------------- src/gromacs/mdlib/clincs.cpp | 4 +- src/gromacs/mdlib/genborn.cpp | 36 ----------- src/gromacs/mdlib/ns.cpp | 88 ++++----------------------- src/gromacs/mdlib/qmmm.cpp | 14 ----- src/gromacs/mdlib/shakef.cpp | 13 ---- src/gromacs/mdlib/wnblist.cpp | 23 ------- src/gromacs/utility/basenetwork.cpp | 85 ++++++++++++-------------- src/gromacs/utility/cstringutil.cpp | 7 --- src/programs/mdrun/repl_ex.cpp | 45 -------------- 26 files changed, 99 insertions(+), 642 deletions(-) diff --git a/cmake/gmxCFlags.cmake b/cmake/gmxCFlags.cmake index 8f649762b3..a7dc69cd32 100644 --- a/cmake/gmxCFlags.cmake +++ b/cmake/gmxCFlags.cmake @@ -256,7 +256,12 @@ macro (gmx_c_flags) GMX_TEST_CFLAG(CFLAGS_OPT "-Mnoipa" GMXC_CFLAGS_RELEASE) endif() if (CMAKE_CXX_COMPILER_ID MATCHES "PGI") + # Using ipa exposes internal PGI-15.7 compiler bugs at compile time GMX_TEST_CXXFLAG(CXXFLAGS_OPT "-Mnoipa" GMXC_CXXFLAGS_RELEASE) + # PGI identifies itself as GCC, but does not understand the GCC + # pragmas that occur in parser.cpp. Since that file is generated + # we cannot add a define there, but supress the warning instead. + GMX_TEST_CXXFLAG(CXXFLAGS_WARN "--diag_suppress=1675" GMXC_CXXFLAGS) endif() # Pathscale @@ -267,7 +272,7 @@ macro (gmx_c_flags) if (GMX_COMPILER_WARNINGS) GMX_TEST_CFLAG(CFLAGS_WARN "-Wall -Wno-unused -Wunused-value" GMXC_CFLAGS) endif() - GMX_TEST_CFLAG(CFLAGS_OPT "-OPT:Ofast -fno-math-errno -ffast-math" + GMX_TEST_CFLAG(CFLAGS_OPT "-OPT:Ofast -fno-math-errno -ffast-math" GMXC_CFLAGS_RELEASE) GMX_TEST_CFLAG(CFLAGS_LANG "-std=gnu99" GMXC_CFLAGS) endif() @@ -278,7 +283,7 @@ macro (gmx_c_flags) if (GMX_COMPILER_WARNINGS) GMX_TEST_CXXFLAG(CXXFLAGS_WARN "-Wall -Wno-unused -Wunused-value" GMXC_CXXFLAGS) endif() - GMX_TEST_CXXFLAG(CXXFLAGS_OPT "-OPT:Ofast -fno-math-errno -ffast-math" + GMX_TEST_CXXFLAG(CXXFLAGS_OPT "-OPT:Ofast -fno-math-errno -ffast-math" GMXC_CXXFLAGS_RELEASE) endif() diff --git a/src/gromacs/ewald/calculate-spline-moduli.cpp b/src/gromacs/ewald/calculate-spline-moduli.cpp index 52d91f05c7..6ec9fd9404 100644 --- a/src/gromacs/ewald/calculate-spline-moduli.cpp +++ b/src/gromacs/ewald/calculate-spline-moduli.cpp @@ -146,24 +146,18 @@ static double do_p3m_influence(double z, int order) { case 2: return 1.0 - 2.0*z2/3.0; - break; case 3: return 1.0 - z2 + 2.0*z4/15.0; - break; case 4: return 1.0 - 4.0*z2/3.0 + 2.0*z4/5.0 + 4.0*z2*z4/315.0; - break; case 5: return 1.0 - 5.0*z2/3.0 + 7.0*z4/9.0 - 17.0*z2*z4/189.0 + 2.0*z4*z4/2835.0; - break; case 6: return 1.0 - 2.0*z2 + 19.0*z4/15.0 - 256.0*z2*z4/945.0 + 62.0*z4*z4/4725.0 + 4.0*z2*z4*z4/155925.0; - break; case 7: return 1.0 - 7.0*z2/3.0 + 28.0*z4/15.0 - 16.0*z2*z4/27.0 + 26.0*z4*z4/405.0 - 2.0*z2*z4*z4/1485.0 + 4.0*z4*z4*z4/6081075.0; case 8: return 1.0 - 8.0*z2/3.0 + 116.0*z4/45.0 - 344.0*z2*z4/315.0 + 914.0*z4*z4/4725.0 - 248.0*z4*z4*z2/22275.0 + 21844.0*z4*z4*z4/212837625.0 - 8.0*z4*z4*z4*z2/638512875.0; - break; } return 0.0; diff --git a/src/gromacs/ewald/pme-grid.cpp b/src/gromacs/ewald/pme-grid.cpp index 0c5cea2bb8..02a29db0e6 100644 --- a/src/gromacs/ewald/pme-grid.cpp +++ b/src/gromacs/ewald/pme-grid.cpp @@ -301,6 +301,7 @@ int copy_pmegrid_to_fftgrid(struct gmx_pme_t *pme, real *pmegrid, real *fftgrid, } +#ifdef PME_TIME_THREADS static gmx_cycles_t omp_cyc_start() { return gmx_cycles_read(); @@ -310,6 +311,7 @@ static gmx_cycles_t omp_cyc_end(gmx_cycles_t c) { return gmx_cycles_read() - c; } +#endif int copy_fftgrid_to_pmegrid(struct gmx_pme_t *pme, const real *fftgrid, real *pmegrid, int grid_index, diff --git a/src/gromacs/fileio/checkpoint.cpp b/src/gromacs/fileio/checkpoint.cpp index 3a9accedf6..10ef97fc80 100644 --- a/src/gromacs/fileio/checkpoint.cpp +++ b/src/gromacs/fileio/checkpoint.cpp @@ -174,10 +174,10 @@ static const char *st_names(int cptp, int ecpt) { switch (cptp) { - case cptpEST: return est_names [ecpt]; break; - case cptpEEKS: return eeks_names[ecpt]; break; - case cptpEENH: return eenh_names[ecpt]; break; - case cptpEDFH: return edfh_names[ecpt]; break; + case cptpEST: return est_names [ecpt]; + case cptpEEKS: return eeks_names[ecpt]; + case cptpEENH: return eenh_names[ecpt]; + case cptpEDFH: return edfh_names[ecpt]; } return NULL; diff --git a/src/gromacs/gmxana/gmx_bar.cpp b/src/gromacs/gmxana/gmx_bar.cpp index 1f59c15176..5ac6f3ec6d 100644 --- a/src/gromacs/gmxana/gmx_bar.cpp +++ b/src/gromacs/gmxana/gmx_bar.cpp @@ -303,11 +303,6 @@ static void lambda_vec_init(lambda_vec_t *lv, const lambda_components_t *lc) lv->lc = lc; } -static void lambda_vec_destroy(lambda_vec_t *lv) -{ - sfree(lv->val); -} - static void lambda_vec_copy(lambda_vec_t *lv, const lambda_vec_t *orig) { int i; @@ -400,31 +395,6 @@ static void lambda_vec_print_intermediate(const lambda_vec_t *a, } - -/* calculate the difference in lambda vectors: c = a-b. - c must be initialized already, and a and b must describe non-derivative - lambda points */ -static void lambda_vec_diff(const lambda_vec_t *a, const lambda_vec_t *b, - lambda_vec_t *c) -{ - int i; - - if ( (a->dhdl > 0) || (b->dhdl > 0) ) - { - gmx_fatal(FARGS, - "Trying to calculate the difference between derivatives instead of lambda points"); - } - if ((a->lc != b->lc) || (a->lc != c->lc) ) - { - gmx_fatal(FARGS, - "Trying to calculate the difference lambdas with differing basis set"); - } - for (i = 0; i < a->lc->N; i++) - { - c->val[i] = a->val[i] - b->val[i]; - } -} - /* calculate and return the absolute difference in lambda vectors: c = |a-b|. a and b must describe non-derivative lambda points */ static double lambda_vec_abs_diff(const lambda_vec_t *a, const lambda_vec_t *b) @@ -594,12 +564,6 @@ static void hist_init(hist_t *h, int nhist, int *nbin) h->nhist = nhist; } -static void hist_destroy(hist_t *h) -{ - sfree(h->bin); -} - - static void xvg_init(xvg_t *ba) { ba->filename = NULL; diff --git a/src/gromacs/gmxana/gmx_eneconv.cpp b/src/gromacs/gmxana/gmx_eneconv.cpp index 83bbfe3bf7..3696123955 100644 --- a/src/gromacs/gmxana/gmx_eneconv.cpp +++ b/src/gromacs/gmxana/gmx_eneconv.cpp @@ -339,77 +339,6 @@ static void edit_files(char **fnms, int nfiles, real *readtime, } -static void copy_ee(t_energy *src, t_energy *dst, int nre) -{ - int i; - - for (i = 0; i < nre; i++) - { - dst[i].e = src[i].e; - dst[i].esum = src[i].esum; - dst[i].eav = src[i].eav; - } -} - -static void update_ee(t_energy *lastee, gmx_int64_t laststep, - t_energy *startee, gmx_int64_t startstep, - t_energy *ee, int step, - t_energy *outee, int nre) -{ - int i; - double sigmacorr, nom, denom; - double prestart_esum; - double prestart_sigma; - - for (i = 0; i < nre; i++) - { - outee[i].e = ee[i].e; - /* add statistics from earlier file if present */ - if (laststep > 0) - { - outee[i].esum = lastee[i].esum+ee[i].esum; - nom = (lastee[i].esum*(step+1)-ee[i].esum*(laststep)); - denom = ((step+1.0)*(laststep)*(step+1.0+laststep)); - sigmacorr = nom*nom/denom; - outee[i].eav = lastee[i].eav+ee[i].eav+sigmacorr; - } - else - { - /* otherwise just copy to output */ - outee[i].esum = ee[i].esum; - outee[i].eav = ee[i].eav; - } - - /* if we didnt start to write at the first frame - * we must compensate the statistics for this - * there are laststep frames in the earlier file - * and step+1 frames in this one. - */ - if (startstep > 0) - { - gmx_int64_t q = laststep+step; - gmx_int64_t p = startstep+1; - prestart_esum = startee[i].esum-startee[i].e; - sigmacorr = prestart_esum-(p-1)*startee[i].e; - prestart_sigma = startee[i].eav- - sigmacorr*sigmacorr/(p*(p-1)); - sigmacorr = prestart_esum/(p-1)- - outee[i].esum/(q); - outee[i].esum -= prestart_esum; - if (q-p+1 > 0) - { - outee[i].eav = outee[i].eav-prestart_sigma- - sigmacorr*sigmacorr*((p-1)*q)/(q-p+1); - } - } - - if ((outee[i].eav/(laststep+step+1)) < (GMX_REAL_EPS)) - { - outee[i].eav = 0; - } - } -} - static void update_ee_sum(int nre, gmx_int64_t *ee_sum_step, gmx_int64_t *ee_sum_nsteps, diff --git a/src/gromacs/gmxana/gmx_hbond.cpp b/src/gromacs/gmxana/gmx_hbond.cpp index c487dc496d..c1ab0325a0 100644 --- a/src/gromacs/gmxana/gmx_hbond.cpp +++ b/src/gromacs/gmxana/gmx_hbond.cpp @@ -1888,18 +1888,6 @@ void compute_derivative(int nn, real x[], real y[], real dydx[]) dydx[nn-1] = 2*dydx[nn-2] - dydx[nn-3]; } -static void parallel_print(int *data, int nThreads) -{ - /* This prints the donors on which each tread is currently working. */ - int i; - - fprintf(stderr, "\r"); - for (i = 0; i < nThreads; i++) - { - fprintf(stderr, "%-7i", data[i]); - } -} - static void normalizeACF(real *ct, real *gt, int nhb, int len) { real ct_fac, gt_fac = 0; diff --git a/src/gromacs/gmxana/gmx_hydorder.cpp b/src/gromacs/gmxana/gmx_hydorder.cpp index 09d197232d..2b3bafbfd2 100644 --- a/src/gromacs/gmxana/gmx_hydorder.cpp +++ b/src/gromacs/gmxana/gmx_hydorder.cpp @@ -59,31 +59,6 @@ #include "gromacs/utility/gmxassert.h" #include "gromacs/utility/smalloc.h" -/* Print name of first atom in all groups in index file */ -static void print_types(int index[], int a[], int ngrps, - char *groups[], t_topology *top) -{ - int i; - - fprintf(stderr, "Using following groups: \n"); - for (i = 0; i < ngrps; i++) - { - fprintf(stderr, "Groupname: %s First atomname: %s First atomnr %d\n", - groups[i], *(top->atoms.atomname[a[index[i]]]), a[index[i]]); - } - fprintf(stderr, "\n"); -} - -static void check_length(real length, int a, int b) -{ - if (length > 0.3) - { - fprintf(stderr, "WARNING: distance between atoms %d and " - "%d > 0.3 nm (%f). Index file might be corrupt.\n", - a, b, length); - } -} - static void find_tetra_order_grid(t_topology top, int ePBC, int natoms, matrix box, rvec x[], int maxidx, int index[], diff --git a/src/gromacs/gmxana/gmx_make_ndx.cpp b/src/gromacs/gmxana/gmx_make_ndx.cpp index 6e6a72d0ef..74935eb2b9 100644 --- a/src/gromacs/gmxana/gmx_make_ndx.cpp +++ b/src/gromacs/gmxana/gmx_make_ndx.cpp @@ -541,39 +541,43 @@ static gmx_bool atoms_from_residuenumbers(t_atoms *atoms, int group, t_blocka *b return *nr; } -static gmx_bool comp_name(char *name, char *search) +static gmx_bool comp_name(const char *name, const char *search) { - while (name[0] != '\0' && search[0] != '\0') + gmx_bool matches = TRUE; + + // Loop while name and search are not end-of-string and matches is true + for (; *name && *search && matches; name++, search++) { - switch (search[0]) + if (*search == '?') { - case '?': - /* Always matches */ - break; - case '*': - if (search[1] != '\0') - { - printf("WARNING: Currently '*' is only supported at the end of an expression\n"); - return FALSE; - } - else - { - return TRUE; - } - break; - default: - /* Compare a single character */ - if (( bCase && std::strncmp(name, search, 1)) || - (!bCase && gmx_strncasecmp(name, search, 1))) - { - return FALSE; - } + // still matching, continue to next character + continue; + } + else if (*search == '*') + { + if (*(search+1)) + { + printf("WARNING: Currently '*' is only supported at the end of an expression\n"); + } + // if * is the last char in search string, we have a match, + // otherwise we just failed. Return in either case, we're done. + return (*(search+1) == '\0'); + } + + // Compare one character + if (bCase) + { + matches = (*name == *search); + } + else + { + matches = (std::toupper(*name) == std::toupper(*search)); } - name++; - search++; } - return (name[0] == '\0' && (search[0] == '\0' || search[0] == '*')); + matches = matches && (*name == '\0' && (*search == '\0' || *search == '*')); + + return matches; } static int select_chainnames(t_atoms *atoms, int n_names, char **names, diff --git a/src/gromacs/gmxana/nrama.cpp b/src/gromacs/gmxana/nrama.cpp index e1902b955d..126f534267 100644 --- a/src/gromacs/gmxana/nrama.cpp +++ b/src/gromacs/gmxana/nrama.cpp @@ -174,42 +174,6 @@ static void get_dih(t_xrama *xr, t_atoms *atoms) fprintf(stderr, "Found %d phi-psi combinations\n", xr->npp); } -static int search_ff(int thisff[NPP], int ndih, int **ff) -{ - int j, k; - gmx_bool bFound = FALSE; - - for (j = 0; (j < ndih); j++) - { - bFound = TRUE; - for (k = 1; (k <= 3); k++) - { - bFound = bFound && (thisff[k] == ff[j][k]); - } - if (bFound) - { - if (thisff[0] == -1) - { - ff[j][4] = thisff[4]; - } - else - { - ff[j][0] = thisff[0]; - } - break; - } - } - if (!bFound) - { - for (k = 0; (k < 5); k++) - { - ff[ndih][k] = thisff[k]; - } - ndih++; - } - return ndih; -} - static void min_max(t_xrama *xr) { int ai, i, j; diff --git a/src/gromacs/gmxana/princ.cpp b/src/gromacs/gmxana/princ.cpp index 8392ac5f7f..2231891036 100644 --- a/src/gromacs/gmxana/princ.cpp +++ b/src/gromacs/gmxana/princ.cpp @@ -47,6 +47,9 @@ #include "gromacs/topology/topology.h" #include "gromacs/utility/smalloc.h" +#define NDIM 4 + +#ifdef DEBUG static void m_op(matrix mat, rvec x) { rvec xp; @@ -62,9 +65,6 @@ static void m_op(matrix mat, rvec x) xp[ZZ]/x[ZZ]); } -#define NDIM 4 - -#ifdef DEBUG static void ptrans(char *s, real **inten, real d[], real e[]) { int m; diff --git a/src/gromacs/gmxlib/conformation-utilities.cpp b/src/gromacs/gmxlib/conformation-utilities.cpp index 0d6b846368..cc9d220d89 100644 --- a/src/gromacs/gmxlib/conformation-utilities.cpp +++ b/src/gromacs/gmxlib/conformation-utilities.cpp @@ -46,20 +46,6 @@ #include "gromacs/math/vec.h" #include "gromacs/pbcutil/pbc.h" -static real dist2(t_pbc *pbc, rvec x, rvec y) -{ - rvec dx; - - pbc_dx(pbc, x, y, dx); - - return norm2(dx); -} - -static real distance_to_z(rvec x) -{ - return (sqr(x[XX])+sqr(x[YY])); -} /*distance_to_z()*/ - static void low_rotate_conf(int natom, rvec *x, real alfa, real beta, real gamma) { int i; @@ -85,31 +71,6 @@ static void low_rotate_conf(int natom, rvec *x, real alfa, real beta, real gamma } } -static void low_rotate_conf_indexed(int nindex, int *index, rvec *x, real alfa, real beta, real gamma) -{ - int i; - rvec x_old; - - for (i = 0; i < nindex; i++) - { - copy_rvec(x[index[i]], x_old); - /*calculate new x[index[i]] by rotation alfa around the x-axis*/ - x[index[i]][XX] = x_old[XX]; - x[index[i]][YY] = cos(alfa)*x_old[YY] - sin(alfa)*x_old[ZZ]; - x[index[i]][ZZ] = sin(alfa)*x_old[YY] + cos(alfa)*x_old[ZZ]; - copy_rvec(x[index[i]], x_old); - /*calculate new x[index[i]] by rotation beta around the y-axis*/ - x[index[i]][XX] = cos(beta)*x_old[XX] + sin(beta)*x_old[ZZ]; - x[index[i]][YY] = x_old[YY]; - x[index[i]][ZZ] = -sin(beta)*x_old[XX] + cos(beta)*x_old[ZZ]; - copy_rvec(x[index[i]], x_old); - /*calculate new x[index[i]] by rotation gamma around the z-axis*/ - x[index[i]][XX] = x_old[XX]*cos(gamma) - x_old[YY]*sin(gamma); - x[index[i]][YY] = x_old[XX]*sin(gamma) + x_old[YY]*cos(gamma); - x[index[i]][ZZ] = x_old[ZZ]; - } -} - void rotate_conf(int natom, rvec *x, rvec *v, real alfa, real beta, real gamma) { if (x) diff --git a/src/gromacs/gmxpreprocess/gen_ad.cpp b/src/gromacs/gmxpreprocess/gen_ad.cpp index 4aabeb2119..c23bb99d23 100644 --- a/src/gromacs/gmxpreprocess/gen_ad.cpp +++ b/src/gromacs/gmxpreprocess/gen_ad.cpp @@ -304,30 +304,6 @@ static int int_comp(const void *a, const void *b) return (*(int *)a) - (*(int *)b); } -static int eq_imp(int a1[], int a2[]) -{ - int b1[4], b2[4]; - int j; - - for (j = 0; (j < 4); j++) - { - b1[j] = a1[j]; - b2[j] = a2[j]; - } - qsort(b1, 4, (size_t)sizeof(b1[0]), int_comp); - qsort(b2, 4, (size_t)sizeof(b2[0]), int_comp); - - for (j = 0; (j < 4); j++) - { - if (b1[j] != b2[j]) - { - return FALSE; - } - } - - return TRUE; -} - static int idcomp(const void *a, const void *b) { t_param *pa, *pb; diff --git a/src/gromacs/gmxpreprocess/topdirs.cpp b/src/gromacs/gmxpreprocess/topdirs.cpp index 94ab852ffc..6120e2d155 100644 --- a/src/gromacs/gmxpreprocess/topdirs.cpp +++ b/src/gromacs/gmxpreprocess/topdirs.cpp @@ -256,7 +256,6 @@ int ifunc_index(directive d, int type) return F_POSRES; case 2: return F_FBPOSRES; - break; default: gmx_fatal(FARGS, "Invalid position restraint type %d", type); } diff --git a/src/gromacs/gmxpreprocess/x2top.cpp b/src/gromacs/gmxpreprocess/x2top.cpp index 5897c70466..2ee7e8db3d 100644 --- a/src/gromacs/gmxpreprocess/x2top.cpp +++ b/src/gromacs/gmxpreprocess/x2top.cpp @@ -101,21 +101,6 @@ static gmx_bool is_bond(int nnm, t_nm2type nmt[], char *ai, char *aj, real blen) return FALSE; } -static int get_atype(char *nm) -{ - int i, aai = NATP-1; - - for (i = 0; (i < NATP-1); i++) - { - if (nm[0] == atp[i]) - { - aai = i; - break; - } - } - return aai; -} - void mk_bonds(int nnm, t_nm2type nmt[], t_atoms *atoms, rvec x[], t_params *bond, int nbond[], gmx_bool bPBC, matrix box) diff --git a/src/gromacs/listed-forces/bonded.cpp b/src/gromacs/listed-forces/bonded.cpp index 926035007d..a82dc3437b 100644 --- a/src/gromacs/listed-forces/bonded.cpp +++ b/src/gromacs/listed-forces/bonded.cpp @@ -1868,18 +1868,6 @@ dopdihs_noener(real cpA, real cpB, real phiA, real phiB, int mult, /* That was 20 flops */ } -static void -dopdihs_mdphi(real cpA, real cpB, real phiA, real phiB, int mult, - real phi, real lambda, real *cp, real *mdphi) -{ - real L1 = 1.0 - lambda; - real ph0 = (L1*phiA + lambda*phiB)*DEG2RAD; - - *cp = L1*cpA + lambda*cpB; - - *mdphi = mult*phi - ph0; -} - static real dopdihs_min(real cpA, real cpB, real phiA, real phiB, int mult, real phi, real lambda, real *V, real *F) /* similar to dopdihs, except for a minus sign * diff --git a/src/gromacs/mdlib/calcvir.cpp b/src/gromacs/mdlib/calcvir.cpp index 79b4e1d529..5f168581b5 100644 --- a/src/gromacs/mdlib/calcvir.cpp +++ b/src/gromacs/mdlib/calcvir.cpp @@ -167,68 +167,6 @@ static void lo_fcv(int i0, int i1, upd_vir(vir[ZZ], dvzx, dvzy, dvzz); } -static void lo_fcv2(int i0, int i1, - rvec x[], rvec f[], tensor vir, - ivec is[], matrix box, gmx_bool bTriclinic) -{ - int i, gg, tx, ty, tz; - real xx, yy, zz; - real dvxx = 0, dvxy = 0, dvxz = 0, dvyx = 0, dvyy = 0, dvyz = 0, dvzx = 0, dvzy = 0, dvzz = 0; - - if (bTriclinic) - { - for (i = i0, gg = 0; (i < i1); i++, gg++) - { - tx = is[gg][XX]; - ty = is[gg][YY]; - tz = is[gg][ZZ]; - - xx = x[i][XX]-tx*box[XX][XX]-ty*box[YY][XX]-tz*box[ZZ][XX]; - dvxx += xx*f[i][XX]; - dvxy += xx*f[i][YY]; - dvxz += xx*f[i][ZZ]; - - yy = x[i][YY]-ty*box[YY][YY]-tz*box[ZZ][YY]; - dvyx += yy*f[i][XX]; - dvyy += yy*f[i][YY]; - dvyz += yy*f[i][ZZ]; - - zz = x[i][ZZ]-tz*box[ZZ][ZZ]; - dvzx += zz*f[i][XX]; - dvzy += zz*f[i][YY]; - dvzz += zz*f[i][ZZ]; - } - } - else - { - for (i = i0, gg = 0; (i < i1); i++, gg++) - { - tx = is[gg][XX]; - ty = is[gg][YY]; - tz = is[gg][ZZ]; - - xx = x[i][XX]-tx*box[XX][XX]; - dvxx += xx*f[i][XX]; - dvxy += xx*f[i][YY]; - dvxz += xx*f[i][ZZ]; - - yy = x[i][YY]-ty*box[YY][YY]; - dvyx += yy*f[i][XX]; - dvyy += yy*f[i][YY]; - dvyz += yy*f[i][ZZ]; - - zz = x[i][ZZ]-tz*box[ZZ][ZZ]; - dvzx += zz*f[i][XX]; - dvzy += zz*f[i][YY]; - dvzz += zz*f[i][ZZ]; - } - } - - upd_vir(vir[XX], dvxx, dvxy, dvxz); - upd_vir(vir[YY], dvyx, dvyy, dvyz); - upd_vir(vir[ZZ], dvzx, dvzy, dvzz); -} - void f_calc_vir(int i0, int i1, rvec x[], rvec f[], tensor vir, t_graph *g, matrix box) { @@ -241,11 +179,7 @@ void f_calc_vir(int i0, int i1, rvec x[], rvec f[], tensor vir, */ start = std::max(i0, g->at_start); end = std::min(i1, g->at_end); -#ifdef SAFE - lo_fcv2(start, end, x, f, vir, g->ishift, box, TRICLINIC(box)); -#else lo_fcv(start, end, x[0], f[0], vir, g->ishift[0], box[0], TRICLINIC(box)); -#endif /* If not all atoms are bonded, calculate their virial contribution * anyway, without shifting back their coordinates. diff --git a/src/gromacs/mdlib/clincs.cpp b/src/gromacs/mdlib/clincs.cpp index 5a83907139..2f6f7d60c9 100644 --- a/src/gromacs/mdlib/clincs.cpp +++ b/src/gromacs/mdlib/clincs.cpp @@ -950,8 +950,7 @@ calc_dr_x_xp_simd(int b0, gmx_simd_store_r(sol + bs, rhs_S); } } -#endif /* LINCS_SIMD */ - +#else /* Determine the distances and right-hand side for the next iteration */ static void calc_dist_iter(int b0, int b1, @@ -1000,6 +999,7 @@ static void calc_dist_iter(int b0, sol[b] = mvb; } /* 20*ncons flops */ } +#endif #ifdef LINCS_SIMD /* As the function above, but using SIMD intrinsics */ diff --git a/src/gromacs/mdlib/genborn.cpp b/src/gromacs/mdlib/genborn.cpp index 04b28fc45f..f6dffd2916 100644 --- a/src/gromacs/mdlib/genborn.cpp +++ b/src/gromacs/mdlib/genborn.cpp @@ -1489,13 +1489,6 @@ static void add_bondeds_to_gblist(t_ilist *il, } } -static int -compare_int (const void * a, const void * b) -{ - return ( *(int*)a - *(int*)b ); -} - - int make_gb_nblist(t_commrec *cr, int gb_algorithm, rvec x[], matrix box, @@ -1616,35 +1609,6 @@ int make_gb_nblist(t_commrec *cr, int gb_algorithm, } } - -#ifdef SORT_GB_LIST - for (i = 0; i < fr->gblist.nri; i++) - { - nj0 = fr->gblist.jindex[i]; - nj1 = fr->gblist.jindex[i+1]; - ai = fr->gblist.iinr[i]; - - /* Temporary fix */ - for (j = nj0; j < nj1; j++) - { - if (fr->gblist.jjnr[j] < ai) - { - fr->gblist.jjnr[j] += fr->natoms_force; - } - } - qsort(fr->gblist.jjnr+nj0, nj1-nj0, sizeof(int), compare_int); - /* Fix back */ - for (j = nj0; j < nj1; j++) - { - if (fr->gblist.jjnr[j] >= fr->natoms_force) - { - fr->gblist.jjnr[j] -= fr->natoms_force; - } - } - - } -#endif - return 0; } diff --git a/src/gromacs/mdlib/ns.cpp b/src/gromacs/mdlib/ns.cpp index d74f0c40d6..92188a6c93 100644 --- a/src/gromacs/mdlib/ns.cpp +++ b/src/gromacs/mdlib/ns.cpp @@ -1577,59 +1577,6 @@ static int ns_simple_core(t_forcerec *fr, * ************************************************/ -static gmx_inline void get_dx(int Nx, real gridx, real rc2, int xgi, real x, - int *dx0, int *dx1, real *dcx2) -{ - real dcx, tmp; - int xgi0, xgi1, i; - - if (xgi < 0) - { - *dx0 = 0; - xgi0 = -1; - *dx1 = -1; - xgi1 = 0; - } - else if (xgi >= Nx) - { - *dx0 = Nx; - xgi0 = Nx-1; - *dx1 = Nx-1; - xgi1 = Nx; - } - else - { - dcx2[xgi] = 0; - *dx0 = xgi; - xgi0 = xgi-1; - *dx1 = xgi; - xgi1 = xgi+1; - } - - for (i = xgi0; i >= 0; i--) - { - dcx = (i+1)*gridx-x; - tmp = dcx*dcx; - if (tmp >= rc2) - { - break; - } - *dx0 = i; - dcx2[i] = tmp; - } - for (i = xgi1; i < Nx; i++) - { - dcx = i*gridx-x; - tmp = dcx*dcx; - if (tmp >= rc2) - { - break; - } - *dx1 = i; - dcx2[i] = tmp; - } -} - static gmx_inline void get_dx_dd(int Nx, real gridx, real rc2, int xgi, real x, int ncpddc, int shift_min, int shift_max, int *g0, int *g1, real *dcx2) @@ -2036,13 +1983,8 @@ static int nsgrid_core(t_commrec *cr, t_forcerec *fr, ZI = cgcm[icg][ZZ]+tz*box[ZZ][ZZ]; /* Calculate range of cells in Z direction that have the shift tz */ zgi = cell_z + tz*Nz; -#define FAST_DD_NS -#ifndef FAST_DD_NS - get_dx(Nz, gridz, rl2, zgi, ZI, &dz0, &dz1, dcz2); -#else get_dx_dd(Nz, gridz, rl2, zgi, ZI-grid_offset[ZZ], ncpddc[ZZ], sh0[ZZ], sh1[ZZ], &dz0, &dz1, dcz2); -#endif if (dz0 > dz1) { continue; @@ -2059,12 +2001,8 @@ static int nsgrid_core(t_commrec *cr, t_forcerec *fr, { ygi = cell_y + ty*Ny; } -#ifndef FAST_DD_NS - get_dx(Ny, gridy, rl2, ygi, YI, &dy0, &dy1, dcy2); -#else get_dx_dd(Ny, gridy, rl2, ygi, YI-grid_offset[YY], ncpddc[YY], sh0[YY], sh1[YY], &dy0, &dy1, dcy2); -#endif if (dy0 > dy1) { continue; @@ -2081,12 +2019,8 @@ static int nsgrid_core(t_commrec *cr, t_forcerec *fr, { xgi = cell_x + tx*Nx; } -#ifndef FAST_DD_NS - get_dx(Nx, gridx, rl2, xgi*Nx, XI, &dx0, &dx1, dcx2); -#else get_dx_dd(Nx, gridx, rl2, xgi, XI-grid_offset[XX], ncpddc[XX], sh0[XX], sh1[XX], &dx0, &dx1, dcx2); -#endif if (dx0 > dx1) { continue; @@ -2263,7 +2197,7 @@ void init_ns(FILE *fplog, const t_commrec *cr, gmx_ns_t *ns, t_forcerec *fr, const gmx_mtop_t *mtop) { - int mt, icg, nr_in_cg, maxcg, i, j, jcg, ngid, ncg; + int mt, icg, nr_in_cg, maxcg, i, j, jcg, ngid, ncg; t_block *cgs; /* Compute largest charge groups size (# atoms) */ @@ -2383,17 +2317,17 @@ int search_neighbours(FILE *log, t_forcerec *fr, gmx_bool bFillGrid, gmx_bool bDoLongRangeNS) { - t_block *cgs = &(top->cgs); - rvec box_size, grid_x0, grid_x1; - int m, ngid; - real min_size, grid_dens; - int nsearch; - gmx_bool bGrid; - int start, end; - gmx_ns_t *ns; - t_grid *grid; + t_block *cgs = &(top->cgs); + rvec box_size, grid_x0, grid_x1; + int m, ngid; + real min_size, grid_dens; + int nsearch; + gmx_bool bGrid; + int start, end; + gmx_ns_t *ns; + t_grid *grid; gmx_domdec_zones_t *dd_zones; - put_in_list_t *put_in_list; + put_in_list_t *put_in_list; ns = &fr->ns; diff --git a/src/gromacs/mdlib/qmmm.cpp b/src/gromacs/mdlib/qmmm.cpp index cdd076c720..c4910874c4 100644 --- a/src/gromacs/mdlib/qmmm.cpp +++ b/src/gromacs/mdlib/qmmm.cpp @@ -134,20 +134,6 @@ static int struct_comp(const void *a, const void *b) } /* struct_comp */ -static int int_comp(const void *a, const void *b) -{ - - return (*(int *)a) - (*(int *)b); - -} /* int_comp */ - -static int QMlayer_comp(const void *a, const void *b) -{ - - return (int)(((t_QMrec *)a)->nrQMatoms)-(int)(((t_QMrec *)b)->nrQMatoms); - -} /* QMlayer_comp */ - real call_QMroutine(t_commrec gmx_unused *cr, t_forcerec gmx_unused *fr, t_QMrec gmx_unused *qm, t_MMrec gmx_unused *mm, rvec gmx_unused f[], rvec gmx_unused fshift[]) { diff --git a/src/gromacs/mdlib/shakef.cpp b/src/gromacs/mdlib/shakef.cpp index 489d5c77a4..9f122b9bd3 100644 --- a/src/gromacs/mdlib/shakef.cpp +++ b/src/gromacs/mdlib/shakef.cpp @@ -77,19 +77,6 @@ gmx_shakedata_t shake_init() return d; } -static void pv(FILE *log, char *s, rvec x) -{ - int m; - - fprintf(log, "%5s:", s); - for (m = 0; (m < DIM); m++) - { - fprintf(log, " %10.3f", x[m]); - } - fprintf(log, "\n"); - fflush(log); -} - /*! \brief Inner kernel for SHAKE constraints * * Original implementation from R.C. van Schaik and W.F. van Gunsteren diff --git a/src/gromacs/mdlib/wnblist.cpp b/src/gromacs/mdlib/wnblist.cpp index e32339056f..9a5f309d00 100644 --- a/src/gromacs/mdlib/wnblist.cpp +++ b/src/gromacs/mdlib/wnblist.cpp @@ -134,29 +134,6 @@ static void write_nblist(FILE *out, gmx_domdec_t *dd, t_nblist *nblist, int nDNL } } -static void set_mat(FILE *fp, int **mat, int i0, int ni, int j0, int nj, - gmx_bool bSymm, int shift) -{ - int i, j; - - for (i = i0; (i < i0+ni); i++) - { - for (j = j0; (j < j0+nj); j++) - { - if (mat[i][j] != 0) - { - fprintf(fp, "mat[%d][%d] changing from %d to %d\n", - i, j, mat[i][j], shift+1); - } - mat[i][j] = shift+1; - if (bSymm) - { - mat[j][i] = 27-shift; - } - } - } -} - void dump_nblist(FILE *out, t_commrec *cr, t_forcerec *fr, int nDNL) diff --git a/src/gromacs/utility/basenetwork.cpp b/src/gromacs/utility/basenetwork.cpp index 38151a9a2e..9aee424875 100644 --- a/src/gromacs/utility/basenetwork.cpp +++ b/src/gromacs/utility/basenetwork.cpp @@ -95,40 +95,6 @@ int gmx_node_rank() #endif } -static int mpi_hostname_hash() -{ - int hash_int; - -#ifndef GMX_LIB_MPI - /* We have a single physical node */ - hash_int = 0; -#else - int resultlen; - char mpi_hostname[MPI_MAX_PROCESSOR_NAME]; - - /* This procedure can only differentiate nodes with different names. - * Architectures where different physical nodes have identical names, - * such as IBM Blue Gene, should use an architecture specific solution. - */ - MPI_Get_processor_name(mpi_hostname, &resultlen); - - /* The string hash function returns an unsigned int. We cast to an int. - * Negative numbers are converted to positive by setting the sign bit to 0. - * This makes the hash one bit smaller. - * A 63-bit hash (with 64-bit int) should be enough for unique node hashes, - * even on a million node machine. 31 bits might not be enough though! - */ - hash_int = - (int)gmx_string_fullhash_func(mpi_hostname, gmx_string_hash_init); - if (hash_int < 0) - { - hash_int -= INT_MIN; - } -#endif - - return hash_int; -} - #if defined GMX_LIB_MPI && defined GMX_TARGET_BGQ #ifdef __clang__ /* IBM's declaration of this function in @@ -191,26 +157,53 @@ static int bgq_nodenum() } #endif -int gmx_physicalnode_id_hash() +static int mpi_hostname_hash() { - int hash; + int hash_int; -#ifndef GMX_MPI - hash = 0; +#ifdef GMX_TARGET_BGQ + hash_int = bgq_nodenum(); +#elif defined GMX_LIB_MPI + int resultlen; + char mpi_hostname[MPI_MAX_PROCESSOR_NAME]; + + /* This procedure can only differentiate nodes with different names. + * Architectures where different physical nodes have identical names, + * such as IBM Blue Gene, should use an architecture specific solution. + */ + MPI_Get_processor_name(mpi_hostname, &resultlen); + + /* The string hash function returns an unsigned int. We cast to an int. + * Negative numbers are converted to positive by setting the sign bit to 0. + * This makes the hash one bit smaller. + * A 63-bit hash (with 64-bit int) should be enough for unique node hashes, + * even on a million node machine. 31 bits might not be enough though! + */ + hash_int = static_cast(gmx_string_fullhash_func(mpi_hostname, gmx_string_hash_init)); + if (hash_int < 0) + { + hash_int -= INT_MIN; + } #else -#ifdef GMX_THREAD_MPI + /* thread-MPI currently puts the thread number in the process name, * we might want to change this, as this is inconsistent with what * most MPI implementations would do when running on a single node. */ - hash = 0; -#else -#ifdef GMX_TARGET_BGQ - hash = bgq_nodenum(); -#else - hash = mpi_hostname_hash(); -#endif + hash_int = 0; #endif + + return hash_int; +} + +int gmx_physicalnode_id_hash(void) +{ + int hash; + +#ifdef GMX_MPI + hash = mpi_hostname_hash(); +#else + hash = 0; #endif if (debug) diff --git a/src/gromacs/utility/cstringutil.cpp b/src/gromacs/utility/cstringutil.cpp index 358201c688..b73c15a893 100644 --- a/src/gromacs/utility/cstringutil.cpp +++ b/src/gromacs/utility/cstringutil.cpp @@ -562,10 +562,3 @@ void parse_digits_from_plain_string(const char *digitstring, int *ndigits, int * (*digitlist)[i] = digitstring[i] - '0'; } } - -static void parse_digits_from_csv_string(const char gmx_unused *digitstring, int gmx_unused *ndigits, int gmx_unused *digitlist) -{ - /* TODO Implement csv format to support (e.g.) more than 10 - different GPUs in a node. */ - gmx_incons("Not implemented yet"); -} diff --git a/src/programs/mdrun/repl_ex.cpp b/src/programs/mdrun/repl_ex.cpp index cbd74ac654..898451f21c 100644 --- a/src/programs/mdrun/repl_ex.cpp +++ b/src/programs/mdrun/repl_ex.cpp @@ -457,38 +457,6 @@ static void exchange_reals(const gmx_multisim_t gmx_unused *ms, int gmx_unused b } -static void exchange_ints(const gmx_multisim_t gmx_unused *ms, int gmx_unused b, int *v, int n) -{ - int *buf; - int i; - - if (v) - { - snew(buf, n); -#ifdef GMX_MPI - /* - MPI_Sendrecv(v, n*sizeof(int),MPI_BYTE,MSRANK(ms,b),0, - buf,n*sizeof(int),MPI_BYTE,MSRANK(ms,b),0, - ms->mpi_comm_masters,MPI_STATUS_IGNORE); - */ - { - MPI_Request mpi_req; - - MPI_Isend(v, n*sizeof(int), MPI_BYTE, MSRANK(ms, b), 0, - ms->mpi_comm_masters, &mpi_req); - MPI_Recv(buf, n*sizeof(int), MPI_BYTE, MSRANK(ms, b), 0, - ms->mpi_comm_masters, MPI_STATUS_IGNORE); - MPI_Wait(&mpi_req, MPI_STATUS_IGNORE); - } -#endif - for (i = 0; i < n; i++) - { - v[i] = buf[i]; - } - sfree(buf); - } -} - static void exchange_doubles(const gmx_multisim_t gmx_unused *ms, int gmx_unused b, double *v, int n) { double *buf; @@ -1124,19 +1092,6 @@ test_for_replica_exchange(FILE *fplog, fflush(fplog); /* make sure we can see what the last exchange was */ } -static void write_debug_x(t_state *state) -{ - int i; - - if (debug) - { - for (i = 0; i < state->natoms; i += 10) - { - fprintf(debug, "dx %5d %10.5f %10.5f %10.5f\n", i, state->x[i][XX], state->x[i][YY], state->x[i][ZZ]); - } - } -} - static void cyclic_decomposition(const int *destinations, int **cyclic, -- 2.11.4.GIT