Virginia Tech
Advanced Research Computing
  • Home
  • About ARC@VT
  • Research
  • Services & Support
  • Systems & Resources
    • System X
    • SGI Systems
      •      Accounts
      •      New Accounts
      •      Usage Overview
      •      Help Requests
    • SGI Software
      •      Applications
      •      Queuing System
      •      Compilers
      •      Subroutine Libraries
      •      Debuggers
    • SGI Parallel Programming
      •      Auto-Parallel
      •      SCSL Subroutines
      •      OpenMP
      •      MPI Programming
    • Sun Systems
    • Visualization
  • Application Software
  • Web Site Map

Parallel Programming Using OpenMP

OpenMP is emerging as a standard for parallel processing on shared memory multiprocessor systems. Directives within the code designate how and what parts of the code are to be parallelized;  environmental variables and a runtime library are used to enable use of the multiprocessors.  Overviews of OpenMP can be found in OpenMP Overview on this web site and at Wikipedia;  for details, see the OpenMP web-site and the OpenMP 2.5 Specification.

Note  the auto-parallel and SCSL library methods described in the prior two sections are implemented through OpenMP on SGI systems.

Examples OpenMP parallel code for "Hello World" in Fortran, C, and C++ are available from Wikipedia. More comprehensive OpenMP example programs are provided from the Sample Programs link off of the OpenMP web site. 

To compile an OpenMP program on SGI using OpenMP directives, use the -openmp compiler option.  With Fortran programs, you will also need to specify the "-fpp" Fortran precompiler option.  For example, to compile a Fortran program called "my_prog.f" as "my_prog" which contains OpenMP directives, you could enter:

     ifort -o my_prog my_prog.f -fpp -openmp

In order to execute an OpenMP program and utilize the parallel programming environment, you need to specify the number of threads to be used for processing. This can be done internally within the program by using the OpenMP  "omp_set_num_threads" library call or by defining the  "OMP_NUM_THREADS"  environmental variable. For example, when using the Bourne, Korn, or Bash shells, you could set the environmental variable to use four processors and execute the compiled program "my_prog"by entering the following pair of commands:

    export OMP_NUM_THREADS=4
    ./my_prog

Note:  C Shell and C Shell derivatives would use:

    setenv OMP_NUM_THREADS 4
    ./my_prog

Some OpenMP Tutorials include:

  • Parallel Programming in Fortran 95 using OpenMP
  • University of Minnesota -- Introduction to OpenMP
  • NCSA -- Introduction to OpenMP
  • Lawrence Livermore Labs -- OpenMP
  • National Energy Research Scientific Computing Center -- OpenMP Tutorial
  • Ohio SuperComputing Center -- Parallel Programming with OpenMP
  • Boston University -- Introduction to OpenMP
  • Indiana University -- Getting Started with OpenMP -- C version
  • Mauhi High Performance Computing Center



VT-ARC Privacy Statement | Contact Us
VT-ARC is a Unit within the Office of the Vice President of Information Technology
© 2007-2008 Virginia Polytechnic Institute and State University
Principles of Community | Acceptable Use Policy | Accessibility | Equal Opportunity
Website Feedback   -   Page Last Updated:  April 16th, 2008