-qcache

Category

Optimization and tuning

Pragma equivalent

None.

Purpose

Specifies the cache configuration for a specific execution machine.

If you know the type of execution system for a program, and that system has its instruction or data cache configured differently from the default case, use this option to specify the exact cache characteristics. The compiler uses this information to calculate the benefits of cache-related optimizations.

Syntax

Read syntax diagramSkip visual syntax diagram
                  .-:-------------------.  .-:------------------------.   
                  V                     |  V                          |   
>>- -q--cache--=----+-level--=--+-1-+-+-+----+----------------------+-+-><
                    |           +-2-+ |      +-assoc--=----number---+     
                    |           '-3-' |      +-auto-----------------+     
                    '-type--=--+-c-+--'      +-cost--=--cycles------+     
                               +-d-+         +-line--=--bytes-------+     
                               '-i-'         '-size--=--Kbytes------'     

Defaults

Automatically determined by the setting of the -qtune option.

Parameters

assoc
Specifies the set associativity of the cache.
number
Is one of:
0
Direct-mapped cache
1
Fully associative cache
N>1
n-way set associative cache
auto
Automatically detects the specific cache configuration of the compiling machine. This assumes that the execution environment will be the same as the compilation environment.
cost
Specifies the performance penalty resulting from a cache miss.
cycles
level
Specifies the level of cache affected. If a machine has more than one level of cache, use a separate -qcache option.
level
Is one of:
1
Basic cache
2
Level-2 cache or, if there is no level-2 cache, the table lookaside buffer (TLB)
3
TLB
line
Specifies the line size of the cache.
bytes
An integer representing the number of bytes of the cache line.
size
Specifies the total size of the cache.
Kbytes
An integer representing the number of kilobytes of the total cache.
type
Specifies that the settings apply to the specified cache_type.
cache_type
Is one of:
c
Combined data and instruction cache
d
Data cache
i
Instruction cache

Usage

The -qtune setting determines the optimal default -qcache settings for most typical compilations. You can use the -qcache to override these default settings. However, if you specify the wrong values for the cache configuration, or run the program on a machine with a different configuration, the program will work correctly but may be slightly slower.

Use the following guidelines when specifying -qcache suboptions:

Predefined macros

None.

Examples

To tune performance for a system with a combined instruction and data level-1 cache, where cache is 2-way associative, 8 KB in size and has 64-byte cache lines, enter:

xlc -O4 -qcache=type=c:level=1:size=8:line=64:assoc=2 file.c

Related information