-
Notifications
You must be signed in to change notification settings - Fork 43
Enable Initializing Second Experiment From Library #931
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
6ae163c
Add breaking test and example of how to get around it
michaelmckinsey1 9553029
Merge branch 'develop' into experiment-init-bug
michaelmckinsey1 997dcf5
Merge branch 'develop' into experiment-init-bug
michaelmckinsey1 b8778ec
Merge branch 'develop' into experiment-init-bug
michaelmckinsey1 c9ca1ea
fix check with spec satisfies
michaelmckinsey1 4015da7
Refactor programming models
michaelmckinsey1 1e25f53
Merge branch 'develop' into experiment-init-bug
michaelmckinsey1 2792c85
Fix bugs
michaelmckinsey1 f34dd94
Merge remote-tracking branch 'origin/develop' into experiment-init-bug
michaelmckinsey1 2ac8f79
Fix test
michaelmckinsey1 1a6aa6e
change names
michaelmckinsey1 da502e6
update other experiments
michaelmckinsey1 863b217
Fix deprecated arg
michaelmckinsey1 9293f69
fix commands
michaelmckinsey1 312c48d
Update docs
michaelmckinsey1 336a7c0
Deprecate check
michaelmckinsey1 feb04a4
Find and replace
michaelmckinsey1 56b7c7c
lint
michaelmckinsey1 27b1f5f
isort
michaelmckinsey1 b9a651c
flake
michaelmckinsey1 b97bfff
lint
michaelmckinsey1 b4e1bb7
Merge branch 'develop' into experiment-init-bug
pearce8 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| # Copyright 2023 Lawrence Livermore National Security, LLC and other | ||
| # Benchpark Project Developers. See the top-level COPYRIGHT file for details. | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
|
|
||
| from benchpark.error import BenchparkError | ||
| from benchpark.directives import variant, requires | ||
| from benchpark.experiment import ExperimentHelper | ||
| from enum import Enum | ||
|
|
||
|
|
||
| class ModelsType(Enum): | ||
| Mpionly = "mpi" | ||
| Openmp = "openmp" | ||
| Cuda = "cuda" | ||
| Rocm = "rocm" | ||
|
|
||
|
|
||
| def Models(*types): | ||
| for ty in types: | ||
| if not isinstance(ty, ModelsType): | ||
| raise ValueError(f"Invalid programming model: {ty}") | ||
|
|
||
| # Normalize once so we can reuse | ||
| _available = tuple(t.value for t in types) | ||
|
|
||
| class BaseModel: | ||
| requires("mpi", when="+mpi") | ||
| requires("rocm", when="+rocm") | ||
| requires("cuda", when="+cuda") | ||
| requires("openmp", when="+openmp") | ||
|
|
||
| variant("mpi", default=True, description="Run with MPI") | ||
| variant("rocm", default=False, description="Build and run with ROCm") | ||
| variant("cuda", default=False, description="Build and run with CUDA") | ||
| variant("openmp", default=False, description="Build and run with OpenMP") | ||
|
|
||
| # Class-level list of supported models for any class that includes this mixin | ||
| _available_programming_models = _available | ||
|
|
||
| # Handy instance-level property (works on Experiment instances) | ||
| @property | ||
| def available_programming_models(self): | ||
| # If multiple mixins contribute, merge them from MRO at runtime | ||
| models = set() | ||
| for cls in type(self).mro(): | ||
| models.update(getattr(cls, "_available_programming_models", ())) | ||
| return tuple(sorted(models)) | ||
|
|
||
| # Quick check helper | ||
| @staticmethod | ||
| def supports_model(name: str) -> bool: | ||
| return name in _available | ||
|
|
||
| # Helper class (unchanged except for optional new method) | ||
| class Helper(ExperimentHelper): | ||
| def get_helper_name_prefix(self): | ||
| models = [] | ||
| for s in [ | ||
| ModelsType.Mpionly.value, | ||
| ModelsType.Openmp.value, | ||
| ModelsType.Cuda.value, | ||
| ModelsType.Rocm.value, | ||
| ]: | ||
| if self.spec.satisfies("+" + s): | ||
| models.append(s) | ||
| if len(models) > 0: | ||
| return models | ||
| return "no_model" | ||
|
|
||
| # Optional: expose *available* (not selected) models via helper, too | ||
| def get_available_models(self): | ||
| models = set() | ||
| for cls in type(self).__mro__: | ||
| models.update(getattr(cls, "_available_programming_models", ())) | ||
| return tuple(sorted(models)) | ||
|
|
||
| return type( | ||
| "ProgrammingModel", | ||
| (BaseModel,), | ||
| { | ||
| "Helper": Helper, | ||
| }, | ||
| ) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # Copyright 2023 Lawrence Livermore National Security, LLC and other | ||
| # Benchpark Project Developers. See the top-level COPYRIGHT file for details. | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import pytest | ||
|
|
||
| import benchpark.spec | ||
| from benchpark.error import BenchparkError | ||
|
|
||
|
|
||
| def test_programming_model_checks(): | ||
| # babelstream mpi-only not valid | ||
| with pytest.raises(BenchparkError, match=r"mpi.*are not valid programming models"): | ||
| spec = benchpark.spec.ExperimentSpec("babelstream").concretize() | ||
| experiment = spec.experiment # noqa: F841 | ||
|
|
||
| # stream+openmp not valid | ||
| with pytest.raises(Exception, match="not a valid variant"): | ||
| spec = benchpark.spec.ExperimentSpec( | ||
| "stream+openmp workload=stream" | ||
| ).concretize() | ||
| experiment = spec.experiment | ||
|
|
||
| # Multiple scaling options not valid | ||
| with pytest.raises(BenchparkError, match="cannot specify multiple scaling options"): | ||
| spec = benchpark.spec.ExperimentSpec("kripke+strong+weak").concretize() | ||
| experiment = spec.experiment |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.