Automatic Parallelism and OpenMP can be used for parallelism in a single node (shared memory parallelism).


Automatic Parallelism

The compiler analyzes the source code and makes modules parallelized in a node suitable for the construction of the program. This procedure is very simple and easy. A program can be parallelized by simply designating a compiling option.


Basic Use

Basically, automatic parallelism can be used simply by compilation.


How to compile

On SX-ACE, SX-ACE cross compiling can be used. Please be aware that the command name is different on a per-language basis.

$ sxf90 -P auto [options] source_file
$ sxc++ -P auto [options] source_file


Execution script

Please specify the number of the parallelism for the environment value on execution.
The following example script requests parallelism in 4 nodes, with a 1 hour elapse time and a memory of 60 GB.



FORTRAN90/SX Multitasking User's Guide(Authentication required)


About the OpenMP

The compiler parallelizes by the directive entered into the program. This parallelization is in a single node (shared-memory parallelization). Please note that the program is different on a per-language basis. The following is an easy way to use the Open MP parallelism.


Basic Use

The following is the OpenMP program with FORTRAN. We explain how to use the OpenMP parallelism according to this program.

The marked lines (line 3 - line 5) are the part of codes related to the OpenMP parallelism.
include "omp_lib.h"[line 3], omp_get_thread_num()[line 5] omp_get_num_threads()[line 5] only to print the OpenMP processing. Therefore, whether you enter this processing or not, the parallelism processing is the same.


line 3: include "omp_lib.h"
This line designates file included for the OpenMP library routine. This line must be specified when using the library routine described below:


line 4: !$omp parallel
line 6: !$omp end parallel
These lines are the directives for the OpenMP. The parallel directive means the block between these directives must be parallelized. In this case, line 5 will be parallelized. The environment value must be specified for OMP_NUM_THREADS, a number of parallelism.

line 5 omp_get_thread_num and omp_get_num_threads is the library routine for the OpenMP. When using this routine, an include file must be specified as line 3. omp_get_thread_num is the processing needed to get the number of threads. omp_get_num_threads is the processing needed to get the "number" named per threads. This number starts from "0".


The execution result of the above program is as follows:

HELLO WORLD mythread= 3 ( 4 threads)
HELLO WORLD mythread= 1 ( 4 threads)
HELLO WORLD mythread= 0 ( 4 threads)
HELLO WORLD mythread= 2 ( 4 threads)



Unlike auto parallelism, users have to insert the directive into a users' program to parallelize on OpenMP. The directive differs depending on the languages. The following are examples of directives:

!$omp "Directive" (In the case of FORTRAN)
#pragma omp "Directive"(In the case of C/C++)

To further understand the kinds of directives, please see the reference materials.



$ sxf90 -P openmp [options] source_file (In the case of FORTRAN)
$ sxc++ -P openmp [options] source_file (In the case of C/C++)


Execution script

Please specify the number of parallel execution to the environmental value, OMP_NUM_THREADS. The following script is an example of 4 parallel executions for 1 hour with a 60 GB memory.


Reference materials

Please see the following for details of usage:(authentication required)

FORTRAN90/SX Multitasking User's Guide
* Please see "Appendix C, OpenMP Function".
The following are the reference materials for the PC cluster, in which the Open MP is explained. Please note that for access to all materials authentication is required.