Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

[FORTRAN] will persist for some time -- probably for at least the next decade. -- T. Cheatham


devel / comp.lang.forth / Re: Efficient CMOVE

SubjectAuthor
* ALLOT?dxforth
+* Re: ALLOT?Krishna Myneni
|`* Naming conventions and question mark (was: ALLOT?)Ruvim
| +- Re: Naming conventions and question markBrian Fox
| +- Re: Naming conventions and question mark (was: ALLOT?)Anton Ertl
| +* Name for: : xxx ( u -- a ) here swap allot ;Doug Hoffman
| |`* Re: Name for: : xxx ( u -- a ) here swap allot ;Ruvim
| | +- Re: Name for: : xxx ( u -- a ) here swap allot ;Doug Hoffman
| | `* Re: Name for: : xxx ( u -- a ) here swap allot ;Paul Rubin
| |  `* Naming conventions and greater-than sign (was: Name for: : xxx ( u --Ruvim
| |   +- Re: Naming conventions and greater-than sign (was: Name for: : xxx (dxforth
| |   +* Re: Naming conventions and greater-than sign (was: Name for: : xxx ( u -- a ) heAnton Ertl
| |   |+* Re: Naming conventions and greater-than signRuvim
| |   ||+* Re: Naming conventions and greater-than signAnton Ertl
| |   |||`* Etymology and behavior of "CMOVE>" (was: Naming conventions andRuvim
| |   ||| +* Re: Etymology and behavior of "CMOVE>" (was: Naming conventions and greater-thanAnton Ertl
| |   ||| |+* Efficient CMOVEAnton Ertl
| |   ||| ||+- Re: Efficient CMOVEdxforth
| |   ||| ||+* Re: Efficient CMOVEMarcel Hendrix
| |   ||| |||`* Re: Efficient CMOVEAnton Ertl
| |   ||| ||| `* Re: Efficient CMOVEdxforth
| |   ||| |||  `- Re: Efficient CMOVEAnton Ertl
| |   ||| ||+* Re: Efficient CMOVEdxforth
| |   ||| |||`* Re: Efficient CMOVEdxforth
| |   ||| ||| `* Re: Efficient CMOVEAnton Ertl
| |   ||| |||  `* Re: Efficient CMOVEdxforth
| |   ||| |||   `* Re: Efficient CMOVEAnton Ertl
| |   ||| |||    +* Re: Efficient CMOVEAnton Ertl
| |   ||| |||    |`- Re: Efficient CMOVEMarcel Hendrix
| |   ||| |||    `* Re: Efficient CMOVEdxforth
| |   ||| |||     `* Re: Efficient CMOVEAnton Ertl
| |   ||| |||      `* Re: Efficient CMOVEdxforth
| |   ||| |||       `* Re: Efficient CMOVEAnton Ertl
| |   ||| |||        +* Re: Efficient CMOVEP Falth
| |   ||| |||        |`- Re: Efficient CMOVEAnton Ertl
| |   ||| |||        `- Re: Efficient CMOVEdxforth
| |   ||| ||`- Re: Efficient CMOVEStephen Pelc
| |   ||| |`* Re: Etymology and behavior of "CMOVE>"Ruvim
| |   ||| | `- Re: Etymology and behavior of "CMOVE>"Anton Ertl
| |   ||| `- Re: Etymology and behavior of "CMOVE>" (was: Naming conventions anddxforth
| |   ||`* Re: Naming conventions and greater-than signS Jack
| |   || `- Re: Naming conventions and greater-than signRuvim
| |   |+* Re: Naming conventions and greater-than sign (was: Name for: : xxx (Bernd Linsel
| |   ||`* Re: Naming conventions and greater-than sign (was: Name for: : xxx ( u -- a ) heAnton Ertl
| |   || +- Re: Naming conventions and greater-than sign (was: Name for: : xxx (Bernd Linsel
| |   || +* Re: Naming conventions and greater-than sign (was: Name for: : xxx (dxforth
| |   || |`* Re: Naming conventions and greater-than sign (was: Name for: : xxx ( u -- a ) heAnton Ertl
| |   || | +- Re: Naming conventions and greater-than sign (was: Name for: : xxx ( u -- a ) heAnton Ertl
| |   || | `- Re: Naming conventions and greater-than sign (was: Name for: : xxx (dxforth
| |   || +- Re: Naming conventions and greater-than sign (was: Name for: : xxx (P Falth
| |   || `* Re: Naming conventions and greater-than sign (was: Name for: : xxx ( u -- a ) heStephen Pelc
| |   ||  `- Re: Naming conventions and greater-than sign (was: Name for: : xxx ( u -- a ) heAnton Ertl
| |   |+* Iterators, control flow, and structures (was: Naming conventions andRuvim
| |   ||`* Re: Iterators, control flow, and structures (was: Naming conventions and greaterAnton Ertl
| |   || `- Re: Iterators, control flow, and structuresRuvim
| |   |`- Re: Naming conventions and greater-than sign (was: Name for: : xxx (Hugh Aguilar
| |   `* Re: Naming conventions and greater-than sign (was: Name for: : xxx (dxforth
| |    +- Re: Naming conventions and greater-than sign (was: Name for: : xxx (Bernd Linsel
| |    `* Re: Naming conventions and greater-than sign (was: Name for: : xxx (Ruvim
| |     `- Re: Naming conventions and greater-than sign (was: Name for: : xxx (dxforth
| +* Re: Naming conventions and question mark (was: ALLOT?)Krishna Myneni
| |+* Re: Naming conventions and question mark (was: ALLOT?)NN
| ||+- Re: Naming conventions and question mark (was: ALLOT?)P Falth
| ||`* Re: Naming conventions and question markPaul Rubin
| || +- Re: Naming conventions and question markdxforth
| || `- Re: Naming conventions and question markAnton Ertl
| |`- Re: Naming conventions and question mark (was: ALLOT?)dxforth
| `- Re: Naming conventions and question mark (was: ALLOT?)dxforth
`- Re: ALLOT?Hans Bezemer

Pages:123
Re: Efficient CMOVE

<sgqdpg$1jsg$1@gioia.aioe.org>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14451&group=comp.lang.forth#14451

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Efficient CMOVE
Date: Thu, 2 Sep 2021 21:50:08 +1000
Organization: Aioe.org NNTP Server
Message-ID: <sgqdpg$1jsg$1@gioia.aioe.org>
References: <sghpg8$1sh6$1@gioia.aioe.org> <sgiipl$bbc$1@dont-email.me>
<sgiouu$k89$1@dont-email.me> <612d0520$0$705$14726298@news.sunsite.dk>
<sgj7q8$t36$1@dont-email.me> <87mtoytul6.fsf@nightsong.com>
<sgjuci$7hb$1@dont-email.me> <2021Aug31.091034@mips.complang.tuwien.ac.at>
<sgl7dk$6q5$1@dont-email.me> <2021Aug31.181205@mips.complang.tuwien.ac.at>
<sgo4qk$ton$1@dont-email.me> <2021Sep1.175835@mips.complang.tuwien.ac.at>
<2021Sep1.233440@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="53136"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Thu, 2 Sep 2021 11:50 UTC

On 2/09/2021 07:34, Anton Ertl wrote:
>
> Eliminating the locals is left as an exercise to the puristic readers.

: propagate ( afrom ato u -- )
>r swap ( ato afrom) 2dup - r@ u< if \ overlapping case
tuck ( ato afrom) - r@ ( u) over + begin ( u1) >r
over ( afrom) dup 2 pick + 2 pick r@ over - min move
2* r> over r@ ( u) u< not
until r> 2drop 2drop
else \ the usual non-pattern case
r> ( ato afrom u) move
then ;

Re: Etymology and behavior of "CMOVE>"

<sgqhqk$i5h$1@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14454&group=comp.lang.forth#14454

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ruvim.pi...@gmail.com (Ruvim)
Newsgroups: comp.lang.forth
Subject: Re: Etymology and behavior of "CMOVE>"
Date: Thu, 2 Sep 2021 15:58:58 +0300
Organization: A noiseless patient Spider
Lines: 83
Message-ID: <sgqhqk$i5h$1@dont-email.me>
References: <sghpg8$1sh6$1@gioia.aioe.org> <sgiipl$bbc$1@dont-email.me>
<sgiouu$k89$1@dont-email.me> <612d0520$0$705$14726298@news.sunsite.dk>
<sgj7q8$t36$1@dont-email.me> <87mtoytul6.fsf@nightsong.com>
<sgjuci$7hb$1@dont-email.me> <2021Aug31.091034@mips.complang.tuwien.ac.at>
<sgl7dk$6q5$1@dont-email.me> <2021Aug31.181205@mips.complang.tuwien.ac.at>
<sgo4qk$ton$1@dont-email.me> <2021Sep1.175835@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 2 Sep 2021 12:59:00 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="d6e479f385a70476d510465f320c1374";
logging-data="18609"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+96RFssXpAsem3Mh15gl7s"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
Cancel-Lock: sha1:D83SeZk3hDrCtsQTqytkwwka9j8=
In-Reply-To: <2021Sep1.175835@mips.complang.tuwien.ac.at>
Content-Language: en-US
 by: Ruvim - Thu, 2 Sep 2021 12:58 UTC

On 2021-09-01 18:58, Anton Ertl wrote:
> Ruvim <ruvim.pinka@gmail.com> writes:
>> On 2021-08-31 19:12, Anton Ertl wrote:
>>> Ruvim <ruvim.pinka@gmail.com> writes:
>>>> On 2021-08-31 10:10, Anton Ertl wrote:
>>>>> Note the pronounciation: "c-move-up". It means: cmove the memory
>>>>> block from lower to higher addresses; i.e., the name describes the
>>>>> usage (what), not the how.
> ...
>> The wording "from lower to higher addresses" is almost the same as in
>> the specification of how "cmove" works: "proceeding
>> character-by-character from lower addresses to higher addresses"
>
> Yes, the difference is between "proceeding" and "move".
>
>> A problem with this etymology for "cmove>" is that it *can* be actually
>> used to copy a memory region to a lower address range as well as to a
>> higher address range.
>
> The name and its pronounciation reflects the intended use, not all
> possible uses.

A possible interpretation of "up" is "start coping from upper addresses"
Though, the specification use the word "higher" for that.

>> The only subtle moment when "up" plays any role, and "cmove>" can
>> produce the different (but expected) result than usual, is the case when
>> the target range is lower than the source range ("moving down") but
>> still has an intersection with the source range.
>
> Yes.
>
>> Concerning overspecifying, — I think some applications rely on this
>> specific behavior to fill a memory region by a pattern.
>
> It's an overspecification for the MOVE-like use. Of course, once you
> have an overspecification, it can allow other uses.
>
> OTOH, an underspecification like memcpy() in the C standard is even
> worse than an overspecification and has led to breakage and long
> discussions <https://bugzilla.redhat.com/show_bug.cgi?id=638477>
> <https://sourceware.org/bugzilla/show_bug.cgi?id=12518>. The way to
> go is a complete specification that can be implemented efficiently.
> Forth provides this with MOVE, and C with memmove(), making CMOVE,
> CMOVE> only useful for legacy code and the (not-recommended, see
> below) pattern case, and memcpy() useful only for legacy code.
>
>> Some examples of filling by a pattern are following.
>>
>> s" *******A-B-" 2dup 4 /string 3 pick swap cmove> type
>>
>> output: -B-A-B-A-B-
>>
>>
>> s" A-B-*******" 2dup 4 /string 3 pick -rot cmove type
>>
>> output: A-B-A-B-A-B
> ...
>> Probably, for big regions such memory propagation is more efficient than
>> call "MOVE" for a pattern in a loop.
>
> That's doubtful. This usage produces dependencies from the store of
> the second A to the load of it (5-6 cycles on modern CPUs), while
> using MOVE multiple times does not. If you want to reduce the loop
> and MOVE initialization overhead, first generate a longer pattern, and
> then call MOVE with longer patterns. Or use a doubling-at-each step
> strategy (or maybe quadrupling at each step); the latency described
> above will play a role in the first few iterations, for later
> iterations the throughput is the limit.

As you show in your tests, "cmove>" can be efficiently implemented in
the high level (comparing to a straightforward machine code).

OTOH, it seems "cmove>" is used quite rare.

Is there any sense to move "cmove>" (and maybe "cmove") to String
extension words?

--
Ruvim

Re: Naming conventions and greater-than sign (was: Name for: : xxx ( u -- a ) here swap allot ;)

<sgqkkf$v4a$1@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14457&group=comp.lang.forth#14457

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ruvim.pi...@gmail.com (Ruvim)
Newsgroups: comp.lang.forth
Subject: Re: Naming conventions and greater-than sign (was: Name for: : xxx (
u -- a ) here swap allot ;)
Date: Thu, 2 Sep 2021 16:46:52 +0300
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <sgqkkf$v4a$1@dont-email.me>
References: <sghpg8$1sh6$1@gioia.aioe.org> <sgiipl$bbc$1@dont-email.me>
<sgiouu$k89$1@dont-email.me> <612d0520$0$705$14726298@news.sunsite.dk>
<sgj7q8$t36$1@dont-email.me> <87mtoytul6.fsf@nightsong.com>
<sgjuci$7hb$1@dont-email.me> <sgl70d$l9l$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 2 Sep 2021 13:46:55 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="d6e479f385a70476d510465f320c1374";
logging-data="31882"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+KNtBCUAe59IZ9YNXxgx8w"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
Cancel-Lock: sha1:FzvyKoio2/9EZi+zQbmH3BbCHGo=
In-Reply-To: <sgl70d$l9l$1@gioia.aioe.org>
Content-Language: en-US
 by: Ruvim - Thu, 2 Sep 2021 13:46 UTC

On 2021-08-31 15:23, dxforth wrote:
> Here's a listing of the naming conventions published in 'Thinking
> Forth' and 'Forth Programmers Handbook':
>
> https://pastebin.com/qpZLFc6h
>
> As to the difference between:
>
>   !name     Store into name                           !DATA
>
>   name!     Store into name                           B!
>
> I was informed it likely stemmed from when forth names were stored
> as count-plus-three characters.

Neither standard word follows this convention concerning "!".
E.g.: "C!", "2!", "+!", "DEFER!", etc.

Though in usual practice, if you have the words "name" and "name!", the
latter one stores something into "name". Probably it's better to use
"!name" instead.

Concerning other old conventions — some of them are outdated, some of
them don't enough consistent.

In general, for new noninternal words it's better to avoid special
symbols except some most consistent and conventional variants.

--
Ruvim

Re: Etymology and behavior of "CMOVE>"

<2021Sep2.155441@mips.complang.tuwien.ac.at>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14458&group=comp.lang.forth#14458

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Etymology and behavior of "CMOVE>"
Date: Thu, 02 Sep 2021 13:54:41 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 35
Message-ID: <2021Sep2.155441@mips.complang.tuwien.ac.at>
References: <sghpg8$1sh6$1@gioia.aioe.org> <sgiipl$bbc$1@dont-email.me> <sgiouu$k89$1@dont-email.me> <612d0520$0$705$14726298@news.sunsite.dk> <sgj7q8$t36$1@dont-email.me> <87mtoytul6.fsf@nightsong.com> <sgjuci$7hb$1@dont-email.me> <2021Aug31.091034@mips.complang.tuwien.ac.at> <sgl7dk$6q5$1@dont-email.me> <2021Aug31.181205@mips.complang.tuwien.ac.at> <sgo4qk$ton$1@dont-email.me> <2021Sep1.175835@mips.complang.tuwien.ac.at> <sgqhqk$i5h$1@dont-email.me>
Injection-Info: reader02.eternal-september.org; posting-host="b8d65dc0511cc8ebe9ae0a45acf55f13";
logging-data="24397"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ZXNj6RkqOP4+ULAkwd5PR"
Cancel-Lock: sha1:thIKHvZAHTO9nmxUOChWVJ/umEA=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Thu, 2 Sep 2021 13:54 UTC

Ruvim <ruvim.pinka@gmail.com> writes:
>A possible interpretation of "up" is "start coping from upper addresses"

Whatever helps you to understand and use it correctly.

>As you show in your tests, "cmove>" can be efficiently implemented in
>the high level (comparing to a straightforward machine code).

Actually, my tests are about CMOVE, not CMOVE>, but I expect similar
results for CMOVE> (except that the orig CMOVE> does worse than the
orig CMOVE on implementations using REP MOVSB, so maybe the speedups
will be better).

>OTOH, it seems "cmove>" is used quite rare.
>
>Is there any sense to move "cmove>" (and maybe "cmove") to String
>extension words?

What would be the benefit? A system (which one?) that does not
implement CMOVE>/CMOVE could change the documentation. New system
implementors (who?) might feel less motivated to implement it. Forth
programmers might be more cautious about using it (although, given
that MOVE is in CORE and the others are in STRING, those who care
about such things probably go for MOVE already).

If these were new words, sure, put them into STRING EXT, but once they
are standardized, I see little benefit in moving them around (except
for moving obsolescent words out of CORE).

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: Efficient CMOVE

<sgqo10$1bg$1@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14459&group=comp.lang.forth#14459

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: step...@vfxforth.com (Stephen Pelc)
Newsgroups: comp.lang.forth
Subject: Re: Efficient CMOVE
Date: Thu, 2 Sep 2021 14:44:48 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 62
Message-ID: <sgqo10$1bg$1@dont-email.me>
References: <sghpg8$1sh6$1@gioia.aioe.org> <sgo4qk$ton$1@dont-email.me> <2021Sep1.175835@mips.complang.tuwien.ac.at> <2021Sep1.233440@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=fixed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 2 Sep 2021 14:44:48 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="8e3757f1cce000ea7670f6e882d7e27b";
logging-data="1392"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/8/WmYeQbA4+JhivDOqTZQ"
User-Agent: Usenapp/1.14.1/l for MacOS - Full License
Cancel-Lock: sha1:FBpd/F0N86qhBSoxQG9eZk4lDYQ=
 by: Stephen Pelc - Thu, 2 Sep 2021 14:44 UTC

On 1 Sep 2021 at 23:34:40 CEST, "Anton Ertl" <Anton Ertl> wrote:
>
> Here are the results in cycles/iteration on Zen 3 (Ryzen 5800X):
>
> VFX64 lxf VFX32
> orig new orig new orig new ulength
> 7474 1125 7624 1095 7807 423 1
> 3360 965 3140 933 4273 420 2
> 2367 957 2380 922 3018 411 3
> 2068 790 2147 761 2418 400 4
> 1645 779 1766 754 2083 426 5

Well, that was interesting, if not a little frustrating. My tests have been
performed on
a mid-2012 Macbook Pro with a 2.6GHz Core i7. The Forth is:

VFX Forth 64 for Mac OS X x64
© MicroProcessor Engineering Ltd, 1998-2021

Version: 5.20 RC2 [build 0381]
Build date: 1 July 2021

For no special cases, REP MOVSB seems to be the fastest straight copy, but
the limited pattern stuff means that this cannot be used much. Far and away
the
best alternative is a transliteration of VFX32's CMOVE> to AMD64. Hence, the
next
release will contain CMOVE and CMOVE> as described here, and a new MOVE
with a more sophisticated overlap detector.

These changes willl mean that if you want to use CMOVE and CMOVE> to
perform tricksy copies, you still can, but I have no sympathy at the corner
cases.
The general case can be handled by MOVE.

My conclusions with respect to AMD64 are that REP MOVSB is only optimised
for CLD (increasing addresses), and that for decreasing addresses you are
better
off (at least on old x64 CPUs) writing old-style code without MOVSx. In
particular,
all my experiments using REP MOVSQ were failures from a performance point of
view. There are notes online that suggest that the fastest code depends on
knowing
the block length.

> As can be seen, the new CMOVE is substantially faster than the REP
> MOVSB based one for this use case. Of course, the question remains
> how relevant this use case is; but then, this is the only use case
> where CMOVE behaves differently from MOVE, so it may be a
> justification for keeping CMOVE.

If you write code that depends on corner cases, you NEED to keep
CMOVE and CMOVE>.

Stephen

--
Stephen Pelc, stephen@vfxforth.com
MicroProcessor Engineering Ltd - More Real, Less Time
133 Hill Lane, Southampton SO15 5AF, England
tel: +44 (0)23 8063 1441, +44 (0)78 0390 3612, +34 649 662 974
http://www.mpeforth.com - free VFX Forth downloads

Re: Efficient CMOVE

<sgrke7$1tap$1@gioia.aioe.org>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14462&group=comp.lang.forth#14462

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Efficient CMOVE
Date: Fri, 3 Sep 2021 08:49:43 +1000
Organization: Aioe.org NNTP Server
Message-ID: <sgrke7$1tap$1@gioia.aioe.org>
References: <sghpg8$1sh6$1@gioia.aioe.org> <sgiipl$bbc$1@dont-email.me>
<sgiouu$k89$1@dont-email.me> <612d0520$0$705$14726298@news.sunsite.dk>
<sgj7q8$t36$1@dont-email.me> <87mtoytul6.fsf@nightsong.com>
<sgjuci$7hb$1@dont-email.me> <2021Aug31.091034@mips.complang.tuwien.ac.at>
<sgl7dk$6q5$1@dont-email.me> <2021Aug31.181205@mips.complang.tuwien.ac.at>
<sgo4qk$ton$1@dont-email.me> <2021Sep1.175835@mips.complang.tuwien.ac.at>
<2021Sep1.233440@mips.complang.tuwien.ac.at> <sgqdpg$1jsg$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="62809"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Thu, 2 Sep 2021 22:49 UTC

On 2/09/2021 21:50, dxforth wrote:
> On 2/09/2021 07:34, Anton Ertl wrote:
>>
>> Eliminating the locals is left as an exercise to the puristic readers.
>
> : propagate ( afrom ato u -- )
> >r swap ( ato afrom) 2dup - r@ u< if \ overlapping case
> tuck ( ato afrom) - r@ ( u) over + begin ( u1) >r
> over ( afrom) dup 2 pick + 2 pick r@ over - min move
> 2* r> over r@ ( u) u< not
> until r> 2drop 2drop
> else \ the usual non-pattern case
> r> ( ato afrom u) move
> then ;

Hmmm - neither this nor the locals version appear to be completing
the fill. Should I need a propagating move, I'll just define one
as follows:

: pmove ( a a2 u --- ) bounds ?do dup c@ i c! 1+ loop drop ;

For straight memory copying I'll use CMOVE CMOVE> MOVE in that
order of preference as it seems the most logical to me.

Re: Naming conventions and greater-than sign (was: Name for: : xxx ( u -- a ) here swap allot ;)

<sgrtvc$o0l$1@gioia.aioe.org>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14466&group=comp.lang.forth#14466

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Naming conventions and greater-than sign (was: Name for: : xxx (
u -- a ) here swap allot ;)
Date: Fri, 3 Sep 2021 11:32:28 +1000
Organization: Aioe.org NNTP Server
Message-ID: <sgrtvc$o0l$1@gioia.aioe.org>
References: <sghpg8$1sh6$1@gioia.aioe.org> <sgiipl$bbc$1@dont-email.me>
<sgiouu$k89$1@dont-email.me> <612d0520$0$705$14726298@news.sunsite.dk>
<sgj7q8$t36$1@dont-email.me> <87mtoytul6.fsf@nightsong.com>
<sgjuci$7hb$1@dont-email.me> <sgl70d$l9l$1@gioia.aioe.org>
<sgqkkf$v4a$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="24597"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Fri, 3 Sep 2021 01:32 UTC

On 2/09/2021 23:46, Ruvim wrote:
> On 2021-08-31 15:23, dxforth wrote:
>> Here's a listing of the naming conventions published in 'Thinking
>> Forth' and 'Forth Programmers Handbook':
>>
>> https://pastebin.com/qpZLFc6h
>>
>> As to the difference between:
>>
>>   !name     Store into name                           !DATA
>>
>>   name!     Store into name                           B!
>>
>> I was informed it likely stemmed from when forth names were stored
>> as count-plus-three characters.
>
> Neither standard word follows this convention concerning "!".
> E.g.: "C!", "2!", "+!", "DEFER!", etc.
>
> Though in usual practice, if you have the words "name" and "name!", the
> latter one stores something into "name". Probably it's better to use
> "!name" instead.

Were I extending the range of standard operators I'd try to maintain
convention. For operations specific to an application, it probably
doesn't matter and one can use what feels best. If it's at odds with
convention it stands out which can be a good thing.

: !FNAME ( a n -- ) max-path min cf cell+ place ;
: @FNAME ( -- a n ) cf cell+ count ;

: @STR ( ofs -- a u ) >buf count ;
: !STR ( a u ofs -- ) >buf place ;
: @BYT ( ofs -- c ) >buf c@ ;
: !BYT ( c ofs -- ) >buf c! ;

Re: Efficient CMOVE

<2021Sep3.123132@mips.complang.tuwien.ac.at>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14468&group=comp.lang.forth#14468

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Efficient CMOVE
Date: Fri, 03 Sep 2021 10:31:32 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 57
Message-ID: <2021Sep3.123132@mips.complang.tuwien.ac.at>
References: <sghpg8$1sh6$1@gioia.aioe.org> <sgiouu$k89$1@dont-email.me> <612d0520$0$705$14726298@news.sunsite.dk> <sgj7q8$t36$1@dont-email.me> <87mtoytul6.fsf@nightsong.com> <sgjuci$7hb$1@dont-email.me> <2021Aug31.091034@mips.complang.tuwien.ac.at> <sgl7dk$6q5$1@dont-email.me> <2021Aug31.181205@mips.complang.tuwien.ac.at> <sgo4qk$ton$1@dont-email.me> <2021Sep1.175835@mips.complang.tuwien.ac.at> <2021Sep1.233440@mips.complang.tuwien.ac.at> <sgqdpg$1jsg$1@gioia.aioe.org> <sgrke7$1tap$1@gioia.aioe.org>
Injection-Info: reader02.eternal-september.org; posting-host="47443575209a8dec73de98d33bb6ff7f";
logging-data="2229"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1++4gTPllMfHEdBd4FSAiQL"
Cancel-Lock: sha1:VpbrQKlVLaLEBwvjJ57bHqsoY6c=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Fri, 3 Sep 2021 10:31 UTC

dxforth <dxforth@gmail.com> writes:
>On 2/09/2021 21:50, dxforth wrote:
>> On 2/09/2021 07:34, Anton Ertl wrote:
>>>
>>> Eliminating the locals is left as an exercise to the puristic readers.
>>
>> : propagate ( afrom ato u -- )
>> >r swap ( ato afrom) 2dup - r@ u< if \ overlapping case
>> tuck ( ato afrom) - r@ ( u) over + begin ( u1) >r
>> over ( afrom) dup 2 pick + 2 pick r@ over - min move
>> 2* r> over r@ ( u) u< not
>> until r> 2drop 2drop
>> else \ the usual non-pattern case
>> r> ( ato afrom u) move
>> then ;
>
>Hmmm - neither this nor the locals version appear to be completing
>the fill.

I tested only the pattern case, and of course the non-pattern case is
broken (to and from interchanged, reported be Peter Faelth) in the
version I posted, and you did not catch my bug when eliminating the
locals. If you have any other case where this CMOVE does not satisfy
the requirements for CMOVE, please provide it as a test case.

So this one should be correct:

: cmove {: afrom ato u | u1 -- :}
ato afrom - u u< if \ pattern replication case
ato afrom - u over + to u1 begin
afrom afrom 2 pick + 2 pick u1 over - min move
2* dup u u>= until
drop
else \ the usual non-pattern case
afrom ato u move
then ;

And adjusting your version for it:

: propagate ( afrom ato u -- )
>r 2dup swap - r@ u< if \ overlapping case
over - r@ ( u) over + begin ( u1) >r
over ( afrom) dup 2 pick + 2 pick r@ over - min move
2* r> over r@ ( u) u< not
until r> 2drop 2drop
else \ the usual non-pattern case
r> ( afrom ato u) move
then ;

Untested.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: Efficient CMOVE

<sgulsm$1bs4$1@gioia.aioe.org>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14472&group=comp.lang.forth#14472

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Efficient CMOVE
Date: Sat, 4 Sep 2021 12:32:55 +1000
Organization: Aioe.org NNTP Server
Message-ID: <sgulsm$1bs4$1@gioia.aioe.org>
References: <sghpg8$1sh6$1@gioia.aioe.org> <sgiouu$k89$1@dont-email.me>
<612d0520$0$705$14726298@news.sunsite.dk> <sgj7q8$t36$1@dont-email.me>
<87mtoytul6.fsf@nightsong.com> <sgjuci$7hb$1@dont-email.me>
<2021Aug31.091034@mips.complang.tuwien.ac.at> <sgl7dk$6q5$1@dont-email.me>
<2021Aug31.181205@mips.complang.tuwien.ac.at> <sgo4qk$ton$1@dont-email.me>
<2021Sep1.175835@mips.complang.tuwien.ac.at>
<2021Sep1.233440@mips.complang.tuwien.ac.at> <sgqdpg$1jsg$1@gioia.aioe.org>
<sgrke7$1tap$1@gioia.aioe.org> <2021Sep3.123132@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="44932"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Sat, 4 Sep 2021 02:32 UTC

On 3/09/2021 20:31, Anton Ertl wrote:
> dxforth <dxforth@gmail.com> writes:
>>
>>Hmmm - neither this nor the locals version appear to be completing
>>the fill.
>
> I tested only the pattern case, and of course the non-pattern case is
> broken (to and from interchanged, reported be Peter Faelth) in the
> version I posted, and you did not catch my bug when eliminating the
> locals. If you have any other case where this CMOVE does not satisfy
> the requirements for CMOVE, please provide it as a test case.

Using Ruvim's test:

s" A-B-*******" 2dup 4 /string 3 pick -rot cmove cr type
A-B-A-B-*** ok

What continues to remain unanswered however is the necessity to have
CMOVE propagate. 200x has once again made CMOVE and CMOVE> logical
factors of MOVE, and as such, deserve to be as fast as possible. As
your code demonstrates, propagation and moving data can - and perhaps
should - be de-linked.

Re: Efficient CMOVE

<2021Sep4.093104@mips.complang.tuwien.ac.at>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14475&group=comp.lang.forth#14475

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Efficient CMOVE
Date: Sat, 04 Sep 2021 07:31:04 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 50
Message-ID: <2021Sep4.093104@mips.complang.tuwien.ac.at>
References: <sghpg8$1sh6$1@gioia.aioe.org> <sgj7q8$t36$1@dont-email.me> <87mtoytul6.fsf@nightsong.com> <sgjuci$7hb$1@dont-email.me> <2021Aug31.091034@mips.complang.tuwien.ac.at> <sgl7dk$6q5$1@dont-email.me> <2021Aug31.181205@mips.complang.tuwien.ac.at> <sgo4qk$ton$1@dont-email.me> <2021Sep1.175835@mips.complang.tuwien.ac.at> <2021Sep1.233440@mips.complang.tuwien.ac.at> <sgqdpg$1jsg$1@gioia.aioe.org> <sgrke7$1tap$1@gioia.aioe.org> <2021Sep3.123132@mips.complang.tuwien.ac.at> <sgulsm$1bs4$1@gioia.aioe.org>
Injection-Info: reader02.eternal-september.org; posting-host="a4621b17a6b7ebe62abe51bcd0746d88";
logging-data="21199"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/eDpPa3UJLTMuIByXfOo+x"
Cancel-Lock: sha1:W+bidNOU6Ce8WyIEQvZTkIKJgVM=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Sat, 4 Sep 2021 07:31 UTC

dxforth <dxforth@gmail.com> writes:
>s" A-B-*******" 2dup 4 /string 3 pick -rot cmove cr type
>A-B-A-B-*** ok

Thanks. I hope I got it right this time:

: cmove {: afrom ato u -- :}
ato afrom - u u< if \ pattern propagation case
ato afrom - >r ato u begin
2dup r@ min afrom -rot move
dup r@ u> while
r@ /string r> 2* >r repeat
r> drop 2drop
else \ non-pattern case
afrom ato u move
then ;

Rather than trying to find and fix the thinko, I just rewrote the
overlapping case from scratch. This will not work on systems that
rely on programs complying with the restriction 13.3.3.2 d).

>What continues to remain unanswered however is the necessity to have
>CMOVE propagate. 200x has once again made CMOVE and CMOVE> logical
>factors of MOVE, and as such, deserve to be as fast as possible.

They are not logical factors at all, exactly because of performance
reasons. CMOVE and CMOVE> have requirements that make straightforward
implementations slow (and MOVE based on it slow, too), while fast
implementations (like the one above) are more complex than required
for implementing MOVE.

You may be thinking of common factors to both. Let's call them

MOVE< ( from to u -- ) \ do not call MOVE< with to in [from,from+u)
MOVE> ( from to u -- ) \ do not call MOVE> with from in [to,to+u)

You could use MOVE< instead of MOVE in the code above.

>As
>your code demonstrates, propagation and moving data can - and perhaps
>should - be de-linked.

They are: We have CMOVE (and CMOVE>) for propagation, and MOVE for moving.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: Efficient CMOVE

<2021Sep4.141841@mips.complang.tuwien.ac.at>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14477&group=comp.lang.forth#14477

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Efficient CMOVE
Date: Sat, 04 Sep 2021 12:18:41 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 62
Message-ID: <2021Sep4.141841@mips.complang.tuwien.ac.at>
References: <sghpg8$1sh6$1@gioia.aioe.org> <sgjuci$7hb$1@dont-email.me> <2021Aug31.091034@mips.complang.tuwien.ac.at> <sgl7dk$6q5$1@dont-email.me> <2021Aug31.181205@mips.complang.tuwien.ac.at> <sgo4qk$ton$1@dont-email.me> <2021Sep1.175835@mips.complang.tuwien.ac.at> <2021Sep1.233440@mips.complang.tuwien.ac.at> <sgqdpg$1jsg$1@gioia.aioe.org> <sgrke7$1tap$1@gioia.aioe.org> <2021Sep3.123132@mips.complang.tuwien.ac.at> <sgulsm$1bs4$1@gioia.aioe.org> <2021Sep4.093104@mips.complang.tuwien.ac.at>
Injection-Info: reader02.eternal-september.org; posting-host="a4621b17a6b7ebe62abe51bcd0746d88";
logging-data="1929"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+7Od9PSBldo5L+ZaKiPec/"
Cancel-Lock: sha1:6SOyxuyJxgdXvaiClQL4xjSCbKo=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Sat, 4 Sep 2021 12:18 UTC

anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>dxforth <dxforth@gmail.com> writes:
>>s" A-B-*******" 2dup 4 /string 3 pick -rot cmove cr type
>>A-B-A-B-*** ok
>
>Thanks. I hope I got it right this time:
>
>: cmove {: afrom ato u -- :}
> ato afrom - u u< if \ pattern propagation case
> ato afrom - >r ato u begin
> 2dup r@ min afrom -rot move
> dup r@ u> while
> r@ /string r> 2* >r repeat
> r> drop 2drop
> else \ non-pattern case
> afrom ato u move
> then ;

Still does not work in some corner cases; here's a more fully tested
version (again rewritten from scratch):

: cmove ( afrom ato u -- )
dup 0= ?exit
begin {: afrom ato u :} ato afrom - {: u1 :}
afrom ato u1 u umin move
u1 1 u within while
afrom ato u u1 /string repeat ;

And here a no-locals version (also tested) for those systems that are
not up to the locals usage exhibited in the code above:

: cmove ( afrom ato u -- )
dup 0= ?exit
begin ( afrom1 ato1 u1 )
over 3 pick - 2>r
2dup 2r@ umin move
2r@ 1 rot within while
2r> /string repeat
2r> 2drop 2drop ;

We recently had a discussion about "confusing stack juggling". Who
has an easier time following the data flow in the no-locals version
compared to the locals version?

The performance of this variant is slightly worse than the old variant
using MOVE (but then, the old version is not correct):

cycles/iteration
VFX64 lxf VFX32
orig new move sep4 orig new move sep4 orig new move sep4 ulength
7474 1125 2903 2960 7624 1095 2240 2258 7807 423 380 396 1
3360 965 2722 2774 3140 933 2059 2071 4273 420 373 386 2
2367 957 2724 2768 2380 922 2313 2329 3018 411 389 397 3
2068 790 2537 2583 2147 761 1871 1888 2418 400 375 392 4
1645 779 2544 2585 1766 754 2002 2024 2083 426 370 381 5

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: Efficient CMOVE

<sgvrji$1fpf$1@gioia.aioe.org>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14478&group=comp.lang.forth#14478

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Efficient CMOVE
Date: Sat, 4 Sep 2021 23:16:35 +1000
Organization: Aioe.org NNTP Server
Message-ID: <sgvrji$1fpf$1@gioia.aioe.org>
References: <sghpg8$1sh6$1@gioia.aioe.org> <sgj7q8$t36$1@dont-email.me>
<87mtoytul6.fsf@nightsong.com> <sgjuci$7hb$1@dont-email.me>
<2021Aug31.091034@mips.complang.tuwien.ac.at> <sgl7dk$6q5$1@dont-email.me>
<2021Aug31.181205@mips.complang.tuwien.ac.at> <sgo4qk$ton$1@dont-email.me>
<2021Sep1.175835@mips.complang.tuwien.ac.at>
<2021Sep1.233440@mips.complang.tuwien.ac.at> <sgqdpg$1jsg$1@gioia.aioe.org>
<sgrke7$1tap$1@gioia.aioe.org> <2021Sep3.123132@mips.complang.tuwien.ac.at>
<sgulsm$1bs4$1@gioia.aioe.org> <2021Sep4.093104@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="48943"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Sat, 4 Sep 2021 13:16 UTC

On 4/09/2021 17:31, Anton Ertl wrote:
> dxforth <dxforth@gmail.com> writes:
> ...
>>What continues to remain unanswered however is the necessity to have
>>CMOVE propagate. 200x has once again made CMOVE and CMOVE> logical
>>factors of MOVE, and as such, deserve to be as fast as possible.
>
> They are not logical factors at all, exactly because of performance
> reasons. CMOVE and CMOVE> have requirements that make straightforward
> implementations slow (and MOVE based on it slow, too), while fast
> implementations (like the one above) are more complex than required
> for implementing MOVE.

What requirement - propagation in CMOVE? I can't recall ever using it.
On the rare occasion pattern fill is required a stand-alone function
would be simpler.

: !pattern ( buf len pat len -- )
2 pick min 2>r
begin dup r@ min 0> while
over 2r@ rot swap cmove r@ /string
repeat 2r> 2drop 2drop ;

> You may be thinking of common factors to both. Let's call them
>
> MOVE< ( from to u -- ) \ do not call MOVE< with to in [from,from+u)
> MOVE> ( from to u -- ) \ do not call MOVE> with from in [to,to+u)
>
> You could use MOVE< instead of MOVE in the code above.
>
>>As
>>your code demonstrates, propagation and moving data can - and perhaps
>>should - be de-linked.
>
> They are: We have CMOVE (and CMOVE>) for propagation, and MOVE for moving.

Pre ANS CMOVE and CMOVE> were used for moving. MOVE is for those who are
confused as to which to use.

Re: Efficient CMOVE

<2021Sep4.171010@mips.complang.tuwien.ac.at>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14479&group=comp.lang.forth#14479

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Efficient CMOVE
Date: Sat, 04 Sep 2021 15:10:10 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 45
Message-ID: <2021Sep4.171010@mips.complang.tuwien.ac.at>
References: <sghpg8$1sh6$1@gioia.aioe.org> <2021Aug31.091034@mips.complang.tuwien.ac.at> <sgl7dk$6q5$1@dont-email.me> <2021Aug31.181205@mips.complang.tuwien.ac.at> <sgo4qk$ton$1@dont-email.me> <2021Sep1.175835@mips.complang.tuwien.ac.at> <2021Sep1.233440@mips.complang.tuwien.ac.at> <sgqdpg$1jsg$1@gioia.aioe.org> <sgrke7$1tap$1@gioia.aioe.org> <2021Sep3.123132@mips.complang.tuwien.ac.at> <sgulsm$1bs4$1@gioia.aioe.org> <2021Sep4.093104@mips.complang.tuwien.ac.at> <sgvrji$1fpf$1@gioia.aioe.org>
Injection-Info: reader02.eternal-september.org; posting-host="a4621b17a6b7ebe62abe51bcd0746d88";
logging-data="14571"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+PuAOC/sEjfuEXYRhZPOyo"
Cancel-Lock: sha1:2oYwMjaY3oKEkQ9Znqmof/Kcobs=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Sat, 4 Sep 2021 15:10 UTC

dxforth <dxforth@gmail.com> writes:
>On 4/09/2021 17:31, Anton Ertl wrote:
>> CMOVE and CMOVE> have requirements that make straightforward
>> implementations slow (and MOVE based on it slow, too), while fast
>> implementations (like the one above) are more complex than required
>> for implementing MOVE.
>
>What requirement - propagation in CMOVE?

Propagation of patterns is a consequence; the specified requirement
is:

|If u is greater than zero, copy u consecutive characters from the data
|space starting at c-addr1 to that starting at c-addr2, proceeding
|character-by-character from lower addresses to higher addresses.

>I can't recall ever using it.

Then you can simply replace all calls of CMOVE in your code with calls
of MOVE for better performance.

If you then don't need CMOVE, you can remove it from your system.

[dxforth wrote:]
>>>As
>>>your code demonstrates, propagation and moving data can - and perhaps
>>>should - be de-linked.
>>
>> They are: We have CMOVE (and CMOVE>) for propagation, and MOVE for moving.
>
>Pre ANS CMOVE and CMOVE> were used for moving. MOVE is for those who are
>confused as to which to use.

The classical CMOVE (and CMOVE>) with its byte-by-byte implementation
could be used for block-copying (with some limitations) and for
patterns, and it still can. If you want something less limited and
more efficient for block-copying, use MOVE. If you want something
more efficient for patterns, use my CMOVE implementation.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: Efficient CMOVE

<sh1buc$glp$1@gioia.aioe.org>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14483&group=comp.lang.forth#14483

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Efficient CMOVE
Date: Sun, 5 Sep 2021 13:01:33 +1000
Organization: Aioe.org NNTP Server
Message-ID: <sh1buc$glp$1@gioia.aioe.org>
References: <sghpg8$1sh6$1@gioia.aioe.org>
<2021Aug31.091034@mips.complang.tuwien.ac.at> <sgl7dk$6q5$1@dont-email.me>
<2021Aug31.181205@mips.complang.tuwien.ac.at> <sgo4qk$ton$1@dont-email.me>
<2021Sep1.175835@mips.complang.tuwien.ac.at>
<2021Sep1.233440@mips.complang.tuwien.ac.at> <sgqdpg$1jsg$1@gioia.aioe.org>
<sgrke7$1tap$1@gioia.aioe.org> <2021Sep3.123132@mips.complang.tuwien.ac.at>
<sgulsm$1bs4$1@gioia.aioe.org> <2021Sep4.093104@mips.complang.tuwien.ac.at>
<sgvrji$1fpf$1@gioia.aioe.org> <2021Sep4.171010@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="17081"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Sun, 5 Sep 2021 03:01 UTC

On 5/09/2021 01:10, Anton Ertl wrote:
> dxforth <dxforth@gmail.com> writes:
>>On 4/09/2021 17:31, Anton Ertl wrote:
>>> CMOVE and CMOVE> have requirements that make straightforward
>>> implementations slow (and MOVE based on it slow, too), while fast
>>> implementations (like the one above) are more complex than required
>>> for implementing MOVE.
>>
>>What requirement - propagation in CMOVE?
>
> Propagation of patterns is a consequence; the specified requirement
> is:
>
> |If u is greater than zero, copy u consecutive characters from the data
> |space starting at c-addr1 to that starting at c-addr2, proceeding
> |character-by-character from lower addresses to higher addresses.

I know what the spec is. You broke it when you decided the char-by-char
requirement was inefficient.

>
>>I can't recall ever using it.
>
> Then you can simply replace all calls of CMOVE in your code with calls
> of MOVE for better performance.

There's no guarantee MOVE has better performance than CMOVE. It certainly
spends more time deciding - something I can do at compile-time where it
costs nothing.

Re: Efficient CMOVE

<2021Sep5.115027@mips.complang.tuwien.ac.at>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14494&group=comp.lang.forth#14494

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Efficient CMOVE
Date: Sun, 05 Sep 2021 09:50:27 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 62
Message-ID: <2021Sep5.115027@mips.complang.tuwien.ac.at>
References: <sghpg8$1sh6$1@gioia.aioe.org> <2021Aug31.181205@mips.complang.tuwien.ac.at> <sgo4qk$ton$1@dont-email.me> <2021Sep1.175835@mips.complang.tuwien.ac.at> <2021Sep1.233440@mips.complang.tuwien.ac.at> <sgqdpg$1jsg$1@gioia.aioe.org> <sgrke7$1tap$1@gioia.aioe.org> <2021Sep3.123132@mips.complang.tuwien.ac.at> <sgulsm$1bs4$1@gioia.aioe.org> <2021Sep4.093104@mips.complang.tuwien.ac.at> <sgvrji$1fpf$1@gioia.aioe.org> <2021Sep4.171010@mips.complang.tuwien.ac.at> <sh1buc$glp$1@gioia.aioe.org>
Injection-Info: reader02.eternal-september.org; posting-host="f2c0174bcd352ab0df34b8c070fdd3d3";
logging-data="9183"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18k/V3pUycuxvX71q7T70F4"
Cancel-Lock: sha1:gdSgvKfyzAnA9IbEv3s6VlbvPqg=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Sun, 5 Sep 2021 09:50 UTC

dxforth <dxforth@gmail.com> writes:
>On 5/09/2021 01:10, Anton Ertl wrote:
>> |If u is greater than zero, copy u consecutive characters from the data
>> |space starting at c-addr1 to that starting at c-addr2, proceeding
>> |character-by-character from lower addresses to higher addresses.
>
>I know what the spec is. You broke it when you decided the char-by-char
>requirement was inefficient.

From what you wrote, you decided that the requirement is inefficient,
and use cell-by-cell copying instead. Which is fine for copying, but
does not always produce the results that CMOVE is required to produce.
By contrast, my CMOVE implementation is efficient and always produces
the right results.

>There's no guarantee MOVE has better performance than CMOVE. It certainly
>spends more time deciding - something I can do at compile-time where it
>costs nothing.

Certainly? My implementation of CMOVE spends more time on deciding
than a typical implementation of MOVE.

Sure, you can write a dumb CMOVE. It will not spend time on deciding,
but it will also be slow. Or you can use a fast CMOVE, which will
spend time on deciding, but amortizes this time quickly.

You can implement MOVE to call a dumb CMOVE, and that's the only
scenario in which your reasoning holds; but then, if you have
implemented both CMOVE and MOVE to perform slowly, why worry about
eliminating the time that MOVE takes for deciding? Penny-wise and
pound-foolish?

Or you can implement MOVE to call the MOVE< or MOVE> factors mentioned
earlier, which do not give the guarantees that CMOVE and CMOVE> give,
and can therefore be implemented efficiently with fewer decisions.

And if you go for efficient implementations, the overhead of MOVE is
less than that of CMOVE. Here are implementations of both in terms of
MOVE< and MOVE>:

: move ( from to u -- )
over 3 pick - 2 pick u< if \ to in [from,from+u)
move>
else
move<
then ;

: cmove ( afrom ato u -- )
dup 0= if exit then
begin ( afrom1 ato1 u1 )
over 3 pick - 2>r
2dup 2r@ umin move<
2r@ 1 rot within while
2r> /string repeat
2r> 2drop 2drop ;

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: Efficient CMOVE

<b36f4f16-d6e6-4c67-aac8-3d383bcb22a3n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14495&group=comp.lang.forth#14495

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:4001:: with SMTP id h1mr7136056qko.454.1630849922639;
Sun, 05 Sep 2021 06:52:02 -0700 (PDT)
X-Received: by 2002:a37:2dc7:: with SMTP id t190mr7021438qkh.60.1630849922485;
Sun, 05 Sep 2021 06:52:02 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Sun, 5 Sep 2021 06:52:02 -0700 (PDT)
In-Reply-To: <2021Sep4.141841@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:1c05:2f14:600:254c:3919:57c5:6fa8;
posting-account=-JQ2RQoAAAB6B5tcBTSdvOqrD1HpT_Rk
NNTP-Posting-Host: 2001:1c05:2f14:600:254c:3919:57c5:6fa8
References: <sghpg8$1sh6$1@gioia.aioe.org> <sgjuci$7hb$1@dont-email.me>
<2021Aug31.091034@mips.complang.tuwien.ac.at> <sgl7dk$6q5$1@dont-email.me>
<2021Aug31.181205@mips.complang.tuwien.ac.at> <sgo4qk$ton$1@dont-email.me>
<2021Sep1.175835@mips.complang.tuwien.ac.at> <2021Sep1.233440@mips.complang.tuwien.ac.at>
<sgqdpg$1jsg$1@gioia.aioe.org> <sgrke7$1tap$1@gioia.aioe.org>
<2021Sep3.123132@mips.complang.tuwien.ac.at> <sgulsm$1bs4$1@gioia.aioe.org>
<2021Sep4.093104@mips.complang.tuwien.ac.at> <2021Sep4.141841@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b36f4f16-d6e6-4c67-aac8-3d383bcb22a3n@googlegroups.com>
Subject: Re: Efficient CMOVE
From: mhx...@iae.nl (Marcel Hendrix)
Injection-Date: Sun, 05 Sep 2021 13:52:02 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 70
 by: Marcel Hendrix - Sun, 5 Sep 2021 13:52 UTC

On Saturday, September 4, 2021 at 3:01:51 PM UTC+2, Anton Ertl wrote:
> an...@mips.complang.tuwien.ac.at (Anton Ertl) writes:
> >dxforth <dxf...@gmail.com> writes:
> >>s" A-B-*******" 2dup 4 /string 3 pick -rot cmove cr type
> >>A-B-A-B-*** ok
> >
> >Thanks. I hope I got it right this time:
> >
> >: cmove {: afrom ato u -- :}
> > ato afrom - u u< if \ pattern propagation case
> > ato afrom - >r ato u begin
> > 2dup r@ min afrom -rot move
> > dup r@ u> while
> > r@ /string r> 2* >r repeat
> > r> drop 2drop
> > else \ non-pattern case
> > afrom ato u move
> > then ;
> Still does not work in some corner cases; here's a more fully tested
> version (again rewritten from scratch):
>
> : cmove ( afrom ato u -- )
> dup 0= ?exit
> begin {: afrom ato u :} ato afrom - {: u1 :}
> afrom ato u1 u umin move
> u1 1 u within while
> afrom ato u u1 /string repeat ;
>
> And here a no-locals version (also tested) for those systems that are
> not up to the locals usage exhibited in the code above:
>
> : cmove ( afrom ato u -- )
> dup 0= ?exit
> begin ( afrom1 ato1 u1 )
> over 3 pick - 2>r
> 2dup 2r@ umin move
> 2r@ 1 rot within while
> 2r> /string repeat
> 2r> 2drop 2drop ;
>
> We recently had a discussion about "confusing stack juggling". Who
> has an easier time following the data flow in the no-locals version
> compared to the locals version?
>
> The performance of this variant is slightly worse than the old variant
> using MOVE (but then, the old version is not correct):
>
> cycles/iteration
> VFX64 lxf VFX32
> orig new move sep4 orig new move sep4 orig new move sep4 ulength
> 7474 1125 2903 2960 7624 1095 2240 2258 7807 423 380 396 1
> 3360 965 2722 2774 3140 933 2059 2071 4273 420 373 386 2
> 2367 957 2724 2768 2380 922 2313 2329 3018 411 389 397 3
> 2068 790 2537 2583 2147 761 1871 1888 2418 400 375 392 4
> 1645 779 2544 2585 1766 754 2002 2024 2083 426 370 381 5

Indeed surprising... The results are reported in cycles/iteration.
With locals times are significantly slower.
I repeated the measurements 4 times, no change in any of the
shown digits.

FORTH> test
AMD Ryzen 7 5800X 8-Core Processor, TICKS-GET uses iTSC at 4192MHz
original new-locals new-stack
\ 1000 1 5,562 310 275
\ 1000 2 3,069 293 266
\ 1000 3 2,103 285 250
\ 1000 4 1,611 229 204
\ 1000 5 1,320 292 260 ok

-marcel

Re: Efficient CMOVE

<bebec471-984c-41f0-a733-00588f82ebd0n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14497&group=comp.lang.forth#14497

 copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:1435:: with SMTP id k21mr7186015qkj.442.1630851269760;
Sun, 05 Sep 2021 07:14:29 -0700 (PDT)
X-Received: by 2002:a05:622a:c6:: with SMTP id p6mr7203828qtw.35.1630851269474;
Sun, 05 Sep 2021 07:14:29 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Sun, 5 Sep 2021 07:14:29 -0700 (PDT)
In-Reply-To: <2021Sep5.115027@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=2a01:2000:2001:46bc:2d96:1f66:b65d:5fa6;
posting-account=ryzhhAoAAAAIqf1uqmG9E4uP1Bagd-k2
NNTP-Posting-Host: 2a01:2000:2001:46bc:2d96:1f66:b65d:5fa6
References: <sghpg8$1sh6$1@gioia.aioe.org> <2021Aug31.181205@mips.complang.tuwien.ac.at>
<sgo4qk$ton$1@dont-email.me> <2021Sep1.175835@mips.complang.tuwien.ac.at>
<2021Sep1.233440@mips.complang.tuwien.ac.at> <sgqdpg$1jsg$1@gioia.aioe.org>
<sgrke7$1tap$1@gioia.aioe.org> <2021Sep3.123132@mips.complang.tuwien.ac.at>
<sgulsm$1bs4$1@gioia.aioe.org> <2021Sep4.093104@mips.complang.tuwien.ac.at>
<sgvrji$1fpf$1@gioia.aioe.org> <2021Sep4.171010@mips.complang.tuwien.ac.at>
<sh1buc$glp$1@gioia.aioe.org> <2021Sep5.115027@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <bebec471-984c-41f0-a733-00588f82ebd0n@googlegroups.com>
Subject: Re: Efficient CMOVE
From: peter.m....@gmail.com (P Falth)
Injection-Date: Sun, 05 Sep 2021 14:14:29 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 69
 by: P Falth - Sun, 5 Sep 2021 14:14 UTC

On Sunday, 5 September 2021 at 12:38:32 UTC+2, Anton Ertl wrote:
> dxforth <dxf...@gmail.com> writes:
> >On 5/09/2021 01:10, Anton Ertl wrote:
> >> |If u is greater than zero, copy u consecutive characters from the data
> >> |space starting at c-addr1 to that starting at c-addr2, proceeding
> >> |character-by-character from lower addresses to higher addresses.
> >
> >I know what the spec is. You broke it when you decided the char-by-char
> >requirement was inefficient.
> From what you wrote, you decided that the requirement is inefficient,
> and use cell-by-cell copying instead. Which is fine for copying, but
> does not always produce the results that CMOVE is required to produce.
> By contrast, my CMOVE implementation is efficient and always produces
> the right results.
> >There's no guarantee MOVE has better performance than CMOVE. It certainly
> >spends more time deciding - something I can do at compile-time where it
> >costs nothing.
> Certainly? My implementation of CMOVE spends more time on deciding
> than a typical implementation of MOVE.
>
> Sure, you can write a dumb CMOVE. It will not spend time on deciding,
> but it will also be slow. Or you can use a fast CMOVE, which will
> spend time on deciding, but amortizes this time quickly.
>
> You can implement MOVE to call a dumb CMOVE, and that's the only
> scenario in which your reasoning holds; but then, if you have
> implemented both CMOVE and MOVE to perform slowly, why worry about
> eliminating the time that MOVE takes for deciding? Penny-wise and
> pound-foolish?

When I check the standard it is clear that MOVE moves address units
from and to address units. With now 1 au = 1 char could that not be simplified to
be c-addrs and chars?

Is there any program (except test programs) that rely on cmove propagating?
I did a faster cmove when porting LXF64 to ARM64 but got caught by the test program
Arm does not have anything like rep movs so the byte per byte copy suffers much
more then on X64.

Peter

> Or you can implement MOVE to call the MOVE< or MOVE> factors mentioned
> earlier, which do not give the guarantees that CMOVE and CMOVE> give,
> and can therefore be implemented efficiently with fewer decisions.
>
> And if you go for efficient implementations, the overhead of MOVE is
> less than that of CMOVE. Here are implementations of both in terms of
> MOVE< and MOVE>:
>
> : move ( from to u -- )
> over 3 pick - 2 pick u< if \ to in [from,from+u)
> move>
> else
> move<
> then ;
>
> : cmove ( afrom ato u -- )
> dup 0= if exit then
> begin ( afrom1 ato1 u1 )
> over 3 pick - 2>r
> 2dup 2r@ umin move<
> 2r@ 1 rot within while
> 2r> /string repeat
> 2r> 2drop 2drop ;
> - anton
> --
> M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
> comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
> New standard: http://www.forth200x.org/forth200x.html
> EuroForth 2021: https://euro.theforth.net/2021

Re: Efficient CMOVE

<2021Sep5.163558@mips.complang.tuwien.ac.at>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14499&group=comp.lang.forth#14499

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Efficient CMOVE
Date: Sun, 05 Sep 2021 14:35:58 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 26
Message-ID: <2021Sep5.163558@mips.complang.tuwien.ac.at>
References: <sghpg8$1sh6$1@gioia.aioe.org> <2021Sep1.233440@mips.complang.tuwien.ac.at> <sgqdpg$1jsg$1@gioia.aioe.org> <sgrke7$1tap$1@gioia.aioe.org> <2021Sep3.123132@mips.complang.tuwien.ac.at> <sgulsm$1bs4$1@gioia.aioe.org> <2021Sep4.093104@mips.complang.tuwien.ac.at> <sgvrji$1fpf$1@gioia.aioe.org> <2021Sep4.171010@mips.complang.tuwien.ac.at> <sh1buc$glp$1@gioia.aioe.org> <2021Sep5.115027@mips.complang.tuwien.ac.at> <bebec471-984c-41f0-a733-00588f82ebd0n@googlegroups.com>
Injection-Info: reader02.eternal-september.org; posting-host="f2c0174bcd352ab0df34b8c070fdd3d3";
logging-data="21773"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+iTCQdUrOhCHe9JoQalP6V"
Cancel-Lock: sha1:mQ2BBXNCPaAixsGqF6hv6LCe3NM=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Sun, 5 Sep 2021 14:35 UTC

P Falth <peter.m.falth@gmail.com> writes:
>When I check the standard it is clear that MOVE moves address units
>from and to address units. With now 1 au = 1 char could that not be simplified to
>be c-addrs and chars?

Yes.

>Is there any program (except test programs) that rely on cmove propagating?

I don't think I have used this feature of CMOVE in production code,
but then, I don't use CMOVE in code that does not use this feature,
either.

>I did a faster cmove when porting LXF64 to ARM64 but got caught by the test program
>Arm does not have anything like rep movs so the byte per byte copy suffers much
>more then on X64.

Your "faster CMOVE" might be MOVE<, and you can then use the code I
posted for MOVE and CMOVE.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: Efficient CMOVE

<sh2lmh$1r34$1@gioia.aioe.org>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=14500&group=comp.lang.forth#14500

 copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Efficient CMOVE
Date: Mon, 6 Sep 2021 00:54:09 +1000
Organization: Aioe.org NNTP Server
Message-ID: <sh2lmh$1r34$1@gioia.aioe.org>
References: <sghpg8$1sh6$1@gioia.aioe.org>
<2021Aug31.181205@mips.complang.tuwien.ac.at> <sgo4qk$ton$1@dont-email.me>
<2021Sep1.175835@mips.complang.tuwien.ac.at>
<2021Sep1.233440@mips.complang.tuwien.ac.at> <sgqdpg$1jsg$1@gioia.aioe.org>
<sgrke7$1tap$1@gioia.aioe.org> <2021Sep3.123132@mips.complang.tuwien.ac.at>
<sgulsm$1bs4$1@gioia.aioe.org> <2021Sep4.093104@mips.complang.tuwien.ac.at>
<sgvrji$1fpf$1@gioia.aioe.org> <2021Sep4.171010@mips.complang.tuwien.ac.at>
<sh1buc$glp$1@gioia.aioe.org> <2021Sep5.115027@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="60516"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Sun, 5 Sep 2021 14:54 UTC

On 5/09/2021 19:50, Anton Ertl wrote:
> dxforth <dxforth@gmail.com> writes:
>>On 5/09/2021 01:10, Anton Ertl wrote:
>>> |If u is greater than zero, copy u consecutive characters from the data
>>> |space starting at c-addr1 to that starting at c-addr2, proceeding
>>> |character-by-character from lower addresses to higher addresses.
>>
>>I know what the spec is. You broke it when you decided the char-by-char
>>requirement was inefficient.
>
> From what you wrote, you decided that the requirement is inefficient,
> and use cell-by-cell copying instead. Which is fine for copying, but
> does not always produce the results that CMOVE is required to produce.
> By contrast, my CMOVE implementation is efficient and always produces
> the right results.

I decided a CMOVE faster than MOVE was in my best interests. A CMOVE
taking up space and no reason to use, was not.

>>There's no guarantee MOVE has better performance than CMOVE. It certainly
>>spends more time deciding - something I can do at compile-time where it
>>costs nothing.
>
> Certainly? My implementation of CMOVE spends more time on deciding
> than a typical implementation of MOVE.

MOVE has to make a decision; CMOVE and CMOVE> do not.

Pages:123
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor