Skip to content

Commit

Permalink
[GPU] Added getMappedPtr
Browse files Browse the repository at this point in the history
  • Loading branch information
dmed256 committed Jul 20, 2018
1 parent 6f4f5c1 commit 405fb35
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 7 deletions.
3 changes: 3 additions & 0 deletions include/occa/modes/cuda/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,14 @@ namespace occa {

class memory : public occa::memory_v {
friend class cuda::device;

friend occa::memory wrapMemory(occa::device device,
void *ptr,
const udim_t bytes,
const occa::properties &props);

friend void* getMappedPtr(occa::memory mem);

public:
CUdeviceptr &cuPtr;
char *mappedPtr;
Expand Down
2 changes: 2 additions & 0 deletions include/occa/modes/cuda/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ namespace occa {

CUcontext getContext(occa::device device);

void* getMappedPtr(occa::memory mem);

occa::device wrapDevice(CUdevice device,
CUcontext context,
const occa::properties &props = occa::properties());
Expand Down
2 changes: 1 addition & 1 deletion include/occa/modes/opencl/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace occa {

friend cl_mem getCLMemory(occa::memory memory);

friend void* getCLMappedPtr(occa::memory memory);
friend void* getMappedPtr(occa::memory memory);

friend occa::memory wrapMemory(occa::device device,
cl_mem clMem,
Expand Down
4 changes: 2 additions & 2 deletions include/occa/modes/opencl/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ namespace occa {

cl_mem getCLMemory(occa::memory memory);

void* getCLMappedPtr(occa::memory memory);

cl_kernel getCLKernel(occa::kernel kernel);

void* getMappedPtr(occa::memory memory);

occa::device wrapDevice(cl_device_id clDevice,
cl_context context,
const occa::properties &props = occa::properties());
Expand Down
5 changes: 5 additions & 0 deletions src/modes/cuda/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ namespace occa {
return ((cuda::device*) device.getDHandle())->cuContext;
}

void* getMappedPtr(occa::memory mem) {
cuda::memory *handle = (cuda::memory*) mem.getMHandle();
return handle ? handle->mappedPtr : NULL;
}

occa::device wrapDevice(CUdevice device,
CUcontext context,
const occa::properties &props) {
Expand Down
9 changes: 5 additions & 4 deletions src/modes/opencl/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,14 +443,15 @@ namespace occa {
return ((opencl::memory*) memory.getMHandle())->clMem;
}

void* getCLMappedPtr(occa::memory memory) {
return ((opencl::memory*) memory.getMHandle())->mappedPtr;
}

cl_kernel getCLKernel(occa::kernel kernel) {
return ((opencl::kernel*) kernel.getKHandle())->clKernel;
}

void* getMappedPtr(occa::memory memory) {
opencl::memory *handle = (opencl::memory*) memory.getMHandle();
return handle ? handle->mappedPtr : NULL;
}

occa::device wrapDevice(cl_device_id clDevice,
cl_context context,
const occa::properties &props) {
Expand Down

0 comments on commit 405fb35

Please sign in to comment.