From 1434a2a4a4de1c4ee1a4cf595b87dc645b9a34f5 Mon Sep 17 00:00:00 2001 From: Mark Abraham Date: Sat, 17 May 2014 14:23:00 +0200 Subject: [PATCH] Convert gmx_detect_hardware.c to C++ Minor fixes to keep new compilers and static analysis happy. The change to the return behaviour of sizeof_cuda_dev_info does not matter, because it is only used if it is non-zero. Change-Id: If2c9c2676667316637a30af9ead71fb9f77058c2 --- ...etect_hardware.c => gmx_detect_hardware.cpp} | 17 ++++++++++------- src/gromacs/legacyheaders/gpu_utils.h | 4 +++- 2 files changed, 13 insertions(+), 8 deletions(-) rename src/gromacs/gmxlib/{gmx_detect_hardware.c => gmx_detect_hardware.cpp} (99%) diff --git a/src/gromacs/gmxlib/gmx_detect_hardware.c b/src/gromacs/gmxlib/gmx_detect_hardware.cpp similarity index 99% rename from src/gromacs/gmxlib/gmx_detect_hardware.c rename to src/gromacs/gmxlib/gmx_detect_hardware.cpp index 96ce3a1a93..e5478b0020 100644 --- a/src/gromacs/gmxlib/gmx_detect_hardware.c +++ b/src/gromacs/gmxlib/gmx_detect_hardware.cpp @@ -233,8 +233,8 @@ void gmx_check_hw_runconf_consistency(FILE *fplog, const gmx_hw_opt_t *hw_opt, gmx_bool bUseGPU) { - int npppn, ntmpi_pp; - char sbuf[STRLEN], th_or_proc[STRLEN], th_or_proc_plural[STRLEN], pernode[STRLEN]; + int npppn; + char th_or_proc[STRLEN], th_or_proc_plural[STRLEN], pernode[STRLEN]; gmx_bool btMPI, bMPI, bMaxMpiThreadsSet, bNthreadsAuto, bEmulateGPU; assert(hwinfo); @@ -249,13 +249,18 @@ void gmx_check_hw_runconf_consistency(FILE *fplog, return; } - btMPI = bMPI = FALSE; - bNthreadsAuto = FALSE; #if defined(GMX_THREAD_MPI) + bMPI = FALSE; btMPI = TRUE; bNthreadsAuto = (hw_opt->nthreads_tmpi < 1); #elif defined(GMX_LIB_MPI) - bMPI = TRUE; + bMPI = TRUE; + btMPI = FALSE; + bNthreadsAuto = FALSE; +#else + bMPI = FALSE; + btMPI = FALSE; + bNthreadsAuto = FALSE; #endif /* GPU emulation detection is done later, but we need here as well @@ -625,7 +630,6 @@ static void gmx_detect_gpus(FILE *fplog, const t_commrec *cr) gmx_hw_info_t *gmx_detect_hardware(FILE *fplog, const t_commrec *cr, gmx_bool bDetectGPUs) { - gmx_hw_info_t *hw; int ret; /* make sure no one else is doing the same thing */ @@ -723,7 +727,6 @@ void gmx_select_gpu_ids(FILE *fplog, const t_commrec *cr, gmx_gpu_opt_t *gpu_opt) { int i; - const char *env; char sbuf[STRLEN], stmp[STRLEN]; /* Bail if binary is not compiled with GPU acceleration, but this is either diff --git a/src/gromacs/legacyheaders/gpu_utils.h b/src/gromacs/legacyheaders/gpu_utils.h index e296073049..c4da7c5a62 100644 --- a/src/gromacs/legacyheaders/gpu_utils.h +++ b/src/gromacs/legacyheaders/gpu_utils.h @@ -47,10 +47,12 @@ #ifdef GMX_GPU #define FUNC_TERM_INT ; +#define FUNC_TERM_SIZE_T ; #define FUNC_TERM_VOID ; #define FUNC_QUALIFIER #else #define FUNC_TERM_INT {return -1; } +#define FUNC_TERM_SIZE_T {return 0; } #define FUNC_TERM_VOID {} #define FUNC_QUALIFIER static #endif @@ -104,7 +106,7 @@ FUNC_QUALIFIER void get_gpu_device_info_string(char gmx_unused *s, const gmx_gpu_info_t gmx_unused *gpu_info, int gmx_unused index) FUNC_TERM_VOID FUNC_QUALIFIER -size_t sizeof_cuda_dev_info(void) FUNC_TERM_INT +size_t sizeof_cuda_dev_info(void) FUNC_TERM_SIZE_T #ifdef __cplusplus } -- 2.22.0