Skip to content

Commit

Permalink
jit.gradient reentrancy fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Timothy Place committed Dec 15, 2015
1 parent 90c9e4a commit 4a8aa4d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions source/matrix/jit.gradient/jit.gradient.c
Expand Up @@ -117,17 +117,14 @@ t_jit_err jit_gradient_matrix_calc(t_jit_gradient *x, void *inputs, void *output
//recursive functions to handle higher dimension matrices, by processing 2D sections at a time
//

static double table[32768]; //temporarily made global to compile. -jkc
//should allocate this some other way...not currently reentrant

// jit_gradient_calculate_ndim() -- when x->dimmode==-1, sorts both dimensions together
void jit_gradient_calculate_ndim(t_jit_gradient *x, long dimcount, long *dim, long planecount,
t_jit_matrix_info *out_minfo, char *bop)
{
long i,j,width,height, index;
long start[4], end[4], chebycount;
float indperc;
double cheby[64]/*, table[32768]*/;
double cheby[64], *table=NULL;
float Tn, Tn1, Tn2, v,d;
float wmax, xmax=0.0;
uchar *op;
Expand Down Expand Up @@ -156,7 +153,8 @@ void jit_gradient_calculate_ndim(t_jit_gradient *x, long dimcount, long *dim, lo

width = dim[0];
height = dim[1];

table = (double *)sysmem_newptr(width*sizeof(double));

// compute the transfer function using the chebyshev equation...
d=(float)(width/2-.5);
for(i=0; i<width; i++) {
Expand Down Expand Up @@ -221,13 +219,16 @@ void jit_gradient_calculate_ndim(t_jit_gradient *x, long dimcount, long *dim, lo
}
}
}
if (table)
sysmem_freeptr((void *)table);
break;
default:
for (i=0; i<dim[dimcount-1]; i++) {
op = bop + i*out_minfo->dimstride[dimcount-1];
jit_gradient_calculate_ndim(x,dimcount-1,dim,planecount,out_minfo,op);
}
}

}


Expand Down

0 comments on commit 4a8aa4d

Please sign in to comment.