Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*
603 Discussions

dpc++ optimizing too much and producing wrong result

SUKLA
Beginner
734 Views

With O2 optimization, it produces wrong result whereas Intel 19.1 compiler produces correct result.

 

////////////////////////////////////////////////////


std::vector<SMDBL> dWdLambda(3,0.);
MATRIX2DZERO(d2Wd2Lambda, SMDBL, 3, 3);
for(INTL1 k=0; k<numMu_; k++){
SMDBL jInvAlpha = std::pow(jvalue,-alpha_[k]/3.);
SMDBL factor = jInvAlpha*mu_[k]/3.;
// factor *=
dWdLambda[0] += (factor/lambda[0])*(+2*std::pow(lambda[0],alpha_[k]) - std::pow(lambda[1],alpha_[k])
- std::pow(lambda[2],alpha_[k]));
dWdLambda[1] += (factor/lambda[1])*(-std::pow(lambda[0],alpha_[k]) + 2.*std::pow(lambda[1],alpha_[k])
- std::pow(lambda[2],alpha_[k]));
dWdLambda[2] += (factor/lambda[2])*(-std::pow(lambda[0],alpha_[k]) - std::pow(lambda[1],alpha_[k])
+ 2.*std::pow(lambda[2],alpha_[k]));
if(elPtr!=NULL){
if(elPtr->getUserID()==-99999999){
// NOTE: This is to avoid a bug in intel dpc++ compiler bug in O2 optimization(release module)
// Compiler is optimizing too much causing dWdLambda to be infinite.
// (probably compilier is doing some optimization). To remove this, please test with
// release module and dpc++ comiler.
PRINT_DIAG(ASSEMBLY_DIAG,0,"dWdLambda",&dWdLambda[0],3);
}
}

SMDBL factor2 = alpha_[k]*factor/3.; // alpha_[k]*mu(J^-alpha/3)/9
d2Wd2Lambda[0][0] += (factor2/lambda2[0])*(
4.*std::pow(lambda[0],alpha_[k])+std::pow(lambda[1],alpha_[k])+std::pow(lambda[2],alpha_[k]))
- (factor/lambda2[0])*(+2*std::pow(lambda[0],alpha_[k]) - std::pow(lambda[1],alpha_[k])
- std::pow(lambda[2],alpha_[k]));
d2Wd2Lambda[0][1] += (factor2/(lambda[0]*lambda[1]))*(
-2.*std::pow(lambda[0],alpha_[k]) - 2.*std::pow(lambda[1],alpha_[k]) + std::pow(lambda[2],alpha_[k]));
d2Wd2Lambda[0][2] += (factor2/(lambda[0]*lambda[2]))*(
-2.*std::pow(lambda[0],alpha_[k]) + std::pow(lambda[1],alpha_[k]) - 2*std::pow(lambda[2],alpha_[k]));


d2Wd2Lambda[1][1] += (factor2/lambda2[1])*(
std::pow(lambda[0],alpha_[k])+4.*std::pow(lambda[1],alpha_[k])+std::pow(lambda[2],alpha_[k]))
- (factor/lambda2[1])*(-std::pow(lambda[0],alpha_[k]) + 2.*std::pow(lambda[1],alpha_[k])
- std::pow(lambda[2],alpha_[k]));
d2Wd2Lambda[1][2] += (factor2/(lambda[1]*lambda[2]))*(
+ std::pow(lambda[0],alpha_[k]) - 2.*std::pow(lambda[1],alpha_[k]) - 2*std::pow(lambda[2],alpha_[k]));

d2Wd2Lambda[2][2] += (factor2/lambda2[2])*(
std::pow(lambda[0],alpha_[k])+std::pow(lambda[1],alpha_[k])+4.*std::pow(lambda[2],alpha_[k]))
- (factor/lambda2[2])*(-std::pow(lambda[0],alpha_[k]) - std::pow(lambda[1],alpha_[k])
+ 2.*std::pow(lambda[2],alpha_[k]));
}

///////////////////////////////////////////////////

0 Kudos
3 Replies
HemanthCH_Intel
Moderator
706 Views

Hi,


Thanks for reaching out to us.


Could you please provide the following information?

1)DPC++ version and OS you are using.

2)The complete sample reproducer code(The above provided code is not sufficient for analyzing your issue).

3)The compilation and execution command for reproducing this issue.

4)Screenshots for correct and incorrect results with respect to Intel compiler(19.1) and DPC++.


Thanks & Regards,

Hemanth.


0 Kudos
HemanthCH_Intel
Moderator
659 Views

Hi,


We haven't heard back from you. Could you please provide the above requested details?



Thanks & Regards,

Hemanth.


0 Kudos
HemanthCH_Intel
Moderator
616 Views

Hi,

 

We have not heard back from you. This thread will no longer be monitored by Intel. If you need further assistance, please post a new question.

 

Thanks & Regards,

Hemanth.

 

0 Kudos
Reply