On Libra, what are the recommended compiler switches?
This document explains some of the most commonly used compiler switches on the Libra system at Indiana University (for example, which switches you can use to compile a 32-bit application that requires more than 256MB of memory).
Debug mode
You can use the -g switch when compiling code
on Libra to force debug mode to be turned on. This prevents many of
the optimizations listed below, so use it only if you plan to
debug code.
Architecture-specific performance tuning switches
The Libra Cluster includes two hardware architectures listed below. Depending on the node(s) you plan to run your code on, you will need to use appropriate switches as explained below:
-
Nodes Libra01-42: These use IBM PowerPC970
architecture. If you plan to run your code on these
nodes, use compile time switches
-qarch=ppc970 -qtune=ppc970to optimize it and take advantage of the IBM PowerPC970 architecture.For example, to compile your C program, you would use something similar to:
xlc -o my_program my_program.c -qarch=ppc970 -qtune=ppc970 -
Nodes Libra43 and Libra47-50 (the SMP nodes):
These nodes are P575s and use IBM Power5 architecture. If you plan to
run your code on these nodes, use compile time
switches
-qarch=pwr5 -qtune=pwr5to optimize it and take advantage of the IBM Power5 architecture.For example, to compile your C program, you would use something like:
xlc -o my_program my_program.c -qarch=pwr5 -qtune=pwr5
Performance optimization switches
- You could also use the
-O<n>switches (uppercase characterOfollowed by an integer) to optimize at your chosen level of optimization. For example,-O3will perform some memory and compile-time intensive optimizations.Caveats:
- The optimizations performed by the
-O3switch could alter your program's semantics; use the-qstrictswitch to turn off these aggressive optimizations. - On the other hand, if you want even more aggressive optimization,
you could look into switches such as
-qhotand-O4, though UITS does not recommend them unless you know exactly what you are doing. - For more information, see your compiler's man page
(for example, try
man xlc).
- The optimizations performed by the
64-bit compiler mode
Assuming 64-bit compiler mode is supported by your application and
the libraries your program uses, you might compile with the
-q64 switch, especially if your program requires more
than 256MB of memory for data.
If you are not sure about 64-bit compiler mode compatibility, you
might want to use the -qwarn64 switch; it checks for
possible data conversion problems between 32-bit and 64-bit compiler
modes.
For example, to compile your C program, you would use something similar to:
xlc -o my_program my_program.c -q64 -qwarn64 -qarch=ppc970 -qtune=ppc97032-bit applications with large memory requirements (i.e., applications incompatible with the 64-bit compiler mode)
If your application/library does not support the 64-bit compiler mode, you can use a couple of switches to get additional data/stack segments:
- You can use the
-bmaxdata:<NUM>switch to specify the number of data segments (each segment is 256MB), i.e., to set the maximum size of the area shared by the static data (both initialized and uninitialized) and the heap to <NUM> bytes.For example, to request two segments for data, i.e., 512MB, you can use the following compile string:
xlc -o my_program my_program.c -bmaxdata:536870912- You could also use hexadecimal notation to indicate the number
of segments:
-bmaxdata:0x20000000 - You can ask for a maximum of eight segments for a 32-bit
application by specifying
-bmaxdata:0x80000000
- You could also use hexadecimal notation to indicate the number
of segments:
- You can use the
-bmaxstack:<NUM>switch to specify the amount of stack space that should be allocated for your program. The maximum size of the stack for 32-bit applications is 256MB and can be declared by using-bmaxstack:268435456.
Also see:
Last modified on January 15, 2008.






