Building CC++Fortran Applications

Document Sample
Building CC++Fortran Applications Powered By Docstoc
					Building C/C++/Fortran Applications for
OpenSolaris and Linux

Vijay Tatkar
Sr. Engineering Manager, Sun Developer Tools
http://blogs.sun.com/tatkar
                                               1
Agenda

• Industry Challenges for Application Developers
• Use Sun Studio to Optimize Application Performance
• Single Source for OpenSolaris and Linux Platforms
• Enhanced GCC Source Compatibility in Sun Studio
• Building Parallel Applications
• Increase Productivity with NetBeans-based IDE
• DEMO!
• Call to Action: Download, Developer Services, ...
• Q&A




                                                       2
Microprocessor Trends
•   Between 1993 and 1999 - average CPU
    clock speed increased tenfold
•   What killed my 10 GHz CPU?
    > Design impediments to HW approach of
       increasing performance
         ● heat
         ● power consumption
         ● slow memory

•   Implications:
     > Multi-core chips everywhere: SPARC(8-
       cores, 64 threads), Intel(4-cores), AMD(4-
       cores), ...
     > Parallelism is the new speedup




                       The GHz chip clock race is over!
                                                          3
Industry Trends
      Multi-core Development            Heterogeneous Development
  ●
      New challenges require new SW     ●
                                            Multi-platform development -
      development                           OpenSolaris & Linux
                                        ●
                                            Lack of advanced toolchain –
                                            developers need freedom and
                                            flexibility



          Compatibility                                     IDE
  ●
      OS Compatibility - RHEL 3 -> 4-   ●
                                            New generation uses IDEs
      > 5 difficult transition          ●
                                            Poor satisfaction with C/C++/Fortran
  ●
      Toolchain Compatibility – g++         IDEs on Solaris and Linux
      incompatibility



                                                                                   4
Sun Studio 12
        Performance                     Parallelism
  • Maximize Application          • Simplify Multi-core and
   Performance                      parallel application
                                    development


                           FREE
      Productivity                        Platforms
 • Improves productivity           • Single source for
  with a next generation            Linux, Solaris and
  IDE                               OpenSolaris; SPARC
                                    and x86

                                                              5
Sun Studio Software Overview
Integrated Toolchain
•

•
    Compilers: Record setting parallelizing C/C++/Fortran Compilers
    IDE: Award winning NetBeans-based IDE
                                                                                  FREE
     > Command-line and GUI

•   Code and Memory Debuggers: Stable, Scriptable, Multilingual
    > dbx: Easily debug multi-threaded apps
    > RTC: memory leak, access, usage

•   Performance Analyzer: Application Profiling Tool
    > Identify hot-spots
    > MPI Profiler/Analyzer

•   Thread Analyzer: Multi-threading tool
     > Detect race and deadlock conditions

•   D-Light GUI Plug-in
•   Multi-core Support: Tools, Optimizations, High Performance Libraries, OpenMP v3.0 API,
    OpenMPI (Sun HPC Cluster Tools)
•   Platform Support: SPARC (Soalris OS) , x86/x64 (OpenSolaris, Solaris & Linux Oss)



                                                                                             6
   Performance

Write Fast Applications



                          7
World Record-setting Parallelizing Compilers
  Sun Fire X4600                                                 Sun Blade X6250
     ❏ Best in Class SPECOMP L2001:                                 ❏ Best in Class SPECint2006:
        11% Faster than HP DL585 G2                                    69% Faster than IBM BladeCenter LS21
     ❏ Best in Class SPECint_rate2006                                  28%Faster than HP Proliant BL20p G4
     ❏ X86 champ on SPECfp_rate2000                              Sun Blade X6220
     ❏ Fastest SPECfp_2000 system on planet (7/2006)                ❏ Best in Class SPECOMP M2001:
        beating even IBM Power5+ systems                               126% Faster than IBM/Power5
  Sun Fire X4200, X4100, X2200_M2
     ❏ Sun snatches two World Records in new SPEC CPU2006
        benchmark: SPECint2006 and SPECfp2006




 UltraSPARC T2 (8 cores/64 Threads)
     ❏ Best Chip score on SPECintrate 2006 and SPECfprate 2006


        Dozens of Recent Industry-based Benchmarks!
                                                                                                              8
Maximize Application Performance
Sun Studio 12 vs. Sun Sudio 11 & GCC
      Sun Studio 11 vs. Sun Studio 12 (SPARC)                                                      Sun Studio 11 vs. Sun Studio 12 (x86/x64)
             Throughput Measurement

                                                                               27%                                                               16 %
SPECINT                                                                                      SPECINT



                                                                             Sun Studio 11                                                      Sun Studio 11
                                                                             Sun Studio 12                                                      Sun Studio 12




SPECFP                                                                                       SPECFP
                                                                              21 %                                                               15 %

          0    0.25         0.5          0.75      1         1.25      1.5                             0       0.25   0.5   0.75   1     1.25


          GCC 4.1 vs. Sun Studio 12 (SPARC)                                                                GCC 4.1 vs. Sun Studio 12 (x86/x64)


                                                                              38 %                                                               13 %
SPECINT                                                                                      SPECINT



                                                                             GCC 4.1                                                            GCC 4.1
                                                                             Sun Studio 12                                                      Sun Studio 12




 SPECFP                                                                                      SPECFP

                                                                              93 %                                                              18 %

          0   0.25    0.5         0.75     1    1.25   1.5      1.75    2                              0       0.25   0.5   0.75   1     1.25                   9
Runtime Performance Optimizations
Sun Invests in Compiler Performance
Optimized performance for each                                                      SPARC optimizations
target system: UltraSPARC, X86,                                                       ●    Niagara, US-IV+, US-IIIi
and x64 - maximal system                                                                   optimizations
utilization
                                                                                      ●    Linkopt
                                                                                      ●    New CoolTools for
  ●   Automatic parallelization and                                                        UltraSPARC development:
      vectorization                                                                        ATS, SPOT, Discover, ...
 ●   High-level loop                                                                  ●    KPIC optimizationsBinary optimizations to improve cache
                                                                                           locality
     transformations                                                                  ●    Modulo Scheduling
 ●   Interprocedural optimizations Common                                 UltraSPARC
                                                                                      ●    Block Scoped optimizations
 ●   Profile-Guided Optimizations
 ●   Advanced OpenMP support Optimizations                                 Optimizations
 ●   Prefetch support for newer
     systems                                                                               X86 optimizations
     Aggressive inlining and cloning
                                                                                               >     SSE2, SSE3, SSSE3,
 ●

 ●   More efficient machine resource utilization (throughput)
 ●   Optimization of (-xbuiltin) calls                                                               SSE4.1, SSE4.2, SSE4a
 ●   Inline template (assembly) code                                                                  instr in assembler and
     Alias-based type disambiguation
                                                                                                     inlines
 ●


     Highly optimized code generation
                                                             Optimized
 ●

 ●   Options to exploit advanced architecture pipelines, cache,                                >     Instruction selection
 ●
     chips
     Linker scoped variables                                  Math libs     x86/x64                  for each target chip
 ●   Class Hierarchy Analysis + Optimization                              Optimizations        >     Alignment
Optimized Math Libraries                                                                       >     Vectorization
 ●   Maximally optimized                                                                       >     Instruction scheduling
     advanced math libraries                                                                   >     Strength reduction
     (BLAS, FFT, LAPACK)                                                                       >     Branch prediction
 ●   libm, libmvec, libmopt, libmil                                                            >     Induction variable elim
 ●   Libsunmath                                                                                >     Invariant hoisting
 ●   MedliaLib, SSE(Math) intrinsics                                                           >     Loop interchange
                                                                                               >     Loop unswitching
                                                                                               >     Alignment of symbol blocks
                                                                                               >     Loop unrolling

                                                                                                                                           10
         Platforms

Unifying OpenSolaris and Linux
         development


                                 11
Full Support for OpenSolaris and Linux
   •   Customers have heterogeneous OpenSolaris + Linux
       environments
        > Single advanced toolset for both platforms
        > Same sources, same features, same components,
           same performance
   •   Sun Studio now supports Linux to ease multi-platform
       development
        > Complete feature set available on Linux
        > C, C++, and Fortran compilers, with optimized math
           and standard libraries and solvers
        > Stable C++ ABI for Linux
        > Improved GCC source compatibility with feature
           extensions like __attribute__, asm_inlines, etc
        > OpenMP and MPI support
        > Dbx, Performance Analyzer, Thread Analyzer, RTC,
           NB-Based IDE, dmake, ...
        > Industrial grade individual developer and enterprise
           support options




                                                                 12
Be Smart. Be Compatible.
  •   Compatibility between releases
      > Allows developers to upgrade their
         environment and continue innovating
         (versus reworking code)
      > Leader in C++ ABI compatibility- link
         with objects produced by earlier
         versions
  •   Enhanced GCC compatibility
      > Eases adoption of Sun Studio for GCC-
         based developers
      > Improved source and binary
         compatibility
  •   Solaris Binary Compatibility Guarantee
      > With Sun Studio software
      > Source and binary compatibility




                                                13
Binary compatibility with gcc
 #include <stdio.h>
 extern void   hello_gcc();
 void hello_suncc(void)
 {
                                       void hello_gcc(void)
         printf("Hello from SUN\n");
                                       {
 }
                                           printf("Hello from GNU\n");
 void main(void)
                                       }
 {
         hello_suncc();
         hello_gcc();
 }

 $ gcc hello_gcc.c -c
 $ cc main.c hello_gcc.o

 $ ./a.out
 Hello from SUN
 Hello from GNU

                                                                         14
           Parallelism

Simplifying Multi-threaded and Multi-
         core Development


                                        15
Compiler Support for Parallel Apps
                                  Application

                     Sun Studio Developer Tools



                       Easiest                           Hardest

           AutoPar          P-Threads           OpenMP             MPI

        libumem         Atomic        Solaris       Posix          Event
                      Operations     Threads       Threads         Ports

                                    Solaris

                  UltraSPARC T1/T2
                                                         Intel/AMD
                    SPARC64 VI,
                                                          x86/x64
                   UltraSPARC IV+                                          16
Automatic Parallelization




                            17
What is OpenMP?
• Language extensions for writing shared-memory parallel applications
    in C, C++ and Fortran
•   Consists of:
     > Compiler directives (pragmas)
     > Runtime routines (libmtsk)
     > Environment variables
•   Advantages
     > Incremental parallelization of source code
     > Small(er) amount of programming effort
     > Good performance and scalability
     > Portable across variety of vendor compilers
•   Sun Studio 12 supports OpenMP 2.5
•   Sun Studio Express 07/08 supports OpenMP 3.0
        OpenMP: defacto standard for creating parallel
         applications, supported by all major vendors
                                                                        18
Parallelism: Opportunities vs. Challenges
• Speed ups can be impressive depending on application type with little
  or incremental programming effort
  > modulo: Amdahl's Law
• Challenges are subtle, difficult to track, very hard to prove
  > Parallelism leads to data access contention / memory stomping
  > Data races and deadlock detection is a harder debugging, profiling,
      performance problem to track and fix
• Sun Studio offers Tools support:
  > Thread Analyzer - pinpoints data-races and locks
  > Performance Analyzer and Debugger(dbx) - Multi-thread, OpenMP and
      autopar aware




                                                                          19
Thread Analyzer
 • Race and Deadlock detection Tool
   > Identifies non-deterministic or incorrect
        execution
     > Identifies actual and potential deadlock
        situations
 •   Supports multi-threaded applications:
     POSIX, Solaris and OpenMP Threads
 •   Easy to use GUI - Integrated into IDE
 •   API provided to inform Thread Analyzer of
     user-defined synchronizations
 •   Supports C, C++ and Fortran



                                                  20
Debugger
• Based on dbx, with easy to use GUI integrated in IDE
• Multi-thread aware
  > Debug optimized code
  > Debug POSIX threaded and OpenMP parallelized code
  > GUI Threads Interface - Browse, select, view active threads
  > Monitor thread entry point, PC, events, LWPs
  > Programmable event-triggered actions
• Supports C/C++, Fortran
• RunTime Checking for Memory leak issues:
  > Out of bounds access checks
  > memory leaks / usage
• Multi-session, follow-fork, attach to running process
• Fix and Continue
   > Quick recompile and reload (without restarting debugging session)


                                                                         21
Performance Analyzer
 •   Assess the performance of your multi-threaded application
     > Identify hot-spots
     > Offers performance data at statement, instruction, routine level
     > Tune your application
     > Displays Compiler Commentary describing optimizations
 •   Supports POSIX threaded, OpenMP parallelization and MPI
 •   Works with unmodified binaries - low overhead
 •   Easy to use GUI – Integrated into IDE
 • Displays various performance metrics, understand where time is being
   spent:
   > Timeline, HW Counters, Synchronization delay, Memory allocation, MPI
      tracing metrics
 • Supports C/C++, Fortran and Java



                                                                            22
      Productivity

Build applications faster


                            23
Next Generation IDE
 • Background
   > New generation of developers
      want sophisticated IDE (vs
      command line tools only)
   > Market study: low satisfaction
      rating for current IDEs on Unix
 • Key Features
   > Sun Studio 12 based on
      NetBeans 5.5.1
   > Intelligent Language-Aware
      Editor – code completion, code
      folding, syntax highlighting, etc.
   > Dynamic class browser
   > Wizard for creating Makefiles
   > Full GUI Integration with Sun
      Studio Tools
   > Highly configurablel




                                           24
Sun Studio IDE Details
•   First hour productivity
    > Ease of installation and configuration
    > Existing application migration: based on makefile or configure
    > New application development: templates, makefile wizard
•   Project system: imposing structure without reorganizing
•   Logical source browsing: classview
•   GUI Editor
•   C/C++ integration in editor: code completion and more
•   Sun Studio tool-chain integration: Debugger (dbx), Performance analyzer,
    Thread analyzer
•   Version control system integration
•   Plug-ins: C/C++ refactoring, Call graph, Assembler editor ...
•   DEMO!



                                                                               25
Demo: IDE, Debugger,
Analyzer on an MT app



                        26
New in Development




                     27
Studio Express: Mapping the Road Ahead
http://developers.sun.com/sunstudio/downloads/express.jsp

 •   Preview Releases of Sun Studio
 •   Introduce new functionality and invite developers
     to help drive tweaks, changes, features in future
     releases
 •   Direct feedback to engineering staff via forums
     and online bug/RFE submission
 •   Almost Quarterly Releases:
     > 7/08: MPI Profiler, OpenMP3.0
     > 5/08: OpenSolaris repository
     > 2/08: Improved IDE (based on NB 6.0)
     > 6/07: Project D-Light showcased at J1
     > 2/07: Early Access for SS12
     > 12/06: Upgraded to NB 5.5.1
     > 8/06: Sun Compilers for Linux
     > 6/06: Thread Analyzer Previewed




                                                            28
Try out these new features
•   Compilers
    > Support new x86 features: SSSE3, SSE4.1, SSE4.2, SSE4a, sparcima, SPARC64 VI,
       SPARC64 VII, UltraSPARC T2
    > Optimize for new Penryn, Barcelona and (upcoming)Nehalem, SPARC64 (Fujitsu/OPL Sun
       Systems), UltraSPARC T2+
    > OpenMP 3.0 API support
    > Improved GCC source compatibility

•   Project D-light
    > Ease to use observability toolkit

•   Dtrace GUI Plugin for Sun Studio/NetBeans
•   MPI Profiler and support for Open MPI / ClusterTools 8.0
•   CoolTools
    > Automatic Tuning System, Sun Grid Compiler, Analysis and Coverage Tools

•   IDE based on NetBeans 6.1
     > Class hierarchy browser
     > Go to {Type, Include, Function}
     > Assembler Plugin

                                                                                           29
Sun Developer Community
          and
   Training Support


                          30
developers.sun.com/sunstudio




                               31
Sun Developer Services Portfolio
    Building Blocks for Success                                                     Peace of mind
                                                                       Build
    developers.sun.com/services Maintain
                            Assist
       Train

                                                                                             Java
                                                                    Sun Developer         MultiPlatform
                                              Sun Software          Service Plans        Support Offering
                          Sun Developer       Service Plans                          ●    Mission-
    Training and             Expert                             ●   Telephone             critical Java™
                                          ●
                                              Telephone             support
    Certification          Assistance         support                                     support
●
    Novice to                                                   ●   Unlimited        ●
                                                                                          Heterogeneous
                      ●   Code level      ●
                                              Releases,             code support
    advanced              support             patches, online                             environments
    training                                  resources
                                                                ●
                                                                    Training         ●
                                                                                          Site-wide
                      ●   Online access                             credits
●
    Options for           to senior       ●
                                              Bug reporting                               coverage
    individuals and       engineers           and escalation
    team training


All developers             Small-Medium Business                       Enterprise Business
                                                                                                           32
–




    Vijay Tatkar
    Sr. Engineering Manager, Sun
    Developer Tools
    http://blogs.sun.com/tatkar




                                   33