wiki:openmp_programming

OpenMP Usage

OpenMP Installation

OpenMP Compilers: http://openmp.org/wp/openmp-compilers/

Omni OpenMP Compiler Installation

Env: Debian 4.0 amd64 2.6.20-krg SMP with Kerrighed 2.3.0
Step1: rider@hd05:~$ wget http://www.hpcc.jp/Omni/ftp/Omni/Omni-1.6.tar.gz
Step2: rider@hd05:~$ tar zxvf Omni-1.6.tar.gz
Step3: rider@hd05:~$ cd Omni-1.6
Step4: rider@hd05:~$ ./configure --prefix=/opt/openmp
Step5: rider@hd05:~$ make & make install
Step6: rider@hd05:~$ export OMPC_NUM_PROCS=16 (Kerrighed_machines: node0~node4)
Step7: rider@hd05:~$ export OMPC_BIND_PROCS=true
Step8: rider@hd05:~$ export OMPC_LOG=1 (for debug)

Omni OpenMP Compiler Installation with enable-Kerrighed patch

Step4: rider@hd05:~$ wget http://131.254.254.17/download/Omni-1.4-krg-0.72.patch (Need to make some changes - revising)
Step5: rider@hd05:~$ patch -p1 -d Omni1.6 < Omni-1.4-krg-0.72.patch
Step6: rider@hd05:~$ cd Omni-1.6
Step7: rider@hd05:~$ ./configure --with-thread=pthread --enable-gcc --enable-kerrighed --enable-shmem --with-lock=mutex --prefix=/opt/openmp
Step8: rider@hd05:~$ make & make install
Step9: rider@hd05:~$ export OMPC_NUM_PROCS=16 (Kerrighed_machines: node0~node4)
Step10: rider@hd05:~$ export OMPC_BIND_PROCS=true
Step11: rider@hd05:~$ export OMPC_LOG=1 (for debug)

Note:
rider@hd05:~/openmp/Omni-1.6$ gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --disable-libmudflap --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Caution: gcc version 4.2.3 (Debian 4.2.3-5)

Directions Part1

OpenMP e-Learning: https://computing.llnl.gov/tutorials/openMP/
OpenMP Omni Environment Variables: http://phase.hpcc.jp/Omni/Omni-doc/environment.html
OpenMP Omni OpenMP C Compiler: http://phase.hpcc.jp/Omni/Omni-doc/omcc.html
OpenMP Omni OpenMP C Compile: http://phase.hpcc.jp/Omni/Omni-doc/ompcc.html
OpenMP Exercise: https://computing.llnl.gov/tutorials/openMP/exercise.html

Directions Part2

-- The environment variable OMPC_NUM_PROCS specifies the number of threads to execute the program. For example, you want to use 4 threads,

setenv OMPC_NUM_PROCS 4

-- If the environment variable OMPC_NUM_PROCS is not set, check the

number of physical processors in your platform. The same number of threads are created as the number of physical processor. In Linux and Solaris platforms, the runtime system checks the number of processors. Otherwise, the current version uses a compile-time constant N_PROC_DEFALUT (currently 4) in "ompclib.h" as the number of threads.

-- If the environment variable OMP_NUM_THREADS is set and its value

is greater than the number of threads described above, the value of OMP_NUM_THREADS is used as the max number of threads.

Intel C++ Compiler Installation

Step1: Download the Intel C++ Compiler from http://www.intel.com/cd/software/products/asmo-na/eng/340679.htm
Step2: rider@hd05:~$ tar zxvf l_cc_p_10.1.015_intel64.tar.gz (ver: Intel(R)64)
Step3: rider@hd05:~$ cd l_cc_p_10.1.015_intel64
Step4: rider@hd05:~$ ./install.sh ( Follow the installation steps -> Free code: NZCR-FZ66ZWWD
Step5: Confirm your installation path: /opt/intel/cce/10.1.015/
Step6: source /opt/intel/cce/10.1.015/bin/iccvars.sh or export PATH=$PATH:/opt/intel/cce/10.1.015/bin to your /etc/profile
Step7: icc -help (If it works fine than it's done)

Intel Fortran Compiler Installation

Step1: Download the Intel Fortran Compiler from http://www.intel.com/cd/software/products/asmo-na/eng/340679.htm
Step2: rider@hd05:~$ tar zxvf l_fc_p_10.1.015_intel64.tar.gz
Step3: rider@hd05:~$ cd l_fc_p_10.1.015_intel64
Step4: rider@hd05:~$ ./install.sh ( Follow the installation steps -> Free code: NRDN-29Z6K5WT
Step5: Confirm your installation path: /opt/intel/fce/10.1.015/
Step6: source /opt/intel/fce/10.1.015/bin/ifortvars.sh or export PATH=$PATH:/opt/intel/fce/10.1.015/bin
Step7: ifort -help (If it works fine than it's done)

Intel Threading Analysis Tool

Step1: Donwload the Intel Threading Analysis Tool from https://registrationcenter.intel.com/RegCenter/AutoGen.aspx?ProductID=893&AccountID=&ProgramID=&RequestDt=&rm=EVAL&lang=
Step2: rider@hd05:~$ tar zxvf Tcheck3.1_009cli_lin.tar.gz
Step3: rider@hd05:~$ sudo chmod -R a+rx Tcheck3.1_009cli_lin
Step4: rider@hd05:~$ cd Tcheck3.1_009cli_lin
Step5: rider@hd05:~$ ./install.sh
Step6: Confirm your installation path: /opt/intel/itt
Step7: source /opt/intel/itt/tcheck/bin/32e/tcheckvars.sh
Step8: tcheck_cl -help (If it works fine than it's done)

How to compile OpenMP C programs ?

GCC

Env: gcc version 4.2.3 (Debian 4.2.3-5)
Example: /home/rider/openmp/examples/omp_hello.c
rider@hd05:~/openmp/example$ gcc -fopenmp -g omp_hello.c -o hello

icc (Intel® Compiler)

Env: icc version 10.1
Example: /home/rider/openmp/examples/omp_hello.c
rider@hd05:~/openmp/example$ icc hello -openmp -o omp_hello.c

How to compile OpenMP Fortran programs ?

ifort (Intel® Compiler)

Env: ifort version 10.1
Example: /home/rider/openmp/examples/omp_hello.c
rider@hd05:~/openmp/example$ ifort hello -openmp -o omp_hello.f

Caution:
To activate the OpenMP extensions for C/C++ and Fortran, the compile-time flag -fopenmp must be specified. This enables the OpenMP directive #pragma omp in C/C++ and !$omp directives in free form, c$omp, *$omp and !$omp directives in fixed form, !$ conditional compilation sentinels in free form and c$, *$ and !$ sentinels in fixed form, for Fortran. The flag also arranges for automatic linking of the OpenMP runtime library.

Reference: GCC 4.2.3 GNU OpenMP Manual -> http://gcc.gnu.org/onlinedocs/gcc-4.2.3/libgomp/

Example OpenMP Code Structure

Fortran - General Code Structure

PROGRAM HELLO //Program_Name: HELLO   // OpenMP Directives

       INTEGER VAR1, VAR2, VAR3

       Serial code 
             .
             .
             .

       Beginning of parallel section. Fork a team of threads. 
       Specify variable scoping 

!$OMP PARALLEL PRIVATE(VAR1, VAR2) SHARED(VAR3)   // OpenMP Directives

       Parallel section executed by all threads 
             .
             .                                       // Parallel Region
             .

       All threads join master thread and disband 

!$OMP END PARALLEL   // OpenMP Directives

       Resume serial code 
             .
             .
             .

       END

C / C++ - General Code Structure

#include <omp.h>   //include the OpenMP header

main ()  {

int var1, var2, var3;

Serial code 
      .
      .
      .

Beginning of parallel section. Fork a team of threads.
Specify variable scoping 

#pragma omp parallel private(var1, var2) shared(var3)   // OpenMP Directives
  {

  Parallel section executed by all threads 
        . 
        .                                          // Parallel Region
        .

  All threads join master thread and disband 

  }  

Resume serial code 
      .
      .
      .

}


Conclusion: EZ Code Revision - All you need to do is just parallelize the loop in your code by following the structure. Enjoy Using OpenMP !

=================================================================================================
More Information from Kerrighed Dev Team

Information for Kerrighed & OpenMP Users
From: DR. Renaud Lottiaux
To: Rider
Kerlabs
B漮iment Germanium
80, avenue des buttes de Co褭mes
35700 Rennes - France
Phone : (+33|0)6 80 89 19 34
Fax : (+33|0)2 99 84 71 71
Email : Renaud.Lottiaux@…
Web : http://www.kerlabs.com/

Hi !

Currently, the openMP support has been disabled. More generally, the support for distributed threads is no more functionnal.

We plan to re-enable this feature in the future, but we don't yet have a release date for this.

Regards.

R.

Rider:

This is the mail wrote to DR.Renaud Lottiaux for kerrighed help, and it seems that kerrighed no longer support OpenMP for now. Maybe in the future kerrighed will enable it.

Last modified 16 years ago Last modified on May 24, 2008, 3:57:39 AM

Attachments (1)

Download all attachments as: .zip