Skip to content

Refactor mpi_cmd_for so we can just grab an MPI execution command #3259

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

Closed
wants to merge 3 commits into from

Conversation

ocaisa
Copy link
Member

@ocaisa ocaisa commented Mar 26, 2020

No description provided.

@ocaisa
Copy link
Member Author

ocaisa commented Mar 26, 2020

@boegel I've set this up so that it could be templated in an easyconfig but to do that I would need a toolchain instance for the easyconfig since I would rely on knowing the MPI family. Not sure where to do that though

None, 'store', None),
'mpi-exec-template': ("Template for MPI execution string to precede commands (template keys: %(nr_ranks)s",
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need a separate configuration setting?

We can just replace %(cmd)s with an empty string whenever we need just the mpirun ... bit without the trailing command?

@boegel boegel added this to the 4.x milestone Mar 28, 2020
@boegel
Copy link
Member

boegel commented Mar 28, 2020

@boegel I've set this up so that it could be templated in an easyconfig but to do that I would need a toolchain instance for the easyconfig since I would rely on knowing the MPI family. Not sure where to do that though

template values are collected via template_constant_dict, which is called from EasyConfig._generate_template_values.

You can pass down the toolchain instance from the EasyConfig instance down to template_constant_dict and put it to good use there, something like this:

template_values = template_constant_dict(self, ignore=ignore, toolchain=self.toolchain)

and then in template_constant_dict:

def template_constant_dict(..., toolchain=None):
    ...
    if toolchain is not None and hasattr(toolchain, 'mpi_cmd_for'):
        # use empty string as command, to only get prefix for commands to be run with mpirun
        mpi_cmd_prefix = toolchain.mpi_cmd_for('', 1)
        template_values['mpi_cmd_prefix'] = mpi_cmd_prefix
       
    

@ocaisa
Copy link
Member Author

ocaisa commented Mar 30, 2020

template values are collected via template_constant_dict, which is called from EasyConfig._generate_template_values.

You can pass down the toolchain instance from the EasyConfig instance down to template_constant_dict and put it to good use there, something like this:

template_values = template_constant_dict(self, ignore=ignore, toolchain=self.toolchain)

and then in template_constant_dict:

def template_constant_dict(..., toolchain=None):
    ...
    if toolchain is not None and hasattr(toolchain, 'mpi_cmd_for'):
        # use empty string as command, to only get prefix for commands to be run with mpirun
        mpi_cmd_prefix = toolchain.mpi_cmd_for('', 1)
        template_values['mpi_cmd_prefix'] = mpi_cmd_prefix
       
    

I could have done this without making any other changes...I think I might just replace this PR rather than row back all the other changes.

@ocaisa
Copy link
Member Author

ocaisa commented Mar 30, 2020

Closed in favour of #3264

@ocaisa ocaisa closed this Mar 30, 2020
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.

2 participants