[petsc-dev] MatCreateMPIAIJ(), MatCreateMPIBAIJ(), MatCreateMPISBAIJ() wrongly named
MatCreateMPIAIJ(), MatCreateMPIBAIJ(), MatCreateMPISBAIJ() actually create Seq version of the matrices when run on one process. Meanwhile MatMPIXXXSetPreallocation() always do preallocation for MPI case. Shouldn't MatCreateMPIXXX() be MatCreateXXX()? Also should we add MatXXXSetPreallocation() that calls both MatSeqXXXSetPreallocation() and MatMPIXXXSetPreallocation()? Barry
[petsc-dev] MatCreateMPIAIJ(), MatCreateMPIBAIJ(), MatCreateMPISBAIJ() wrongly named
On Thu, Mar 1, 2012 at 11:03 AM, Barry Smith wrote: > >MatCreateMPIAIJ(), MatCreateMPIBAIJ(), MatCreateMPISBAIJ() actually > create Seq version of the matrices when run on one process. > >Meanwhile MatMPIXXXSetPreallocation() always do preallocation for MPI > case. > >Shouldn't MatCreateMPIXXX() be MatCreateXXX()? > I agree, and we already have MATAIJ so it matches a type. >Also should we add MatXXXSetPreallocation() that calls both > MatSeqXXXSetPreallocation() and MatMPIXXXSetPreallocation()? In fact, that exists: MatXAIJSetPreallocation(). I use it for DMComplex. Matt > >Barry > > -- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener -- next part -- An HTML attachment was scrubbed... URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20120301/2d09eb40/attachment.html>
[petsc-dev] MatCreateMPIAIJ(), MatCreateMPIBAIJ(), MatCreateMPISBAIJ() wrongly named
On Mar 1, 2012, at 11:11 AM, Matthew Knepley wrote: > On Thu, Mar 1, 2012 at 11:03 AM, Barry Smith wrote: > >MatCreateMPIAIJ(), MatCreateMPIBAIJ(), MatCreateMPISBAIJ() actually > create Seq version of the matrices when run on one process. > >Meanwhile MatMPIXXXSetPreallocation() always do preallocation for MPI case. > >Shouldn't MatCreateMPIXXX() be MatCreateXXX()? > > I agree, and we already have MATAIJ so it matches a type. > >Also should we add MatXXXSetPreallocation() that calls both > MatSeqXXXSetPreallocation() and MatMPIXXXSetPreallocation()? > > In fact, that exists: MatXAIJSetPreallocation(). I use it for DMComplex. Cool. Some suggestions for this routine: 1) get rid of the maximum number of non-zeros per row arguments, they are stupid and just make this calling sequence too damn complicated looking. 2) the manual page doesn't make clear these are nonzero BLOCKS per row, not nonzero entries per row. Barry Input Arguments: + A - matrix being preallocated . bs - block size . dnz - maximum number of nonzero entries per row of diagonal block of parallel matrix . dnnz - number of nonzeros per row of diagonal block of parallel matrix . onz - maximum number of nonzero entries per row of off-diagonal block of parallel matrix . onnz - number of nonzeros per row of off-diagonal block of parallel matrix . dnzu - maximum number of nonzero entries per row of upper-triangular part of diagonal block of parallel matrix . dnnzu - number of nonzeros per row of upper-triangular part of diagonal block of parallel matrix . onzu - maximum number of nonzero entries per row of upper-triangular part of off-diagonal block of parallel matrix - onnzu - number of nonzeros per row of upper-triangular part of off-diagonal block of parallel matrix > >Matt > > >Barry > > > > > -- > What most experimenters take for granted before they begin their experiments > is infinitely more interesting than any results to which their experiments > lead. > -- Norbert Wiener
[petsc-dev] MatCreateMPIAIJ(), MatCreateMPIBAIJ(), MatCreateMPISBAIJ() wrongly named
On Thu, Mar 1, 2012 at 11:31, Barry Smith wrote: > Cool. Some suggestions for this routine: > > 1) get rid of the maximum number of non-zeros per row arguments, they are > stupid and just make this calling sequence too damn complicated looking. > Okay, I thought I would help people out who wanted to punt, but I don't mind removing it. > > 2) the manual page doesn't make clear these are nonzero BLOCKS per row, > not nonzero entries per row. > fixing > > Barry > > > Input Arguments: > + A - matrix being preallocated > . bs - block size > . dnz - maximum number of nonzero entries per row of diagonal block of > parallel matrix > . dnnz - number of nonzeros per row of diagonal block of parallel matrix > . onz - maximum number of nonzero entries per row of off-diagonal block > of parallel matrix > . onnz - number of nonzeros per row of off-diagonal block of parallel > matrix > . dnzu - maximum number of nonzero entries per row of upper-triangular > part of diagonal block of parallel matrix > . dnnzu - number of nonzeros per row of upper-triangular part of diagonal > block of parallel matrix > . onzu - maximum number of nonzero entries per row of upper-triangular > part of off-diagonal block of parallel matrix > - onnzu - number of nonzeros per row of upper-triangular part of > off-diagonal block of parallel matrix > -- next part -- An HTML attachment was scrubbed... URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20120301/14ae4d7e/attachment.html>
[petsc-dev] MatCreateMPIAIJ(), MatCreateMPIBAIJ(), MatCreateMPISBAIJ() wrongly named
On Mar 1, 2012, at 11:37 AM, Jed Brown wrote: > On Thu, Mar 1, 2012 at 11:31, Barry Smith wrote: > Cool. Some suggestions for this routine: > > 1) get rid of the maximum number of non-zeros per row arguments, they are > stupid and just make this calling sequence too damn complicated looking. > > Okay, I thought I would help people out who wanted to punt, but I don't mind > removing it. I just want it removed from the XAIJ preallocation one, not the individual preallocation ones, leave that them in that one. > > > 2) the manual page doesn't make clear these are nonzero BLOCKS per row, not > nonzero entries per row. > > fixing > > > Barry > > > Input Arguments: > + A - matrix being preallocated > . bs - block size > . dnz - maximum number of nonzero entries per row of diagonal block of > parallel matrix > . dnnz - number of nonzeros per row of diagonal block of parallel matrix > . onz - maximum number of nonzero entries per row of off-diagonal block of > parallel matrix > . onnz - number of nonzeros per row of off-diagonal block of parallel matrix > . dnzu - maximum number of nonzero entries per row of upper-triangular part > of diagonal block of parallel matrix > . dnnzu - number of nonzeros per row of upper-triangular part of diagonal > block of parallel matrix > . onzu - maximum number of nonzero entries per row of upper-triangular part > of off-diagonal block of parallel matrix > - onnzu - number of nonzeros per row of upper-triangular part of > off-diagonal block of parallel matrix >
[petsc-dev] MatCreateMPIAIJ(), MatCreateMPIBAIJ(), MatCreateMPISBAIJ() wrongly named
On Thu, Mar 1, 2012 at 11:39, Barry Smith wrote: > I just want it removed from the XAIJ preallocation one, not the > individual preallocation ones, leave that them in that one. http://petsc.cs.iit.edu/petsc/petsc-dev/rev/6a8a730dd0af -- next part -- An HTML attachment was scrubbed... URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20120301/ad736af8/attachment.html>
[petsc-dev] MatCopy to zero preallocated matrix
On Thu, Mar 1, 2012 at 5:03 PM, Vaclav Hapla wrote: > Dear PETSc team, > why I am not able to do this: > > ... > MatCreate(PETSC_COMM_SELF, &Kreg); > MatSetSizes(Kreg,m,n,m,n); > MatSetType(Kreg, MATSEQAIJ); > MatSeqAIJSetPreallocation(**Kreg,0,nnz); > MatAssemblyBegin(Kreg, MAT_FINAL_ASSEMBLY); > MatAssemblyEnd( Kreg, MAT_FINAL_ASSEMBLY); > PetscFree(nnz); > { >PetscInt nz_Kreg; >MatGetRow(Kreg, 0, &nz_Kreg, PETSC_IGNORE, PETSC_IGNORE); >PetscPrintf(PETSC_COMM_SELF, "nnz %d Kreg %d\n", nnz[0], nz_Kreg); // > prints nnz 11 Kreg 0 !!! > } > MatCopy(K_loc, Kreg, DIFFERENT_NONZERO_PATTERN); //fails: New nonzero at > (0,0) caused a malloc! > I think you want http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatDuplicate.html which does it in one line. Matt > > PETSc complains about new nonzero - not surprisingly because > MatAssemblyBegin/End filters zeros as I understand. > But when I comment out MatAssemblyBegin/End, MatCopy complains that it is > only for assembled matrices. > > I think that to call MatSetValues on all allocated nonzeros just to make > them survive MatAssemblyBegin/End or to replace MatCopy call by loop over > raw array is both quite awkward. > Maybe one should be able to turn the filter in MatAssemblyBegin/End off. > Or is there any other way out? > > BTW, what I need is to make a copy Kreg of given matrix K_loc but with few > additional preallocated positions which are filled later. Is there some > other convenient solution? > > Cheers, > Vaclav Hapla > -- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener -- next part -- An HTML attachment was scrubbed... URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20120301/80013715/attachment.html>
[petsc-dev] MatCopy to zero preallocated matrix
On Thu, Mar 1, 2012 at 5:14 PM, Vaclav Hapla wrote: > ** > This is what I used before for a long time until now when I updated PETSc > and it started to complain "New nonzero caused a malloc!" when I wanted to > add > You can turn off this message using MatSetOption(). We put it there so people know when allocation is being done since it can be slow. Thanks, Matt > some new nonzero outside of the original nnz-pattern. MatDuplicate is > always retaining the pattern, isn't it? > Vaclav > > On 03/02/2012 12:06 AM, Matthew Knepley wrote: > > On Thu, Mar 1, 2012 at 5:03 PM, Vaclav Hapla wrote: > >> Dear PETSc team, >> why I am not able to do this: >> >> ... >> MatCreate(PETSC_COMM_SELF, &Kreg); >> MatSetSizes(Kreg,m,n,m,n); >> MatSetType(Kreg, MATSEQAIJ); >> MatSeqAIJSetPreallocation(Kreg,0,nnz); >> MatAssemblyBegin(Kreg, MAT_FINAL_ASSEMBLY); >> MatAssemblyEnd( Kreg, MAT_FINAL_ASSEMBLY); >> PetscFree(nnz); >> { >>PetscInt nz_Kreg; >>MatGetRow(Kreg, 0, &nz_Kreg, PETSC_IGNORE, PETSC_IGNORE); >>PetscPrintf(PETSC_COMM_SELF, "nnz %d Kreg %d\n", nnz[0], nz_Kreg); >> // prints nnz 11 Kreg 0 !!! >> } >> MatCopy(K_loc, Kreg, DIFFERENT_NONZERO_PATTERN); //fails: New nonzero at >> (0,0) caused a malloc! >> > > I think you want > > > http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatDuplicate.html > > which does it in one line. > > Matt > > >> >> PETSc complains about new nonzero - not surprisingly because >> MatAssemblyBegin/End filters zeros as I understand. >> But when I comment out MatAssemblyBegin/End, MatCopy complains that it is >> only for assembled matrices. >> >> I think that to call MatSetValues on all allocated nonzeros just to make >> them survive MatAssemblyBegin/End or to replace MatCopy call by loop over >> raw array is both quite awkward. >> Maybe one should be able to turn the filter in MatAssemblyBegin/End off. >> Or is there any other way out? >> >> BTW, what I need is to make a copy Kreg of given matrix K_loc but with >> few additional preallocated positions which are filled later. Is there some >> other convenient solution? >> >> Cheers, >> Vaclav Hapla >> > > > > -- > What most experimenters take for granted before they begin their > experiments is infinitely more interesting than any results to which their > experiments lead. > -- Norbert Wiener > > > > -- > > Vaclav Hapla > Research assistant > SPOMECH project <http://spomech.vsb.cz/> > Centre of Excellence IT4Innovations <http://www.it4i.eu/> > > tel.: (+420) 59 732 6291 > VSB-Technical University of Ostrava > 17.listopadu 15/2172 > 708 33 Ostrava-Poruba > Czech Republic > -- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener -- next part -- An HTML attachment was scrubbed... URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20120301/a796f192/attachment.html>
[petsc-dev] MatCopy to zero preallocated matrix
On Thu, Mar 1, 2012 at 17:39, Vaclav Hapla wrote: > OK, but: > 1. I don't understand what's the use case for MatCopy. > Copy to a complete matrix with same or different preallocation. > 2. I think it's not good that I can't do the thing without reallocations > though I have an apriori information where the new nonzeros will lie. > 3. Documentation of MatAssemblyBegin/End should definitely contain the > information about the zero filter. > There is no "zero filter". If you preallocate and set columns (inserting explicit zeros or whatever), they will not get filtered out. > > But OK, 2. is not a problem in my case :-) > Thank you, > -- next part -- An HTML attachment was scrubbed... URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20120301/1dda3ff4/attachment.html>
[petsc-dev] setup.py for building Python extensions involving PETSc
Hi, This may be of interest to people developing in Python and C/C++. I worked out a simple hack to use the petsc4py configuration to build Python extension modules with the correct petsc compilers and options. We had been doing this using some makefile tricks, but our approach wasn't as reliable as Lisandro's configuration of petsc4py. I had to hack two of the build_ext functions. You still have to give setup.py the --petsc-dir/--petsc-arch arguments.It might be a nice feature to install something similar in petsc4py so one could just do 'from petsc4py import PetscExtension'. Chris setup.py --- from distutils.core import setup sys.path.append('/path_to_petsc4py') from conf.petscconf import Extension as PetscExtension from conf.petscconf import build_ext as petsc_build_ext from conf.petscconf import config, build, build_src from conf.petscconf import test, sdist class my_build_ext(petsc_build_ext): def build_configuration(self, arch_list): from distutils.util import split_quoted, execute # template, variables = self.get_config_data(arch_list) config_data = template % variables # build_lib = self.build_lib dist_name = self.distribution.get_name() config_file = os.path.join(build_lib, dist_name,'petsc.cfg')#cek hack # def write_file(filename, data): fh = open(filename, 'w') try: fh.write(config_data) finally: fh.close() execute(write_file, (config_file, config_data), msg='writing %s' % config_file, verbose=self.verbose, dry_run=self.dry_run) def _copy_ext(self, ext): from copy import deepcopy extclass = ext.__class__ fullname = self.get_ext_fullname(ext.name) modpath = str.split(fullname, '.') pkgpath = os.path.join('', *modpath[0:-1]) name = modpath[-1] sources = list(ext.sources) newext = extclass(name, sources) newext.__dict__.update(deepcopy(ext.__dict__)) newext.name = name pkgpath=''#cek hack return pkgpath, newext setup(name='proteus', ext_package='proteus', package_data = {'proteus' : ['petsc.cfg'],}, cmdclass = {'config' : config, 'build' : build, 'build_src' : build_src, 'build_ext' : my_build_ext, 'test' : test, 'sdist' : sdist, }, ext_modules=[PetscExtension('flcbdfWrappers', ['proteus/flcbdfWrappersModule.cpp','proteus/mesh.cpp','proteus/meshio.cpp'], define_macros=[('PROTEUS_TRIANGLE_H',PROTEUS_TRIANGLE_H), ('PROTEUS_SUPERLU_H',PROTEUS_SUPERLU_H), ('CMRVEC_BOUNDS_CHECK',1), ('MV_VECTOR_BOUNDS_CHECK',1), ('PETSCVEC_BOUNDS_CHECK',1), ('F77_POST_UNDERSCORE',1), ('USE_BLAS',1)], include_dirs=['include',numpy.get_include(),PROTEUS_SUPERLU_INCLUDE_DIR,PROTEUS_TRIANGLE_INCLUDE_DIR]+PROTEUS_DAETK_INCLUDE_DIR+PROTEUS_PETSC_INCLUDE_DIRS+ [PROTEUS_MPI_INCLUDE_DIR], library_dirs=[PROTEUS_DAETK_LIB_DIR]+PROTEUS_PETSC_LIB_DIRS+[PROTEUS_MPI_LIB_DIR], libraries=['m',PROTEUS_DAETK_LIB]+PROTEUS_PETSC_LIBS+PROTEUS_MPI_LIBS, extra_link_args=PROTEUS_EXTRA_LINK_ARGS, extra_compile_args=PROTEUS_EXTRA_COMPILE_ARGS)]) -- next part -- An HTML attachment was scrubbed... URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20120301/523eee73/attachment.html>