[问题] 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