[問題] OpenMP平行處理的bug

作者: jason77623 (我思故我怪)   2015-04-22 21:31:26
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
VC++ 2012
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
Tifflib,Armadillo:C++ linear algebra library
問題(Question):
平行處理迴圈 內的變數獨立處理
餵入的資料(Input):
txt文字檔 amd 16bit TIFF影像
預期的正確結果(Expected Output):
錯誤結果(Wrong Output):
出現R6010 abort() has been called
程式碼(Code):(請善用置底文網頁, 記得排版)
void test(double &X, double &Y, double &Z,double parameter[6]){
...略...
mat B(4,3); //design matrix
mat Un; // unknows,XYZ的修正量
mat C(4,1);
mat V;
mat InN; //Inv(BTPB)
mat BTPB, BTPC;
X = 0.0;
Y = 0.0;
Z = 0.0;
for(uint8 iter=0;iter<20;iter++){ //iterative caculation
.
.
.

.
.
.
BTPB.fill(0);
BTPC.fill(0);
BTPB = trans(B)*B;
BTPC = trans(B)*C;
Un = inv(BTPB)*BTPC;
InN = inv(BTPB);
X = X+Un(0,0); //bug點應該是在這
Y = Y+Un(1,0);
Z = Z+Un(2,0);
if(fabs(Un)<pow(10,-5)){iter = 100;} //停止迴圈門檻
}
}
main{
//
作者: celestialgod (天)   2015-04-22 21:36:00
private(X, Y, Z) 找一下,設定於openmp應該是num_threads那一行
作者: jason77623 (我思故我怪)   2015-04-22 22:11:00
那我要在#pragma omp parallel前面宣告X,Y,Z嗎?
作者: celestialgod (天)   2015-04-22 22:13:00
當然。

Links booklink

Contact Us: admin [ a t ] ucptt.com