I am working on a project where I use the GPU for some heavy number crunching with OpenCL which has to go on for multiple frames. If I do the most efficient thing and schedule all of the work at once, it will end up flooding the device and it won't manage to render the GUI and swap buffers at VBLANK. The most sensible solution for this problem I see is splitting the OpenCL tasks into chunks that will leave some time during a single frame for rendering etc., but how much time a given amount of work will take is very nonlinear and dependent on the device, so I guess I would have to do some nontrivial profiling at startup or during runtime to determine that.
Does anyone have suggestions of how this could be better solved? Is there perhaps some way to tell the driver that the OpenCL tasks have a lower priority than the OpenGL ones?