<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'><div dir='ltr'>
Hi everyone!<br><br>I've been experimenting a bit with adol-c and OpenMP (not differentiating<br>OpenMP code, just trying to paralellize some code that uses adoubles). Anyway,<br>I have a piece of code that looks something like this:<br><br>"adouble t1, t2;<br>adouble t0, tf;<br>t0.setValue(0.0); tf.setValue(1.0);<br>double nn[] = {1.0,2.0,3.0,4.0,5.0};<br>int i;<br> <br>#pragma omp parallel shared(t0,tf,nn) private(i,t1,t2)<br> {<br> #pragma omp for nowait<br> for (i=0;i<4;i++) {<br> t1 = (t0+tf)*nn[i];<br> t2 = (t0+tf)*nn[i+1];<br> std::cout << i << i+1 << t1.value() << t2.value();<br> }<br>}"<br><br>Now if I run the loop using just one thread everything works fine, but for more<br>than one I get some weird results, like, say, the following output:<br><br>0 1 1.000 2.000<br>2 3 3.000 2.000<br>3 4 4.000 4.000<br>1 2 2.000 3.000<br><br>Here I think the second line should read "2 3 3.000 4.000" and the third "3 4 4.000 5.000".<br><br>Anyone have an idea why this strange behavior occurs?<br><br>cheers<br>ingrid<br><br>                                            </div></body>
</html>