? s U w U 7 OpenMP >2014/01/15 · k g: ? .| B E D OpenMP 17 : k g ? .' G E DMPI 2ÒÑ j b f T L _...
Transcript of ? s U w U 7 OpenMP >2014/01/15 · k g: ? .| B E D OpenMP 17 : k g ? .' G E DMPI 2ÒÑ j b f T L _...
HPC
8
CPU
CPU
OpenMP
MPI
CPUCPU
CPUCPU
Core
Core
Core
Core
Core
Core
Core
Core
Core
Core
Core
Core
Core
Core
Core
Core
Hello OpenMP world
( )
(*) intel fortran: ifort –openmp hello.f GNU: gfortran –fopenmp hello.f login-node: frtpx –Kopenmp hello.f (**) csh : setenv OMP_NUM_THREADS 4
OpenMP
Hello OpenMP world
Write
Write
Write
Write
Write
Hello OpenMP
world
Hello OpenMP
world
Hello OpenMP
world
Hello OpenMP
world
Hello world
write
Parallel
Fortran
Private ( i )
Parallel DO
DO private
Shared ( X(:) ) default
default(shared), default(private), default(none)
none
call y call X(i)
Shared COMMON/SAVE (n, ymax, a) module save shared
Private
Reduction
Reduction r = r op expr r: reduction , expr: r
Reduction reduction private
!$omp parallel do reduction(op : r1 [ , r2] )
op : reduction (+ , * , - , .and. , .or. , .eqv. , .neqv. , max, min, iand, ior, ieor)
r1 [ , r2] : reduction
reduction
Reduction (cont.)
Reducion
Reduction private
0 .neqv. .false.
1 max
0 min
.and. .true. iand 1
.or. .false. Ior 0
.eqv. .true. ieor 0
omp_get_thread_num integer
0 [ -1]
omp_get_max_threads integer
omp_get_num_threads integer
omp_in_parallel logical.true. .false.
omp_get_wtime real*8 wall clock
1 2 4 81
2
4
8
(cont.)
(N)
1-p = 1/2
1-p = 1/4
1-p = 0 (1-p)
1-p = 1/8
s = 1
1− p( ) + p / Np: N:
100%
(88%)
(75%)
(50%)
2.3 2.9
4.3
1 10 100 1000 104 1051
10
100
1000
104
105
(cont.)
(N)
1-p = 1/10
1-p = 1/100
1-p = 1/1000
1-p = 1/10000
1-p = 0
(1-p)
s = 1
1− p( ) + p / Np: N:
100%
99.99%
99.9%
99%
90%
1-p = 1/10000099.999%
OpenMP http://openmp.org/wp/openmp-specifications/
version 3.0 OpenMP v3.0 gcc 4.4 v3.0 gcc 4.7 v3.1 intel 11.0 : v3.0 12.1 : v3.1
https://computing.llnl.gov/tutorials/openMP/
Fortran/C
Using OpenMP B. Chapman The MIT Press Fortran
OpenMP C/C++
C/C++ OpenMP OpenMP CPU
https://www.hpci-office.jp/pages/seminar_text
Threadprivate (cont.)
Threadprivate common common subroutine
private
common subroutine
common equivalence threadprivate
common