Forums > Jitter

[Efficiency] optimized jit.unpack, other stuff ?

August 10, 2008 | 12:20 am

Hi,

i’m discovering jitter more deeply since few months, and i’m (like many, i thinks?) always looking for efficiency… And, on my 2,2Ghz MBP, working on 1200*700 4 planes matrixes, i noticed that :

- sending it to some objects like jit.coerce, taking only few microseconds, is very efficient.

- copying it to an other jit.matrix of the same size takes 1 millisecond.

- sending it to [jit.unpack] takes 10 milliseconds…

…And i found that expensive for just unpacking a matrix so i started to compare efficiency of some differents jitter objects… then i found a more efficent way to do the same thing than jit.unpack, using 4 jit.rgb2luma !! (a little bit more efficient if you need all the four planes, but really more efficient if you only need some) (and as each [jit.rgb2luma ...] operate on four planes, i’m sure that there must be a furthermore efficient way to unpack a 4 plane matrix…)

You can see my test patcher down here.

Does anybody have any other interresting topics or test-patchers relating to "efficiency comparisons" of jitter objects ?

Thanks,

Alexandre

– Pasted Max Patch, click to expand. –

August 10, 2008 | 4:54 pm

Salut Alex,

Under 4.6.3/1.6.3
[jit.unpack] takes less than 7 seconds and unpacking with [jit.expr] is better (less than 6).
Your [rgb2luma] unpacking technic is really faster.

max v2;
#N vpatcher 1 149 1196 674;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 899 355 50 196617 5930;
#P comment 949 356 100 196617 ms;
#P message 609 366 50 196617 2218;
#P comment 659 367 100 196617 ms;
#P message 407 370 50 196617 83;
#P comment 457 371 100 196617 ms;
#P comment 288 343 100 196617 ms;
#P comment 93 322 100 196617 ms;
#P message 240 343 50 196617 6788;
#P message 56 378 50 196617 5930;
#P newex 56 357 62 196617 prepend set;
#P newex 44 163 34 196617 s img;
#P newex 44 134 105 196617 prepend importmovie;
#P message 44 113 53 196617 bball.mov;
#P comment 254 320 62 196617 p jit.unpack;
#P window linecount 3;
#P comment 375 322 129 196617 p jit.unpack.really.more.efficient.only.for.the.first.plane;
#P window linecount 1;
#P comment 869 337 210 196617 p jit.unpack.using.jit.expr.not.efficient.at.all;
#P newex 405 199 34 196617 r img;
#P user jit.pwindow 406 266 28 24 0 1 0 0 1 0;
#P newex 395 243 86 196617 jit.coerce 1 char;
#P newex 395 222 138 196617 jit.matrix 4 char 1200 700;
#P newex 412 171 37 196617 s stop;
#P button 395 89 15 0;
#P newex 447 130 26 196617 s go;
#P newex 395 109 30 196617 t b b;
#P newex 395 148 44 196617 uzi 100;
#P newex 876 279 251 196617 jit.expr 1 char 1200 700 @expr in[0].p[1] @inputs 1;
#P newex 868 259 251 196617 jit.expr 1 char 1200 700 @expr in[0].p[3] @inputs 1;
#P newex 860 239 251 196617 jit.expr 1 char 1200 700 @expr in[0].p[2] @inputs 1;
#P newex 862 175 34 196617 r img;
#P user jit.pwindow 927 306 28 24 0 1 0 0 1 0;
#P user jit.pwindow 898 306 28 24 0 1 0 0 1 0;
#P user jit.pwindow 869 306 28 24 0 1 0 0 1 0;
#P user jit.pwindow 840 306 28 24 0 1 0 0 1 0;
#P newex 852 219 251 196617 jit.expr 1 char 1200 700 @expr in[0].p[0] @inputs 1;
#P newex 852 198 138 196617 jit.matrix 4 char 1200 700;
#P newex 869 147 37 196617 s stop;
#P button 852 65 15 0;
#P newex 904 106 26 196617 s go;
#P newex 852 85 30 196617 t b b;
#P newex 852 124 44 196617 uzi 100;
#P newex 565 276 270 196617 jit.rgb2luma @ascale 0. @rscale 0. @gscale 0. @bscale 1.;
#P newex 557 256 270 196617 jit.rgb2luma @ascale 0. @rscale 0. @gscale 1. @bscale 0.;
#P newex 549 236 270 196617 jit.rgb2luma @ascale 0. @rscale 1. @gscale 0. @bscale 0.;
#P newex 551 172 34 196617 r img;
#P user jit.pwindow 616 303 28 24 0 1 0 0 1 0;
#P user jit.pwindow 587 303 28 24 0 1 0 0 1 0;
#P user jit.pwindow 558 303 28 24 0 1 0 0 1 0;
#P user jit.pwindow 529 303 28 24 0 1 0 0 1 0;
#P newex 541 216 270 196617 jit.rgb2luma @ascale 1. @rscale 0. @gscale 0. @bscale 0.;
#P newex 541 195 138 196617 jit.matrix 4 char 1200 700;
#P newex 558 144 37 196617 s stop;
#P button 541 62 15 0;
#P newex 593 103 26 196617 s go;
#P newex 541 82 30 196617 t b b;
#P newex 541 121 44 196617 uzi 100;
#P newex 244 195 34 196617 r img;
#P user jit.pwindow 293 264 28 24 0 1 0 0 1 0;
#P user jit.pwindow 264 264 28 24 0 1 0 0 1 0;
#P user jit.pwindow 235 264 28 24 0 1 0 0 1 0;
#P user jit.pwindow 206 264 28 24 0 1 0 0 1 0;
#P newex 234 239 66 196617 jit.unpack;
#P newex 234 218 138 196617 jit.matrix 4 char 1200 700;
#P newex 251 167 37 196617 s stop;
#P button 234 85 15 0;
#P newex 286 126 26 196617 s go;
#P newex 234 105 30 196617 t b b;
#P newex 234 144 44 196617 uzi 100;
#P window linecount 5;
#P message 782 400 306 196617 ; max launchbrowser http://www.cycling74.com/forums/index.php?t=msg&th=35083&start=0&rid=3975&S=ea34c6e7dbcfb20ad6a03003f68b3742;
#P number 46 319 47 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 46 293 27 196617 – 0.;
#P newex 79 238 26 196617 r go;
#P newex 28 238 37 196617 r stop;
#P newex 79 261 48 196617 cpuclock;
#P newex 28 261 48 196617 cpuclock;
#P comment 106 379 100 196617 ms;
#P comment 571 340 129 196617 p jit.unpack.more.efficient;
#P connect 4 0 2 0;
#P connect 63 0 64 0;
#P connect 64 0 65 0;
#P connect 2 0 6 0;
#P connect 6 0 7 0;
#P connect 7 0 66 0;
#P connect 66 0 67 0;
#P connect 3 0 6 1;
#P connect 5 0 3 0;
#P connect 15 0 16 0;
#P connect 12 0 10 0;
#P connect 10 0 9 0;
#P connect 20 0 14 0;
#P connect 9 0 14 0;
#P connect 14 0 15 0;
#P connect 15 1 17 0;
#P connect 9 1 13 0;
#P connect 15 2 18 0;
#P fasten 10 1 11 0 259 124 291 124;
#P connect 15 3 19 0;
#P connect 54 0 52 0;
#P connect 52 0 51 0;
#P connect 51 0 56 0;
#P connect 59 0 56 0;
#P connect 56 0 57 0;
#P connect 57 0 58 0;
#P connect 51 1 55 0;
#P fasten 52 1 53 0 420 128 452 128;
#P connect 27 0 28 0;
#P connect 24 0 22 0;
#P connect 22 0 21 0;
#P connect 21 0 26 0;
#P connect 32 0 26 0;
#P connect 26 0 27 0;
#P connect 21 1 25 0;
#P connect 33 0 29 0;
#P connect 34 0 30 0;
#P fasten 22 1 23 0 566 101 598 101;
#P connect 35 0 31 0;
#P connect 42 0 43 0;
#P connect 39 0 37 0;
#P connect 37 0 36 0;
#P connect 47 0 41 0;
#P connect 36 0 41 0;
#P connect 41 0 42 0;
#P connect 36 1 40 0;
#P connect 48 0 44 0;
#P connect 49 0 45 0;
#P fasten 37 1 38 0 877 104 909 104;
#P connect 50 0 46 0;
#P pop;


August 10, 2008 | 5:08 pm

jit.unpack is best avoided if possible because it has to deinterleave
data and pack it into separate memory blocks. You can use shaders to
do per-channel manipulations in a much more efficient manner if what
you’re trying to accomplish lends itself to slab chains.
wes

On Sun, Aug 10, 2008 at 9:54 AM, Derrick Giscloux
wrote:
>
> Salut Alex,
>
> Under 4.6.3/1.6.3
> [jit.unpack] takes less than 7 seconds and unpacking with [jit.expr] is better (less than 6).
> Your [rgb2luma] unpacking technic is really faster.
>
>
> max v2;
> #N vpatcher 1 149 1196 674;
> #P window setfont "Sans Serif" 9.;
> #P window linecount 1;
> #P message 899 355 50 196617 5930;
> #P comment 949 356 100 196617 ms;
> #P message 609 366 50 196617 2218;
> #P comment 659 367 100 196617 ms;
> #P message 407 370 50 196617 83;
> #P comment 457 371 100 196617 ms;
> #P comment 288 343 100 196617 ms;
> #P comment 93 322 100 196617 ms;
> #P message 240 343 50 196617 6788;
> #P message 56 378 50 196617 5930;
> #P newex 56 357 62 196617 prepend set;
> #P newex 44 163 34 196617 s img;
> #P newex 44 134 105 196617 prepend importmovie;
> #P message 44 113 53 196617 bball.mov;
> #P comment 254 320 62 196617 p jit.unpack;
> #P window linecount 3;
> #P comment 375 322 129 196617 p jit.unpack.really.more.efficient.only.for.the.first.plane;
> #P window linecount 1;
> #P comment 869 337 210 196617 p jit.unpack.using.jit.expr.not.efficient.at.all;
> #P newex 405 199 34 196617 r img;
> #P user jit.pwindow 406 266 28 24 0 1 0 0 1 0;
> #P newex 395 243 86 196617 jit.coerce 1 char;
> #P newex 395 222 138 196617 jit.matrix 4 char 1200 700;
> #P newex 412 171 37 196617 s stop;
> #P button 395 89 15 0;
> #P newex 447 130 26 196617 s go;
> #P newex 395 109 30 196617 t b b;
> #P newex 395 148 44 196617 uzi 100;
> #P newex 876 279 251 196617 jit.expr 1 char 1200 700 @expr in[0].p[1] @inputs 1;
> #P newex 868 259 251 196617 jit.expr 1 char 1200 700 @expr in[0].p[3] @inputs 1;
> #P newex 860 239 251 196617 jit.expr 1 char 1200 700 @expr in[0].p[2] @inputs 1;
> #P newex 862 175 34 196617 r img;
> #P user jit.pwindow 927 306 28 24 0 1 0 0 1 0;
> #P user jit.pwindow 898 306 28 24 0 1 0 0 1 0;
> #P user jit.pwindow 869 306 28 24 0 1 0 0 1 0;
> #P user jit.pwindow 840 306 28 24 0 1 0 0 1 0;
> #P newex 852 219 251 196617 jit.expr 1 char 1200 700 @expr in[0].p[0] @inputs 1;
> #P newex 852 198 138 196617 jit.matrix 4 char 1200 700;
> #P newex 869 147 37 196617 s stop;
> #P button 852 65 15 0;
> #P newex 904 106 26 196617 s go;
> #P newex 852 85 30 196617 t b b;
> #P newex 852 124 44 196617 uzi 100;
> #P newex 565 276 270 196617 jit.rgb2luma @ascale 0. @rscale 0. @gscale 0. @bscale 1.;
> #P newex 557 256 270 196617 jit.rgb2luma @ascale 0. @rscale 0. @gscale 1. @bscale 0.;
> #P newex 549 236 270 196617 jit.rgb2luma @ascale 0. @rscale 1. @gscale 0. @bscale 0.;
> #P newex 551 172 34 196617 r img;
> #P user jit.pwindow 616 303 28 24 0 1 0 0 1 0;
> #P user jit.pwindow 587 303 28 24 0 1 0 0 1 0;
> #P user jit.pwindow 558 303 28 24 0 1 0 0 1 0;
> #P user jit.pwindow 529 303 28 24 0 1 0 0 1 0;
> #P newex 541 216 270 196617 jit.rgb2luma @ascale 1. @rscale 0. @gscale 0. @bscale 0.;
> #P newex 541 195 138 196617 jit.matrix 4 char 1200 700;
> #P newex 558 144 37 196617 s stop;
> #P button 541 62 15 0;
> #P newex 593 103 26 196617 s go;
> #P newex 541 82 30 196617 t b b;
> #P newex 541 121 44 196617 uzi 100;
> #P newex 244 195 34 196617 r img;
> #P user jit.pwindow 293 264 28 24 0 1 0 0 1 0;
> #P user jit.pwindow 264 264 28 24 0 1 0 0 1 0;
> #P user jit.pwindow 235 264 28 24 0 1 0 0 1 0;
> #P user jit.pwindow 206 264 28 24 0 1 0 0 1 0;
> #P newex 234 239 66 196617 jit.unpack;
> #P newex 234 218 138 196617 jit.matrix 4 char 1200 700;
> #P newex 251 167 37 196617 s stop;
> #P button 234 85 15 0;
> #P newex 286 126 26 196617 s go;
> #P newex 234 105 30 196617 t b b;
> #P newex 234 144 44 196617 uzi 100;
> #P window linecount 5;
> #P message 782 400 306 196617 ; max launchbrowser http://www.cycling74.com/forums/index.php?t=msg&th=35083&start=0&rid=3975&S=ea34c6e7dbcfb20ad6a03003f68b3742;
> #P number 46 319 47 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P window linecount 1;
> #P newex 46 293 27 196617 – 0.;
> #P newex 79 238 26 196617 r go;
> #P newex 28 238 37 196617 r stop;
> #P newex 79 261 48 196617 cpuclock;
> #P newex 28 261 48 196617 cpuclock;
> #P comment 106 379 100 196617 ms;
> #P comment 571 340 129 196617 p jit.unpack.more.efficient;
> #P connect 4 0 2 0;
> #P connect 63 0 64 0;
> #P connect 64 0 65 0;
> #P connect 2 0 6 0;
> #P connect 6 0 7 0;
> #P connect 7 0 66 0;
> #P connect 66 0 67 0;
> #P connect 3 0 6 1;
> #P connect 5 0 3 0;
> #P connect 15 0 16 0;
> #P connect 12 0 10 0;
> #P connect 10 0 9 0;
> #P connect 20 0 14 0;
> #P connect 9 0 14 0;
> #P connect 14 0 15 0;
> #P connect 15 1 17 0;
> #P connect 9 1 13 0;
> #P connect 15 2 18 0;
> #P fasten 10 1 11 0 259 124 291 124;
> #P connect 15 3 19 0;
> #P connect 54 0 52 0;
> #P connect 52 0 51 0;
> #P connect 51 0 56 0;
> #P connect 59 0 56 0;
> #P connect 56 0 57 0;
> #P connect 57 0 58 0;
> #P connect 51 1 55 0;
> #P fasten 52 1 53 0 420 128 452 128;
> #P connect 27 0 28 0;
> #P connect 24 0 22 0;
> #P connect 22 0 21 0;
> #P connect 21 0 26 0;
> #P connect 32 0 26 0;
> #P connect 26 0 27 0;
> #P connect 21 1 25 0;
> #P connect 33 0 29 0;
> #P connect 34 0 30 0;
> #P fasten 22 1 23 0 566 101 598 101;
> #P connect 35 0 31 0;
> #P connect 42 0 43 0;
> #P connect 39 0 37 0;
> #P connect 37 0 36 0;
> #P connect 47 0 41 0;
> #P connect 36 0 41 0;
> #P connect 41 0 42 0;
> #P connect 36 1 40 0;
> #P connect 48 0 44 0;
> #P connect 49 0 45 0;
> #P fasten 37 1 38 0 877 104 909 104;
> #P connect 50 0 46 0;
> #P pop;
>
>
>


August 10, 2008 | 9:43 pm

> You can use shaders to do per-channel manipulations
> in a much more efficient manner if what you’re trying
> to accomplish lends itself to slab chains.

Well, i’m not really sure to understand, this sentence sounds a bit mysterous to me. Hard for me to see how to "use shaders to do per-channel manipulations".. What do you mean by "slab chains" ? Any exemple welcome..


August 10, 2008 | 10:40 pm

Here’s what I’m talking about. If it doesn’t make sense, read the
tutorials on shaders and slabs.
wes

– Pasted Max Patch, click to expand. –

August 11, 2008 | 4:08 pm

Thanks!

Well, this make some sence. I was able to test the efficiency of the rendering of the green screen, and it’s looking like we might make a furthermore efficient [optimized.jit.unpack], using this stuff… But it’s true that i didn’t really read the tutorial about shaders and slab right now, and i’m unable to transform this into an [optimized.jit.unpack] right now.. Specially i’m not sure if openGL can "render" a 1 plane matrix, plus i get some GL error that i’m unable to understand right now.. I’ll look at it later when i have time.

Regards,
Alexandre


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