Convert gmx_detect_hardware.c to C++
authorMark Abraham <mark.j.abraham@gmail.com>
Sat, 17 May 2014 12:23:00 +0000 (14:23 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Mon, 19 May 2014 11:59:37 +0000 (13:59 +0200)
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

src/gromacs/gmxlib/gmx_detect_hardware.cpp [moved from src/gromacs/gmxlib/gmx_detect_hardware.c with 99% similarity]
src/gromacs/legacyheaders/gpu_utils.h

similarity index 99%
rename from src/gromacs/gmxlib/gmx_detect_hardware.c
rename to src/gromacs/gmxlib/gmx_detect_hardware.cpp
index 96ce3a1a9330ea2a4d490b7df13082469f38ede5..e5478b00202cea6d0f027e9d161350530bab7a92 100644 (file)
@@ -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
index e2960730495f0185e2374e3b87175bc6f05ff4be..c4da7c5a6218d772bd4d69887ea19f09142c84a7 100644 (file)
 
 #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
 }