Forum Discussion
Altera_Forum
Honored Contributor
15 years agoWell have scrubbed out all function references in the code I am accelerating. Now, getting a new error which occurs when Quartus tried to compile the C2H-generated VHDL file (C2H compiler runs successfully):
error (10465): vhdl error at accelerator_dtwserver_dtw_calcvectorcost_mxn_c2h.vhd(20040): name "i0" cannot be used because it is already used for a previously declared item file: This is the function that I trying to optimise:
int DTW_calcVectorCost_mxn_C2H(int **x, int xsize, int **y, int ysize, int nSize, int **Dist, int **globdist, int **move, int **temp, int **warp)
{
/* DESCRIPTION */
/* Compute a distance matrix on 2 multi-parameter vectors
and perform dynamic time warping on the distance matrix */
int top, mid, bot, cheapest, total;
int I, X, Y, n, i, j, k, cost;
int params = nSize;
/*Compute distance matrix*/
for(i=0;i<xsize;i++) {
for(j=0;j<ysize;j++) {
total = 0;
for (k=0;k<params;k++) {
total = total + ((x - y) * (x - y));
}
Dist = total;
}
}
/*% for first frame, only possible match is at (0,0)*/
globdist = Dist;
for (j=1; j<xsize; j++)
globdist = VERY_BIG_C2H;
globdist = VERY_BIG_C2H;
globdist = globdist + Dist;
move = 2;
for(j=2;j<xsize;j++)
globdist = VERY_BIG_C2H;
for(i=2;i<ysize;i++) {
globdist = VERY_BIG_C2H;
globdist = globdist + Dist;
for(j=2;j<xsize;j++) {
top = globdist + Dist + Dist;
mid = globdist + Dist;
bot = globdist + Dist + Dist;
if( (top < mid) && (top < bot))
{
cheapest = top;
I = 1;
}
elseif (mid < bot)
{
cheapest = mid;
I = 2;
}
else {cheapest = bot;
I = 3;
}
/*if all costs are equal, pick middle path*/
if( ( top == mid) && (mid == bot))
I = 2;
globdist = cheapest;
move = I;
}
}
X = ysize-1; Y = xsize-1; n=0;
warp = X; warp = Y;
while (X > 0 && Y > 0) {
n=n+1;
if (n>ysize *2)
{
return VERY_BIG_C2H; // Return default cost (large) if failed.
// exit(1);
}
if (move == 1 )
{
warp = X-1; warp = Y;
n=n+1;
X=X-2; Y = Y-1;
}
elseif (move == 2)
{
X=X-1; Y = Y-1;
}
elseif (move == 3 )
{
warp = X;
warp = Y-1;
n=n+1;
X=X-1; Y = Y-2;
}
else
{
return VERY_BIG_C2H; // Return default cost (large) if failed.
}
warp =X;
warp =Y;
}
/*flip warp*/
for (i=0;i<=n;i++) {
temp = warp;
temp = warp;
}
for (i=0;i<=n;i++) {
warp = temp;
warp = temp;
}
// Cast 'globdist' as int 'cost' (to be returned)
cost = globdist;
return cost;
}