Repository: spack/spack

Issue:
Fix cuda arch conflicts in asp concretizer for dbcsr and cp2k
Ping @dev-zero. Currently on develop there's a problem with the new concretizer and dbcsr:

```bash
$ spack solve dbcsr
==> Error: invalid values for variant "cuda_arch" in package "dbcsr": ['10']
```

I've tracked it down to 1343a815c02421fb94ddb2b80af76d35760bf4c4, and the advise was to no redefine `cuda_arch` and instead use conflicts, so that the conflicts regarding `cuda_arch=10` in the parent class `CudaPackage` would still make sense.



Discussion:
Btw, before you reviewed I changed

```
all_cuda_archs = set(arch for arch in CudaPackage.cuda_arch_values)
```
was that necessary? Or is `set(CudaPackage.cuda_arch_values)` fine?
I'd probably write `dbcsr_conflicts = (a for a in CudaPackage.cuda_arch_values if a not in dbcsr_cuda_archs)` instead of using sets. Also, the check `conflicts('+cuda', when='cuda_arch=none')` will then be redundant.

What is missing is the `multi=False`, or is that covered implicitly? If yes, please add a comment somewhere. Neither DBCSR nor CP2K can at the moment support multiple GPUs at the same time (like other packages can do).

Other than that LGTM, could you also do the same for CP2K?
Thanks @dev-zero, yeah, multi=False got dropped :( it just takes the first element from the list. I'll add your suggestion.

Resolving patch:
diff --git a/var/spack/repos/builtin.mock/packages/external-buildable-with-variant/package.py b/var/spack/repos/builtin.mock/packages/external-buildable-with-variant/package.py
--- a/var/spack/repos/builtin.mock/packages/external-buildable-with-variant/package.py
+++ b/var/spack/repos/builtin.mock/packages/external-buildable-with-variant/package.py
@@ -11,5 +11,8 @@ class ExternalBuildableWithVariant(Package):
     url = "http://somewhere.com/module-1.0.tar.gz"
 
     version('1.0', '1234567890abcdef1234567890abcdef')
+    version('0.9', '1234567890abcdef1234567890abcdef')
 
     variant('baz', default=False, description='nope')
+
+    depends_on('c@1.0', when='@0.9')
diff --git a/var/spack/repos/builtin.mock/packages/test-dep-with-imposed-conditions/package.py b/var/spack/repos/builtin.mock/packages/test-dep-with-imposed-conditions/package.py
new file mode 100644
--- /dev/null
+++ b/var/spack/repos/builtin.mock/packages/test-dep-with-imposed-conditions/package.py
@@ -0,0 +1,17 @@
+# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack import *
+
+
+class TestDepWithImposedConditions(Package):
+    """Simple package with no dependencies"""
+
+    homepage = "http://www.example.com"
+    url = "http://www.example.com/e-1.0.tar.gz"
+
+    version('1.0', '0123456789abcdef0123456789abcdef')
+
+    depends_on('c@1.0', type='test')


Test patch:
diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py
--- a/lib/spack/spack/test/concretize.py
+++ b/lib/spack/spack/test/concretize.py
@@ -1044,7 +1044,7 @@ def test_dont_select_version_that_brings_more_variants_in(self):
         s = Spec('dep-with-variants-if-develop-root').concretized()
         assert s['dep-with-variants-if-develop'].satisfies('@1.0')
 
-    @pytest.mark.regression('20244')
+    @pytest.mark.regression('20244,20736')
     @pytest.mark.parametrize('spec_str,is_external,expected', [
         # These are all externals, and 0_8 is a version not in package.py
         ('externaltool@1.0', True, '@1.0'),
@@ -1056,6 +1056,10 @@ def test_dont_select_version_that_brings_more_variants_in(self):
         ('external-buildable-with-variant +baz', True, '@1.1.special +baz'),
         ('external-buildable-with-variant ~baz', False, '@1.0 ~baz'),
         ('external-buildable-with-variant@1.0: ~baz', False, '@1.0 ~baz'),
+        # This uses an external version that meets the condition for
+        # having an additional dependency, but the dependency shouldn't
+        # appear in the answer set
+        ('external-buildable-with-variant@0.9 +baz', True, '@0.9'),
     ])
     def test_external_package_versions(self, spec_str, is_external, expected):
         s = Spec(spec_str).concretized()
@@ -1086,3 +1090,11 @@ def test_reuse_installed_packages(
         ).concretized()
 
         assert root.dag_hash() == new_root.dag_hash()
+
+    @pytest.mark.regression('20784')
+    def test_concretization_of_test_dependencies(self):
+        # With clingo we emit dependency_conditions regardless of the type
+        # of the dependency. We need to ensure that there's at least one
+        # dependency type declared to infer that the dependency holds.
+        s = Spec('test-dep-with-imposed-conditions').concretized()
+        assert 'c' not in s
diff --git a/lib/spack/spack/test/data/config/packages.yaml b/lib/spack/spack/test/data/config/packages.yaml
--- a/lib/spack/spack/test/data/config/packages.yaml
+++ b/lib/spack/spack/test/data/config/packages.yaml
@@ -34,3 +34,5 @@ packages:
     externals:
       - spec: external-buildable-with-variant@1.1.special +baz
         prefix: /usr
+      - spec: external-buildable-with-variant@0.9 +baz
+        prefix: /usr
\ No newline at end of file