11 #include <kvikio/shim/utils.hpp> 
   31   template <
typename Callable>
 
   32   void set(Callable&& c)
 
   34     _callable = std::function(c);
 
   40   void reset() { _callable.reset(); }
 
   53   template <
typename... Args>
 
   56     using T = std::function<CUresult(Args...)>;
 
   57     if (!_callable.has_value()) {
 
   58       throw std::runtime_error(
"No callable has been assigned to the wrapper yet.");
 
   60     return std::any_cast<T&>(_callable)(args...);
 
   66   operator bool()
 const { 
return _callable.has_value(); }
 
   80   int driver_version{0};
 
   82   decltype(cuInit)* Init{
nullptr};
 
   83   decltype(cuMemHostAlloc)* MemHostAlloc{
nullptr};
 
   84   decltype(cuMemFreeHost)* MemFreeHost{
nullptr};
 
   85   decltype(cuMemcpyHtoDAsync)* MemcpyHtoDAsync{
nullptr};
 
   86   decltype(cuMemcpyDtoHAsync)* MemcpyDtoHAsync{
nullptr};
 
   90   decltype(cuPointerGetAttribute)* PointerGetAttribute{
nullptr};
 
   91   decltype(cuPointerGetAttributes)* PointerGetAttributes{
nullptr};
 
   92   decltype(cuCtxPushCurrent)* CtxPushCurrent{
nullptr};
 
   93   decltype(cuCtxPopCurrent)* CtxPopCurrent{
nullptr};
 
   94   decltype(cuCtxGetCurrent)* CtxGetCurrent{
nullptr};
 
   95   decltype(cuCtxGetDevice)* CtxGetDevice{
nullptr};
 
   96   decltype(cuMemGetAddressRange)* MemGetAddressRange{
nullptr};
 
   97   decltype(cuGetErrorName)* GetErrorName{
nullptr};
 
   98   decltype(cuGetErrorString)* GetErrorString{
nullptr};
 
   99   decltype(cuDeviceGet)* DeviceGet{
nullptr};
 
  100   decltype(cuDeviceGetCount)* DeviceGetCount{
nullptr};
 
  101   decltype(cuDeviceGetAttribute)* DeviceGetAttribute{
nullptr};
 
  102   decltype(cuDevicePrimaryCtxRetain)* DevicePrimaryCtxRetain{
nullptr};
 
  103   decltype(cuDevicePrimaryCtxRelease)* DevicePrimaryCtxRelease{
nullptr};
 
  104   decltype(cuStreamSynchronize)* StreamSynchronize{
nullptr};
 
  105   decltype(cuStreamCreate)* StreamCreate{
nullptr};
 
  106   decltype(cuStreamDestroy)* StreamDestroy{
nullptr};
 
  107   decltype(cuDriverGetVersion)* DriverGetVersion{
nullptr};
 
  114   void operator=(
cudaAPI const&) = 
delete;
 
  116   KVIKIO_EXPORT 
static cudaAPI& instance();
 
Shim layer of the cuda C-API.
 
Non-templated class to hold any callable that returns CUresult.
 
CUresult operator()(Args... args)
Invoke the container callable.
 
void reset()
Destroy the contained callable.
 
void set(Callable &&c)
Assign a callable to the object.
 
bool is_cuda_available()
Check if the CUDA library is available.