why not a single PETSc library

Lisandro Dalcin dalcinl at gmail.com
Tue Jun 9 17:19:12 CDT 2009


On Tue, Jun 9, 2009 at 6:59 PM, Matthew Knepley<knepley at gmail.com> wrote:
> I would ask: why is anything ever split up? Why not just munge everything in
> the
> entire Linux distribution into one big fat library?
>
>   Matt

Mat, that's is not a fair example...

A single library will solve a problem you can exercise with the Python
code below (using a shared libs build)

import os
PETSC_DIR = os.getenv('PETSC_DIR')
PETSC_ARCH = os.getenv('PETSC_ARCH')
PETSC_LIB_DIR = os.path.join(PETSC_DIR, PETSC_ARCH, 'lib')

import ctypes
MODE = ctypes.RTLD_LOCAL
#MODE = ctypes.RTLD_GLOBAL
libpetsc    = ctypes.CDLL(os.path.join(PETSC_LIB_DIR, 'libpetsc.so'), mode=MODE)
libpetscvec = ctypes.CDLL(os.path.join(PETSC_LIB_DIR,
'libpetscvec.so'), mode=MODE)


The only way you can dlopen() PETSc libraries is by using RTLD_GLOBAL
(uncomment an you will see it works in that case).


Moreover, see this, just run on my rather old box, with a debug build
and many external packages (= big libraries):

$ time python -c "from petsc4py import PETSc"
real	0m0.791s
user	0m0.175s
sys	0m0.081s

$ time python -c "from petsc4py import PETSc"
real	0m0.341s
user	0m0.199s
sys	0m0.072s


So the time required to load the whole PETSc (at least what petsc4py
uses, that IMHO is a lot) is really tiny compared to any practical
run.



>
> On Tue, Jun 9, 2009 at 4:55 PM, Jed Brown <jed at 59a2.org> wrote:
>>
>> Barry Smith wrote:
>> >
>> > On Jun 9, 2009, at 4:37 PM, Matthew Knepley wrote:
>> >
>> >> I think its legitimate to only want some of our crap.
>> >
>> >    You only get what you use; if you only use KSP then only the KSP and
>> > below stuff will be pulled into your program, so what is the problem?
>>
>> With shared libs, you always get the whole thing.  Of course, the unused
>> part may only be mapped into virtual memory (thus never physically
>> present).  I suspect it's fairly rare to use less than Mat or KSP at
>> which point the presence of SNES/TS/DM is minimal overhead.  A single
>> lib is certainly easier to find with configure scripts.
>>
>> Jed
>>
>
>
>
> --
> 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
>



-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594



More information about the petsc-dev mailing list