Another possibility which occurs to me, on newer hardware, is to try out
the BPRP instruction. This also addresses Gil's thought about not fetching
the cache line containing SUM unless it is necessary. Remember this assumes
that CURRENT is almost always a zero, per the OP.
*
* SET UP BRANCH PREDICTION ON JZ
* INSTRUCTION TO NOADD LABEL
BPRP 8,JZ,NOADD PREDICT BRANCH IS TAKEN
LT R0,CURRENT
JZ JZ NOADD
ADD R0,SUM
ST R0,SUM
NOADD DS 0H
On Mon, Feb 17, 2014 at 10:02 AM, Charles Mills <[email protected]> wrote:
> Nice!
>
> I got to thinking it would be nice to have a "store different" instruction
> (or make store behave this way automatically under the covers) which would
> invalidate the cache only if what it were storing were different from what
> was in memory already.
>
> Charles
>
> -----Original Message-----
> From: IBM Mainframe Discussion List [mailto:[email protected]] On
> Behalf Of John McKown
> Sent: Monday, February 17, 2014 6:37 AM
> To: [email protected]
> Subject: Re: Branch (was: Performance question - adding)
>
> Combining the thoughts engendered from about three replies, I wonder if
> avoiding a branch as follows (on a processor which supports the
> instructions) would perform better than branching.
>
> LT R0,CURRENT #LOAD CURRENT AND SET CC
> SPM R1 #SAVE CC FROM LT
> A R0,SUM #ADD SUM TO IT
> IPM R1 #RESTORE CC FROM LT
> STOC R0,SUM,NZ #STORE SUM ONLY IF CC OF LT WAS NZ
>
> Basically this loads CURRENT into R0, setting the CC based on its value.
> Then saves the CC in R1. Adds the SUM value into R0. Restores the CC from
> the LT, because the Add destroyed it. Then only stores the result in SUM if
> the CC is "Not Zero", as set by the LT. I don't know if this code avoid the
> "cache thrashing" mention by Ed. I don't know if the CPU needs to "lock"
> the cache line if the STOC is a NOP due to the CC being zero (from the LT)
>
> ----------------------------------------------------------------------
> For IBM-MAIN subscribe / signoff / archive access instructions,
> send email to [email protected] with the message: INFO IBM-MAIN
>
--
Wasn't there something about a PASCAL programmer knowing the value of
everything and the Wirth of nothing?
Maranatha! <><
John McKown
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN