diff options
-rw-r--r-- | include/CL/cl_intel.h | 8 | ||||
-rw-r--r-- | src/cl_api.c | 23 | ||||
-rw-r--r-- | src/cl_mem.c | 15 | ||||
-rw-r--r-- | src/cl_mem.h | 6 |
4 files changed, 52 insertions, 0 deletions
diff --git a/include/CL/cl_intel.h b/include/CL/cl_intel.h index 680f9480..ff1860a6 100644 --- a/include/CL/cl_intel.h +++ b/include/CL/cl_intel.h @@ -40,6 +40,14 @@ clIntelMapBuffer(cl_mem, cl_int*); extern CL_API_ENTRY cl_int CL_API_CALL clIntelUnmapBuffer(cl_mem); +/* 1 to 1 mapping of drm_intel_gem_bo_map_gtt */ +extern CL_API_ENTRY void* CL_API_CALL +clIntelMapBufferGTT(cl_mem, cl_int*); + +/* 1 to 1 mapping of drm_intel_gem_bo_unmap_gtt */ +extern CL_API_ENTRY cl_int CL_API_CALL +clIntelUnmapBufferGTT(cl_mem); + /* Pin /Unpin the buffer in GPU memory (must be root) */ extern CL_API_ENTRY cl_int CL_API_CALL clIntelPinBuffer(cl_mem); diff --git a/src/cl_api.c b/src/cl_api.c index 2d84ace6..6d7dd9aa 100644 --- a/src/cl_api.c +++ b/src/cl_api.c @@ -1212,6 +1212,29 @@ error: return err; } +void* +clIntelMapBufferGTT(cl_mem mem, cl_int *errcode_ret) +{ + void *ptr = NULL; + cl_int err = CL_SUCCESS; + CHECK_MEM (mem); + ptr = cl_mem_map_gtt(mem); +error: + if (errcode_ret) + *errcode_ret = err; + return ptr; +} + +cl_int +clIntelUnmapBufferGTT(cl_mem mem) +{ + cl_int err = CL_SUCCESS; + CHECK_MEM (mem); + err = cl_mem_unmap_gtt(mem); +error: + return err; +} + cl_int clIntelPinBuffer(cl_mem mem) { diff --git a/src/cl_mem.c b/src/cl_mem.c index ab9cc9a0..690e5cfa 100644 --- a/src/cl_mem.c +++ b/src/cl_mem.c @@ -481,6 +481,21 @@ cl_mem_unmap(cl_mem mem) return CL_SUCCESS; } +LOCAL void* +cl_mem_map_gtt(cl_mem mem) +{ + cl_buffer_map_gtt(mem->bo); + assert(cl_buffer_get_virtual(mem->bo)); + return cl_buffer_get_virtual(mem->bo); +} + +LOCAL cl_int +cl_mem_unmap_gtt(cl_mem mem) +{ + cl_buffer_unmap_gtt(mem->bo); + return CL_SUCCESS; +} + LOCAL cl_int cl_mem_pin(cl_mem mem) { diff --git a/src/cl_mem.h b/src/cl_mem.h index a3a15478..99f3835e 100644 --- a/src/cl_mem.h +++ b/src/cl_mem.h @@ -76,6 +76,12 @@ extern void *cl_mem_map(cl_mem); /* Unmap a memory object */ extern cl_int cl_mem_unmap(cl_mem); +/* Directly map a memory object in GTT mode */ +extern void *cl_mem_map_gtt(cl_mem); + +/* Unmap a memory object in GTT mode */ +extern cl_int cl_mem_unmap_gtt(cl_mem); + /* Pin/unpin the buffer in memory (you must be root) */ extern cl_int cl_mem_pin(cl_mem); extern cl_int cl_mem_unpin(cl_mem); |