<div class="gmail_quote">On Sat, Aug 27, 2011 at 15:24, Likun Tan <span dir="ltr"><<a href="mailto:likunt@andrew.cmu.edu">likunt@andrew.cmu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div id=":1mz">g(temp) could be sum of temp[num][j][i] where num from 1 to N, so the<br>
index k is specified.</div></blockquote></div><br><div>It could be, but you still didn't explain how the indices i and j were made available to g() or what that code looks like. That is almost certainly your problem. You might want to try running with valgrind.</div>
<div><br></div><div>Also, this is totally the wrong memory layout for performance (you want to sum over the last index, unfortunately this requires changing your interpretation of the x,y,z directions).</div>