From 59e2e32b7fce3e00408486a8ba56f2a0bfc62455 Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Fri, 6 Aug 2010 01:17:50 -0400
Subject: [PATCH] Fix Mandelbrot example for AMD. (patch by Ren Lifeng)

---
 examples/demo_mandelbrot.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/examples/demo_mandelbrot.py b/examples/demo_mandelbrot.py
index 45fd74e5..4919dbb0 100644
--- a/examples/demo_mandelbrot.py
+++ b/examples/demo_mandelbrot.py
@@ -41,6 +41,7 @@ def calc_fractal_opencl(q, maxiter):
     output_opencl = cl.Buffer(ctx, mf.WRITE_ONLY, output.nbytes)
 
     prg = cl.Program(ctx, """
+    #pragma OPENCL EXTENSION cl_khr_byte_addressable_store : enable
     __kernel void mandelbrot(__global float2 *q,
                      __global ushort *output, ushort const maxiter)
     {
@@ -51,11 +52,11 @@ def calc_fractal_opencl(q, maxiter):
         output[gid] = 0;
 
         for(int curiter = 0; curiter < maxiter; curiter++) {
-            nreal = real*real - imag*imag + q[gid][0];
-            imag = 2* real*imag + q[gid][1];
+            nreal = real*real - imag*imag + q[gid].x;
+            imag = 2* real*imag + q[gid].y;
             real = nreal;
 
-            if (real*real + imag*imag > 4.)
+            if (real*real + imag*imag > 4.0f)
                  output[gid] = curiter;
         }
     }
-- 
GitLab