From 8bfaa3e31ea3cb03bd829cf487fe4ca9524f69a0 Mon Sep 17 00:00:00 2001 From: Artem Zhmurov Date: Thu, 30 Jan 2020 13:56:17 +0100 Subject: [PATCH] Cleaning booleans in NBNXM in OpenCL build Patch 93f2f30017595e419d25c5dd6fa6a8b320a1858f changed some of the booleans types from cl_bool to bool, but not changed how these variables were used in some places. This caused the compiler to be confused with the data types, trying to convert bool to int or to cl_bool. Change-Id: Ib8017bbdac804f3946e65698df5882c669250044 --- src/gromacs/nbnxm/cuda/nbnxm_cuda_data_mgmt.cu | 2 +- src/gromacs/nbnxm/gpu_common.h | 3 +-- src/gromacs/nbnxm/gpu_data_mgmt.h | 2 +- src/gromacs/nbnxm/opencl/nbnxm_ocl.cpp | 8 ++++---- src/gromacs/nbnxm/opencl/nbnxm_ocl_data_mgmt.cpp | 10 +++++----- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/gromacs/nbnxm/cuda/nbnxm_cuda_data_mgmt.cu b/src/gromacs/nbnxm/cuda/nbnxm_cuda_data_mgmt.cu index d99bdfd774..b2fc758417 100644 --- a/src/gromacs/nbnxm/cuda/nbnxm_cuda_data_mgmt.cu +++ b/src/gromacs/nbnxm/cuda/nbnxm_cuda_data_mgmt.cu @@ -417,7 +417,7 @@ NbnxmGpu* gpu_init(const gmx_device_info_t* deviceInfo, const PairlistParams& listParams, const nbnxn_atomdata_t* nbat, int /*rank*/, - gmx_bool bLocalAndNonlocal) + bool bLocalAndNonlocal) { cudaError_t stat; diff --git a/src/gromacs/nbnxm/gpu_common.h b/src/gromacs/nbnxm/gpu_common.h index dcfd2f8fef..65f38daea2 100644 --- a/src/gromacs/nbnxm/gpu_common.h +++ b/src/gromacs/nbnxm/gpu_common.h @@ -418,8 +418,7 @@ bool gpu_try_finish_task(NbnxmGpu* nb, // TODO: this needs to be moved later because conditional wait could brake timing // with a future OpenCL implementation, but with CUDA timing is anyway disabled // in all cases where we skip the wait. - gpu_accumulate_timings(nb->timings, nb->timers, nb->plist[iLocality], aloc, stepWork, - nb->bDoTime != 0); + gpu_accumulate_timings(nb->timings, nb->timers, nb->plist[iLocality], aloc, stepWork, nb->bDoTime); if (stepWork.computeEnergy || stepWork.computeVirial) { diff --git a/src/gromacs/nbnxm/gpu_data_mgmt.h b/src/gromacs/nbnxm/gpu_data_mgmt.h index 30d44159ca..9d7502cdbd 100644 --- a/src/gromacs/nbnxm/gpu_data_mgmt.h +++ b/src/gromacs/nbnxm/gpu_data_mgmt.h @@ -69,7 +69,7 @@ NbnxmGpu* gpu_init(const gmx_device_info_t gmx_unused* deviceInfo, const nbnxn_atomdata_t gmx_unused* nbat, int gmx_unused rank, /* true if both local and non-local are done on GPU */ - gmx_bool gmx_unused bLocalAndNonlocal) GPU_FUNC_TERM_WITH_RETURN(nullptr); + bool gmx_unused bLocalAndNonlocal) GPU_FUNC_TERM_WITH_RETURN(nullptr); /** Initializes pair-list data for GPU, called at every pair search step. */ GPU_FUNC_QUALIFIER diff --git a/src/gromacs/nbnxm/opencl/nbnxm_ocl.cpp b/src/gromacs/nbnxm/opencl/nbnxm_ocl.cpp index 12d38ed267..90dbf0a336 100644 --- a/src/gromacs/nbnxm/opencl/nbnxm_ocl.cpp +++ b/src/gromacs/nbnxm/opencl/nbnxm_ocl.cpp @@ -488,7 +488,7 @@ void gpu_copy_xq_to_gpu(NbnxmGpu* nb, const nbnxn_atomdata_t* nbatom, const Atom cl_timers_t* t = nb->timers; cl_command_queue stream = nb->stream[iloc]; - bool bDoTime = (nb->bDoTime) != 0; + bool bDoTime = nb->bDoTime; /* Don't launch the non-local H2D copy if there is no dependent work to do: neither non-local nor other (e.g. bonded) work @@ -588,7 +588,7 @@ void gpu_launch_kernel(NbnxmGpu* nb, const gmx::StepWorkload& stepWork, const Nb cl_timers_t* t = nb->timers; cl_command_queue stream = nb->stream[iloc]; - bool bDoTime = (nb->bDoTime) != 0; + bool bDoTime = nb->bDoTime; cl_nbparam_params_t nbparams_params; @@ -726,7 +726,7 @@ void gpu_launch_kernel_pruneonly(NbnxmGpu* nb, const InteractionLocality iloc, c cl_plist_t* plist = nb->plist[iloc]; cl_timers_t* t = nb->timers; cl_command_queue stream = nb->stream[iloc]; - bool bDoTime = nb->bDoTime == CL_TRUE; + bool bDoTime = nb->bDoTime; if (plist->haveFreshList) { @@ -861,7 +861,7 @@ void gpu_launch_cpyback(NbnxmGpu* nb, cl_atomdata_t* adat = nb->atdat; cl_timers_t* t = nb->timers; - bool bDoTime = nb->bDoTime == CL_TRUE; + bool bDoTime = nb->bDoTime; cl_command_queue stream = nb->stream[iloc]; /* don't launch non-local copy-back if there was no non-local work to do */ diff --git a/src/gromacs/nbnxm/opencl/nbnxm_ocl_data_mgmt.cpp b/src/gromacs/nbnxm/opencl/nbnxm_ocl_data_mgmt.cpp index e7b2884f1a..2556ea6261 100644 --- a/src/gromacs/nbnxm/opencl/nbnxm_ocl_data_mgmt.cpp +++ b/src/gromacs/nbnxm/opencl/nbnxm_ocl_data_mgmt.cpp @@ -614,7 +614,7 @@ NbnxmGpu* gpu_init(const gmx_device_info_t* deviceInfo, const PairlistParams& listParams, const nbnxn_atomdata_t* nbat, const int rank, - const gmx_bool bLocalAndNonlocal) + const bool bLocalAndNonlocal) { cl_int cl_error; cl_command_queue_properties queue_properties; @@ -630,7 +630,7 @@ NbnxmGpu* gpu_init(const gmx_device_info_t* deviceInfo, snew(nb->plist[InteractionLocality::NonLocal], 1); } - nb->bUseTwoStreams = static_cast(bLocalAndNonlocal); + nb->bUseTwoStreams = bLocalAndNonlocal; nb->timers = new cl_timers_t(); snew(nb->timings, 1); @@ -647,7 +647,7 @@ NbnxmGpu* gpu_init(const gmx_device_info_t* deviceInfo, init_plist(nb->plist[InteractionLocality::Local]); /* OpenCL timing disabled if GMX_DISABLE_GPU_TIMING is defined. */ - nb->bDoTime = static_cast(getenv("GMX_DISABLE_GPU_TIMING") == nullptr); + nb->bDoTime = (getenv("GMX_DISABLE_GPU_TIMING") == nullptr); /* Create queues only after bDoTime has been initialized */ if (nb->bDoTime) @@ -762,7 +762,7 @@ void gpu_init_pairlist(NbnxmGpu* nb, const NbnxnPairlistGpu* h_plist, const Inte // Timing accumulation should happen only if there was work to do // because getLastRangeTime() gets skipped with empty lists later // which leads to the counter not being reset. - bool bDoTime = ((nb->bDoTime == CL_TRUE) && !h_plist->sci.empty()); + bool bDoTime = (nb->bDoTime && !h_plist->sci.empty()); cl_command_queue stream = nb->stream[iloc]; cl_plist_t* d_plist = nb->plist[iloc]; @@ -837,7 +837,7 @@ void gpu_init_atomdata(NbnxmGpu* nb, const nbnxn_atomdata_t* nbat) cl_int cl_error; int nalloc, natoms; bool realloced; - bool bDoTime = nb->bDoTime == CL_TRUE; + bool bDoTime = nb->bDoTime; cl_timers_t* timers = nb->timers; cl_atomdata_t* d_atdat = nb->atdat; cl_command_queue ls = nb->stream[InteractionLocality::Local]; -- 2.22.0