Post Reply 
Optimizing performance with loop unrolling
05-04-2021, 02:08 PM
Post: #1
Optimizing performance with loop unrolling
A few months ago, I bought a Surveying Pac for my 97. (Because I'm a sucker - I don't know anything about surveying that isn't in the HP 25 Applications Programs book!) One of the included cards was hand-labeled in pencil: "WEIGHTED AVE GRAVE - Will take 43 sets (ft)(oz) no more".

Yesterday I got my printer working, so I was curious to print out the listing from this card and see what was on it. It has some rather interesting loop-unrolling techniques. But I bet with some effort, I could optimize the program, and shorten it by at least a dozen steps. Wink

Program Listing
Visit this user's website Find all posts by this user
Quote this message in a reply
05-04-2021, 02:30 PM
Post: #2
RE: Optimizing performance with loop unrolling
(05-04-2021 02:08 PM)Dave Britten Wrote:  A few months ago, I bought a Surveying Pac for my 97. (Because I'm a sucker - I don't know anything about surveying that isn't in the HP 25 Applications Programs book!) One of the included cards was hand-labeled in pencil: "WEIGHTED AVE GRAVE - Will take 43 sets (ft)(oz) no more".

Yesterday I got my printer working, so I was curious to print out the listing from this card and see what was on it. It has some rather interesting loop-unrolling techniques. But I bet with some effort, I could optimize the program, and shorten it by at least a dozen steps. Wink

Program Listing

Doesn't unrolling a loop take more steps?

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
05-04-2021, 03:11 PM
Post: #3
RE: Optimizing performance with loop unrolling
(05-04-2021 02:30 PM)toml_12953 Wrote:  Doesn't unrolling a loop take more steps?

Yes, and this program looks like it was unrolled to the point where there's literally no loop left! It's a bit hard to read but it looks like the same five lines repeated over and over?
Visit this user's website Find all posts by this user
Quote this message in a reply
05-04-2021, 03:45 PM
Post: #4
RE: Optimizing performance with loop unrolling
(05-04-2021 03:11 PM)Thomas Okken Wrote:  
(05-04-2021 02:30 PM)toml_12953 Wrote:  Doesn't unrolling a loop take more steps?

Yes, and this program looks like it was unrolled to the point where there's literally no loop left! It's a bit hard to read but it looks like the same five lines repeated over and over?

That was my immediate assessment of it too. It's basically the same 5 steps repeated for almost 220 steps, plus a LBL B to calculate the results. I found the "Will take 43 sets (ft)(oz) no more" note rather humorous, considering you could rewrite the whole program in about 20 steps and eliminate that limitation at the same time. Smile
Visit this user's website Find all posts by this user
Quote this message in a reply
05-04-2021, 04:27 PM
Post: #5
RE: Optimizing performance with loop unrolling
The only advantage to unrolling a loop is saved time for looking up GTO targets but that can't amount to much here as the program is very short and constantly interrupted for user inputs anyway.
Find all posts by this user
Quote this message in a reply
05-04-2021, 06:50 PM
Post: #6
RE: Optimizing performance with loop unrolling
I wonder if someone took a program for say, a mini-computer, and slavishly copied it to the 41: optimizations that made sense on the original platform and all.
Find all posts by this user
Quote this message in a reply
05-04-2021, 06:55 PM
Post: #7
RE: Optimizing performance with loop unrolling
(05-04-2021 04:27 PM)Siegfried Wrote:  The only advantage to unrolling a loop is saved time for looking up GTO targets but that can't amount to much here as the program is very short and constantly interrupted for user inputs anyway.

Yeah, that is the crux of the joke. Wink

Whoever wrote this program apparently knew just enough about HP 67 programming to have both LBL A and LBL B for two different functions, but didn't know that those 5 steps could be repeated indefinitely with a simple GTO.

I wonder if this person ever adapted the program for the greatly expanded memory of the 41!
Visit this user's website Find all posts by this user
Quote this message in a reply
05-04-2021, 07:52 PM
Post: #8
RE: Optimizing performance with loop unrolling
The horror! The HORROR!!

I wonder how many data pairs one could write into Prime PPL program, using the same technique? Most likely, ones fingers would bleed before you ran out of program steps...

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
05-04-2021, 07:54 PM
Post: #9
RE: Optimizing performance with loop unrolling
(05-04-2021 07:52 PM)rprosperi Wrote:  The horror! The HORROR!!

I wonder how many data pairs one could write into Prime PPL program, using the same technique? Most likely, ones fingers would bleed before you ran out of program steps...

Well the beauty of it is you could just use repeated applications of copy/paste to double your code at each step! Work smarter, not harder!
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)