Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong values and NaN if intermediates are created and destroyed repeatedly #5

Open
jpoto opened this issue May 24, 2023 · 2 comments
Open

Comments

@jpoto
Copy link

jpoto commented May 24, 2023

In my code I used intermediates I3/I4

      ierr=exatns_tensor_create(I3,"I3",id%vvoo,root%vvoo,EXA_DATA_KIND_C8)
      ierr=exatns_tensor_create(I4,"I4",id%vvoo,root%vvoo,EXA_DATA_KIND_C8)
      ierr=exatns_tensor_init(I3,ZERO)
      ierr=exatns_tensor_init(I4,ZERO)
      ierr=exatns_tensor_contract("T(e,a,k,n)+=X+(e,c,j,k)*Y(c,a,j,n)",I3,t2_v,t2_o)
      if (ierr.ne.0) call quit('laplace_get_T: contraction T12 wrong')
      ierr=exatns_tensor_contract("G(e,a,k,n)+=X+(a,b,i,e)*Y(b,n,k,i)",I4,vvov_v,vooo_o)
      if (ierr.ne.0) call quit('laplace_get_T: contraction G11 wrong')
      ierr=exatns_tensor_contract("R()+=T(e,a,k,n)*G(e,a,k,n)",T_tensor,I3,I4,ONE_QUARTER)
      if (ierr.ne.0) call quit('laplace_get_T: contraction 23 wrong')
      ierr=exatns_tensor_destroy(I3)
      ierr=exatns_tensor_destroy(I4)

and reused the intermediates in similar pieces of code.

At runtime I got NaN. Now I have grouped them and use only one create and destroy and the NaN's vanished. I still get a larger than expected error, but regrouping should solve it.

Therefore:
Avoid creating and destroying tensors too often.

@jpoto
Copy link
Author

jpoto commented May 24, 2023

I commented out the contraction giving NaN, but then the next contraction gave NaN.

@jpoto
Copy link
Author

jpoto commented May 30, 2023

I now circumvent this error by creating all intermediates in the beginning of the routine and destroying them at the end of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant