Skip to content

make variants in CudaPackage optional #14337

@glennpj

Description

@glennpj

I am not sure if there is a way to make variants optional or conditional but that would be nice to have for the CudaPackage class. That class provides conflicts management for cuda and compilers, which makes it very useful to include. However, it also includes two variants, cuda and cuda_arch that are not necessarily needed for all cuda enabled packages. For instance, a package that requires CUDA can use CudaPackage to take advantage of the compiler conflicts statements. However, if the package requires CUDA then the cuda variant does not make sense. That leads to needing another conflict statement in the package itself. See the gpu-burn package for an example.

class GpuBurn(MakefilePackage, CudaPackage):
...
    # This package uses CudaPackage to pick up the cuda_arch variant. A side
    # effect is that it also picks up the cuda variant, but cuda is required
    # for gpu-burn so is not really a variant.
    variant('cuda', 'True', description='Use CUDA; must be true')

    conflicts('~cuda', msg='gpu-burn requires cuda')
...

In the above case, the compiler conflicts statements and the cpu_arch variant are needed but not the cuda variant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cudafeatureA feature is missing in Spack

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions