Gromacs  2024.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
oclutils.h File Reference
#include <string>
#include "gromacs/gpu_utils/device_context.h"
#include "gromacs/gpu_utils/device_stream.h"
#include "gromacs/gpu_utils/gmxopencl.h"
#include "gromacs/gpu_utils/gputraits_ocl.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/stringutil.h"
+ Include dependency graph for oclutils.h:
+ This graph shows which files directly or indirectly include this file:

Description

Declare utility routines for OpenCL.

Author
Anca Hamuraru anca@.nosp@m.stre.nosp@m.amcom.nosp@m.puti.nosp@m.ng.eu

Functions

std::string ocl_get_error_string (cl_int error)
 Convert error code to diagnostic string.
 
static bool haveStreamTasksCompleted (const DeviceStream &)
 Pretend to synchronize an OpenCL stream (dummy implementation). More...
 
void prepareGpuKernelArgument (cl_kernel kernel, const KernelLaunchConfig &config, size_t argIndex)
 A function for setting up a single OpenCL kernel argument. This is the tail of the compile-time recursive function below. It has to be seen by the compiler first. As NB kernels might be using dynamic local memory as the last argument, this function also manages that, using sharedMemorySize from config. More...
 
template<typename CurrentArg , typename... RemainingArgs>
void prepareGpuKernelArgument (cl_kernel kernel, const KernelLaunchConfig &config, size_t argIndex, const CurrentArg *argPtr, const RemainingArgs *...otherArgsPtrs)
 Compile-time recursive function for setting up a single OpenCL kernel argument. This function uses one kernel argument pointer argPtr to call clSetKernelArg(), and calls itself on the next argument, eventually calling the tail function above. More...
 
template<typename... Args>
void * prepareGpuKernelArguments (cl_kernel kernel, const KernelLaunchConfig &config, const Args *...argsPtrs)
 A wrapper function for setting up all the OpenCL kernel arguments. Calls the recursive functions above. More...
 
void launchGpuKernel (cl_kernel kernel, const KernelLaunchConfig &config, const DeviceStream &deviceStream, CommandEvent *timingEvent, const char *kernelName, const void *)
 Launches the OpenCL kernel and handles the errors. More...
 

Function Documentation

static bool haveStreamTasksCompleted ( const DeviceStream )
inlinestatic

Pretend to synchronize an OpenCL stream (dummy implementation).

Returns
Not implemented in OpenCL.
void launchGpuKernel ( cl_kernel  kernel,
const KernelLaunchConfig &  config,
const DeviceStream deviceStream,
CommandEvent timingEvent,
const char *  kernelName,
const void *   
)
inline

Launches the OpenCL kernel and handles the errors.

Parameters
[in]kernelKernel function handle
[in]configKernel configuration for launching
[in]deviceStreamGPU stream to launch kernel in
[in]timingEventTiming event, fetched from GpuRegionTimer
[in]kernelNameHuman readable kernel description, for error handling only
Exceptions
gmx::InternalErroron kernel launch failure
void prepareGpuKernelArgument ( cl_kernel  kernel,
const KernelLaunchConfig &  config,
size_t  argIndex 
)
inline

A function for setting up a single OpenCL kernel argument. This is the tail of the compile-time recursive function below. It has to be seen by the compiler first. As NB kernels might be using dynamic local memory as the last argument, this function also manages that, using sharedMemorySize from config.

Parameters
[in]kernelKernel function handle
[in]configKernel configuration for launching
[in]argIndexIndex of the current argument
template<typename CurrentArg , typename... RemainingArgs>
void prepareGpuKernelArgument ( cl_kernel  kernel,
const KernelLaunchConfig &  config,
size_t  argIndex,
const CurrentArg *  argPtr,
const RemainingArgs *...  otherArgsPtrs 
)

Compile-time recursive function for setting up a single OpenCL kernel argument. This function uses one kernel argument pointer argPtr to call clSetKernelArg(), and calls itself on the next argument, eventually calling the tail function above.

Template Parameters
CurrentArgType of the current argument
RemainingArgsTypes of remaining arguments after the current one
Parameters
[in]kernelKernel function handle
[in]configKernel configuration for launching
[in]argIndexIndex of the current argument
[in]argPtrPointer to the current argument
[in]otherArgsPtrsPack of pointers to arguments remaining to process after the current one
template<typename... Args>
void* prepareGpuKernelArguments ( cl_kernel  kernel,
const KernelLaunchConfig &  config,
const Args *...  argsPtrs 
)

A wrapper function for setting up all the OpenCL kernel arguments. Calls the recursive functions above.

Template Parameters
ArgsTypes of all the kernel arguments
Parameters
[in]kernelKernel function handle
[in]configKernel configuration for launching
[in]argsPtrsPointers to all the kernel arguments
Returns
A handle for the prepared parameter pack to be used with launchGpuKernel() as the last argument
  • currently always nullptr for OpenCL, as it manages kernel/arguments association by itself.