41CL TURBO anomaly? - Printable Version +- HP Forums (https://archived.hpcalc.org/museumforum) +-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html) +--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html) +--- Thread: 41CL TURBO anomaly? (/thread-221400.html) |
41CL TURBO anomaly? - M. Joury - 05-14-2012 I was playing around with the SANDMATH ROM on my V2 hardware 41CL and came across an interesting anomaly. I was timing the INCX function to see how it compared to a two line 1 + in FOCAL
LBL INC-TST and got the following numbers when running for 10 seconds:
Turbo mode FOCAL 1+ INCX Speed gain I was surprised by these results. In fact I would have expected the speed advantage to increase with the INCX function as TURBO went up since I would have expected MCODE to have a greater advantage over FOCAL at higher turbo speeds. I do realize that the majority of the execution time is spent outside the actual code that adds 1 or increments X but I would still have expected the INCX approach to be faster than the 1 + FOCAL at all turbo speeds. What am I missing? Cheers, -Marwan
Edited: 14 May 2012, 11:34 a.m.
Re: 41CL TURBO anomaly? - Monte Dalrymple - 05-14-2012 It is only really meaningful to compare the results between different Turbo modes for the same code. The reason for this is that the automatic switch back to 1x (for display access, checking the keyboard, etc.) interferes with fast execution. Re: 41CL TURBO anomaly? - Ángel Martin - 05-14-2012 Well, for what it´s worth- the four almost-trivial functions INCX, DECX, INCY, and DECY - are not in the latest SandMath release, the SandMath-IV... the LBL B code has a lot going on in FOCAL, so my guess is that the INCX MCODE effect has little impact in the global picture.
Cheers, Re: 41CL TURBO anomaly? - M. Joury - 05-14-2012 Hi Monte, Thanks for the explanation. Very informative and it clarifies things for me. This following table appears to confirm what you wrote. This is a set of timings for the same basic routines modified to do 5 "1 +" combinations or 5 INCX instructions within the body of the loop. As can be seen in the table, the performance improvement is greater at the lower turbo speeds but falls off faster and ends up slightly lower at 50X.
Turbo mode FOCAL 1+ (x5) INCX (x5) Speed gain Cheers,
-Marwan
Re: 41CL TURBO anomaly? - M. Joury - 05-14-2012 Quote: Yes, that is true. I acknowledged that in my original post. But even taking that into consideration, and taking into account that the code in both routines is identical except for "1 +" vs. "INCX" one would expect the LBL B code to be faster at all TURBO settings. Monte's reply explains why this is not the case. By the way, why did you choose to remove INCX, DECX, INCY, DECY from the SandMath library? I have not taken a look at the latest version (I don't actually know where to find it) so I am assuming that it was to make room for other, deemed more useful, routines? Cheers,
-Marwan
Re: 41CL TURBO anomaly? - Ángel Martin - 05-15-2012
Quote: I had to make room for some code and a couple of FAT entries, so I thought these were not adding much value to the Module given their simple nature. I replaced them with:
LGMN - Logarithm Multi-Factorial
Quote: Same place where you got the current version.
Cheers, Re: 41CL TURBO anomaly? - M. Joury - 05-15-2012 Hi Ángel, Thank you for your response. I guess I still have the old docs. I'll grab the latest shortly. Do you know which version went into the 41CL V3? I have not installed my V3 board yet. While I have yet to find a need for INCY and DECY I suspect that these fall into those cases where when you do need them you *really* would like to have them since incrementing Y without using ISG (which may not be possible--there is a way around this problem) takes a fair amount of stack manipulation.
X<>Y And either approach ends with you pushing T off the top of the stack. The other approach would be to use ISG followed by a NO-OP to deal with the potential skip. This would preserve the stack:
ISG Y Using X<>X as a NO-OP. This would probably be the approach I would use. At any rate I understand your reasoning. I am just trying to get into MCODE programming and am thinking about building a small utility library with these sorts of functions. You already have most of the ones I want but also many that I would not include since the idea is not to build a "higher math" library but a simple utility library. This is something that I am just starting to play with since I have never done any MCODE on a 41. Cheers,
-Marwan
Re: 41CL TURBO anomaly? - Ángel Martin - 05-15-2012 Hi again, DECX/Y and INCX/Y can always be replaced with ISG X/Y and DSE X/Y followed by a NOP,(like "F0", text-0 string). Yes it's a little slower and takes one more byte but it removes the dependency with the module, and FAT entries are a a premium. Hope you get into MCODE soon, it's a lot of fun. A routine library is perhaps the best way to start... as a matter of fact I'm almost ready to release my Library#4 project, which is exactly about that.
Cheers,
Re: 41CL TURBO anomaly? - M. Joury - 05-15-2012 Hi Ángel, I just used X<>X in my example because it was easier than messing with a synthetic instruction. But yes, "F0" would better. Actually if you are skipping on every ISG instruction (I have yet to test where you don't skip) the break even point is between TURBO 10X and TURBO 20X (see the table below) as we are seeing the same thing as we did for INCX in my earlier posts. I'll add timings for NOT skipping shortly just for completeness.
Iterations per 10 seconds: Thanks for your responses! -Marwan
|