在单独的线程中,需要调用mkl库的mkl_set_num_threads_local函数设置并行的线程数量:
int policy;
struct sched_param param;
pthread_getschedparam(pthread_self(), &policy, ¶m);
mkl_set_num_threads_local(8);
while (1)
{
wait_semt(0, 4);
#pragma omp parallel for
for (int i = 0; i < 10; ++i)
{
printf("test omp parallel for, %d\n", i);
}
// unimplement
}
如果不这么做,在某些Linux环境中,运行程序后可能会crash。