FluidityProject / fluidity

Fluidity
http://fluidity-project.org
Other
365 stars 115 forks source link

Configure not picking up BLAS and LAPACK from PETSc #294

Open gnikit opened 3 years ago

gnikit commented 3 years ago

This is more of an open-ended question, but I think it might be worth pointing it out. I have been playing with PETSc and Intel's new OneAPI toolkit to try and speed some of my local calculations. In doing so I realised that when using gfortran Fluidity picks up BLAS & LAPACK only from their standard library locations i.e. when installed through APT, which does not make much sense since we can also install them through PETSc and that should also be picked up.

Moreover, attempting to specify the location of BLAS & LAPACK with --with-blas= and --with-lapack= will fail because these options are not transferred over when ./configure is called for libadaptivity, which in turn will attempt to pick up BLAS & LAPACK from the system location, causing it either to fail or link against a different set of libs (possibly true for Judy as well). This can be circumvented by passing to the ./configure LIBS="-L$PETSC_DIR/$PETSC_ARCH/lib":${LIBS}, but then the real question is why have --with-blas, --with-lapack if they do not work as expected and in some cases can lead to Fluidity using multiple versions of BLAS & LAPACK?

stephankramer commented 3 years ago

Picking up blas and lapack from what has been specified in petsc may not be a bad idea as default. Just putting my grumpy code-conservative hat back on though: configure scripts in general are notoriously sensitive; any change you make, it will break someone's configure on some obscure system that has things installed just a little differently, and you get to spend hours figuring out why it doesn't work for them. So this might be something we should consider if/when we change over to cmake?

Final point: when you're optimizing your code make sure you profile first ("premature optimization is the root of all evil") - I would be surprised if fluidity itself you will spend much time at all in blas/lapack - in petsc you may spend some more time in it but this will depend a lot on your solver configuration (I think mumps does use it a fair bit, also for some block sor smoothing it may be useful). Speaking very generally, the use of blas/lapack will be a lot less important in unstructured mesh models.