1
我添加OpenMP代码的一些串行代码在模拟器上的一个应用,所有的线程执行的所有工作共享结构,当我运行使用该应用程序该程序与输出意外退出“线程‘的Win32线程’(0x1828)已经退出,代码1(为0x1)”,这种情况发生在哪里添加OpenMP代码并行区域, 这里有一个代码示例:应用程序使用OpenMP过早地退出,错误代码:致命用户错误1002:未通过
#pragma omp parallel for private (curr_proc_info, current_writer, method_h) shared (exceptionOccured) schedule(dynamic, 1)
for (i = 0 ; i < method_process_num ; i++)
{
current_writer = 0;
// we need to add protection before we can dequeue a method from the methods queue,
#pragma omp critical(dequeueMethod)
method_h = pop_runnable_method(curr_proc_info, current_writer);
if(method_h !=0 && exceptionOccured == false){
try {
method_h->semantics();
}
catch(const sc_report& ex) {
::std::cout << "\n" << ex.what() << ::std::endl;
m_error = true;
exceptionOccured = true; // we cannot jump outside the loop, so instead of return we use a flag and return somewhere else
}
}
}
调度是静态的前余使它动态,以后我添加动态1个的应用程序的块大小进行再稍微其离开之前,可以在此是正在发生的事情我的指示在平行区域? 感谢
感谢您的答复标志,有2种方式,使一个变量线程专用,你建议的人,和一个我使用,我将它们定义为在编译子句中私有的,他们是我贴的代码之前正确声明,否则我会得到一个编译错误,是的这是我使用的标志exceptionOccured的意图。 – Noona 2010-01-11 11:21:34
是的,你curr_proc_info您编译子句中定义的,但你传递到函数pop_runnable_method之前没有赋予它的价值。如果该函数需要curr_proc_info有一个值,你将会遇到问题。如果该函数为curr_proc_info指定一个值,那么我就没有想法了。 – 2010-01-11 12:45:01
我想为我调用的函数(使用引用调用)为它分配值。问题背后的原因与OpenMp调度或OpenMp相关,这是我希望获得建议的地方。 – Noona 2010-01-12 03:24:37