[sundials-users] Single precision in CVode

16 views
Skip to first unread message

Nurdinova, Aizada

unread,
Jun 24, 2022, 1:11:47 PM6/24/22
to SUNDIAL...@listserv.llnl.gov

Hi

I just had a short question about CVode solvers. I'm using Adams-Moulton linear multistep method with the FixedPoint nonlinear solver, and also CUDA N_Vectors.
So I was wondering if it's possible to switch to single-precision computations with such a set-up.

Sorry if I've missed some info in the documentation. With my test implementation, CVode solver refuses to integrate, that's why I decided to ask.

Kind regards,
Aizada.



To unsubscribe from the SUNDIALS-USERS list: write to: mailto:SUNDIALS-USERS-...@LISTSERV.LLNL.GOV

Balos, Cody Joe

unread,
Jun 24, 2022, 1:43:40 PM6/24/22
to SUNDIAL...@listserv.llnl.gov

You can build SUNDIALS for single precision by setting the CMake option SUNDIALS_PRECISION to single. It should then be possible to use single precision with CVODE, the FixedPoint nonlinear solver, and CUDA N_Vectors so long as your problem (and accuracy requirements) are amenable to single precision. What tolerance values are you using?

 

Regards,

Cody

Nurdinova, Aizada

unread,
Jun 27, 2022, 1:53:07 PM6/27/22
to SUNDIAL...@listserv.llnl.gov
Thank you for your reply, Cody!

I was setting scalar absolute tolerance to 1e-6 and relative tolerance to 1e-5 - 1e-4. Does these values make sense to you?

Best,
Aizada.
От: sundial...@llnl.gov <sundial...@llnl.gov> от имени Balos, Cody Joe <bal...@llnl.gov>
Отправлено: 24 июня 2022 г. 19:42:43
Кому: SUNDIAL...@LISTSERV.LLNL.GOV
Тема: Re: [sundials-users] Single precision in CVode
 

Balos, Cody Joe

unread,
Jun 27, 2022, 2:07:22 PM6/27/22
to SUNDIAL...@listserv.llnl.gov
Hi Aizada,

You said CVODE refuses to integrate. Did compiling with SUNDIALS_PRECISION set to single fix the problem? Are you still getting an error message? If yes, please copy it or describe it here. It would also help to know a bit more about the problem you're trying to solve.  I was thinking it could be that the relative tolerance you are using is too tight for single precision (machine epsilon ~10^-7). However, without knowing how CVODE is failing it is not obvious if this is why.

Regards,
Cody  

From: sundials-users <sundial...@llnl.gov> on behalf of Nurdinova, Aizada <aizada.n...@TUM.DE>
Sent: Saturday, June 25, 2022 5:38 PM
To: sundials-users <sundial...@llnl.gov>
Subject: Re: [sundials-users] Single precision in CVode
 

Nurdinova, Aizada

unread,
Jun 27, 2022, 2:50:43 PM6/27/22
to SUNDIAL...@listserv.llnl.gov

Hi Cody,

I am compiling CVode with SUNDIALS_PRECISION=single, but it doesn't solve the problem. 

So my solution does not move from the initial value even though the 'perturbation' with time is applied. I've tracked the issue and the RHS values are actually changing correctly and y_dot is set, but y stays the same. I've tried to play with ATOL and RTOL from 1e-2 till 1e-6, but the problem stayed. 

Have you ever experienced such an issue? What could it be?

Best and thanks for your help,
Aizada. 



От: sundial...@llnl.gov <sundial...@llnl.gov> от имени Balos, Cody Joe <bal...@llnl.gov>
Отправлено: 27 июня 2022 г. 20:06:42

Balos, Cody Joe

unread,
Jun 27, 2022, 2:55:30 PM6/27/22
to SUNDIAL...@listserv.llnl.gov
Without seeing your code it is hard to say what the problem could be. How are you accessing the data stored in the CUDA N_Vectors? You should be using N_VGetDeviceArrayPointer in the RHS and then operating on that data on the GPU (i.e. in a CUDA kernel). If you want to look at the data on the host (e.g., after the call to the CVode function) then you will need to call N_VCopyFromDevice_Cuda first.  See https://sundials.readthedocs.io/en/latest/sundials/GPU_link.html#sundials-gpu-programming-model for more info.

Cody

From: sundials-users <sundial...@llnl.gov> on behalf of Nurdinova, Aizada <aizada.n...@TUM.DE>
Sent: Monday, June 27, 2022 11:44 AM
To: sundials-users <sundial...@llnl.gov>
Subject: Re: [sundials-users] Single precision in CVode
 

Nurdinova, Aizada

unread,
Jun 27, 2022, 4:15:36 PM6/27/22
to SUNDIAL...@listserv.llnl.gov
Yes, my code is working with the double precision and fails after recompiling with the single :)
I'm not comfortable with posting the code on the forum but am happy to share and discuss with you directly.

Might be that I'm recompiling it wrongly. So I deleted all the related files from usr/local/include and lib. Then I cleaned up the build folder and  recompiled with the single precision flag. Is it the way one should do it?

Kind regards,
Aizada.
От: sundial...@llnl.gov <sundial...@llnl.gov> от имени Balos, Cody Joe <bal...@llnl.gov>
Отправлено: 27 июня 2022 г. 20:54:56
Reply all
Reply to author
Forward
0 new messages