Core: fixed handle wrapping for CUcontext

This commit is contained in:
Philippe Tillet
2015-11-21 13:57:05 -05:00
parent f653625aa9
commit 6be5929b0d
14 changed files with 59 additions and 12 deletions

View File

@@ -48,6 +48,7 @@ RESTORE_MSVC_WARNING_C4251
static void release();
public:
static Context const & get_default();
static Context const & import(CUcontext context);
static Context const & import(cl_context context);
static void get(std::list<Context const *> &);
private:

View File

@@ -6,7 +6,7 @@
#include "isaac/driver/common.h"
#include "isaac/driver/context.h"
#include "isaac/driver/handle.h"
#include "isaac/driver/dispatch.h"
namespace isaac
{
@@ -18,6 +18,14 @@ class ISAACAPI Buffer
{
friend class CommandQueue;
friend class Kernel;
static CUcontext context(CUdeviceptr h)
{
CUcontext res;
cuda::check(dispatch::cuPointerGetAttribute((void*)&res, CU_POINTER_ATTRIBUTE_CONTEXT, h));
return res;
}
public:
Buffer(CUdeviceptr h = 0, bool take_ownership = true);
Buffer(cl_mem Buffer = 0, bool take_ownership = true);

View File

@@ -21,6 +21,7 @@ class ISAACAPI Context
friend class Buffer;
public:
explicit Context(CUcontext const & context, CUdevice const & device, bool take_ownership = true);
explicit Context(cl_context const & context, bool take_ownership = true);
explicit Context(Device const & device);

View File

@@ -47,8 +47,9 @@ private:
int cuGetInfo() const;
public:
Device(int ordinal);
Device(cl_device_id const & device, bool take_ownership = true);
// Device(int ordinal);
explicit Device(CUdevice const & device, bool take_ownership = true);
explicit Device(cl_device_id const & device, bool take_ownership = true);
bool operator==(Device const &) const;
bool operator<(Device const &) const;

View File

@@ -113,6 +113,7 @@ public:
static CUresult cuStreamDestroy_v2(CUstream hStream);
static CUresult cuEventDestroy_v2(CUevent hEvent);
static CUresult cuMemAlloc_v2(CUdeviceptr *dptr, size_t bytesize);
static CUresult cuPointerGetAttribute(void * data, CUpointer_attribute attribute, CUdeviceptr ptr);
static nvrtcResult nvrtcCompileProgram(nvrtcProgram prog, int numOptions, const char **options);
static nvrtcResult nvrtcGetProgramLogSize(nvrtcProgram prog, size_t *logSizeRet);
@@ -188,6 +189,7 @@ private:
static void* cuStreamDestroy_v2_;
static void* cuEventDestroy_v2_;
static void* cuMemAlloc_v2_;
static void* cuPointerGetAttribute_;
static void* nvrtcCompileProgram_;
static void* nvrtcGetProgramLogSize_;