Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
20 years ago

Some questions about C2H

When I used C2H to accelerate my code,I met some problems.

I chose a fuction to accelerate,but the report told me that:"The code does not contain any loop...".But it has 6 loops.

I don't know what's wrong.Please help me.Thank you!

-------------------------------------My code below-------------------------------------------

void HistogramEql(alt_16 nWidth, alt_16 nHeight, alt_u8 *lpInput, alt_u8 *lpOutput)

{

alt_16 x, y;

# define Point1(x, y) lpInput[(x) + (y) * nWidth]

# define Point(x, y) lpOutput[(x) + (y) * nWidth]

alt_16 r[256], s[256];

alt_16 i;

i=0;

do{

r=s=0;

i++;

}while(i<256);

for (y = 0; y < nHeight; y++)

{

for (x = 0; x < nWidth; x++)

{

r[Point1(x, y)]++;

}

}

s[0] = r[0];

for (y = 1; y < 256; y++)

{

s[y] = s[y - 1];

s[y] += r[y];

}

for (y = 0; y < nHeight; y++)

{

for (x = 0; x < nWidth; x++)

{

Point(x, y) = s[Point1(x, y)] * 255 / nWidth / nHeight;

}

}

}

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Did you try without using the# define Point(...) macro&#39;s, and use the formulas directly. Maybe the C2H compiler is not intelligent enough??

    Does the code works in software mode??
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Try to remove any ALTERA NIOS specific HAL use and also ignore# define statement.

    Because C2H only accelerate the function which is purely C/C++ and used only their library. They will never work with NIOS HAL function and etc..

    Best Regards,

    slsnios