Fix warnings when clang is the CUDA host compiler
[alexxy/gromacs.git] / src / gromacs / gpu_utils / devicebuffer.cuh
index 97e9d525b21b3deab5cffaf476ad3173bdf473e2..9dd29c2923dc0694bd74bf95b03b313b8dc24eb0 100644 (file)
@@ -68,8 +68,7 @@ template<typename ValueType>
 void allocateDeviceBuffer(DeviceBuffer<ValueType>* buffer, size_t numValues, const DeviceContext& /* deviceContext */)
 {
     GMX_ASSERT(buffer, "needs a buffer pointer");
-    // NOLINTNEXTLINE(google-readability-casting)
-    cudaError_t stat = cudaMalloc((void**)(buffer), numValues * sizeof(ValueType));
+    cudaError_t stat = cudaMalloc(buffer, numValues * sizeof(ValueType));
     GMX_RELEASE_ASSERT(
             stat == cudaSuccess,
             ("Allocation of the device buffer failed. " + gmx::getDeviceErrorString(stat)).c_str());
@@ -131,8 +130,7 @@ void copyToDeviceBuffer(DeviceBuffer<ValueType>* buffer,
     {
         case GpuApiCallBehavior::Async:
             GMX_ASSERT(isHostMemoryPinned(hostBuffer), "Source host buffer was not pinned for CUDA");
-            // NOLINTNEXTLINE(google-readability-casting)
-            stat = cudaMemcpyAsync(*((ValueType**)buffer) + startingOffset,
+            stat = cudaMemcpyAsync(*reinterpret_cast<ValueType**>(buffer) + startingOffset,
                                    hostBuffer,
                                    bytes,
                                    cudaMemcpyHostToDevice,
@@ -143,12 +141,10 @@ void copyToDeviceBuffer(DeviceBuffer<ValueType>* buffer,
             break;
 
         case GpuApiCallBehavior::Sync:
-            stat = cudaMemcpy(
-                    // NOLINTNEXTLINE(google-readability-casting)
-                    *((ValueType**)buffer) + startingOffset,
-                    hostBuffer,
-                    bytes,
-                    cudaMemcpyHostToDevice);
+            stat = cudaMemcpy(*reinterpret_cast<ValueType**>(buffer) + startingOffset,
+                              hostBuffer,
+                              bytes,
+                              cudaMemcpyHostToDevice);
             GMX_RELEASE_ASSERT(
                     stat == cudaSuccess,
                     ("Synchronous H2D copy failed. " + gmx::getDeviceErrorString(stat)).c_str());
@@ -195,8 +191,7 @@ void copyFromDeviceBuffer(ValueType*               hostBuffer,
             GMX_ASSERT(isHostMemoryPinned(hostBuffer),
                        "Destination host buffer was not pinned for CUDA");
             stat = cudaMemcpyAsync(hostBuffer,
-                                   // NOLINTNEXTLINE(google-readability-casting)
-                                   *((ValueType**)buffer) + startingOffset,
+                                   *reinterpret_cast<ValueType**>(buffer) + startingOffset,
                                    bytes,
                                    cudaMemcpyDeviceToHost,
                                    deviceStream.stream());
@@ -207,8 +202,7 @@ void copyFromDeviceBuffer(ValueType*               hostBuffer,
 
         case GpuApiCallBehavior::Sync:
             stat = cudaMemcpy(hostBuffer,
-                              // NOLINTNEXTLINE(google-readability-casting)
-                              *((ValueType**)buffer) + startingOffset,
+                              *reinterpret_cast<ValueType**>(buffer) + startingOffset,
                               bytes,
                               cudaMemcpyDeviceToHost);
             GMX_RELEASE_ASSERT(
@@ -297,11 +291,7 @@ void clearDeviceBufferAsync(DeviceBuffer<ValueType>* buffer,
     const char   pattern = 0;
 
     cudaError_t stat = cudaMemsetAsync(
-            // NOLINTNEXTLINE(google-readability-casting)
-            *((ValueType**)buffer) + startingOffset,
-            pattern,
-            bytes,
-            deviceStream.stream());
+            *reinterpret_cast<ValueType**>(buffer) + startingOffset, pattern, bytes, deviceStream.stream());
     GMX_RELEASE_ASSERT(stat == cudaSuccess,
                        ("Couldn't clear the device buffer. " + gmx::getDeviceErrorString(stat)).c_str());
 }
@@ -358,9 +348,8 @@ void initParamLookupTable(DeviceBuffer<ValueType>* deviceBuffer,
 
     const size_t sizeInBytes = numValues * sizeof(ValueType);
 
-    cudaError_t stat =
-            // NOLINTNEXTLINE(google-readability-casting)
-            cudaMemcpy(*((ValueType**)deviceBuffer), hostBuffer, sizeInBytes, cudaMemcpyHostToDevice);
+    cudaError_t stat = cudaMemcpy(
+            *reinterpret_cast<ValueType**>(deviceBuffer), hostBuffer, sizeInBytes, cudaMemcpyHostToDevice);
 
     GMX_RELEASE_ASSERT(stat == cudaSuccess,
                        ("Synchronous H2D copy failed. " + gmx::getDeviceErrorString(stat)).c_str());