prefetching

From: Christian Lande (IIZUXMKQOEHH_at_spammotel.com)
Date: 04/17/04


Date: Sat, 17 Apr 2004 17:31:52 +0000 (UTC)

Hi,

playing arroud with some SSE commands I saw that some are confusing me.
I want to try the PREFETCHx ones. In this way I wrote a little gcc programm
(for XEON with Linux), which goes through an array (backward to prefent from
hardware prefetching), but whatever I do, prefetching don't want to bring
any gain in time.

Here is the code:

int a,b,c,d;
int *feld;
int size = 16777216;
feld = (int*)calloc(size+200,sizeof(int));
int block=16;
int *p;

for (d=size-block-1;d>=0;d-=block) {
  p = &feld[d-(1*block)]; // <---------- (1)
  asm("PREFETCHT0 %0 \n\t" : : "m" (p)); // <---------- (2)
  for (b=0;b<100;b++) { // <---------- (3)
    for (c=d;c<d+block;c+=8) {
      feld[c]++;
      feld[c+1]++;
      feld[c+2]++;
      feld[c+3]++;
      feld[c+4]++;
      feld[c+5]++;
      feld[c+6]++;
      feld[c+7]++;
    }
  }
}

The marked lines (1), (2) and (3) are the interesting ones.Whatever I do,
in (1), e.g. 2*block or 3*block
in (2), e.g. PREFETCHT1, PREFETCHT2
in (3), increasing number of passes

nothing helps. Working time is always near the same (at the moment I measure
with "time <prog>"). If anybody knows a bether methode for measuring, please
let me know.

Possibly somebody with more experience can give me some tips why it doesn't
work or how I can make it work.

Many thanks,
ChL



Relevant Pages

  • [PATCH] mm: implement swap prefetching v21
    ... there is free ram available. ... to do the prefetching at a later stage. ... for conditions suitable to prefetch swap pages every 5 seconds. ... extern unsigned int nr_swapfiles; ...
    (Linux-Kernel)
  • [PATCH] mm: Implement Swap Prefetching v23
    ... there is free ram available. ... to do the prefetching at a later stage. ... for conditions suitable to prefetch swap pages every 5 seconds. ... extern unsigned int nr_swapfiles; ...
    (Linux-Kernel)
  • [PATCH] mm: Implement Swap Prefetching v25
    ... to do the prefetching at a later stage. ... for conditions suitable to prefetch swap pages every 5 seconds. ... +static inline void prepare_swap_prefetch ... extern unsigned int nr_swapfiles; ...
    (Linux-Kernel)
  • [Resend] [PATCH] mm: implement swap prefetching (v26)
    ... to do the prefetching at a later stage. ... for conditions suitable to prefetch swap pages every 5 seconds. ... +static inline void prepare_swap_prefetch ... extern unsigned int nr_swapfiles; ...
    (Linux-Kernel)
  • [PATCH] mm: implement swap prefetching
    ... I'm resubmitting the swap prefetching patch for inclusion in -mm and hopefully ... +static inline void prepare_prefetch ... extern unsigned int nr_swapfiles; ...
    (Linux-Kernel)