Hello everyone! I’m currently a student at Edinboro University of PA working on a senior project. I’m trying to draw a mandelbrot fractal using openCL. It works on the first zoom, however on the second zoom, or just not doing anything after the first and the display driver breaks. I have the newest nvidia drivers for my card (8800 gts).
Here is my kernel code. I’m fairly certain it’s not my c code causing the issue. Am I using too much memory? I must be overwriting some memory somewhere.
const char* CreateImageSource[] = {
"__kernel void CreateImage(__global float* image, __global float* fractalProperties, __global unsigned int* fpOperations)",
"{",
"unsigned int n = get_global_id(0);",
"int iterations = 0;",
"float realC = fractalProperties[0] + (n % 800) * fractalProperties[4];", //2
"float imaginaryC = fractalProperties[2] + (int)(n / 800) * fractalProperties[5];", // 2
"float realA = 0;",
"float imaginaryA = 0;",
"float magnitude = sqrt(pow(realC, 2) + pow(imaginaryC, 2));", //5
"float hue = 0;",
"float value = .556789;",
"float saturation = 1;",
"float red = 0;",
"float green = 0;",
"float blue = 0;",
"int i = 0;",
"float f = 0;",
"float p = 0;",
"float q = 0;",
"float t = 0;",
"fpOperations[n] = 0;", // 9 up to this point
"while(magnitude > fractalProperties[7] && magnitude < fractalProperties[8] && iterations < fractalProperties[6])", // 3
"{",
"float tempRealA = (realA * realA) - (imaginaryA * imaginaryA);", // 3
"imaginaryA = (realA * imaginaryA) + (imaginaryA * realA);", // 3
"realA = tempRealA + realC;", // 1
"imaginaryA = imaginaryA + imaginaryC;", // 1
"magnitude = sqrt(pow(realA, 2) + pow(imaginaryA, 2));", // 3
"iterations = iterations + 1;",
"fpOperations += 14;",
"}",
"if(iterations < 20 || (int)(iterations / fractalProperties[6]) == 1)",
"{",
"image[n*3] = 0.0;",
"image[n*3+1] = 0.0;",
"image[n*3+2] = 0.0;",
"}",
"else",
"{",
"hue = 360 * ((float)iterations / (float)fractalProperties[6]);", // 2
"hue = hue / (float)60;", // 1
"i = (int)floor(hue);", // 1
"f = hue - i;", // 1
"p = value * ( 1 - saturation );", // 2
"q = value * ( 1 - saturation * f );", // 3
"t = value * ( 1 - saturation * ( 1 - f ) );", //4
"switch( i )",
"{",
"case 0:",
"{",
"red = value;",
"green = t;",
"blue = p;",
"break;",
"}",
"case 1:",
"{",
"red = q;",
"green = value;",
"blue = p;",
"break;",
"}",
"case 2:",
"{",
"red = p;",
"green = value;",
"blue = t;",
"break;",
"}",
"case 3:",
"{",
"red = p;",
"green = q;",
"blue = value;",
"break;",
"}",
"case 4:",
"{",
"red = t;",
"green = p;",
"blue = value;",
"break;",
"}",
"default:",
"{",
"red = value;",
"green = p;",
"blue = q;",
"break;",
"}",
"}",
"image[n*3] = red;",
"image[n*3+1] = green;",
"image[n*3+2] = blue;",
"}",
"}"
};
Image is a float[8008003], fractalProperties is float[9], and fpOperations is size float[800*800].