mpwm

output stream offset + preprocessor directives

Discussion created by mpwm on Nov 22, 2009
Latest reply on Nov 22, 2009 by gaurav.garg

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; ... }

Outcomes