C ache Analyzer

W
Description

C ache Analyzer

Shared by: benbenzhou
Categories
Tags
-
Stats
views:
6
posted:
7/29/2010
language:
English
pages:
13
Document Sample
scope of work template
							                                                                                                       Cache Analyzer




                 Technical Information




                                         Cache Analyzer


                                                          s     Basic support for all microcontrollers
                                                          s     Advanced support for ARM architecture
                                                          s     Optimize instruction and data cache usage
                                                          s     Find bus transfer bottlenecks
                                                          s     Verify effects of code optimisation
                                                          s     Simulate effects of different cache sizes
                                                          s     Various graphical and numerical displays

                                                          The cache analysis tool provides developers of embedded
                                                          systems with the following benefits:
                                                          1) Optimization of program run times
                                                          2) Reduction in power consumption of the entire system
                                                          Cache analysis can be performed on all microcontrollers,
                                                          cache architectures, and cache hierarchies. If required,
                                                          the predefined cache structure of microcontrollers can
Cache Analyzer




                                                          also be modified. In this way, an alternative cache struc-
                                                          ture can be tested to
                                                          determine if its use will lead to greater cache efficiency
                                                          and therefore shorten program run times. The result can
                                                          then be taken into account for future designs.
                          26.03.10
TRACE32 - Technical Information                                                                    2



Cache Analyzer

                   Overview
                   Microcontrollers that operate at rates of   the TRACE32-PowerTrace micropro-
                   more than 200 MHz can only achieve          cessor development tool is used to
                   optimum program run times in embed-         analyze the relationship between
                   ded systems if their caches are used        cache efficiency and program run
                   efficiently. This article describes how     times.



                   Introduction
                   A cache is a small, fast memory that is     gram instructions or data items
                   generally integrated directly in the        required because of its small size (128
                   microcontroller. Individual program         KB to 1 MB). As a result, various parts
                   parts are temporarily stored in the         of the program compete for space in
                   cache so that the microcontroller does      the cache and evict each other. The
                   not have to retrieve each program           cache structure determines which pro-
                   instruction or data item from the slow      gram parts compete for a place in the
                   external memory. However, the cache         cache and constantly replace other
                   can only store a limited number of pro-     program parts.



                   Cache Addressing
                   Short sections of program (usually 16
                   or 32 bytes) can be temporarily stored      Cache addressing uses the memory
                   in a cache line to enable quick access.     address to determine in which cache
                   Cache addressing, which is defined by       line the required program part is to be
                   the cache structure, determines in          temporarily stored. The analyses dis-
                   which cache line the instructions and       cussed in this article use a 2-way set
                   data items of individual memory             associative cache. In a 2-way set asso-
                   addresses are stored. As the memory         ciative cache two cache lines are
                   address mapping on the cache line           allowed to hold the instructions or data
                   provides the basis for analyzing cache      of a memory address.
                   efficiency, it is necessary to understand
                   the process of cache addressing.




Cache Analyzer
 Cache Analyzer
TRACE32 - Technical Information                                                                        3




                                              Tag      Cache line


                                                    Tag       Cache line




                                         Figure 1: Diagram of a 2-way associative cache


                                                                     ❏ Bits [12..4] are used to select the
                      The given example of a cache has the              cache line (9 bits for 512 cache
                      following data:                                   lines)
                        ❏ 16 bytes per cache line                    ❏ Bits [31..13] are entered as the
                                                                        tag in the cache line. The bits
                        ❏ 512 cache lines                               [31..13] of a memory address are
                                                                        compared with the tag to
                      Using this data, a 32-bit memory is               determine whether a program
                      mapped as follows to a cache line:                instruction or data item is already
                                                                        stored in a cache line.
                        ❏ Bits [3..0] are used to determine
                            the address of the word/byte
                            within the cache line
                            (4 bits for 16 bytes per cache line)


                 31                      13 12                             4 3                        0
                                                                                 Word/byte in the
                        Tag entry              Cache line selection
                                                                                 cache line

                 Figure 2: In the example of a cache, the bits [12..4] of the memory address
                 determine in which cache line the program instructions/data items are
                 to be temporarily stored.

                                                                   This type of cache addressing means
                                                                   that all program parts that match the
                                                                   address defined in bits [12..4] are
                                                                   stored in the same cache line. For
                                                                   example, the following memory
                                                                   addresses are competing for the cache
                                                                   line 0x15:

                                                                   0x8150: 0000 0000 0000 0000
                                                                   100 0 0001 0101 0000
                                                                   0xA150: 0000 0000 0000 0000
                                                                   101 0 0001 0101 0000




Cache Analyzer
Cache Analyzer
TRACE32 - Technical Information                                                                        4

                       0xC150: 0000 0000 0000 0000                      times slower than when the data
                       110 0 0001 0101 0000                             is stored in the cache. Each time
                                                                        the external memory is accessed,
                       If three or more addresses compete for           the program execution time slows
                       the same cache line in a 2-way asso-             down considerably.
                       ciative cache, the memory contents of         ❏ Each time the external memory is
                       the address are repeatedly evicted               accessed, the power
                       from the cache. When an entry is                 consumption of the entire system
                       replaced, the evicted cache contents             increases immediately by a
                       have to be reloaded into the cache               significant level . This is a great
                       when the program requires them again.            disadvantage for portable,
                                                                        battery-powered devices.
                       The contents have to be accessed from
                       the external memory each time. This is
                                                                   The best way to reduce the frequency
                       to be avoided if possible for the follow-
                                                                   with which the external memory is
                       ing reasons:
                                                                   accessed, is to prevent unnecessary
                         ❏ Current access times for external       eviction from the cache. Unnecessary
                             memories show that the rate at        eviction always occurs when several
                             which an instruction or data item     memory addresses compete for a lim-
                             is retrieved from the external        ited number of cache lines, while other
                             memory, is on average, 10 to 30       cache lines are hardly being used, if at
                                                                   all.




                 Figure 3: Several memory addresses compete for a limited number of cache
                 lines, while other cache lines are hardly used.




Cache Analyzer
Cache Analyzer
TRACE32 - Technical Information                                                                   5

                   Cache efficiency can be optimized by       ory in such a way that competition for
                   modifying the relocation information in    cache lines is distributed as evenly as
                   the linker command file so that func-      possible.
                   tions and data are placed in the mem-




                     Figure 4: Competition for cache lines is distributed evenly.

                                                              cache. Since October 2004, Lauter-
                   Before developers of embedded              bach Datentechnik GmbH has provided
                   designs can optimize the positioning of    a cache analysis tool for its TRACE32-
                   functions and data in the memory, they     PowerTrace microprocessor develop-
                   require an analysis tool that can trace    ment system.
                   any unnecessary eviction from the



                   Cache Analysis
                   Before describing how to carry out a         ❏ Cache miss: An instruction or
                   cache analysis, here is a short defini-          data item required by the
                   tion of some important terms:                    program that is not located in the
                                                                    cache and therefore has to be
                     ❏ Cache hit: An instruction or data            loaded from the external memory.
                        item required by the program that
                        is located in the cache.                ❏ Cache victim: An instruction or
                                                                    data item evicted from the cache,
                                                                    in order to create a cache miss
                                                                    place for the program part
                                                                    currently required.




Cache Analyzer
Cache Analyzer
TRACE32 - Technical Information                                                                        6

                   The following steps are required to         ture
                   carry out a cache analysis using
                   TRACE32-PowerTrace for a selected           The TRACE32 software identifies the
                   system function (for example, image         cache structure of the microcontroller
                   compression for a cellular telephone):      used in the target system. The instruc-
                                                               tion cache (IC) has the same cache
                                                               structure as the cache structure
                   Identifying the cache struc-                described in the introduction.




                    Figure 5: Automatic definition of the cache structure of the microcontroller



                                                               Evaluating the results of the
                   The software can identify all cache         analysis
                   structures and cache hierarchies cur-
                   rently available on the market, includ-     Cache analysis determines the cache
                   ing level 2/level 3 caches. TRACE32         hit, cache miss, and cache victim rates
                   also supports cache structures that         for the recorded program and data flow
                   have been configured using a memory         based on the defined cache structure.
                   protection unit (MPU) or a memory
                   management unit (MMU).                      To avoid unnecessary eviction from the
                                                               cache, the following information is
                                                               required:
                   Recording program and data
                                                                 ❏ Which cache lines have a
                   flow in the trace memory                           particularly high cache victim
                   Cache analysis is based on the pro-                rate?
                   gram and data flow recorded in the            ❏ Which parts of the program are
                   trace memory. TRACE32-PowerTrace                   competing for these lines?
                   provides a 128-MFrame trace memory,
                   which can record up to 10 seconds of
                                                                 ❏ Are there any cache lines that are
                                                                      not, or hardly, being used?
                   program run time.




Cache Analyzer
Cache Analyzer
TRACE32 - Technical Information                                                                    7




                                  Figure 6: Analysis of the cache hit/cache miss/cache victim rates fo
                                  instruction cache (IC) and data (DC) caches




                       Figure 7: Analysis of the cache hit/cache miss/cache victim rates for the
                       individual cache lines of the instruction cache




                     Figure 8: List of program addresses competing for cache line 0x15 of the
                     instruction cache




Cache Analyzer
Cache Analyzer
TRACE32 - Technical Information                                                                 8

                                                            therefore, eviction will always occur,
                   Figure 8 in the above analysis shows     resulting in cache victims. At the same
                   that the program instructions at the     time, cache line 0x19 is completely
                   addresses, 0x8150, 0xA150, and           unused. By redirecting the address of
                   0xC150, are competing for the cache      one of the competing program instruc-
                   line 0x15. The above example uses a      tions to the end address 0x190, the
                   cache in which each cache line has two   competition can be removed from
                   locations in the cache (2-way associa-   cache line 0x15 and there will be no
                   tive cache). Three program addresses     further cache victims.
                   are competing for one cache line;




Cache Analyzer
Cache Analyzer
TRACE32 - Technical Information                                                                         9



                        Relationship Between Cache Efficiency and Program
                        Run Time
                        As described in the previous section,      between program run time and cache
                        cache analysis is based on the pro-        efficiency can be measured and veri-
                        gram and data flow recorded in the         fied using TRACE32-PowerTrace.
                        trace memory. As all entries in the
                        trace memory have a time stamp, the        Figure 9 shows how the function ana-
                        trace contents are used as the basis for   lyzed has a cache hit rate of 79% and a
                        run time measurements. This has the        cache victim rate of 21% for the cache
                        advantage that the direct relationship     line 0x15.




                         Figure 9: Graphical analysis of the cache hit/cache victim rates for the cache line
                                  0x15.




                        The high rate of replacement also
                        becomes apparent when the function’s
                        run time is studied. The average run
                        time of the function (sievebad) is 77.6
                        us.




                 Figure 10: Run-time analysis of the sievebad function using
                 TRACE32-PowerTrace




Cache Analyzer
Cache Analyzer
TRACE32 - Technical Information                                                                     10

                                                                mized function (sievegood) shows an
                   By redirecting the address of one of the     immediate and considerable improve-
                   competing program instructions to the        ment in run-time performance. The run
                   end address 0x190, the competition is        time is on average only 7.9 us.
                   removed from cache line 0x15. As only
                   two addresses are now competing for
                   this cache line, there is no need for fur-
                   ther eviction. An analysis of the opti-




                           Figure 11: Run-time analysis of the sievegood function using
                                     TRACE32-PowerTrace



                                                                actually leads to the predicted improve-
                   Using a combination of cache analysis        ment in run times. It can also be used
                   and run-time measurements, develop-          to investigate if code optimizations
                   ers can use TRACE32-PowerTrace to            impair cache efficiency and therefore
                   test whether optimized cache efficiency      do not improve program run times.



                   Summary
                   The latest cache analysis tool from          required, the predefined cache struc-
                   Lauterbach Datentechnik GmbH pro-            ture of microcontrollers can also be
                   vides developers of embedded sys-            modified. In this way, an alternative
                   tems with the following benefits:            cache structure can be tested to deter-
                                                                mine if its use will lead to greater cache
                                                                efficiency and therefore shorten pro-
                     ❏ Optimization of program run
                                                                gram run times. The result can then be
                         times
                                                                taken into account for future designs.
                     ❏ Reduction in power consumption
                         of the entire system

                   Cache analysis can be performed on
                   all microcontrollers, cache architec-
                   tures, and cache hierarchies. If




Cache Analyzer
Cache Analyzer
TRACE32 - Technical Information                                                                 11



Contact

                   International Representative
                     Australia                              Finland
                      Embedded Logic Solutions Pty L         Nohau
                      Mr. Ramzi Kattan                       Mr. Leevi Lehtinen
                      391 Hume Highway                       Teknobulevardi 3-5
                      Bankstown NSW 2200                     FI-01531 Vantaa
                      Phone: ++61 2 9793 9542                Phone: ++358 40 546 1469
                      FAX: ++61 2 9790 1183                  FAX: ++358 9 2517 8101
                      EMAIL: sales@emlogic.com.au            EMAIL: leevi.lehtinen@nohau.se

                     Austria                                France
                      Lauterbach Datentechnik GmbH           Logic Instrument
                      Mr. Norbert Weiss                      Mr. Stephane Morice
                      Fichtenstr. 27                         BP 116
                      D-85649 Hofolding                      71, route de Saint-Denis
                      Phone: ++49 8104 8943 183              F-95170 Deuil la Barre
                      FAX: ++49 8104 8943 170                Phone: ++33 1 342861 70
                      EMAIL: info_de@lauterbach.com          FAX: ++33 1 342800 50
                                                             EMAIL: s.morice@logic-instrument.com
                     Belgium
                      Tritec Benelux B.V.                   Germany
                      Mr. Robbert de Voogt                   Lauterbach Datentechnik GmbH
                      Stationspark 550                       Mr. Norbert Weiss
                      NL-3364 DA Sliedrecht                  Fichtenstr. 27
                      Phone: ++31 184 41 41 31               D-85649 Hofolding
                      FAX: ++31 184 42 36 11                 Phone: ++49 8104 8943 183
                      EMAIL: software@tritec.nl              FAX: ++49 8104 8943 170
                                                             EMAIL: info_de@lauterbach.com
                     Brazil
                      ANACOM Software e Hardware Ltd        Germany North
                      Mr. Rodrigo Ferreira                   Lauterbach Datentechnik GmbH
                      Rua Nazareth, 807, Bairro Barc         Mr. Klaus Hommann
                      BR-09551-200 Sao Caetano do Sul        Leonhardring 5
                      Phone: 0055 11 3422-4200               D-31319 Sehnde
                      FAX: 0055 11 3422-4242                 Phone: ++49 5138 6185 0
                      EMAIL: rferreira@anacom.com.br         FAX: ++49 5138 6185 3
                                                             EMAIL: klaus.hommann@lauterbach.com
                     Canada
                      Lauterbach Inc.                       India
                      4 Mount Royal Ave.                     Electro Systems Ass. Pvt. Ltd.
                      USA-Marlborough, MA 01752              Mr. G. V. Gurunatham
                      Phone: ++1 508 303 6812                4215 JK Complex First Main Rd.
                      FAX: ++1 508 303 6813                  IND-Bangalore 560 021
                      EMAIL: info_us@lauterbach.com          Phone: ++91 80 23577924
                                                             FAX: ++91 80 23475615
                     China                                   EMAIL: esaindia@vsnl.com
                      Watertek Inc.                         Ireland
                      Mr. Liu Ming
                      Room 1006, Hai Tai Building            Lauterbach Ltd.
                      No.229,North Si Huan Zhong Rd.         Mr. Barry Lock
                      PRC-Beijing Hai Dian Distr., 100083    11 Basepoint Enterprise Centre
                      Phone: +86 10 82883933-680             Stroudley Road
                      FAX: +86 10 82883858                   Basingstoke, Hants RG24 8UP
                      EMAIL: sales@watertek.com              Phone: ++44-1256-333-690
                                                             FAX: ++44-1256-336-661
                     Denmark                                 EMAIL: info_uk@lauterbach.com
                      Nohau Danmark A/S                     Israel
                      Mr. Flemming Jensen
                      Klausdalsbrovej 493                    Itec Ltd.
                      DK-2730 Herlev                         Mr. Mauri Gottlieb
                      Phone: ++45 44 52 16 50                P.O.Box 10002
                      FAX: ++45 44 52 26 55                  IL-Tel Aviv 61100
                      EMAIL: info@nohau.dk                   Phone: ++972 3 6491202
                                                             FAX: ++972 3 6497661
                     Egypt                                   EMAIL: general@itec.co.il
                      Wantech                               Italy
                      Mr. Nawara
                      5 Shafik Ghalie St., Suite 2           Lauterbach Srl
                      Off Pyramids Road, Giza                Mr. Maurizio Menegotto
                      Cairo 12111                            Via Enzo Ferrieri 12
                      Phone: ++20 2 5848020                  I-20153 Milano
                      FAX: ++20 2 5877303                    Phone: ++39 02 45490282
                      EMAIL: sales@wantechnet.com            FAX: ++39 02 45490428
                                                             EMAIL: info_it@lauterbach.com




Cache Analyzer
 Contact
TRACE32 - Technical Information                                                             12

                     Japan                             South Korea
                      Lauterbach Japan, Ltd.            MDS Technology Co.,Ltd.
                      Mr. Kenji Furukawa                Mr. Hyunchul Kim
                      3-9-5 Shinyokohama                15F Kolon Digital Tower Vilant
                      Kouhoku-ku                        #222-7, Guro-3dong, Guro-gu
                      Yokohama-shi, Japan 222-0033      Seoul, 152-848, ROK
                      Phone: ++81-45-477-4511           Phone: ++82 2 2106 6000
                      FAX: ++81-45-477-4519             FAX: ++82 2 2106 6004
                      EMAIL: info@lauterbach.co.jp      EMAIL: trace32@mdstec.com

                     Luxemburg                         Spain
                      Tritec Benelux B.V.               Captura Electronica,SCCL
                      Mr. Robbert de Voogt              Mr. Juan Martinez
                      Stationspark 550                  c/Albert Einstein s/n
                      NL-3364 DA Sliedrecht             Edificio Forum de la Tecnol.
                      Phone: ++31 184 41 41 31          E-08042 Barcelona
                      FAX: ++31 184 42 36 11            Phone: ++34 93 291 76 33
                      EMAIL: software@tritec.nl         FAX: ++34 93 291 76 35
                                                        EMAIL: info@captura-el.com
                     Malaysia
                      Flash Technology                 Sweden
                      Mr. Teo Kian Hock                 Nohau Elektronik AB
                      No 61, # 04-15 Kaki Bukit Av 1    Mr.Greger Andersson
                      Shun Li Industrial Park           Derbyvägen 4
                      SGP-Singapore 417943              SE-21235 Malmoe
                      Phone: ++65 6749 6168             Phone: ++46 40 59 22 00
                      FAX: ++65 6749 6138               FAX: ++46 40 59 22 29
                      EMAIL: flashsgp@pacific.net.sg    EMAIL: info@nohau.se

                     Netherlands                       Switzerland
                      Tritec Benelux B.V.               JDT Jberg DatenTechnik
                      Mr. Robbert de Voogt              Mr. Andreas Iberg
                      Stationspark 550                  Zimmereistrasse 2
                      NL-3364 DA Sliedrecht             CH-5734 Reinach AG
                      Phone: ++31 184 41 41 31          Phone: ++41 62 7710 886
                      FAX: ++31 184 42 36 11            FAX: ++41 62 7717 187
                      EMAIL: software@tritec.nl         EMAIL: Andreas.Jberg@jdt.ch

                     New Zealand                       Taiwan
                      Embedded Logic Solutions Pty L    Superlink Technology Corp.
                      Mr. Ramzi Kattan                  Mr. Sulin Huang
                      391 Hume Highway                  3F-8,No.77,Shin-Tai-Wu Rd.Sec1
                      Bankstown NSW 2200                Taipei Hsien 221, Taiwan, R.O.C.
                      Phone: ++61 2 9793 9542           Phone: ++886 2 26983456
                      FAX: ++61 2 9790 1183             FAX: ++886 2 26983535
                      EMAIL: sales@emlogic.com.au       EMAIL: stc@tpts1.seed.net.tw

                     Norway                            Turkey
                      Nohau Elektronik AB               Bildem Bilgisayar Ltd. Sti.
                      Mr. Greger Andersson              Mr. Hakan Yavuz
                      Derbyvägen 4                      Koroglu Cad. 64/3 G.O.Pasa
                      S-21235 Malmoe                    TR-06700 Ankara
                      Phone: ++46 40 59 22 00           Phone: ++90 312 4472700
                      FAX: ++46 40 59 22 29             FAX: ++90 312 4472702
                      EMAIL: info@nohau.se              EMAIL: info@bildem.com.tr

                     Poland                            UK
                      Quantum Sp.z o.o. Korp. Transf    Lauterbach Ltd.
                      Mr. Czeslaw Bil                   Mr. Barry Lock
                      ul. Skwierzynska 21               11 Basepoint Enterprise Centre
                      53-521 Wroclaw                    Stroudley Rd
                      Phone: ++48 71 362 6356           Basingstoke, Hants RG24 8UP
                      FAX: ++48 71 362 6357             Phone: ++44 (0) 1256-333690
                      EMAIL: bil@quantum.com.pl         FAX: ++44 (0) 1256-336661
                                                        EMAIL: info_uk@lauterbach.com
                     Portugal
                      Captura Electronica,SCCL         USA East
                      Mr. Juan Martinez                 Lauterbach Inc.
                      c/Albert Einstein s/n             Mr. Udo Zoettler
                      Edificio Forum de la Tecnol.      4 Mount Royal Ave.
                      E-08042 Barcelona                 USA-Marlborough, MA 01752
                      Phone: ++34 93 291 76 33          Phone: ++1 508 303 6812
                      FAX: ++34 93 291 76 35            FAX: ++1 508 303 6813
                      EMAIL: info@captura-el.com        EMAIL: info_us@lauterbach.com

                     Singapore                         USA West
                      Flash Technology                  Lauterbach Inc.
                      Mr. Teo Kian Hock                 Mr. Jerry Flake
                      No 61, # 04-15 Kaki Bukit Av 1    13256 SW. Hillshire Drive
                      Shun Li Industrial Park           USA-Tigard, OR 97223
                      SGP-Singapore 417943              Phone: ++1 503 524 2222
                      Phone: ++65 6749 6168             FAX: (503) 524 2223
                      FAX: ++65 6749 6138               EMAIL: jerry.flake@lauterbach.com
                      EMAIL: flashsgp@pacific.net.sg




Cache Analyzer
Contact
TRACE32 - Technical Information                                                                     13



                   Additional Information


                      http://www.lauterbach.com

                     Lauterbach Datentechnik GmbH                   Lauterbach Japan, Ltd.
                      Fichtenstr. 27                                 3-9-5 Shinyokohama Kouhoku-ku
                      D-85649 Hofolding                              Yokohama-shi Japan 222-0033
                      Tel. ++49 8104 8943-188 FAX -187               Phone ++81-45-477-4511 FAX -4519
                      info@lauterbach.com                            info_j@lauterbach.com
                      http://www.lauterbach.de                       http://www.lauterbach.co.jp

                     Lauterbach Inc.                                Lauterbach s.r.l.
                      4 Mount Royal Ave.                             Lauterbach s.r.l.
                      Marlboro MA 01752                              Via Enzo Ferrieri 12
                      Phone (508) 303 6812 FAX (508) 303 6813        I-20153 Milano
                      info_us@lauterbach.com                         Phone ++39 02 45490282
                      http://www.lauterbach.com/usa                  FAX ++39 02 45490428
                                                                     info_it@lauterbach.it
                     Lauterbach Ltd.                                 http://www.lauterbach.it
                      11 Basepoint Enterprise Ctre Stroudley Road
                      Basingstoke, Hants RG24 8UP
                      Phone ++44-1256-333-690 FAX -661
                      info_uk@lauterbach.com
                      http:/www.lauterbach.co.uk




                   Disclaimer

                      The information presented is intended to give overview information only.
                      Changes and technical enhancements or modifications can be made with-




Cache Analyzer
Contact

						
Related docs
Other docs by benbenzhou
Green Tea Colostrum
Views: 22  |  Downloads: 0
Engr Intro to Engineering
Views: 1  |  Downloads: 0
A BASIC OIL Jojoba Oil
Views: 269  |  Downloads: 0
Palaro_B_030810
Views: 36  |  Downloads: 0
MIT ALOE VERA
Views: 6  |  Downloads: 0