Skip to content

Commit

Permalink
Provide conversion operators for CUDA wrapper classes
Browse files Browse the repository at this point in the history
These may be a more convenient alternative to the .raw() methods.
  • Loading branch information
ddemidov committed Mar 18, 2016
1 parent 33d6daf commit b6e7852
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions vexcl/backend/cuda/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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() ) );
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit b6e7852

Please sign in to comment.