visual studio에서 openmp 사용할 때 ordered 지시어 사용안해도 ordered하게 사용되는 이유?

high385의 이미지

#include "stdlib.h"
#include "stdio.h"
#include "omp.h"
//헤더파일에서 <>가 표현이 안 되어서 ""로 표시함
void main()
{
int i = 0;

printf("ordered 미사용 ");
omp_set_num_threads(2);
#pragma omp parallel
{
#pragma omp for
for (i=0; i < 10; i++){
printf(" %d ", i);
}

#pragma omp single
printf("\nordered 사용 ");

#pragma omp for ordered
for (i=0; i < 10; i++){
#pragma omp ordered
printf(" %d ", i);
}
}
printf("\n");
}
==> 실행결과
ordered 미사용 0 1 2 3 4 5 6 7 8 9
ordered 사용 0 1 2 3 4 5 6 7 8 9

core2Duo 컴퓨터인데요 ordered 지시어 사용 전후 모두 ordered하게
표현되는 이유가 무엇일까요?

평소에 ordered하지 않게 multi thread 사용하게 하는

visual studio 설정이 따로 있나요?ㅠㅠ

ordered하니까 critical, atomic도 필요없는 것 같아서요..
critical, atomic의 효과를 보고 싶은데 도움 주세요.

shint의 이미지

확인해보니.

윈도우 DevC++ 에서 ,c .cpp 는 순서대로 출력되고.
윈도우 CYGWIN 에서 .c 는 뒤죽박죽으로 출력됩니다.

http://njuhb.blog.me/140156053691

http://blog.naver.com/hextrial?Redirect=Log&logNo=60165281299

OpenMP를 이용한 병렬 프로그래밍
http://www.mimul.com/pebble/default/2012/05/30/1338342349153.html

pragma omp for ordered'로 네이버 검색
http://search.naver.com/search.naver?ie=utf8&sm=stp_hty&where=se&query=pragma+omp+for+ordered

A “Hands-on” Introduction to OpenMP*
http://openmp.org/mp-documents/omp-hands-on-SC08.pdf

#include <omp.h>
 
WIN32 API 용 - 라이브러리 위치  (추가 안해도 된다.) 
C:\Program Files\Dev-Cpp\MinGW64\x86_64-w64-mingw32\lib32
 
openmp 라이브러리 위치 (추가 안해도 된다.) 
C:\Program Files\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2
 
 
네이버와 구글에서 openmp DevC++로 검색해서 찾은 내용 
 
컴파일러 
-std=c++11
 
링커 
-static-libgcc -lgomp -fopenmp

----------------------------------------------------------------------------
젊음'은 모든것을 가능하게 만든다.

매일 1억명이 사용하는 프로그램을 함께 만들어보고 싶습니다.
정규 근로 시간을 지키는. 야근 없는 회사와 거래합니다.

각 분야별. 좋은 책'이나 사이트' 블로그' 링크 소개 받습니다. shintx@naver.com

high385의 이미지

저는 Visual studio 2010버전으로 집컴퓨터와 회사 컴퓨터로 각각 수행해본 결과 집에서는 ordered하게 기본적으로 실행되고

회사 컴퓨터는 ordered하지 않게 실행되지 않던데요 무엇이 다른 것일까요?

정말 모르겠군요..

shint의 이미지

...
-----------------------------------------
윈도우 XP 32비트. 삼보드림프로 노트북.
-----------------------------------------
DevC++ 기본 갯수는 0으로 표시됩니다.

// omp_parallel.cpp
// compile with: /openmp 
#include <stdio.h>
#include <omp.h>
 
int main() {
   #pragma omp parallel num_threads(4)
   {
      int i = omp_get_thread_num();
      printf("Hello from thread %d\n", i);
   }
}
 
출력 결과
Hello from thread 0

-----------------------------------------
cygwin 에서는 출력 순서가 스레드 단위로 표시됩니다.
-----------------------------------------

$ gcc -fopenmp -o omp omp.c
cc1: warning: C: not a directory
 
shint@shint-note ~
$ ./omp
Hello from thread 0
Hello from thread 1
Hello from thread 3
Hello from thread 2

$ gcc -fopenmp -o omp omp.c
cc1: warning: C: not a directory
 
shint@shint-note ~
$ ./omp
[1-5] Hello World
[0-0] Hello World
[1-6] Hello World
[0-1] Hello World
[1-7] Hello World
[0-2] Hello World
[1-8] Hello World
[0-3] Hello World
[1-9] Hello World
[0-4] Hello World

- 컴파일 방법. 옵션
- 라이브러리
- MSDN 설명을 첨부해봅니다.

OpenMP Directives
https://msdn.microsoft.com/ko-kr/library/windows/apps/xaml/0ca2w8dk(v=vs.90).aspx

단일 칩 다중 프로세서상에서 운영체제를 사용하지 않은 OpenMP 구현 및 주요 디렉티브 변환
http://academic.naver.com/view.nhn?doc_id=16419026&dir_id=0&page=0&query=OpenMP%20Directives&ndsCategoryId=10512

How does one use a library in Dev C++?
https://www.quora.com/How-does-one-use-a-library-in-Dev-C++

How to Compile and Run an OpenMP Program
http://www.dartmouth.edu/~rc/classes/intro_openmp/compile_run.html

OpenMP Libraries
https://msdn.microsoft.com/en-us/library/0h7x01y0.aspx

Initialization of Mixed Assemblies
https://msdn.microsoft.com/en-us/library/ms173266.aspx

managed, unmanaged
https://msdn.microsoft.com/en-us/library/0adb9zxe.aspx#

Initialization of Mixed Assemblies
https://msdn.microsoft.com/en-us/library/ms173266.aspx#

/openmp (Enable OpenMP 2.0 Support)
https://msdn.microsoft.com/en-us/library/fw509c3b.aspx#

Board index ‹ Using OpenMP
http://openmp.org/forum/viewtopic.php?f=3&t=157

----------------------------------------------------------------------------
젊음'은 모든것을 가능하게 만든다.

매일 1억명이 사용하는 프로그램을 함께 만들어보고 싶습니다.
정규 근로 시간을 지키는. 야근 없는 회사와 거래합니다.

각 분야별. 좋은 책'이나 사이트' 블로그' 링크 소개 받습니다. shintx@naver.com

익명 사용자의 이미지

CPU/core를 더 늘려서 해보세요.(가상머신 만들때,..., VirtualBox, VMWare로 가능하겠지요?)

* SMP(Symetric Multi-Processor) 2 CPU/Core 모델에서, 윈도우 커널이 CPU 1개를 점유하고, 다른 한개는 응용프로그램(들)에게 보통 스케쥴링합니다. 운영체제가 채택한 Processor 스케쥴링 알고리즘에 따른 차이가 있을 수 있으나, 말입니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.