[Beignet] [PATCH] Runtime: don't use map_gtt for cl buffer.

Yang, Rong R rong.r.yang at intel.com
Sun May 4 20:11:15 PDT 2014


It can't use cl_mem_map here. Because function _cl_map_mem is used for clEnqueueMapBuffer and clEnqueueMapImage, which request unsynchronized map.
Unfortunately libdrm only provide unsynchronized map GTT. There is no unsynchronized version drm_intel_gem_bo_map.

-----Original Message-----
From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of Zhigang Gong
Sent: Sunday, May 04, 2014 9:42 AM
To: beignet at lists.freedesktop.org
Cc: Gong, Zhigang
Subject: [Beignet] [PATCH] Runtime: don't use map_gtt for cl buffer.

We only need to map gtt for image. Map gtt may fail for large buffers.

Signed-off-by: Zhigang Gong <zhigang.gong at intel.com>
---
 src/cl_api.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/cl_api.c b/src/cl_api.c index 03a1cda..774ca8f 100644
--- a/src/cl_api.c
+++ b/src/cl_api.c
@@ -2172,9 +2172,16 @@ static cl_int _cl_map_mem(cl_mem mem, void **ptr, void **mem_ptr, size_t offset,
     sub_offset = buffer->sub_offset;
   }
 
-  if (!(*ptr = cl_mem_map_gtt_unsync(mem))) {
-    err = CL_MAP_FAILURE;
-    goto error;
+  if (mem->type == CL_MEM_IMAGE_TYPE) {
+    if (!(*ptr = cl_mem_map_gtt_unsync(mem))) {
+      err = CL_MAP_FAILURE;
+      goto error;
+    }
+  } else {
+    if (!(*ptr = cl_mem_map(mem))) {
+      err = CL_MAP_FAILURE;
+      goto error;
+    }
   }
   *ptr = (char*)(*ptr) + offset + sub_offset;
   if(mem->flags & CL_MEM_USE_HOST_PTR) {
--
1.8.3.2

_______________________________________________
Beignet mailing list
Beignet at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list