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