<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Feb 3, 2022, at 4:28 PM, Rohan Yadav <<a href="mailto:rohany@alumni.cmu.edu" class="">rohany@alumni.cmu.edu</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">To be concrete, the first matrix was <a href="https://sparse.tamu.edu/LAW/arabic-2005" class="">https://sparse.tamu.edu/LAW/arabic-2005</a> and the second was <a href="https://sparse.tamu.edu/Schenk/nlpkkt200" class="">https://sparse.tamu.edu/Schenk/nlpkkt200</a> (which looks like it does come from the PDE domain?).</div></div></blockquote><div><br class=""></div> You are correct; but the matrix bandwidth is so huge (see how far that off diagonal that second band of nonzeros is is) for two ranks this means the each MPI rank ends up needing the entire right hand side matrix to do the computation. Plus the 0 in the lower diagonal block means that on the second rank there is essentially no work to be done on the GPU at all. </div><div><br class=""></div><div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">Regardless of the non-zero structure, there is still a significant hit when moving from 1 gpu to multiple GPUs that causes a large number of device to host copies to be performed. If this is a result of the PETSc implementation thats fine -- but if there's something I can do to work around that it would be great.</div></div></div></blockquote><div><br class=""></div> I don't understand enough about the code that Stefeno pointed to know how easy the performance problem would be to fix in PETSc for sparse times dense matrix product It would still be a problem for the <a href="https://sparse.tamu.edu/Schenk/nlpkkt200" class="">nlpkkt200</a> as partitioned on two ranks no matter what, but in theory the problem can be fixed by improving the PETSc code. </div><div><br class=""></div><div> I recommend finding a different sparse matrix test case which has an appropriate nonzero data structuring and partitioning that one can expect good performance on. </div><div><br class=""></div><div><br class=""></div><div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">Rohan</div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 3, 2022 at 1:25 PM Barry Smith <<a href="mailto:bsmith@petsc.dev" class="">bsmith@petsc.dev</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;" class=""><div class=""><br class=""></div> I suspect the new matrix has a very different parallel nonzero structure that results in MOST of the calculations taking place on the CPU (since the "off-diagonal" part of the matrix dominates the non-zero pattern). PETSc is not designed for this type of nonzero structure and will give a bad performance (CPU or GPU); it is not a "PDE-ish" type of nonzero structure.<div class=""><br class=""></div><div class=""><br class=""><div class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Feb 3, 2022, at 2:59 PM, Rohan Yadav <<a href="mailto:rohany@alumni.cmu.edu" target="_blank" class="">rohany@alumni.cmu.edu</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class="">I'm sorry, I did a little switch here. The original log view I sent for 2 runs was on a different input matrix. Based on Barry's request I switched to a different matrix as the original one did not fit on 1 GPU.<div class=""><br class=""></div><div class="">> In the previously sent runs it was about 98% on GPU. </div><div class=""><br class=""></div><div class="">Re 98% on the GPU though, my first email had a similar ratio in the log though:</div><div class="">```<br class=""><pre style="white-space:pre-wrap" class="">MatMatMultNum 30 1.0 4.2967e+01 1.0 6.34e+11 1.1 6.0e+01 9.4e+07 0.0e+00 37100 86110 0 37100 86110 0 28598 920026 2 6.71e+03 30 8.73e+04 98<br class=""></pre><pre style="white-space:pre-wrap" class="">```</pre><pre style="white-space:pre-wrap" class="">The follow up log might be slightly different as well because I pushed a new log stage as requested by Stefano.</pre><pre style="white-space:pre-wrap" class=""><br class=""></pre><pre style="white-space:pre-wrap" class="">Rohan</pre></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 3, 2022 at 11:50 AM Barry Smith <<a href="mailto:bsmith@petsc.dev" target="_blank" class="">bsmith@petsc.dev</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class=""><div class=""><br class=""></div> Mark,<div class=""><br class=""></div><div class=""> Good eye. Something is definitely very different between this run and the previous (options, code change?). In the previously sent runs it was about 98% on GPU. </div><div class=""><br class=""></div><div class=""> Barry</div><div class=""><br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Feb 3, 2022, at 12:29 PM, Rohan Yadav <<a href="mailto:rohany@alumni.cmu.edu" target="_blank" class="">rohany@alumni.cmu.edu</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class="">> Please send the code that builds the sparse B matrix and the <span style="white-space:pre-wrap" class="">setMatToConstant() routine.</span><br class=""><br class="">Setting to a constant:<br class="">```<div class=""><span style="white-space:pre-wrap" class="">void setMatToConstant(Mat mat, PetscScalar c) {</span><pre style="white-space:pre-wrap" class=""> PetscInt rStart, rEnd, m, n;
MatGetSize(mat, &m, &n);
MatGetOwnershipRange(mat, &rStart, &rEnd);
for (int i = rStart; i < rEnd; i++) {
for (int j = 0; j < n; j++) {
MatSetValue(mat, i, j, c, INSERT_VALUES);
}
}
MatAssemblyBegin(mat, MAT_FINAL_ASSEMBLY);
MatAssemblyEnd(mat, MAT_FINAL_ASSEMBLY);
}
```
<br style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal" class=""></pre><pre style="white-space:pre-wrap" class=""><span style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal" class="">Loading sparse matrix from disk:</span><br style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal" class=""></pre><pre style="white-space:pre-wrap" class=""><span style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal" class="">```</span></pre><pre style="white-space:pre-wrap" class=""><pre style="white-space:pre-wrap" class="">int loadMatrixFromFile(Mat* A, char* filename) {
auto ierr = MatCreate(PETSC_COMM_WORLD, A); CHKERRQ(ierr);
MatSetFromOptions(*A);
PetscViewer viewer;
PetscViewerCreate(PETSC_COMM_WORLD, &viewer);
PetscViewerSetType(viewer, PETSCVIEWERBINARY);
PetscViewerFileSetMode(viewer, FILE_MODE_READ);
PetscViewerFileSetName(viewer, filename);
MatLoad(*A, viewer);
return 0;
}</pre></pre><pre style="white-space:pre-wrap" class=""><span style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal" class="">```</span></pre><pre style="white-space:pre-wrap" class=""><span style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;white-space:normal" class="">These are only called once and should not affect the computation in a loop though.</span></pre><pre style="white-space:pre-wrap" class="">> But first please verify that if you run with one MPI rank the "on GPU" and the overall flop rates for the MatMatMult() are almost the same and there is no copy from the GPU for each multiply?</pre><br class=""></div><div class="">Yes, with 1 mpi rank / GPU there are no extra copies done. As soon as I move to 2 ranks I see this behavior.</div><div class=""><br class=""></div><div class="">Here are updated logs with a new stage for 2 ranks. I've staged the logs into "MyComputation".</div><div class=""><br class="">```<br class="">---------------------------------------------- PETSc Performance Summary: ----------------------------------------------<br class=""><br class="">/g/g15/yadav2/taco/petsc/bin/benchmark on a named lassen572 with 2 processors, by yadav2 Thu Feb 3 09:27:30 2022<br class="">Using Petsc Release Version 3.16.3, unknown<br class=""><br class=""> Max Max/Min Avg Total<br class="">Time (sec): 2.091e+02 1.001 2.090e+02<br class="">Objects: 4.800e+01 1.000 4.800e+01<br class="">Flop: 4.344e+11 1.019 4.303e+11 8.606e+11<br class="">Flop/sec: 2.077e+09 1.018 2.059e+09 4.118e+09<br class="">MPI Messages: 3.500e+01 1.000 3.500e+01 7.000e+01<br class="">MPI Message Lengths: 6.316e+10 1.000 1.805e+09 1.263e+11<br class="">MPI Reductions: 8.100e+01 1.000<br class=""><br class="">Flop counting convention: 1 flop = 1 real number operation of type (multiply/divide/add/subtract)<br class=""> e.g., VecAXPY() for real vectors of length N --> 2N flop<br class=""> and VecAXPY() for complex vectors of length N --> 8N flop<br class=""><br class="">Summary of Stages: ----- Time ------ ----- Flop ------ --- Messages --- -- Message Lengths -- -- Reductions --<br class=""> Avg %Total Avg %Total Count %Total Avg %Total Count %Total<br class=""> 0: Main Stage: 1.0555e+02 50.5% 2.8686e+11 33.3% 3.000e+01 42.9% 1.466e+09 34.8% 4.300e+01 53.1%<br class=""> 1: MyComputation: 1.0345e+02 49.5% 5.7373e+11 66.7% 4.000e+01 57.1% 2.058e+09 65.2% 2.000e+01 24.7%<br class=""><br class="">------------------------------------------------------------------------------------------------------------------------<br class="">See the 'Profiling' chapter of the users' manual for details on interpreting output.<br class="">Phase summary info:<br class=""> Count: number of times phase was executed<br class=""> Time and Flop: Max - maximum over all processors<br class=""> Ratio - ratio of maximum to minimum over all processors<br class=""> Mess: number of messages sent<br class=""> AvgLen: average message length (bytes)<br class=""> Reduct: number of global reductions<br class=""> Global: entire computation<br class=""> Stage: stages of a computation. Set stages with PetscLogStagePush() and PetscLogStagePop().<br class=""> %T - percent time in this phase %F - percent flop in this phase<br class=""> %M - percent messages in this phase %L - percent message lengths in this phase<br class=""> %R - percent reductions in this phase<br class=""> Total Mflop/s: 10e-6 * (sum of flop over all processors)/(max time over all processors)<br class=""> GPU Mflop/s: 10e-6 * (sum of flop on GPU over all processors)/(max GPU time over all processors)<br class=""> CpuToGpu Count: total number of CPU to GPU copies per processor<br class=""> CpuToGpu Size (Mbytes): 10e-6 * (total size of CPU to GPU copies per processor)<br class=""> GpuToCpu Count: total number of GPU to CPU copies per processor<br class=""> GpuToCpu Size (Mbytes): 10e-6 * (total size of GPU to CPU copies per processor)<br class=""> GPU %F: percent flops on GPU in this event<br class="">------------------------------------------------------------------------------------------------------------------------<br class="">Event Count Time (sec) Flop --- Global --- --- Stage ---- Total GPU - CpuToGpu - - GpuToCpu - GPU<br class=""> Max Ratio Max Ratio Max Ratio Mess AvgLen Reduct %T %F %M %L %R %T %F %M %L %R Mflop/s Mflop/s Count Size Count Size %F<br class="">---------------------------------------------------------------------------------------------------------------------------------------------------------------<br class=""><br class="">--- Event Stage 0: Main Stage<br class=""><br class="">BuildTwoSided 2 1.0 4.0085e-0136.3 0.00e+00 0.0 2.0e+00 4.0e+00 2.0e+00 0 0 3 0 2 0 0 7 0 5 0 0 0 0.00e+00 0 0.00e+00 0<br class="">BuildTwoSidedF 1 1.0 4.0080e-0113602.0 0.00e+00 0.0 0.0e+00 0.0e+00 1.0e+00 0 0 0 0 1 0 0 0 0 2 0 0 0 0.00e+00 0 0.00e+00 0<br class="">MatAssemblyBegin 12 1.0 4.0084e-017217.1 0.00e+00 0.0 0.0e+00 0.0e+00 1.0e+00 0 0 0 0 1 0 0 0 0 2 0 0 0 0.00e+00 0 0.00e+00 0<br class="">MatAssemblyEnd 12 1.0 3.4970e+00 1.0 0.00e+00 0.0 0.0e+00 0.0e+00 6.0e+00 2 0 0 0 7 3 0 0 0 14 0 0 0 0.00e+00 0 0.00e+00 0<br class="">MatZeroEntries 1 1.0 2.4093e-03 1.0 0.00e+00 0.0 0.0e+00 0.0e+00 0.0e+00 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00e+00 0 0.00e+00 0<br class="">MatLoad 1 1.0 1.3756e+01 1.0 0.00e+00 0.0 6.0e+00 4.6e+08 2.1e+01 7 0 9 2 26 13 0 20 6 49 0 0 0 0.00e+00 0 0.00e+00 0<br class="">MatMatMultSym 20 1.0 4.7919e+00 2.4 0.00e+00 0.0 4.0e+00 1.6e+07 1.2e+01 2 0 6 0 15 3 0 13 0 28 0 0 0 0.00e+00 0 0.00e+00 0<br class="">MatMatMultNum 10 1.0 4.9853e+01 1.1 1.45e+11 1.0 2.0e+01 2.1e+09 0.0e+00 23 33 29 33 0 46100 67 94 0 5754 182686 2 2.23e+03 10 2.08e+04 5<br class="">MatCUSPARSCopyTo 1 1.0 2.2646e-02 1.1 0.00e+00 0.0 0.0e+00 0.0e+00 0.0e+00 0 0 0 0 0 0 0 0 0 0 0 0 1 1.55e+02 0 0.00e+00 0<br class="">MatDenseCopyTo 1 1.0 1.6636e-01 1.0 0.00e+00 0.0 0.0e+00 0.0e+00 0.0e+00 0 0 0 0 0 0 0 0 0 0 0 0 1 2.08e+03 0 0.00e+00 0<br class="">MatDenseCopyFrom 11 1.0 3.0463e+00 1.0 0.00e+00 0.0 0.0e+00 0.0e+00 0.0e+00 1 0 0 0 0 3 0 0 0 0 0 0 0 0.00e+00 11 2.29e+04 0<br class="">VecSet 3 1.0 5.0035e-04 1.0 0.00e+00 0.0 0.0e+00 0.0e+00 0.0e+00 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00e+00 0 0.00e+00 0<br class="">SFSetGraph 1 1.0 4.4294e-03 1.1 0.00e+00 0.0 0.0e+00 0.0e+00 0.0e+00 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00e+00 0 0.00e+00 0<br class="">SFSetUp 1 1.0 1.3982e-01 1.0 0.00e+00 0.0 4.0e+00 1.6e+07 1.0e+00 0 0 6 0 1 0 0 13 0 2 0 0 0 0.00e+00 0 0.00e+00 0<br class=""><br class="">--- Event Stage 1: MyComputation<br class=""><br class="">MatAssemblyBegin 20 1.0 1.6894e-05 2.7 0.00e+00 0.0 0.0e+00 0.0e+00 0.0e+00 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00e+00 0 0.00e+00 0<br class="">MatAssemblyEnd 20 1.0 1.5575e-05 1.5 0.00e+00 0.0 0.0e+00 0.0e+00 0.0e+00 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00e+00 0 0.00e+00 0<br class="">MatMatMultSym 40 1.0 1.0096e+01 2.6 0.00e+00 0.0 0.0e+00 0.0e+00 2.0e+01 3 0 0 0 25 7 0 0 0100 0 0 0 0.00e+00 0 0.00e+00 0<br class="">MatMatMultNum 20 1.0 9.9320e+01 1.1 2.90e+11 1.0 4.0e+01 2.1e+09 0.0e+00 46 67 57 65 0 93100100100 0 5777 182577 0 0.00e+00 20 4.16e+04 5<br class="">MatDenseCopyFrom 20 1.0 5.5380e+00 1.0 0.00e+00 0.0 0.0e+00 0.0e+00 0.0e+00 3 0 0 0 0 5 0 0 0 0 0 0 0 0.00e+00 20 4.16e+04 0<br class="">---------------------------------------------------------------------------------------------------------------------------------------------------------------<br class=""><br class="">Memory usage is given in bytes:<br class=""><br class="">Object Type Creations Destructions Memory Descendants' Mem.<br class="">Reports information only for process 0.<br class=""><br class="">--- Event Stage 0: Main Stage<br class=""><br class=""> Matrix 17 10 20381695840 0.<br class=""> Viewer 2 0 0 0.<br class=""> Vector 4 1 1792 0.<br class=""> Index Set 2 2 31848152 0.<br class=""> Star Forest Graph 3 0 0 0.<br class=""><br class="">--- Event Stage 1: MyComputation<br class=""><br class=""> Matrix 20 20 40763391680 0.<br class="">========================================================================================================================<br class="">Average time to get PetscTime(): 3.96e-08<br class="">Average time for MPI_Barrier(): 8.184e-07<br class="">Average time for zero size MPI_Send(): 2.8165e-06<br class="">#PETSc Option Table entries:<br class="">-bench spmm<br class="">-enable_gpu<br class="">-log_view<br class="">-mat_type aijcusparse<br class="">-matload_block_size 1<br class="">-matrix /p/gpfs1/yadav2/tensors/petsc/nlpkkt200.petsc<br class="">-n 20<br class="">-vec_type cuda<br class="">-warmup 10<br class="">#End of PETSc Option Table entries<br class="">Compiled without FORTRAN kernels<br class="">Compiled with full precision matrices (default)<br class="">sizeof(short) 2 sizeof(int) 4 sizeof(long) 8 sizeof(void*) 8 sizeof(PetscScalar) 8 sizeof(PetscInt) 4<br class="">Configure options: --download-c2html=0 --download-hwloc=0 --download-sowing=0 --prefix=./petsc-install/ --with-64-bit-indices=0 --with-blaslapack-lib="/usr/tcetmp/packages/lapack/lapack-3.9.0-gcc-7.3.1/lib/liblapack.so /usr/tcetmp/packages/lapack/lapack-3.9.0-gcc-7.3.1/lib/libblas.so" --with-cc=/usr/tce/packages/spectrum-mpi/spectrum-mpi-rolling-release-gcc-8.3.1/bin/mpigcc --with-clanguage=C --with-cxx-dialect=C++17 --with-cxx=/usr/tce/packages/spectrum-mpi/spectrum-mpi-rolling-release-gcc-8.3.1/bin/mpig++ --with-cuda=1 --with-debugging=0 --with-fc=/usr/tce/packages/spectrum-mpi/spectrum-mpi-rolling-release-gcc-8.3.1/bin/mpigfortran --with-fftw=0 --with-hdf5-dir=/usr/tcetmp/packages/petsc/build/3.13.0/spack/opt/spack/linux-rhel7-power9le/xl_r-16.1/hdf5-1.10.6-e7e7urb5k7va3ib7j4uro56grvzmcmd4 --with-hdf5=1 --with-mumps=0 --with-precision=double --with-scalapack=0 --with-scalar-type=real --with-shared-libraries=1 --with-ssl=0 --with-suitesparse=0 --with-trilinos=0 --with-valgrind=0 --with-x=0 --with-zlib-include=/usr/include --with-zlib-lib=/usr/lib64/libz.so --with-zlib=1 CFLAGS="-g -DNoChange" COPTFLAGS="-O3" CXXFLAGS="-O3" CXXOPTFLAGS="-O3" FFLAGS=-g CUDAFLAGS=-std=c++17 FOPTFLAGS= PETSC_ARCH=arch-linux-c-opt<br class="">-----------------------------------------<br class="">Libraries compiled on 2022-01-21 06:41:50 on lassen111<br class="">Machine characteristics: Linux-4.14.0-115.21.2.1chaos.ch6a.ppc64le-ppc64le-with-redhat-7.6-Maipo<br class="">Using PETSc directory: /g/g15/yadav2/taco/petsc/petsc/petsc-install<br class="">Using PETSc arch:<br class="">-----------------------------------------<br class=""><br class="">Using C compiler: /usr/tce/packages/spectrum-mpi/spectrum-mpi-rolling-release-gcc-8.3.1/bin/mpigcc -g -DNoChange -fPIC "-O3"<br class="">Using Fortran compiler: /usr/tce/packages/spectrum-mpi/spectrum-mpi-rolling-release-gcc-8.3.1/bin/mpigfortran -g -fPIC<br class="">-----------------------------------------<br class=""><br class="">Using include paths: -I/g/g15/yadav2/taco/petsc/petsc/petsc-install/include -I/usr/tcetmp/packages/petsc/build/3.13.0/spack/opt/spack/linux-rhel7-power9le/xl_r-16.1/hdf5-1.10.6-e7e7urb5k7va3ib7j4uro56grvzmcmd4/include -I/usr/include -I/usr/tce/packages/cuda/cuda-11.1.0/include<br class="">-----------------------------------------<br class=""><br class="">Using C linker: /usr/tce/packages/spectrum-mpi/spectrum-mpi-rolling-release-gcc-8.3.1/bin/mpigcc<br class="">Using Fortran linker: /usr/tce/packages/spectrum-mpi/spectrum-mpi-rolling-release-gcc-8.3.1/bin/mpigfortran<br class="">Using libraries: -Wl,-rpath,/g/g15/yadav2/taco/petsc/petsc/petsc-install/lib -L/g/g15/yadav2/taco/petsc/petsc/petsc-install/lib -lpetsc -Wl,-rpath,/usr/tcetmp/packages/lapack/lapack-3.9.0-gcc-7.3.1/lib -L/usr/tcetmp/packages/lapack/lapack-3.9.0-gcc-7.3.1/lib -Wl,-rpath,/usr/tcetmp/packages/petsc/build/3.13.0/spack/opt/spack/linux-rhel7-power9le/xl_r-16.1/hdf5-1.10.6-e7e7urb5k7va3ib7j4uro56grvzmcmd4/lib -L/usr/tcetmp/packages/petsc/build/3.13.0/spack/opt/spack/linux-rhel7-power9le/xl_r-16.1/hdf5-1.10.6-e7e7urb5k7va3ib7j4uro56grvzmcmd4/lib -Wl,-rpath,/usr/tce/packages/cuda/cuda-11.1.0/lib64 -L/usr/tce/packages/cuda/cuda-11.1.0/lib64 -Wl,-rpath,/usr/tce/packages/spectrum-mpi/ibm/spectrum-mpi-rolling-release/lib -L/usr/tce/packages/spectrum-mpi/ibm/spectrum-mpi-rolling-release/lib -Wl,-rpath,/usr/tce/packages/gcc/gcc-8.3.1/rh/usr/lib/gcc/ppc64le-redhat-linux/8 -L/usr/tce/packages/gcc/gcc-8.3.1/rh/usr/lib/gcc/ppc64le-redhat-linux/8 -Wl,-rpath,/usr/tce/packages/gcc/gcc-8.3.1/rh/usr/lib/gcc -L/usr/tce/packages/gcc/gcc-8.3.1/rh/usr/lib/gcc -Wl,-rpath,/usr/tce/packages/gcc/gcc-8.3.1/rh/usr/lib64 -L/usr/tce/packages/gcc/gcc-8.3.1/rh/usr/lib64 -Wl,-rpath,/usr/tce/packages/gcc/gcc-8.3.1/rh/usr/lib -L/usr/tce/packages/gcc/gcc-8.3.1/rh/usr/lib -llapack -lblas -lhdf5_hl -lhdf5 -lm /usr/lib64/libz.so -lcuda -lcudart -lcufft -lcublas -lcusparse -lcusolver -lcurand -lstdc++ -ldl -lmpiprofilesupport -lmpi_ibm_usempi -lmpi_ibm_mpifh -lmpi_ibm -lgfortran -lm -lgfortran -lm -lgcc_s -lquadmath -lpthread -lquadmath -lstdc++ -ldl<br class="">-----------------------------------------<br class="">```</div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 2, 2022 at 11:59 PM Stefano Zampini <<a href="mailto:stefano.zampini@gmail.com" target="_blank" class="">stefano.zampini@gmail.com</a>> wrote:<br class=""></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" class=""><div dir="ltr" class=""><br class=""></div><br class=""><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class=""><div class=""><div class=""><span style="white-space:pre-wrap" class="">1) It</span><span style="white-space:pre-wrap" class=""> uses MatMPIDenseScatter() to move to the other ranks their needed rows of the C matrix. That function has the call MatDenseGetArrayRead() normally would trigger a copy of C up to the CPU each time. But since C is not changing in your test run I guess it only triggers one copy.</span></div><div class=""><span style="white-space:pre-wrap" class=""><br class=""></span></div><div class=""><span style="white-space:pre-wrap" class="">2) If uses MatMatMultNumericAdd_SeqAIJ_SeqDense(aij->B,workB,cdense->A,PETSC_TRUE);CHKERRQ(ierr); to do the off diagonal part of the product but this triggers for each multiply a copy of the result matrix from the CPU to the GPU (hugely expensive)</span></div><div class=""><span style="white-space:pre-wrap" class=""></span> <br class=""></div></div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class=""><div class=""><div class=""><span style="white-space:pre-wrap" class=""></span></div><div class=""><span style="white-space:pre-wrap" class="">For performance there needs to be a new routine </span><span style="white-space:pre-wrap" class="">MatMatMultNumeric_MPIAIJCUSPRSE_MPICUDADense() that is smarter about the needed MPI communication so it only moves exactly what it needs to the other ranks and it does the off-diagonal part of the product on the GPU so it does not need to copy the result up to the CPU. </span></div><div class=""><span style="white-space:pre-wrap" class=""><br class=""></span></div></div></div></blockquote><div class=""><br class=""></div><div class="">MPIAIJCUSPARSE uses MatProductSetFromOptions_MPIAIJBACKEND</div><div class=""><br class=""></div><div class="">Rohan</div><div class="">I would suggest to add PetscLogStage around your performance loop (do a warmup outside of it) and send the relevant portion of the log<br class=""></div><div class=""> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class=""><div class=""><div class=""><span style="white-space:pre-wrap" class=""></span></div><div class=""><span style="white-space:pre-wrap" class="">Barry</span></div><div class=""><span style="white-space:pre-wrap" class=""><br class=""></span></div><div class=""><span style="white-space:pre-wrap" class=""><br class=""></span></div><div class=""><span style="white-space:pre-wrap" class=""><br class=""></span></div><div class=""><span style="white-space:pre-wrap" class=""><br class=""></span></div><div class=""><span style="white-space:pre-wrap" class=""><br class=""></span></div><div class=""><span style="white-space:pre-wrap" class=""><br class=""></span></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><pre class="">---------------------------------------------- PETSc Performance Summary: ----------------------------------------------<br class=""><br class="">/g/g15/yadav2/taco/petsc/bin/benchmark on a named lassen457 with 2 processors, by yadav2 Wed Feb 2 17:23:19 2022<br class="">Using Petsc Release Version 3.16.3, unknown<br class=""><br class=""> Max Max/Min Avg Total<br class="">Time (sec): 1.163e+02 1.000 1.163e+02<br class="">Objects: 4.800e+01 1.000 4.800e+01<br class="">Flop: 6.338e+11 1.065 6.144e+11 1.229e+12<br class="">Flop/sec: 5.451e+09 1.065 5.284e+09 1.057e+10<br class="">MPI Messages: 3.500e+01 1.000 3.500e+01 7.000e+01<br class="">MPI Message Lengths: 2.544e+09 1.000 7.267e+07 5.087e+09<br class="">MPI Reductions: 8.100e+01 1.000<br class=""><br class="">Flop counting convention: 1 flop = 1 real number operation of type (multiply/divide/add/subtract)<br class=""> e.g., VecAXPY() for real vectors of length N --> 2N flop<br class=""> and VecAXPY() for complex vectors of length N --> 8N flop<br class=""><br class="">Summary of Stages: ----- Time ------ ----- Flop ------ --- Messages --- -- Message Lengths -- -- Reductions --<br class=""> Avg %Total Avg %Total Count %Total Avg %Total Count %Total<br class=""> 0: Main Stage: 1.1628e+02 100.0% 1.2288e+12 100.0% 7.000e+01 100.0% 7.267e+07 100.0% 6.300e+01 77.8%<br class=""><br class="">------------------------------------------------------------------------------------------------------------------------<br class="">See the 'Profiling' chapter of the users' manual for details on interpreting output.<br class="">Phase summary info:<br class=""> Count: number of times phase was executed<br class=""> Time and Flop: Max - maximum over all processors<br class=""> Ratio - ratio of maximum to minimum over all processors<br class=""> Mess: number of messages sent<br class=""> AvgLen: average message length (bytes)<br class=""> Reduct: number of global reductions<br class=""> Global: entire computation<br class=""> Stage: stages of a computation. Set stages with PetscLogStagePush() and PetscLogStagePop().<br class=""> %T - percent time in this phase %F - percent flop in this phase<br class=""> %M - percent messages in this phase %L - percent message lengths in this phase<br class=""> %R - percent reductions in this phase<br class=""> Total Mflop/s: 10e-6 * (sum of flop over all processors)/(max time over all processors)<br class=""> GPU Mflop/s: 10e-6 * (sum of flop on GPU over all processors)/(max GPU time over all processors)<br class=""> CpuToGpu Count: total number of CPU to GPU copies per processor<br class=""> CpuToGpu Size (Mbytes): 10e-6 * (total size of CPU to GPU copies per processor)<br class=""> GpuToCpu Count: total number of GPU to CPU copies per processor<br class=""> GpuToCpu Size (Mbytes): 10e-6 * (total size of GPU to CPU copies per processor)<br class=""> GPU %F: percent flops on GPU in this event<br class="">------------------------------------------------------------------------------------------------------------------------<br class="">Event Count Time (sec) Flop --- Global --- --- Stage ---- Total GPU - CpuToGpu - - GpuToCpu - GPU<br class=""> Max Ratio Max Ratio Max Ratio Mess AvgLen Reduct %T %F %M %L %R %T %F %M %L %R Mflop/s Mflop/s Count Size Count Size %F<br class="">---------------------------------------------------------------------------------------------------------------------------------------------------------------<br class=""><br class="">--- Event Stage 0: Main Stage<br class=""><br class="">BuildTwoSided 2 1.0 4.4400e-01567.5 0.00e+00 0.0 2.0e+00 4.0e+00 2.0e+00 0 0 3 0 2 0 0 3 0 3 0 0 0 0.00e+00 0 0.00e+00 0<br class="">BuildTwoSidedF 1 1.0 4.4395e-0115659.1 0.00e+00 0.0 0.0e+00 0.0e+00 1.0e+00 0 0 0 0 1 0 0 0 0 2 0 0 0 0.00e+00 0 0.00e+00 0<br class="">MatAssemblyBegin 32 1.0 4.4400e-017378.9 0.00e+00 0.0 0.0e+00 0.0e+00 1.0e+00 0 0 0 0 1 0 0 0 0 2 0 0 0 0.00e+00 0 0.00e+00 0<br class="">MatAssemblyEnd 32 1.0 1.8511e+00 2.2 0.00e+00 0.0 0.0e+00 0.0e+00 6.0e+00 1 0 0 0 7 1 0 0 0 10 0 0 0 0.00e+00 0 0.00e+00 0<br class="">MatZeroEntries 1 1.0 3.3306e-03 1.0 0.00e+00 0.0 0.0e+00 0.0e+00 0.0e+00 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00e+00 0 0.00e+00 0<br class="">MatLoad 1 1.0 1.7220e+01 1.0 0.00e+00 0.0 6.0e+00 -8.8e+07 2.1e+01 15 0 9-10 26 15 0 9-10 33 0 0 0 0.00e+00 0 0.00e+00 0<br class="">MatMatMultSym 60 1.0 9.2215e-01 2.6 0.00e+00 0.0 4.0e+00 7.3e+05 3.2e+01 1 0 6 0 40 1 0 6 0 51 0 0 0 0.00e+00 0 0.00e+00 0<br class="">MatMatMultNum 30 1.0 4.2967e+01 1.0 6.34e+11 1.1 6.0e+01 9.4e+07 0.0e+00 37100 86110 0 37100 86110 0 28598 920026 2 6.71e+03 30 8.73e+04 98<br class="">MatCUSPARSCopyTo 1 1.0 4.4761e-01 1.0 0.00e+00 0.0 0.0e+00 0.0e+00 0.0e+00 0 0 0 0 0 0 0 0 0 0 0 0 1 3.80e+03 0 0.00e+00 0<br class="">MatDenseCopyTo 1 1.0 2.2742e-01 1.0 0.00e+00 0.0 0.0e+00 0.0e+00 0.0e+00 0 0 0 0 0 0 0 0 0 0 0 0 1 2.91e+03 0 0.00e+00 0<br class="">MatDenseCopyFrom 31 1.0 1.2006e+01 1.0 0.00e+00 0.0 0.0e+00 0.0e+00 0.0e+00 10 0 0 0 0 10 0 0 0 0 0 0 0 0.00e+00 31 9.02e+04 0<br class="">VecSet 3 1.0 4.1917e-04 1.1 0.00e+00 0.0 0.0e+00 0.0e+00 0.0e+00 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00e+00 0 0.00e+00 0<br class="">SFSetGraph 1 1.0 1.9180e-04 1.1 0.00e+00 0.0 0.0e+00 0.0e+00 0.0e+00 0 0 0 0 0 0 0 0 0 0 0 0 0 0.00e+00 0 0.00e+00 0<br class="">SFSetUp 1 1.0 1.3672e-02 1.1 0.00e+00 0.0 4.0e+00 7.3e+05 1.0e+00 0 0 6 0 1 0 0 6 0 2 0 0 0 0.00e+00 0 0.00e+00 0<br class="">---------------------------------------------------------------------------------------------------------------------------------------------------------------<br class=""><br class="">Memory usage is given in bytes:<br class=""><br class="">Object Type Creations Destructions Memory Descendants' Mem.<br class="">Reports information only for process 0.<br class=""><br class="">--- Event Stage 0: Main Stage<br class=""><br class=""> Matrix 37 30 2867511840 0.<br class=""> Viewer 2 0 0 0.<br class=""> Vector 4 1 1792 0.<br class=""> Index Set 2 2 1495248 0.<br class=""> Star Forest Graph 3 0 0 0.<br class="">========================================================================================================================<br class="">Average time to get PetscTime(): 3.83e-08<br class="">Average time for MPI_Barrier(): 7.874e-07<br class="">Average time for zero size MPI_Send(): 3.4035e-06<br class="">#PETSc Option Table entries:<br class="">-bench spmm<br class="">-enable_gpu<br class="">-log_view<br class="">-mat_type aijcusparse<br class="">-matload_block_size 1<br class="">-matrix /p/gpfs1/yadav2/tensors/petsc/arabic-2005.petsc<br class="">-n 20<br class="">-vec_type cuda<br class="">-warmup 10
```</pre><pre class=""><br class=""></pre><pre class="">Thanks,</pre><pre class=""><br class=""></pre><pre class="">Rohan Yadav</pre><pre class=""><font face="Arial, Helvetica, sans-serif" class=""><span style="white-space:normal" class=""><br class=""></span></font></pre></div></div>
</div></blockquote></div><br class=""></div></blockquote></div><br clear="all" class=""><br class="">-- <br class=""><div dir="ltr" class="">Stefano</div></div>
</blockquote></div>
</div></blockquote></div><br class=""></div></div></blockquote></div>
</div></blockquote></div><br class=""></div></div></div></blockquote></div>
</div></blockquote></div><br class=""></body></html>