-
Notifications
You must be signed in to change notification settings - Fork 8
Issue #1785 Add writing the HPC input file #1790
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| from typing import List, NamedTuple | ||
| from typing import List, NamedTuple, Optional | ||
|
|
||
| import numpy as np | ||
|
|
||
|
|
@@ -9,9 +9,13 @@ | |
| class PartitionInfo(NamedTuple): | ||
| active_domain: GridDataArray | ||
| id: int | ||
| mpi_rank: int | ||
|
|
||
|
|
||
| def create_partition_info(submodel_labels: GridDataArray) -> List[PartitionInfo]: | ||
| def create_partition_info( | ||
| submodel_labels: GridDataArray, | ||
| submodel_label_to_mpi_rank: Optional[dict[int, int]] = None, | ||
| ) -> List[PartitionInfo]: | ||
| """ | ||
| A PartitionInfo is used to partition a model or package. The partition | ||
| info's of a domain are created using a submodel_labels array. The | ||
|
|
@@ -31,8 +35,19 @@ def create_partition_info(submodel_labels: GridDataArray) -> List[PartitionInfo] | |
| active_domain = ones_like(active_domain).where(active_domain.notnull(), 0) | ||
| active_domain = active_domain.astype(submodel_labels.dtype) | ||
|
|
||
| if submodel_label_to_mpi_rank is not None: | ||
| if label_id not in submodel_label_to_mpi_rank: | ||
| raise ValueError( | ||
| f"Label {label_id} not found in the MPI process mapping." | ||
| ) | ||
| mpi_rank = submodel_label_to_mpi_rank[label_id] | ||
| if mpi_rank < 0: | ||
| raise ValueError(f"Negative MPI rank of {mpi_rank} is not allowed.") | ||
| else: | ||
| mpi_rank = -1 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really like sentinel values to indicate the |
||
|
|
||
| submodel_partition_info = PartitionInfo( | ||
| id=label_id, active_domain=active_domain | ||
| id=label_id, mpi_rank=mpi_rank, active_domain=active_domain | ||
| ) | ||
| partition_infos.append(submodel_partition_info) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -300,3 +300,14 @@ def _get_transport_models( | |
| for model_name, model in models.items() | ||
| if isinstance(model, GroundwaterTransportModel) | ||
| ] | ||
|
|
||
| def _get_model_to_mpi_rank_mapping(self) -> dict[str, int]: | ||
| mpi_mapping = {} | ||
|
|
||
| for id, model_dict in self._partition_id_to_models.items(): | ||
| mpi_rank = self.partition_info[id].mpi_rank | ||
| if mpi_rank > 0: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in the code in |
||
| for model_name in model_dict.keys(): | ||
| mpi_mapping[model_name] = mpi_rank | ||
|
|
||
| return mpi_mapping | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| begin options | ||
| {% if print_tabe is defined %} print_table | ||
| {% endif -%} | ||
| end options | ||
|
|
||
| begin partitions | ||
| {% for mname, mrank in partitions %} {{mname}} {{mrank}} | ||
| {% endfor -%} | ||
| end partitions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See other comment on line R47 in this file