#pragma omp parallel
{
#pragma omp for // schedule(static, 2)
for (int i = 0; i < 5; i++) {
std::cout << "[" << omp_get_thread_num() << "]Test1" << std::endl;
std::cout << "[" << omp_get_thread_num() << "]Test2" << std::endl;
}
#pragma omp for // schedule(static, 2)
for (int i = 0; i < 5; i++) {
std::cout << "[" << omp_get_thread_num() << "]Test3" << std::endl;
std::cout << "[" << omp_get_thread_num() << "]Test4" << std::endl;
}
}
比如这段代码, 我想要让上面的循环和下面的循环同时并行分担执行, 要怎么改? 比如上面6个线程, 下面6个线程
--
FROM 104.243.25.*