#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/smalloc.h"
-int ocl_copy_H2D(cl_mem d_dest, const void* h_src,
- size_t offset, size_t bytes,
+int ocl_copy_H2D(cl_mem d_dest,
+ const void* h_src,
+ size_t offset,
+ size_t bytes,
GpuApiCallBehavior transferKind,
- cl_command_queue command_queue,
- cl_event *copy_event)
+ cl_command_queue command_queue,
+ cl_event* copy_event)
{
cl_int gmx_unused cl_error;
switch (transferKind)
{
case GpuApiCallBehavior::Async:
- cl_error = clEnqueueWriteBuffer(command_queue, d_dest, CL_FALSE, offset, bytes, h_src, 0, nullptr, copy_event);
+ cl_error = clEnqueueWriteBuffer(command_queue, d_dest, CL_FALSE, offset, bytes, h_src,
+ 0, nullptr, copy_event);
assert(cl_error == CL_SUCCESS);
// TODO: handle errors
break;
case GpuApiCallBehavior::Sync:
- cl_error = clEnqueueWriteBuffer(command_queue, d_dest, CL_TRUE, offset, bytes, h_src, 0, nullptr, copy_event);
+ cl_error = clEnqueueWriteBuffer(command_queue, d_dest, CL_TRUE, offset, bytes, h_src, 0,
+ nullptr, copy_event);
assert(cl_error == CL_SUCCESS);
// TODO: handle errors
break;
- default:
- throw;
+ default: throw;
}
return 0;
* identifying this particular host to device operation. The event can further
* be used to queue a wait for this operation or to query profiling information.
*/
-int ocl_copy_H2D_async(cl_mem d_dest, const void * h_src,
- size_t offset, size_t bytes,
+int ocl_copy_H2D_async(cl_mem d_dest,
+ const void* h_src,
+ size_t offset,
+ size_t bytes,
cl_command_queue command_queue,
- cl_event *copy_event)
+ cl_event* copy_event)
{
return ocl_copy_H2D(d_dest, h_src, offset, bytes, GpuApiCallBehavior::Async, command_queue, copy_event);
}
/*! \brief Launches synchronous host to device memory copy.
*/
-int ocl_copy_H2D_sync(cl_mem d_dest, const void * h_src,
- size_t offset, size_t bytes,
- cl_command_queue command_queue)
+int ocl_copy_H2D_sync(cl_mem d_dest, const void* h_src, size_t offset, size_t bytes, cl_command_queue command_queue)
{
return ocl_copy_H2D(d_dest, h_src, offset, bytes, GpuApiCallBehavior::Sync, command_queue, nullptr);
}
-int ocl_copy_D2H(void * h_dest, cl_mem d_src,
- size_t offset, size_t bytes,
+int ocl_copy_D2H(void* h_dest,
+ cl_mem d_src,
+ size_t offset,
+ size_t bytes,
GpuApiCallBehavior transferKind,
- cl_command_queue command_queue,
- cl_event *copy_event)
+ cl_command_queue command_queue,
+ cl_event* copy_event)
{
cl_int gmx_unused cl_error;
switch (transferKind)
{
case GpuApiCallBehavior::Async:
- cl_error = clEnqueueReadBuffer(command_queue, d_src, CL_FALSE, offset, bytes, h_dest, 0, nullptr, copy_event);
+ cl_error = clEnqueueReadBuffer(command_queue, d_src, CL_FALSE, offset, bytes, h_dest, 0,
+ nullptr, copy_event);
assert(cl_error == CL_SUCCESS);
// TODO: handle errors
break;
case GpuApiCallBehavior::Sync:
- cl_error = clEnqueueReadBuffer(command_queue, d_src, CL_TRUE, offset, bytes, h_dest, 0, nullptr, copy_event);
+ cl_error = clEnqueueReadBuffer(command_queue, d_src, CL_TRUE, offset, bytes, h_dest, 0,
+ nullptr, copy_event);
assert(cl_error == CL_SUCCESS);
// TODO: handle errors
break;
- default:
- throw;
+ default: throw;
}
return 0;
* identifying this particular host to device operation. The event can further
* be used to queue a wait for this operation or to query profiling information.
*/
-int ocl_copy_D2H_async(void * h_dest, cl_mem d_src,
- size_t offset, size_t bytes,
+int ocl_copy_D2H_async(void* h_dest,
+ cl_mem d_src,
+ size_t offset,
+ size_t bytes,
cl_command_queue command_queue,
- cl_event *copy_event)
+ cl_event* copy_event)
{
return ocl_copy_D2H(h_dest, d_src, offset, bytes, GpuApiCallBehavior::Async, command_queue, copy_event);
}
* \param[in,out] h_ptr Pointer where to store the address of the newly allocated buffer.
* \param[in] nbytes Size in bytes of the buffer to be allocated.
*/
-void pmalloc(void **h_ptr, size_t nbytes)
+void pmalloc(void** h_ptr, size_t nbytes)
{
/* Need a temporary type whose size is 1 byte, so that the
* implementation of snew_aligned can cope without issuing
* warnings. */
- char **temporary = reinterpret_cast<char **>(h_ptr);
+ char** temporary = reinterpret_cast<char**>(h_ptr);
/* 16-byte alignment is required by the neighbour-searching code,
* because it uses four-wide SIMD for bounding-box calculation.
*
* \param[in] h_ptr Buffer allocated with pmalloc that needs to be freed.
*/
-void pfree(void *h_ptr)
+void pfree(void* h_ptr)
{
if (h_ptr)
case -1003: return "CL_INVALID_D3D10_RESOURCE_KHR";
case -1004: return "CL_D3D10_RESOURCE_ALREADY_ACQUIRED_KHR";
case -1005: return "CL_D3D10_RESOURCE_NOT_ACQUIRED_KHR";
- default: return "Unknown OpenCL error: " +
- std::to_string(static_cast<int32_t>(error));
+ default: return "Unknown OpenCL error: " + std::to_string(static_cast<int32_t>(error));
}
}