Re: numerous kernel panics when using OpenCL inside FCPX
Re: numerous kernel panics when using OpenCL inside FCPX
- Subject: Re: numerous kernel panics when using OpenCL inside FCPX
- From: Garrick Meeker <email@hidden>
- Date: Fri, 26 Apr 2013 11:47:52 -0700
Some drivers do have bugs. The AMD driver in 10.6, in particular, may not be worth supporting. It doesn't support OpenCL images (requiring buffers only) and while we did work around that, we found the OpenCL/OpenGL interop so buggy that we disabled FxPlug hardware rendering for these cards/OS (instead transferring from host memory to the card). AMD 6xxx cards in 10.7 had issues (something I found with local memory) but an update seemed to fix that.
However, you might be writing out of bounds to images or buffers, and very bad things can happen. Perhaps the first way to check this is to use the CPU device, call clEnqueueMapBuffer/clEnqueueMapImage on all buffers to print out the address, and see if you get a segfault (and compare that against your known buffer addresses).
If that's not feasible, one other solution is to add manual bounds checking to all of your kernels. Consider this following code. You can add "-D BOUNDS_CHECK" to the compile options, add optional parameters to your host code (passing the additional int4 buffer and buffer sizes), add CHECK_ARG() and CHECK_ARRAY_ARG(a) to function arguments, and CHECK_ARRAY_DECL() for any private arrays. Then call CHECK_A() for array access and read_imagef_BOUNDS/write_imagef_BOUNDS for image access. Then you can turn this on and off (even at runtime).
BTW, I'm about to open source a OpenCL logging utility that might interest you. It won't detect buffer overwrites (and kernel panics won't leave any log), but it's useful to track down errors on the host side like event handling.
#ifndef STRCAT
#define STRCAT(a,b) a ## b
#endif
#ifdef BOUNDS_CHECK
int _CHECK_A(int i, int s, int line, __global int4 *bounds_log) { if ((i < 0) || i >= s) { bounds_log[0] = (int4)(1, i, 0, line); bounds_log[1] = (int4)(s, 0, 0, 0); i = max(0, min(s-1, i)); } return i; }
int2 _CHECK_BOUNDS(image2d_t i, int2 s, int2 p, bool v, int line, __global int4 *bounds_log) { if (v && any((p < (int2)(0)) || p >= s)) { bounds_log[0] = (int4)(1, p.x, p.y, line); bounds_log[1] = (int4)(s.x, s.y, 0, 0); p = max((int2)(0), min(s-(int2)(1), p)); } return p; }
#define CHECK_ARG() __global int4 *bounds_log,
#define CHECK_ARRAY_DECL(a) const int STRCAT(a,Size)
#define CHECK_ARRAY_ARG(a) a, int STRCAT(a,Size)
#define CHECK_A(i, s) _CHECK_A((int)(i), (int)(s), __LINE__, bounds_log)
#define CHECK_BOUNDS(i, p, v) _CHECK_BOUNDS(i, get_image_dim(i), p, v, __LINE__, bounds_log)
#else
#define CHECK_ARG()
#define CHECK_ARRAY_ARG(a) a
#define CHECK_A(i, s) (i)
#define CHECK_BOUNDS(i, p, v) (p)
#endif
#ifndef CLK_ADDRESS_MASK
#if defined(__CL_VERSION_1_1__) && (__OPENCL_VERSION__ >= __CL_VERSION_1_1__)
#define CLK_ADDRESS_MASK (CLK_ADDRESS_NONE | CLK_ADDRESS_CLAMP | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_ADDRESS_REPEAT | CLK_ADDRESS_MIRRORED_REPEAT)
#else
#define CLK_ADDRESS_MASK (CLK_ADDRESS_NONE | CLK_ADDRESS_CLAMP | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_ADDRESS_REPEAT)
#endif
#endif
#define read_imagef_BOUNDS(i,s,p) read_imagef(i,s,CHECK_BOUNDS(i,p,(s&CLK_ADDRESS_MASK)==CLK_ADDRESS_NONE))
#define write_imagef_BOUNDS(i,p,v) write_imagef(i,CHECK_BOUNDS(i,p,true),v)
On Apr 25, 2013, at 2:34 PM, Paul Miller <email@hidden> wrote:
> Everything is working in my test code and in other hosts, but in FCPX when I attempt to run some OCL code on *D1* clips I get a repeatable kernel panic and have to restart the machine.
>
> Works fine on *HD* clips in FCPX. Works fine in Motion.
>
> Has anyone else run into this situation?
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Pro-apps-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Pro-apps-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden