[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39924] branches/cycles/intern/cycles: Cycles: use workgroup size from opencl, attempt to fix issue with apple opencl.

Brecht Van Lommel brechtvanlommel at pandora.be
Mon Sep 5 14:24:29 CEST 2011


Revision: 39924
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39924
Author:   blendix
Date:     2011-09-05 12:24:28 +0000 (Mon, 05 Sep 2011)
Log Message:
-----------
Cycles: use workgroup size from opencl, attempt to fix issue with apple opencl.

Modified Paths:
--------------
    branches/cycles/intern/cycles/device/device_opencl.cpp
    branches/cycles/intern/cycles/util/util_math.h

Modified: branches/cycles/intern/cycles/device/device_opencl.cpp
===================================================================
--- branches/cycles/intern/cycles/device/device_opencl.cpp	2011-09-05 08:23:01 UTC (rev 39923)
+++ branches/cycles/intern/cycles/device/device_opencl.cpp	2011-09-05 12:24:28 UTC (rev 39924)
@@ -26,6 +26,7 @@
 #include "device_intern.h"
 
 #include "util_map.h"
+#include "util_math.h"
 #include "util_opencl.h"
 #include "util_opengl.h"
 #include "util_path.h"
@@ -412,7 +413,14 @@
 
 		opencl_assert(ciErr);
 
-		size_t local_size[2] = {8, 8};
+		size_t workgroup_size;
+
+		clGetKernelWorkGroupInfo(ckPathTraceKernel, cdDevice,
+			CL_KERNEL_WORK_GROUP_SIZE, sizeof(size_t), &workgroup_size, NULL);
+	
+		workgroup_size = max(sqrt((double)workgroup_size), 1.0);
+
+		size_t local_size[2] = {workgroup_size, workgroup_size};
 		size_t global_size[2] = {global_size_round_up(local_size[0], d_w), global_size_round_up(local_size[1], d_h)};
 
 		/* run kernel */
@@ -480,7 +488,14 @@
 
 		opencl_assert(ciErr);
 
-		size_t local_size[2] = {8, 8};
+		size_t workgroup_size;
+
+		clGetKernelWorkGroupInfo(ckFilmConvertKernel, cdDevice,
+			CL_KERNEL_WORK_GROUP_SIZE, sizeof(size_t), &workgroup_size, NULL);
+	
+		workgroup_size = max(sqrt((double)workgroup_size), 1.0);
+
+		size_t local_size[2] = {workgroup_size, workgroup_size};
 		size_t global_size[2] = {global_size_round_up(local_size[0], d_w), global_size_round_up(local_size[1], d_h)};
 
 		/* run kernel */

Modified: branches/cycles/intern/cycles/util/util_math.h
===================================================================
--- branches/cycles/intern/cycles/util/util_math.h	2011-09-05 08:23:01 UTC (rev 39923)
+++ branches/cycles/intern/cycles/util/util_math.h	2011-09-05 12:24:28 UTC (rev 39924)
@@ -101,6 +101,16 @@
 	return (a < b)? a: b;
 }
 
+__device_inline double max(double a, double b)
+{
+	return (a > b)? a: b;
+}
+
+__device_inline double min(double a, double b)
+{
+	return (a < b)? a: b;
+}
+
 #endif
 
 __device_inline float min4(float a, float b, float c, float d)




More information about the Bf-blender-cvs mailing list