cancel
Showing results for 
Search instead for 
Did you mean: 

OpenCL

Journeyman III
Journeyman III

Kernel function problem

Gaurav,

I wonder, what is advantage of using cpu emulator? I understand that instructions are executed on cpu. And what...? Anyway I can not to enter kernel and debugging inside.

0 Kudos
Reply
Adept I
Adept I

Kernel function problem

The purpose of CPU backend code is for debugging only. You can debug inside kernel if you disable line generation in cpp file (use -nl option)

0 Kudos
Reply
Journeyman III
Journeyman III

Kernel function problem

Gaurav,

BRT_RUNTIME = cal

mkdir brookgenfiles | "$(BROOKROOT)\sdk\bin\brcc_d.exe" -p cal -o "$(ProjectDir)\brookgenfiles\$(InputName)" "$(InputPath)"

Ouput is broken yet. Why?

0 Kudos
Reply
Adept I
Adept I

Kernel function problem

That is strange. Are you sure it works without -p cal option? I mean how did you test it with template error? Could you post the test case?

0 Kudos
Reply
Journeyman III
Journeyman III

Kernel function problem

I just use the simple test in this case.

 

kernel void motion_estimation(unsigned char src[],
                              unsigned char ref[],
                              int width,
                              int height,
                              out double sad<>,
                              out int mvx<>,
                              out int mvy<>
{
    // Output position
    int2 vPos = instance().xy;
   
    int i = vPos.x; // width
    int j = vPos.y; // height
   
    int ix = i * 16;
    int jy = j * 16;

   sad = 2.0;

}

 

That's it. So, no templates. With -p cal option output sad contains garbage. With -p cpu everything is ok (2.0 value).

 

0 Kudos
Reply
Adept I
Adept I

Kernel function problem

Something is going wrong. It seems you are running your code under CPU backend. Make sure you close your visual studo or command prompt after changing environment variable and then open it again to read the updated env variable.

0 Kudos
Reply
Journeyman III
Journeyman III

Kernel function problem

You are right. I tried to restart VS, but it did not help.

The windows restart helps.

0 Kudos
Reply
Journeyman III
Journeyman III

Kernel function problem

if ((sad >= testsad) && (mvlength > abs(y) + abs(x)))
{
         sad = testsad;
         mvlength = abs(y) + abs(x);
         mvy = y;
         mvx = x;
}

ERROR--1: In Binary expression: Mismatched operands: both must have same type and same number of components
1> Statement: sad >= testsad && mvlength > abs(y) + abs(x) in sad >= testsad && mvlength > abs(y) + abs(x)
1> Expression : sad >= testsad, Type : double
1> Expression : mvlength > abs(y) + abs(x), Type : int

 

Try to do this : if (((int)sad >= (int)testsad) && (mvlength > abs(y) + abs(x))) and this condition never is true.

 

 

 

 

0 Kudos
Reply
Adept I
Adept I

Kernel function problem

brcc returns the same type from conditional expressions as of operands. You can try this-

if ((int)(sad >= testsad) && (mvlength > abs(y) + abs(x)))

0 Kudos
Reply
Journeyman III
Journeyman III

Kernel function problem

No, I suppose your variant is incorrect. I have checked.

The correct:

if (((int)sad >= (int)testsad) && (mvlength > abs(y) + abs(x)))

I just figured out it.

 

 

0 Kudos
Reply