今天学习了OpenMP sections。sections的主要功能是用户可以将一个任务分成独立的几个section,每个section由不同的thread来处理。
C/C++测试代码:
int a = 2;
int b = 20;
int c = 200;
int d = 2000;
int sum;
omp_set_num_threads( 4 );
#pragma omp parallel
{
#pragma omp sections
{
#pragma omp section
{
a = 1;
printf("execute thread ID is %d/n", omp_get_thread_num());
}
#pragma omp section
{
b = 10;
printf("execute thread ID is %d/n", omp_get_thread_num());
}
#pragma omp section
{
c = 100;
printf("execute thread ID is %d/n", omp_get_thread_num());
}
#pragma omp section
{
d = 1000;
printf("execute thread ID is %d/n", omp_get_thread_