cancel
Showing results for 
Search instead for 
Did you mean: 

OpenCL

Journeyman III
Journeyman III

output stream offset + preprocessor directives

Hi everybody,

 

I would have two questions in regards to preprocessor and output stream. I had some program in C, and I wanted to rewrite it to brook+.  I'm not sure if I am doing it properly, so : this my part of code in C:

void fun (int width, int height, short* in, short* o) {
 
  for(int y = 1; y < height-1; y ++) {
   for(int x = 1; x < width-1; x ++) {
   int pi = (x + y * width) * 3;
     o[pi + 0] = 10;
     o[pi + 1] = 20;
     o[pi + 2] = 30;

... }



My first question: how could I make this ( for ex. o[pi + 2] = 10; ) access in brook+. I've tried something like this: My kernel:

kernel
void fund(  int width,  int height, float input[], out float output<>
 int2 index = instance().xy;

int pi = (index.y + index.x * width) * 3;
   
  output+=( ( float )pi + 0)+10;
  output+=( ( float )pi + 1)+20;
  output+=( ( float )pi + 2)+30;

...}

I'm not sure if is it correct ??

The second question is about preprocessor: I would like to for ex. use

#define FX(xo, yo) in[(y + yo)*width + (x + xo)]

void fun (int width, int height, short* in, short* o) {..} i

n my code but I'm still getting error: "Problem with call expression in kernel: callee unknown"

Thank you for your answers in advice,

mpwm

 

void fun (int width, int height, short* in, short* o) { for(int y = 1; y < height-1; y ++) { for(int x = 1; x < width-1; x ++) { int pi = (x + y * width) * 3; o[pi + 0] = 10; o[pi + 1] = 20; o[pi + 2] = 30; ... }

0 Kudos
Reply
1 Reply
Adept I
Adept I

output stream offset + preprocessor directives

To use pre-processor you need to pass -pp flag to brcc.

If you are wrting to multiple places in output within a kernel, you have to use scatter streams. You code would look somethin like this-

kernel void fund( int width, int height, float input[], out float output<> { int2 index = instance().xy; int pi = (index.x + index.y * width) * 3; // <---Note a change here instance().x gives the column value of the output output[pi]=10.0f; output[pi+1]=20.0f; output[pi+2]=30.0f; ...}

0 Kudos
Reply