This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] Improve prefetch heuristics
- From: Zdenek Dvorak <rakdver at kam dot mff dot cuni dot cz>
- To: "Fang, Changpeng" <Changpeng dot Fang at amd dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, "rguenther at suse dot de" <rguenther at suse dot de>, "sebpop at gmail dot com" <sebpop at gmail dot com>
- Date: Wed, 5 May 2010 22:36:04 +0200
- Subject: Re: [patch] Improve prefetch heuristics
- References: <20100430010543.GA30055@kam.mff.cuni.cz> <1C13CD442679CE45A2E80AE9251D7EF921803A35@SAUSEXMBP01.amd.com>
Hi,
> > The reason is that there are too many prefetches. Here is an example:
> > Ahead 5, unroll factor 1, trip count 216, insn count 49, mem ref count 15, prefetch count 15
> >
> > Here we inserted one prefetch for each memory reference. I just feel uncomfortable that
> > we inserted so many prefetches in this loop. I think prefetches will compete with loads/stores
> > for memory ports and bandwidth, and thus cause performance degradation in this case.
>
> >SIMULTANEOUS_PREFETCHES parameter is used to avoid that. Perhaps it is set too high for your
> >architecture?
>
> SIMULTANEOUS_PREFETCHES does not consider the existing memory references in the loop. If we
> consider prefetch as a memory reference, then we have 30 memory reference in this loop. It is too many
> for a loop with instruction count of 49.
>
> I am thinking whether we can account prefetch instruction in the prefetch-min-insns-to-mem ratio heuristic.
> The idea is:
> max_num_prefetches = ninsns - mem_ref_count * prefetch-min-insns-to-mem ratio;
>
> Then in schedule_prefetches, we can schedule at most "max_num_prefetches" prefetches.
>
> What do you think?
I don't quite understand why this would be useful. After all, the prefetches do not affect
the number or amount of memory accesses, so they will not "compete with loads/stores
for memory ports and bandwidth",
Zdenek