Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Sundials package #5696

Merged
merged 7 commits into from
Oct 14, 2017
Merged

Update Sundials package #5696

merged 7 commits into from
Oct 14, 2017

Conversation

gardner48
Copy link
Member

Change to CMake subclass
Update web addresses
Add 3.0.0-beta-2 version
Add new and missing Sundials configuration options
Add conflicts for some variants
Add xSDK configuration
Update lists of example program Makefiles

description='Use external BLAS/LAPACK libraries')
variant('klu', default=False,
description='Enable MPI parallel vector')
variant('openmp', default=False,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are openmp and pthread mutually exclusive (i.e. only one can be True at the same time)? If so, could you please rework it into a single variant:

variant(
        'threads', default='none',
        description='Multithreading support',
        values=('pthreads', 'openmp', 'none'),
        multi=False
    )

that's what we do with all blas/lapac (i.e. see openblas)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In our case openmp and pthread are not mutually exclusive options. Turning on these variants builds separate openmp and pthread vector modules that can be used together if a user wanted.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i see, thanks for explanation

description='Enable RAJA parallel vector')

# External libraries
variant('blas', default=False,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need internal blas at all? I would remove the two variants all together... Imaging what could happen if one uses sundials as a part of a bigger DAG (i.e. dealii) which uses petsc, trilinos, mumps etc where everyone use exactly the same Blas/Lapack, but now you would have different Blas/Lapack within sundials itself. So if you have dynamic linking, you can easily get into troubles because you don't have control over what blas/lapack is used within sundials (threaded / openmp or not).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generally, 99% packages in Spack do not build any dependencies themselves, look at petsc which is able to compile all of its dependencies but we provide them via Spack for a good reason.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another way to look at it is that Spack promises that there is one and only one version/variant/configuration of each dependency within the DAG. If you build internal Blas/Lapack, this is no longer the case...

Copy link
Member Author

@gardner48 gardner48 Oct 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sundials does not build an internal blas and only needs to link to a blas library when building with an external solver requires blas (e.g. superlu_mt). Activating the blas variant sets the path to whatever blas the user is providing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an external solver requires blas (e.g. superlu_mt).

oh, then you don't need these variants at all. If superlu_mt is there and it needs blas/lapack, you will have it in DAG.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tgamblin : if some dependency in the DAG needs blas/lapack, spec['blas'].libs will still work, right, meaning there is no need to declare that the root node depends on blas/lapack?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Activating the blas variant sets the path to whatever blas the user is providing.

atlernative is still to remove those variants and add something like

depends_on('blas', when='+superlu_mt')
depends_on('lapack', when='+superlu_mt')

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is also possible to build superlu_mt with its own internal blas so it doesn't necessarily depend on using blas. So it seems like we don't need the blas variant or the depends_on in the package.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is also possible to build superlu_mt with its own internal blas

that's bad for the reasons outlined above... Luckily by default it will use blas from Spack. Maybe you can make sure it is this way here by writing

depends_on(superlu_mt+blas,...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

superlu_mt encourages users to not use the internal blas unless they have to and since Spack will provides a blas installation your suggestion sounds like the way to go.

description='Install examples')

# Generic (std-c) math libraries (UNIX only)
variant('generic-math', default=True,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it work on macOS? if not, maybe set default = platfom!="darwin" or alike.

Copy link
Member Author

@gardner48 gardner48 Oct 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our CMake build links to std-c math libraries only if IF(UNIX) is true. This option is really for a unix user to turn this behavior off, otherwise it's not used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, ok. Just wanted to be sure that it won't break the build on macOS with default values (the current version of the package builds OK).

# ==========================================================================

# Build dependencies
depends_on('cmake', type='build')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's in CMakePackage already

Copy link
Member Author

@gardner48 gardner48 Oct 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'll remove this. It was left over from the original Sundials package which used Package rather than CMakePackage.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they only reason to keep this if you add some specific constraint on version of cmake. There are a couple of packages which do that.

Copy link
Member Author

@gardner48 gardner48 Oct 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do require at least CMake 2.8.1 and I'll update the depends to reflect that.


# MPI related dependencies
depends_on('mpi', when='+mpi')
depends_on('mpi', when='+hypre')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you build ~mpi+hypre? if not, there should be a conflict

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, this needs to be added as a conflict.

# MPI related dependencies
depends_on('mpi', when='+mpi')
depends_on('mpi', when='+hypre')
depends_on('mpi', when='+petsc')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, if +petsc~mpi does not make sense, declare a conflict

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here, I'll add a conflict.

# SUNDIALS xSDK Settings
# ==========================================================================

@when('xsdk-defaults=True')
Copy link
Member

@davydden davydden Oct 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you really need two different cmake_args? there is so much code duplication here!.. Can you not do some if/else within the same function based on xsdk-defaults? It would be much easier to maintain...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking over this again we don't really need the xsdk-defaults option in Spack since user's don't directly set the CMake variables. So I've removed this option and the related cmake_args function.


# External libraries
depends_on('hypre', when='+hypre')
depends_on('petsc', when='+petsc')
Copy link
Member

@davydden davydden Oct 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably you want petsc+mpi, as petsc can also be built without mpi.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I do, I'll update the dependency.

depends_on('lapack', when='+lapack')
depends_on('suite-sparse', when='+klu')
depends_on('superlu-mt+openmp', when='+superlu+openmp')
depends_on('superlu-mt+pthread', when='+superlu+pthread')
depends_on('superlu-mt+openmp', when='+superlu-mt+openmp')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you probably want to add a conflict that +superlu-mt needs either openmp or pthread, and if both are disabled you can't have sundials+supleru-mt.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These depend lines are not quite right since it is possible to use superlu-mt from Sundials without enabling openmp or pthreads (i.e. Sundials is run in serial but the linear solves with superlu_mt are threaded).

So what I need is to know is if superlu_mt was build with openmp or pthread and set our CMake variable accordingly. Is this the right way to do that

if spec.satisfies('^superlu-mt+openmp'):

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think it’s the right syntax

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above if works as expected for checking how superlu_mt was configured.

@davydden
Copy link
Member

btw, you may want to add yourself as a maintainer of sundials :

    maintainers = ['gardner48']

which would appear in spack info sundials.

variant('idas', default=True,
description='Enable IDAS')
variant('kinsol', default=True,
description='Enable KINSOL')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you turn them in an array and loop over them? (see lammps for an example)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion and the pointer to lammps. I've updated these options to an array of sundials solvers.

Remove blas variant as blas is only needed when used by an external
linear solver. Set related CMake blas variables as needed depending
enabled external linear solvers.

Add minimum required CMake version.

Additional conflicts and dependencies for external libraries based
on mpi, indextype, and precision.

Fix SuperLU_MT logic to check which threading type SuperLU_MT was
configured with.

Add maintaiers.

Change Sundials solver options to use an array of values.

Consistently use % for formatting.
Copy link
Member

@davydden davydden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for updating, some minor suggestions, otherwise LGTM.

url = "http://computation.llnl.gov/projects/sundials-suite-nonlinear-differential-algebraic-equation-solvers/download/sundials-2.6.2.tar.gz"
homepage = "https://computation.llnl.gov/projects/sundials"
url = "https://computation.llnl.gov/projects/sundials/download/sundials-2.7.0.tar.gz"
maintainers = ['cswoodward', 'gardner48']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

variant(
'precision',
default='double',
description='''real type precision''',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: i think it's enough to have a single ' on both sides

variant(
'indextype',
default='int64_t',
description='''index integer type''',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, a single '

'indextype',
default='int64_t',
description='''index integer type''',
values=('int32_t', 'int64_t'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be consistent with other packages (i.e. at least petsc, mump, superlu-dist, hypre), could you please make it into a single bool variant:

int64 [off]          True, False       Compile with 64bit indices

Copy link
Member Author

@gardner48 gardner48 Oct 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made this a single bool option but does the default need to be False? Prior to the current beta release sundials only supported 64bit indices.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prior to the current beta release sundials only supported 64bit indices.

i would say we shall keep it as True then, so that default values are working, i.e. spack install sundials should build.

And after you have a next stable release we can switch it to False by default to be consistent with defaults in other packages.

# Require that PETSc is built with MPI
depends_on('petsc+mpi', when='+petsc')

# Require that SuperLU_MT built with external blas
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!


def on_off(varstr):
return 'ON' if varstr in self.spec else 'OFF'

cmake_args = std_cmake_args[:]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, that's in CMakePackage already 👍

description='Enable PETSc MPI parallel vector')

# Library type
variant('shared', default=True,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, there is currently a discussion in Spack on how to unify static/shared #5269 If you have any preferences where that go, please feel free to join the discussion


# External libraries
variant('lapack', default=False,
description='Enable LAPACK direct solvers')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so that's something you use in Sundials regardless of superlu_mt or alike? So that's indeed a build option?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this activates interfaces to use LAPACKdense or banded solvers for linear systems that arise inside sundials time integrators and nonlinear solvers.

@davydden
Copy link
Member

@junghans ping.

@tgamblin tgamblin added the xSDK label Oct 12, 2017
@davydden
Copy link
Member

@junghans since you requested changes to this PR, do you have further comments?

@tgamblin
Copy link
Member

@junghans

@junghans junghans merged commit f885c89 into spack:develop Oct 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants