On Mon, 13 Feb 2012, recrusader wrote:

I am not sure that Jed mentioned the following stuff to you.
Now, I can realize GPU computation with libMesh and PETSc in one or two cards.
However, compared to CPU implementation, matrix assembly using GPU is very slow.

I take it the problem is that when you switch the matrix to a
GPU-based type, the sparsity data is lost?

Is it easy to add the following codes in libMesh?

I have no idea.  Forwarding to libmesh-devel, in case any of the more
PETSc-literate developers can say more.
---
Roy

Thank you very much,
Yujie

---------- Forwarded message ----------
From: Jed Brown <jedbr...@mcs.anl.gov>
Date: Sat, Feb 11, 2012 at 11:06 AM
Subject: Re: [petsc-users] MatSetValues() for MATMPICUSP
To: PETSc users list <petsc-us...@mcs.anl.gov>


On Sat, Feb 11, 2012 at 10:58, recrusader <recrusa...@gmail.com> wrote:
          "    ierr = MatCreateMPIAIJ (libMesh::COMM_WORLD,
                                    
  m_local, n_local,
                                m_global, n_global,
                                PETSC_NULL, (int*) &n_nz[0],
                                PETSC_NULL, (int*) &n_oz[0], &_mat);
             CHKERRABORT(libMesh::COMM_WORLD,ierr);

      MatSetOption(_mat,MAT_NEW_NONZERO_ALLOCATION_ERR,PETSC_FALSE); //by Yujie
      std::cout<<"MatSetOption"<<std::endl;"

I run the same codes in CPU and GPU modes (the same parameters except that GPU 
uses '-vec_type mpicusp -mat_type
mpiaijcusp'). I can find "MatSetOption" output from both the modes. Does that 
mean that the codes set the options for both
the modes?


Libmesh is calling MatSetFromOptions() after MatCreateMPIAIJ() which means the 
preallocation information will be lost if the
type is changed. The code should be written differently
  ierr = MatCreate(comm,A);CHKERRQ(ierr);
  ierr = MatSetSizes(*A,m,n,M,N);CHKERRQ(ierr);
  ierr = MPI_Comm_size(comm,&size);CHKERRQ(ierr);
  ierr = MatSetType(*A,MATAIJ);CHKERRQ(ierr);
  ierr = MatSetOptionsPrefix(*A,optional_prefix);CHKERRQ(ierr);
  ierr = MatSetFromOptions(*A);CHKERRQ(ierr);
  ierr = MatMPIAIJSetPreallocation(*A,d_nz,d_nnz,o_nz,o_nnz);CHKERRQ(ierr);
  ierr = MatSeqAIJSetPreallocation(*A,d_nz,d_nnz);CHKERRQ(ierr);

I can talk to the libmesh developers about making this change.
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Libmesh-devel mailing list
Libmesh-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-devel

Reply via email to