U.Mutlu via llvm-dev
2018-Jun-19 19:12 UTC
[llvm-dev] Naming clash: -DCLS=n and CLS in code
Tim Northover wrote on 06/19/2018 08:54 PM:>>> Why are you passing that argument in the first place? The compiler >>> completely ignores it. >> >> CLS stands for cacheline size. It is an important parameter >> for optimization of the generated code, at least with gcc/g++. >> -DCLS=n should have the same importance like for example -DNDEBUG. > > The GCC source doesn't appear to mention it, and neither does any > documentation I can find. NDEBUG on the other hand is in both the C > and C++ standards. > > I still think there's some weird library out there that interprets it > the way you're suggesting, and Clang is not that weird library.This is from a famous article series titled "What every programmer should know about memory": gcc -DCLS=$(getconf LEVEL1_DCACHE_LINESIZE) ... https://lwn.net/Articles/255364/ http://mosermichael.github.io/cstuff/all/blog/2015/12/11/wepskn.html https://www.dcl.hpi.uni-potsdam.de/teaching/numasem/slides/NUMASem_Matrix_multiplication.pdf You can find more examples by searching for "DCLS getconf LEVEL1_DCACHE_LINESIZE".
Tim Northover via llvm-dev
2018-Jun-19 19:22 UTC
[llvm-dev] Naming clash: -DCLS=n and CLS in code
On Tue, 19 Jun 2018 at 20:12, U.Mutlu <um at mutluit.com> wrote:> You can find more examples by searching for "DCLS getconf LEVEL1_DCACHE_LINESIZE".Frankly, it all looks like cargo-cult optimization flagomancy. I'd suggest you drop it, it's not magical I promise. Tim.
U.Mutlu via llvm-dev
2018-Jun-19 19:33 UTC
[llvm-dev] Naming clash: -DCLS=n and CLS in code
Tim Northover via llvm-dev wrote on 06/19/2018 09:22 PM:> On Tue, 19 Jun 2018 at 20:12, U.Mutlu <um at mutluit.com> wrote: >> You can find more examples by searching for "DCLS getconf LEVEL1_DCACHE_LINESIZE". > > Frankly, it all looks like cargo-cult optimization flagomancy. I'd > suggest you drop it, it's not magical I promise.Hey, I'm working on optimization, and I know "it works". Curious, have you ever heard of "false sharing" and "true sharing" and what lies behind them? Hint: it has todo with the cacheline and its size, and memory alignment etc... No need to start a sideline discussion here. Ciao
Bruce Hoult via llvm-dev
2018-Jun-19 19:46 UTC
[llvm-dev] Naming clash: -DCLS=n and CLS in code
Furthermore .. in the articles you reference, the -DCLS=$(getconf LEVEL1_DCACHE_LINESIZE) is passed when compiling the user's program -- one doing extensive blocked matrix operations -- and not when building the *compiler*. On Tue, Jun 19, 2018 at 12:12 PM, U.Mutlu via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Tim Northover wrote on 06/19/2018 08:54 PM: > >> Why are you passing that argument in the first place? The compiler >>>> completely ignores it. >>>> >>> >>> CLS stands for cacheline size. It is an important parameter >>> for optimization of the generated code, at least with gcc/g++. >>> -DCLS=n should have the same importance like for example -DNDEBUG. >>> >> >> The GCC source doesn't appear to mention it, and neither does any >> documentation I can find. NDEBUG on the other hand is in both the C >> and C++ standards. >> >> I still think there's some weird library out there that interprets it >> the way you're suggesting, and Clang is not that weird library. >> > > This is from a famous article series titled "What every programmer should > know about memory": > gcc -DCLS=$(getconf LEVEL1_DCACHE_LINESIZE) ... > > https://lwn.net/Articles/255364/ > http://mosermichael.github.io/cstuff/all/blog/2015/12/11/wepskn.html > https://www.dcl.hpi.uni-potsdam.de/teaching/numasem/slides/ > NUMASem_Matrix_multiplication.pdf > > You can find more examples by searching for "DCLS getconf > LEVEL1_DCACHE_LINESIZE". > > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180619/9a82ee20/attachment.html>
Tim Northover via llvm-dev
2018-Jun-19 19:49 UTC
[llvm-dev] Naming clash: -DCLS=n and CLS in code
On Tue, 19 Jun 2018 at 20:46, Bruce Hoult <brucehoult at sifive.com> wrote:> Furthermore .. in the articles you reference, the -DCLS=$(getconf LEVEL1_DCACHE_LINESIZE) is passed when compiling the user's program -- one doing extensive blocked matrix operations -- and not when building the *compiler*.It's worse. At least in the first case, the code looks like it wouldn't even compile without that definition. That's not an optimization flag, that's a weird build system.> > > On Tue, Jun 19, 2018 at 12:12 PM, U.Mutlu via llvm-dev <llvm-dev at lists.llvm.org> wrote: >> >> Tim Northover wrote on 06/19/2018 08:54 PM: >>>>> >>>>> Why are you passing that argument in the first place? The compiler >>>>> completely ignores it. >>>> >>>> >>>> CLS stands for cacheline size. It is an important parameter >>>> for optimization of the generated code, at least with gcc/g++. >>>> -DCLS=n should have the same importance like for example -DNDEBUG. >>> >>> >>> The GCC source doesn't appear to mention it, and neither does any >>> documentation I can find. NDEBUG on the other hand is in both the C >>> and C++ standards. >>> >>> I still think there's some weird library out there that interprets it >>> the way you're suggesting, and Clang is not that weird library. >> >> >> This is from a famous article series titled "What every programmer should know about memory": >> gcc -DCLS=$(getconf LEVEL1_DCACHE_LINESIZE) ... >> >> https://lwn.net/Articles/255364/ >> http://mosermichael.github.io/cstuff/all/blog/2015/12/11/wepskn.html >> https://www.dcl.hpi.uni-potsdam.de/teaching/numasem/slides/NUMASem_Matrix_multiplication.pdf >> >> You can find more examples by searching for "DCLS getconf LEVEL1_DCACHE_LINESIZE". >> >> >> >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >
U.Mutlu via llvm-dev
2018-Jun-19 20:21 UTC
[llvm-dev] Naming clash: -DCLS=n and CLS in code
Bruce Hoult via llvm-dev wrote on 06/19/2018 09:46 PM:> Furthermore .. in the articles you reference, the -DCLS=$(getconf > LEVEL1_DCACHE_LINESIZE) is passed when compiling the user's program -- one > doing extensive blocked matrix operations -- and not when building the *compiler*.It doesn't matter. The goal is to build an optimized (ie. fast) optimizing compiler.
> -----Original Message----- > From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] On Behalf Of > U.Mutlu via llvm-dev > Sent: Tuesday, June 19, 2018 3:12 PM > To: Tim Northover > Cc: LLVM Developers Mailing List > Subject: Re: [llvm-dev] Naming clash: -DCLS=n and CLS in code > > This is from a famous article series titled "What every programmer should > know > about memory": > gcc -DCLS=$(getconf LEVEL1_DCACHE_LINESIZE) ... > > https://lwn.net/Articles/255364/ > http://mosermichael.github.io/cstuff/all/blog/2015/12/11/wepskn.html > https://www.dcl.hpi.uni- > potsdam.de/teaching/numasem/slides/NUMASem_Matrix_multiplication.pdf > > You can find more examples by searching for "DCLS getconf > LEVEL1_DCACHE_LINESIZE".Right, but there is nothing inherently significant about the symbol name CLS. They could have called it MY_SILLY_PARAMETER and it would have worked equally well. gcc attaches no special significance to that name. Clang attaches no special significance to that name. Changing the value of CLS works for the software in the article because that software is written to make use of a symbol named CLS. That's all. --paulr