<div dir="ltr">Hi, Ramoni<div> Do you have a reproducible example? Usually it is because the cpu and gpu are out of synchronization. It could be a user's problem or petsc's.</div><div><br></div><div> Thanks.<br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">--Junchao Zhang</div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Aug 30, 2023 at 4:13 PM Ramoni Z. Sedano Azevedo <<a href="mailto:ramoni.zsedano@gmail.com">ramoni.zsedano@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hello,<br><br>I'm executing a code in Fortran using PETSc with MPI via CPU and I would like to execute it using GPU.<br>PETSc is configured as follows:<br></div><div>./configure \<br> --prefix=${PWD}/installdir \<br> --with-fortran \<br> --with-fortran-kernels=true \<br> --with-cuda \<br> --download-fblaslapack \<br> --with-scalar-type=complex \<br> --with-precision=double \<br> --with-debugging=0 \<br> --with-x=0 \<br> --with-gnu-compilers=1 \<br> --with-cc=mpicc \<br> --with-cxx=mpicxx \<br> --with-fc=mpif90 \<br> --with-make-exec=make</div><div><br></div><div>The parameters for using MPI on CPU are:<br></div><div>mpirun -np $ntasks ./${executable} \<br> -A_mat_type mpiaij \<br> -P_mat_type mpiaij \<br> -em_ksp_monitor_true_residual \<br> -em_ksp_type bcgs \<br> -em_pc_type bjacobi \<br> -em_sub_pc_type ilu \<br> -em_sub_pc_factor_levels 3 \<br> -em_sub_pc_factor_fill 6 \<br> < ./Parameters.inp<br></div><div><br></div><div>Code output:<br></div><div>Solving for Hz fields<br> bnorm 3.7727507818834821E-005<br> xnorm 2.3407405211699372E-016<br> Residual norms for em_ solve.<br> 0 KSP preconditioned resid norm 1.236208833927e-08 true resid norm 1.413045088306e-03 ||r(i)||/||b|| 3.745397377137e+01<br> 1 KSP preconditioned resid norm 1.664973208594e-10 true resid norm 3.463939828700e+00 ||r(i)||/||b|| 9.181470043910e+04<br> 2 KSP preconditioned resid norm 8.366983092820e-14 true resid norm 9.171051852915e-02 ||r(i)||/||b|| 2.430866066466e+03<br> 3 KSP preconditioned resid norm 1.386354386207e-14 true resid norm 1.905770367881e-02 ||r(i)||/||b|| 5.051408052270e+02<br> 4 KSP preconditioned resid norm 4.635883581096e-15 true resid norm 7.285180695640e-03 ||r(i)||/||b|| 1.930999717931e+02<br> 5 KSP preconditioned resid norm 1.974093227402e-15 true resid norm 2.953370060898e-03 ||r(i)||/||b|| 7.828161020018e+01<br> 6 KSP preconditioned resid norm 1.182781787023e-15 true resid norm 2.288756945462e-03 ||r(i)||/||b|| 6.066546871987e+01<br> 7 KSP preconditioned resid norm 6.221244366707e-16 true resid norm 1.263339414861e-03 ||r(i)||/||b|| 3.348589631014e+01<br> 8 KSP preconditioned resid norm 3.800488678870e-16 true resid norm 9.015738978063e-04 ||r(i)||/||b|| 2.389699054959e+01<br> 9 KSP preconditioned resid norm 2.498733213989e-16 true resid norm 7.194509577987e-04 ||r(i)||/||b|| 1.906966559396e+01<br> 10 KSP preconditioned resid norm 1.563017112250e-16 true resid norm 5.055208317846e-04 ||r(i)||/||b|| 1.339926385310e+01<br> 11 KSP preconditioned resid norm 8.733803057628e-17 true resid norm 3.171941303660e-04 ||r(i)||/||b|| 8.407502872682e+00<br> 12 KSP preconditioned resid norm 4.907010803529e-17 true resid norm 1.868311755294e-04 ||r(i)||/||b|| 4.952120782177e+00<br> 13 KSP preconditioned resid norm 2.214070343700e-17 true resid norm 8.760421740830e-05 ||r(i)||/||b|| 2.322025028236e+00<br> 14 KSP preconditioned resid norm 1.333171674446e-17 true resid norm 5.984548368534e-05 ||r(i)||/||b|| 1.586255948119e+00<br> 15 KSP preconditioned resid norm 7.696778066646e-18 true resid norm 3.786809196913e-05 ||r(i)||/||b|| 1.003726303656e+00<br> 16 KSP preconditioned resid norm 3.863008301366e-18 true resid norm 1.284864871601e-05 ||r(i)||/||b|| 3.405644702988e-01<br> 17 KSP preconditioned resid norm 2.061402843494e-18 true resid norm 1.054741071688e-05 ||r(i)||/||b|| 2.795681805311e-01<br> 18 KSP preconditioned resid norm 1.062033155108e-18 true resid norm 3.992776343462e-06 ||r(i)||/||b|| 1.058319664960e-01<br> converged reason 2<br> total number of relaxations 18<br> ========================================<br></div><div> <br></div><div>The parameters for GPU usage are:<br></div><div>mpirun -np $ntasks ./${executable} \<br> -A_mat_type aijcusparse \<br> -P_mat_type aijcusparse \<br> -vec_type cuda \<br> -use_gpu_aware_mpi 0 \<br> -em_ksp_monitor_true_residual \<br> -em_ksp_type bcgs \<br> -em_pc_type bjacobi \<br> -em_sub_pc_type ilu \<br> -em_sub_pc_factor_levels 3 \<br> -em_sub_pc_factor_fill 6 \<br> < ./Parameters.inp<br></div><div><br></div><div>Code output:</div>Solving for Hz fields<br> bnorm 3.7727507818834821E-005<br> xnorm 2.3407405211699372E-016<br> Residual norms for em_ solve.<br> 0 KSP preconditioned resid norm 1.236220954395e-08 true resid norm 3.772750781883e-05 ||r(i)||/||b|| 1.000000000000e+00<br> 1 KSP preconditioned resid norm 0.000000000000e+00 true resid norm 3.772750781883e-05 ||r(i)||/||b|| 1.000000000000e+00<br> converged reason 3<br> total number of relaxations 1<br> ========================================<div><br></div><div>Clearly the code running on GPU is not converging correctly.<br>Has anyone experienced this problem?<br><br>Sincerely,</div><div><div><div dir="ltr" class="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Ramoni Z. S. Azevedo</div><div dir="ltr"><br></div></div></div></div></div></div></div></div>
</blockquote></div>