Beruflich Dokumente
Kultur Dokumente
Stephen Blair-Chappell
12/13/2007 2
Copyright 2007, Intel Corporation. All rights reserved.
*Other brands and names are the property of their respective owners
Compiler Support For Multi-Core
Agenda
Optimisation
Security
Quality
Compatibility
12/13/2007 3
Copyright 2007, Intel Corporation. All rights reserved.
*Other brands and names are the property of their respective owners
Compiler Support For Multi-Core
Optimisations
Global Compiler Options
Inter-procedural Optimisations
Profile Guided Optimisations
Vectorisation
Parallelisation
12/13/2007 4
Copyright 2007, Intel Corporation. All rights reserved.
*Other brands and names are the property of their respective owners
Compiler Support For Multi-Core
Common Optimization Switches
-openmp /Qopenmp
OpenMP 2.5 support
-fast /fast
Optimize for speed, including IPO
-parallel /Qparallel
Automatic parallelization
-ipo /Qipo
Inter-procedural optimization
-prof-gen
-prof-use
/Qprof-gen
/Qprof-use
Profile guided optimization (muli-step build)
Linux & Mac OS* WINDOWS
/Zi
/O3
/O2
/O1
/Og
-g
Create symbols for debugging
-O3
High-level optimizer, including prefetch, unroll
-O2
Optimize for speed (default)
-O1
Optimize for speed (no code size increase)
-O0
Disable optimization
Itanium and the Intel logo are trademarks or registered trademarks of Intel
Corporation or its subsidiaries in the United States or other countries
12/13/2007 5
Copyright 2007, Intel Corporation. All rights reserved.
*Other brands and names are the property of their respective owners
Compiler Support For Multi-Core
Optimisations
Global Compiler Options
Inter-procedural Optimisations
Profile Guided Optimisations
Vectorisation
Parallelisation
12/13/2007 6
Copyright 2007, Intel Corporation. All rights reserved.
*Other brands and names are the property of their respective owners
Compiler Support For Multi-Core
Interprocedural Optimizations
Enables inlining, better register usage, dead
code elimination, etc.
usage:
icpc -ip: single file IPO
icpc -ipo: multi-file IPO
Link time code generation - increases build
time
IPO: Two Step Process
Usability Tips:
Try IPO on performance critical files/libs
Dont run ipo on 10,000s object files,
avoid unnecessary increased build time
Remember to link with -ipo option
Pass 1
Pass 2
ipo objects
executable
Compiling:
icpc -c -ipo a.cxx b.cxx
Linking:
icpc -ipo a.o b.o
12/13/2007 7
Copyright 2007, Intel Corporation. All rights reserved.
*Other brands and names are the property of their respective owners
Compiler Support For Multi-Core
Interprocedural Optimization
Extends optimizations across file boundaries
Compile & Optimize Compile & Optimize
Compile & Optimize Compile & Optimize
Compile & Optimize Compile & Optimize
Compile & Optimize Compile & Optimize
file1.c
file2.c
file3.c
file4.c
Without IPO
Without IPO
Compile & Optimize Compile & Optimize
file1.c
file4.c file2.c
file3.c
With IPO
With IPO
Modules of multiple files/whole application -ipo
Only between modules of one source file -ip
12/13/2007 8
Copyright 2007, Intel Corporation. All rights reserved.
*Other brands and names are the property of their respective owners
Compiler Support For Multi-Core
Optimisations
Global Compiler Options
Inter-procedural Optimisations
Profile Guided Optimisations
Vectorisation
Parallelisation
12/13/2007 9
Copyright 2007, Intel Corporation. All rights reserved.
*Other brands and names are the property of their respective owners
Compiler Support For Multi-Core
Profile-Guided
Optimizations
Optimizing with runtime feedback
Enhances all optimizations, especially
IPO, register allocation, instruction
cache usage, switch statement
optimization, etc
Code-Coverage and Test-Prioritization
Tools uses PGO technology
Usability Tips:
- Run on typical input dataset(s)
- Each run generates a data file.
- Compiler calculates averages of all runs
12/13/2007 10
Copyright 2007, Intel Corporation. All rights reserved.
*Other brands and names are the property of their respective owners
Compiler Support For Multi-Core
Profile-Guided Optimizations (PGO)
Use execution-time feedback to guide (final) optimization
Helps I-cache, paging, branch-prediction
Enabled optimizations:
Basic block ordering
Better register allocation
Better decision on which functions to inline
Function ordering
Switch-statement optimization
12/13/2007 11
Copyright 2007, Intel Corporation. All rights reserved.
*Other brands and names are the property of their respective owners
Compiler Support For Multi-Core
Optimisations
Global Compiler Options
Inter-procedural Optimisations
Profile Guided Optimisations
Vectorisation
Parallelisation
12/13/2007 12
Copyright 2007, Intel Corporation. All rights reserved.
*Other brands and names are the property of their respective owners
Compiler Support For Multi-Core
Automatic Compiler Vectorization
Processor Specific Optimizations
Automatically generate vector SSE/SSE2/SSE3/SSSE3/SSE4
Vector processing: Operate at once on:
4 floating point values
2 double precision floating point values
4 integer values
Etc
Optimal code generation and instruction scheduling
Large number of options for advanced control of vectorization
Specify trip count, ignore dependencies (ivdep), specify alignme Specify trip count, ignore dependencies (ivdep), specify alignment, nt,
disable vectorization, etc. disable vectorization, etc.
12/13/2007 13
Copyright 2007, Intel Corporation. All rights reserved.
*Other brands and names are the property of their respective owners
Compiler Support For Multi-Core
Auto-Vectorization (IA-32 and Intel
64):
Optimizing Loops with SSE/SSE2/SSE3/SSSE3/SSE4
Your Task: convert this
$ cat w.c
void work( float* a, float *b, float *c, int MAX) {
for (int I=0;I<=MAX;I++)
c[I]=a[I]+b[I]; }
128-bit Registers
128-bit Registers
A[0]
B[0]
C[0]
+
+
+
+
+
+
+
+
A[1]
B[1]
C[1]
not used not used not used
not used not used not used
not used not used not used
12/13/2007 14
Copyright 2007, Intel Corporation. All rights reserved.
*Other brands and names are the property of their respective owners
Compiler Support For Multi-Core
IA32
Red Hat EL3
SuSE SLES 10
SGI Propack v4.0
SGI Propack v5.0
Red Flag DC Server5.0
Red Hat EL4
Red Hat Fedora Core 5
Turbo Linux 10
Mandriva/Mandrake 10.1
Red Hat Fedora Core 4
Haansoft Linux 2006 Server
Miracle Linux v4.0
SuSE SLES9
Linux Distros
IPF Intel 64
12/13/2007 41
Copyright 2007, Intel Corporation. All rights reserved.
*Other brands and names are the property of their respective owners
Compiler Support For Multi-Core
Additional Resources
Intel C++ Compiler for Linux* product website
http://www.intel.com/software/products/compilers/clin
Active User Forum http://softwarecommunity.intel.com/isn/Community/en-
US/forums/1016/ShowForum.aspx
C++ Compiler White Papers at http://www3.intel.com/cd/software/products/asmo-
na/eng/278608.htm
Useful White Papers
Quick Reference Guide White Paper - http://cache-
www.intel.com/cd/00/00/22/23/222300_222300.pdf
Optimization Guide White Paper - http://cache-
www.intel.com/cd/00/00/27/66/276615_276615.pdf
gcc/g++ compatibility White Paper - http://cache-
www.intel.com/cd/00/00/28/47/284736_284736.pdf
Code Coverage White Paper - http://cache-
www.intel.com/cd/00/00/21/92/219280_compiler_code-coverage.pdf
Security White Paper - : http://cache-
www.intel.com/cd/00/00/37/03/370307_370307.pdf