Forums > Jitter

Problems with speed of patch using Expr and Matrix

August 1, 2007 | 3:14 pm

Okay, I’ve looked at my patch again and it is not the ‘virtual sand’ that I orignally thought was the problem.

[img]index.php?t=getfile&id=777&private=0[/img]

I have 20 or so formula’s in a java external. They are selected using values, n and m in inlet 2 and 3 – no processing at all. The selected formula is passed out of the outlet into jit.expr. As the formula is be passed into jit.expr it starts a bang, where a new matrix is also passed into jit.expr. If I scroll through the values n/m I get lots of slow down! I’m sure it has something to do with creating a new matrix for each expr! Though I dont know a better approach? Any ideas?

Thanks.


August 1, 2007 | 3:24 pm

It’s not creating a new matrix that’s the problem, it’s more than
likely the speed of jit.expr’s evaluation. It’s not a fast object by
its very nature, especially if you have decently sized exressions. If
you have a fixed number of expressions, I would recommend building an
optimized pipeline for each and switching between those. If you’re
using JAVA than this is fairly easy to do because you can make a
function for each expression and switch between them based on a
parameter.

wes

On 8/1/07, Carl Knott wrote:
> Okay, I’ve looked at my patch again and it is not the ‘virtual sand’ that I orignally thought was the problem.
>
> [img]index.php?t=getfile&id=777&private=0[/img]
>
> I have 20 or so formula’s in a java external. They are selected using values, n and m in inlet 2 and 3 – no processing at all. The selected formula is passed out of the outlet into jit.expr. As the formula is be passed into jit.expr it starts a bang, where a new matrix is also passed into jit.expr. If I scroll through the values n/m I get lots of slow down! I’m sure it has something to do with creating a new matrix for each expr! Though I dont know a better approach? Any ideas?
>
> Thanks.
>
>
>
>
>
>


August 1, 2007 | 3:28 pm


August 1, 2007 | 3:52 pm

Okay I see. Though I’m not entirely sure what you mean by an optimized pipeline. Do you have a reference? Btw, just for clarification, this is one of my formulas.

(-0.034886*pow(norm[0]\,6)-0.087331*pow(norm[0]\,5)+0.58852*pow(norm[0]\,4)-0.024326*pow(norm[0]\,3)-1.4418*pow(norm[0]\,2)-0.00025598*norm[0]+1)*sin(norm[0]*2)*cos(0*PI*snorm[1])

jeanfrancois.charles, ahh yes, I solved that one with a delay.

Quote: wesley.hoke@gmail.com wrote on Wed, 01 August 2007 09:24
—————————————————-
> It’s not creating a new matrix that’s the problem, it’s more than
> likely the speed of jit.expr’s evaluation. It’s not a fast object by
> its very nature, especially if you have decently sized exressions. If
> you have a fixed number of expressions, I would recommend building an
> optimized pipeline for each and switching between those. If you’re
> using JAVA than this is fairly easy to do because you can make a
> function for each expression and switch between them based on a
> parameter.
>
> wes
>
> On 8/1/07, Carl Knott wrote:
> > Okay, I’ve looked at my patch again and it is not the ‘virtual sand’ that I orignally thought was the problem.
> >
> > [img]index.php?t=getfile&id=777&private=0[/img]
> >
> > I have 20 or so formula’s in a java external. They are selected using values, n and m in inlet 2 and 3 – no processing at all. The selected formula is passed out of the outlet into jit.expr. As the formula is be passed into jit.expr it starts a bang, where a new matrix is also passed into jit.expr. If I scroll through the values n/m I get lots of slow down! I’m sure it has something to do with creating a new matrix for each expr! Though I dont know a better approach? Any ideas?
> >
> > Thanks.
> >
> >
> >
> >
> >
> >
>
—————————————————-


August 1, 2007 | 4:00 pm

yeah, that’s going to be slowwww (-er using expr and potentially
faster using jit.ops because of vector operations). BTW, your last
cos has 0*PI*snorm[1] which will always be 1.

wes

On 8/1/07, Carl Knott wrote:
>
> Okay I see. Though I’m not entirely sure what you mean by an optimized pipeline. Do you have a reference? Btw, just for clarification, this is one of my formulas.
>
> (-0.034886*pow(norm[0]\,6)-0.087331*pow(norm[0]\,5)+0.58852*pow(norm[0]\,4)-0.024326*pow(norm[0]\,3)-1.4418*pow(norm[0]\,2)-0.00025598*norm[0]+1)*sin(norm[0]*2)*cos(0*PI*snorm[1])
>
> jeanfrancois.charles, ahh yes, I solved that one with a delay.
>
> Quote: wesley.hoke@gmail.com wrote on Wed, 01 August 2007 09:24
> —————————————————-
> > It’s not creating a new matrix that’s the problem, it’s more than
> > likely the speed of jit.expr’s evaluation. It’s not a fast object by
> > its very nature, especially if you have decently sized exressions. If
> > you have a fixed number of expressions, I would recommend building an
> > optimized pipeline for each and switching between those. If you’re
> > using JAVA than this is fairly easy to do because you can make a
> > function for each expression and switch between them based on a
> > parameter.
> >
> > wes
> >
> > On 8/1/07, Carl Knott
wrote:
> > > Okay, I’ve looked at my patch again and it is not the ‘virtual sand’ that I orignally thought was the problem.
> > >
> > > [img]index.php?t=getfile&id=777&private=0[/img]
> > >
> > > I have 20 or so formula’s in a java external. They are selected using values, n and m in inlet 2 and 3 – no processing at all. The selected formula is passed out of the outlet into jit.expr. As the formula is be passed into jit.expr it starts a bang, where a new matrix is also passed into jit.expr. If I scroll through the values n/m I get lots of slow down! I’m sure it has something to do with creating a new matrix for each expr! Though I dont know a better approach? Any ideas?
> > >
> > > Thanks.
> > >
> > >
> > >
> > >
> > >
> > >
> >
> —————————————————-
>
>
>


August 1, 2007 | 4:17 pm

One thing that hasn’t been suggested is that you create one jit.expr
object for each expression you are going to use, and then a gate to
route the bang/matrix to the right one. This will save you a lot of
processing time as you aren’t having to evaluate the expression string
each time you switch. Jit.expr should be no different from using the
equivalent jit.op objects when working with float32 matrices (in theory).

Andrew B.


August 1, 2007 | 4:21 pm

Do you have an example of the optimized pipe line Wez? I dont know what you mean.


August 1, 2007 | 4:36 pm

by optimized pipe I mean a chain of jit.ops.

wes

On 8/1/07, andrew benson wrote:
> One thing that hasn’t been suggested is that you create one jit.expr
> object for each expression you are going to use, and then a gate to
> route the bang/matrix to the right one. This will save you a lot of
> processing time as you aren’t having to evaluate the expression string
> each time you switch. Jit.expr should be no different from using the
> equivalent jit.op objects when working with float32 matrices (in theory).
>
> Andrew B.
>


August 1, 2007 | 5:38 pm

"One thing that hasn’t been suggested is that you create one jit.expr
object for each expression you are going to use, and then a gate to
route the bang/matrix to the right one. This will save you a lot of
processing time as you aren’t having to evaluate the expression string
each time you switch. Jit.expr should be no different from using the
equivalent jit.op objects when working with float32 matrices (in theory).

Andrew B."

Ah, I was thinking among the same lines.. but set up an array of Matrix in Java, process it in the constructor, then return the correct matrix through the outlet.


August 1, 2007 | 6:53 pm

For people who have a similar problem in the future, I solved it by writing this algorithm…

JitterObject myexpr = new JitterObject("jit.expr");
boolean result;
for(int i=0; i
for(int j=1; j
jm[i][j] = new JitterMatrix(1, "float32",256, 256);
out[i][j] = new JitterMatrix(1, "float32",256, 256);
myexpr.send("expr", CircleMembraneFormula[i][j]);
result = myexpr.matrixcalc(jm[i][j],out[i][j]);
post("RESULT: " + result);
}
}

I put it into my constructor, it just takes an extra couple of seconds to load the patch :)

Quote: andrewb@cycling74.com wrote on Wed, 01 August 2007 10:17
—————————————————-
> One thing that hasn’t been suggested is that you create one jit.expr
> object for each expression you are going to use, and then a gate to
> route the bang/matrix to the right one. This will save you a lot of
> processing time as you aren’t having to evaluate the expression string
> each time you switch. Jit.expr should be no different from using the
> equivalent jit.op objects when working with float32 matrices (in theory).
>
> Andrew B.
>
—————————————————-


Viewing 10 posts - 1 through 10 (of 10 total)