Re: Can I run applications run completely from of CPU cache
Joseph Hadzima <[email protected]> Sat, 12 Nov 2005 08:39:22 -0800 (PST)
| Newsgroups | gmane.comp.programming.cppug |
|---|---|
| Message-ID | <[email protected]> |
Hello Vishal This is the function of the "instruction" cache. If your machine has one, and your application's main execution loop fits within the instruction cache, then you're covered automatically. The slowest part of the application you describe, is accessing the data. Does your application access the same memory address more than once? If you are doing several different types of tests on the memory (walking 1's, patterns, etc.). Then design your application so it does ALL the tests on a block of memory which fits in the "Data" cache, before moving to another block. Data cache can be as much of a bottle neck to processing as a help, just based upon the way you write your application. I do DSP (Digital Signal Processing) and a usual application is to run an DFT algorithm on a 2 dimensional matrix. If the entire matrix will not fit in the cash, then the typical idea of running the algorithm first on the rows, and then on the columns is very slow. However if I write my application to do only the part of the rows which fit into the cache, then work the columns, that are part of those rows, then my data is in cache for both parts. Since most cache algorithms replace the "oldest" row when a memory access from the CPU requests a memory address which has is not cached, when I go back to work the first column, the CPU gets a "cache miss", and need to wait while the "cache line" for that memory address is RELOADED. So, if I do an entire row, and then do the columns, the first row, would be over written, and there would be a slight delay while the line I want gets reloaded. Thus, the general rules are: (1) Design your application to do every thing it has to do to the data that resides in cache, before moving onto the next block of data. (2) Work on continuous memory address whenever possible. The cache only loads an entire cache line at a time. So if your application reads bytes from random memory addresses, your machine is actually loading 32 bytes (or whatever your machine's cache line size is) into the cache before your CPU gets to read the single byte. This true for most PPC based machines, you'll need to check how your cache works. (3) Start each data block on a cache boundary. If a cache line is 32 bytes (8, 32bit words), it loads the cache with 32 bytes, starting at a 32 byte multiple. Thus, reading blocks of memory where the starting address is not at a multiple of 32, causes the cache to load extra data bytes. I don't know what machine or OS you're using, but the above are very general rules to think about when working with caches. So, I would (1) concentrate on how your application access data, and thus how efficiently it uses the data cache, and (2) modularize your application so if the entire application doesn't fit in the instruction cache, then each test will. I believe number 1 above will show you the most improvement. I hope this helps, and I hope you'll share some of your test with the group! hadz. --- vsapre80 <[email protected]> wrote: > Hi, > > is there a way I could get all my code (if I know its > small enough) > into the cache, and then run all instructions from the > CPU cache? The > data bits could still come from the main memory. > > I am looking for a main memory test program, which has to > test almost > the whole memory, except, ofcourse, the resident part of > the OS etc... > This program should also be as fast as possible. > > hence the idea. > > Any takers?? Any thoughts, suggestions ?? > > Vishal > > > > > > ------------------------ Yahoo! Groups Sponsor > --------------------~--> > Get Bzzzy! (real tools to help you find a job). Welcome > to the Sweet Life. > http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/EbFolB/TM > --------------------------------------------------------------------~-> > > > > Yahoo! Groups Links > > > > > > > > HADZ. The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man. --George Bernard Shaw, Man and Superman (1903) "Maxims for Revolutionists" Irish dramatist & socialist (1856 - 1950) (this email sent using 100% recycled electrons) ------------------------ Yahoo! Groups Sponsor --------------------~--> Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life. http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/EbFolB/TM --------------------------------------------------------------------~-> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/cppug/ <*> To unsubscribe from this group, send an email to: [email protected] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/