OpenMP를 시작하며
| Directive | Description |
|---|---|
Specifies that a memory location that will be updated atomically. | |
Synchronizes all threads in a team; all threads pause at the barrier, until all threads execute the barrier. | |
Specifies that code is only executed on one thread at a time. | |
Specifies that all threads have the same view of memory for all shared objects. | |
Causes the work done in a for loop inside a parallel region to be divided among threads. | |
Specifies that only the master threadshould execute a section of the program. | |
Specifies that code under a parallelized for loop should be executed like a sequential loop. | |
Defines a parallel region, which is code that will be executed by multiple threads in parallel. | |
Identifies code sections to be divided among all threads. | |
Lets you specify that a section of code should be executed on a single thread, not necessarily the master thread. | |
예제
_tprintf(_T("Start OpenMP\r\n"));
omp_set_num_threads(10);
_tprintf(_T("omp_get_max_threads() : %d\r\n"), omp_get_max_threads());
#pragma omp parallel
{
for(int i=0 ; i< 10; i++)
{
_tprintf(_T("%d"), i);
}
}Start OpenMP
omp_get_max_threads() : 10
01000000000123411111111234567222222225678933333333894444444456785555555678966666
69777777898888899999
_tprintf(_T("Start OpenMP\r\n"));
omp_set_num_threads(10);
_tprintf(_T("omp_get_max_threads() : %d\r\n"), omp_get_max_threads());
#pragma omp parallel for
for(int i=0 ; i< 10; i++)
{
_tprintf(_T("%d"), i);
}
or
#pragma omp parallel
{
#pragma omp for
for(int i=0 ; i< 10; i++)
{
_tprintf(_T("%d"), i);
}
}
Start OpenMP
omp_get_max_threads() : 10
0123456789
"프로그래밍 / TIP& Study" 분류의 다른 글
| [퀴즈] SQLite collate 문제 (0) | 2010/07/16 |
| [TIP] XP, Vista에서 CD/DVD롬이 보이지 않을 경우 (2) | 2009/08/05 |
| [C#] WinForm 에서 Docking 순서 변경하기 (0) | 2009/07/29 |
| [WPF] InkCanvas 사용하기 (2) | 2009/06/29 |
| [C#] Control Library 만들 때 TIP (0) | 2009/06/26 |
| [C#] 자연스럽게 Pen으로 그리기 (0) | 2009/06/23 |
| [WPF] Canvas의 Width, Height Binding (0) | 2009/06/23 |
| [C#] DateTime으로 7일 후는 어떻게? (0) | 2009/06/23 |

댓글을 달아 주세요