AntoineSfx Posted January 31, 2018 Share Posted January 31, 2018 (edited) Input is a line, I'm trying to set a different pscale attribute on the first and last point. In PointWrangle (Run over Points), I have this: f@pscale=chf("scl") ; float scale=chf("scl"); printf("begin %f\n",scale); printf("numpt=%d\n", @numpt); printf("ptnum=%d\n", @ptnum); if (@ptnum==0 || @ptnum== @numpt-1) f@pscale=chf("scl") ; else f@pscale=1 ; output: (twice the same thing) begin 0.101000 numpt=10 ptnum=0 ptnum=1 ptnum=2 ptnum=3 ptnum=4 ptnum=5 ptnum=6 ptnum=7 ptnum=8 ptnum=9 begin 0.101000 numpt=10 ptnum=0 ptnum=1 ptnum=2 ptnum=3 ptnum=4 ptnum=5 ptnum=6 ptnum=7 ptnum=8 ptnum=9 Is the compiler parallelizing portion of codes which refer to points attributes ? Edited January 31, 2018 by AntoineSfx Quote Link to comment Share on other sites More sharing options...
Atom Posted January 31, 2018 Share Posted January 31, 2018 I would construct the setup like this. In your IF statement it seems like you are "ORING zero with @ptnum. Use parenthesis to keep logic clear. Quote Link to comment Share on other sites More sharing options...
AntoineSfx Posted January 31, 2018 Author Share Posted January 31, 2018 54 minutes ago, Atom said: I would construct the setup like this. In your IF statement it seems like you are "ORING zero with @ptnum. Use parenthesis to keep logic clear. Operators precedence is such that non contrived expressions don't require additional parenthesis.. Unless you want to assign the result of a comparison or something. It's built-in in the BNF. However it doesn't explain why I have that behavior on the original code. Quote Link to comment Share on other sites More sharing options...
Noobini Posted January 31, 2018 Share Posted January 31, 2018 (edited) 50 minutes ago, AntoineSfx said: Operators precedence is such that non contrived expressions don't require additional parenthesis.. Unless you want to assign the result of a comparison or something. It's built-in in the BNF. However it doesn't explain why I have that behavior on the original code. I found that if you drag the slider on your Scl param, it prints it twice.......but if you type in a number, press Enter...it does it ONCE as expected (same as using the value ladder...prints it twice) Edited January 31, 2018 by Noobini Quote Link to comment Share on other sites More sharing options...
AntoineSfx Posted January 31, 2018 Author Share Posted January 31, 2018 3 minutes ago, Noobini said: I found that if you drag the slider on your Scl param, it prints it twice.......but if you type in a number, press Enter...it does it ONCE as expected (same as using the value ladder...prints it twice) the real question is, why does printf("numpt=%d\n", @numpt); seems to be outside of the points loop, while printf("ptnum=%d\n", @ptnum); seems to be be inside the points loop. I assume some optimization is made on the program, but I can't find exactly what. I know that vcc (or should I say the VM running its output) runs several threads, but it's unclear what happens to the VEX I wrote in that box. Quote Link to comment Share on other sites More sharing options...
acey195 Posted February 1, 2018 Share Posted February 1, 2018 both are in the points loop, but if the thing printed is exactly the same (and the calculation/memory needed is exactly the same) it will only do the print once, as VEX optimizes these things. Quote Link to comment Share on other sites More sharing options...
f1480187 Posted February 1, 2018 Share Posted February 1, 2018 (edited) Point wrangle: do a; do b; do c; do a: on point 0 on point 1 on point 2 do b: on point 0 on point 1 on point 2 do c: on point 0 on point 1 on point 2 Detail wrangle point loop: for (int i = 0; i < @numpt; i++) { do a; do b; do c; } on point 0: do a do b do c on point 1: do a do b do c on point 2: do a do b do c Since the scale and @numpt are uniform vars, print instruction was executed once and cached. @ptnum is varying and printf executed every time. It's an old issue with debugging VEX wrangles using printf(). Edited February 1, 2018 by f1480187 Quote Link to comment Share on other sites More sharing options...
acey195 Posted February 1, 2018 Share Posted February 1, 2018 I would say its a feature :P... whenever I use printf() without having a condition like: if(@ptnum == 0){printf("stuff");} I kinda want to punch myself because of the millions of prints it wants to do.. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.