#include <array>
#include <string>
+#include <type_traits>
#include "gromacs/gpu_utils/device_stream.h"
#include "gromacs/gpu_utils/gputraits.cuh"
const CurrentArg* argPtr,
const RemainingArgs*... otherArgsPtrs)
{
- // NOLINTNEXTLINE(google-readability-casting)
- (*kernelArgsPtr)[argIndex] = (void*)argPtr;
+ (*kernelArgsPtr)[argIndex] = const_cast<void*>(static_cast<const void*>(argPtr));
prepareGpuKernelArgument(kernel, kernelArgsPtr, argIndex + 1, otherArgsPtrs...);
}
{
dim3 blockSize(config.blockSize[0], config.blockSize[1], config.blockSize[2]);
dim3 gridSize(config.gridSize[0], config.gridSize[1], config.gridSize[2]);
- // NOLINTNEXTLINE(google-readability-casting)
- cudaLaunchKernel((void*)kernel,
+ cudaLaunchKernel(reinterpret_cast<void*>(kernel),
gridSize,
blockSize,
const_cast<void**>(kernelArgs.data()),
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());
{
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,
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());
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());
case GpuApiCallBehavior::Sync:
stat = cudaMemcpy(hostBuffer,
- // NOLINTNEXTLINE(google-readability-casting)
- *((ValueType**)buffer) + startingOffset,
+ *reinterpret_cast<ValueType**>(buffer) + startingOffset,
bytes,
cudaMemcpyDeviceToHost);
GMX_RELEASE_ASSERT(
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());
}
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());