OpenMPプログラミング→スケジューリング最適化
1449 ワード
void test20() { #pragma omp parallel for schedule(static, 2) //static ,for for (int i = 0; i < 10; ++i) // 5 , 0~1,4~5,8~9 , { std::cout << "Thread ID:" << omp_get_thread_num() << " Value:" << i << std::endl; } }
void test21() { #pragma omp parallel for schedule(dynamic, 2) //dynamic ,for for (int i = 0; i < 10; ++i) // 5 , , { std::cout << "Thread ID:" << omp_get_thread_num() << " Value:" << i << std::endl; } }
/* guided dynamic , 。 : :[ / ]。 guided , 1。 */ void test22() { #pragma omp parallel for schedule( guided, 10) for (int i = 0; i < 80; ++i) { std::cout << "Thread ID:" << omp_get_thread_num() << " Value:" << i << std::endl; } }
/* OMP_SCHEDULE */ #define OMP_SCHEDULE " dynamic, 5" void test23() { #pragma omp parallel for schedule( runtime) for (int i = 0; i < 80; ++i) { std::cout << "Thread ID:" << omp_get_thread_num() << " Value:" << i << std::endl; } }
転載先:https://blog.51cto.com/3754839/1401682