Re: MMX bzero of a page...

Andrea Arcangeli (arcangeli@mbox.queen.it)
Wed, 11 Mar 1998 14:51:30 +0100 (CET)


On Wed, 11 Mar 1998, Perry Harrington wrote:

>I found some decent info on Intel's site finally. I'll take a whack
>at an MMX enhanced bzero, I am unsure of the correctness, heck, I
>don't even know if my assembler would take it. This is to bzero a
>single memory page via writing a 64bit amount to RAM.
>
> MOV ESI, [memory location]
> PXOR MM0, MM0
> MOV CX, 512
>begin:
> MOVQ ESI:[0], MM0
> ADD ESI, 8
> LOOPNZ begin
> EMMS

I just write also a memcpy that works using 64bit transfer using MMX and
it gain a improvement of more than x2 on large array (some megabyte). I
never tried it in the kernel also thinking that in the kernel the most of
memcpy works on little array and not always multiple of 8 byte so the
improvement should be minor.

Here the result with two different bufsize:
andrea@arca:~/devel/mmx/memcpy$ ./memcpy
BUFSIZE = 65536
memcpy from libc
time elapsed: 1568 ms
memcpy in linux/include/asm/string.h of 2.1.89
time elapsed: 1360 ms
memcpyby8 developed by Andrea Arcangeli using MMX
time elapsed: 737 ms

andrea@arca:~/devel/mmx/memcpy$ ./memcpy
BUFSIZE = 1024
memcpy from libc
time elapsed: 23 ms
memcpy in linux/include/asm/string.h of 2.1.89
time elapsed: 5 ms
memcpyby8 developed by Andrea Arcangeli using MMX
time elapsed: 7 ms

As you can see seems that for small array the performance drops (even if I
can' t realize why...).

I am not sure if we must save and restore the fpu state before and then
using MMX if we run in the kernel. Must the state of the fpu be preserved
after a call (asm in general) or a syscall (kernel)?

Andrea[s] Arcangeli

begin 644 memcpy.c.gz
M'XL("-.4!C4"`VUE;6-P>2YC`*5436^;0!`]L[]B2DH%A,3&L2HKQ#U4:J5*
M42]5+JTKA&%QMF)W75@[)57^>V?XLF-'4:)R86?F[<SN>_!.A$J+3<;AJC*9
MT.>W']C)+E57(R,DIRP[R7@N%(>/-Y^_??G^"<+Q9`H^O)\R5IERDQH@Z#8I
MP&PC5FBU@B7/=<F#)#>\C%AZFY3@ZU*L`O`S7IF(L:T6&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