Skip to content
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

Overhaul parallel runs #188

Merged
merged 7 commits into from
Jan 27, 2023
Merged

Overhaul parallel runs #188

merged 7 commits into from
Jan 27, 2023

Conversation

yardasol
Copy link
Contributor

@yardasol yardasol commented Jan 19, 2023

Summary of changes

This PR adds support for flexible distributed memory runs on various machines with the addition of the mpi_args parameter. Specifically, this PR:

  • Deprecates the -n command line argument in favor of the mpi_args parameter.
  • Changes the -d command line argument to the more standard -s/--threads.
  • Updates docstrings adds machinery to handle the new parameter in Depcode.run_depletion_step(), SerpentDepcode.run_depletion_step(), and OpenMCDepcode.run_depletion_step() functions.
  • Adds some machinery to app.py to handle the new variables.
  • Update the docpages
  • Add null type to certain object properties in the input schema.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Required for Merging

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • My change is a source code change
    • I have added/modified tests to cover my changes
    • I have explained why my change does not require new/modified tests
  • My change is a user-facing change
    • I have recorded my changes in the changelog for the upcoming release
  • My change is exclusively related to the repository (e.g. GitHub actions workflows, PR/issue templates, etc.)
    • I have verified or justified that my change will work as intended.
  • All new and existing tests passed.
    • CI tests pass
    • Local tests pass (including Serpent2 integration tests)

Associated Issues and PRs

Associated Developers

  • Dev: @

Checklist for Reviewers

Reviewers should use this link to get to the
Review Checklist before they begin their review.

@yardasol yardasol changed the title Mpi arguments Overhaul parallel runs Jan 19, 2023
- remove the `core_number` and `node_number` arguments from Simulation;
  consistency changes
- Fix the input schema by adding multiple types
- Make the try-except block in read_main_input more robust
@yardasol yardasol marked this pull request as ready for review January 20, 2023 20:55
Copy link
Contributor

@LukeSeifert LukeSeifert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I had a few comments on some minor things.

Comment on lines +343 to +345
:type:
``string``, ``null``

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like these changes tie in with the changes to overhauling parallel runs. Consider adding a note to the PR about these changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea.

saltproc/app.py Outdated
Comment on lines 115 to 116
d : int
Number of threads to use for shared-memory parallelism.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace d with s as done previously

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

saltproc/app.py Outdated
depletion code simulation')
default=None,
help='Number of threads to use for shared-memory \
parallelism.')
parser.add_argument('-i', # main input file
type=str,
default=None,
help='path and name of SaltProc main input file')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Match capitalization in the help strings

@@ -270,12 +281,12 @@
"type": "boolean",
"default": false}
},
"default": {},
"required": ["sim_name"]
"required": ["sim_name", "db_name"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought db_name was previously made optional since there was a default setting?

"required": ["volume", "mass_flowrate", "power_levels", "depletion_timesteps", "timestep_units"]
}
},
"required": ["proc_input_file", "dot_input_file", "output_path", "depcode", "simulation", "reactor"]
"required": ["proc_input_file", "dot_input_file", "output_path", "mpi_args", "depcode", "simulation", "reactor"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come mpi_args is required, isn't it given a default value of None?

'--directory',
str(self.output_path)]
if mpi_args is not None:
args = mpi_args + args

print('Running %s' % (self.codename))
# TODO: Need to figure out how to adapt this to openmc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this TODO line still needed?

def run_depletion_step(self, cores, nodes):
"""Runs a depletion step in OpenMC as a subprocess with the given
parameters.
def run_depletion_step(self, mpi_args=None, threads=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see threads called in this function, is it needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's needed in the signature, but it isn't used in the function.

Comment on lines +441 to +442
if threads is not None:
args = args + ['-omp', str(threads)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come this isn't in OpenMC run_depletion_step?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There isn't currently a way to specify how many OpenMC threads to use when using depletion outside of an environment variable. Otherwise the transport simulation will use as many threads as there are on the machine/node.

@@ -27,13 +27,13 @@ def serpent_runtime(cwd, tmpdir_factory):
"""SaltProc objects for Serpent unit tests"""
saltproc_input = str(cwd / 'serpent_data' / 'tap_input.json')
depcode_input, simulation_input, reactor_input = \
read_main_input(saltproc_input)[3]
read_main_input(saltproc_input)[4]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rewrite this in a way that doesn't use a hard-coded value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of any, other than using -1 instead of 4.

@@ -65,7 +65,7 @@ def openmc_runtime(cwd, tmpdir_factory):
"""SaltProc objects for OpenMC unit tests"""
saltproc_input = str(cwd / 'openmc_data' / 'tap_input.json')
depcode_input, simulation_input, reactor_input = \
read_main_input(saltproc_input)[3]
read_main_input(saltproc_input)[4]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

@yardasol
Copy link
Contributor Author

@samgdotson @abachma2 bump

Copy link
Contributor

@LukeSeifert LukeSeifert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, let me know if you want me to merge.

Copy link
Contributor

@samgdotson samgdotson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have anything to add here, these are pretty straightforward changes. However, the abc.py file is still called abc.py which should be changd.

@yardasol
Copy link
Contributor Author

I don't have anything to add here, these are pretty straightforward changes. However, the abc.py file is still called abc.py which should be changd.

As I've stated before, this will be happening in a future PR, and there is already an issue in the repo for this.

@yardasol
Copy link
Contributor Author

@LukeSeifert is this good to merge?

@LukeSeifert LukeSeifert merged commit 419447d into arfc:master Jan 27, 2023
github-actions bot pushed a commit that referenced this pull request Jan 27, 2023
github-actions bot pushed a commit to khurrumsaleem/saltproc that referenced this pull request Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Enable use of mpiexec flags when executing depletion codes via SaltProc
3 participants