PDA

View Full Version : How to reduce kernel overhead



fakruddeen
10-26-2012, 01:18 AM
Hello, I am new to OpenCL. right now i am trying to convert my c code into opencl. In this connection, I have function named as some 'x', in that function i have if-else loop.

function x()
{
if()
{
for()
{
update1();
}
for()
{
update2();
}
}
else
{
for()
{
update1();
}
for()
{
update2();
}
}
}
in 'if' loop i have two 'for' loops, for the first 'for' loop i want to make a kernel function. for this i need to create an opencl environment in my host code. For this i created host code, now i want to make one more kernel for 'else' part 1st 'for' loop.
Note:: two 'for' loops (1st from 'if' loop (1st 'for' loop), 2nd from 'else' loop(1st 'for' loop)), both are calling same function (update1()). but the 'for' loops computation is different. so i need two kernels.
Now my question is, do i need to create two times opencl environment or one time?
if it is one time then how to cal kernel function after entering into 'if' loop and 'else' loop?

Thanks in advance.