Compare commits
6 Commits
develop
...
features/m
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5a23819165 | ||
![]() |
9df3b57f1f | ||
![]() |
788ad561bd | ||
![]() |
c8c025215d | ||
![]() |
1df6a3196a | ||
![]() |
7014eb3236 |
@ -30,6 +30,10 @@
|
|||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {"type": "array", "items": {"type": "string"}},
|
"items": {"type": "array", "items": {"type": "string"}},
|
||||||
},
|
},
|
||||||
|
"broadcast": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {"type": "array", "items": {"type": "string"}},
|
||||||
|
},
|
||||||
"exclude": {"type": "array", "items": {"type": "string"}},
|
"exclude": {"type": "array", "items": {"type": "string"}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -186,17 +186,28 @@ def _expand_matrix_constraints(matrix_config):
|
|||||||
new_row.append([r])
|
new_row.append([r])
|
||||||
expanded_rows.append(new_row)
|
expanded_rows.append(new_row)
|
||||||
|
|
||||||
|
# TODO someday: allow matrices inside `broadcast`
|
||||||
|
broadcast_rows = matrix_config.get("broadcast", [])
|
||||||
excludes = matrix_config.get("exclude", []) # only compute once
|
excludes = matrix_config.get("exclude", []) # only compute once
|
||||||
sigil = matrix_config.get("sigil", "")
|
sigil = matrix_config.get("sigil", "")
|
||||||
|
|
||||||
|
broadcast_constraints = list(itertools.product(*broadcast_rows))
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
for combo in itertools.product(*expanded_rows):
|
for combo in itertools.product(*expanded_rows):
|
||||||
# Construct a combined spec to test against excludes
|
# Construct a combined spec to test against excludes
|
||||||
flat_combo = [constraint for constraint_list in combo for constraint in constraint_list]
|
flat_combo = [constraint for constraint_list in combo for constraint in constraint_list]
|
||||||
flat_combo = [Spec(x) for x in flat_combo]
|
flat_combo = [Spec(x) for x in flat_combo]
|
||||||
|
|
||||||
test_spec = flat_combo[0].copy()
|
# If no broadcast, this is [(,)].
|
||||||
for constraint in flat_combo[1:]:
|
# It will run once, as required, and apply no constraints
|
||||||
|
for broadcast_combo in broadcast_constraints:
|
||||||
|
final_combo = [_apply_broadcast(spec.copy(), broadcast_combo) for spec in flat_combo]
|
||||||
|
|
||||||
|
# Check whether final spec is excluded
|
||||||
|
# requires constructing a spec from constraints
|
||||||
|
test_spec = final_combo[0].copy()
|
||||||
|
for constraint in final_combo[1:]:
|
||||||
test_spec.constrain(constraint)
|
test_spec.constrain(constraint)
|
||||||
|
|
||||||
# Abstract variants don't have normal satisfaction semantics
|
# Abstract variants don't have normal satisfaction semantics
|
||||||
@ -209,18 +220,30 @@ def _expand_matrix_constraints(matrix_config):
|
|||||||
spack.variant.substitute_abstract_variants(test_spec)
|
spack.variant.substitute_abstract_variants(test_spec)
|
||||||
except spack.variant.UnknownVariantError:
|
except spack.variant.UnknownVariantError:
|
||||||
pass
|
pass
|
||||||
if any(test_spec.satisfies(x) for x in excludes):
|
|
||||||
|
# actual exclusion check is here
|
||||||
|
if any(test_spec.satisfies(e) for e in excludes):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Apply sigil if applicable
|
||||||
if sigil:
|
if sigil:
|
||||||
flat_combo[0] = Spec(sigil + str(flat_combo[0]))
|
final_combo[0] = Spec(sigil + str(final_combo[0]))
|
||||||
|
|
||||||
# Add to list of constraints
|
# Add to list of constraints
|
||||||
results.append(flat_combo)
|
results.append(final_combo)
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
def _apply_broadcast(spec, constraints):
|
||||||
|
if constraints:
|
||||||
|
for node in spec.traverse():
|
||||||
|
if node.name:
|
||||||
|
for constraint in constraints:
|
||||||
|
node.constrain(constraint)
|
||||||
|
return spec
|
||||||
|
|
||||||
|
|
||||||
def _sigilify(item, sigil):
|
def _sigilify(item, sigil):
|
||||||
if isinstance(item, dict):
|
if isinstance(item, dict):
|
||||||
if sigil:
|
if sigil:
|
||||||
|
@ -214,3 +214,17 @@ def test_spec_list_constraints_with_structure(
|
|||||||
speclist = SpecList("specs", [matrix])
|
speclist = SpecList("specs", [matrix])
|
||||||
assert len(speclist.specs) == 1
|
assert len(speclist.specs) == 1
|
||||||
assert libdwarf_spec in speclist.specs[0]
|
assert libdwarf_spec in speclist.specs[0]
|
||||||
|
|
||||||
|
def test_spec_list_broadcast(self, mock_packages):
|
||||||
|
matrix = {
|
||||||
|
"matrix": [["mpileaks"], ["^callpath"]],
|
||||||
|
"broadcast": [["%gcc", "%clang"], ["+debug", "~debug"]],
|
||||||
|
"exclude": ["+debug%clang"],
|
||||||
|
}
|
||||||
|
speclist = SpecList("specs", [matrix])
|
||||||
|
|
||||||
|
assert len(speclist) == 3
|
||||||
|
for spec in speclist:
|
||||||
|
for node in spec.traverse():
|
||||||
|
assert node.compiler.name == spec.compiler.name
|
||||||
|
assert node.variants["debug"].value == spec.variants["debug"].value
|
||||||
|
Loading…
Reference in New Issue
Block a user