Thread: Cache Optimisations

  1. #1
    Registered User
    Join Date
    Jan 2014
    Posts
    4

    Cache Optimisations

    I have a 125X125 array, each element is 55 bits. The cache line for the CPU ( Cortex A9) is 32 bits. Is there anyway to do optimizations, like loop tiling that would make multiplication and calculations faster?

    Any other ideas that I could try?

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    What does Google show for optimizing code for the Cortex A9?

    Why are you (seemingly) starting optimizations at the cache level? Have all the algorithmic and other optimizations been made already? How much improvement in run time are you looking for?

    Can you post an example of what your program is doing, and the code you're using to do it? Do you have a test case (10-30 seconds worth of run time), which can be used for testing? Have you checked the generated assembly code of your program? Have you profiled the program yet?

  3. #3
    Registered User
    Join Date
    Jan 2014
    Posts
    4
    What does Google show for optimizing code for the Cortex A9?
    I have checked and done some implementation based on that.

    Why are you (seemingly) starting optimizations at the cache level?
    I'm not. All algos have been optimized.

    How much improvement in run time are you looking for?
    Depends on how much time and complexity it takes.

    Do you have a test case (10-30 seconds worth of run time), which can be used for testing? Have you checked the generated assembly code of your program? Have you profiled the program yet?
    Yes.


    I am really just asking a specific question about 55 bytes elements in arrays. If a cache line is 32 bytes then I guess nothing can be done?

    Thanks.

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    I didn't say that. Without seeing the program tested, about all you can say is that you want to flush out the cache as few times as possible, to work with new data.

    Another question, can the data be represented using bits, in a more compact form? What is the widest range of the data? Is there a secondary cache, and if so, what size is it? Have you tried multiplication by bit shifting?

    There might be some forum members who can rattle off something specific, but I would have to study every detail of the data, the algorithm, and make several tests just to start at optimizing at this level - too much work for me to take on, "just because".

  5. #5
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    I'm sorry, it's not possible to ask that we simply trust that you have performed adequate higher-level optimisations and can now only do micro-optimisations.
    If you were really that skilled, then you probably wouldn't be the one asking a question here.
    Or at the least, reputation is to be earned rather than handed out unconditionally.

    Instead, you should try to trust us, and take advantage of what additional wisdom we might impart, about that which you may have overlooked.

    In other words you'll need to post some relevant code. If we are half as skilled as many of us here think we are, then we should easily be able to come to the same conclusion as you, if it is indeed correct.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  6. #6
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Run your code through cachegrind and then get back to us.

    My latest code had something like 0% miss rate because cachegrind truncates so it read 0.0%. That means it's about as optimized for the cache as it's gonna get.

    Try to limit your reads too.

    Also, read this : What every programmer should know about memory, Part 1 [LWN.net]

    This will literally help you with everything you wanted to do and more. At the bottom they have links to other sections on cache optimization so I think it'd be worth looking over.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. D-Cache/I Cache Simulator
    By husslela2 in forum C Programming
    Replies: 7
    Last Post: 04-27-2010, 08:41 AM
  2. Optimisations required for 8 queen problem.
    By chottachatri in forum C Programming
    Replies: 2
    Last Post: 06-28-2009, 10:19 PM
  3. Difference between ARP Cache and DNS cache?
    By namasteall2000 in forum Networking/Device Communication
    Replies: 9
    Last Post: 06-26-2009, 08:49 AM
  4. HTTP Cache
    By PING in forum Tech Board
    Replies: 0
    Last Post: 03-01-2009, 04:01 PM
  5. Cache using c/c++
    By m_kk in forum C Programming
    Replies: 0
    Last Post: 01-28-2008, 09:36 PM