From b6e7852ba0eb3fecd5943d6a687fda4b21179785 Mon Sep 17 00:00:00 2001 From: Denis Demidov Date: Fri, 18 Mar 2016 22:09:09 +0300 Subject: [PATCH] Provide conversion operators for CUDA wrapper classes These may be a more convenient alternative to the .raw() methods. --- vexcl/backend/cuda/context.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/vexcl/backend/cuda/context.hpp b/vexcl/backend/cuda/context.hpp index 1a5d07789..b1a3ece8d 100644 --- a/vexcl/backend/cuda/context.hpp +++ b/vexcl/backend/cuda/context.hpp @@ -101,6 +101,9 @@ class device { /// Returns raw CUdevice handle. CUdevice raw() const { return d; } + /// Returns raw CUdevice handle. + operator CUdevice() const { return d; } + /// Returns name of the device. std::string name() const { char name[256]; @@ -166,6 +169,11 @@ class context { return c.get(); } + /// Returns raw CUcontext handle. + operator CUcontext() const { + return c.get(); + } + /// Binds the context to the calling CPU thread. void set_current() const { cuda_check( cuCtxSetCurrent( c.get() ) ); @@ -223,6 +231,12 @@ class command_queue { CUstream raw() const { return s.get(); } + + /// Returns raw CUstream handle for the command queue. + operator CUstream() const { + return s.get(); + } + private: vex::backend::context ctx; vex::backend::device dev;