¸ÞÀϺ¸³»±â

À̸§°Ë»ö

::: SHIN, Byeong-Chun's Board


97 110 Åë°èÄ«¿îÅÍ º¸±â   ȸ¿ø °¡ÀÔ È¸¿ø ·Î±×ÀÎ °ü¸®ÀÚ Á¢¼Ó --+
Name   ½Åº´Ãá
Subject   OpenMP
OpenMP :
N°³ÀÇ CPU¸¦ °¡Áø ÇϳªÀÇ ÄÄÇ»ÅÍ¿¡¼­
´ë¿ë·®ÀÇ ¸Þ¸ð¸®¸¦ °øÀ¯Çϸç N°³ÀÇ CPU(Shared Memory Multiprocessors System)¸¦
µ¿½Ã¿¡ »ç¿ëÇÏ¿© ÄÄÇ»ÆÃÇÒ ¼ö ÀÖµµ·Ï ÇÏ´Â API(application programming interface)ÀÌ´Ù.
À̸¦ »ç¿ëÇÏ¿© ¾ÆÁÖ ½±°Ô(MPI:message passing interface º¸´Ù ½±°Ô)
Fortran ¶Ç´Â C/C++ ¿¡¼­ º´·Ä°è»êÀ» ÇÒ ¼ö ÀÖµµ·Ï ÇÏ´Â ÀÎÅÍÆäÀ̽ºÀÌ´Ù.

¸Þ¸ð¸®º´¸ñÇö»óÀ¸·Î ÀÎÇÏ¿© ÇöÀçÀÇ ±â¼ú·Î 32 Processors±îÁö Áö¿ø

MPI :
¿©·¯´ëÀÇ ÄÄÇ»ÅÍ(Nodes)¿¡¼­ °¢°¢ÀÇ ºÐ»êµÈ ¸Þ¸ð¸®¸¦ »ç¿ëÇÏ¿© ÄÄÇ»ÆÃÇÑ °á°úµéÀ»
³×Æ®¿÷À» ÅëÇÏ¿© Head Node¿¡¼­ Á¦¾îÇϵµ·Ï ÇÏ´Â Distributed Memory SystemÀÇ
ÀÎÅÍÆäÀ̽ºÀÌ´Ù.

In HPPC(4*Itanium2 Processors 64bit Server) with Inter Fortran ia64 for Linux,
to compile a fortran source file :
efc -FR -openmp -fpp -o appl appl.f
% -FR : Free format fortran

Program Hello
  Implicit None
  Integer :: omp_get_thread_num()
  print *, "Hello"
!$omp parallel
  print *, omp_get_thread_num()
!$omp end parallel
  print *, "Bye"
End Program Hello


Remark]
1. omp_get_thread_num : ÇöÀç »ç¿ëÁßÀÎ ÇÁ·Î¼¼¼­ÀÇ ¹øÈ£

2.  !$omp parallel ¿¡¼­  " !$ " ÀÇ »ç¿ëÇÏ´Â ±î´ßÁß Çϳª´Â
     openmp°¡ ¾ÈµÇ´Â °÷¿¡¼­ ÁÖ¼®À¸·Î »ç¿ëÇϱâ À§ÇÔ

3. °á°ú(4CPU)
    Hello
    1
    3
    0
    2
    Bye

openMP directive :

!$omp directives

¸¸¾à openMP CompileÀ» Áö¿øÇÏÁö ¾ÊÀ¸¸é
À§ÀÇ Áö½Ã³»¿ëÀº ÇϳªÀÇ ÁÖ¼®À¸·Î ÀνĵÊ

openMP prefix :

!$  directives

À§¿Í °°°í openMP CompileÀ» Áö¿øÇϸé !$ ´Â ºó°ø°£(white space)À¸·Î
µÇ°í µÚÀÇ Áö½Ã³»¿ëÀ» ½ÇÇàÇÔ

¿¹]
<Correct>
1.
!$   iam = omp_get_thread_num()

2.
     y = x &
!$&      + offset

<InCorrect>
     y = x + !$  + offset

! sam1.f
Program Main
 Implicit None
 Integer :: a, b
 Real :: c, d
 Integer :: omp_get_thread_num

 a = 0
 Print *, "Hello"
!$omp parallel
!$ a= omp_get_thread_num()
!$ a = a + 5
 print *, a
!$omp end parallel

end

Command>
1. efc -o sam1 sam1.f
Result ==>
 Hello
          0

2. efc -openmp -fpp -o sam1 sam1.f
Result ==>
   Hello
          7
          5
          8
          6

Program Main

Implicit None
Integer :: i,n=40
Real :: z(n), a, x(n), y

a = 1.0 ; y = 0.1
Do i=1,n ; x(i)=log(1.0*i) ; EndDo

!$omp parallel Do

Do i=1,n
  z(i) = a*x(i)+y
  print *, i, z(i)
EndDo


End Program

°Ô½Ã¹°À» À̸ÞÀÏ·Î º¸³»±â ÇÁ¸°Æ®Ãâ·ÂÀ» À§ÇÑ È­¸éº¸±â
DATE: 2018.07.02 - 17:33


 ÀÌÀü±Û ¼ºÀû¼ÒÆà C-language
 ´ÙÀ½±Û Anaconda for Python 3.6
±Û³²±â±â»èÁ¦Çϱâ¼öÁ¤Çϱâ´äº¯´Þ±âÀüü ¸ñ·Ï º¸±â