๋‚ด ์ธ์ƒ์—์„œ ๋ฏฟ์„ ๊ฑด ์˜ค์ง ๋‚˜ ์ž์‹ ๋ฟ!

The only one you can truly trust is yourself.

๊ฒŒ์ž„ ํ”„๋กœ๊ทธ๋ž˜๋ฐ/๋ณ‘๋ ฌ ํ”„๋กœ๊ทธ๋ž˜๋ฐ

OpenMP ์ฒซ ์‚ฝ (2010)

๐ŸŽฎinspirer9 2021. 2. 13. 01:33
728x90
๋ฐ˜์‘ํ˜•

์˜คํ”ˆ์— ํ”ผ ๊ณต์‹ ์‚ฌ์ดํŠธ

The OpenMP API specification for parallel programming    http://openmp.org/wp/

 

์˜คํ”ˆ์— ํ”ผ ์ž˜ ์ •๋ฆฌ๋œ ์‚ฌ์ดํŠธ

C์–ธ์–ด: OpenMP๋ฅผ ์ด์šฉํ•œ ๋ฉ€ํ‹ฐ ์“ฐ๋ ˆ๋“œ ํ”„๋กœ๊ทธ๋ž˜๋ฐ HOWTO #1 http://sunyzero.egloos.com/4227785

C์–ธ์–ด: OpenMP๋ฅผ ์ด์šฉํ•œ ๋ฉ€ํ‹ฐ ์“ฐ๋ ˆ๋“œ ํ”„๋กœ๊ทธ๋ž˜๋ฐ HOWTO #2 http://sunyzero.egloos.com/4229235

C์–ธ์–ด: OpenMP๋ฅผ ์ด์šฉํ•œ ๋ฉ€ํ‹ฐ ์“ฐ๋ ˆ๋“œ ํ”„๋กœ๊ทธ๋ž˜๋ฐ HOWTO #3 http://sunyzero.egloos.com/4234766

C์–ธ์–ด: OpenMP๋ฅผ ์ด์šฉํ•œ ๋ฉ€ํ‹ฐ ์“ฐ๋ ˆ๋“œ ํ”„๋กœ๊ทธ๋ž˜๋ฐ HOWTO #4 http://sunyzero.egloos.com/4258873

 

์–ธ์ œ๋‚˜ ๋”ฐ๋ผํ•˜๊ธฐ๊ฐ€ ์žˆ๋‹ค๋Š” ๊ฒƒ์€ ํ–‰๋ณตํ•œ ์ผ์ด๋‹ค.

ํŠนํžˆ ์ด๊ณต๊ณ„์ชฝ์€ ์ž์‹ ์ด ์ฒœ์žฌ์ ์ธ ๋ฆฌ๋”๋‚˜ ํ”„๋ก ํ‹ฐ์–ด๊ฐ€ ์•„๋‹ˆ๋ผ๋ฉด ๊ทธ๋ƒฅ ๊ตฌ๊ธ€ ๊ฒ€์ƒ‰ํ•˜๋ฉด ์ž์‹ ์ด ํ•˜๋ ค๊ณ  ํ–ˆ๋˜ ๊ฒƒ๋“ค์„ ๋ˆ„๊ตฐ๊ฐ€ ์ด๋ฏธ ํ•ด๋†“์€ ๊ฒƒ์„ ๋ฐœ๊ฒฌํ•  ์ˆ˜ ์žˆ๋‹ค. ์ด ๋ฉ€ํ‹ฐํ”„๋กœ์„ธ์„œ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ๊ฐ™์€ ๊ฒƒ๋„ 1970๋…„์ธ๊ฐ€ 1960๋…„์ธ๊ฐ€? ์•”ํŠผ ๋ช‡ ์‹ญ๋…„์ „์˜ ์ด๋ก ๊ณผ ๊ธฐ์ˆ ์ด ๊ธฐ๋ฐ˜์ด๋‹ค.

๊ทธ๋ž˜์„œ ํ–‰๋ณตํ•˜๋ฉด์„œ ์Šฌํ”ˆ ์ผ์ด๊ธฐ๋„ ํ•˜๋‹ค.

 

์•”ํŠผ openMP ์ฒซ ์‚ฝ์„ ๋– ๋ณด๋ ค๊ณ  ํ–ˆ๋Š”๋ฐ...

gcc ๋ฒ„์ „์ด 3.4.5๋‹ค.

๊ทธ๋ž˜์„œ ์–ด์ฉ”์ˆ˜ ์—†์ด "omp 2.0"์„ ์ง€์›ํ•˜๋Š” Visual studio 2008 c++์—์„œ ์–ด์ œ ์„ธ๋ฏธ๋‚˜์—์„œ ๋“ค์—ˆ๋˜ ๋‚ด์šฉ์„ ๋”ฐ๋ผ ์œ„ ์‚ฌ์ดํŠธ๋ฅผ ์ฐธ๊ณ ํ•˜๋ฉฐ ๊ณต๋ถ€ํ–ˆ๋‹ค.

๋งž๋Š”์ง„ ๋ชจ๋ฅด๊ฒ ์ง€๋งŒ ์š”๋ ‡๊ฒŒ ํ•˜๋ฉด ๊ฐ„๋‹จํ•˜๊ฒŒ for ๋ฃจํ”„ ๋ถ€๋ถ„์— ๋ฉ€ํ‹ฐ์ฝ”์–ด๋ฅผ ํ™œ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

// openMP.cpp : ์ฝ˜์†” ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์— ๋Œ€ํ•œ ์ง„์ž…์ ์„ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.
//

#include "stdafx.h"

int num_steps=100000000;

int _tmain(int argc, _TCHAR* argv[])
{
  int i;
  double x, step, sum = 0.0;
  step = 1.0/(double) num_steps;

  int j;
  unsigned int sum2= 0;
  #pragma omp parallel
  {
    printf("Hello from thread %d / %d\n", 
      omp_get_thread_num(), 
      omp_get_num_threads());

    #pragma omp single nowait
      for(j=0;j<num_steps;j++)
        sum2 += j;

    #pragma omp for private(x) reduction(+:sum) schedule(dynamic,10000)
      for(i=0;i<num_steps;i++)
      {
        x = (i+0.5) * step;
        sum += 4.0/(1.0 + x*x);
      }
  }

  printf("sum2 %u\n", sum2);
  printf("PI = %.8f (sum = %.8f)\n", step*sum, sum);
  return 0;
}

์•„์ฐธ, ์˜ต์…˜์—์„œ openMP ์ง€์› ์˜ต์…˜์„ ๋„ฃ์–ด์•ผ ํ•จ. (/openmp)

 

์ถœ๋ ฅ์€ ๋ญ ์˜ˆ์ƒํ–ˆ๋˜ ๋Œ€๋กœ ...

 

"OpenMP ์ง€์›:์•„๋‹ˆ์˜ค"์ผ ๊ฒฝ์šฐ์—๋Š” ์‹ฑ๊ธ€ ์ฝ”์–ด๋กœ ๋™์ž‘ํ•˜๊ณ ...

 

"OpenMP ์ง€์›:์˜ˆ"์ผ ๊ฒฝ์šฐ์—๋Š” ์‹œ์Šคํ…œ ์ฝ”์–ด ๋งŒํผ ์“ฐ๋ ˆ๋“œ๋ฅผ ์•Œ์•„์„œ ๋งŒ๋“ค์–ด์„œ ๋™์ž‘ํ•จ.

 

 

๊ดœํžˆ ๋จธ๋ฆฌ ์•„ํ”„๊ฒŒ ๊ณ ๋ฏผํ•  ํ•„์š”์—†์ด ์ปดํŒŒ์ผ ํ•  ๋•Œ ์˜ต์…˜๋งŒ ๋ฐ”๊ฟ”์„œ ์‹คํ–‰ํŒŒ์ผ 2๊ฐœ ๋งŒ๋“ค๋ฉด ๋จ.

์šฐ์™• ํŽธํ•˜๋‹ค~!

728x90
๋ฐ˜์‘ํ˜•