Results 1 to 3 of 3

Thread: HPC - Branching Instruction Reduction (Inlining)

  1. #1
    Join Date
    Nov 2001

    HPC - Branching Instruction Reduction (Inlining)

    This is a technique I would only recomend to someone that understands how thier specific compiler actualy works, and the optimizations it performs itself. Some compilers, (Cobol 2 >, HLASM, etc...) already perfrom this one automatically so there is no need with them, some, like C# do not.

    This optimization, also goes against code re-usuablility/maintainablilty priciples, and should only be considered where performance is a must need, and usualy best to contain it to a one time/or limited usage type situation.

    Mainly it involves going through your code, and removeing all function/method calls, and copying that code back to where it's used, inline.

    It's usefulness is limited to fucntions/methods that are in often repeated loops or code.

    This will not effect huge gains, but it will eliminate 2 to 4 instructions per function/method call transitioned to inline, (eliminates a branch and return, and the instuctions involved in passing and returning paramaters).

    In some large loops this might be a benefit. But again, it's a very specific optimization that I would not normal recomend in day to day coding. However for HPC it might be something to consider if maintainablitiy is not as much of an issue as speed of operation.

  2. #2
    Join Date
    May 2007
    One major disadvantage is that if it's done manually, it's going to introduce a source of bugs, as it is likely that one or more identical statements or blocks of code won't be changed. This is where #include statements are very handy, as cpp or its logical equivalents will do the copy & paste for you.

    More generically, knowing how to break up a problem into functions or subroutines is not trivial. There is some overhead involved with function calls; how much is compiler dependent. Luckily, most of my high-intensity programming has been done with Fortran, which tend to have very good optimizers in their compilers -- optimized Fortran was beating the speed of the best hand-coded assembler by the late 1980s -- so I've never had to worry about in-lining, and usually those kind of optimizations don't help enough to override the downstream maintenance problems (z/OS didn't have a Fortran pre-processor, and cpp usually mungs up Fortran code).
    Information about American English usage here. Floating point issues? Please read this before posting.

    How do things fly? This explains it all.

    Actually they can't: "Heavier-than-air flying machines are impossible." - Lord Kelvin, president, Royal Society, 1895.

  3. #3
    Join Date
    Nov 2001
    Yes Inlcuding is defininately a big help with this when it;s available. Likewise most compilers do a decent job of inlining on thier own.

    In the Case of .Net the inlining is done at run time when the MSIL is compiled to machine code, it keeps statitics on each fuction that's been JIT'd, and will inline based on those statitics when another function is converted that uses the already converted ones.

    However compiler's do not do quite as well with inlining when they cross .dll or.exe boundries. This is the one case I can think of, where inlining (or inlcuding) the function in a dll or callable program into the main one might be usefull on a very rare occasion. I'm assumign that JIT's do a better job of inlining across .dll boundries, but I was not able to determine if that is the case with a little research on my end.

Similar Threads

  1. HPC - Litteral's Reduction in OO
    By dgavin in forum Coder Talk
    Replies: 20
    Last Post: 2013-Jan-04, 05:57 PM
  2. Meade DS-10 Old Adds/Instruction Manual Web Site?
    By Mr Q in forum Astronomical Observing, Equipment and Accessories
    Replies: 1
    Last Post: 2008-Mar-12, 12:31 AM
  3. X-Prize Founder Branching Out!
    By DigitalKnight in forum Off-Topic Babbling
    Replies: 2
    Last Post: 2005-Oct-04, 07:35 PM
  4. Nancy's been looking at a weapon of math instruction
    By Grizzly in forum Against the Mainstream
    Replies: 4
    Last Post: 2004-Jul-30, 08:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts