Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo
I'm currently writing some image filters using Cloo and I've been having a weird issue. I've just been running a simple invert filter via the GPU and it works quite well on an Nvidia-based device (GTX 650).
Yet, on two separate and completely different AMD-based devices, I get the following error:
Cloo.InvalidHostPointerComputeException: OpenCL error code detected: InvalidHostPointer
at Cloo.ComputeException.ThrowOnError ….
The line of code that throws this exception is the declaration of ComputeBuffer b.
byte arrayA = new byte[size];
byte arrayB = new byte[size];
//Copy from imageData to arrayA
Marshal.Copy((imageData.Scan0 + (int)(n * size)), arrayA, 0, (int)size);
ComputeBuffer<byte> a = new ComputeBuffer<byte>(context, ComputeMemoryFlags.ReadOnly | ComputeMemoryFlags.CopyHostPointer,arrayA);
ComputeBuffer<byte> b = new ComputeBuffer<byte>(context, ComputeMemoryFlags.WriteOnly,arrayB);
What's even more interesting is that this error happens in both Windows and Linux
(one AMD-device is my home computer , using a Radeon 5870, the other is a laptop running Linux with a Radeon 6310)
The OpenCL code is as follows:
string InvertFunction = @"
__kernel void InvertColour(
__global read_only unsigned char *a,
__global write_only unsigned char *b)
int i = get_global_id(0);
b[i] = 255 - a[i];
At this point, I'm not sure why it's having issues pointing to the other array. I've tried playing with the ComputeMemoryFlags types with no success.
I'm still very new to OpenCL programming and Cloo in general, so I'm hoping it's just a silly mistake or something I've overlooked.
Thank you for reading my post. :)