[gegl] choose iteration region based on device's max allocation size



commit 3a258034e57e8e90fa1eaa8139c8a1cdde82b070
Author: Victor Oliveira <victormatheus gmail com>
Date:   Tue Feb 28 00:14:28 2012 -0300

    choose iteration region based on device's max allocation size

 gegl/opencl/gegl-cl-init.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/gegl/opencl/gegl-cl-init.c b/gegl/opencl/gegl-cl-init.c
index 10ca78d..83bce1f 100644
--- a/gegl/opencl/gegl-cl-init.c
+++ b/gegl/opencl/gegl-cl-init.c
@@ -220,18 +220,26 @@ gegl_cl_init (GError **error)
       gegl_clGetDeviceInfo(cl_state.device, CL_DEVICE_NAME, sizeof(cl_state.device_name), cl_state.device_name, NULL);
 
       gegl_clGetDeviceInfo (cl_state.device, CL_DEVICE_IMAGE_SUPPORT,      sizeof(cl_bool),  &cl_state.image_support,    NULL);
-      gegl_clGetDeviceInfo (cl_state.device, CL_DEVICE_IMAGE2D_MAX_HEIGHT, sizeof(size_t),   &cl_state.max_image_height, NULL);
-      gegl_clGetDeviceInfo (cl_state.device, CL_DEVICE_IMAGE2D_MAX_WIDTH,  sizeof(size_t),   &cl_state.max_image_width,  NULL);
       gegl_clGetDeviceInfo (cl_state.device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof(cl_ulong), &cl_state.max_mem_alloc,    NULL);
 
-      cl_state.max_image_width  = MIN(4096, MIN(cl_state.max_image_width, cl_state.max_image_height));
-      cl_state.max_image_height = MIN(4096, MIN(cl_state.max_image_width, cl_state.max_image_height));
+      cl_state.max_image_width  = 4096;
+      cl_state.max_image_height = 4096;
 
       g_printf("[OpenCL] Platform Name:%s\n",       cl_state.platform_name);
       g_printf("[OpenCL] Version:%s\n",             cl_state.platform_version);
       g_printf("[OpenCL] Extensions:%s\n",          cl_state.platform_ext);
       g_printf("[OpenCL] Default Device Name:%s\n", cl_state.device_name);
-      g_printf("[OpenCL] Tile Dimensions: (%d, %d)\n", cl_state.max_image_width, cl_state.max_image_height);
+      g_printf("[OpenCL] Max Alloc: %lu bytes\n",   cl_state.max_mem_alloc);
+
+      while (cl_state.max_image_width * cl_state.max_image_height * 16 > cl_state.max_mem_alloc)
+        {
+          if (cl_state.max_image_height < cl_state.max_image_width)
+            cl_state.max_image_width  /= 2;
+          else
+            cl_state.max_image_height /= 2;
+        }
+
+      g_printf("[OpenCL] Iteration size: (%d, %d)\n", cl_state.max_image_width, cl_state.max_image_height);
 
       if (cl_state.image_support)
         {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]