[XviD-devel] New Trellis Quant

Christoph Lampert chl at math.uni-bonn.de
Mon May 12 12:27:34 CEST 2003


On Mon, 12 May 2003, Marco Al wrote:
> Well bzero vs memset(0,.. on a modern PC isnt really relevant anymore,
> instruction count in the inner loop is hardly going to be the limiting
> factor on a modern PC for such simple code (the only really important
> improvement which would be helpfull in some instances would be to use non
> temporal stores, but memset wouldnt know when exactly to use em).

Maybve not, but still I hate to waste cycles ;-) Memset() writes arbitrary
bytes to arbitrarily many possibly non-aligned positions. 

XVID needs to write exactly 128 zero bytes to (16-byte?) aligned
positions. A simple unrolled loop of int/long/double/longdouble or
anything is three times as fast as memset(). All 4 data types compile to
the same asm code btw. (gcc 2.95). MMX is even faster. 

  aligned blocks
      glibc memset()       1.290000 s 369 MB/s
      glibc bzero()        1.270000 s 375 MB/s
      double C             0.460000 s 1036 MB/s
      longdouble C         0.470000 s 1014 MB/s
      longlong C           0.510000 s 934 MB/s
      long C               0.500000 s 953 MB/s
      MMX                  0.170000 s 2804 MB/s

  unaligned blocks
      glibc memset()       1.280000 s 372 MB/s
      glibc bzero()        1.270000 s 375 MB/s
      double C             0.820000 s 581 MB/s
      longdouble C         0.830000 s 574 MB/s
      longlong C           0.820000 s 581 MB/s
      long C               0.830000 s 574 MB/s
      MMX                  0.410000 s 1163 MB/s

DCT blocs will always be reused right after setting to zero.
 
Some routine(s?) in image.c call memset() for clearing the bitplane.
Those data will surely _not_ be immediately reaccessed, so there it could
be done using not-temporal stores, right?

gruel
 
P.S. Okay, maybe the main advantage would be that handwritten bzero/memset
could be inlined. After all, this routine is called 6 to 12 times per
macroblock. 



More information about the XviD-devel mailing list