Re: [petsc-users] petsc4py, cython

2018-01-30 Thread Jaroslaw Piwonski (CAU)
Dear Lisandro, > Am 18.01.2018 um 17:13 schrieb Lisandro Dalcin : > > In Cython code using C types from petsc4py, you should do: > > from petsc4py.PETSc cimport Vec, PetscVec > from petsc4py.PETSc cimport Mat, PetscMat > # etcetera > > now you can "cdef" either "PetscVec"

Re: [petsc-users] Petsc messing with OpenMP

2018-01-30 Thread Satish Balay
Try building PETSc with -qopenmp flag and see if this makes a difference. i.e use CFLAGS=-qopenmp FFLAGS=-qopenmp CXXFLAGS=-qopenmp Potential explanation: Compilers do different things internally [for ex - link to different libraries] when different compile flags are used. When -qopenmp is

Re: [petsc-users] Petsc messing with OpenMP

2018-01-30 Thread Timothée Nicolas
Thank you very much Barry, it works indeed to build petsc with the qopenmp flags! Best Timothee 2018-01-30 18:46 GMT+01:00 Satish Balay : > Try building PETSc with -qopenmp flag and see if this makes a difference. > > i.e use CFLAGS=-qopenmp FFLAGS=-qopenmp CXXFLAGS=-qopenmp

Re: [petsc-users] Petsc messing with OpenMP

2018-01-30 Thread Timothée Nicolas
Thank you for your answer, I am not responsible for the choices in this code to begin with, but in any case, as you can see in the example, I am not using any petsc call. Also in our code, even though openmp is used, this is never in interaction with petsc, the latter being used only at a

Re: [petsc-users] Petsc messing with OpenMP

2018-01-30 Thread Smith, Barry F.
I don't know what you are trying to do with OpenMP and PETSc, nor do I understand why anyone would use OpenMP, but you cannot call virtually any PETSc function or operation while you are using threads. Best to use PETSc as intended, with one MPI process per core or hardware thread and

[petsc-users] Petsc messing with OpenMP

2018-01-30 Thread Timothée Nicolas
Dear petsc team, For a while, I have been wondering why I have never managed to print what threads are doing in an openMP region in my FORTRAN programs. Some people told me it was normal because threads will get confused all trying to write at the same time. However I realised today that the

Re: [petsc-users] combine two matrices with different non-zero structure

2018-01-30 Thread Marius Buerkle
Barry,   Thanks for you reply. The pulled matrix is symmetric but that's it. At the moment I am doing a copy of the matrix right after MatCreateSubMatrix to keep it's nonzero structure. To insert the matrix which I obtained after the multiplications back into the bigger matrix I use the

Re: [petsc-users] combine two matrices with different non-zero structure

2018-01-30 Thread Smith, Barry F.
Could you tell us exactly what matrix matrix products you are doing? Barry > On Jan 30, 2018, at 6:53 PM, Marius Buerkle wrote: > > Barry, > > Thanks for you reply. The pulled matrix is symmetric but that's it. At the > moment I am doing a copy of the matrix right

Re: [petsc-users] combine two matrices with different non-zero structure

2018-01-30 Thread Smith, Barry F.
> On Jan 30, 2018, at 6:53 PM, Marius Buerkle wrote: > > Barry, > > Thanks for you reply. The pulled matrix is symmetric but that's it. At the > moment I am doing a copy of the matrix right after MatCreateSubMatrix to keep > it's nonzero structure. To insert the matrix

Re: [petsc-users] combine two matrices with different non-zero structure

2018-01-30 Thread Marius Buerkle
The matrix A is the extracted submatrix and I am basicallly doing something like this D=A+B'*C*B. Where A, B, and C are sparse but B'*C*C will clearly generate some addional nonzero entries in D. And D should go back into the bigger matrix but only the entries which are already nonzero in A.  

Re: [petsc-users] combine two matrices with different non-zero structure

2018-01-30 Thread Marius Buerkle
Not sure how much overhead it produces but copying the actual values with MatGetRow is not necessary as I only need the col position of the nonzero elements in each row.  Inserting the Matrix back is not so complicated as the submatrix is a continous square matrix from somewhere in the bigger

Re: [petsc-users] combine two matrices with different non-zero structure

2018-01-30 Thread Smith, Barry F.
To do this most efficiently you would compute exactly the part of F = B'*C*B you need (that matches the nonzero pattern of A) do a MatAXPY() with same numerical pattern and then just stick the values of D into the original matrix (without worrying about excluding the new nonzeros since

Re: [petsc-users] combine two matrices with different non-zero structure

2018-01-30 Thread Marius Buerkle
Thanks. While B'*C*B may not have the same nonzero pattern as A it does not matter as this is done by MaTAXPY with different nonzero pattern it should not matter when using  MatPtAPNumeric_MPIAIJ_MPIAIJ_scalable()  with a restricted reduction. I will give it a try.       To do this most

Re: [petsc-users] combine two matrices with different non-zero structure

2018-01-30 Thread Smith, Barry F.
MaTAXPY with same nonzero pattern is much faster. > On Jan 30, 2018, at 10:10 PM, Marius Buerkle wrote: > > Thanks. While B'*C*B may not have the same nonzero pattern as A it does not > matter as this is done by MaTAXPY with different nonzero pattern it should > not matter