Class CublasCaller

Class Documentation

class CublasCaller

A wrapper for cuBLAS calls. This should be used for all calls to cuBLAS.

In most cases you do not want to create objects of this class directly but use % This classes purpose is to manage the cuBLAS handle and avoid data races between setting the active CUDA device, the current cuBLAS stream and the call of the cuBLAS function via the call method. The class creates and destroys a cuBLAS handle on construction/destruction.

Public Functions

inline CublasCaller()

Creates a new CublasCaller with a new cuBLAS handle

inline ~CublasCaller()

Destructs the CublasCaller and destroys its cuBLAS handle

CublasCaller(CublasCaller const&) = delete
CublasCaller(CublasCaller&&) = delete
CublasCaller &operator=(CublasCaller const&) = delete
CublasCaller &operator=(CublasCaller&&) = delete
template<typename F, typename ...Args>
inline void call(F &&func, int dev_id, cudaStream_t stream, Args&&... args) const

Call a cuBLAS function.

The call function executes a cuBLAS function on a specified CUDA device and stream pair. It ensures thread safety for this operation, i.e., it prevents other thread from changing the active device and stream of the cuBLAS handle before the passed cuBLAS call could be queued.

Parameters
  • func – the cuBLAS function to be called.

  • dev_id – the CUDA device id on which the function should be executed.

  • stream – the CUDA stream on which the cuBLAS function should be queued.

  • args – the arguments for the cuBLAS function.